mutation.go 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901
  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/compapiasynctask"
  19. "wechat-api/ent/contact"
  20. "wechat-api/ent/contactfield"
  21. "wechat-api/ent/contactfieldtemplate"
  22. "wechat-api/ent/creditbalance"
  23. "wechat-api/ent/creditusage"
  24. "wechat-api/ent/custom_types"
  25. "wechat-api/ent/employee"
  26. "wechat-api/ent/employeeconfig"
  27. "wechat-api/ent/label"
  28. "wechat-api/ent/labelrelationship"
  29. "wechat-api/ent/labeltagging"
  30. "wechat-api/ent/message"
  31. "wechat-api/ent/messagerecords"
  32. "wechat-api/ent/msg"
  33. "wechat-api/ent/payrecharge"
  34. "wechat-api/ent/predicate"
  35. "wechat-api/ent/server"
  36. "wechat-api/ent/sopnode"
  37. "wechat-api/ent/sopstage"
  38. "wechat-api/ent/soptask"
  39. "wechat-api/ent/token"
  40. "wechat-api/ent/tutorial"
  41. "wechat-api/ent/usagedetail"
  42. "wechat-api/ent/usagestatisticday"
  43. "wechat-api/ent/usagestatistichour"
  44. "wechat-api/ent/usagestatisticmonth"
  45. "wechat-api/ent/usagetotal"
  46. "wechat-api/ent/whatsapp"
  47. "wechat-api/ent/whatsappchannel"
  48. "wechat-api/ent/workexperience"
  49. "wechat-api/ent/wpchatroom"
  50. "wechat-api/ent/wpchatroommember"
  51. "wechat-api/ent/wx"
  52. "wechat-api/ent/wxcard"
  53. "wechat-api/ent/wxcarduser"
  54. "wechat-api/ent/wxcardvisit"
  55. "wechat-api/ent/xunji"
  56. "wechat-api/ent/xunjiservice"
  57. "entgo.io/ent"
  58. "entgo.io/ent/dialect/sql"
  59. )
  60. const (
  61. // Operation types.
  62. OpCreate = ent.OpCreate
  63. OpDelete = ent.OpDelete
  64. OpDeleteOne = ent.OpDeleteOne
  65. OpUpdate = ent.OpUpdate
  66. OpUpdateOne = ent.OpUpdateOne
  67. // Node types.
  68. TypeAgent = "Agent"
  69. TypeAgentBase = "AgentBase"
  70. TypeAliyunAvatar = "AliyunAvatar"
  71. TypeAllocAgent = "AllocAgent"
  72. TypeApiKey = "ApiKey"
  73. TypeBatchMsg = "BatchMsg"
  74. TypeCategory = "Category"
  75. TypeChatRecords = "ChatRecords"
  76. TypeChatSession = "ChatSession"
  77. TypeCompapiAsynctask = "CompapiAsynctask"
  78. TypeContact = "Contact"
  79. TypeContactField = "ContactField"
  80. TypeContactFieldTemplate = "ContactFieldTemplate"
  81. TypeCreditBalance = "CreditBalance"
  82. TypeCreditUsage = "CreditUsage"
  83. TypeEmployee = "Employee"
  84. TypeEmployeeConfig = "EmployeeConfig"
  85. TypeLabel = "Label"
  86. TypeLabelRelationship = "LabelRelationship"
  87. TypeLabelTagging = "LabelTagging"
  88. TypeMessage = "Message"
  89. TypeMessageRecords = "MessageRecords"
  90. TypeMsg = "Msg"
  91. TypePayRecharge = "PayRecharge"
  92. TypeServer = "Server"
  93. TypeSopNode = "SopNode"
  94. TypeSopStage = "SopStage"
  95. TypeSopTask = "SopTask"
  96. TypeToken = "Token"
  97. TypeTutorial = "Tutorial"
  98. TypeUsageDetail = "UsageDetail"
  99. TypeUsageStatisticDay = "UsageStatisticDay"
  100. TypeUsageStatisticHour = "UsageStatisticHour"
  101. TypeUsageStatisticMonth = "UsageStatisticMonth"
  102. TypeUsageTotal = "UsageTotal"
  103. TypeWhatsapp = "Whatsapp"
  104. TypeWhatsappChannel = "WhatsappChannel"
  105. TypeWorkExperience = "WorkExperience"
  106. TypeWpChatroom = "WpChatroom"
  107. TypeWpChatroomMember = "WpChatroomMember"
  108. TypeWx = "Wx"
  109. TypeWxCard = "WxCard"
  110. TypeWxCardUser = "WxCardUser"
  111. TypeWxCardVisit = "WxCardVisit"
  112. TypeXunji = "Xunji"
  113. TypeXunjiService = "XunjiService"
  114. )
  115. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  116. type AgentMutation struct {
  117. config
  118. op Op
  119. typ string
  120. id *uint64
  121. created_at *time.Time
  122. updated_at *time.Time
  123. deleted_at *time.Time
  124. name *string
  125. role *string
  126. status *int
  127. addstatus *int
  128. background *string
  129. examples *string
  130. organization_id *uint64
  131. addorganization_id *int64
  132. dataset_id *string
  133. collection_id *string
  134. model *string
  135. api_base *string
  136. api_key *string
  137. _type *int
  138. add_type *int
  139. clearedFields map[string]struct{}
  140. wx_agent map[uint64]struct{}
  141. removedwx_agent map[uint64]struct{}
  142. clearedwx_agent bool
  143. token_agent map[uint64]struct{}
  144. removedtoken_agent map[uint64]struct{}
  145. clearedtoken_agent bool
  146. wa_agent map[uint64]struct{}
  147. removedwa_agent map[uint64]struct{}
  148. clearedwa_agent bool
  149. xjs_agent map[uint64]struct{}
  150. removedxjs_agent map[uint64]struct{}
  151. clearedxjs_agent bool
  152. key_agent map[uint64]struct{}
  153. removedkey_agent map[uint64]struct{}
  154. clearedkey_agent bool
  155. done bool
  156. oldValue func(context.Context) (*Agent, error)
  157. predicates []predicate.Agent
  158. }
  159. var _ ent.Mutation = (*AgentMutation)(nil)
  160. // agentOption allows management of the mutation configuration using functional options.
  161. type agentOption func(*AgentMutation)
  162. // newAgentMutation creates new mutation for the Agent entity.
  163. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  164. m := &AgentMutation{
  165. config: c,
  166. op: op,
  167. typ: TypeAgent,
  168. clearedFields: make(map[string]struct{}),
  169. }
  170. for _, opt := range opts {
  171. opt(m)
  172. }
  173. return m
  174. }
  175. // withAgentID sets the ID field of the mutation.
  176. func withAgentID(id uint64) agentOption {
  177. return func(m *AgentMutation) {
  178. var (
  179. err error
  180. once sync.Once
  181. value *Agent
  182. )
  183. m.oldValue = func(ctx context.Context) (*Agent, error) {
  184. once.Do(func() {
  185. if m.done {
  186. err = errors.New("querying old values post mutation is not allowed")
  187. } else {
  188. value, err = m.Client().Agent.Get(ctx, id)
  189. }
  190. })
  191. return value, err
  192. }
  193. m.id = &id
  194. }
  195. }
  196. // withAgent sets the old Agent of the mutation.
  197. func withAgent(node *Agent) agentOption {
  198. return func(m *AgentMutation) {
  199. m.oldValue = func(context.Context) (*Agent, error) {
  200. return node, nil
  201. }
  202. m.id = &node.ID
  203. }
  204. }
  205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  206. // executed in a transaction (ent.Tx), a transactional client is returned.
  207. func (m AgentMutation) Client() *Client {
  208. client := &Client{config: m.config}
  209. client.init()
  210. return client
  211. }
  212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  213. // it returns an error otherwise.
  214. func (m AgentMutation) Tx() (*Tx, error) {
  215. if _, ok := m.driver.(*txDriver); !ok {
  216. return nil, errors.New("ent: mutation is not running in a transaction")
  217. }
  218. tx := &Tx{config: m.config}
  219. tx.init()
  220. return tx, nil
  221. }
  222. // SetID sets the value of the id field. Note that this
  223. // operation is only accepted on creation of Agent entities.
  224. func (m *AgentMutation) SetID(id uint64) {
  225. m.id = &id
  226. }
  227. // ID returns the ID value in the mutation. Note that the ID is only available
  228. // if it was provided to the builder or after it was returned from the database.
  229. func (m *AgentMutation) ID() (id uint64, exists bool) {
  230. if m.id == nil {
  231. return
  232. }
  233. return *m.id, true
  234. }
  235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  236. // That means, if the mutation is applied within a transaction with an isolation level such
  237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  238. // or updated by the mutation.
  239. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  240. switch {
  241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  242. id, exists := m.ID()
  243. if exists {
  244. return []uint64{id}, nil
  245. }
  246. fallthrough
  247. case m.op.Is(OpUpdate | OpDelete):
  248. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  249. default:
  250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  251. }
  252. }
  253. // SetCreatedAt sets the "created_at" field.
  254. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  255. m.created_at = &t
  256. }
  257. // CreatedAt returns the value of the "created_at" field in the mutation.
  258. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  259. v := m.created_at
  260. if v == nil {
  261. return
  262. }
  263. return *v, true
  264. }
  265. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  266. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  268. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  269. if !m.op.Is(OpUpdateOne) {
  270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  271. }
  272. if m.id == nil || m.oldValue == nil {
  273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  274. }
  275. oldValue, err := m.oldValue(ctx)
  276. if err != nil {
  277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  278. }
  279. return oldValue.CreatedAt, nil
  280. }
  281. // ResetCreatedAt resets all changes to the "created_at" field.
  282. func (m *AgentMutation) ResetCreatedAt() {
  283. m.created_at = nil
  284. }
  285. // SetUpdatedAt sets the "updated_at" field.
  286. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  287. m.updated_at = &t
  288. }
  289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  290. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  291. v := m.updated_at
  292. if v == nil {
  293. return
  294. }
  295. return *v, true
  296. }
  297. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  298. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  300. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  301. if !m.op.Is(OpUpdateOne) {
  302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  303. }
  304. if m.id == nil || m.oldValue == nil {
  305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  306. }
  307. oldValue, err := m.oldValue(ctx)
  308. if err != nil {
  309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  310. }
  311. return oldValue.UpdatedAt, nil
  312. }
  313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  314. func (m *AgentMutation) ResetUpdatedAt() {
  315. m.updated_at = nil
  316. }
  317. // SetDeletedAt sets the "deleted_at" field.
  318. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  319. m.deleted_at = &t
  320. }
  321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  322. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  323. v := m.deleted_at
  324. if v == nil {
  325. return
  326. }
  327. return *v, true
  328. }
  329. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  330. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  332. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  333. if !m.op.Is(OpUpdateOne) {
  334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  335. }
  336. if m.id == nil || m.oldValue == nil {
  337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  338. }
  339. oldValue, err := m.oldValue(ctx)
  340. if err != nil {
  341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  342. }
  343. return oldValue.DeletedAt, nil
  344. }
  345. // ClearDeletedAt clears the value of the "deleted_at" field.
  346. func (m *AgentMutation) ClearDeletedAt() {
  347. m.deleted_at = nil
  348. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  349. }
  350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  351. func (m *AgentMutation) DeletedAtCleared() bool {
  352. _, ok := m.clearedFields[agent.FieldDeletedAt]
  353. return ok
  354. }
  355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  356. func (m *AgentMutation) ResetDeletedAt() {
  357. m.deleted_at = nil
  358. delete(m.clearedFields, agent.FieldDeletedAt)
  359. }
  360. // SetName sets the "name" field.
  361. func (m *AgentMutation) SetName(s string) {
  362. m.name = &s
  363. }
  364. // Name returns the value of the "name" field in the mutation.
  365. func (m *AgentMutation) Name() (r string, exists bool) {
  366. v := m.name
  367. if v == nil {
  368. return
  369. }
  370. return *v, true
  371. }
  372. // OldName returns the old "name" field's value of the Agent entity.
  373. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  375. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  376. if !m.op.Is(OpUpdateOne) {
  377. return v, errors.New("OldName is only allowed on UpdateOne operations")
  378. }
  379. if m.id == nil || m.oldValue == nil {
  380. return v, errors.New("OldName requires an ID field in the mutation")
  381. }
  382. oldValue, err := m.oldValue(ctx)
  383. if err != nil {
  384. return v, fmt.Errorf("querying old value for OldName: %w", err)
  385. }
  386. return oldValue.Name, nil
  387. }
  388. // ResetName resets all changes to the "name" field.
  389. func (m *AgentMutation) ResetName() {
  390. m.name = nil
  391. }
  392. // SetRole sets the "role" field.
  393. func (m *AgentMutation) SetRole(s string) {
  394. m.role = &s
  395. }
  396. // Role returns the value of the "role" field in the mutation.
  397. func (m *AgentMutation) Role() (r string, exists bool) {
  398. v := m.role
  399. if v == nil {
  400. return
  401. }
  402. return *v, true
  403. }
  404. // OldRole returns the old "role" field's value of the Agent entity.
  405. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  407. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  408. if !m.op.Is(OpUpdateOne) {
  409. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  410. }
  411. if m.id == nil || m.oldValue == nil {
  412. return v, errors.New("OldRole requires an ID field in the mutation")
  413. }
  414. oldValue, err := m.oldValue(ctx)
  415. if err != nil {
  416. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  417. }
  418. return oldValue.Role, nil
  419. }
  420. // ClearRole clears the value of the "role" field.
  421. func (m *AgentMutation) ClearRole() {
  422. m.role = nil
  423. m.clearedFields[agent.FieldRole] = struct{}{}
  424. }
  425. // RoleCleared returns if the "role" field was cleared in this mutation.
  426. func (m *AgentMutation) RoleCleared() bool {
  427. _, ok := m.clearedFields[agent.FieldRole]
  428. return ok
  429. }
  430. // ResetRole resets all changes to the "role" field.
  431. func (m *AgentMutation) ResetRole() {
  432. m.role = nil
  433. delete(m.clearedFields, agent.FieldRole)
  434. }
  435. // SetStatus sets the "status" field.
  436. func (m *AgentMutation) SetStatus(i int) {
  437. m.status = &i
  438. m.addstatus = nil
  439. }
  440. // Status returns the value of the "status" field in the mutation.
  441. func (m *AgentMutation) Status() (r int, exists bool) {
  442. v := m.status
  443. if v == nil {
  444. return
  445. }
  446. return *v, true
  447. }
  448. // OldStatus returns the old "status" field's value of the Agent entity.
  449. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  451. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  452. if !m.op.Is(OpUpdateOne) {
  453. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  454. }
  455. if m.id == nil || m.oldValue == nil {
  456. return v, errors.New("OldStatus requires an ID field in the mutation")
  457. }
  458. oldValue, err := m.oldValue(ctx)
  459. if err != nil {
  460. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  461. }
  462. return oldValue.Status, nil
  463. }
  464. // AddStatus adds i to the "status" field.
  465. func (m *AgentMutation) AddStatus(i int) {
  466. if m.addstatus != nil {
  467. *m.addstatus += i
  468. } else {
  469. m.addstatus = &i
  470. }
  471. }
  472. // AddedStatus returns the value that was added to the "status" field in this mutation.
  473. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  474. v := m.addstatus
  475. if v == nil {
  476. return
  477. }
  478. return *v, true
  479. }
  480. // ClearStatus clears the value of the "status" field.
  481. func (m *AgentMutation) ClearStatus() {
  482. m.status = nil
  483. m.addstatus = nil
  484. m.clearedFields[agent.FieldStatus] = struct{}{}
  485. }
  486. // StatusCleared returns if the "status" field was cleared in this mutation.
  487. func (m *AgentMutation) StatusCleared() bool {
  488. _, ok := m.clearedFields[agent.FieldStatus]
  489. return ok
  490. }
  491. // ResetStatus resets all changes to the "status" field.
  492. func (m *AgentMutation) ResetStatus() {
  493. m.status = nil
  494. m.addstatus = nil
  495. delete(m.clearedFields, agent.FieldStatus)
  496. }
  497. // SetBackground sets the "background" field.
  498. func (m *AgentMutation) SetBackground(s string) {
  499. m.background = &s
  500. }
  501. // Background returns the value of the "background" field in the mutation.
  502. func (m *AgentMutation) Background() (r string, exists bool) {
  503. v := m.background
  504. if v == nil {
  505. return
  506. }
  507. return *v, true
  508. }
  509. // OldBackground returns the old "background" field's value of the Agent entity.
  510. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  512. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  513. if !m.op.Is(OpUpdateOne) {
  514. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  515. }
  516. if m.id == nil || m.oldValue == nil {
  517. return v, errors.New("OldBackground requires an ID field in the mutation")
  518. }
  519. oldValue, err := m.oldValue(ctx)
  520. if err != nil {
  521. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  522. }
  523. return oldValue.Background, nil
  524. }
  525. // ClearBackground clears the value of the "background" field.
  526. func (m *AgentMutation) ClearBackground() {
  527. m.background = nil
  528. m.clearedFields[agent.FieldBackground] = struct{}{}
  529. }
  530. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  531. func (m *AgentMutation) BackgroundCleared() bool {
  532. _, ok := m.clearedFields[agent.FieldBackground]
  533. return ok
  534. }
  535. // ResetBackground resets all changes to the "background" field.
  536. func (m *AgentMutation) ResetBackground() {
  537. m.background = nil
  538. delete(m.clearedFields, agent.FieldBackground)
  539. }
  540. // SetExamples sets the "examples" field.
  541. func (m *AgentMutation) SetExamples(s string) {
  542. m.examples = &s
  543. }
  544. // Examples returns the value of the "examples" field in the mutation.
  545. func (m *AgentMutation) Examples() (r string, exists bool) {
  546. v := m.examples
  547. if v == nil {
  548. return
  549. }
  550. return *v, true
  551. }
  552. // OldExamples returns the old "examples" field's value of the Agent entity.
  553. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  555. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  556. if !m.op.Is(OpUpdateOne) {
  557. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  558. }
  559. if m.id == nil || m.oldValue == nil {
  560. return v, errors.New("OldExamples requires an ID field in the mutation")
  561. }
  562. oldValue, err := m.oldValue(ctx)
  563. if err != nil {
  564. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  565. }
  566. return oldValue.Examples, nil
  567. }
  568. // ClearExamples clears the value of the "examples" field.
  569. func (m *AgentMutation) ClearExamples() {
  570. m.examples = nil
  571. m.clearedFields[agent.FieldExamples] = struct{}{}
  572. }
  573. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  574. func (m *AgentMutation) ExamplesCleared() bool {
  575. _, ok := m.clearedFields[agent.FieldExamples]
  576. return ok
  577. }
  578. // ResetExamples resets all changes to the "examples" field.
  579. func (m *AgentMutation) ResetExamples() {
  580. m.examples = nil
  581. delete(m.clearedFields, agent.FieldExamples)
  582. }
  583. // SetOrganizationID sets the "organization_id" field.
  584. func (m *AgentMutation) SetOrganizationID(u uint64) {
  585. m.organization_id = &u
  586. m.addorganization_id = nil
  587. }
  588. // OrganizationID returns the value of the "organization_id" field in the mutation.
  589. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  590. v := m.organization_id
  591. if v == nil {
  592. return
  593. }
  594. return *v, true
  595. }
  596. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  597. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  599. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  600. if !m.op.Is(OpUpdateOne) {
  601. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  602. }
  603. if m.id == nil || m.oldValue == nil {
  604. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  605. }
  606. oldValue, err := m.oldValue(ctx)
  607. if err != nil {
  608. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  609. }
  610. return oldValue.OrganizationID, nil
  611. }
  612. // AddOrganizationID adds u to the "organization_id" field.
  613. func (m *AgentMutation) AddOrganizationID(u int64) {
  614. if m.addorganization_id != nil {
  615. *m.addorganization_id += u
  616. } else {
  617. m.addorganization_id = &u
  618. }
  619. }
  620. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  621. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  622. v := m.addorganization_id
  623. if v == nil {
  624. return
  625. }
  626. return *v, true
  627. }
  628. // ResetOrganizationID resets all changes to the "organization_id" field.
  629. func (m *AgentMutation) ResetOrganizationID() {
  630. m.organization_id = nil
  631. m.addorganization_id = nil
  632. }
  633. // SetDatasetID sets the "dataset_id" field.
  634. func (m *AgentMutation) SetDatasetID(s string) {
  635. m.dataset_id = &s
  636. }
  637. // DatasetID returns the value of the "dataset_id" field in the mutation.
  638. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  639. v := m.dataset_id
  640. if v == nil {
  641. return
  642. }
  643. return *v, true
  644. }
  645. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  646. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  648. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  649. if !m.op.Is(OpUpdateOne) {
  650. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  651. }
  652. if m.id == nil || m.oldValue == nil {
  653. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  654. }
  655. oldValue, err := m.oldValue(ctx)
  656. if err != nil {
  657. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  658. }
  659. return oldValue.DatasetID, nil
  660. }
  661. // ResetDatasetID resets all changes to the "dataset_id" field.
  662. func (m *AgentMutation) ResetDatasetID() {
  663. m.dataset_id = nil
  664. }
  665. // SetCollectionID sets the "collection_id" field.
  666. func (m *AgentMutation) SetCollectionID(s string) {
  667. m.collection_id = &s
  668. }
  669. // CollectionID returns the value of the "collection_id" field in the mutation.
  670. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  671. v := m.collection_id
  672. if v == nil {
  673. return
  674. }
  675. return *v, true
  676. }
  677. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  678. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  680. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  681. if !m.op.Is(OpUpdateOne) {
  682. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  683. }
  684. if m.id == nil || m.oldValue == nil {
  685. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  686. }
  687. oldValue, err := m.oldValue(ctx)
  688. if err != nil {
  689. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  690. }
  691. return oldValue.CollectionID, nil
  692. }
  693. // ResetCollectionID resets all changes to the "collection_id" field.
  694. func (m *AgentMutation) ResetCollectionID() {
  695. m.collection_id = nil
  696. }
  697. // SetModel sets the "model" field.
  698. func (m *AgentMutation) SetModel(s string) {
  699. m.model = &s
  700. }
  701. // Model returns the value of the "model" field in the mutation.
  702. func (m *AgentMutation) Model() (r string, exists bool) {
  703. v := m.model
  704. if v == nil {
  705. return
  706. }
  707. return *v, true
  708. }
  709. // OldModel returns the old "model" field's value of the Agent entity.
  710. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  712. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  713. if !m.op.Is(OpUpdateOne) {
  714. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  715. }
  716. if m.id == nil || m.oldValue == nil {
  717. return v, errors.New("OldModel requires an ID field in the mutation")
  718. }
  719. oldValue, err := m.oldValue(ctx)
  720. if err != nil {
  721. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  722. }
  723. return oldValue.Model, nil
  724. }
  725. // ClearModel clears the value of the "model" field.
  726. func (m *AgentMutation) ClearModel() {
  727. m.model = nil
  728. m.clearedFields[agent.FieldModel] = struct{}{}
  729. }
  730. // ModelCleared returns if the "model" field was cleared in this mutation.
  731. func (m *AgentMutation) ModelCleared() bool {
  732. _, ok := m.clearedFields[agent.FieldModel]
  733. return ok
  734. }
  735. // ResetModel resets all changes to the "model" field.
  736. func (m *AgentMutation) ResetModel() {
  737. m.model = nil
  738. delete(m.clearedFields, agent.FieldModel)
  739. }
  740. // SetAPIBase sets the "api_base" field.
  741. func (m *AgentMutation) SetAPIBase(s string) {
  742. m.api_base = &s
  743. }
  744. // APIBase returns the value of the "api_base" field in the mutation.
  745. func (m *AgentMutation) APIBase() (r string, exists bool) {
  746. v := m.api_base
  747. if v == nil {
  748. return
  749. }
  750. return *v, true
  751. }
  752. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  753. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  755. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  756. if !m.op.Is(OpUpdateOne) {
  757. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  758. }
  759. if m.id == nil || m.oldValue == nil {
  760. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  761. }
  762. oldValue, err := m.oldValue(ctx)
  763. if err != nil {
  764. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  765. }
  766. return oldValue.APIBase, nil
  767. }
  768. // ClearAPIBase clears the value of the "api_base" field.
  769. func (m *AgentMutation) ClearAPIBase() {
  770. m.api_base = nil
  771. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  772. }
  773. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  774. func (m *AgentMutation) APIBaseCleared() bool {
  775. _, ok := m.clearedFields[agent.FieldAPIBase]
  776. return ok
  777. }
  778. // ResetAPIBase resets all changes to the "api_base" field.
  779. func (m *AgentMutation) ResetAPIBase() {
  780. m.api_base = nil
  781. delete(m.clearedFields, agent.FieldAPIBase)
  782. }
  783. // SetAPIKey sets the "api_key" field.
  784. func (m *AgentMutation) SetAPIKey(s string) {
  785. m.api_key = &s
  786. }
  787. // APIKey returns the value of the "api_key" field in the mutation.
  788. func (m *AgentMutation) APIKey() (r string, exists bool) {
  789. v := m.api_key
  790. if v == nil {
  791. return
  792. }
  793. return *v, true
  794. }
  795. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  796. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  798. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  799. if !m.op.Is(OpUpdateOne) {
  800. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  801. }
  802. if m.id == nil || m.oldValue == nil {
  803. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  804. }
  805. oldValue, err := m.oldValue(ctx)
  806. if err != nil {
  807. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  808. }
  809. return oldValue.APIKey, nil
  810. }
  811. // ClearAPIKey clears the value of the "api_key" field.
  812. func (m *AgentMutation) ClearAPIKey() {
  813. m.api_key = nil
  814. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  815. }
  816. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  817. func (m *AgentMutation) APIKeyCleared() bool {
  818. _, ok := m.clearedFields[agent.FieldAPIKey]
  819. return ok
  820. }
  821. // ResetAPIKey resets all changes to the "api_key" field.
  822. func (m *AgentMutation) ResetAPIKey() {
  823. m.api_key = nil
  824. delete(m.clearedFields, agent.FieldAPIKey)
  825. }
  826. // SetType sets the "type" field.
  827. func (m *AgentMutation) SetType(i int) {
  828. m._type = &i
  829. m.add_type = nil
  830. }
  831. // GetType returns the value of the "type" field in the mutation.
  832. func (m *AgentMutation) GetType() (r int, exists bool) {
  833. v := m._type
  834. if v == nil {
  835. return
  836. }
  837. return *v, true
  838. }
  839. // OldType returns the old "type" field's value of the Agent entity.
  840. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  842. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  843. if !m.op.Is(OpUpdateOne) {
  844. return v, errors.New("OldType is only allowed on UpdateOne operations")
  845. }
  846. if m.id == nil || m.oldValue == nil {
  847. return v, errors.New("OldType requires an ID field in the mutation")
  848. }
  849. oldValue, err := m.oldValue(ctx)
  850. if err != nil {
  851. return v, fmt.Errorf("querying old value for OldType: %w", err)
  852. }
  853. return oldValue.Type, nil
  854. }
  855. // AddType adds i to the "type" field.
  856. func (m *AgentMutation) AddType(i int) {
  857. if m.add_type != nil {
  858. *m.add_type += i
  859. } else {
  860. m.add_type = &i
  861. }
  862. }
  863. // AddedType returns the value that was added to the "type" field in this mutation.
  864. func (m *AgentMutation) AddedType() (r int, exists bool) {
  865. v := m.add_type
  866. if v == nil {
  867. return
  868. }
  869. return *v, true
  870. }
  871. // ClearType clears the value of the "type" field.
  872. func (m *AgentMutation) ClearType() {
  873. m._type = nil
  874. m.add_type = nil
  875. m.clearedFields[agent.FieldType] = struct{}{}
  876. }
  877. // TypeCleared returns if the "type" field was cleared in this mutation.
  878. func (m *AgentMutation) TypeCleared() bool {
  879. _, ok := m.clearedFields[agent.FieldType]
  880. return ok
  881. }
  882. // ResetType resets all changes to the "type" field.
  883. func (m *AgentMutation) ResetType() {
  884. m._type = nil
  885. m.add_type = nil
  886. delete(m.clearedFields, agent.FieldType)
  887. }
  888. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  889. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  890. if m.wx_agent == nil {
  891. m.wx_agent = make(map[uint64]struct{})
  892. }
  893. for i := range ids {
  894. m.wx_agent[ids[i]] = struct{}{}
  895. }
  896. }
  897. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  898. func (m *AgentMutation) ClearWxAgent() {
  899. m.clearedwx_agent = true
  900. }
  901. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  902. func (m *AgentMutation) WxAgentCleared() bool {
  903. return m.clearedwx_agent
  904. }
  905. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  906. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  907. if m.removedwx_agent == nil {
  908. m.removedwx_agent = make(map[uint64]struct{})
  909. }
  910. for i := range ids {
  911. delete(m.wx_agent, ids[i])
  912. m.removedwx_agent[ids[i]] = struct{}{}
  913. }
  914. }
  915. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  916. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  917. for id := range m.removedwx_agent {
  918. ids = append(ids, id)
  919. }
  920. return
  921. }
  922. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  923. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  924. for id := range m.wx_agent {
  925. ids = append(ids, id)
  926. }
  927. return
  928. }
  929. // ResetWxAgent resets all changes to the "wx_agent" edge.
  930. func (m *AgentMutation) ResetWxAgent() {
  931. m.wx_agent = nil
  932. m.clearedwx_agent = false
  933. m.removedwx_agent = nil
  934. }
  935. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  936. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  937. if m.token_agent == nil {
  938. m.token_agent = make(map[uint64]struct{})
  939. }
  940. for i := range ids {
  941. m.token_agent[ids[i]] = struct{}{}
  942. }
  943. }
  944. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  945. func (m *AgentMutation) ClearTokenAgent() {
  946. m.clearedtoken_agent = true
  947. }
  948. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  949. func (m *AgentMutation) TokenAgentCleared() bool {
  950. return m.clearedtoken_agent
  951. }
  952. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  953. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  954. if m.removedtoken_agent == nil {
  955. m.removedtoken_agent = make(map[uint64]struct{})
  956. }
  957. for i := range ids {
  958. delete(m.token_agent, ids[i])
  959. m.removedtoken_agent[ids[i]] = struct{}{}
  960. }
  961. }
  962. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  963. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  964. for id := range m.removedtoken_agent {
  965. ids = append(ids, id)
  966. }
  967. return
  968. }
  969. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  970. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  971. for id := range m.token_agent {
  972. ids = append(ids, id)
  973. }
  974. return
  975. }
  976. // ResetTokenAgent resets all changes to the "token_agent" edge.
  977. func (m *AgentMutation) ResetTokenAgent() {
  978. m.token_agent = nil
  979. m.clearedtoken_agent = false
  980. m.removedtoken_agent = nil
  981. }
  982. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  983. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  984. if m.wa_agent == nil {
  985. m.wa_agent = make(map[uint64]struct{})
  986. }
  987. for i := range ids {
  988. m.wa_agent[ids[i]] = struct{}{}
  989. }
  990. }
  991. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  992. func (m *AgentMutation) ClearWaAgent() {
  993. m.clearedwa_agent = true
  994. }
  995. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  996. func (m *AgentMutation) WaAgentCleared() bool {
  997. return m.clearedwa_agent
  998. }
  999. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  1000. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  1001. if m.removedwa_agent == nil {
  1002. m.removedwa_agent = make(map[uint64]struct{})
  1003. }
  1004. for i := range ids {
  1005. delete(m.wa_agent, ids[i])
  1006. m.removedwa_agent[ids[i]] = struct{}{}
  1007. }
  1008. }
  1009. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  1010. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  1011. for id := range m.removedwa_agent {
  1012. ids = append(ids, id)
  1013. }
  1014. return
  1015. }
  1016. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1017. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1018. for id := range m.wa_agent {
  1019. ids = append(ids, id)
  1020. }
  1021. return
  1022. }
  1023. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1024. func (m *AgentMutation) ResetWaAgent() {
  1025. m.wa_agent = nil
  1026. m.clearedwa_agent = false
  1027. m.removedwa_agent = nil
  1028. }
  1029. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  1030. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  1031. if m.xjs_agent == nil {
  1032. m.xjs_agent = make(map[uint64]struct{})
  1033. }
  1034. for i := range ids {
  1035. m.xjs_agent[ids[i]] = struct{}{}
  1036. }
  1037. }
  1038. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  1039. func (m *AgentMutation) ClearXjsAgent() {
  1040. m.clearedxjs_agent = true
  1041. }
  1042. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  1043. func (m *AgentMutation) XjsAgentCleared() bool {
  1044. return m.clearedxjs_agent
  1045. }
  1046. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  1047. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  1048. if m.removedxjs_agent == nil {
  1049. m.removedxjs_agent = make(map[uint64]struct{})
  1050. }
  1051. for i := range ids {
  1052. delete(m.xjs_agent, ids[i])
  1053. m.removedxjs_agent[ids[i]] = struct{}{}
  1054. }
  1055. }
  1056. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  1057. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  1058. for id := range m.removedxjs_agent {
  1059. ids = append(ids, id)
  1060. }
  1061. return
  1062. }
  1063. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  1064. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  1065. for id := range m.xjs_agent {
  1066. ids = append(ids, id)
  1067. }
  1068. return
  1069. }
  1070. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  1071. func (m *AgentMutation) ResetXjsAgent() {
  1072. m.xjs_agent = nil
  1073. m.clearedxjs_agent = false
  1074. m.removedxjs_agent = nil
  1075. }
  1076. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1077. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1078. if m.key_agent == nil {
  1079. m.key_agent = make(map[uint64]struct{})
  1080. }
  1081. for i := range ids {
  1082. m.key_agent[ids[i]] = struct{}{}
  1083. }
  1084. }
  1085. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1086. func (m *AgentMutation) ClearKeyAgent() {
  1087. m.clearedkey_agent = true
  1088. }
  1089. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1090. func (m *AgentMutation) KeyAgentCleared() bool {
  1091. return m.clearedkey_agent
  1092. }
  1093. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1094. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1095. if m.removedkey_agent == nil {
  1096. m.removedkey_agent = make(map[uint64]struct{})
  1097. }
  1098. for i := range ids {
  1099. delete(m.key_agent, ids[i])
  1100. m.removedkey_agent[ids[i]] = struct{}{}
  1101. }
  1102. }
  1103. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1104. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1105. for id := range m.removedkey_agent {
  1106. ids = append(ids, id)
  1107. }
  1108. return
  1109. }
  1110. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1111. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1112. for id := range m.key_agent {
  1113. ids = append(ids, id)
  1114. }
  1115. return
  1116. }
  1117. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1118. func (m *AgentMutation) ResetKeyAgent() {
  1119. m.key_agent = nil
  1120. m.clearedkey_agent = false
  1121. m.removedkey_agent = nil
  1122. }
  1123. // Where appends a list predicates to the AgentMutation builder.
  1124. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1125. m.predicates = append(m.predicates, ps...)
  1126. }
  1127. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1128. // users can use type-assertion to append predicates that do not depend on any generated package.
  1129. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1130. p := make([]predicate.Agent, len(ps))
  1131. for i := range ps {
  1132. p[i] = ps[i]
  1133. }
  1134. m.Where(p...)
  1135. }
  1136. // Op returns the operation name.
  1137. func (m *AgentMutation) Op() Op {
  1138. return m.op
  1139. }
  1140. // SetOp allows setting the mutation operation.
  1141. func (m *AgentMutation) SetOp(op Op) {
  1142. m.op = op
  1143. }
  1144. // Type returns the node type of this mutation (Agent).
  1145. func (m *AgentMutation) Type() string {
  1146. return m.typ
  1147. }
  1148. // Fields returns all fields that were changed during this mutation. Note that in
  1149. // order to get all numeric fields that were incremented/decremented, call
  1150. // AddedFields().
  1151. func (m *AgentMutation) Fields() []string {
  1152. fields := make([]string, 0, 15)
  1153. if m.created_at != nil {
  1154. fields = append(fields, agent.FieldCreatedAt)
  1155. }
  1156. if m.updated_at != nil {
  1157. fields = append(fields, agent.FieldUpdatedAt)
  1158. }
  1159. if m.deleted_at != nil {
  1160. fields = append(fields, agent.FieldDeletedAt)
  1161. }
  1162. if m.name != nil {
  1163. fields = append(fields, agent.FieldName)
  1164. }
  1165. if m.role != nil {
  1166. fields = append(fields, agent.FieldRole)
  1167. }
  1168. if m.status != nil {
  1169. fields = append(fields, agent.FieldStatus)
  1170. }
  1171. if m.background != nil {
  1172. fields = append(fields, agent.FieldBackground)
  1173. }
  1174. if m.examples != nil {
  1175. fields = append(fields, agent.FieldExamples)
  1176. }
  1177. if m.organization_id != nil {
  1178. fields = append(fields, agent.FieldOrganizationID)
  1179. }
  1180. if m.dataset_id != nil {
  1181. fields = append(fields, agent.FieldDatasetID)
  1182. }
  1183. if m.collection_id != nil {
  1184. fields = append(fields, agent.FieldCollectionID)
  1185. }
  1186. if m.model != nil {
  1187. fields = append(fields, agent.FieldModel)
  1188. }
  1189. if m.api_base != nil {
  1190. fields = append(fields, agent.FieldAPIBase)
  1191. }
  1192. if m.api_key != nil {
  1193. fields = append(fields, agent.FieldAPIKey)
  1194. }
  1195. if m._type != nil {
  1196. fields = append(fields, agent.FieldType)
  1197. }
  1198. return fields
  1199. }
  1200. // Field returns the value of a field with the given name. The second boolean
  1201. // return value indicates that this field was not set, or was not defined in the
  1202. // schema.
  1203. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1204. switch name {
  1205. case agent.FieldCreatedAt:
  1206. return m.CreatedAt()
  1207. case agent.FieldUpdatedAt:
  1208. return m.UpdatedAt()
  1209. case agent.FieldDeletedAt:
  1210. return m.DeletedAt()
  1211. case agent.FieldName:
  1212. return m.Name()
  1213. case agent.FieldRole:
  1214. return m.Role()
  1215. case agent.FieldStatus:
  1216. return m.Status()
  1217. case agent.FieldBackground:
  1218. return m.Background()
  1219. case agent.FieldExamples:
  1220. return m.Examples()
  1221. case agent.FieldOrganizationID:
  1222. return m.OrganizationID()
  1223. case agent.FieldDatasetID:
  1224. return m.DatasetID()
  1225. case agent.FieldCollectionID:
  1226. return m.CollectionID()
  1227. case agent.FieldModel:
  1228. return m.Model()
  1229. case agent.FieldAPIBase:
  1230. return m.APIBase()
  1231. case agent.FieldAPIKey:
  1232. return m.APIKey()
  1233. case agent.FieldType:
  1234. return m.GetType()
  1235. }
  1236. return nil, false
  1237. }
  1238. // OldField returns the old value of the field from the database. An error is
  1239. // returned if the mutation operation is not UpdateOne, or the query to the
  1240. // database failed.
  1241. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1242. switch name {
  1243. case agent.FieldCreatedAt:
  1244. return m.OldCreatedAt(ctx)
  1245. case agent.FieldUpdatedAt:
  1246. return m.OldUpdatedAt(ctx)
  1247. case agent.FieldDeletedAt:
  1248. return m.OldDeletedAt(ctx)
  1249. case agent.FieldName:
  1250. return m.OldName(ctx)
  1251. case agent.FieldRole:
  1252. return m.OldRole(ctx)
  1253. case agent.FieldStatus:
  1254. return m.OldStatus(ctx)
  1255. case agent.FieldBackground:
  1256. return m.OldBackground(ctx)
  1257. case agent.FieldExamples:
  1258. return m.OldExamples(ctx)
  1259. case agent.FieldOrganizationID:
  1260. return m.OldOrganizationID(ctx)
  1261. case agent.FieldDatasetID:
  1262. return m.OldDatasetID(ctx)
  1263. case agent.FieldCollectionID:
  1264. return m.OldCollectionID(ctx)
  1265. case agent.FieldModel:
  1266. return m.OldModel(ctx)
  1267. case agent.FieldAPIBase:
  1268. return m.OldAPIBase(ctx)
  1269. case agent.FieldAPIKey:
  1270. return m.OldAPIKey(ctx)
  1271. case agent.FieldType:
  1272. return m.OldType(ctx)
  1273. }
  1274. return nil, fmt.Errorf("unknown Agent field %s", name)
  1275. }
  1276. // SetField sets the value of a field with the given name. It returns an error if
  1277. // the field is not defined in the schema, or if the type mismatched the field
  1278. // type.
  1279. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1280. switch name {
  1281. case agent.FieldCreatedAt:
  1282. v, ok := value.(time.Time)
  1283. if !ok {
  1284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1285. }
  1286. m.SetCreatedAt(v)
  1287. return nil
  1288. case agent.FieldUpdatedAt:
  1289. v, ok := value.(time.Time)
  1290. if !ok {
  1291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1292. }
  1293. m.SetUpdatedAt(v)
  1294. return nil
  1295. case agent.FieldDeletedAt:
  1296. v, ok := value.(time.Time)
  1297. if !ok {
  1298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1299. }
  1300. m.SetDeletedAt(v)
  1301. return nil
  1302. case agent.FieldName:
  1303. v, ok := value.(string)
  1304. if !ok {
  1305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1306. }
  1307. m.SetName(v)
  1308. return nil
  1309. case agent.FieldRole:
  1310. v, ok := value.(string)
  1311. if !ok {
  1312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1313. }
  1314. m.SetRole(v)
  1315. return nil
  1316. case agent.FieldStatus:
  1317. v, ok := value.(int)
  1318. if !ok {
  1319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1320. }
  1321. m.SetStatus(v)
  1322. return nil
  1323. case agent.FieldBackground:
  1324. v, ok := value.(string)
  1325. if !ok {
  1326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1327. }
  1328. m.SetBackground(v)
  1329. return nil
  1330. case agent.FieldExamples:
  1331. v, ok := value.(string)
  1332. if !ok {
  1333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1334. }
  1335. m.SetExamples(v)
  1336. return nil
  1337. case agent.FieldOrganizationID:
  1338. v, ok := value.(uint64)
  1339. if !ok {
  1340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1341. }
  1342. m.SetOrganizationID(v)
  1343. return nil
  1344. case agent.FieldDatasetID:
  1345. v, ok := value.(string)
  1346. if !ok {
  1347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1348. }
  1349. m.SetDatasetID(v)
  1350. return nil
  1351. case agent.FieldCollectionID:
  1352. v, ok := value.(string)
  1353. if !ok {
  1354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1355. }
  1356. m.SetCollectionID(v)
  1357. return nil
  1358. case agent.FieldModel:
  1359. v, ok := value.(string)
  1360. if !ok {
  1361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1362. }
  1363. m.SetModel(v)
  1364. return nil
  1365. case agent.FieldAPIBase:
  1366. v, ok := value.(string)
  1367. if !ok {
  1368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1369. }
  1370. m.SetAPIBase(v)
  1371. return nil
  1372. case agent.FieldAPIKey:
  1373. v, ok := value.(string)
  1374. if !ok {
  1375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1376. }
  1377. m.SetAPIKey(v)
  1378. return nil
  1379. case agent.FieldType:
  1380. v, ok := value.(int)
  1381. if !ok {
  1382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1383. }
  1384. m.SetType(v)
  1385. return nil
  1386. }
  1387. return fmt.Errorf("unknown Agent field %s", name)
  1388. }
  1389. // AddedFields returns all numeric fields that were incremented/decremented during
  1390. // this mutation.
  1391. func (m *AgentMutation) AddedFields() []string {
  1392. var fields []string
  1393. if m.addstatus != nil {
  1394. fields = append(fields, agent.FieldStatus)
  1395. }
  1396. if m.addorganization_id != nil {
  1397. fields = append(fields, agent.FieldOrganizationID)
  1398. }
  1399. if m.add_type != nil {
  1400. fields = append(fields, agent.FieldType)
  1401. }
  1402. return fields
  1403. }
  1404. // AddedField returns the numeric value that was incremented/decremented on a field
  1405. // with the given name. The second boolean return value indicates that this field
  1406. // was not set, or was not defined in the schema.
  1407. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1408. switch name {
  1409. case agent.FieldStatus:
  1410. return m.AddedStatus()
  1411. case agent.FieldOrganizationID:
  1412. return m.AddedOrganizationID()
  1413. case agent.FieldType:
  1414. return m.AddedType()
  1415. }
  1416. return nil, false
  1417. }
  1418. // AddField adds the value to the field with the given name. It returns an error if
  1419. // the field is not defined in the schema, or if the type mismatched the field
  1420. // type.
  1421. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1422. switch name {
  1423. case agent.FieldStatus:
  1424. v, ok := value.(int)
  1425. if !ok {
  1426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1427. }
  1428. m.AddStatus(v)
  1429. return nil
  1430. case agent.FieldOrganizationID:
  1431. v, ok := value.(int64)
  1432. if !ok {
  1433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1434. }
  1435. m.AddOrganizationID(v)
  1436. return nil
  1437. case agent.FieldType:
  1438. v, ok := value.(int)
  1439. if !ok {
  1440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1441. }
  1442. m.AddType(v)
  1443. return nil
  1444. }
  1445. return fmt.Errorf("unknown Agent numeric field %s", name)
  1446. }
  1447. // ClearedFields returns all nullable fields that were cleared during this
  1448. // mutation.
  1449. func (m *AgentMutation) ClearedFields() []string {
  1450. var fields []string
  1451. if m.FieldCleared(agent.FieldDeletedAt) {
  1452. fields = append(fields, agent.FieldDeletedAt)
  1453. }
  1454. if m.FieldCleared(agent.FieldRole) {
  1455. fields = append(fields, agent.FieldRole)
  1456. }
  1457. if m.FieldCleared(agent.FieldStatus) {
  1458. fields = append(fields, agent.FieldStatus)
  1459. }
  1460. if m.FieldCleared(agent.FieldBackground) {
  1461. fields = append(fields, agent.FieldBackground)
  1462. }
  1463. if m.FieldCleared(agent.FieldExamples) {
  1464. fields = append(fields, agent.FieldExamples)
  1465. }
  1466. if m.FieldCleared(agent.FieldModel) {
  1467. fields = append(fields, agent.FieldModel)
  1468. }
  1469. if m.FieldCleared(agent.FieldAPIBase) {
  1470. fields = append(fields, agent.FieldAPIBase)
  1471. }
  1472. if m.FieldCleared(agent.FieldAPIKey) {
  1473. fields = append(fields, agent.FieldAPIKey)
  1474. }
  1475. if m.FieldCleared(agent.FieldType) {
  1476. fields = append(fields, agent.FieldType)
  1477. }
  1478. return fields
  1479. }
  1480. // FieldCleared returns a boolean indicating if a field with the given name was
  1481. // cleared in this mutation.
  1482. func (m *AgentMutation) FieldCleared(name string) bool {
  1483. _, ok := m.clearedFields[name]
  1484. return ok
  1485. }
  1486. // ClearField clears the value of the field with the given name. It returns an
  1487. // error if the field is not defined in the schema.
  1488. func (m *AgentMutation) ClearField(name string) error {
  1489. switch name {
  1490. case agent.FieldDeletedAt:
  1491. m.ClearDeletedAt()
  1492. return nil
  1493. case agent.FieldRole:
  1494. m.ClearRole()
  1495. return nil
  1496. case agent.FieldStatus:
  1497. m.ClearStatus()
  1498. return nil
  1499. case agent.FieldBackground:
  1500. m.ClearBackground()
  1501. return nil
  1502. case agent.FieldExamples:
  1503. m.ClearExamples()
  1504. return nil
  1505. case agent.FieldModel:
  1506. m.ClearModel()
  1507. return nil
  1508. case agent.FieldAPIBase:
  1509. m.ClearAPIBase()
  1510. return nil
  1511. case agent.FieldAPIKey:
  1512. m.ClearAPIKey()
  1513. return nil
  1514. case agent.FieldType:
  1515. m.ClearType()
  1516. return nil
  1517. }
  1518. return fmt.Errorf("unknown Agent nullable field %s", name)
  1519. }
  1520. // ResetField resets all changes in the mutation for the field with the given name.
  1521. // It returns an error if the field is not defined in the schema.
  1522. func (m *AgentMutation) ResetField(name string) error {
  1523. switch name {
  1524. case agent.FieldCreatedAt:
  1525. m.ResetCreatedAt()
  1526. return nil
  1527. case agent.FieldUpdatedAt:
  1528. m.ResetUpdatedAt()
  1529. return nil
  1530. case agent.FieldDeletedAt:
  1531. m.ResetDeletedAt()
  1532. return nil
  1533. case agent.FieldName:
  1534. m.ResetName()
  1535. return nil
  1536. case agent.FieldRole:
  1537. m.ResetRole()
  1538. return nil
  1539. case agent.FieldStatus:
  1540. m.ResetStatus()
  1541. return nil
  1542. case agent.FieldBackground:
  1543. m.ResetBackground()
  1544. return nil
  1545. case agent.FieldExamples:
  1546. m.ResetExamples()
  1547. return nil
  1548. case agent.FieldOrganizationID:
  1549. m.ResetOrganizationID()
  1550. return nil
  1551. case agent.FieldDatasetID:
  1552. m.ResetDatasetID()
  1553. return nil
  1554. case agent.FieldCollectionID:
  1555. m.ResetCollectionID()
  1556. return nil
  1557. case agent.FieldModel:
  1558. m.ResetModel()
  1559. return nil
  1560. case agent.FieldAPIBase:
  1561. m.ResetAPIBase()
  1562. return nil
  1563. case agent.FieldAPIKey:
  1564. m.ResetAPIKey()
  1565. return nil
  1566. case agent.FieldType:
  1567. m.ResetType()
  1568. return nil
  1569. }
  1570. return fmt.Errorf("unknown Agent field %s", name)
  1571. }
  1572. // AddedEdges returns all edge names that were set/added in this mutation.
  1573. func (m *AgentMutation) AddedEdges() []string {
  1574. edges := make([]string, 0, 5)
  1575. if m.wx_agent != nil {
  1576. edges = append(edges, agent.EdgeWxAgent)
  1577. }
  1578. if m.token_agent != nil {
  1579. edges = append(edges, agent.EdgeTokenAgent)
  1580. }
  1581. if m.wa_agent != nil {
  1582. edges = append(edges, agent.EdgeWaAgent)
  1583. }
  1584. if m.xjs_agent != nil {
  1585. edges = append(edges, agent.EdgeXjsAgent)
  1586. }
  1587. if m.key_agent != nil {
  1588. edges = append(edges, agent.EdgeKeyAgent)
  1589. }
  1590. return edges
  1591. }
  1592. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1593. // name in this mutation.
  1594. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1595. switch name {
  1596. case agent.EdgeWxAgent:
  1597. ids := make([]ent.Value, 0, len(m.wx_agent))
  1598. for id := range m.wx_agent {
  1599. ids = append(ids, id)
  1600. }
  1601. return ids
  1602. case agent.EdgeTokenAgent:
  1603. ids := make([]ent.Value, 0, len(m.token_agent))
  1604. for id := range m.token_agent {
  1605. ids = append(ids, id)
  1606. }
  1607. return ids
  1608. case agent.EdgeWaAgent:
  1609. ids := make([]ent.Value, 0, len(m.wa_agent))
  1610. for id := range m.wa_agent {
  1611. ids = append(ids, id)
  1612. }
  1613. return ids
  1614. case agent.EdgeXjsAgent:
  1615. ids := make([]ent.Value, 0, len(m.xjs_agent))
  1616. for id := range m.xjs_agent {
  1617. ids = append(ids, id)
  1618. }
  1619. return ids
  1620. case agent.EdgeKeyAgent:
  1621. ids := make([]ent.Value, 0, len(m.key_agent))
  1622. for id := range m.key_agent {
  1623. ids = append(ids, id)
  1624. }
  1625. return ids
  1626. }
  1627. return nil
  1628. }
  1629. // RemovedEdges returns all edge names that were removed in this mutation.
  1630. func (m *AgentMutation) RemovedEdges() []string {
  1631. edges := make([]string, 0, 5)
  1632. if m.removedwx_agent != nil {
  1633. edges = append(edges, agent.EdgeWxAgent)
  1634. }
  1635. if m.removedtoken_agent != nil {
  1636. edges = append(edges, agent.EdgeTokenAgent)
  1637. }
  1638. if m.removedwa_agent != nil {
  1639. edges = append(edges, agent.EdgeWaAgent)
  1640. }
  1641. if m.removedxjs_agent != nil {
  1642. edges = append(edges, agent.EdgeXjsAgent)
  1643. }
  1644. if m.removedkey_agent != nil {
  1645. edges = append(edges, agent.EdgeKeyAgent)
  1646. }
  1647. return edges
  1648. }
  1649. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1650. // the given name in this mutation.
  1651. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1652. switch name {
  1653. case agent.EdgeWxAgent:
  1654. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1655. for id := range m.removedwx_agent {
  1656. ids = append(ids, id)
  1657. }
  1658. return ids
  1659. case agent.EdgeTokenAgent:
  1660. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1661. for id := range m.removedtoken_agent {
  1662. ids = append(ids, id)
  1663. }
  1664. return ids
  1665. case agent.EdgeWaAgent:
  1666. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1667. for id := range m.removedwa_agent {
  1668. ids = append(ids, id)
  1669. }
  1670. return ids
  1671. case agent.EdgeXjsAgent:
  1672. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  1673. for id := range m.removedxjs_agent {
  1674. ids = append(ids, id)
  1675. }
  1676. return ids
  1677. case agent.EdgeKeyAgent:
  1678. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1679. for id := range m.removedkey_agent {
  1680. ids = append(ids, id)
  1681. }
  1682. return ids
  1683. }
  1684. return nil
  1685. }
  1686. // ClearedEdges returns all edge names that were cleared in this mutation.
  1687. func (m *AgentMutation) ClearedEdges() []string {
  1688. edges := make([]string, 0, 5)
  1689. if m.clearedwx_agent {
  1690. edges = append(edges, agent.EdgeWxAgent)
  1691. }
  1692. if m.clearedtoken_agent {
  1693. edges = append(edges, agent.EdgeTokenAgent)
  1694. }
  1695. if m.clearedwa_agent {
  1696. edges = append(edges, agent.EdgeWaAgent)
  1697. }
  1698. if m.clearedxjs_agent {
  1699. edges = append(edges, agent.EdgeXjsAgent)
  1700. }
  1701. if m.clearedkey_agent {
  1702. edges = append(edges, agent.EdgeKeyAgent)
  1703. }
  1704. return edges
  1705. }
  1706. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1707. // was cleared in this mutation.
  1708. func (m *AgentMutation) EdgeCleared(name string) bool {
  1709. switch name {
  1710. case agent.EdgeWxAgent:
  1711. return m.clearedwx_agent
  1712. case agent.EdgeTokenAgent:
  1713. return m.clearedtoken_agent
  1714. case agent.EdgeWaAgent:
  1715. return m.clearedwa_agent
  1716. case agent.EdgeXjsAgent:
  1717. return m.clearedxjs_agent
  1718. case agent.EdgeKeyAgent:
  1719. return m.clearedkey_agent
  1720. }
  1721. return false
  1722. }
  1723. // ClearEdge clears the value of the edge with the given name. It returns an error
  1724. // if that edge is not defined in the schema.
  1725. func (m *AgentMutation) ClearEdge(name string) error {
  1726. switch name {
  1727. }
  1728. return fmt.Errorf("unknown Agent unique edge %s", name)
  1729. }
  1730. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1731. // It returns an error if the edge is not defined in the schema.
  1732. func (m *AgentMutation) ResetEdge(name string) error {
  1733. switch name {
  1734. case agent.EdgeWxAgent:
  1735. m.ResetWxAgent()
  1736. return nil
  1737. case agent.EdgeTokenAgent:
  1738. m.ResetTokenAgent()
  1739. return nil
  1740. case agent.EdgeWaAgent:
  1741. m.ResetWaAgent()
  1742. return nil
  1743. case agent.EdgeXjsAgent:
  1744. m.ResetXjsAgent()
  1745. return nil
  1746. case agent.EdgeKeyAgent:
  1747. m.ResetKeyAgent()
  1748. return nil
  1749. }
  1750. return fmt.Errorf("unknown Agent edge %s", name)
  1751. }
  1752. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1753. type AgentBaseMutation struct {
  1754. config
  1755. op Op
  1756. typ string
  1757. id *string
  1758. q *string
  1759. a *string
  1760. chunk_index *uint64
  1761. addchunk_index *int64
  1762. indexes *[]string
  1763. appendindexes []string
  1764. dataset_id *string
  1765. collection_id *string
  1766. source_name *string
  1767. can_write *[]bool
  1768. appendcan_write []bool
  1769. is_owner *[]bool
  1770. appendis_owner []bool
  1771. clearedFields map[string]struct{}
  1772. wx_agent map[uint64]struct{}
  1773. removedwx_agent map[uint64]struct{}
  1774. clearedwx_agent bool
  1775. done bool
  1776. oldValue func(context.Context) (*AgentBase, error)
  1777. predicates []predicate.AgentBase
  1778. }
  1779. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1780. // agentbaseOption allows management of the mutation configuration using functional options.
  1781. type agentbaseOption func(*AgentBaseMutation)
  1782. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1783. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1784. m := &AgentBaseMutation{
  1785. config: c,
  1786. op: op,
  1787. typ: TypeAgentBase,
  1788. clearedFields: make(map[string]struct{}),
  1789. }
  1790. for _, opt := range opts {
  1791. opt(m)
  1792. }
  1793. return m
  1794. }
  1795. // withAgentBaseID sets the ID field of the mutation.
  1796. func withAgentBaseID(id string) agentbaseOption {
  1797. return func(m *AgentBaseMutation) {
  1798. var (
  1799. err error
  1800. once sync.Once
  1801. value *AgentBase
  1802. )
  1803. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1804. once.Do(func() {
  1805. if m.done {
  1806. err = errors.New("querying old values post mutation is not allowed")
  1807. } else {
  1808. value, err = m.Client().AgentBase.Get(ctx, id)
  1809. }
  1810. })
  1811. return value, err
  1812. }
  1813. m.id = &id
  1814. }
  1815. }
  1816. // withAgentBase sets the old AgentBase of the mutation.
  1817. func withAgentBase(node *AgentBase) agentbaseOption {
  1818. return func(m *AgentBaseMutation) {
  1819. m.oldValue = func(context.Context) (*AgentBase, error) {
  1820. return node, nil
  1821. }
  1822. m.id = &node.ID
  1823. }
  1824. }
  1825. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1826. // executed in a transaction (ent.Tx), a transactional client is returned.
  1827. func (m AgentBaseMutation) Client() *Client {
  1828. client := &Client{config: m.config}
  1829. client.init()
  1830. return client
  1831. }
  1832. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1833. // it returns an error otherwise.
  1834. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1835. if _, ok := m.driver.(*txDriver); !ok {
  1836. return nil, errors.New("ent: mutation is not running in a transaction")
  1837. }
  1838. tx := &Tx{config: m.config}
  1839. tx.init()
  1840. return tx, nil
  1841. }
  1842. // SetID sets the value of the id field. Note that this
  1843. // operation is only accepted on creation of AgentBase entities.
  1844. func (m *AgentBaseMutation) SetID(id string) {
  1845. m.id = &id
  1846. }
  1847. // ID returns the ID value in the mutation. Note that the ID is only available
  1848. // if it was provided to the builder or after it was returned from the database.
  1849. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1850. if m.id == nil {
  1851. return
  1852. }
  1853. return *m.id, true
  1854. }
  1855. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1856. // That means, if the mutation is applied within a transaction with an isolation level such
  1857. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1858. // or updated by the mutation.
  1859. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1860. switch {
  1861. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1862. id, exists := m.ID()
  1863. if exists {
  1864. return []string{id}, nil
  1865. }
  1866. fallthrough
  1867. case m.op.Is(OpUpdate | OpDelete):
  1868. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1869. default:
  1870. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1871. }
  1872. }
  1873. // SetQ sets the "q" field.
  1874. func (m *AgentBaseMutation) SetQ(s string) {
  1875. m.q = &s
  1876. }
  1877. // Q returns the value of the "q" field in the mutation.
  1878. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1879. v := m.q
  1880. if v == nil {
  1881. return
  1882. }
  1883. return *v, true
  1884. }
  1885. // OldQ returns the old "q" 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) OldQ(ctx context.Context) (v string, err error) {
  1889. if !m.op.Is(OpUpdateOne) {
  1890. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1891. }
  1892. if m.id == nil || m.oldValue == nil {
  1893. return v, errors.New("OldQ 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 OldQ: %w", err)
  1898. }
  1899. return oldValue.Q, nil
  1900. }
  1901. // ClearQ clears the value of the "q" field.
  1902. func (m *AgentBaseMutation) ClearQ() {
  1903. m.q = nil
  1904. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1905. }
  1906. // QCleared returns if the "q" field was cleared in this mutation.
  1907. func (m *AgentBaseMutation) QCleared() bool {
  1908. _, ok := m.clearedFields[agentbase.FieldQ]
  1909. return ok
  1910. }
  1911. // ResetQ resets all changes to the "q" field.
  1912. func (m *AgentBaseMutation) ResetQ() {
  1913. m.q = nil
  1914. delete(m.clearedFields, agentbase.FieldQ)
  1915. }
  1916. // SetA sets the "a" field.
  1917. func (m *AgentBaseMutation) SetA(s string) {
  1918. m.a = &s
  1919. }
  1920. // A returns the value of the "a" field in the mutation.
  1921. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1922. v := m.a
  1923. if v == nil {
  1924. return
  1925. }
  1926. return *v, true
  1927. }
  1928. // OldA returns the old "a" field's value of the AgentBase entity.
  1929. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1931. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1932. if !m.op.Is(OpUpdateOne) {
  1933. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1934. }
  1935. if m.id == nil || m.oldValue == nil {
  1936. return v, errors.New("OldA requires an ID field in the mutation")
  1937. }
  1938. oldValue, err := m.oldValue(ctx)
  1939. if err != nil {
  1940. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1941. }
  1942. return oldValue.A, nil
  1943. }
  1944. // ClearA clears the value of the "a" field.
  1945. func (m *AgentBaseMutation) ClearA() {
  1946. m.a = nil
  1947. m.clearedFields[agentbase.FieldA] = struct{}{}
  1948. }
  1949. // ACleared returns if the "a" field was cleared in this mutation.
  1950. func (m *AgentBaseMutation) ACleared() bool {
  1951. _, ok := m.clearedFields[agentbase.FieldA]
  1952. return ok
  1953. }
  1954. // ResetA resets all changes to the "a" field.
  1955. func (m *AgentBaseMutation) ResetA() {
  1956. m.a = nil
  1957. delete(m.clearedFields, agentbase.FieldA)
  1958. }
  1959. // SetChunkIndex sets the "chunk_index" field.
  1960. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1961. m.chunk_index = &u
  1962. m.addchunk_index = nil
  1963. }
  1964. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1965. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1966. v := m.chunk_index
  1967. if v == nil {
  1968. return
  1969. }
  1970. return *v, true
  1971. }
  1972. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1973. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1975. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1976. if !m.op.Is(OpUpdateOne) {
  1977. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1978. }
  1979. if m.id == nil || m.oldValue == nil {
  1980. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1981. }
  1982. oldValue, err := m.oldValue(ctx)
  1983. if err != nil {
  1984. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1985. }
  1986. return oldValue.ChunkIndex, nil
  1987. }
  1988. // AddChunkIndex adds u to the "chunk_index" field.
  1989. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1990. if m.addchunk_index != nil {
  1991. *m.addchunk_index += u
  1992. } else {
  1993. m.addchunk_index = &u
  1994. }
  1995. }
  1996. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1997. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1998. v := m.addchunk_index
  1999. if v == nil {
  2000. return
  2001. }
  2002. return *v, true
  2003. }
  2004. // ResetChunkIndex resets all changes to the "chunk_index" field.
  2005. func (m *AgentBaseMutation) ResetChunkIndex() {
  2006. m.chunk_index = nil
  2007. m.addchunk_index = nil
  2008. }
  2009. // SetIndexes sets the "indexes" field.
  2010. func (m *AgentBaseMutation) SetIndexes(s []string) {
  2011. m.indexes = &s
  2012. m.appendindexes = nil
  2013. }
  2014. // Indexes returns the value of the "indexes" field in the mutation.
  2015. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  2016. v := m.indexes
  2017. if v == nil {
  2018. return
  2019. }
  2020. return *v, true
  2021. }
  2022. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  2023. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2025. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  2026. if !m.op.Is(OpUpdateOne) {
  2027. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  2028. }
  2029. if m.id == nil || m.oldValue == nil {
  2030. return v, errors.New("OldIndexes requires an ID field in the mutation")
  2031. }
  2032. oldValue, err := m.oldValue(ctx)
  2033. if err != nil {
  2034. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  2035. }
  2036. return oldValue.Indexes, nil
  2037. }
  2038. // AppendIndexes adds s to the "indexes" field.
  2039. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  2040. m.appendindexes = append(m.appendindexes, s...)
  2041. }
  2042. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  2043. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  2044. if len(m.appendindexes) == 0 {
  2045. return nil, false
  2046. }
  2047. return m.appendindexes, true
  2048. }
  2049. // ClearIndexes clears the value of the "indexes" field.
  2050. func (m *AgentBaseMutation) ClearIndexes() {
  2051. m.indexes = nil
  2052. m.appendindexes = nil
  2053. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  2054. }
  2055. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  2056. func (m *AgentBaseMutation) IndexesCleared() bool {
  2057. _, ok := m.clearedFields[agentbase.FieldIndexes]
  2058. return ok
  2059. }
  2060. // ResetIndexes resets all changes to the "indexes" field.
  2061. func (m *AgentBaseMutation) ResetIndexes() {
  2062. m.indexes = nil
  2063. m.appendindexes = nil
  2064. delete(m.clearedFields, agentbase.FieldIndexes)
  2065. }
  2066. // SetDatasetID sets the "dataset_id" field.
  2067. func (m *AgentBaseMutation) SetDatasetID(s string) {
  2068. m.dataset_id = &s
  2069. }
  2070. // DatasetID returns the value of the "dataset_id" field in the mutation.
  2071. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  2072. v := m.dataset_id
  2073. if v == nil {
  2074. return
  2075. }
  2076. return *v, true
  2077. }
  2078. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  2079. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2081. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  2082. if !m.op.Is(OpUpdateOne) {
  2083. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  2084. }
  2085. if m.id == nil || m.oldValue == nil {
  2086. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2087. }
  2088. oldValue, err := m.oldValue(ctx)
  2089. if err != nil {
  2090. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2091. }
  2092. return oldValue.DatasetID, nil
  2093. }
  2094. // ClearDatasetID clears the value of the "dataset_id" field.
  2095. func (m *AgentBaseMutation) ClearDatasetID() {
  2096. m.dataset_id = nil
  2097. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2098. }
  2099. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2100. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2101. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2102. return ok
  2103. }
  2104. // ResetDatasetID resets all changes to the "dataset_id" field.
  2105. func (m *AgentBaseMutation) ResetDatasetID() {
  2106. m.dataset_id = nil
  2107. delete(m.clearedFields, agentbase.FieldDatasetID)
  2108. }
  2109. // SetCollectionID sets the "collection_id" field.
  2110. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2111. m.collection_id = &s
  2112. }
  2113. // CollectionID returns the value of the "collection_id" field in the mutation.
  2114. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2115. v := m.collection_id
  2116. if v == nil {
  2117. return
  2118. }
  2119. return *v, true
  2120. }
  2121. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2122. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2124. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2125. if !m.op.Is(OpUpdateOne) {
  2126. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2127. }
  2128. if m.id == nil || m.oldValue == nil {
  2129. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2130. }
  2131. oldValue, err := m.oldValue(ctx)
  2132. if err != nil {
  2133. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2134. }
  2135. return oldValue.CollectionID, nil
  2136. }
  2137. // ClearCollectionID clears the value of the "collection_id" field.
  2138. func (m *AgentBaseMutation) ClearCollectionID() {
  2139. m.collection_id = nil
  2140. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2141. }
  2142. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2143. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2144. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2145. return ok
  2146. }
  2147. // ResetCollectionID resets all changes to the "collection_id" field.
  2148. func (m *AgentBaseMutation) ResetCollectionID() {
  2149. m.collection_id = nil
  2150. delete(m.clearedFields, agentbase.FieldCollectionID)
  2151. }
  2152. // SetSourceName sets the "source_name" field.
  2153. func (m *AgentBaseMutation) SetSourceName(s string) {
  2154. m.source_name = &s
  2155. }
  2156. // SourceName returns the value of the "source_name" field in the mutation.
  2157. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2158. v := m.source_name
  2159. if v == nil {
  2160. return
  2161. }
  2162. return *v, true
  2163. }
  2164. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  2165. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2167. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  2168. if !m.op.Is(OpUpdateOne) {
  2169. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2170. }
  2171. if m.id == nil || m.oldValue == nil {
  2172. return v, errors.New("OldSourceName requires an ID field in the mutation")
  2173. }
  2174. oldValue, err := m.oldValue(ctx)
  2175. if err != nil {
  2176. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  2177. }
  2178. return oldValue.SourceName, nil
  2179. }
  2180. // ClearSourceName clears the value of the "source_name" field.
  2181. func (m *AgentBaseMutation) ClearSourceName() {
  2182. m.source_name = nil
  2183. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2184. }
  2185. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2186. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2187. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2188. return ok
  2189. }
  2190. // ResetSourceName resets all changes to the "source_name" field.
  2191. func (m *AgentBaseMutation) ResetSourceName() {
  2192. m.source_name = nil
  2193. delete(m.clearedFields, agentbase.FieldSourceName)
  2194. }
  2195. // SetCanWrite sets the "can_write" field.
  2196. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2197. m.can_write = &b
  2198. m.appendcan_write = nil
  2199. }
  2200. // CanWrite returns the value of the "can_write" field in the mutation.
  2201. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2202. v := m.can_write
  2203. if v == nil {
  2204. return
  2205. }
  2206. return *v, true
  2207. }
  2208. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2209. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2211. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2212. if !m.op.Is(OpUpdateOne) {
  2213. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2214. }
  2215. if m.id == nil || m.oldValue == nil {
  2216. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2217. }
  2218. oldValue, err := m.oldValue(ctx)
  2219. if err != nil {
  2220. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2221. }
  2222. return oldValue.CanWrite, nil
  2223. }
  2224. // AppendCanWrite adds b to the "can_write" field.
  2225. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2226. m.appendcan_write = append(m.appendcan_write, b...)
  2227. }
  2228. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2229. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2230. if len(m.appendcan_write) == 0 {
  2231. return nil, false
  2232. }
  2233. return m.appendcan_write, true
  2234. }
  2235. // ClearCanWrite clears the value of the "can_write" field.
  2236. func (m *AgentBaseMutation) ClearCanWrite() {
  2237. m.can_write = nil
  2238. m.appendcan_write = nil
  2239. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2240. }
  2241. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2242. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2243. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2244. return ok
  2245. }
  2246. // ResetCanWrite resets all changes to the "can_write" field.
  2247. func (m *AgentBaseMutation) ResetCanWrite() {
  2248. m.can_write = nil
  2249. m.appendcan_write = nil
  2250. delete(m.clearedFields, agentbase.FieldCanWrite)
  2251. }
  2252. // SetIsOwner sets the "is_owner" field.
  2253. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2254. m.is_owner = &b
  2255. m.appendis_owner = nil
  2256. }
  2257. // IsOwner returns the value of the "is_owner" field in the mutation.
  2258. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2259. v := m.is_owner
  2260. if v == nil {
  2261. return
  2262. }
  2263. return *v, true
  2264. }
  2265. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2266. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2268. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2269. if !m.op.Is(OpUpdateOne) {
  2270. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2271. }
  2272. if m.id == nil || m.oldValue == nil {
  2273. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2274. }
  2275. oldValue, err := m.oldValue(ctx)
  2276. if err != nil {
  2277. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2278. }
  2279. return oldValue.IsOwner, nil
  2280. }
  2281. // AppendIsOwner adds b to the "is_owner" field.
  2282. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2283. m.appendis_owner = append(m.appendis_owner, b...)
  2284. }
  2285. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2286. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2287. if len(m.appendis_owner) == 0 {
  2288. return nil, false
  2289. }
  2290. return m.appendis_owner, true
  2291. }
  2292. // ClearIsOwner clears the value of the "is_owner" field.
  2293. func (m *AgentBaseMutation) ClearIsOwner() {
  2294. m.is_owner = nil
  2295. m.appendis_owner = nil
  2296. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2297. }
  2298. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2299. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2300. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2301. return ok
  2302. }
  2303. // ResetIsOwner resets all changes to the "is_owner" field.
  2304. func (m *AgentBaseMutation) ResetIsOwner() {
  2305. m.is_owner = nil
  2306. m.appendis_owner = nil
  2307. delete(m.clearedFields, agentbase.FieldIsOwner)
  2308. }
  2309. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2310. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2311. if m.wx_agent == nil {
  2312. m.wx_agent = make(map[uint64]struct{})
  2313. }
  2314. for i := range ids {
  2315. m.wx_agent[ids[i]] = struct{}{}
  2316. }
  2317. }
  2318. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2319. func (m *AgentBaseMutation) ClearWxAgent() {
  2320. m.clearedwx_agent = true
  2321. }
  2322. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2323. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2324. return m.clearedwx_agent
  2325. }
  2326. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2327. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2328. if m.removedwx_agent == nil {
  2329. m.removedwx_agent = make(map[uint64]struct{})
  2330. }
  2331. for i := range ids {
  2332. delete(m.wx_agent, ids[i])
  2333. m.removedwx_agent[ids[i]] = struct{}{}
  2334. }
  2335. }
  2336. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2337. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2338. for id := range m.removedwx_agent {
  2339. ids = append(ids, id)
  2340. }
  2341. return
  2342. }
  2343. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2344. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2345. for id := range m.wx_agent {
  2346. ids = append(ids, id)
  2347. }
  2348. return
  2349. }
  2350. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2351. func (m *AgentBaseMutation) ResetWxAgent() {
  2352. m.wx_agent = nil
  2353. m.clearedwx_agent = false
  2354. m.removedwx_agent = nil
  2355. }
  2356. // Where appends a list predicates to the AgentBaseMutation builder.
  2357. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2358. m.predicates = append(m.predicates, ps...)
  2359. }
  2360. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2361. // users can use type-assertion to append predicates that do not depend on any generated package.
  2362. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2363. p := make([]predicate.AgentBase, len(ps))
  2364. for i := range ps {
  2365. p[i] = ps[i]
  2366. }
  2367. m.Where(p...)
  2368. }
  2369. // Op returns the operation name.
  2370. func (m *AgentBaseMutation) Op() Op {
  2371. return m.op
  2372. }
  2373. // SetOp allows setting the mutation operation.
  2374. func (m *AgentBaseMutation) SetOp(op Op) {
  2375. m.op = op
  2376. }
  2377. // Type returns the node type of this mutation (AgentBase).
  2378. func (m *AgentBaseMutation) Type() string {
  2379. return m.typ
  2380. }
  2381. // Fields returns all fields that were changed during this mutation. Note that in
  2382. // order to get all numeric fields that were incremented/decremented, call
  2383. // AddedFields().
  2384. func (m *AgentBaseMutation) Fields() []string {
  2385. fields := make([]string, 0, 9)
  2386. if m.q != nil {
  2387. fields = append(fields, agentbase.FieldQ)
  2388. }
  2389. if m.a != nil {
  2390. fields = append(fields, agentbase.FieldA)
  2391. }
  2392. if m.chunk_index != nil {
  2393. fields = append(fields, agentbase.FieldChunkIndex)
  2394. }
  2395. if m.indexes != nil {
  2396. fields = append(fields, agentbase.FieldIndexes)
  2397. }
  2398. if m.dataset_id != nil {
  2399. fields = append(fields, agentbase.FieldDatasetID)
  2400. }
  2401. if m.collection_id != nil {
  2402. fields = append(fields, agentbase.FieldCollectionID)
  2403. }
  2404. if m.source_name != nil {
  2405. fields = append(fields, agentbase.FieldSourceName)
  2406. }
  2407. if m.can_write != nil {
  2408. fields = append(fields, agentbase.FieldCanWrite)
  2409. }
  2410. if m.is_owner != nil {
  2411. fields = append(fields, agentbase.FieldIsOwner)
  2412. }
  2413. return fields
  2414. }
  2415. // Field returns the value of a field with the given name. The second boolean
  2416. // return value indicates that this field was not set, or was not defined in the
  2417. // schema.
  2418. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2419. switch name {
  2420. case agentbase.FieldQ:
  2421. return m.Q()
  2422. case agentbase.FieldA:
  2423. return m.A()
  2424. case agentbase.FieldChunkIndex:
  2425. return m.ChunkIndex()
  2426. case agentbase.FieldIndexes:
  2427. return m.Indexes()
  2428. case agentbase.FieldDatasetID:
  2429. return m.DatasetID()
  2430. case agentbase.FieldCollectionID:
  2431. return m.CollectionID()
  2432. case agentbase.FieldSourceName:
  2433. return m.SourceName()
  2434. case agentbase.FieldCanWrite:
  2435. return m.CanWrite()
  2436. case agentbase.FieldIsOwner:
  2437. return m.IsOwner()
  2438. }
  2439. return nil, false
  2440. }
  2441. // OldField returns the old value of the field from the database. An error is
  2442. // returned if the mutation operation is not UpdateOne, or the query to the
  2443. // database failed.
  2444. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2445. switch name {
  2446. case agentbase.FieldQ:
  2447. return m.OldQ(ctx)
  2448. case agentbase.FieldA:
  2449. return m.OldA(ctx)
  2450. case agentbase.FieldChunkIndex:
  2451. return m.OldChunkIndex(ctx)
  2452. case agentbase.FieldIndexes:
  2453. return m.OldIndexes(ctx)
  2454. case agentbase.FieldDatasetID:
  2455. return m.OldDatasetID(ctx)
  2456. case agentbase.FieldCollectionID:
  2457. return m.OldCollectionID(ctx)
  2458. case agentbase.FieldSourceName:
  2459. return m.OldSourceName(ctx)
  2460. case agentbase.FieldCanWrite:
  2461. return m.OldCanWrite(ctx)
  2462. case agentbase.FieldIsOwner:
  2463. return m.OldIsOwner(ctx)
  2464. }
  2465. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2466. }
  2467. // SetField sets the value of a field with the given name. It returns an error if
  2468. // the field is not defined in the schema, or if the type mismatched the field
  2469. // type.
  2470. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2471. switch name {
  2472. case agentbase.FieldQ:
  2473. v, ok := value.(string)
  2474. if !ok {
  2475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2476. }
  2477. m.SetQ(v)
  2478. return nil
  2479. case agentbase.FieldA:
  2480. v, ok := value.(string)
  2481. if !ok {
  2482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2483. }
  2484. m.SetA(v)
  2485. return nil
  2486. case agentbase.FieldChunkIndex:
  2487. v, ok := value.(uint64)
  2488. if !ok {
  2489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2490. }
  2491. m.SetChunkIndex(v)
  2492. return nil
  2493. case agentbase.FieldIndexes:
  2494. v, ok := value.([]string)
  2495. if !ok {
  2496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2497. }
  2498. m.SetIndexes(v)
  2499. return nil
  2500. case agentbase.FieldDatasetID:
  2501. v, ok := value.(string)
  2502. if !ok {
  2503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2504. }
  2505. m.SetDatasetID(v)
  2506. return nil
  2507. case agentbase.FieldCollectionID:
  2508. v, ok := value.(string)
  2509. if !ok {
  2510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2511. }
  2512. m.SetCollectionID(v)
  2513. return nil
  2514. case agentbase.FieldSourceName:
  2515. v, ok := value.(string)
  2516. if !ok {
  2517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2518. }
  2519. m.SetSourceName(v)
  2520. return nil
  2521. case agentbase.FieldCanWrite:
  2522. v, ok := value.([]bool)
  2523. if !ok {
  2524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2525. }
  2526. m.SetCanWrite(v)
  2527. return nil
  2528. case agentbase.FieldIsOwner:
  2529. v, ok := value.([]bool)
  2530. if !ok {
  2531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2532. }
  2533. m.SetIsOwner(v)
  2534. return nil
  2535. }
  2536. return fmt.Errorf("unknown AgentBase field %s", name)
  2537. }
  2538. // AddedFields returns all numeric fields that were incremented/decremented during
  2539. // this mutation.
  2540. func (m *AgentBaseMutation) AddedFields() []string {
  2541. var fields []string
  2542. if m.addchunk_index != nil {
  2543. fields = append(fields, agentbase.FieldChunkIndex)
  2544. }
  2545. return fields
  2546. }
  2547. // AddedField returns the numeric value that was incremented/decremented on a field
  2548. // with the given name. The second boolean return value indicates that this field
  2549. // was not set, or was not defined in the schema.
  2550. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2551. switch name {
  2552. case agentbase.FieldChunkIndex:
  2553. return m.AddedChunkIndex()
  2554. }
  2555. return nil, false
  2556. }
  2557. // AddField adds the value to the field with the given name. It returns an error if
  2558. // the field is not defined in the schema, or if the type mismatched the field
  2559. // type.
  2560. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2561. switch name {
  2562. case agentbase.FieldChunkIndex:
  2563. v, ok := value.(int64)
  2564. if !ok {
  2565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2566. }
  2567. m.AddChunkIndex(v)
  2568. return nil
  2569. }
  2570. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2571. }
  2572. // ClearedFields returns all nullable fields that were cleared during this
  2573. // mutation.
  2574. func (m *AgentBaseMutation) ClearedFields() []string {
  2575. var fields []string
  2576. if m.FieldCleared(agentbase.FieldQ) {
  2577. fields = append(fields, agentbase.FieldQ)
  2578. }
  2579. if m.FieldCleared(agentbase.FieldA) {
  2580. fields = append(fields, agentbase.FieldA)
  2581. }
  2582. if m.FieldCleared(agentbase.FieldIndexes) {
  2583. fields = append(fields, agentbase.FieldIndexes)
  2584. }
  2585. if m.FieldCleared(agentbase.FieldDatasetID) {
  2586. fields = append(fields, agentbase.FieldDatasetID)
  2587. }
  2588. if m.FieldCleared(agentbase.FieldCollectionID) {
  2589. fields = append(fields, agentbase.FieldCollectionID)
  2590. }
  2591. if m.FieldCleared(agentbase.FieldSourceName) {
  2592. fields = append(fields, agentbase.FieldSourceName)
  2593. }
  2594. if m.FieldCleared(agentbase.FieldCanWrite) {
  2595. fields = append(fields, agentbase.FieldCanWrite)
  2596. }
  2597. if m.FieldCleared(agentbase.FieldIsOwner) {
  2598. fields = append(fields, agentbase.FieldIsOwner)
  2599. }
  2600. return fields
  2601. }
  2602. // FieldCleared returns a boolean indicating if a field with the given name was
  2603. // cleared in this mutation.
  2604. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2605. _, ok := m.clearedFields[name]
  2606. return ok
  2607. }
  2608. // ClearField clears the value of the field with the given name. It returns an
  2609. // error if the field is not defined in the schema.
  2610. func (m *AgentBaseMutation) ClearField(name string) error {
  2611. switch name {
  2612. case agentbase.FieldQ:
  2613. m.ClearQ()
  2614. return nil
  2615. case agentbase.FieldA:
  2616. m.ClearA()
  2617. return nil
  2618. case agentbase.FieldIndexes:
  2619. m.ClearIndexes()
  2620. return nil
  2621. case agentbase.FieldDatasetID:
  2622. m.ClearDatasetID()
  2623. return nil
  2624. case agentbase.FieldCollectionID:
  2625. m.ClearCollectionID()
  2626. return nil
  2627. case agentbase.FieldSourceName:
  2628. m.ClearSourceName()
  2629. return nil
  2630. case agentbase.FieldCanWrite:
  2631. m.ClearCanWrite()
  2632. return nil
  2633. case agentbase.FieldIsOwner:
  2634. m.ClearIsOwner()
  2635. return nil
  2636. }
  2637. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2638. }
  2639. // ResetField resets all changes in the mutation for the field with the given name.
  2640. // It returns an error if the field is not defined in the schema.
  2641. func (m *AgentBaseMutation) ResetField(name string) error {
  2642. switch name {
  2643. case agentbase.FieldQ:
  2644. m.ResetQ()
  2645. return nil
  2646. case agentbase.FieldA:
  2647. m.ResetA()
  2648. return nil
  2649. case agentbase.FieldChunkIndex:
  2650. m.ResetChunkIndex()
  2651. return nil
  2652. case agentbase.FieldIndexes:
  2653. m.ResetIndexes()
  2654. return nil
  2655. case agentbase.FieldDatasetID:
  2656. m.ResetDatasetID()
  2657. return nil
  2658. case agentbase.FieldCollectionID:
  2659. m.ResetCollectionID()
  2660. return nil
  2661. case agentbase.FieldSourceName:
  2662. m.ResetSourceName()
  2663. return nil
  2664. case agentbase.FieldCanWrite:
  2665. m.ResetCanWrite()
  2666. return nil
  2667. case agentbase.FieldIsOwner:
  2668. m.ResetIsOwner()
  2669. return nil
  2670. }
  2671. return fmt.Errorf("unknown AgentBase field %s", name)
  2672. }
  2673. // AddedEdges returns all edge names that were set/added in this mutation.
  2674. func (m *AgentBaseMutation) AddedEdges() []string {
  2675. edges := make([]string, 0, 1)
  2676. if m.wx_agent != nil {
  2677. edges = append(edges, agentbase.EdgeWxAgent)
  2678. }
  2679. return edges
  2680. }
  2681. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2682. // name in this mutation.
  2683. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2684. switch name {
  2685. case agentbase.EdgeWxAgent:
  2686. ids := make([]ent.Value, 0, len(m.wx_agent))
  2687. for id := range m.wx_agent {
  2688. ids = append(ids, id)
  2689. }
  2690. return ids
  2691. }
  2692. return nil
  2693. }
  2694. // RemovedEdges returns all edge names that were removed in this mutation.
  2695. func (m *AgentBaseMutation) RemovedEdges() []string {
  2696. edges := make([]string, 0, 1)
  2697. if m.removedwx_agent != nil {
  2698. edges = append(edges, agentbase.EdgeWxAgent)
  2699. }
  2700. return edges
  2701. }
  2702. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2703. // the given name in this mutation.
  2704. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2705. switch name {
  2706. case agentbase.EdgeWxAgent:
  2707. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2708. for id := range m.removedwx_agent {
  2709. ids = append(ids, id)
  2710. }
  2711. return ids
  2712. }
  2713. return nil
  2714. }
  2715. // ClearedEdges returns all edge names that were cleared in this mutation.
  2716. func (m *AgentBaseMutation) ClearedEdges() []string {
  2717. edges := make([]string, 0, 1)
  2718. if m.clearedwx_agent {
  2719. edges = append(edges, agentbase.EdgeWxAgent)
  2720. }
  2721. return edges
  2722. }
  2723. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2724. // was cleared in this mutation.
  2725. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2726. switch name {
  2727. case agentbase.EdgeWxAgent:
  2728. return m.clearedwx_agent
  2729. }
  2730. return false
  2731. }
  2732. // ClearEdge clears the value of the edge with the given name. It returns an error
  2733. // if that edge is not defined in the schema.
  2734. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2735. switch name {
  2736. }
  2737. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2738. }
  2739. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2740. // It returns an error if the edge is not defined in the schema.
  2741. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2742. switch name {
  2743. case agentbase.EdgeWxAgent:
  2744. m.ResetWxAgent()
  2745. return nil
  2746. }
  2747. return fmt.Errorf("unknown AgentBase edge %s", name)
  2748. }
  2749. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2750. type AliyunAvatarMutation struct {
  2751. config
  2752. op Op
  2753. typ string
  2754. id *uint64
  2755. created_at *time.Time
  2756. updated_at *time.Time
  2757. deleted_at *time.Time
  2758. user_id *uint64
  2759. adduser_id *int64
  2760. biz_id *string
  2761. access_key_id *string
  2762. access_key_secret *string
  2763. app_id *string
  2764. tenant_id *uint64
  2765. addtenant_id *int64
  2766. response *string
  2767. token *string
  2768. session_id *string
  2769. clearedFields map[string]struct{}
  2770. done bool
  2771. oldValue func(context.Context) (*AliyunAvatar, error)
  2772. predicates []predicate.AliyunAvatar
  2773. }
  2774. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2775. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2776. type aliyunavatarOption func(*AliyunAvatarMutation)
  2777. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2778. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2779. m := &AliyunAvatarMutation{
  2780. config: c,
  2781. op: op,
  2782. typ: TypeAliyunAvatar,
  2783. clearedFields: make(map[string]struct{}),
  2784. }
  2785. for _, opt := range opts {
  2786. opt(m)
  2787. }
  2788. return m
  2789. }
  2790. // withAliyunAvatarID sets the ID field of the mutation.
  2791. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2792. return func(m *AliyunAvatarMutation) {
  2793. var (
  2794. err error
  2795. once sync.Once
  2796. value *AliyunAvatar
  2797. )
  2798. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2799. once.Do(func() {
  2800. if m.done {
  2801. err = errors.New("querying old values post mutation is not allowed")
  2802. } else {
  2803. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2804. }
  2805. })
  2806. return value, err
  2807. }
  2808. m.id = &id
  2809. }
  2810. }
  2811. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2812. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2813. return func(m *AliyunAvatarMutation) {
  2814. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2815. return node, nil
  2816. }
  2817. m.id = &node.ID
  2818. }
  2819. }
  2820. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2821. // executed in a transaction (ent.Tx), a transactional client is returned.
  2822. func (m AliyunAvatarMutation) Client() *Client {
  2823. client := &Client{config: m.config}
  2824. client.init()
  2825. return client
  2826. }
  2827. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2828. // it returns an error otherwise.
  2829. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2830. if _, ok := m.driver.(*txDriver); !ok {
  2831. return nil, errors.New("ent: mutation is not running in a transaction")
  2832. }
  2833. tx := &Tx{config: m.config}
  2834. tx.init()
  2835. return tx, nil
  2836. }
  2837. // SetID sets the value of the id field. Note that this
  2838. // operation is only accepted on creation of AliyunAvatar entities.
  2839. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2840. m.id = &id
  2841. }
  2842. // ID returns the ID value in the mutation. Note that the ID is only available
  2843. // if it was provided to the builder or after it was returned from the database.
  2844. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2845. if m.id == nil {
  2846. return
  2847. }
  2848. return *m.id, true
  2849. }
  2850. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2851. // That means, if the mutation is applied within a transaction with an isolation level such
  2852. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2853. // or updated by the mutation.
  2854. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2855. switch {
  2856. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2857. id, exists := m.ID()
  2858. if exists {
  2859. return []uint64{id}, nil
  2860. }
  2861. fallthrough
  2862. case m.op.Is(OpUpdate | OpDelete):
  2863. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2864. default:
  2865. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2866. }
  2867. }
  2868. // SetCreatedAt sets the "created_at" field.
  2869. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2870. m.created_at = &t
  2871. }
  2872. // CreatedAt returns the value of the "created_at" field in the mutation.
  2873. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2874. v := m.created_at
  2875. if v == nil {
  2876. return
  2877. }
  2878. return *v, true
  2879. }
  2880. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2881. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2883. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2884. if !m.op.Is(OpUpdateOne) {
  2885. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2886. }
  2887. if m.id == nil || m.oldValue == nil {
  2888. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2889. }
  2890. oldValue, err := m.oldValue(ctx)
  2891. if err != nil {
  2892. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2893. }
  2894. return oldValue.CreatedAt, nil
  2895. }
  2896. // ResetCreatedAt resets all changes to the "created_at" field.
  2897. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2898. m.created_at = nil
  2899. }
  2900. // SetUpdatedAt sets the "updated_at" field.
  2901. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2902. m.updated_at = &t
  2903. }
  2904. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2905. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2906. v := m.updated_at
  2907. if v == nil {
  2908. return
  2909. }
  2910. return *v, true
  2911. }
  2912. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2913. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2915. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2916. if !m.op.Is(OpUpdateOne) {
  2917. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2918. }
  2919. if m.id == nil || m.oldValue == nil {
  2920. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2921. }
  2922. oldValue, err := m.oldValue(ctx)
  2923. if err != nil {
  2924. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2925. }
  2926. return oldValue.UpdatedAt, nil
  2927. }
  2928. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2929. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2930. m.updated_at = nil
  2931. }
  2932. // SetDeletedAt sets the "deleted_at" field.
  2933. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2934. m.deleted_at = &t
  2935. }
  2936. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2937. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2938. v := m.deleted_at
  2939. if v == nil {
  2940. return
  2941. }
  2942. return *v, true
  2943. }
  2944. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2945. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2947. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2948. if !m.op.Is(OpUpdateOne) {
  2949. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2950. }
  2951. if m.id == nil || m.oldValue == nil {
  2952. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2953. }
  2954. oldValue, err := m.oldValue(ctx)
  2955. if err != nil {
  2956. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2957. }
  2958. return oldValue.DeletedAt, nil
  2959. }
  2960. // ClearDeletedAt clears the value of the "deleted_at" field.
  2961. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2962. m.deleted_at = nil
  2963. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2964. }
  2965. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2966. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2967. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2968. return ok
  2969. }
  2970. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2971. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2972. m.deleted_at = nil
  2973. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2974. }
  2975. // SetUserID sets the "user_id" field.
  2976. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2977. m.user_id = &u
  2978. m.adduser_id = nil
  2979. }
  2980. // UserID returns the value of the "user_id" field in the mutation.
  2981. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2982. v := m.user_id
  2983. if v == nil {
  2984. return
  2985. }
  2986. return *v, true
  2987. }
  2988. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2989. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2991. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2992. if !m.op.Is(OpUpdateOne) {
  2993. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2994. }
  2995. if m.id == nil || m.oldValue == nil {
  2996. return v, errors.New("OldUserID requires an ID field in the mutation")
  2997. }
  2998. oldValue, err := m.oldValue(ctx)
  2999. if err != nil {
  3000. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3001. }
  3002. return oldValue.UserID, nil
  3003. }
  3004. // AddUserID adds u to the "user_id" field.
  3005. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  3006. if m.adduser_id != nil {
  3007. *m.adduser_id += u
  3008. } else {
  3009. m.adduser_id = &u
  3010. }
  3011. }
  3012. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  3013. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  3014. v := m.adduser_id
  3015. if v == nil {
  3016. return
  3017. }
  3018. return *v, true
  3019. }
  3020. // ResetUserID resets all changes to the "user_id" field.
  3021. func (m *AliyunAvatarMutation) ResetUserID() {
  3022. m.user_id = nil
  3023. m.adduser_id = nil
  3024. }
  3025. // SetBizID sets the "biz_id" field.
  3026. func (m *AliyunAvatarMutation) SetBizID(s string) {
  3027. m.biz_id = &s
  3028. }
  3029. // BizID returns the value of the "biz_id" field in the mutation.
  3030. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  3031. v := m.biz_id
  3032. if v == nil {
  3033. return
  3034. }
  3035. return *v, true
  3036. }
  3037. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  3038. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3040. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  3041. if !m.op.Is(OpUpdateOne) {
  3042. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  3043. }
  3044. if m.id == nil || m.oldValue == nil {
  3045. return v, errors.New("OldBizID requires an ID field in the mutation")
  3046. }
  3047. oldValue, err := m.oldValue(ctx)
  3048. if err != nil {
  3049. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  3050. }
  3051. return oldValue.BizID, nil
  3052. }
  3053. // ResetBizID resets all changes to the "biz_id" field.
  3054. func (m *AliyunAvatarMutation) ResetBizID() {
  3055. m.biz_id = nil
  3056. }
  3057. // SetAccessKeyID sets the "access_key_id" field.
  3058. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  3059. m.access_key_id = &s
  3060. }
  3061. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  3062. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  3063. v := m.access_key_id
  3064. if v == nil {
  3065. return
  3066. }
  3067. return *v, true
  3068. }
  3069. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  3070. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3072. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  3073. if !m.op.Is(OpUpdateOne) {
  3074. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  3075. }
  3076. if m.id == nil || m.oldValue == nil {
  3077. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  3078. }
  3079. oldValue, err := m.oldValue(ctx)
  3080. if err != nil {
  3081. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  3082. }
  3083. return oldValue.AccessKeyID, nil
  3084. }
  3085. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3086. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3087. m.access_key_id = nil
  3088. }
  3089. // SetAccessKeySecret sets the "access_key_secret" field.
  3090. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3091. m.access_key_secret = &s
  3092. }
  3093. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3094. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3095. v := m.access_key_secret
  3096. if v == nil {
  3097. return
  3098. }
  3099. return *v, true
  3100. }
  3101. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3102. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3104. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3105. if !m.op.Is(OpUpdateOne) {
  3106. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3107. }
  3108. if m.id == nil || m.oldValue == nil {
  3109. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3110. }
  3111. oldValue, err := m.oldValue(ctx)
  3112. if err != nil {
  3113. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3114. }
  3115. return oldValue.AccessKeySecret, nil
  3116. }
  3117. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3118. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3119. m.access_key_secret = nil
  3120. }
  3121. // SetAppID sets the "app_id" field.
  3122. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3123. m.app_id = &s
  3124. }
  3125. // AppID returns the value of the "app_id" field in the mutation.
  3126. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3127. v := m.app_id
  3128. if v == nil {
  3129. return
  3130. }
  3131. return *v, true
  3132. }
  3133. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3134. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3136. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3137. if !m.op.Is(OpUpdateOne) {
  3138. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3139. }
  3140. if m.id == nil || m.oldValue == nil {
  3141. return v, errors.New("OldAppID requires an ID field in the mutation")
  3142. }
  3143. oldValue, err := m.oldValue(ctx)
  3144. if err != nil {
  3145. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3146. }
  3147. return oldValue.AppID, nil
  3148. }
  3149. // ClearAppID clears the value of the "app_id" field.
  3150. func (m *AliyunAvatarMutation) ClearAppID() {
  3151. m.app_id = nil
  3152. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3153. }
  3154. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3155. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3156. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3157. return ok
  3158. }
  3159. // ResetAppID resets all changes to the "app_id" field.
  3160. func (m *AliyunAvatarMutation) ResetAppID() {
  3161. m.app_id = nil
  3162. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3163. }
  3164. // SetTenantID sets the "tenant_id" field.
  3165. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3166. m.tenant_id = &u
  3167. m.addtenant_id = nil
  3168. }
  3169. // TenantID returns the value of the "tenant_id" field in the mutation.
  3170. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3171. v := m.tenant_id
  3172. if v == nil {
  3173. return
  3174. }
  3175. return *v, true
  3176. }
  3177. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3178. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3180. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3181. if !m.op.Is(OpUpdateOne) {
  3182. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3183. }
  3184. if m.id == nil || m.oldValue == nil {
  3185. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3186. }
  3187. oldValue, err := m.oldValue(ctx)
  3188. if err != nil {
  3189. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3190. }
  3191. return oldValue.TenantID, nil
  3192. }
  3193. // AddTenantID adds u to the "tenant_id" field.
  3194. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3195. if m.addtenant_id != nil {
  3196. *m.addtenant_id += u
  3197. } else {
  3198. m.addtenant_id = &u
  3199. }
  3200. }
  3201. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3202. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3203. v := m.addtenant_id
  3204. if v == nil {
  3205. return
  3206. }
  3207. return *v, true
  3208. }
  3209. // ResetTenantID resets all changes to the "tenant_id" field.
  3210. func (m *AliyunAvatarMutation) ResetTenantID() {
  3211. m.tenant_id = nil
  3212. m.addtenant_id = nil
  3213. }
  3214. // SetResponse sets the "response" field.
  3215. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3216. m.response = &s
  3217. }
  3218. // Response returns the value of the "response" field in the mutation.
  3219. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3220. v := m.response
  3221. if v == nil {
  3222. return
  3223. }
  3224. return *v, true
  3225. }
  3226. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3227. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3229. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3230. if !m.op.Is(OpUpdateOne) {
  3231. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3232. }
  3233. if m.id == nil || m.oldValue == nil {
  3234. return v, errors.New("OldResponse requires an ID field in the mutation")
  3235. }
  3236. oldValue, err := m.oldValue(ctx)
  3237. if err != nil {
  3238. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3239. }
  3240. return oldValue.Response, nil
  3241. }
  3242. // ResetResponse resets all changes to the "response" field.
  3243. func (m *AliyunAvatarMutation) ResetResponse() {
  3244. m.response = nil
  3245. }
  3246. // SetToken sets the "token" field.
  3247. func (m *AliyunAvatarMutation) SetToken(s string) {
  3248. m.token = &s
  3249. }
  3250. // Token returns the value of the "token" field in the mutation.
  3251. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3252. v := m.token
  3253. if v == nil {
  3254. return
  3255. }
  3256. return *v, true
  3257. }
  3258. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3259. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3261. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3262. if !m.op.Is(OpUpdateOne) {
  3263. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3264. }
  3265. if m.id == nil || m.oldValue == nil {
  3266. return v, errors.New("OldToken requires an ID field in the mutation")
  3267. }
  3268. oldValue, err := m.oldValue(ctx)
  3269. if err != nil {
  3270. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3271. }
  3272. return oldValue.Token, nil
  3273. }
  3274. // ResetToken resets all changes to the "token" field.
  3275. func (m *AliyunAvatarMutation) ResetToken() {
  3276. m.token = nil
  3277. }
  3278. // SetSessionID sets the "session_id" field.
  3279. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3280. m.session_id = &s
  3281. }
  3282. // SessionID returns the value of the "session_id" field in the mutation.
  3283. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3284. v := m.session_id
  3285. if v == nil {
  3286. return
  3287. }
  3288. return *v, true
  3289. }
  3290. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3291. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3293. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3294. if !m.op.Is(OpUpdateOne) {
  3295. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3296. }
  3297. if m.id == nil || m.oldValue == nil {
  3298. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3299. }
  3300. oldValue, err := m.oldValue(ctx)
  3301. if err != nil {
  3302. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3303. }
  3304. return oldValue.SessionID, nil
  3305. }
  3306. // ResetSessionID resets all changes to the "session_id" field.
  3307. func (m *AliyunAvatarMutation) ResetSessionID() {
  3308. m.session_id = nil
  3309. }
  3310. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3311. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3312. m.predicates = append(m.predicates, ps...)
  3313. }
  3314. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3315. // users can use type-assertion to append predicates that do not depend on any generated package.
  3316. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3317. p := make([]predicate.AliyunAvatar, len(ps))
  3318. for i := range ps {
  3319. p[i] = ps[i]
  3320. }
  3321. m.Where(p...)
  3322. }
  3323. // Op returns the operation name.
  3324. func (m *AliyunAvatarMutation) Op() Op {
  3325. return m.op
  3326. }
  3327. // SetOp allows setting the mutation operation.
  3328. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3329. m.op = op
  3330. }
  3331. // Type returns the node type of this mutation (AliyunAvatar).
  3332. func (m *AliyunAvatarMutation) Type() string {
  3333. return m.typ
  3334. }
  3335. // Fields returns all fields that were changed during this mutation. Note that in
  3336. // order to get all numeric fields that were incremented/decremented, call
  3337. // AddedFields().
  3338. func (m *AliyunAvatarMutation) Fields() []string {
  3339. fields := make([]string, 0, 12)
  3340. if m.created_at != nil {
  3341. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3342. }
  3343. if m.updated_at != nil {
  3344. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3345. }
  3346. if m.deleted_at != nil {
  3347. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3348. }
  3349. if m.user_id != nil {
  3350. fields = append(fields, aliyunavatar.FieldUserID)
  3351. }
  3352. if m.biz_id != nil {
  3353. fields = append(fields, aliyunavatar.FieldBizID)
  3354. }
  3355. if m.access_key_id != nil {
  3356. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3357. }
  3358. if m.access_key_secret != nil {
  3359. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3360. }
  3361. if m.app_id != nil {
  3362. fields = append(fields, aliyunavatar.FieldAppID)
  3363. }
  3364. if m.tenant_id != nil {
  3365. fields = append(fields, aliyunavatar.FieldTenantID)
  3366. }
  3367. if m.response != nil {
  3368. fields = append(fields, aliyunavatar.FieldResponse)
  3369. }
  3370. if m.token != nil {
  3371. fields = append(fields, aliyunavatar.FieldToken)
  3372. }
  3373. if m.session_id != nil {
  3374. fields = append(fields, aliyunavatar.FieldSessionID)
  3375. }
  3376. return fields
  3377. }
  3378. // Field returns the value of a field with the given name. The second boolean
  3379. // return value indicates that this field was not set, or was not defined in the
  3380. // schema.
  3381. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3382. switch name {
  3383. case aliyunavatar.FieldCreatedAt:
  3384. return m.CreatedAt()
  3385. case aliyunavatar.FieldUpdatedAt:
  3386. return m.UpdatedAt()
  3387. case aliyunavatar.FieldDeletedAt:
  3388. return m.DeletedAt()
  3389. case aliyunavatar.FieldUserID:
  3390. return m.UserID()
  3391. case aliyunavatar.FieldBizID:
  3392. return m.BizID()
  3393. case aliyunavatar.FieldAccessKeyID:
  3394. return m.AccessKeyID()
  3395. case aliyunavatar.FieldAccessKeySecret:
  3396. return m.AccessKeySecret()
  3397. case aliyunavatar.FieldAppID:
  3398. return m.AppID()
  3399. case aliyunavatar.FieldTenantID:
  3400. return m.TenantID()
  3401. case aliyunavatar.FieldResponse:
  3402. return m.Response()
  3403. case aliyunavatar.FieldToken:
  3404. return m.Token()
  3405. case aliyunavatar.FieldSessionID:
  3406. return m.SessionID()
  3407. }
  3408. return nil, false
  3409. }
  3410. // OldField returns the old value of the field from the database. An error is
  3411. // returned if the mutation operation is not UpdateOne, or the query to the
  3412. // database failed.
  3413. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3414. switch name {
  3415. case aliyunavatar.FieldCreatedAt:
  3416. return m.OldCreatedAt(ctx)
  3417. case aliyunavatar.FieldUpdatedAt:
  3418. return m.OldUpdatedAt(ctx)
  3419. case aliyunavatar.FieldDeletedAt:
  3420. return m.OldDeletedAt(ctx)
  3421. case aliyunavatar.FieldUserID:
  3422. return m.OldUserID(ctx)
  3423. case aliyunavatar.FieldBizID:
  3424. return m.OldBizID(ctx)
  3425. case aliyunavatar.FieldAccessKeyID:
  3426. return m.OldAccessKeyID(ctx)
  3427. case aliyunavatar.FieldAccessKeySecret:
  3428. return m.OldAccessKeySecret(ctx)
  3429. case aliyunavatar.FieldAppID:
  3430. return m.OldAppID(ctx)
  3431. case aliyunavatar.FieldTenantID:
  3432. return m.OldTenantID(ctx)
  3433. case aliyunavatar.FieldResponse:
  3434. return m.OldResponse(ctx)
  3435. case aliyunavatar.FieldToken:
  3436. return m.OldToken(ctx)
  3437. case aliyunavatar.FieldSessionID:
  3438. return m.OldSessionID(ctx)
  3439. }
  3440. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3441. }
  3442. // SetField sets the value of a field with the given name. It returns an error if
  3443. // the field is not defined in the schema, or if the type mismatched the field
  3444. // type.
  3445. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3446. switch name {
  3447. case aliyunavatar.FieldCreatedAt:
  3448. v, ok := value.(time.Time)
  3449. if !ok {
  3450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3451. }
  3452. m.SetCreatedAt(v)
  3453. return nil
  3454. case aliyunavatar.FieldUpdatedAt:
  3455. v, ok := value.(time.Time)
  3456. if !ok {
  3457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3458. }
  3459. m.SetUpdatedAt(v)
  3460. return nil
  3461. case aliyunavatar.FieldDeletedAt:
  3462. v, ok := value.(time.Time)
  3463. if !ok {
  3464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3465. }
  3466. m.SetDeletedAt(v)
  3467. return nil
  3468. case aliyunavatar.FieldUserID:
  3469. v, ok := value.(uint64)
  3470. if !ok {
  3471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3472. }
  3473. m.SetUserID(v)
  3474. return nil
  3475. case aliyunavatar.FieldBizID:
  3476. v, ok := value.(string)
  3477. if !ok {
  3478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3479. }
  3480. m.SetBizID(v)
  3481. return nil
  3482. case aliyunavatar.FieldAccessKeyID:
  3483. v, ok := value.(string)
  3484. if !ok {
  3485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3486. }
  3487. m.SetAccessKeyID(v)
  3488. return nil
  3489. case aliyunavatar.FieldAccessKeySecret:
  3490. v, ok := value.(string)
  3491. if !ok {
  3492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3493. }
  3494. m.SetAccessKeySecret(v)
  3495. return nil
  3496. case aliyunavatar.FieldAppID:
  3497. v, ok := value.(string)
  3498. if !ok {
  3499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3500. }
  3501. m.SetAppID(v)
  3502. return nil
  3503. case aliyunavatar.FieldTenantID:
  3504. v, ok := value.(uint64)
  3505. if !ok {
  3506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3507. }
  3508. m.SetTenantID(v)
  3509. return nil
  3510. case aliyunavatar.FieldResponse:
  3511. v, ok := value.(string)
  3512. if !ok {
  3513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3514. }
  3515. m.SetResponse(v)
  3516. return nil
  3517. case aliyunavatar.FieldToken:
  3518. v, ok := value.(string)
  3519. if !ok {
  3520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3521. }
  3522. m.SetToken(v)
  3523. return nil
  3524. case aliyunavatar.FieldSessionID:
  3525. v, ok := value.(string)
  3526. if !ok {
  3527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3528. }
  3529. m.SetSessionID(v)
  3530. return nil
  3531. }
  3532. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3533. }
  3534. // AddedFields returns all numeric fields that were incremented/decremented during
  3535. // this mutation.
  3536. func (m *AliyunAvatarMutation) AddedFields() []string {
  3537. var fields []string
  3538. if m.adduser_id != nil {
  3539. fields = append(fields, aliyunavatar.FieldUserID)
  3540. }
  3541. if m.addtenant_id != nil {
  3542. fields = append(fields, aliyunavatar.FieldTenantID)
  3543. }
  3544. return fields
  3545. }
  3546. // AddedField returns the numeric value that was incremented/decremented on a field
  3547. // with the given name. The second boolean return value indicates that this field
  3548. // was not set, or was not defined in the schema.
  3549. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3550. switch name {
  3551. case aliyunavatar.FieldUserID:
  3552. return m.AddedUserID()
  3553. case aliyunavatar.FieldTenantID:
  3554. return m.AddedTenantID()
  3555. }
  3556. return nil, false
  3557. }
  3558. // AddField adds the value to the field with the given name. It returns an error if
  3559. // the field is not defined in the schema, or if the type mismatched the field
  3560. // type.
  3561. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3562. switch name {
  3563. case aliyunavatar.FieldUserID:
  3564. v, ok := value.(int64)
  3565. if !ok {
  3566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3567. }
  3568. m.AddUserID(v)
  3569. return nil
  3570. case aliyunavatar.FieldTenantID:
  3571. v, ok := value.(int64)
  3572. if !ok {
  3573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3574. }
  3575. m.AddTenantID(v)
  3576. return nil
  3577. }
  3578. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3579. }
  3580. // ClearedFields returns all nullable fields that were cleared during this
  3581. // mutation.
  3582. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3583. var fields []string
  3584. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3585. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3586. }
  3587. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3588. fields = append(fields, aliyunavatar.FieldAppID)
  3589. }
  3590. return fields
  3591. }
  3592. // FieldCleared returns a boolean indicating if a field with the given name was
  3593. // cleared in this mutation.
  3594. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3595. _, ok := m.clearedFields[name]
  3596. return ok
  3597. }
  3598. // ClearField clears the value of the field with the given name. It returns an
  3599. // error if the field is not defined in the schema.
  3600. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3601. switch name {
  3602. case aliyunavatar.FieldDeletedAt:
  3603. m.ClearDeletedAt()
  3604. return nil
  3605. case aliyunavatar.FieldAppID:
  3606. m.ClearAppID()
  3607. return nil
  3608. }
  3609. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3610. }
  3611. // ResetField resets all changes in the mutation for the field with the given name.
  3612. // It returns an error if the field is not defined in the schema.
  3613. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3614. switch name {
  3615. case aliyunavatar.FieldCreatedAt:
  3616. m.ResetCreatedAt()
  3617. return nil
  3618. case aliyunavatar.FieldUpdatedAt:
  3619. m.ResetUpdatedAt()
  3620. return nil
  3621. case aliyunavatar.FieldDeletedAt:
  3622. m.ResetDeletedAt()
  3623. return nil
  3624. case aliyunavatar.FieldUserID:
  3625. m.ResetUserID()
  3626. return nil
  3627. case aliyunavatar.FieldBizID:
  3628. m.ResetBizID()
  3629. return nil
  3630. case aliyunavatar.FieldAccessKeyID:
  3631. m.ResetAccessKeyID()
  3632. return nil
  3633. case aliyunavatar.FieldAccessKeySecret:
  3634. m.ResetAccessKeySecret()
  3635. return nil
  3636. case aliyunavatar.FieldAppID:
  3637. m.ResetAppID()
  3638. return nil
  3639. case aliyunavatar.FieldTenantID:
  3640. m.ResetTenantID()
  3641. return nil
  3642. case aliyunavatar.FieldResponse:
  3643. m.ResetResponse()
  3644. return nil
  3645. case aliyunavatar.FieldToken:
  3646. m.ResetToken()
  3647. return nil
  3648. case aliyunavatar.FieldSessionID:
  3649. m.ResetSessionID()
  3650. return nil
  3651. }
  3652. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3653. }
  3654. // AddedEdges returns all edge names that were set/added in this mutation.
  3655. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3656. edges := make([]string, 0, 0)
  3657. return edges
  3658. }
  3659. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3660. // name in this mutation.
  3661. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3662. return nil
  3663. }
  3664. // RemovedEdges returns all edge names that were removed in this mutation.
  3665. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3666. edges := make([]string, 0, 0)
  3667. return edges
  3668. }
  3669. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3670. // the given name in this mutation.
  3671. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3672. return nil
  3673. }
  3674. // ClearedEdges returns all edge names that were cleared in this mutation.
  3675. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3676. edges := make([]string, 0, 0)
  3677. return edges
  3678. }
  3679. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3680. // was cleared in this mutation.
  3681. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3682. return false
  3683. }
  3684. // ClearEdge clears the value of the edge with the given name. It returns an error
  3685. // if that edge is not defined in the schema.
  3686. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3687. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3688. }
  3689. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3690. // It returns an error if the edge is not defined in the schema.
  3691. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3692. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3693. }
  3694. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3695. type AllocAgentMutation struct {
  3696. config
  3697. op Op
  3698. typ string
  3699. id *uint64
  3700. created_at *time.Time
  3701. updated_at *time.Time
  3702. deleted_at *time.Time
  3703. user_id *string
  3704. organization_id *uint64
  3705. addorganization_id *int64
  3706. agents *[]uint64
  3707. appendagents []uint64
  3708. status *int
  3709. addstatus *int
  3710. clearedFields map[string]struct{}
  3711. done bool
  3712. oldValue func(context.Context) (*AllocAgent, error)
  3713. predicates []predicate.AllocAgent
  3714. }
  3715. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3716. // allocagentOption allows management of the mutation configuration using functional options.
  3717. type allocagentOption func(*AllocAgentMutation)
  3718. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3719. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3720. m := &AllocAgentMutation{
  3721. config: c,
  3722. op: op,
  3723. typ: TypeAllocAgent,
  3724. clearedFields: make(map[string]struct{}),
  3725. }
  3726. for _, opt := range opts {
  3727. opt(m)
  3728. }
  3729. return m
  3730. }
  3731. // withAllocAgentID sets the ID field of the mutation.
  3732. func withAllocAgentID(id uint64) allocagentOption {
  3733. return func(m *AllocAgentMutation) {
  3734. var (
  3735. err error
  3736. once sync.Once
  3737. value *AllocAgent
  3738. )
  3739. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3740. once.Do(func() {
  3741. if m.done {
  3742. err = errors.New("querying old values post mutation is not allowed")
  3743. } else {
  3744. value, err = m.Client().AllocAgent.Get(ctx, id)
  3745. }
  3746. })
  3747. return value, err
  3748. }
  3749. m.id = &id
  3750. }
  3751. }
  3752. // withAllocAgent sets the old AllocAgent of the mutation.
  3753. func withAllocAgent(node *AllocAgent) allocagentOption {
  3754. return func(m *AllocAgentMutation) {
  3755. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3756. return node, nil
  3757. }
  3758. m.id = &node.ID
  3759. }
  3760. }
  3761. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3762. // executed in a transaction (ent.Tx), a transactional client is returned.
  3763. func (m AllocAgentMutation) Client() *Client {
  3764. client := &Client{config: m.config}
  3765. client.init()
  3766. return client
  3767. }
  3768. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3769. // it returns an error otherwise.
  3770. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3771. if _, ok := m.driver.(*txDriver); !ok {
  3772. return nil, errors.New("ent: mutation is not running in a transaction")
  3773. }
  3774. tx := &Tx{config: m.config}
  3775. tx.init()
  3776. return tx, nil
  3777. }
  3778. // SetID sets the value of the id field. Note that this
  3779. // operation is only accepted on creation of AllocAgent entities.
  3780. func (m *AllocAgentMutation) SetID(id uint64) {
  3781. m.id = &id
  3782. }
  3783. // ID returns the ID value in the mutation. Note that the ID is only available
  3784. // if it was provided to the builder or after it was returned from the database.
  3785. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3786. if m.id == nil {
  3787. return
  3788. }
  3789. return *m.id, true
  3790. }
  3791. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3792. // That means, if the mutation is applied within a transaction with an isolation level such
  3793. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3794. // or updated by the mutation.
  3795. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3796. switch {
  3797. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3798. id, exists := m.ID()
  3799. if exists {
  3800. return []uint64{id}, nil
  3801. }
  3802. fallthrough
  3803. case m.op.Is(OpUpdate | OpDelete):
  3804. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3805. default:
  3806. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3807. }
  3808. }
  3809. // SetCreatedAt sets the "created_at" field.
  3810. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3811. m.created_at = &t
  3812. }
  3813. // CreatedAt returns the value of the "created_at" field in the mutation.
  3814. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3815. v := m.created_at
  3816. if v == nil {
  3817. return
  3818. }
  3819. return *v, true
  3820. }
  3821. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3822. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3824. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3825. if !m.op.Is(OpUpdateOne) {
  3826. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3827. }
  3828. if m.id == nil || m.oldValue == nil {
  3829. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3830. }
  3831. oldValue, err := m.oldValue(ctx)
  3832. if err != nil {
  3833. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3834. }
  3835. return oldValue.CreatedAt, nil
  3836. }
  3837. // ResetCreatedAt resets all changes to the "created_at" field.
  3838. func (m *AllocAgentMutation) ResetCreatedAt() {
  3839. m.created_at = nil
  3840. }
  3841. // SetUpdatedAt sets the "updated_at" field.
  3842. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3843. m.updated_at = &t
  3844. }
  3845. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3846. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3847. v := m.updated_at
  3848. if v == nil {
  3849. return
  3850. }
  3851. return *v, true
  3852. }
  3853. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3854. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3856. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3857. if !m.op.Is(OpUpdateOne) {
  3858. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3859. }
  3860. if m.id == nil || m.oldValue == nil {
  3861. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3862. }
  3863. oldValue, err := m.oldValue(ctx)
  3864. if err != nil {
  3865. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3866. }
  3867. return oldValue.UpdatedAt, nil
  3868. }
  3869. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3870. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3871. m.updated_at = nil
  3872. }
  3873. // SetDeletedAt sets the "deleted_at" field.
  3874. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3875. m.deleted_at = &t
  3876. }
  3877. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3878. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3879. v := m.deleted_at
  3880. if v == nil {
  3881. return
  3882. }
  3883. return *v, true
  3884. }
  3885. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3886. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3888. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3889. if !m.op.Is(OpUpdateOne) {
  3890. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3891. }
  3892. if m.id == nil || m.oldValue == nil {
  3893. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3894. }
  3895. oldValue, err := m.oldValue(ctx)
  3896. if err != nil {
  3897. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3898. }
  3899. return oldValue.DeletedAt, nil
  3900. }
  3901. // ClearDeletedAt clears the value of the "deleted_at" field.
  3902. func (m *AllocAgentMutation) ClearDeletedAt() {
  3903. m.deleted_at = nil
  3904. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3905. }
  3906. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3907. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3908. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3909. return ok
  3910. }
  3911. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3912. func (m *AllocAgentMutation) ResetDeletedAt() {
  3913. m.deleted_at = nil
  3914. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3915. }
  3916. // SetUserID sets the "user_id" field.
  3917. func (m *AllocAgentMutation) SetUserID(s string) {
  3918. m.user_id = &s
  3919. }
  3920. // UserID returns the value of the "user_id" field in the mutation.
  3921. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3922. v := m.user_id
  3923. if v == nil {
  3924. return
  3925. }
  3926. return *v, true
  3927. }
  3928. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3929. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3931. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3932. if !m.op.Is(OpUpdateOne) {
  3933. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3934. }
  3935. if m.id == nil || m.oldValue == nil {
  3936. return v, errors.New("OldUserID requires an ID field in the mutation")
  3937. }
  3938. oldValue, err := m.oldValue(ctx)
  3939. if err != nil {
  3940. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3941. }
  3942. return oldValue.UserID, nil
  3943. }
  3944. // ClearUserID clears the value of the "user_id" field.
  3945. func (m *AllocAgentMutation) ClearUserID() {
  3946. m.user_id = nil
  3947. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3948. }
  3949. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3950. func (m *AllocAgentMutation) UserIDCleared() bool {
  3951. _, ok := m.clearedFields[allocagent.FieldUserID]
  3952. return ok
  3953. }
  3954. // ResetUserID resets all changes to the "user_id" field.
  3955. func (m *AllocAgentMutation) ResetUserID() {
  3956. m.user_id = nil
  3957. delete(m.clearedFields, allocagent.FieldUserID)
  3958. }
  3959. // SetOrganizationID sets the "organization_id" field.
  3960. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3961. m.organization_id = &u
  3962. m.addorganization_id = nil
  3963. }
  3964. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3965. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3966. v := m.organization_id
  3967. if v == nil {
  3968. return
  3969. }
  3970. return *v, true
  3971. }
  3972. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3973. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3975. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3976. if !m.op.Is(OpUpdateOne) {
  3977. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3978. }
  3979. if m.id == nil || m.oldValue == nil {
  3980. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3981. }
  3982. oldValue, err := m.oldValue(ctx)
  3983. if err != nil {
  3984. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3985. }
  3986. return oldValue.OrganizationID, nil
  3987. }
  3988. // AddOrganizationID adds u to the "organization_id" field.
  3989. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3990. if m.addorganization_id != nil {
  3991. *m.addorganization_id += u
  3992. } else {
  3993. m.addorganization_id = &u
  3994. }
  3995. }
  3996. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3997. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3998. v := m.addorganization_id
  3999. if v == nil {
  4000. return
  4001. }
  4002. return *v, true
  4003. }
  4004. // ClearOrganizationID clears the value of the "organization_id" field.
  4005. func (m *AllocAgentMutation) ClearOrganizationID() {
  4006. m.organization_id = nil
  4007. m.addorganization_id = nil
  4008. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  4009. }
  4010. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  4011. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  4012. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  4013. return ok
  4014. }
  4015. // ResetOrganizationID resets all changes to the "organization_id" field.
  4016. func (m *AllocAgentMutation) ResetOrganizationID() {
  4017. m.organization_id = nil
  4018. m.addorganization_id = nil
  4019. delete(m.clearedFields, allocagent.FieldOrganizationID)
  4020. }
  4021. // SetAgents sets the "agents" field.
  4022. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  4023. m.agents = &u
  4024. m.appendagents = nil
  4025. }
  4026. // Agents returns the value of the "agents" field in the mutation.
  4027. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  4028. v := m.agents
  4029. if v == nil {
  4030. return
  4031. }
  4032. return *v, true
  4033. }
  4034. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  4035. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4037. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  4038. if !m.op.Is(OpUpdateOne) {
  4039. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  4040. }
  4041. if m.id == nil || m.oldValue == nil {
  4042. return v, errors.New("OldAgents requires an ID field in the mutation")
  4043. }
  4044. oldValue, err := m.oldValue(ctx)
  4045. if err != nil {
  4046. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  4047. }
  4048. return oldValue.Agents, nil
  4049. }
  4050. // AppendAgents adds u to the "agents" field.
  4051. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  4052. m.appendagents = append(m.appendagents, u...)
  4053. }
  4054. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  4055. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  4056. if len(m.appendagents) == 0 {
  4057. return nil, false
  4058. }
  4059. return m.appendagents, true
  4060. }
  4061. // ResetAgents resets all changes to the "agents" field.
  4062. func (m *AllocAgentMutation) ResetAgents() {
  4063. m.agents = nil
  4064. m.appendagents = nil
  4065. }
  4066. // SetStatus sets the "status" field.
  4067. func (m *AllocAgentMutation) SetStatus(i int) {
  4068. m.status = &i
  4069. m.addstatus = nil
  4070. }
  4071. // Status returns the value of the "status" field in the mutation.
  4072. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  4073. v := m.status
  4074. if v == nil {
  4075. return
  4076. }
  4077. return *v, true
  4078. }
  4079. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  4080. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4082. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  4083. if !m.op.Is(OpUpdateOne) {
  4084. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4085. }
  4086. if m.id == nil || m.oldValue == nil {
  4087. return v, errors.New("OldStatus requires an ID field in the mutation")
  4088. }
  4089. oldValue, err := m.oldValue(ctx)
  4090. if err != nil {
  4091. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4092. }
  4093. return oldValue.Status, nil
  4094. }
  4095. // AddStatus adds i to the "status" field.
  4096. func (m *AllocAgentMutation) AddStatus(i int) {
  4097. if m.addstatus != nil {
  4098. *m.addstatus += i
  4099. } else {
  4100. m.addstatus = &i
  4101. }
  4102. }
  4103. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4104. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4105. v := m.addstatus
  4106. if v == nil {
  4107. return
  4108. }
  4109. return *v, true
  4110. }
  4111. // ClearStatus clears the value of the "status" field.
  4112. func (m *AllocAgentMutation) ClearStatus() {
  4113. m.status = nil
  4114. m.addstatus = nil
  4115. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4116. }
  4117. // StatusCleared returns if the "status" field was cleared in this mutation.
  4118. func (m *AllocAgentMutation) StatusCleared() bool {
  4119. _, ok := m.clearedFields[allocagent.FieldStatus]
  4120. return ok
  4121. }
  4122. // ResetStatus resets all changes to the "status" field.
  4123. func (m *AllocAgentMutation) ResetStatus() {
  4124. m.status = nil
  4125. m.addstatus = nil
  4126. delete(m.clearedFields, allocagent.FieldStatus)
  4127. }
  4128. // Where appends a list predicates to the AllocAgentMutation builder.
  4129. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4130. m.predicates = append(m.predicates, ps...)
  4131. }
  4132. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4133. // users can use type-assertion to append predicates that do not depend on any generated package.
  4134. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4135. p := make([]predicate.AllocAgent, len(ps))
  4136. for i := range ps {
  4137. p[i] = ps[i]
  4138. }
  4139. m.Where(p...)
  4140. }
  4141. // Op returns the operation name.
  4142. func (m *AllocAgentMutation) Op() Op {
  4143. return m.op
  4144. }
  4145. // SetOp allows setting the mutation operation.
  4146. func (m *AllocAgentMutation) SetOp(op Op) {
  4147. m.op = op
  4148. }
  4149. // Type returns the node type of this mutation (AllocAgent).
  4150. func (m *AllocAgentMutation) Type() string {
  4151. return m.typ
  4152. }
  4153. // Fields returns all fields that were changed during this mutation. Note that in
  4154. // order to get all numeric fields that were incremented/decremented, call
  4155. // AddedFields().
  4156. func (m *AllocAgentMutation) Fields() []string {
  4157. fields := make([]string, 0, 7)
  4158. if m.created_at != nil {
  4159. fields = append(fields, allocagent.FieldCreatedAt)
  4160. }
  4161. if m.updated_at != nil {
  4162. fields = append(fields, allocagent.FieldUpdatedAt)
  4163. }
  4164. if m.deleted_at != nil {
  4165. fields = append(fields, allocagent.FieldDeletedAt)
  4166. }
  4167. if m.user_id != nil {
  4168. fields = append(fields, allocagent.FieldUserID)
  4169. }
  4170. if m.organization_id != nil {
  4171. fields = append(fields, allocagent.FieldOrganizationID)
  4172. }
  4173. if m.agents != nil {
  4174. fields = append(fields, allocagent.FieldAgents)
  4175. }
  4176. if m.status != nil {
  4177. fields = append(fields, allocagent.FieldStatus)
  4178. }
  4179. return fields
  4180. }
  4181. // Field returns the value of a field with the given name. The second boolean
  4182. // return value indicates that this field was not set, or was not defined in the
  4183. // schema.
  4184. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4185. switch name {
  4186. case allocagent.FieldCreatedAt:
  4187. return m.CreatedAt()
  4188. case allocagent.FieldUpdatedAt:
  4189. return m.UpdatedAt()
  4190. case allocagent.FieldDeletedAt:
  4191. return m.DeletedAt()
  4192. case allocagent.FieldUserID:
  4193. return m.UserID()
  4194. case allocagent.FieldOrganizationID:
  4195. return m.OrganizationID()
  4196. case allocagent.FieldAgents:
  4197. return m.Agents()
  4198. case allocagent.FieldStatus:
  4199. return m.Status()
  4200. }
  4201. return nil, false
  4202. }
  4203. // OldField returns the old value of the field from the database. An error is
  4204. // returned if the mutation operation is not UpdateOne, or the query to the
  4205. // database failed.
  4206. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4207. switch name {
  4208. case allocagent.FieldCreatedAt:
  4209. return m.OldCreatedAt(ctx)
  4210. case allocagent.FieldUpdatedAt:
  4211. return m.OldUpdatedAt(ctx)
  4212. case allocagent.FieldDeletedAt:
  4213. return m.OldDeletedAt(ctx)
  4214. case allocagent.FieldUserID:
  4215. return m.OldUserID(ctx)
  4216. case allocagent.FieldOrganizationID:
  4217. return m.OldOrganizationID(ctx)
  4218. case allocagent.FieldAgents:
  4219. return m.OldAgents(ctx)
  4220. case allocagent.FieldStatus:
  4221. return m.OldStatus(ctx)
  4222. }
  4223. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4224. }
  4225. // SetField sets the value of a field with the given name. It returns an error if
  4226. // the field is not defined in the schema, or if the type mismatched the field
  4227. // type.
  4228. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4229. switch name {
  4230. case allocagent.FieldCreatedAt:
  4231. v, ok := value.(time.Time)
  4232. if !ok {
  4233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4234. }
  4235. m.SetCreatedAt(v)
  4236. return nil
  4237. case allocagent.FieldUpdatedAt:
  4238. v, ok := value.(time.Time)
  4239. if !ok {
  4240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4241. }
  4242. m.SetUpdatedAt(v)
  4243. return nil
  4244. case allocagent.FieldDeletedAt:
  4245. v, ok := value.(time.Time)
  4246. if !ok {
  4247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4248. }
  4249. m.SetDeletedAt(v)
  4250. return nil
  4251. case allocagent.FieldUserID:
  4252. v, ok := value.(string)
  4253. if !ok {
  4254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4255. }
  4256. m.SetUserID(v)
  4257. return nil
  4258. case allocagent.FieldOrganizationID:
  4259. v, ok := value.(uint64)
  4260. if !ok {
  4261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4262. }
  4263. m.SetOrganizationID(v)
  4264. return nil
  4265. case allocagent.FieldAgents:
  4266. v, ok := value.([]uint64)
  4267. if !ok {
  4268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4269. }
  4270. m.SetAgents(v)
  4271. return nil
  4272. case allocagent.FieldStatus:
  4273. v, ok := value.(int)
  4274. if !ok {
  4275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4276. }
  4277. m.SetStatus(v)
  4278. return nil
  4279. }
  4280. return fmt.Errorf("unknown AllocAgent field %s", name)
  4281. }
  4282. // AddedFields returns all numeric fields that were incremented/decremented during
  4283. // this mutation.
  4284. func (m *AllocAgentMutation) AddedFields() []string {
  4285. var fields []string
  4286. if m.addorganization_id != nil {
  4287. fields = append(fields, allocagent.FieldOrganizationID)
  4288. }
  4289. if m.addstatus != nil {
  4290. fields = append(fields, allocagent.FieldStatus)
  4291. }
  4292. return fields
  4293. }
  4294. // AddedField returns the numeric value that was incremented/decremented on a field
  4295. // with the given name. The second boolean return value indicates that this field
  4296. // was not set, or was not defined in the schema.
  4297. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4298. switch name {
  4299. case allocagent.FieldOrganizationID:
  4300. return m.AddedOrganizationID()
  4301. case allocagent.FieldStatus:
  4302. return m.AddedStatus()
  4303. }
  4304. return nil, false
  4305. }
  4306. // AddField adds the value to the field with the given name. It returns an error if
  4307. // the field is not defined in the schema, or if the type mismatched the field
  4308. // type.
  4309. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4310. switch name {
  4311. case allocagent.FieldOrganizationID:
  4312. v, ok := value.(int64)
  4313. if !ok {
  4314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4315. }
  4316. m.AddOrganizationID(v)
  4317. return nil
  4318. case allocagent.FieldStatus:
  4319. v, ok := value.(int)
  4320. if !ok {
  4321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4322. }
  4323. m.AddStatus(v)
  4324. return nil
  4325. }
  4326. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4327. }
  4328. // ClearedFields returns all nullable fields that were cleared during this
  4329. // mutation.
  4330. func (m *AllocAgentMutation) ClearedFields() []string {
  4331. var fields []string
  4332. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4333. fields = append(fields, allocagent.FieldDeletedAt)
  4334. }
  4335. if m.FieldCleared(allocagent.FieldUserID) {
  4336. fields = append(fields, allocagent.FieldUserID)
  4337. }
  4338. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4339. fields = append(fields, allocagent.FieldOrganizationID)
  4340. }
  4341. if m.FieldCleared(allocagent.FieldStatus) {
  4342. fields = append(fields, allocagent.FieldStatus)
  4343. }
  4344. return fields
  4345. }
  4346. // FieldCleared returns a boolean indicating if a field with the given name was
  4347. // cleared in this mutation.
  4348. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4349. _, ok := m.clearedFields[name]
  4350. return ok
  4351. }
  4352. // ClearField clears the value of the field with the given name. It returns an
  4353. // error if the field is not defined in the schema.
  4354. func (m *AllocAgentMutation) ClearField(name string) error {
  4355. switch name {
  4356. case allocagent.FieldDeletedAt:
  4357. m.ClearDeletedAt()
  4358. return nil
  4359. case allocagent.FieldUserID:
  4360. m.ClearUserID()
  4361. return nil
  4362. case allocagent.FieldOrganizationID:
  4363. m.ClearOrganizationID()
  4364. return nil
  4365. case allocagent.FieldStatus:
  4366. m.ClearStatus()
  4367. return nil
  4368. }
  4369. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4370. }
  4371. // ResetField resets all changes in the mutation for the field with the given name.
  4372. // It returns an error if the field is not defined in the schema.
  4373. func (m *AllocAgentMutation) ResetField(name string) error {
  4374. switch name {
  4375. case allocagent.FieldCreatedAt:
  4376. m.ResetCreatedAt()
  4377. return nil
  4378. case allocagent.FieldUpdatedAt:
  4379. m.ResetUpdatedAt()
  4380. return nil
  4381. case allocagent.FieldDeletedAt:
  4382. m.ResetDeletedAt()
  4383. return nil
  4384. case allocagent.FieldUserID:
  4385. m.ResetUserID()
  4386. return nil
  4387. case allocagent.FieldOrganizationID:
  4388. m.ResetOrganizationID()
  4389. return nil
  4390. case allocagent.FieldAgents:
  4391. m.ResetAgents()
  4392. return nil
  4393. case allocagent.FieldStatus:
  4394. m.ResetStatus()
  4395. return nil
  4396. }
  4397. return fmt.Errorf("unknown AllocAgent field %s", name)
  4398. }
  4399. // AddedEdges returns all edge names that were set/added in this mutation.
  4400. func (m *AllocAgentMutation) AddedEdges() []string {
  4401. edges := make([]string, 0, 0)
  4402. return edges
  4403. }
  4404. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4405. // name in this mutation.
  4406. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4407. return nil
  4408. }
  4409. // RemovedEdges returns all edge names that were removed in this mutation.
  4410. func (m *AllocAgentMutation) RemovedEdges() []string {
  4411. edges := make([]string, 0, 0)
  4412. return edges
  4413. }
  4414. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4415. // the given name in this mutation.
  4416. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4417. return nil
  4418. }
  4419. // ClearedEdges returns all edge names that were cleared in this mutation.
  4420. func (m *AllocAgentMutation) ClearedEdges() []string {
  4421. edges := make([]string, 0, 0)
  4422. return edges
  4423. }
  4424. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4425. // was cleared in this mutation.
  4426. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4427. return false
  4428. }
  4429. // ClearEdge clears the value of the edge with the given name. It returns an error
  4430. // if that edge is not defined in the schema.
  4431. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4432. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4433. }
  4434. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4435. // It returns an error if the edge is not defined in the schema.
  4436. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4437. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4438. }
  4439. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4440. type ApiKeyMutation struct {
  4441. config
  4442. op Op
  4443. typ string
  4444. id *uint64
  4445. created_at *time.Time
  4446. updated_at *time.Time
  4447. deleted_at *time.Time
  4448. title *string
  4449. key *string
  4450. organization_id *uint64
  4451. addorganization_id *int64
  4452. custom_agent_base *string
  4453. custom_agent_key *string
  4454. openai_base *string
  4455. openai_key *string
  4456. clearedFields map[string]struct{}
  4457. agent *uint64
  4458. clearedagent bool
  4459. done bool
  4460. oldValue func(context.Context) (*ApiKey, error)
  4461. predicates []predicate.ApiKey
  4462. }
  4463. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4464. // apikeyOption allows management of the mutation configuration using functional options.
  4465. type apikeyOption func(*ApiKeyMutation)
  4466. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4467. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4468. m := &ApiKeyMutation{
  4469. config: c,
  4470. op: op,
  4471. typ: TypeApiKey,
  4472. clearedFields: make(map[string]struct{}),
  4473. }
  4474. for _, opt := range opts {
  4475. opt(m)
  4476. }
  4477. return m
  4478. }
  4479. // withApiKeyID sets the ID field of the mutation.
  4480. func withApiKeyID(id uint64) apikeyOption {
  4481. return func(m *ApiKeyMutation) {
  4482. var (
  4483. err error
  4484. once sync.Once
  4485. value *ApiKey
  4486. )
  4487. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4488. once.Do(func() {
  4489. if m.done {
  4490. err = errors.New("querying old values post mutation is not allowed")
  4491. } else {
  4492. value, err = m.Client().ApiKey.Get(ctx, id)
  4493. }
  4494. })
  4495. return value, err
  4496. }
  4497. m.id = &id
  4498. }
  4499. }
  4500. // withApiKey sets the old ApiKey of the mutation.
  4501. func withApiKey(node *ApiKey) apikeyOption {
  4502. return func(m *ApiKeyMutation) {
  4503. m.oldValue = func(context.Context) (*ApiKey, error) {
  4504. return node, nil
  4505. }
  4506. m.id = &node.ID
  4507. }
  4508. }
  4509. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4510. // executed in a transaction (ent.Tx), a transactional client is returned.
  4511. func (m ApiKeyMutation) Client() *Client {
  4512. client := &Client{config: m.config}
  4513. client.init()
  4514. return client
  4515. }
  4516. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4517. // it returns an error otherwise.
  4518. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4519. if _, ok := m.driver.(*txDriver); !ok {
  4520. return nil, errors.New("ent: mutation is not running in a transaction")
  4521. }
  4522. tx := &Tx{config: m.config}
  4523. tx.init()
  4524. return tx, nil
  4525. }
  4526. // SetID sets the value of the id field. Note that this
  4527. // operation is only accepted on creation of ApiKey entities.
  4528. func (m *ApiKeyMutation) SetID(id uint64) {
  4529. m.id = &id
  4530. }
  4531. // ID returns the ID value in the mutation. Note that the ID is only available
  4532. // if it was provided to the builder or after it was returned from the database.
  4533. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4534. if m.id == nil {
  4535. return
  4536. }
  4537. return *m.id, true
  4538. }
  4539. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4540. // That means, if the mutation is applied within a transaction with an isolation level such
  4541. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4542. // or updated by the mutation.
  4543. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4544. switch {
  4545. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4546. id, exists := m.ID()
  4547. if exists {
  4548. return []uint64{id}, nil
  4549. }
  4550. fallthrough
  4551. case m.op.Is(OpUpdate | OpDelete):
  4552. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4553. default:
  4554. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4555. }
  4556. }
  4557. // SetCreatedAt sets the "created_at" field.
  4558. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4559. m.created_at = &t
  4560. }
  4561. // CreatedAt returns the value of the "created_at" field in the mutation.
  4562. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4563. v := m.created_at
  4564. if v == nil {
  4565. return
  4566. }
  4567. return *v, true
  4568. }
  4569. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4570. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4572. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4573. if !m.op.Is(OpUpdateOne) {
  4574. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4575. }
  4576. if m.id == nil || m.oldValue == nil {
  4577. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4578. }
  4579. oldValue, err := m.oldValue(ctx)
  4580. if err != nil {
  4581. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4582. }
  4583. return oldValue.CreatedAt, nil
  4584. }
  4585. // ResetCreatedAt resets all changes to the "created_at" field.
  4586. func (m *ApiKeyMutation) ResetCreatedAt() {
  4587. m.created_at = nil
  4588. }
  4589. // SetUpdatedAt sets the "updated_at" field.
  4590. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4591. m.updated_at = &t
  4592. }
  4593. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4594. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4595. v := m.updated_at
  4596. if v == nil {
  4597. return
  4598. }
  4599. return *v, true
  4600. }
  4601. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4602. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4604. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4605. if !m.op.Is(OpUpdateOne) {
  4606. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4607. }
  4608. if m.id == nil || m.oldValue == nil {
  4609. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4610. }
  4611. oldValue, err := m.oldValue(ctx)
  4612. if err != nil {
  4613. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4614. }
  4615. return oldValue.UpdatedAt, nil
  4616. }
  4617. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4618. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4619. m.updated_at = nil
  4620. }
  4621. // SetDeletedAt sets the "deleted_at" field.
  4622. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4623. m.deleted_at = &t
  4624. }
  4625. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4626. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4627. v := m.deleted_at
  4628. if v == nil {
  4629. return
  4630. }
  4631. return *v, true
  4632. }
  4633. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4634. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4636. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4637. if !m.op.Is(OpUpdateOne) {
  4638. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4639. }
  4640. if m.id == nil || m.oldValue == nil {
  4641. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4642. }
  4643. oldValue, err := m.oldValue(ctx)
  4644. if err != nil {
  4645. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4646. }
  4647. return oldValue.DeletedAt, nil
  4648. }
  4649. // ClearDeletedAt clears the value of the "deleted_at" field.
  4650. func (m *ApiKeyMutation) ClearDeletedAt() {
  4651. m.deleted_at = nil
  4652. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4653. }
  4654. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4655. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4656. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4657. return ok
  4658. }
  4659. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4660. func (m *ApiKeyMutation) ResetDeletedAt() {
  4661. m.deleted_at = nil
  4662. delete(m.clearedFields, apikey.FieldDeletedAt)
  4663. }
  4664. // SetTitle sets the "title" field.
  4665. func (m *ApiKeyMutation) SetTitle(s string) {
  4666. m.title = &s
  4667. }
  4668. // Title returns the value of the "title" field in the mutation.
  4669. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4670. v := m.title
  4671. if v == nil {
  4672. return
  4673. }
  4674. return *v, true
  4675. }
  4676. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4677. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4679. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4680. if !m.op.Is(OpUpdateOne) {
  4681. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4682. }
  4683. if m.id == nil || m.oldValue == nil {
  4684. return v, errors.New("OldTitle requires an ID field in the mutation")
  4685. }
  4686. oldValue, err := m.oldValue(ctx)
  4687. if err != nil {
  4688. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4689. }
  4690. return oldValue.Title, nil
  4691. }
  4692. // ClearTitle clears the value of the "title" field.
  4693. func (m *ApiKeyMutation) ClearTitle() {
  4694. m.title = nil
  4695. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4696. }
  4697. // TitleCleared returns if the "title" field was cleared in this mutation.
  4698. func (m *ApiKeyMutation) TitleCleared() bool {
  4699. _, ok := m.clearedFields[apikey.FieldTitle]
  4700. return ok
  4701. }
  4702. // ResetTitle resets all changes to the "title" field.
  4703. func (m *ApiKeyMutation) ResetTitle() {
  4704. m.title = nil
  4705. delete(m.clearedFields, apikey.FieldTitle)
  4706. }
  4707. // SetKey sets the "key" field.
  4708. func (m *ApiKeyMutation) SetKey(s string) {
  4709. m.key = &s
  4710. }
  4711. // Key returns the value of the "key" field in the mutation.
  4712. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4713. v := m.key
  4714. if v == nil {
  4715. return
  4716. }
  4717. return *v, true
  4718. }
  4719. // OldKey returns the old "key" field's value of the ApiKey entity.
  4720. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4722. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4723. if !m.op.Is(OpUpdateOne) {
  4724. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4725. }
  4726. if m.id == nil || m.oldValue == nil {
  4727. return v, errors.New("OldKey requires an ID field in the mutation")
  4728. }
  4729. oldValue, err := m.oldValue(ctx)
  4730. if err != nil {
  4731. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4732. }
  4733. return oldValue.Key, nil
  4734. }
  4735. // ClearKey clears the value of the "key" field.
  4736. func (m *ApiKeyMutation) ClearKey() {
  4737. m.key = nil
  4738. m.clearedFields[apikey.FieldKey] = struct{}{}
  4739. }
  4740. // KeyCleared returns if the "key" field was cleared in this mutation.
  4741. func (m *ApiKeyMutation) KeyCleared() bool {
  4742. _, ok := m.clearedFields[apikey.FieldKey]
  4743. return ok
  4744. }
  4745. // ResetKey resets all changes to the "key" field.
  4746. func (m *ApiKeyMutation) ResetKey() {
  4747. m.key = nil
  4748. delete(m.clearedFields, apikey.FieldKey)
  4749. }
  4750. // SetOrganizationID sets the "organization_id" field.
  4751. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4752. m.organization_id = &u
  4753. m.addorganization_id = nil
  4754. }
  4755. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4756. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4757. v := m.organization_id
  4758. if v == nil {
  4759. return
  4760. }
  4761. return *v, true
  4762. }
  4763. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4764. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4766. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4767. if !m.op.Is(OpUpdateOne) {
  4768. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4769. }
  4770. if m.id == nil || m.oldValue == nil {
  4771. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4772. }
  4773. oldValue, err := m.oldValue(ctx)
  4774. if err != nil {
  4775. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4776. }
  4777. return oldValue.OrganizationID, nil
  4778. }
  4779. // AddOrganizationID adds u to the "organization_id" field.
  4780. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4781. if m.addorganization_id != nil {
  4782. *m.addorganization_id += u
  4783. } else {
  4784. m.addorganization_id = &u
  4785. }
  4786. }
  4787. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4788. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4789. v := m.addorganization_id
  4790. if v == nil {
  4791. return
  4792. }
  4793. return *v, true
  4794. }
  4795. // ResetOrganizationID resets all changes to the "organization_id" field.
  4796. func (m *ApiKeyMutation) ResetOrganizationID() {
  4797. m.organization_id = nil
  4798. m.addorganization_id = nil
  4799. }
  4800. // SetAgentID sets the "agent_id" field.
  4801. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4802. m.agent = &u
  4803. }
  4804. // AgentID returns the value of the "agent_id" field in the mutation.
  4805. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4806. v := m.agent
  4807. if v == nil {
  4808. return
  4809. }
  4810. return *v, true
  4811. }
  4812. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4813. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4815. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4816. if !m.op.Is(OpUpdateOne) {
  4817. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4818. }
  4819. if m.id == nil || m.oldValue == nil {
  4820. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4821. }
  4822. oldValue, err := m.oldValue(ctx)
  4823. if err != nil {
  4824. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4825. }
  4826. return oldValue.AgentID, nil
  4827. }
  4828. // ResetAgentID resets all changes to the "agent_id" field.
  4829. func (m *ApiKeyMutation) ResetAgentID() {
  4830. m.agent = nil
  4831. }
  4832. // SetCustomAgentBase sets the "custom_agent_base" field.
  4833. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4834. m.custom_agent_base = &s
  4835. }
  4836. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4837. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4838. v := m.custom_agent_base
  4839. if v == nil {
  4840. return
  4841. }
  4842. return *v, true
  4843. }
  4844. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4845. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4847. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4848. if !m.op.Is(OpUpdateOne) {
  4849. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4850. }
  4851. if m.id == nil || m.oldValue == nil {
  4852. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4853. }
  4854. oldValue, err := m.oldValue(ctx)
  4855. if err != nil {
  4856. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4857. }
  4858. return oldValue.CustomAgentBase, nil
  4859. }
  4860. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4861. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4862. m.custom_agent_base = nil
  4863. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4864. }
  4865. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4866. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4867. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4868. return ok
  4869. }
  4870. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4871. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4872. m.custom_agent_base = nil
  4873. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4874. }
  4875. // SetCustomAgentKey sets the "custom_agent_key" field.
  4876. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4877. m.custom_agent_key = &s
  4878. }
  4879. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4880. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4881. v := m.custom_agent_key
  4882. if v == nil {
  4883. return
  4884. }
  4885. return *v, true
  4886. }
  4887. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4888. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4890. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4891. if !m.op.Is(OpUpdateOne) {
  4892. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4893. }
  4894. if m.id == nil || m.oldValue == nil {
  4895. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4896. }
  4897. oldValue, err := m.oldValue(ctx)
  4898. if err != nil {
  4899. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4900. }
  4901. return oldValue.CustomAgentKey, nil
  4902. }
  4903. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4904. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4905. m.custom_agent_key = nil
  4906. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4907. }
  4908. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4909. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4910. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4911. return ok
  4912. }
  4913. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4914. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4915. m.custom_agent_key = nil
  4916. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4917. }
  4918. // SetOpenaiBase sets the "openai_base" field.
  4919. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4920. m.openai_base = &s
  4921. }
  4922. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4923. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4924. v := m.openai_base
  4925. if v == nil {
  4926. return
  4927. }
  4928. return *v, true
  4929. }
  4930. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4931. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4933. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4934. if !m.op.Is(OpUpdateOne) {
  4935. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4936. }
  4937. if m.id == nil || m.oldValue == nil {
  4938. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4939. }
  4940. oldValue, err := m.oldValue(ctx)
  4941. if err != nil {
  4942. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4943. }
  4944. return oldValue.OpenaiBase, nil
  4945. }
  4946. // ClearOpenaiBase clears the value of the "openai_base" field.
  4947. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4948. m.openai_base = nil
  4949. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4950. }
  4951. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4952. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4953. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4954. return ok
  4955. }
  4956. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4957. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4958. m.openai_base = nil
  4959. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4960. }
  4961. // SetOpenaiKey sets the "openai_key" field.
  4962. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4963. m.openai_key = &s
  4964. }
  4965. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4966. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4967. v := m.openai_key
  4968. if v == nil {
  4969. return
  4970. }
  4971. return *v, true
  4972. }
  4973. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4974. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4976. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4977. if !m.op.Is(OpUpdateOne) {
  4978. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4979. }
  4980. if m.id == nil || m.oldValue == nil {
  4981. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4982. }
  4983. oldValue, err := m.oldValue(ctx)
  4984. if err != nil {
  4985. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4986. }
  4987. return oldValue.OpenaiKey, nil
  4988. }
  4989. // ClearOpenaiKey clears the value of the "openai_key" field.
  4990. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4991. m.openai_key = nil
  4992. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4993. }
  4994. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4995. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4996. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4997. return ok
  4998. }
  4999. // ResetOpenaiKey resets all changes to the "openai_key" field.
  5000. func (m *ApiKeyMutation) ResetOpenaiKey() {
  5001. m.openai_key = nil
  5002. delete(m.clearedFields, apikey.FieldOpenaiKey)
  5003. }
  5004. // ClearAgent clears the "agent" edge to the Agent entity.
  5005. func (m *ApiKeyMutation) ClearAgent() {
  5006. m.clearedagent = true
  5007. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  5008. }
  5009. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  5010. func (m *ApiKeyMutation) AgentCleared() bool {
  5011. return m.clearedagent
  5012. }
  5013. // AgentIDs returns the "agent" edge IDs in the mutation.
  5014. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  5015. // AgentID instead. It exists only for internal usage by the builders.
  5016. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  5017. if id := m.agent; id != nil {
  5018. ids = append(ids, *id)
  5019. }
  5020. return
  5021. }
  5022. // ResetAgent resets all changes to the "agent" edge.
  5023. func (m *ApiKeyMutation) ResetAgent() {
  5024. m.agent = nil
  5025. m.clearedagent = false
  5026. }
  5027. // Where appends a list predicates to the ApiKeyMutation builder.
  5028. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  5029. m.predicates = append(m.predicates, ps...)
  5030. }
  5031. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  5032. // users can use type-assertion to append predicates that do not depend on any generated package.
  5033. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  5034. p := make([]predicate.ApiKey, len(ps))
  5035. for i := range ps {
  5036. p[i] = ps[i]
  5037. }
  5038. m.Where(p...)
  5039. }
  5040. // Op returns the operation name.
  5041. func (m *ApiKeyMutation) Op() Op {
  5042. return m.op
  5043. }
  5044. // SetOp allows setting the mutation operation.
  5045. func (m *ApiKeyMutation) SetOp(op Op) {
  5046. m.op = op
  5047. }
  5048. // Type returns the node type of this mutation (ApiKey).
  5049. func (m *ApiKeyMutation) Type() string {
  5050. return m.typ
  5051. }
  5052. // Fields returns all fields that were changed during this mutation. Note that in
  5053. // order to get all numeric fields that were incremented/decremented, call
  5054. // AddedFields().
  5055. func (m *ApiKeyMutation) Fields() []string {
  5056. fields := make([]string, 0, 11)
  5057. if m.created_at != nil {
  5058. fields = append(fields, apikey.FieldCreatedAt)
  5059. }
  5060. if m.updated_at != nil {
  5061. fields = append(fields, apikey.FieldUpdatedAt)
  5062. }
  5063. if m.deleted_at != nil {
  5064. fields = append(fields, apikey.FieldDeletedAt)
  5065. }
  5066. if m.title != nil {
  5067. fields = append(fields, apikey.FieldTitle)
  5068. }
  5069. if m.key != nil {
  5070. fields = append(fields, apikey.FieldKey)
  5071. }
  5072. if m.organization_id != nil {
  5073. fields = append(fields, apikey.FieldOrganizationID)
  5074. }
  5075. if m.agent != nil {
  5076. fields = append(fields, apikey.FieldAgentID)
  5077. }
  5078. if m.custom_agent_base != nil {
  5079. fields = append(fields, apikey.FieldCustomAgentBase)
  5080. }
  5081. if m.custom_agent_key != nil {
  5082. fields = append(fields, apikey.FieldCustomAgentKey)
  5083. }
  5084. if m.openai_base != nil {
  5085. fields = append(fields, apikey.FieldOpenaiBase)
  5086. }
  5087. if m.openai_key != nil {
  5088. fields = append(fields, apikey.FieldOpenaiKey)
  5089. }
  5090. return fields
  5091. }
  5092. // Field returns the value of a field with the given name. The second boolean
  5093. // return value indicates that this field was not set, or was not defined in the
  5094. // schema.
  5095. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5096. switch name {
  5097. case apikey.FieldCreatedAt:
  5098. return m.CreatedAt()
  5099. case apikey.FieldUpdatedAt:
  5100. return m.UpdatedAt()
  5101. case apikey.FieldDeletedAt:
  5102. return m.DeletedAt()
  5103. case apikey.FieldTitle:
  5104. return m.Title()
  5105. case apikey.FieldKey:
  5106. return m.Key()
  5107. case apikey.FieldOrganizationID:
  5108. return m.OrganizationID()
  5109. case apikey.FieldAgentID:
  5110. return m.AgentID()
  5111. case apikey.FieldCustomAgentBase:
  5112. return m.CustomAgentBase()
  5113. case apikey.FieldCustomAgentKey:
  5114. return m.CustomAgentKey()
  5115. case apikey.FieldOpenaiBase:
  5116. return m.OpenaiBase()
  5117. case apikey.FieldOpenaiKey:
  5118. return m.OpenaiKey()
  5119. }
  5120. return nil, false
  5121. }
  5122. // OldField returns the old value of the field from the database. An error is
  5123. // returned if the mutation operation is not UpdateOne, or the query to the
  5124. // database failed.
  5125. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5126. switch name {
  5127. case apikey.FieldCreatedAt:
  5128. return m.OldCreatedAt(ctx)
  5129. case apikey.FieldUpdatedAt:
  5130. return m.OldUpdatedAt(ctx)
  5131. case apikey.FieldDeletedAt:
  5132. return m.OldDeletedAt(ctx)
  5133. case apikey.FieldTitle:
  5134. return m.OldTitle(ctx)
  5135. case apikey.FieldKey:
  5136. return m.OldKey(ctx)
  5137. case apikey.FieldOrganizationID:
  5138. return m.OldOrganizationID(ctx)
  5139. case apikey.FieldAgentID:
  5140. return m.OldAgentID(ctx)
  5141. case apikey.FieldCustomAgentBase:
  5142. return m.OldCustomAgentBase(ctx)
  5143. case apikey.FieldCustomAgentKey:
  5144. return m.OldCustomAgentKey(ctx)
  5145. case apikey.FieldOpenaiBase:
  5146. return m.OldOpenaiBase(ctx)
  5147. case apikey.FieldOpenaiKey:
  5148. return m.OldOpenaiKey(ctx)
  5149. }
  5150. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5151. }
  5152. // SetField sets the value of a field with the given name. It returns an error if
  5153. // the field is not defined in the schema, or if the type mismatched the field
  5154. // type.
  5155. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5156. switch name {
  5157. case apikey.FieldCreatedAt:
  5158. v, ok := value.(time.Time)
  5159. if !ok {
  5160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5161. }
  5162. m.SetCreatedAt(v)
  5163. return nil
  5164. case apikey.FieldUpdatedAt:
  5165. v, ok := value.(time.Time)
  5166. if !ok {
  5167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5168. }
  5169. m.SetUpdatedAt(v)
  5170. return nil
  5171. case apikey.FieldDeletedAt:
  5172. v, ok := value.(time.Time)
  5173. if !ok {
  5174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5175. }
  5176. m.SetDeletedAt(v)
  5177. return nil
  5178. case apikey.FieldTitle:
  5179. v, ok := value.(string)
  5180. if !ok {
  5181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5182. }
  5183. m.SetTitle(v)
  5184. return nil
  5185. case apikey.FieldKey:
  5186. v, ok := value.(string)
  5187. if !ok {
  5188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5189. }
  5190. m.SetKey(v)
  5191. return nil
  5192. case apikey.FieldOrganizationID:
  5193. v, ok := value.(uint64)
  5194. if !ok {
  5195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5196. }
  5197. m.SetOrganizationID(v)
  5198. return nil
  5199. case apikey.FieldAgentID:
  5200. v, ok := value.(uint64)
  5201. if !ok {
  5202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5203. }
  5204. m.SetAgentID(v)
  5205. return nil
  5206. case apikey.FieldCustomAgentBase:
  5207. v, ok := value.(string)
  5208. if !ok {
  5209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5210. }
  5211. m.SetCustomAgentBase(v)
  5212. return nil
  5213. case apikey.FieldCustomAgentKey:
  5214. v, ok := value.(string)
  5215. if !ok {
  5216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5217. }
  5218. m.SetCustomAgentKey(v)
  5219. return nil
  5220. case apikey.FieldOpenaiBase:
  5221. v, ok := value.(string)
  5222. if !ok {
  5223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5224. }
  5225. m.SetOpenaiBase(v)
  5226. return nil
  5227. case apikey.FieldOpenaiKey:
  5228. v, ok := value.(string)
  5229. if !ok {
  5230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5231. }
  5232. m.SetOpenaiKey(v)
  5233. return nil
  5234. }
  5235. return fmt.Errorf("unknown ApiKey field %s", name)
  5236. }
  5237. // AddedFields returns all numeric fields that were incremented/decremented during
  5238. // this mutation.
  5239. func (m *ApiKeyMutation) AddedFields() []string {
  5240. var fields []string
  5241. if m.addorganization_id != nil {
  5242. fields = append(fields, apikey.FieldOrganizationID)
  5243. }
  5244. return fields
  5245. }
  5246. // AddedField returns the numeric value that was incremented/decremented on a field
  5247. // with the given name. The second boolean return value indicates that this field
  5248. // was not set, or was not defined in the schema.
  5249. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5250. switch name {
  5251. case apikey.FieldOrganizationID:
  5252. return m.AddedOrganizationID()
  5253. }
  5254. return nil, false
  5255. }
  5256. // AddField adds the value to the field with the given name. It returns an error if
  5257. // the field is not defined in the schema, or if the type mismatched the field
  5258. // type.
  5259. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5260. switch name {
  5261. case apikey.FieldOrganizationID:
  5262. v, ok := value.(int64)
  5263. if !ok {
  5264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5265. }
  5266. m.AddOrganizationID(v)
  5267. return nil
  5268. }
  5269. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5270. }
  5271. // ClearedFields returns all nullable fields that were cleared during this
  5272. // mutation.
  5273. func (m *ApiKeyMutation) ClearedFields() []string {
  5274. var fields []string
  5275. if m.FieldCleared(apikey.FieldDeletedAt) {
  5276. fields = append(fields, apikey.FieldDeletedAt)
  5277. }
  5278. if m.FieldCleared(apikey.FieldTitle) {
  5279. fields = append(fields, apikey.FieldTitle)
  5280. }
  5281. if m.FieldCleared(apikey.FieldKey) {
  5282. fields = append(fields, apikey.FieldKey)
  5283. }
  5284. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5285. fields = append(fields, apikey.FieldCustomAgentBase)
  5286. }
  5287. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5288. fields = append(fields, apikey.FieldCustomAgentKey)
  5289. }
  5290. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5291. fields = append(fields, apikey.FieldOpenaiBase)
  5292. }
  5293. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5294. fields = append(fields, apikey.FieldOpenaiKey)
  5295. }
  5296. return fields
  5297. }
  5298. // FieldCleared returns a boolean indicating if a field with the given name was
  5299. // cleared in this mutation.
  5300. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5301. _, ok := m.clearedFields[name]
  5302. return ok
  5303. }
  5304. // ClearField clears the value of the field with the given name. It returns an
  5305. // error if the field is not defined in the schema.
  5306. func (m *ApiKeyMutation) ClearField(name string) error {
  5307. switch name {
  5308. case apikey.FieldDeletedAt:
  5309. m.ClearDeletedAt()
  5310. return nil
  5311. case apikey.FieldTitle:
  5312. m.ClearTitle()
  5313. return nil
  5314. case apikey.FieldKey:
  5315. m.ClearKey()
  5316. return nil
  5317. case apikey.FieldCustomAgentBase:
  5318. m.ClearCustomAgentBase()
  5319. return nil
  5320. case apikey.FieldCustomAgentKey:
  5321. m.ClearCustomAgentKey()
  5322. return nil
  5323. case apikey.FieldOpenaiBase:
  5324. m.ClearOpenaiBase()
  5325. return nil
  5326. case apikey.FieldOpenaiKey:
  5327. m.ClearOpenaiKey()
  5328. return nil
  5329. }
  5330. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5331. }
  5332. // ResetField resets all changes in the mutation for the field with the given name.
  5333. // It returns an error if the field is not defined in the schema.
  5334. func (m *ApiKeyMutation) ResetField(name string) error {
  5335. switch name {
  5336. case apikey.FieldCreatedAt:
  5337. m.ResetCreatedAt()
  5338. return nil
  5339. case apikey.FieldUpdatedAt:
  5340. m.ResetUpdatedAt()
  5341. return nil
  5342. case apikey.FieldDeletedAt:
  5343. m.ResetDeletedAt()
  5344. return nil
  5345. case apikey.FieldTitle:
  5346. m.ResetTitle()
  5347. return nil
  5348. case apikey.FieldKey:
  5349. m.ResetKey()
  5350. return nil
  5351. case apikey.FieldOrganizationID:
  5352. m.ResetOrganizationID()
  5353. return nil
  5354. case apikey.FieldAgentID:
  5355. m.ResetAgentID()
  5356. return nil
  5357. case apikey.FieldCustomAgentBase:
  5358. m.ResetCustomAgentBase()
  5359. return nil
  5360. case apikey.FieldCustomAgentKey:
  5361. m.ResetCustomAgentKey()
  5362. return nil
  5363. case apikey.FieldOpenaiBase:
  5364. m.ResetOpenaiBase()
  5365. return nil
  5366. case apikey.FieldOpenaiKey:
  5367. m.ResetOpenaiKey()
  5368. return nil
  5369. }
  5370. return fmt.Errorf("unknown ApiKey field %s", name)
  5371. }
  5372. // AddedEdges returns all edge names that were set/added in this mutation.
  5373. func (m *ApiKeyMutation) AddedEdges() []string {
  5374. edges := make([]string, 0, 1)
  5375. if m.agent != nil {
  5376. edges = append(edges, apikey.EdgeAgent)
  5377. }
  5378. return edges
  5379. }
  5380. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5381. // name in this mutation.
  5382. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5383. switch name {
  5384. case apikey.EdgeAgent:
  5385. if id := m.agent; id != nil {
  5386. return []ent.Value{*id}
  5387. }
  5388. }
  5389. return nil
  5390. }
  5391. // RemovedEdges returns all edge names that were removed in this mutation.
  5392. func (m *ApiKeyMutation) RemovedEdges() []string {
  5393. edges := make([]string, 0, 1)
  5394. return edges
  5395. }
  5396. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5397. // the given name in this mutation.
  5398. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5399. return nil
  5400. }
  5401. // ClearedEdges returns all edge names that were cleared in this mutation.
  5402. func (m *ApiKeyMutation) ClearedEdges() []string {
  5403. edges := make([]string, 0, 1)
  5404. if m.clearedagent {
  5405. edges = append(edges, apikey.EdgeAgent)
  5406. }
  5407. return edges
  5408. }
  5409. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5410. // was cleared in this mutation.
  5411. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5412. switch name {
  5413. case apikey.EdgeAgent:
  5414. return m.clearedagent
  5415. }
  5416. return false
  5417. }
  5418. // ClearEdge clears the value of the edge with the given name. It returns an error
  5419. // if that edge is not defined in the schema.
  5420. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5421. switch name {
  5422. case apikey.EdgeAgent:
  5423. m.ClearAgent()
  5424. return nil
  5425. }
  5426. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5427. }
  5428. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5429. // It returns an error if the edge is not defined in the schema.
  5430. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5431. switch name {
  5432. case apikey.EdgeAgent:
  5433. m.ResetAgent()
  5434. return nil
  5435. }
  5436. return fmt.Errorf("unknown ApiKey edge %s", name)
  5437. }
  5438. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5439. type BatchMsgMutation struct {
  5440. config
  5441. op Op
  5442. typ string
  5443. id *uint64
  5444. created_at *time.Time
  5445. updated_at *time.Time
  5446. deleted_at *time.Time
  5447. status *uint8
  5448. addstatus *int8
  5449. batch_no *string
  5450. task_name *string
  5451. fromwxid *string
  5452. msg *string
  5453. tag *string
  5454. tagids *string
  5455. total *int32
  5456. addtotal *int32
  5457. success *int32
  5458. addsuccess *int32
  5459. fail *int32
  5460. addfail *int32
  5461. start_time *time.Time
  5462. stop_time *time.Time
  5463. send_time *time.Time
  5464. _type *int32
  5465. add_type *int32
  5466. organization_id *uint64
  5467. addorganization_id *int64
  5468. ctype *uint64
  5469. addctype *int64
  5470. cc *string
  5471. phone *string
  5472. template_name *string
  5473. template_code *string
  5474. lang *string
  5475. clearedFields map[string]struct{}
  5476. done bool
  5477. oldValue func(context.Context) (*BatchMsg, error)
  5478. predicates []predicate.BatchMsg
  5479. }
  5480. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5481. // batchmsgOption allows management of the mutation configuration using functional options.
  5482. type batchmsgOption func(*BatchMsgMutation)
  5483. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5484. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5485. m := &BatchMsgMutation{
  5486. config: c,
  5487. op: op,
  5488. typ: TypeBatchMsg,
  5489. clearedFields: make(map[string]struct{}),
  5490. }
  5491. for _, opt := range opts {
  5492. opt(m)
  5493. }
  5494. return m
  5495. }
  5496. // withBatchMsgID sets the ID field of the mutation.
  5497. func withBatchMsgID(id uint64) batchmsgOption {
  5498. return func(m *BatchMsgMutation) {
  5499. var (
  5500. err error
  5501. once sync.Once
  5502. value *BatchMsg
  5503. )
  5504. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5505. once.Do(func() {
  5506. if m.done {
  5507. err = errors.New("querying old values post mutation is not allowed")
  5508. } else {
  5509. value, err = m.Client().BatchMsg.Get(ctx, id)
  5510. }
  5511. })
  5512. return value, err
  5513. }
  5514. m.id = &id
  5515. }
  5516. }
  5517. // withBatchMsg sets the old BatchMsg of the mutation.
  5518. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5519. return func(m *BatchMsgMutation) {
  5520. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5521. return node, nil
  5522. }
  5523. m.id = &node.ID
  5524. }
  5525. }
  5526. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5527. // executed in a transaction (ent.Tx), a transactional client is returned.
  5528. func (m BatchMsgMutation) Client() *Client {
  5529. client := &Client{config: m.config}
  5530. client.init()
  5531. return client
  5532. }
  5533. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5534. // it returns an error otherwise.
  5535. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5536. if _, ok := m.driver.(*txDriver); !ok {
  5537. return nil, errors.New("ent: mutation is not running in a transaction")
  5538. }
  5539. tx := &Tx{config: m.config}
  5540. tx.init()
  5541. return tx, nil
  5542. }
  5543. // SetID sets the value of the id field. Note that this
  5544. // operation is only accepted on creation of BatchMsg entities.
  5545. func (m *BatchMsgMutation) SetID(id uint64) {
  5546. m.id = &id
  5547. }
  5548. // ID returns the ID value in the mutation. Note that the ID is only available
  5549. // if it was provided to the builder or after it was returned from the database.
  5550. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5551. if m.id == nil {
  5552. return
  5553. }
  5554. return *m.id, true
  5555. }
  5556. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5557. // That means, if the mutation is applied within a transaction with an isolation level such
  5558. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5559. // or updated by the mutation.
  5560. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5561. switch {
  5562. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5563. id, exists := m.ID()
  5564. if exists {
  5565. return []uint64{id}, nil
  5566. }
  5567. fallthrough
  5568. case m.op.Is(OpUpdate | OpDelete):
  5569. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5570. default:
  5571. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5572. }
  5573. }
  5574. // SetCreatedAt sets the "created_at" field.
  5575. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5576. m.created_at = &t
  5577. }
  5578. // CreatedAt returns the value of the "created_at" field in the mutation.
  5579. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5580. v := m.created_at
  5581. if v == nil {
  5582. return
  5583. }
  5584. return *v, true
  5585. }
  5586. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5587. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5589. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5590. if !m.op.Is(OpUpdateOne) {
  5591. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5592. }
  5593. if m.id == nil || m.oldValue == nil {
  5594. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5595. }
  5596. oldValue, err := m.oldValue(ctx)
  5597. if err != nil {
  5598. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5599. }
  5600. return oldValue.CreatedAt, nil
  5601. }
  5602. // ResetCreatedAt resets all changes to the "created_at" field.
  5603. func (m *BatchMsgMutation) ResetCreatedAt() {
  5604. m.created_at = nil
  5605. }
  5606. // SetUpdatedAt sets the "updated_at" field.
  5607. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5608. m.updated_at = &t
  5609. }
  5610. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5611. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5612. v := m.updated_at
  5613. if v == nil {
  5614. return
  5615. }
  5616. return *v, true
  5617. }
  5618. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5619. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5621. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5622. if !m.op.Is(OpUpdateOne) {
  5623. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5624. }
  5625. if m.id == nil || m.oldValue == nil {
  5626. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5627. }
  5628. oldValue, err := m.oldValue(ctx)
  5629. if err != nil {
  5630. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5631. }
  5632. return oldValue.UpdatedAt, nil
  5633. }
  5634. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5635. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5636. m.updated_at = nil
  5637. }
  5638. // SetDeletedAt sets the "deleted_at" field.
  5639. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5640. m.deleted_at = &t
  5641. }
  5642. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5643. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5644. v := m.deleted_at
  5645. if v == nil {
  5646. return
  5647. }
  5648. return *v, true
  5649. }
  5650. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5651. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5653. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5654. if !m.op.Is(OpUpdateOne) {
  5655. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5656. }
  5657. if m.id == nil || m.oldValue == nil {
  5658. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5659. }
  5660. oldValue, err := m.oldValue(ctx)
  5661. if err != nil {
  5662. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5663. }
  5664. return oldValue.DeletedAt, nil
  5665. }
  5666. // ClearDeletedAt clears the value of the "deleted_at" field.
  5667. func (m *BatchMsgMutation) ClearDeletedAt() {
  5668. m.deleted_at = nil
  5669. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5670. }
  5671. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5672. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5673. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5674. return ok
  5675. }
  5676. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5677. func (m *BatchMsgMutation) ResetDeletedAt() {
  5678. m.deleted_at = nil
  5679. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5680. }
  5681. // SetStatus sets the "status" field.
  5682. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5683. m.status = &u
  5684. m.addstatus = nil
  5685. }
  5686. // Status returns the value of the "status" field in the mutation.
  5687. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5688. v := m.status
  5689. if v == nil {
  5690. return
  5691. }
  5692. return *v, true
  5693. }
  5694. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5695. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5697. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5698. if !m.op.Is(OpUpdateOne) {
  5699. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5700. }
  5701. if m.id == nil || m.oldValue == nil {
  5702. return v, errors.New("OldStatus requires an ID field in the mutation")
  5703. }
  5704. oldValue, err := m.oldValue(ctx)
  5705. if err != nil {
  5706. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5707. }
  5708. return oldValue.Status, nil
  5709. }
  5710. // AddStatus adds u to the "status" field.
  5711. func (m *BatchMsgMutation) AddStatus(u int8) {
  5712. if m.addstatus != nil {
  5713. *m.addstatus += u
  5714. } else {
  5715. m.addstatus = &u
  5716. }
  5717. }
  5718. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5719. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5720. v := m.addstatus
  5721. if v == nil {
  5722. return
  5723. }
  5724. return *v, true
  5725. }
  5726. // ClearStatus clears the value of the "status" field.
  5727. func (m *BatchMsgMutation) ClearStatus() {
  5728. m.status = nil
  5729. m.addstatus = nil
  5730. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5731. }
  5732. // StatusCleared returns if the "status" field was cleared in this mutation.
  5733. func (m *BatchMsgMutation) StatusCleared() bool {
  5734. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5735. return ok
  5736. }
  5737. // ResetStatus resets all changes to the "status" field.
  5738. func (m *BatchMsgMutation) ResetStatus() {
  5739. m.status = nil
  5740. m.addstatus = nil
  5741. delete(m.clearedFields, batchmsg.FieldStatus)
  5742. }
  5743. // SetBatchNo sets the "batch_no" field.
  5744. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5745. m.batch_no = &s
  5746. }
  5747. // BatchNo returns the value of the "batch_no" field in the mutation.
  5748. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5749. v := m.batch_no
  5750. if v == nil {
  5751. return
  5752. }
  5753. return *v, true
  5754. }
  5755. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5756. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5757. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5758. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5759. if !m.op.Is(OpUpdateOne) {
  5760. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5761. }
  5762. if m.id == nil || m.oldValue == nil {
  5763. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5764. }
  5765. oldValue, err := m.oldValue(ctx)
  5766. if err != nil {
  5767. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5768. }
  5769. return oldValue.BatchNo, nil
  5770. }
  5771. // ClearBatchNo clears the value of the "batch_no" field.
  5772. func (m *BatchMsgMutation) ClearBatchNo() {
  5773. m.batch_no = nil
  5774. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5775. }
  5776. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5777. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5778. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5779. return ok
  5780. }
  5781. // ResetBatchNo resets all changes to the "batch_no" field.
  5782. func (m *BatchMsgMutation) ResetBatchNo() {
  5783. m.batch_no = nil
  5784. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5785. }
  5786. // SetTaskName sets the "task_name" field.
  5787. func (m *BatchMsgMutation) SetTaskName(s string) {
  5788. m.task_name = &s
  5789. }
  5790. // TaskName returns the value of the "task_name" field in the mutation.
  5791. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5792. v := m.task_name
  5793. if v == nil {
  5794. return
  5795. }
  5796. return *v, true
  5797. }
  5798. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5799. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5801. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5802. if !m.op.Is(OpUpdateOne) {
  5803. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5804. }
  5805. if m.id == nil || m.oldValue == nil {
  5806. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5807. }
  5808. oldValue, err := m.oldValue(ctx)
  5809. if err != nil {
  5810. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5811. }
  5812. return oldValue.TaskName, nil
  5813. }
  5814. // ClearTaskName clears the value of the "task_name" field.
  5815. func (m *BatchMsgMutation) ClearTaskName() {
  5816. m.task_name = nil
  5817. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5818. }
  5819. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5820. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5821. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5822. return ok
  5823. }
  5824. // ResetTaskName resets all changes to the "task_name" field.
  5825. func (m *BatchMsgMutation) ResetTaskName() {
  5826. m.task_name = nil
  5827. delete(m.clearedFields, batchmsg.FieldTaskName)
  5828. }
  5829. // SetFromwxid sets the "fromwxid" field.
  5830. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5831. m.fromwxid = &s
  5832. }
  5833. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5834. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5835. v := m.fromwxid
  5836. if v == nil {
  5837. return
  5838. }
  5839. return *v, true
  5840. }
  5841. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5842. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5844. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5845. if !m.op.Is(OpUpdateOne) {
  5846. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5847. }
  5848. if m.id == nil || m.oldValue == nil {
  5849. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5850. }
  5851. oldValue, err := m.oldValue(ctx)
  5852. if err != nil {
  5853. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5854. }
  5855. return oldValue.Fromwxid, nil
  5856. }
  5857. // ClearFromwxid clears the value of the "fromwxid" field.
  5858. func (m *BatchMsgMutation) ClearFromwxid() {
  5859. m.fromwxid = nil
  5860. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5861. }
  5862. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5863. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5864. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5865. return ok
  5866. }
  5867. // ResetFromwxid resets all changes to the "fromwxid" field.
  5868. func (m *BatchMsgMutation) ResetFromwxid() {
  5869. m.fromwxid = nil
  5870. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5871. }
  5872. // SetMsg sets the "msg" field.
  5873. func (m *BatchMsgMutation) SetMsg(s string) {
  5874. m.msg = &s
  5875. }
  5876. // Msg returns the value of the "msg" field in the mutation.
  5877. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5878. v := m.msg
  5879. if v == nil {
  5880. return
  5881. }
  5882. return *v, true
  5883. }
  5884. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5885. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5887. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5888. if !m.op.Is(OpUpdateOne) {
  5889. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5890. }
  5891. if m.id == nil || m.oldValue == nil {
  5892. return v, errors.New("OldMsg requires an ID field in the mutation")
  5893. }
  5894. oldValue, err := m.oldValue(ctx)
  5895. if err != nil {
  5896. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5897. }
  5898. return oldValue.Msg, nil
  5899. }
  5900. // ClearMsg clears the value of the "msg" field.
  5901. func (m *BatchMsgMutation) ClearMsg() {
  5902. m.msg = nil
  5903. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5904. }
  5905. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5906. func (m *BatchMsgMutation) MsgCleared() bool {
  5907. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5908. return ok
  5909. }
  5910. // ResetMsg resets all changes to the "msg" field.
  5911. func (m *BatchMsgMutation) ResetMsg() {
  5912. m.msg = nil
  5913. delete(m.clearedFields, batchmsg.FieldMsg)
  5914. }
  5915. // SetTag sets the "tag" field.
  5916. func (m *BatchMsgMutation) SetTag(s string) {
  5917. m.tag = &s
  5918. }
  5919. // Tag returns the value of the "tag" field in the mutation.
  5920. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5921. v := m.tag
  5922. if v == nil {
  5923. return
  5924. }
  5925. return *v, true
  5926. }
  5927. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5928. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5930. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5931. if !m.op.Is(OpUpdateOne) {
  5932. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5933. }
  5934. if m.id == nil || m.oldValue == nil {
  5935. return v, errors.New("OldTag requires an ID field in the mutation")
  5936. }
  5937. oldValue, err := m.oldValue(ctx)
  5938. if err != nil {
  5939. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5940. }
  5941. return oldValue.Tag, nil
  5942. }
  5943. // ClearTag clears the value of the "tag" field.
  5944. func (m *BatchMsgMutation) ClearTag() {
  5945. m.tag = nil
  5946. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5947. }
  5948. // TagCleared returns if the "tag" field was cleared in this mutation.
  5949. func (m *BatchMsgMutation) TagCleared() bool {
  5950. _, ok := m.clearedFields[batchmsg.FieldTag]
  5951. return ok
  5952. }
  5953. // ResetTag resets all changes to the "tag" field.
  5954. func (m *BatchMsgMutation) ResetTag() {
  5955. m.tag = nil
  5956. delete(m.clearedFields, batchmsg.FieldTag)
  5957. }
  5958. // SetTagids sets the "tagids" field.
  5959. func (m *BatchMsgMutation) SetTagids(s string) {
  5960. m.tagids = &s
  5961. }
  5962. // Tagids returns the value of the "tagids" field in the mutation.
  5963. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5964. v := m.tagids
  5965. if v == nil {
  5966. return
  5967. }
  5968. return *v, true
  5969. }
  5970. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5971. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5973. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5974. if !m.op.Is(OpUpdateOne) {
  5975. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5976. }
  5977. if m.id == nil || m.oldValue == nil {
  5978. return v, errors.New("OldTagids requires an ID field in the mutation")
  5979. }
  5980. oldValue, err := m.oldValue(ctx)
  5981. if err != nil {
  5982. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5983. }
  5984. return oldValue.Tagids, nil
  5985. }
  5986. // ClearTagids clears the value of the "tagids" field.
  5987. func (m *BatchMsgMutation) ClearTagids() {
  5988. m.tagids = nil
  5989. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5990. }
  5991. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5992. func (m *BatchMsgMutation) TagidsCleared() bool {
  5993. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5994. return ok
  5995. }
  5996. // ResetTagids resets all changes to the "tagids" field.
  5997. func (m *BatchMsgMutation) ResetTagids() {
  5998. m.tagids = nil
  5999. delete(m.clearedFields, batchmsg.FieldTagids)
  6000. }
  6001. // SetTotal sets the "total" field.
  6002. func (m *BatchMsgMutation) SetTotal(i int32) {
  6003. m.total = &i
  6004. m.addtotal = nil
  6005. }
  6006. // Total returns the value of the "total" field in the mutation.
  6007. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  6008. v := m.total
  6009. if v == nil {
  6010. return
  6011. }
  6012. return *v, true
  6013. }
  6014. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  6015. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6017. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  6018. if !m.op.Is(OpUpdateOne) {
  6019. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  6020. }
  6021. if m.id == nil || m.oldValue == nil {
  6022. return v, errors.New("OldTotal requires an ID field in the mutation")
  6023. }
  6024. oldValue, err := m.oldValue(ctx)
  6025. if err != nil {
  6026. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  6027. }
  6028. return oldValue.Total, nil
  6029. }
  6030. // AddTotal adds i to the "total" field.
  6031. func (m *BatchMsgMutation) AddTotal(i int32) {
  6032. if m.addtotal != nil {
  6033. *m.addtotal += i
  6034. } else {
  6035. m.addtotal = &i
  6036. }
  6037. }
  6038. // AddedTotal returns the value that was added to the "total" field in this mutation.
  6039. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  6040. v := m.addtotal
  6041. if v == nil {
  6042. return
  6043. }
  6044. return *v, true
  6045. }
  6046. // ClearTotal clears the value of the "total" field.
  6047. func (m *BatchMsgMutation) ClearTotal() {
  6048. m.total = nil
  6049. m.addtotal = nil
  6050. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  6051. }
  6052. // TotalCleared returns if the "total" field was cleared in this mutation.
  6053. func (m *BatchMsgMutation) TotalCleared() bool {
  6054. _, ok := m.clearedFields[batchmsg.FieldTotal]
  6055. return ok
  6056. }
  6057. // ResetTotal resets all changes to the "total" field.
  6058. func (m *BatchMsgMutation) ResetTotal() {
  6059. m.total = nil
  6060. m.addtotal = nil
  6061. delete(m.clearedFields, batchmsg.FieldTotal)
  6062. }
  6063. // SetSuccess sets the "success" field.
  6064. func (m *BatchMsgMutation) SetSuccess(i int32) {
  6065. m.success = &i
  6066. m.addsuccess = nil
  6067. }
  6068. // Success returns the value of the "success" field in the mutation.
  6069. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  6070. v := m.success
  6071. if v == nil {
  6072. return
  6073. }
  6074. return *v, true
  6075. }
  6076. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  6077. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6079. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  6080. if !m.op.Is(OpUpdateOne) {
  6081. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  6082. }
  6083. if m.id == nil || m.oldValue == nil {
  6084. return v, errors.New("OldSuccess requires an ID field in the mutation")
  6085. }
  6086. oldValue, err := m.oldValue(ctx)
  6087. if err != nil {
  6088. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6089. }
  6090. return oldValue.Success, nil
  6091. }
  6092. // AddSuccess adds i to the "success" field.
  6093. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6094. if m.addsuccess != nil {
  6095. *m.addsuccess += i
  6096. } else {
  6097. m.addsuccess = &i
  6098. }
  6099. }
  6100. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6101. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6102. v := m.addsuccess
  6103. if v == nil {
  6104. return
  6105. }
  6106. return *v, true
  6107. }
  6108. // ClearSuccess clears the value of the "success" field.
  6109. func (m *BatchMsgMutation) ClearSuccess() {
  6110. m.success = nil
  6111. m.addsuccess = nil
  6112. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6113. }
  6114. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6115. func (m *BatchMsgMutation) SuccessCleared() bool {
  6116. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6117. return ok
  6118. }
  6119. // ResetSuccess resets all changes to the "success" field.
  6120. func (m *BatchMsgMutation) ResetSuccess() {
  6121. m.success = nil
  6122. m.addsuccess = nil
  6123. delete(m.clearedFields, batchmsg.FieldSuccess)
  6124. }
  6125. // SetFail sets the "fail" field.
  6126. func (m *BatchMsgMutation) SetFail(i int32) {
  6127. m.fail = &i
  6128. m.addfail = nil
  6129. }
  6130. // Fail returns the value of the "fail" field in the mutation.
  6131. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6132. v := m.fail
  6133. if v == nil {
  6134. return
  6135. }
  6136. return *v, true
  6137. }
  6138. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6139. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6141. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6142. if !m.op.Is(OpUpdateOne) {
  6143. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6144. }
  6145. if m.id == nil || m.oldValue == nil {
  6146. return v, errors.New("OldFail requires an ID field in the mutation")
  6147. }
  6148. oldValue, err := m.oldValue(ctx)
  6149. if err != nil {
  6150. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6151. }
  6152. return oldValue.Fail, nil
  6153. }
  6154. // AddFail adds i to the "fail" field.
  6155. func (m *BatchMsgMutation) AddFail(i int32) {
  6156. if m.addfail != nil {
  6157. *m.addfail += i
  6158. } else {
  6159. m.addfail = &i
  6160. }
  6161. }
  6162. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6163. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6164. v := m.addfail
  6165. if v == nil {
  6166. return
  6167. }
  6168. return *v, true
  6169. }
  6170. // ClearFail clears the value of the "fail" field.
  6171. func (m *BatchMsgMutation) ClearFail() {
  6172. m.fail = nil
  6173. m.addfail = nil
  6174. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6175. }
  6176. // FailCleared returns if the "fail" field was cleared in this mutation.
  6177. func (m *BatchMsgMutation) FailCleared() bool {
  6178. _, ok := m.clearedFields[batchmsg.FieldFail]
  6179. return ok
  6180. }
  6181. // ResetFail resets all changes to the "fail" field.
  6182. func (m *BatchMsgMutation) ResetFail() {
  6183. m.fail = nil
  6184. m.addfail = nil
  6185. delete(m.clearedFields, batchmsg.FieldFail)
  6186. }
  6187. // SetStartTime sets the "start_time" field.
  6188. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6189. m.start_time = &t
  6190. }
  6191. // StartTime returns the value of the "start_time" field in the mutation.
  6192. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6193. v := m.start_time
  6194. if v == nil {
  6195. return
  6196. }
  6197. return *v, true
  6198. }
  6199. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6200. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6202. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6203. if !m.op.Is(OpUpdateOne) {
  6204. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6205. }
  6206. if m.id == nil || m.oldValue == nil {
  6207. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6208. }
  6209. oldValue, err := m.oldValue(ctx)
  6210. if err != nil {
  6211. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6212. }
  6213. return oldValue.StartTime, nil
  6214. }
  6215. // ClearStartTime clears the value of the "start_time" field.
  6216. func (m *BatchMsgMutation) ClearStartTime() {
  6217. m.start_time = nil
  6218. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6219. }
  6220. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6221. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6222. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6223. return ok
  6224. }
  6225. // ResetStartTime resets all changes to the "start_time" field.
  6226. func (m *BatchMsgMutation) ResetStartTime() {
  6227. m.start_time = nil
  6228. delete(m.clearedFields, batchmsg.FieldStartTime)
  6229. }
  6230. // SetStopTime sets the "stop_time" field.
  6231. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6232. m.stop_time = &t
  6233. }
  6234. // StopTime returns the value of the "stop_time" field in the mutation.
  6235. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6236. v := m.stop_time
  6237. if v == nil {
  6238. return
  6239. }
  6240. return *v, true
  6241. }
  6242. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6243. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6245. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6246. if !m.op.Is(OpUpdateOne) {
  6247. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6248. }
  6249. if m.id == nil || m.oldValue == nil {
  6250. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6251. }
  6252. oldValue, err := m.oldValue(ctx)
  6253. if err != nil {
  6254. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6255. }
  6256. return oldValue.StopTime, nil
  6257. }
  6258. // ClearStopTime clears the value of the "stop_time" field.
  6259. func (m *BatchMsgMutation) ClearStopTime() {
  6260. m.stop_time = nil
  6261. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6262. }
  6263. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6264. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6265. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6266. return ok
  6267. }
  6268. // ResetStopTime resets all changes to the "stop_time" field.
  6269. func (m *BatchMsgMutation) ResetStopTime() {
  6270. m.stop_time = nil
  6271. delete(m.clearedFields, batchmsg.FieldStopTime)
  6272. }
  6273. // SetSendTime sets the "send_time" field.
  6274. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6275. m.send_time = &t
  6276. }
  6277. // SendTime returns the value of the "send_time" field in the mutation.
  6278. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6279. v := m.send_time
  6280. if v == nil {
  6281. return
  6282. }
  6283. return *v, true
  6284. }
  6285. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  6286. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6288. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6289. if !m.op.Is(OpUpdateOne) {
  6290. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6291. }
  6292. if m.id == nil || m.oldValue == nil {
  6293. return v, errors.New("OldSendTime requires an ID field in the mutation")
  6294. }
  6295. oldValue, err := m.oldValue(ctx)
  6296. if err != nil {
  6297. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  6298. }
  6299. return oldValue.SendTime, nil
  6300. }
  6301. // ClearSendTime clears the value of the "send_time" field.
  6302. func (m *BatchMsgMutation) ClearSendTime() {
  6303. m.send_time = nil
  6304. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6305. }
  6306. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6307. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6308. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6309. return ok
  6310. }
  6311. // ResetSendTime resets all changes to the "send_time" field.
  6312. func (m *BatchMsgMutation) ResetSendTime() {
  6313. m.send_time = nil
  6314. delete(m.clearedFields, batchmsg.FieldSendTime)
  6315. }
  6316. // SetType sets the "type" field.
  6317. func (m *BatchMsgMutation) SetType(i int32) {
  6318. m._type = &i
  6319. m.add_type = nil
  6320. }
  6321. // GetType returns the value of the "type" field in the mutation.
  6322. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6323. v := m._type
  6324. if v == nil {
  6325. return
  6326. }
  6327. return *v, true
  6328. }
  6329. // OldType returns the old "type" field's value of the BatchMsg entity.
  6330. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6332. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6333. if !m.op.Is(OpUpdateOne) {
  6334. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6335. }
  6336. if m.id == nil || m.oldValue == nil {
  6337. return v, errors.New("OldType requires an ID field in the mutation")
  6338. }
  6339. oldValue, err := m.oldValue(ctx)
  6340. if err != nil {
  6341. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6342. }
  6343. return oldValue.Type, nil
  6344. }
  6345. // AddType adds i to the "type" field.
  6346. func (m *BatchMsgMutation) AddType(i int32) {
  6347. if m.add_type != nil {
  6348. *m.add_type += i
  6349. } else {
  6350. m.add_type = &i
  6351. }
  6352. }
  6353. // AddedType returns the value that was added to the "type" field in this mutation.
  6354. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6355. v := m.add_type
  6356. if v == nil {
  6357. return
  6358. }
  6359. return *v, true
  6360. }
  6361. // ClearType clears the value of the "type" field.
  6362. func (m *BatchMsgMutation) ClearType() {
  6363. m._type = nil
  6364. m.add_type = nil
  6365. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6366. }
  6367. // TypeCleared returns if the "type" field was cleared in this mutation.
  6368. func (m *BatchMsgMutation) TypeCleared() bool {
  6369. _, ok := m.clearedFields[batchmsg.FieldType]
  6370. return ok
  6371. }
  6372. // ResetType resets all changes to the "type" field.
  6373. func (m *BatchMsgMutation) ResetType() {
  6374. m._type = nil
  6375. m.add_type = nil
  6376. delete(m.clearedFields, batchmsg.FieldType)
  6377. }
  6378. // SetOrganizationID sets the "organization_id" field.
  6379. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6380. m.organization_id = &u
  6381. m.addorganization_id = nil
  6382. }
  6383. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6384. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6385. v := m.organization_id
  6386. if v == nil {
  6387. return
  6388. }
  6389. return *v, true
  6390. }
  6391. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6392. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6394. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6395. if !m.op.Is(OpUpdateOne) {
  6396. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6397. }
  6398. if m.id == nil || m.oldValue == nil {
  6399. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6400. }
  6401. oldValue, err := m.oldValue(ctx)
  6402. if err != nil {
  6403. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6404. }
  6405. return oldValue.OrganizationID, nil
  6406. }
  6407. // AddOrganizationID adds u to the "organization_id" field.
  6408. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6409. if m.addorganization_id != nil {
  6410. *m.addorganization_id += u
  6411. } else {
  6412. m.addorganization_id = &u
  6413. }
  6414. }
  6415. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6416. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6417. v := m.addorganization_id
  6418. if v == nil {
  6419. return
  6420. }
  6421. return *v, true
  6422. }
  6423. // ResetOrganizationID resets all changes to the "organization_id" field.
  6424. func (m *BatchMsgMutation) ResetOrganizationID() {
  6425. m.organization_id = nil
  6426. m.addorganization_id = nil
  6427. }
  6428. // SetCtype sets the "ctype" field.
  6429. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6430. m.ctype = &u
  6431. m.addctype = nil
  6432. }
  6433. // Ctype returns the value of the "ctype" field in the mutation.
  6434. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6435. v := m.ctype
  6436. if v == nil {
  6437. return
  6438. }
  6439. return *v, true
  6440. }
  6441. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6442. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6444. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6445. if !m.op.Is(OpUpdateOne) {
  6446. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6447. }
  6448. if m.id == nil || m.oldValue == nil {
  6449. return v, errors.New("OldCtype requires an ID field in the mutation")
  6450. }
  6451. oldValue, err := m.oldValue(ctx)
  6452. if err != nil {
  6453. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6454. }
  6455. return oldValue.Ctype, nil
  6456. }
  6457. // AddCtype adds u to the "ctype" field.
  6458. func (m *BatchMsgMutation) AddCtype(u int64) {
  6459. if m.addctype != nil {
  6460. *m.addctype += u
  6461. } else {
  6462. m.addctype = &u
  6463. }
  6464. }
  6465. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6466. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6467. v := m.addctype
  6468. if v == nil {
  6469. return
  6470. }
  6471. return *v, true
  6472. }
  6473. // ResetCtype resets all changes to the "ctype" field.
  6474. func (m *BatchMsgMutation) ResetCtype() {
  6475. m.ctype = nil
  6476. m.addctype = nil
  6477. }
  6478. // SetCc sets the "cc" field.
  6479. func (m *BatchMsgMutation) SetCc(s string) {
  6480. m.cc = &s
  6481. }
  6482. // Cc returns the value of the "cc" field in the mutation.
  6483. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6484. v := m.cc
  6485. if v == nil {
  6486. return
  6487. }
  6488. return *v, true
  6489. }
  6490. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6491. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6493. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6494. if !m.op.Is(OpUpdateOne) {
  6495. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6496. }
  6497. if m.id == nil || m.oldValue == nil {
  6498. return v, errors.New("OldCc requires an ID field in the mutation")
  6499. }
  6500. oldValue, err := m.oldValue(ctx)
  6501. if err != nil {
  6502. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6503. }
  6504. return oldValue.Cc, nil
  6505. }
  6506. // ClearCc clears the value of the "cc" field.
  6507. func (m *BatchMsgMutation) ClearCc() {
  6508. m.cc = nil
  6509. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6510. }
  6511. // CcCleared returns if the "cc" field was cleared in this mutation.
  6512. func (m *BatchMsgMutation) CcCleared() bool {
  6513. _, ok := m.clearedFields[batchmsg.FieldCc]
  6514. return ok
  6515. }
  6516. // ResetCc resets all changes to the "cc" field.
  6517. func (m *BatchMsgMutation) ResetCc() {
  6518. m.cc = nil
  6519. delete(m.clearedFields, batchmsg.FieldCc)
  6520. }
  6521. // SetPhone sets the "phone" field.
  6522. func (m *BatchMsgMutation) SetPhone(s string) {
  6523. m.phone = &s
  6524. }
  6525. // Phone returns the value of the "phone" field in the mutation.
  6526. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6527. v := m.phone
  6528. if v == nil {
  6529. return
  6530. }
  6531. return *v, true
  6532. }
  6533. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6534. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6536. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6537. if !m.op.Is(OpUpdateOne) {
  6538. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6539. }
  6540. if m.id == nil || m.oldValue == nil {
  6541. return v, errors.New("OldPhone requires an ID field in the mutation")
  6542. }
  6543. oldValue, err := m.oldValue(ctx)
  6544. if err != nil {
  6545. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6546. }
  6547. return oldValue.Phone, nil
  6548. }
  6549. // ClearPhone clears the value of the "phone" field.
  6550. func (m *BatchMsgMutation) ClearPhone() {
  6551. m.phone = nil
  6552. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6553. }
  6554. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6555. func (m *BatchMsgMutation) PhoneCleared() bool {
  6556. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6557. return ok
  6558. }
  6559. // ResetPhone resets all changes to the "phone" field.
  6560. func (m *BatchMsgMutation) ResetPhone() {
  6561. m.phone = nil
  6562. delete(m.clearedFields, batchmsg.FieldPhone)
  6563. }
  6564. // SetTemplateName sets the "template_name" field.
  6565. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6566. m.template_name = &s
  6567. }
  6568. // TemplateName returns the value of the "template_name" field in the mutation.
  6569. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6570. v := m.template_name
  6571. if v == nil {
  6572. return
  6573. }
  6574. return *v, true
  6575. }
  6576. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6577. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6579. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6580. if !m.op.Is(OpUpdateOne) {
  6581. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6582. }
  6583. if m.id == nil || m.oldValue == nil {
  6584. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6585. }
  6586. oldValue, err := m.oldValue(ctx)
  6587. if err != nil {
  6588. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6589. }
  6590. return oldValue.TemplateName, nil
  6591. }
  6592. // ClearTemplateName clears the value of the "template_name" field.
  6593. func (m *BatchMsgMutation) ClearTemplateName() {
  6594. m.template_name = nil
  6595. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6596. }
  6597. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6598. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6599. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6600. return ok
  6601. }
  6602. // ResetTemplateName resets all changes to the "template_name" field.
  6603. func (m *BatchMsgMutation) ResetTemplateName() {
  6604. m.template_name = nil
  6605. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6606. }
  6607. // SetTemplateCode sets the "template_code" field.
  6608. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6609. m.template_code = &s
  6610. }
  6611. // TemplateCode returns the value of the "template_code" field in the mutation.
  6612. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6613. v := m.template_code
  6614. if v == nil {
  6615. return
  6616. }
  6617. return *v, true
  6618. }
  6619. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6620. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6622. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6623. if !m.op.Is(OpUpdateOne) {
  6624. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6625. }
  6626. if m.id == nil || m.oldValue == nil {
  6627. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6628. }
  6629. oldValue, err := m.oldValue(ctx)
  6630. if err != nil {
  6631. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6632. }
  6633. return oldValue.TemplateCode, nil
  6634. }
  6635. // ClearTemplateCode clears the value of the "template_code" field.
  6636. func (m *BatchMsgMutation) ClearTemplateCode() {
  6637. m.template_code = nil
  6638. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6639. }
  6640. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6641. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6642. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6643. return ok
  6644. }
  6645. // ResetTemplateCode resets all changes to the "template_code" field.
  6646. func (m *BatchMsgMutation) ResetTemplateCode() {
  6647. m.template_code = nil
  6648. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6649. }
  6650. // SetLang sets the "lang" field.
  6651. func (m *BatchMsgMutation) SetLang(s string) {
  6652. m.lang = &s
  6653. }
  6654. // Lang returns the value of the "lang" field in the mutation.
  6655. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6656. v := m.lang
  6657. if v == nil {
  6658. return
  6659. }
  6660. return *v, true
  6661. }
  6662. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6663. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6665. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6666. if !m.op.Is(OpUpdateOne) {
  6667. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6668. }
  6669. if m.id == nil || m.oldValue == nil {
  6670. return v, errors.New("OldLang requires an ID field in the mutation")
  6671. }
  6672. oldValue, err := m.oldValue(ctx)
  6673. if err != nil {
  6674. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6675. }
  6676. return oldValue.Lang, nil
  6677. }
  6678. // ClearLang clears the value of the "lang" field.
  6679. func (m *BatchMsgMutation) ClearLang() {
  6680. m.lang = nil
  6681. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6682. }
  6683. // LangCleared returns if the "lang" field was cleared in this mutation.
  6684. func (m *BatchMsgMutation) LangCleared() bool {
  6685. _, ok := m.clearedFields[batchmsg.FieldLang]
  6686. return ok
  6687. }
  6688. // ResetLang resets all changes to the "lang" field.
  6689. func (m *BatchMsgMutation) ResetLang() {
  6690. m.lang = nil
  6691. delete(m.clearedFields, batchmsg.FieldLang)
  6692. }
  6693. // Where appends a list predicates to the BatchMsgMutation builder.
  6694. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6695. m.predicates = append(m.predicates, ps...)
  6696. }
  6697. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6698. // users can use type-assertion to append predicates that do not depend on any generated package.
  6699. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6700. p := make([]predicate.BatchMsg, len(ps))
  6701. for i := range ps {
  6702. p[i] = ps[i]
  6703. }
  6704. m.Where(p...)
  6705. }
  6706. // Op returns the operation name.
  6707. func (m *BatchMsgMutation) Op() Op {
  6708. return m.op
  6709. }
  6710. // SetOp allows setting the mutation operation.
  6711. func (m *BatchMsgMutation) SetOp(op Op) {
  6712. m.op = op
  6713. }
  6714. // Type returns the node type of this mutation (BatchMsg).
  6715. func (m *BatchMsgMutation) Type() string {
  6716. return m.typ
  6717. }
  6718. // Fields returns all fields that were changed during this mutation. Note that in
  6719. // order to get all numeric fields that were incremented/decremented, call
  6720. // AddedFields().
  6721. func (m *BatchMsgMutation) Fields() []string {
  6722. fields := make([]string, 0, 24)
  6723. if m.created_at != nil {
  6724. fields = append(fields, batchmsg.FieldCreatedAt)
  6725. }
  6726. if m.updated_at != nil {
  6727. fields = append(fields, batchmsg.FieldUpdatedAt)
  6728. }
  6729. if m.deleted_at != nil {
  6730. fields = append(fields, batchmsg.FieldDeletedAt)
  6731. }
  6732. if m.status != nil {
  6733. fields = append(fields, batchmsg.FieldStatus)
  6734. }
  6735. if m.batch_no != nil {
  6736. fields = append(fields, batchmsg.FieldBatchNo)
  6737. }
  6738. if m.task_name != nil {
  6739. fields = append(fields, batchmsg.FieldTaskName)
  6740. }
  6741. if m.fromwxid != nil {
  6742. fields = append(fields, batchmsg.FieldFromwxid)
  6743. }
  6744. if m.msg != nil {
  6745. fields = append(fields, batchmsg.FieldMsg)
  6746. }
  6747. if m.tag != nil {
  6748. fields = append(fields, batchmsg.FieldTag)
  6749. }
  6750. if m.tagids != nil {
  6751. fields = append(fields, batchmsg.FieldTagids)
  6752. }
  6753. if m.total != nil {
  6754. fields = append(fields, batchmsg.FieldTotal)
  6755. }
  6756. if m.success != nil {
  6757. fields = append(fields, batchmsg.FieldSuccess)
  6758. }
  6759. if m.fail != nil {
  6760. fields = append(fields, batchmsg.FieldFail)
  6761. }
  6762. if m.start_time != nil {
  6763. fields = append(fields, batchmsg.FieldStartTime)
  6764. }
  6765. if m.stop_time != nil {
  6766. fields = append(fields, batchmsg.FieldStopTime)
  6767. }
  6768. if m.send_time != nil {
  6769. fields = append(fields, batchmsg.FieldSendTime)
  6770. }
  6771. if m._type != nil {
  6772. fields = append(fields, batchmsg.FieldType)
  6773. }
  6774. if m.organization_id != nil {
  6775. fields = append(fields, batchmsg.FieldOrganizationID)
  6776. }
  6777. if m.ctype != nil {
  6778. fields = append(fields, batchmsg.FieldCtype)
  6779. }
  6780. if m.cc != nil {
  6781. fields = append(fields, batchmsg.FieldCc)
  6782. }
  6783. if m.phone != nil {
  6784. fields = append(fields, batchmsg.FieldPhone)
  6785. }
  6786. if m.template_name != nil {
  6787. fields = append(fields, batchmsg.FieldTemplateName)
  6788. }
  6789. if m.template_code != nil {
  6790. fields = append(fields, batchmsg.FieldTemplateCode)
  6791. }
  6792. if m.lang != nil {
  6793. fields = append(fields, batchmsg.FieldLang)
  6794. }
  6795. return fields
  6796. }
  6797. // Field returns the value of a field with the given name. The second boolean
  6798. // return value indicates that this field was not set, or was not defined in the
  6799. // schema.
  6800. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6801. switch name {
  6802. case batchmsg.FieldCreatedAt:
  6803. return m.CreatedAt()
  6804. case batchmsg.FieldUpdatedAt:
  6805. return m.UpdatedAt()
  6806. case batchmsg.FieldDeletedAt:
  6807. return m.DeletedAt()
  6808. case batchmsg.FieldStatus:
  6809. return m.Status()
  6810. case batchmsg.FieldBatchNo:
  6811. return m.BatchNo()
  6812. case batchmsg.FieldTaskName:
  6813. return m.TaskName()
  6814. case batchmsg.FieldFromwxid:
  6815. return m.Fromwxid()
  6816. case batchmsg.FieldMsg:
  6817. return m.Msg()
  6818. case batchmsg.FieldTag:
  6819. return m.Tag()
  6820. case batchmsg.FieldTagids:
  6821. return m.Tagids()
  6822. case batchmsg.FieldTotal:
  6823. return m.Total()
  6824. case batchmsg.FieldSuccess:
  6825. return m.Success()
  6826. case batchmsg.FieldFail:
  6827. return m.Fail()
  6828. case batchmsg.FieldStartTime:
  6829. return m.StartTime()
  6830. case batchmsg.FieldStopTime:
  6831. return m.StopTime()
  6832. case batchmsg.FieldSendTime:
  6833. return m.SendTime()
  6834. case batchmsg.FieldType:
  6835. return m.GetType()
  6836. case batchmsg.FieldOrganizationID:
  6837. return m.OrganizationID()
  6838. case batchmsg.FieldCtype:
  6839. return m.Ctype()
  6840. case batchmsg.FieldCc:
  6841. return m.Cc()
  6842. case batchmsg.FieldPhone:
  6843. return m.Phone()
  6844. case batchmsg.FieldTemplateName:
  6845. return m.TemplateName()
  6846. case batchmsg.FieldTemplateCode:
  6847. return m.TemplateCode()
  6848. case batchmsg.FieldLang:
  6849. return m.Lang()
  6850. }
  6851. return nil, false
  6852. }
  6853. // OldField returns the old value of the field from the database. An error is
  6854. // returned if the mutation operation is not UpdateOne, or the query to the
  6855. // database failed.
  6856. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6857. switch name {
  6858. case batchmsg.FieldCreatedAt:
  6859. return m.OldCreatedAt(ctx)
  6860. case batchmsg.FieldUpdatedAt:
  6861. return m.OldUpdatedAt(ctx)
  6862. case batchmsg.FieldDeletedAt:
  6863. return m.OldDeletedAt(ctx)
  6864. case batchmsg.FieldStatus:
  6865. return m.OldStatus(ctx)
  6866. case batchmsg.FieldBatchNo:
  6867. return m.OldBatchNo(ctx)
  6868. case batchmsg.FieldTaskName:
  6869. return m.OldTaskName(ctx)
  6870. case batchmsg.FieldFromwxid:
  6871. return m.OldFromwxid(ctx)
  6872. case batchmsg.FieldMsg:
  6873. return m.OldMsg(ctx)
  6874. case batchmsg.FieldTag:
  6875. return m.OldTag(ctx)
  6876. case batchmsg.FieldTagids:
  6877. return m.OldTagids(ctx)
  6878. case batchmsg.FieldTotal:
  6879. return m.OldTotal(ctx)
  6880. case batchmsg.FieldSuccess:
  6881. return m.OldSuccess(ctx)
  6882. case batchmsg.FieldFail:
  6883. return m.OldFail(ctx)
  6884. case batchmsg.FieldStartTime:
  6885. return m.OldStartTime(ctx)
  6886. case batchmsg.FieldStopTime:
  6887. return m.OldStopTime(ctx)
  6888. case batchmsg.FieldSendTime:
  6889. return m.OldSendTime(ctx)
  6890. case batchmsg.FieldType:
  6891. return m.OldType(ctx)
  6892. case batchmsg.FieldOrganizationID:
  6893. return m.OldOrganizationID(ctx)
  6894. case batchmsg.FieldCtype:
  6895. return m.OldCtype(ctx)
  6896. case batchmsg.FieldCc:
  6897. return m.OldCc(ctx)
  6898. case batchmsg.FieldPhone:
  6899. return m.OldPhone(ctx)
  6900. case batchmsg.FieldTemplateName:
  6901. return m.OldTemplateName(ctx)
  6902. case batchmsg.FieldTemplateCode:
  6903. return m.OldTemplateCode(ctx)
  6904. case batchmsg.FieldLang:
  6905. return m.OldLang(ctx)
  6906. }
  6907. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6908. }
  6909. // SetField sets the value of a field with the given name. It returns an error if
  6910. // the field is not defined in the schema, or if the type mismatched the field
  6911. // type.
  6912. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6913. switch name {
  6914. case batchmsg.FieldCreatedAt:
  6915. v, ok := value.(time.Time)
  6916. if !ok {
  6917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6918. }
  6919. m.SetCreatedAt(v)
  6920. return nil
  6921. case batchmsg.FieldUpdatedAt:
  6922. v, ok := value.(time.Time)
  6923. if !ok {
  6924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6925. }
  6926. m.SetUpdatedAt(v)
  6927. return nil
  6928. case batchmsg.FieldDeletedAt:
  6929. v, ok := value.(time.Time)
  6930. if !ok {
  6931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6932. }
  6933. m.SetDeletedAt(v)
  6934. return nil
  6935. case batchmsg.FieldStatus:
  6936. v, ok := value.(uint8)
  6937. if !ok {
  6938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6939. }
  6940. m.SetStatus(v)
  6941. return nil
  6942. case batchmsg.FieldBatchNo:
  6943. v, ok := value.(string)
  6944. if !ok {
  6945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6946. }
  6947. m.SetBatchNo(v)
  6948. return nil
  6949. case batchmsg.FieldTaskName:
  6950. v, ok := value.(string)
  6951. if !ok {
  6952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6953. }
  6954. m.SetTaskName(v)
  6955. return nil
  6956. case batchmsg.FieldFromwxid:
  6957. v, ok := value.(string)
  6958. if !ok {
  6959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6960. }
  6961. m.SetFromwxid(v)
  6962. return nil
  6963. case batchmsg.FieldMsg:
  6964. v, ok := value.(string)
  6965. if !ok {
  6966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6967. }
  6968. m.SetMsg(v)
  6969. return nil
  6970. case batchmsg.FieldTag:
  6971. v, ok := value.(string)
  6972. if !ok {
  6973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6974. }
  6975. m.SetTag(v)
  6976. return nil
  6977. case batchmsg.FieldTagids:
  6978. v, ok := value.(string)
  6979. if !ok {
  6980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6981. }
  6982. m.SetTagids(v)
  6983. return nil
  6984. case batchmsg.FieldTotal:
  6985. v, ok := value.(int32)
  6986. if !ok {
  6987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6988. }
  6989. m.SetTotal(v)
  6990. return nil
  6991. case batchmsg.FieldSuccess:
  6992. v, ok := value.(int32)
  6993. if !ok {
  6994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6995. }
  6996. m.SetSuccess(v)
  6997. return nil
  6998. case batchmsg.FieldFail:
  6999. v, ok := value.(int32)
  7000. if !ok {
  7001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7002. }
  7003. m.SetFail(v)
  7004. return nil
  7005. case batchmsg.FieldStartTime:
  7006. v, ok := value.(time.Time)
  7007. if !ok {
  7008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7009. }
  7010. m.SetStartTime(v)
  7011. return nil
  7012. case batchmsg.FieldStopTime:
  7013. v, ok := value.(time.Time)
  7014. if !ok {
  7015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7016. }
  7017. m.SetStopTime(v)
  7018. return nil
  7019. case batchmsg.FieldSendTime:
  7020. v, ok := value.(time.Time)
  7021. if !ok {
  7022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7023. }
  7024. m.SetSendTime(v)
  7025. return nil
  7026. case batchmsg.FieldType:
  7027. v, ok := value.(int32)
  7028. if !ok {
  7029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7030. }
  7031. m.SetType(v)
  7032. return nil
  7033. case batchmsg.FieldOrganizationID:
  7034. v, ok := value.(uint64)
  7035. if !ok {
  7036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7037. }
  7038. m.SetOrganizationID(v)
  7039. return nil
  7040. case batchmsg.FieldCtype:
  7041. v, ok := value.(uint64)
  7042. if !ok {
  7043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7044. }
  7045. m.SetCtype(v)
  7046. return nil
  7047. case batchmsg.FieldCc:
  7048. v, ok := value.(string)
  7049. if !ok {
  7050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7051. }
  7052. m.SetCc(v)
  7053. return nil
  7054. case batchmsg.FieldPhone:
  7055. v, ok := value.(string)
  7056. if !ok {
  7057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7058. }
  7059. m.SetPhone(v)
  7060. return nil
  7061. case batchmsg.FieldTemplateName:
  7062. v, ok := value.(string)
  7063. if !ok {
  7064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7065. }
  7066. m.SetTemplateName(v)
  7067. return nil
  7068. case batchmsg.FieldTemplateCode:
  7069. v, ok := value.(string)
  7070. if !ok {
  7071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7072. }
  7073. m.SetTemplateCode(v)
  7074. return nil
  7075. case batchmsg.FieldLang:
  7076. v, ok := value.(string)
  7077. if !ok {
  7078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7079. }
  7080. m.SetLang(v)
  7081. return nil
  7082. }
  7083. return fmt.Errorf("unknown BatchMsg field %s", name)
  7084. }
  7085. // AddedFields returns all numeric fields that were incremented/decremented during
  7086. // this mutation.
  7087. func (m *BatchMsgMutation) AddedFields() []string {
  7088. var fields []string
  7089. if m.addstatus != nil {
  7090. fields = append(fields, batchmsg.FieldStatus)
  7091. }
  7092. if m.addtotal != nil {
  7093. fields = append(fields, batchmsg.FieldTotal)
  7094. }
  7095. if m.addsuccess != nil {
  7096. fields = append(fields, batchmsg.FieldSuccess)
  7097. }
  7098. if m.addfail != nil {
  7099. fields = append(fields, batchmsg.FieldFail)
  7100. }
  7101. if m.add_type != nil {
  7102. fields = append(fields, batchmsg.FieldType)
  7103. }
  7104. if m.addorganization_id != nil {
  7105. fields = append(fields, batchmsg.FieldOrganizationID)
  7106. }
  7107. if m.addctype != nil {
  7108. fields = append(fields, batchmsg.FieldCtype)
  7109. }
  7110. return fields
  7111. }
  7112. // AddedField returns the numeric value that was incremented/decremented on a field
  7113. // with the given name. The second boolean return value indicates that this field
  7114. // was not set, or was not defined in the schema.
  7115. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7116. switch name {
  7117. case batchmsg.FieldStatus:
  7118. return m.AddedStatus()
  7119. case batchmsg.FieldTotal:
  7120. return m.AddedTotal()
  7121. case batchmsg.FieldSuccess:
  7122. return m.AddedSuccess()
  7123. case batchmsg.FieldFail:
  7124. return m.AddedFail()
  7125. case batchmsg.FieldType:
  7126. return m.AddedType()
  7127. case batchmsg.FieldOrganizationID:
  7128. return m.AddedOrganizationID()
  7129. case batchmsg.FieldCtype:
  7130. return m.AddedCtype()
  7131. }
  7132. return nil, false
  7133. }
  7134. // AddField adds the value to the field with the given name. It returns an error if
  7135. // the field is not defined in the schema, or if the type mismatched the field
  7136. // type.
  7137. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7138. switch name {
  7139. case batchmsg.FieldStatus:
  7140. v, ok := value.(int8)
  7141. if !ok {
  7142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7143. }
  7144. m.AddStatus(v)
  7145. return nil
  7146. case batchmsg.FieldTotal:
  7147. v, ok := value.(int32)
  7148. if !ok {
  7149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7150. }
  7151. m.AddTotal(v)
  7152. return nil
  7153. case batchmsg.FieldSuccess:
  7154. v, ok := value.(int32)
  7155. if !ok {
  7156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7157. }
  7158. m.AddSuccess(v)
  7159. return nil
  7160. case batchmsg.FieldFail:
  7161. v, ok := value.(int32)
  7162. if !ok {
  7163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7164. }
  7165. m.AddFail(v)
  7166. return nil
  7167. case batchmsg.FieldType:
  7168. v, ok := value.(int32)
  7169. if !ok {
  7170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7171. }
  7172. m.AddType(v)
  7173. return nil
  7174. case batchmsg.FieldOrganizationID:
  7175. v, ok := value.(int64)
  7176. if !ok {
  7177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7178. }
  7179. m.AddOrganizationID(v)
  7180. return nil
  7181. case batchmsg.FieldCtype:
  7182. v, ok := value.(int64)
  7183. if !ok {
  7184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7185. }
  7186. m.AddCtype(v)
  7187. return nil
  7188. }
  7189. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7190. }
  7191. // ClearedFields returns all nullable fields that were cleared during this
  7192. // mutation.
  7193. func (m *BatchMsgMutation) ClearedFields() []string {
  7194. var fields []string
  7195. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7196. fields = append(fields, batchmsg.FieldDeletedAt)
  7197. }
  7198. if m.FieldCleared(batchmsg.FieldStatus) {
  7199. fields = append(fields, batchmsg.FieldStatus)
  7200. }
  7201. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7202. fields = append(fields, batchmsg.FieldBatchNo)
  7203. }
  7204. if m.FieldCleared(batchmsg.FieldTaskName) {
  7205. fields = append(fields, batchmsg.FieldTaskName)
  7206. }
  7207. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7208. fields = append(fields, batchmsg.FieldFromwxid)
  7209. }
  7210. if m.FieldCleared(batchmsg.FieldMsg) {
  7211. fields = append(fields, batchmsg.FieldMsg)
  7212. }
  7213. if m.FieldCleared(batchmsg.FieldTag) {
  7214. fields = append(fields, batchmsg.FieldTag)
  7215. }
  7216. if m.FieldCleared(batchmsg.FieldTagids) {
  7217. fields = append(fields, batchmsg.FieldTagids)
  7218. }
  7219. if m.FieldCleared(batchmsg.FieldTotal) {
  7220. fields = append(fields, batchmsg.FieldTotal)
  7221. }
  7222. if m.FieldCleared(batchmsg.FieldSuccess) {
  7223. fields = append(fields, batchmsg.FieldSuccess)
  7224. }
  7225. if m.FieldCleared(batchmsg.FieldFail) {
  7226. fields = append(fields, batchmsg.FieldFail)
  7227. }
  7228. if m.FieldCleared(batchmsg.FieldStartTime) {
  7229. fields = append(fields, batchmsg.FieldStartTime)
  7230. }
  7231. if m.FieldCleared(batchmsg.FieldStopTime) {
  7232. fields = append(fields, batchmsg.FieldStopTime)
  7233. }
  7234. if m.FieldCleared(batchmsg.FieldSendTime) {
  7235. fields = append(fields, batchmsg.FieldSendTime)
  7236. }
  7237. if m.FieldCleared(batchmsg.FieldType) {
  7238. fields = append(fields, batchmsg.FieldType)
  7239. }
  7240. if m.FieldCleared(batchmsg.FieldCc) {
  7241. fields = append(fields, batchmsg.FieldCc)
  7242. }
  7243. if m.FieldCleared(batchmsg.FieldPhone) {
  7244. fields = append(fields, batchmsg.FieldPhone)
  7245. }
  7246. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7247. fields = append(fields, batchmsg.FieldTemplateName)
  7248. }
  7249. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7250. fields = append(fields, batchmsg.FieldTemplateCode)
  7251. }
  7252. if m.FieldCleared(batchmsg.FieldLang) {
  7253. fields = append(fields, batchmsg.FieldLang)
  7254. }
  7255. return fields
  7256. }
  7257. // FieldCleared returns a boolean indicating if a field with the given name was
  7258. // cleared in this mutation.
  7259. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7260. _, ok := m.clearedFields[name]
  7261. return ok
  7262. }
  7263. // ClearField clears the value of the field with the given name. It returns an
  7264. // error if the field is not defined in the schema.
  7265. func (m *BatchMsgMutation) ClearField(name string) error {
  7266. switch name {
  7267. case batchmsg.FieldDeletedAt:
  7268. m.ClearDeletedAt()
  7269. return nil
  7270. case batchmsg.FieldStatus:
  7271. m.ClearStatus()
  7272. return nil
  7273. case batchmsg.FieldBatchNo:
  7274. m.ClearBatchNo()
  7275. return nil
  7276. case batchmsg.FieldTaskName:
  7277. m.ClearTaskName()
  7278. return nil
  7279. case batchmsg.FieldFromwxid:
  7280. m.ClearFromwxid()
  7281. return nil
  7282. case batchmsg.FieldMsg:
  7283. m.ClearMsg()
  7284. return nil
  7285. case batchmsg.FieldTag:
  7286. m.ClearTag()
  7287. return nil
  7288. case batchmsg.FieldTagids:
  7289. m.ClearTagids()
  7290. return nil
  7291. case batchmsg.FieldTotal:
  7292. m.ClearTotal()
  7293. return nil
  7294. case batchmsg.FieldSuccess:
  7295. m.ClearSuccess()
  7296. return nil
  7297. case batchmsg.FieldFail:
  7298. m.ClearFail()
  7299. return nil
  7300. case batchmsg.FieldStartTime:
  7301. m.ClearStartTime()
  7302. return nil
  7303. case batchmsg.FieldStopTime:
  7304. m.ClearStopTime()
  7305. return nil
  7306. case batchmsg.FieldSendTime:
  7307. m.ClearSendTime()
  7308. return nil
  7309. case batchmsg.FieldType:
  7310. m.ClearType()
  7311. return nil
  7312. case batchmsg.FieldCc:
  7313. m.ClearCc()
  7314. return nil
  7315. case batchmsg.FieldPhone:
  7316. m.ClearPhone()
  7317. return nil
  7318. case batchmsg.FieldTemplateName:
  7319. m.ClearTemplateName()
  7320. return nil
  7321. case batchmsg.FieldTemplateCode:
  7322. m.ClearTemplateCode()
  7323. return nil
  7324. case batchmsg.FieldLang:
  7325. m.ClearLang()
  7326. return nil
  7327. }
  7328. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7329. }
  7330. // ResetField resets all changes in the mutation for the field with the given name.
  7331. // It returns an error if the field is not defined in the schema.
  7332. func (m *BatchMsgMutation) ResetField(name string) error {
  7333. switch name {
  7334. case batchmsg.FieldCreatedAt:
  7335. m.ResetCreatedAt()
  7336. return nil
  7337. case batchmsg.FieldUpdatedAt:
  7338. m.ResetUpdatedAt()
  7339. return nil
  7340. case batchmsg.FieldDeletedAt:
  7341. m.ResetDeletedAt()
  7342. return nil
  7343. case batchmsg.FieldStatus:
  7344. m.ResetStatus()
  7345. return nil
  7346. case batchmsg.FieldBatchNo:
  7347. m.ResetBatchNo()
  7348. return nil
  7349. case batchmsg.FieldTaskName:
  7350. m.ResetTaskName()
  7351. return nil
  7352. case batchmsg.FieldFromwxid:
  7353. m.ResetFromwxid()
  7354. return nil
  7355. case batchmsg.FieldMsg:
  7356. m.ResetMsg()
  7357. return nil
  7358. case batchmsg.FieldTag:
  7359. m.ResetTag()
  7360. return nil
  7361. case batchmsg.FieldTagids:
  7362. m.ResetTagids()
  7363. return nil
  7364. case batchmsg.FieldTotal:
  7365. m.ResetTotal()
  7366. return nil
  7367. case batchmsg.FieldSuccess:
  7368. m.ResetSuccess()
  7369. return nil
  7370. case batchmsg.FieldFail:
  7371. m.ResetFail()
  7372. return nil
  7373. case batchmsg.FieldStartTime:
  7374. m.ResetStartTime()
  7375. return nil
  7376. case batchmsg.FieldStopTime:
  7377. m.ResetStopTime()
  7378. return nil
  7379. case batchmsg.FieldSendTime:
  7380. m.ResetSendTime()
  7381. return nil
  7382. case batchmsg.FieldType:
  7383. m.ResetType()
  7384. return nil
  7385. case batchmsg.FieldOrganizationID:
  7386. m.ResetOrganizationID()
  7387. return nil
  7388. case batchmsg.FieldCtype:
  7389. m.ResetCtype()
  7390. return nil
  7391. case batchmsg.FieldCc:
  7392. m.ResetCc()
  7393. return nil
  7394. case batchmsg.FieldPhone:
  7395. m.ResetPhone()
  7396. return nil
  7397. case batchmsg.FieldTemplateName:
  7398. m.ResetTemplateName()
  7399. return nil
  7400. case batchmsg.FieldTemplateCode:
  7401. m.ResetTemplateCode()
  7402. return nil
  7403. case batchmsg.FieldLang:
  7404. m.ResetLang()
  7405. return nil
  7406. }
  7407. return fmt.Errorf("unknown BatchMsg field %s", name)
  7408. }
  7409. // AddedEdges returns all edge names that were set/added in this mutation.
  7410. func (m *BatchMsgMutation) AddedEdges() []string {
  7411. edges := make([]string, 0, 0)
  7412. return edges
  7413. }
  7414. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7415. // name in this mutation.
  7416. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7417. return nil
  7418. }
  7419. // RemovedEdges returns all edge names that were removed in this mutation.
  7420. func (m *BatchMsgMutation) RemovedEdges() []string {
  7421. edges := make([]string, 0, 0)
  7422. return edges
  7423. }
  7424. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7425. // the given name in this mutation.
  7426. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7427. return nil
  7428. }
  7429. // ClearedEdges returns all edge names that were cleared in this mutation.
  7430. func (m *BatchMsgMutation) ClearedEdges() []string {
  7431. edges := make([]string, 0, 0)
  7432. return edges
  7433. }
  7434. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7435. // was cleared in this mutation.
  7436. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7437. return false
  7438. }
  7439. // ClearEdge clears the value of the edge with the given name. It returns an error
  7440. // if that edge is not defined in the schema.
  7441. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7442. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7443. }
  7444. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7445. // It returns an error if the edge is not defined in the schema.
  7446. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7447. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7448. }
  7449. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7450. type CategoryMutation struct {
  7451. config
  7452. op Op
  7453. typ string
  7454. id *uint64
  7455. created_at *time.Time
  7456. updated_at *time.Time
  7457. deleted_at *time.Time
  7458. name *string
  7459. organization_id *uint64
  7460. addorganization_id *int64
  7461. clearedFields map[string]struct{}
  7462. done bool
  7463. oldValue func(context.Context) (*Category, error)
  7464. predicates []predicate.Category
  7465. }
  7466. var _ ent.Mutation = (*CategoryMutation)(nil)
  7467. // categoryOption allows management of the mutation configuration using functional options.
  7468. type categoryOption func(*CategoryMutation)
  7469. // newCategoryMutation creates new mutation for the Category entity.
  7470. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7471. m := &CategoryMutation{
  7472. config: c,
  7473. op: op,
  7474. typ: TypeCategory,
  7475. clearedFields: make(map[string]struct{}),
  7476. }
  7477. for _, opt := range opts {
  7478. opt(m)
  7479. }
  7480. return m
  7481. }
  7482. // withCategoryID sets the ID field of the mutation.
  7483. func withCategoryID(id uint64) categoryOption {
  7484. return func(m *CategoryMutation) {
  7485. var (
  7486. err error
  7487. once sync.Once
  7488. value *Category
  7489. )
  7490. m.oldValue = func(ctx context.Context) (*Category, error) {
  7491. once.Do(func() {
  7492. if m.done {
  7493. err = errors.New("querying old values post mutation is not allowed")
  7494. } else {
  7495. value, err = m.Client().Category.Get(ctx, id)
  7496. }
  7497. })
  7498. return value, err
  7499. }
  7500. m.id = &id
  7501. }
  7502. }
  7503. // withCategory sets the old Category of the mutation.
  7504. func withCategory(node *Category) categoryOption {
  7505. return func(m *CategoryMutation) {
  7506. m.oldValue = func(context.Context) (*Category, error) {
  7507. return node, nil
  7508. }
  7509. m.id = &node.ID
  7510. }
  7511. }
  7512. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7513. // executed in a transaction (ent.Tx), a transactional client is returned.
  7514. func (m CategoryMutation) Client() *Client {
  7515. client := &Client{config: m.config}
  7516. client.init()
  7517. return client
  7518. }
  7519. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7520. // it returns an error otherwise.
  7521. func (m CategoryMutation) Tx() (*Tx, error) {
  7522. if _, ok := m.driver.(*txDriver); !ok {
  7523. return nil, errors.New("ent: mutation is not running in a transaction")
  7524. }
  7525. tx := &Tx{config: m.config}
  7526. tx.init()
  7527. return tx, nil
  7528. }
  7529. // SetID sets the value of the id field. Note that this
  7530. // operation is only accepted on creation of Category entities.
  7531. func (m *CategoryMutation) SetID(id uint64) {
  7532. m.id = &id
  7533. }
  7534. // ID returns the ID value in the mutation. Note that the ID is only available
  7535. // if it was provided to the builder or after it was returned from the database.
  7536. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7537. if m.id == nil {
  7538. return
  7539. }
  7540. return *m.id, true
  7541. }
  7542. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7543. // That means, if the mutation is applied within a transaction with an isolation level such
  7544. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7545. // or updated by the mutation.
  7546. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7547. switch {
  7548. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7549. id, exists := m.ID()
  7550. if exists {
  7551. return []uint64{id}, nil
  7552. }
  7553. fallthrough
  7554. case m.op.Is(OpUpdate | OpDelete):
  7555. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7556. default:
  7557. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7558. }
  7559. }
  7560. // SetCreatedAt sets the "created_at" field.
  7561. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7562. m.created_at = &t
  7563. }
  7564. // CreatedAt returns the value of the "created_at" field in the mutation.
  7565. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7566. v := m.created_at
  7567. if v == nil {
  7568. return
  7569. }
  7570. return *v, true
  7571. }
  7572. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7573. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7575. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7576. if !m.op.Is(OpUpdateOne) {
  7577. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7578. }
  7579. if m.id == nil || m.oldValue == nil {
  7580. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7581. }
  7582. oldValue, err := m.oldValue(ctx)
  7583. if err != nil {
  7584. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7585. }
  7586. return oldValue.CreatedAt, nil
  7587. }
  7588. // ResetCreatedAt resets all changes to the "created_at" field.
  7589. func (m *CategoryMutation) ResetCreatedAt() {
  7590. m.created_at = nil
  7591. }
  7592. // SetUpdatedAt sets the "updated_at" field.
  7593. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7594. m.updated_at = &t
  7595. }
  7596. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7597. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7598. v := m.updated_at
  7599. if v == nil {
  7600. return
  7601. }
  7602. return *v, true
  7603. }
  7604. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7605. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7607. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7608. if !m.op.Is(OpUpdateOne) {
  7609. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7610. }
  7611. if m.id == nil || m.oldValue == nil {
  7612. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7613. }
  7614. oldValue, err := m.oldValue(ctx)
  7615. if err != nil {
  7616. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7617. }
  7618. return oldValue.UpdatedAt, nil
  7619. }
  7620. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7621. func (m *CategoryMutation) ResetUpdatedAt() {
  7622. m.updated_at = nil
  7623. }
  7624. // SetDeletedAt sets the "deleted_at" field.
  7625. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7626. m.deleted_at = &t
  7627. }
  7628. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7629. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7630. v := m.deleted_at
  7631. if v == nil {
  7632. return
  7633. }
  7634. return *v, true
  7635. }
  7636. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7637. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7639. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7640. if !m.op.Is(OpUpdateOne) {
  7641. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7642. }
  7643. if m.id == nil || m.oldValue == nil {
  7644. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7645. }
  7646. oldValue, err := m.oldValue(ctx)
  7647. if err != nil {
  7648. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7649. }
  7650. return oldValue.DeletedAt, nil
  7651. }
  7652. // ClearDeletedAt clears the value of the "deleted_at" field.
  7653. func (m *CategoryMutation) ClearDeletedAt() {
  7654. m.deleted_at = nil
  7655. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7656. }
  7657. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7658. func (m *CategoryMutation) DeletedAtCleared() bool {
  7659. _, ok := m.clearedFields[category.FieldDeletedAt]
  7660. return ok
  7661. }
  7662. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7663. func (m *CategoryMutation) ResetDeletedAt() {
  7664. m.deleted_at = nil
  7665. delete(m.clearedFields, category.FieldDeletedAt)
  7666. }
  7667. // SetName sets the "name" field.
  7668. func (m *CategoryMutation) SetName(s string) {
  7669. m.name = &s
  7670. }
  7671. // Name returns the value of the "name" field in the mutation.
  7672. func (m *CategoryMutation) Name() (r string, exists bool) {
  7673. v := m.name
  7674. if v == nil {
  7675. return
  7676. }
  7677. return *v, true
  7678. }
  7679. // OldName returns the old "name" field's value of the Category entity.
  7680. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7682. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7683. if !m.op.Is(OpUpdateOne) {
  7684. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7685. }
  7686. if m.id == nil || m.oldValue == nil {
  7687. return v, errors.New("OldName requires an ID field in the mutation")
  7688. }
  7689. oldValue, err := m.oldValue(ctx)
  7690. if err != nil {
  7691. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7692. }
  7693. return oldValue.Name, nil
  7694. }
  7695. // ResetName resets all changes to the "name" field.
  7696. func (m *CategoryMutation) ResetName() {
  7697. m.name = nil
  7698. }
  7699. // SetOrganizationID sets the "organization_id" field.
  7700. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7701. m.organization_id = &u
  7702. m.addorganization_id = nil
  7703. }
  7704. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7705. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7706. v := m.organization_id
  7707. if v == nil {
  7708. return
  7709. }
  7710. return *v, true
  7711. }
  7712. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7713. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7715. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7716. if !m.op.Is(OpUpdateOne) {
  7717. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7718. }
  7719. if m.id == nil || m.oldValue == nil {
  7720. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7721. }
  7722. oldValue, err := m.oldValue(ctx)
  7723. if err != nil {
  7724. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7725. }
  7726. return oldValue.OrganizationID, nil
  7727. }
  7728. // AddOrganizationID adds u to the "organization_id" field.
  7729. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7730. if m.addorganization_id != nil {
  7731. *m.addorganization_id += u
  7732. } else {
  7733. m.addorganization_id = &u
  7734. }
  7735. }
  7736. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7737. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7738. v := m.addorganization_id
  7739. if v == nil {
  7740. return
  7741. }
  7742. return *v, true
  7743. }
  7744. // ResetOrganizationID resets all changes to the "organization_id" field.
  7745. func (m *CategoryMutation) ResetOrganizationID() {
  7746. m.organization_id = nil
  7747. m.addorganization_id = nil
  7748. }
  7749. // Where appends a list predicates to the CategoryMutation builder.
  7750. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7751. m.predicates = append(m.predicates, ps...)
  7752. }
  7753. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7754. // users can use type-assertion to append predicates that do not depend on any generated package.
  7755. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7756. p := make([]predicate.Category, len(ps))
  7757. for i := range ps {
  7758. p[i] = ps[i]
  7759. }
  7760. m.Where(p...)
  7761. }
  7762. // Op returns the operation name.
  7763. func (m *CategoryMutation) Op() Op {
  7764. return m.op
  7765. }
  7766. // SetOp allows setting the mutation operation.
  7767. func (m *CategoryMutation) SetOp(op Op) {
  7768. m.op = op
  7769. }
  7770. // Type returns the node type of this mutation (Category).
  7771. func (m *CategoryMutation) Type() string {
  7772. return m.typ
  7773. }
  7774. // Fields returns all fields that were changed during this mutation. Note that in
  7775. // order to get all numeric fields that were incremented/decremented, call
  7776. // AddedFields().
  7777. func (m *CategoryMutation) Fields() []string {
  7778. fields := make([]string, 0, 5)
  7779. if m.created_at != nil {
  7780. fields = append(fields, category.FieldCreatedAt)
  7781. }
  7782. if m.updated_at != nil {
  7783. fields = append(fields, category.FieldUpdatedAt)
  7784. }
  7785. if m.deleted_at != nil {
  7786. fields = append(fields, category.FieldDeletedAt)
  7787. }
  7788. if m.name != nil {
  7789. fields = append(fields, category.FieldName)
  7790. }
  7791. if m.organization_id != nil {
  7792. fields = append(fields, category.FieldOrganizationID)
  7793. }
  7794. return fields
  7795. }
  7796. // Field returns the value of a field with the given name. The second boolean
  7797. // return value indicates that this field was not set, or was not defined in the
  7798. // schema.
  7799. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7800. switch name {
  7801. case category.FieldCreatedAt:
  7802. return m.CreatedAt()
  7803. case category.FieldUpdatedAt:
  7804. return m.UpdatedAt()
  7805. case category.FieldDeletedAt:
  7806. return m.DeletedAt()
  7807. case category.FieldName:
  7808. return m.Name()
  7809. case category.FieldOrganizationID:
  7810. return m.OrganizationID()
  7811. }
  7812. return nil, false
  7813. }
  7814. // OldField returns the old value of the field from the database. An error is
  7815. // returned if the mutation operation is not UpdateOne, or the query to the
  7816. // database failed.
  7817. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7818. switch name {
  7819. case category.FieldCreatedAt:
  7820. return m.OldCreatedAt(ctx)
  7821. case category.FieldUpdatedAt:
  7822. return m.OldUpdatedAt(ctx)
  7823. case category.FieldDeletedAt:
  7824. return m.OldDeletedAt(ctx)
  7825. case category.FieldName:
  7826. return m.OldName(ctx)
  7827. case category.FieldOrganizationID:
  7828. return m.OldOrganizationID(ctx)
  7829. }
  7830. return nil, fmt.Errorf("unknown Category field %s", name)
  7831. }
  7832. // SetField sets the value of a field with the given name. It returns an error if
  7833. // the field is not defined in the schema, or if the type mismatched the field
  7834. // type.
  7835. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7836. switch name {
  7837. case category.FieldCreatedAt:
  7838. v, ok := value.(time.Time)
  7839. if !ok {
  7840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7841. }
  7842. m.SetCreatedAt(v)
  7843. return nil
  7844. case category.FieldUpdatedAt:
  7845. v, ok := value.(time.Time)
  7846. if !ok {
  7847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7848. }
  7849. m.SetUpdatedAt(v)
  7850. return nil
  7851. case category.FieldDeletedAt:
  7852. v, ok := value.(time.Time)
  7853. if !ok {
  7854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7855. }
  7856. m.SetDeletedAt(v)
  7857. return nil
  7858. case category.FieldName:
  7859. v, ok := value.(string)
  7860. if !ok {
  7861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7862. }
  7863. m.SetName(v)
  7864. return nil
  7865. case category.FieldOrganizationID:
  7866. v, ok := value.(uint64)
  7867. if !ok {
  7868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7869. }
  7870. m.SetOrganizationID(v)
  7871. return nil
  7872. }
  7873. return fmt.Errorf("unknown Category field %s", name)
  7874. }
  7875. // AddedFields returns all numeric fields that were incremented/decremented during
  7876. // this mutation.
  7877. func (m *CategoryMutation) AddedFields() []string {
  7878. var fields []string
  7879. if m.addorganization_id != nil {
  7880. fields = append(fields, category.FieldOrganizationID)
  7881. }
  7882. return fields
  7883. }
  7884. // AddedField returns the numeric value that was incremented/decremented on a field
  7885. // with the given name. The second boolean return value indicates that this field
  7886. // was not set, or was not defined in the schema.
  7887. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7888. switch name {
  7889. case category.FieldOrganizationID:
  7890. return m.AddedOrganizationID()
  7891. }
  7892. return nil, false
  7893. }
  7894. // AddField adds the value to the field with the given name. It returns an error if
  7895. // the field is not defined in the schema, or if the type mismatched the field
  7896. // type.
  7897. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7898. switch name {
  7899. case category.FieldOrganizationID:
  7900. v, ok := value.(int64)
  7901. if !ok {
  7902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7903. }
  7904. m.AddOrganizationID(v)
  7905. return nil
  7906. }
  7907. return fmt.Errorf("unknown Category numeric field %s", name)
  7908. }
  7909. // ClearedFields returns all nullable fields that were cleared during this
  7910. // mutation.
  7911. func (m *CategoryMutation) ClearedFields() []string {
  7912. var fields []string
  7913. if m.FieldCleared(category.FieldDeletedAt) {
  7914. fields = append(fields, category.FieldDeletedAt)
  7915. }
  7916. return fields
  7917. }
  7918. // FieldCleared returns a boolean indicating if a field with the given name was
  7919. // cleared in this mutation.
  7920. func (m *CategoryMutation) FieldCleared(name string) bool {
  7921. _, ok := m.clearedFields[name]
  7922. return ok
  7923. }
  7924. // ClearField clears the value of the field with the given name. It returns an
  7925. // error if the field is not defined in the schema.
  7926. func (m *CategoryMutation) ClearField(name string) error {
  7927. switch name {
  7928. case category.FieldDeletedAt:
  7929. m.ClearDeletedAt()
  7930. return nil
  7931. }
  7932. return fmt.Errorf("unknown Category nullable field %s", name)
  7933. }
  7934. // ResetField resets all changes in the mutation for the field with the given name.
  7935. // It returns an error if the field is not defined in the schema.
  7936. func (m *CategoryMutation) ResetField(name string) error {
  7937. switch name {
  7938. case category.FieldCreatedAt:
  7939. m.ResetCreatedAt()
  7940. return nil
  7941. case category.FieldUpdatedAt:
  7942. m.ResetUpdatedAt()
  7943. return nil
  7944. case category.FieldDeletedAt:
  7945. m.ResetDeletedAt()
  7946. return nil
  7947. case category.FieldName:
  7948. m.ResetName()
  7949. return nil
  7950. case category.FieldOrganizationID:
  7951. m.ResetOrganizationID()
  7952. return nil
  7953. }
  7954. return fmt.Errorf("unknown Category field %s", name)
  7955. }
  7956. // AddedEdges returns all edge names that were set/added in this mutation.
  7957. func (m *CategoryMutation) AddedEdges() []string {
  7958. edges := make([]string, 0, 0)
  7959. return edges
  7960. }
  7961. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7962. // name in this mutation.
  7963. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7964. return nil
  7965. }
  7966. // RemovedEdges returns all edge names that were removed in this mutation.
  7967. func (m *CategoryMutation) RemovedEdges() []string {
  7968. edges := make([]string, 0, 0)
  7969. return edges
  7970. }
  7971. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7972. // the given name in this mutation.
  7973. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7974. return nil
  7975. }
  7976. // ClearedEdges returns all edge names that were cleared in this mutation.
  7977. func (m *CategoryMutation) ClearedEdges() []string {
  7978. edges := make([]string, 0, 0)
  7979. return edges
  7980. }
  7981. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7982. // was cleared in this mutation.
  7983. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7984. return false
  7985. }
  7986. // ClearEdge clears the value of the edge with the given name. It returns an error
  7987. // if that edge is not defined in the schema.
  7988. func (m *CategoryMutation) ClearEdge(name string) error {
  7989. return fmt.Errorf("unknown Category unique edge %s", name)
  7990. }
  7991. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7992. // It returns an error if the edge is not defined in the schema.
  7993. func (m *CategoryMutation) ResetEdge(name string) error {
  7994. return fmt.Errorf("unknown Category edge %s", name)
  7995. }
  7996. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7997. type ChatRecordsMutation struct {
  7998. config
  7999. op Op
  8000. typ string
  8001. id *uint64
  8002. created_at *time.Time
  8003. updated_at *time.Time
  8004. deleted_at *time.Time
  8005. content *string
  8006. content_type *uint8
  8007. addcontent_type *int8
  8008. session_id *uint64
  8009. addsession_id *int64
  8010. user_id *uint64
  8011. adduser_id *int64
  8012. bot_id *uint64
  8013. addbot_id *int64
  8014. bot_type *uint8
  8015. addbot_type *int8
  8016. clearedFields map[string]struct{}
  8017. done bool
  8018. oldValue func(context.Context) (*ChatRecords, error)
  8019. predicates []predicate.ChatRecords
  8020. }
  8021. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  8022. // chatrecordsOption allows management of the mutation configuration using functional options.
  8023. type chatrecordsOption func(*ChatRecordsMutation)
  8024. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  8025. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  8026. m := &ChatRecordsMutation{
  8027. config: c,
  8028. op: op,
  8029. typ: TypeChatRecords,
  8030. clearedFields: make(map[string]struct{}),
  8031. }
  8032. for _, opt := range opts {
  8033. opt(m)
  8034. }
  8035. return m
  8036. }
  8037. // withChatRecordsID sets the ID field of the mutation.
  8038. func withChatRecordsID(id uint64) chatrecordsOption {
  8039. return func(m *ChatRecordsMutation) {
  8040. var (
  8041. err error
  8042. once sync.Once
  8043. value *ChatRecords
  8044. )
  8045. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  8046. once.Do(func() {
  8047. if m.done {
  8048. err = errors.New("querying old values post mutation is not allowed")
  8049. } else {
  8050. value, err = m.Client().ChatRecords.Get(ctx, id)
  8051. }
  8052. })
  8053. return value, err
  8054. }
  8055. m.id = &id
  8056. }
  8057. }
  8058. // withChatRecords sets the old ChatRecords of the mutation.
  8059. func withChatRecords(node *ChatRecords) chatrecordsOption {
  8060. return func(m *ChatRecordsMutation) {
  8061. m.oldValue = func(context.Context) (*ChatRecords, error) {
  8062. return node, nil
  8063. }
  8064. m.id = &node.ID
  8065. }
  8066. }
  8067. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8068. // executed in a transaction (ent.Tx), a transactional client is returned.
  8069. func (m ChatRecordsMutation) Client() *Client {
  8070. client := &Client{config: m.config}
  8071. client.init()
  8072. return client
  8073. }
  8074. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8075. // it returns an error otherwise.
  8076. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  8077. if _, ok := m.driver.(*txDriver); !ok {
  8078. return nil, errors.New("ent: mutation is not running in a transaction")
  8079. }
  8080. tx := &Tx{config: m.config}
  8081. tx.init()
  8082. return tx, nil
  8083. }
  8084. // SetID sets the value of the id field. Note that this
  8085. // operation is only accepted on creation of ChatRecords entities.
  8086. func (m *ChatRecordsMutation) SetID(id uint64) {
  8087. m.id = &id
  8088. }
  8089. // ID returns the ID value in the mutation. Note that the ID is only available
  8090. // if it was provided to the builder or after it was returned from the database.
  8091. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8092. if m.id == nil {
  8093. return
  8094. }
  8095. return *m.id, true
  8096. }
  8097. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8098. // That means, if the mutation is applied within a transaction with an isolation level such
  8099. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8100. // or updated by the mutation.
  8101. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8102. switch {
  8103. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8104. id, exists := m.ID()
  8105. if exists {
  8106. return []uint64{id}, nil
  8107. }
  8108. fallthrough
  8109. case m.op.Is(OpUpdate | OpDelete):
  8110. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8111. default:
  8112. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8113. }
  8114. }
  8115. // SetCreatedAt sets the "created_at" field.
  8116. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8117. m.created_at = &t
  8118. }
  8119. // CreatedAt returns the value of the "created_at" field in the mutation.
  8120. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8121. v := m.created_at
  8122. if v == nil {
  8123. return
  8124. }
  8125. return *v, true
  8126. }
  8127. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8128. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8130. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8131. if !m.op.Is(OpUpdateOne) {
  8132. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8133. }
  8134. if m.id == nil || m.oldValue == nil {
  8135. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8136. }
  8137. oldValue, err := m.oldValue(ctx)
  8138. if err != nil {
  8139. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8140. }
  8141. return oldValue.CreatedAt, nil
  8142. }
  8143. // ResetCreatedAt resets all changes to the "created_at" field.
  8144. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8145. m.created_at = nil
  8146. }
  8147. // SetUpdatedAt sets the "updated_at" field.
  8148. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8149. m.updated_at = &t
  8150. }
  8151. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8152. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8153. v := m.updated_at
  8154. if v == nil {
  8155. return
  8156. }
  8157. return *v, true
  8158. }
  8159. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8160. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8162. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8163. if !m.op.Is(OpUpdateOne) {
  8164. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8165. }
  8166. if m.id == nil || m.oldValue == nil {
  8167. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8168. }
  8169. oldValue, err := m.oldValue(ctx)
  8170. if err != nil {
  8171. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8172. }
  8173. return oldValue.UpdatedAt, nil
  8174. }
  8175. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8176. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8177. m.updated_at = nil
  8178. }
  8179. // SetDeletedAt sets the "deleted_at" field.
  8180. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8181. m.deleted_at = &t
  8182. }
  8183. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8184. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8185. v := m.deleted_at
  8186. if v == nil {
  8187. return
  8188. }
  8189. return *v, true
  8190. }
  8191. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8192. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8194. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8195. if !m.op.Is(OpUpdateOne) {
  8196. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8197. }
  8198. if m.id == nil || m.oldValue == nil {
  8199. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8200. }
  8201. oldValue, err := m.oldValue(ctx)
  8202. if err != nil {
  8203. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8204. }
  8205. return oldValue.DeletedAt, nil
  8206. }
  8207. // ClearDeletedAt clears the value of the "deleted_at" field.
  8208. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8209. m.deleted_at = nil
  8210. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8211. }
  8212. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8213. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8214. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8215. return ok
  8216. }
  8217. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8218. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8219. m.deleted_at = nil
  8220. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8221. }
  8222. // SetContent sets the "content" field.
  8223. func (m *ChatRecordsMutation) SetContent(s string) {
  8224. m.content = &s
  8225. }
  8226. // Content returns the value of the "content" field in the mutation.
  8227. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8228. v := m.content
  8229. if v == nil {
  8230. return
  8231. }
  8232. return *v, true
  8233. }
  8234. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8235. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8237. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8238. if !m.op.Is(OpUpdateOne) {
  8239. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8240. }
  8241. if m.id == nil || m.oldValue == nil {
  8242. return v, errors.New("OldContent requires an ID field in the mutation")
  8243. }
  8244. oldValue, err := m.oldValue(ctx)
  8245. if err != nil {
  8246. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8247. }
  8248. return oldValue.Content, nil
  8249. }
  8250. // ResetContent resets all changes to the "content" field.
  8251. func (m *ChatRecordsMutation) ResetContent() {
  8252. m.content = nil
  8253. }
  8254. // SetContentType sets the "content_type" field.
  8255. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8256. m.content_type = &u
  8257. m.addcontent_type = nil
  8258. }
  8259. // ContentType returns the value of the "content_type" field in the mutation.
  8260. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8261. v := m.content_type
  8262. if v == nil {
  8263. return
  8264. }
  8265. return *v, true
  8266. }
  8267. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8268. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8270. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8271. if !m.op.Is(OpUpdateOne) {
  8272. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8273. }
  8274. if m.id == nil || m.oldValue == nil {
  8275. return v, errors.New("OldContentType requires an ID field in the mutation")
  8276. }
  8277. oldValue, err := m.oldValue(ctx)
  8278. if err != nil {
  8279. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8280. }
  8281. return oldValue.ContentType, nil
  8282. }
  8283. // AddContentType adds u to the "content_type" field.
  8284. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8285. if m.addcontent_type != nil {
  8286. *m.addcontent_type += u
  8287. } else {
  8288. m.addcontent_type = &u
  8289. }
  8290. }
  8291. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8292. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8293. v := m.addcontent_type
  8294. if v == nil {
  8295. return
  8296. }
  8297. return *v, true
  8298. }
  8299. // ResetContentType resets all changes to the "content_type" field.
  8300. func (m *ChatRecordsMutation) ResetContentType() {
  8301. m.content_type = nil
  8302. m.addcontent_type = nil
  8303. }
  8304. // SetSessionID sets the "session_id" field.
  8305. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8306. m.session_id = &u
  8307. m.addsession_id = nil
  8308. }
  8309. // SessionID returns the value of the "session_id" field in the mutation.
  8310. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8311. v := m.session_id
  8312. if v == nil {
  8313. return
  8314. }
  8315. return *v, true
  8316. }
  8317. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8318. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8320. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8321. if !m.op.Is(OpUpdateOne) {
  8322. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8323. }
  8324. if m.id == nil || m.oldValue == nil {
  8325. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8326. }
  8327. oldValue, err := m.oldValue(ctx)
  8328. if err != nil {
  8329. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8330. }
  8331. return oldValue.SessionID, nil
  8332. }
  8333. // AddSessionID adds u to the "session_id" field.
  8334. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8335. if m.addsession_id != nil {
  8336. *m.addsession_id += u
  8337. } else {
  8338. m.addsession_id = &u
  8339. }
  8340. }
  8341. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8342. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8343. v := m.addsession_id
  8344. if v == nil {
  8345. return
  8346. }
  8347. return *v, true
  8348. }
  8349. // ResetSessionID resets all changes to the "session_id" field.
  8350. func (m *ChatRecordsMutation) ResetSessionID() {
  8351. m.session_id = nil
  8352. m.addsession_id = nil
  8353. }
  8354. // SetUserID sets the "user_id" field.
  8355. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8356. m.user_id = &u
  8357. m.adduser_id = nil
  8358. }
  8359. // UserID returns the value of the "user_id" field in the mutation.
  8360. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8361. v := m.user_id
  8362. if v == nil {
  8363. return
  8364. }
  8365. return *v, true
  8366. }
  8367. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8368. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8370. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8371. if !m.op.Is(OpUpdateOne) {
  8372. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8373. }
  8374. if m.id == nil || m.oldValue == nil {
  8375. return v, errors.New("OldUserID requires an ID field in the mutation")
  8376. }
  8377. oldValue, err := m.oldValue(ctx)
  8378. if err != nil {
  8379. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8380. }
  8381. return oldValue.UserID, nil
  8382. }
  8383. // AddUserID adds u to the "user_id" field.
  8384. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8385. if m.adduser_id != nil {
  8386. *m.adduser_id += u
  8387. } else {
  8388. m.adduser_id = &u
  8389. }
  8390. }
  8391. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8392. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8393. v := m.adduser_id
  8394. if v == nil {
  8395. return
  8396. }
  8397. return *v, true
  8398. }
  8399. // ResetUserID resets all changes to the "user_id" field.
  8400. func (m *ChatRecordsMutation) ResetUserID() {
  8401. m.user_id = nil
  8402. m.adduser_id = nil
  8403. }
  8404. // SetBotID sets the "bot_id" field.
  8405. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8406. m.bot_id = &u
  8407. m.addbot_id = nil
  8408. }
  8409. // BotID returns the value of the "bot_id" field in the mutation.
  8410. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8411. v := m.bot_id
  8412. if v == nil {
  8413. return
  8414. }
  8415. return *v, true
  8416. }
  8417. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8418. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8420. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8421. if !m.op.Is(OpUpdateOne) {
  8422. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8423. }
  8424. if m.id == nil || m.oldValue == nil {
  8425. return v, errors.New("OldBotID requires an ID field in the mutation")
  8426. }
  8427. oldValue, err := m.oldValue(ctx)
  8428. if err != nil {
  8429. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8430. }
  8431. return oldValue.BotID, nil
  8432. }
  8433. // AddBotID adds u to the "bot_id" field.
  8434. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8435. if m.addbot_id != nil {
  8436. *m.addbot_id += u
  8437. } else {
  8438. m.addbot_id = &u
  8439. }
  8440. }
  8441. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8442. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8443. v := m.addbot_id
  8444. if v == nil {
  8445. return
  8446. }
  8447. return *v, true
  8448. }
  8449. // ResetBotID resets all changes to the "bot_id" field.
  8450. func (m *ChatRecordsMutation) ResetBotID() {
  8451. m.bot_id = nil
  8452. m.addbot_id = nil
  8453. }
  8454. // SetBotType sets the "bot_type" field.
  8455. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8456. m.bot_type = &u
  8457. m.addbot_type = nil
  8458. }
  8459. // BotType returns the value of the "bot_type" field in the mutation.
  8460. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8461. v := m.bot_type
  8462. if v == nil {
  8463. return
  8464. }
  8465. return *v, true
  8466. }
  8467. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8468. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8470. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8471. if !m.op.Is(OpUpdateOne) {
  8472. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8473. }
  8474. if m.id == nil || m.oldValue == nil {
  8475. return v, errors.New("OldBotType requires an ID field in the mutation")
  8476. }
  8477. oldValue, err := m.oldValue(ctx)
  8478. if err != nil {
  8479. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8480. }
  8481. return oldValue.BotType, nil
  8482. }
  8483. // AddBotType adds u to the "bot_type" field.
  8484. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8485. if m.addbot_type != nil {
  8486. *m.addbot_type += u
  8487. } else {
  8488. m.addbot_type = &u
  8489. }
  8490. }
  8491. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8492. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8493. v := m.addbot_type
  8494. if v == nil {
  8495. return
  8496. }
  8497. return *v, true
  8498. }
  8499. // ResetBotType resets all changes to the "bot_type" field.
  8500. func (m *ChatRecordsMutation) ResetBotType() {
  8501. m.bot_type = nil
  8502. m.addbot_type = nil
  8503. }
  8504. // Where appends a list predicates to the ChatRecordsMutation builder.
  8505. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8506. m.predicates = append(m.predicates, ps...)
  8507. }
  8508. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8509. // users can use type-assertion to append predicates that do not depend on any generated package.
  8510. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8511. p := make([]predicate.ChatRecords, len(ps))
  8512. for i := range ps {
  8513. p[i] = ps[i]
  8514. }
  8515. m.Where(p...)
  8516. }
  8517. // Op returns the operation name.
  8518. func (m *ChatRecordsMutation) Op() Op {
  8519. return m.op
  8520. }
  8521. // SetOp allows setting the mutation operation.
  8522. func (m *ChatRecordsMutation) SetOp(op Op) {
  8523. m.op = op
  8524. }
  8525. // Type returns the node type of this mutation (ChatRecords).
  8526. func (m *ChatRecordsMutation) Type() string {
  8527. return m.typ
  8528. }
  8529. // Fields returns all fields that were changed during this mutation. Note that in
  8530. // order to get all numeric fields that were incremented/decremented, call
  8531. // AddedFields().
  8532. func (m *ChatRecordsMutation) Fields() []string {
  8533. fields := make([]string, 0, 9)
  8534. if m.created_at != nil {
  8535. fields = append(fields, chatrecords.FieldCreatedAt)
  8536. }
  8537. if m.updated_at != nil {
  8538. fields = append(fields, chatrecords.FieldUpdatedAt)
  8539. }
  8540. if m.deleted_at != nil {
  8541. fields = append(fields, chatrecords.FieldDeletedAt)
  8542. }
  8543. if m.content != nil {
  8544. fields = append(fields, chatrecords.FieldContent)
  8545. }
  8546. if m.content_type != nil {
  8547. fields = append(fields, chatrecords.FieldContentType)
  8548. }
  8549. if m.session_id != nil {
  8550. fields = append(fields, chatrecords.FieldSessionID)
  8551. }
  8552. if m.user_id != nil {
  8553. fields = append(fields, chatrecords.FieldUserID)
  8554. }
  8555. if m.bot_id != nil {
  8556. fields = append(fields, chatrecords.FieldBotID)
  8557. }
  8558. if m.bot_type != nil {
  8559. fields = append(fields, chatrecords.FieldBotType)
  8560. }
  8561. return fields
  8562. }
  8563. // Field returns the value of a field with the given name. The second boolean
  8564. // return value indicates that this field was not set, or was not defined in the
  8565. // schema.
  8566. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8567. switch name {
  8568. case chatrecords.FieldCreatedAt:
  8569. return m.CreatedAt()
  8570. case chatrecords.FieldUpdatedAt:
  8571. return m.UpdatedAt()
  8572. case chatrecords.FieldDeletedAt:
  8573. return m.DeletedAt()
  8574. case chatrecords.FieldContent:
  8575. return m.Content()
  8576. case chatrecords.FieldContentType:
  8577. return m.ContentType()
  8578. case chatrecords.FieldSessionID:
  8579. return m.SessionID()
  8580. case chatrecords.FieldUserID:
  8581. return m.UserID()
  8582. case chatrecords.FieldBotID:
  8583. return m.BotID()
  8584. case chatrecords.FieldBotType:
  8585. return m.BotType()
  8586. }
  8587. return nil, false
  8588. }
  8589. // OldField returns the old value of the field from the database. An error is
  8590. // returned if the mutation operation is not UpdateOne, or the query to the
  8591. // database failed.
  8592. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8593. switch name {
  8594. case chatrecords.FieldCreatedAt:
  8595. return m.OldCreatedAt(ctx)
  8596. case chatrecords.FieldUpdatedAt:
  8597. return m.OldUpdatedAt(ctx)
  8598. case chatrecords.FieldDeletedAt:
  8599. return m.OldDeletedAt(ctx)
  8600. case chatrecords.FieldContent:
  8601. return m.OldContent(ctx)
  8602. case chatrecords.FieldContentType:
  8603. return m.OldContentType(ctx)
  8604. case chatrecords.FieldSessionID:
  8605. return m.OldSessionID(ctx)
  8606. case chatrecords.FieldUserID:
  8607. return m.OldUserID(ctx)
  8608. case chatrecords.FieldBotID:
  8609. return m.OldBotID(ctx)
  8610. case chatrecords.FieldBotType:
  8611. return m.OldBotType(ctx)
  8612. }
  8613. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8614. }
  8615. // SetField sets the value of a field with the given name. It returns an error if
  8616. // the field is not defined in the schema, or if the type mismatched the field
  8617. // type.
  8618. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8619. switch name {
  8620. case chatrecords.FieldCreatedAt:
  8621. v, ok := value.(time.Time)
  8622. if !ok {
  8623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8624. }
  8625. m.SetCreatedAt(v)
  8626. return nil
  8627. case chatrecords.FieldUpdatedAt:
  8628. v, ok := value.(time.Time)
  8629. if !ok {
  8630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8631. }
  8632. m.SetUpdatedAt(v)
  8633. return nil
  8634. case chatrecords.FieldDeletedAt:
  8635. v, ok := value.(time.Time)
  8636. if !ok {
  8637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8638. }
  8639. m.SetDeletedAt(v)
  8640. return nil
  8641. case chatrecords.FieldContent:
  8642. v, ok := value.(string)
  8643. if !ok {
  8644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8645. }
  8646. m.SetContent(v)
  8647. return nil
  8648. case chatrecords.FieldContentType:
  8649. v, ok := value.(uint8)
  8650. if !ok {
  8651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8652. }
  8653. m.SetContentType(v)
  8654. return nil
  8655. case chatrecords.FieldSessionID:
  8656. v, ok := value.(uint64)
  8657. if !ok {
  8658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8659. }
  8660. m.SetSessionID(v)
  8661. return nil
  8662. case chatrecords.FieldUserID:
  8663. v, ok := value.(uint64)
  8664. if !ok {
  8665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8666. }
  8667. m.SetUserID(v)
  8668. return nil
  8669. case chatrecords.FieldBotID:
  8670. v, ok := value.(uint64)
  8671. if !ok {
  8672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8673. }
  8674. m.SetBotID(v)
  8675. return nil
  8676. case chatrecords.FieldBotType:
  8677. v, ok := value.(uint8)
  8678. if !ok {
  8679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8680. }
  8681. m.SetBotType(v)
  8682. return nil
  8683. }
  8684. return fmt.Errorf("unknown ChatRecords field %s", name)
  8685. }
  8686. // AddedFields returns all numeric fields that were incremented/decremented during
  8687. // this mutation.
  8688. func (m *ChatRecordsMutation) AddedFields() []string {
  8689. var fields []string
  8690. if m.addcontent_type != nil {
  8691. fields = append(fields, chatrecords.FieldContentType)
  8692. }
  8693. if m.addsession_id != nil {
  8694. fields = append(fields, chatrecords.FieldSessionID)
  8695. }
  8696. if m.adduser_id != nil {
  8697. fields = append(fields, chatrecords.FieldUserID)
  8698. }
  8699. if m.addbot_id != nil {
  8700. fields = append(fields, chatrecords.FieldBotID)
  8701. }
  8702. if m.addbot_type != nil {
  8703. fields = append(fields, chatrecords.FieldBotType)
  8704. }
  8705. return fields
  8706. }
  8707. // AddedField returns the numeric value that was incremented/decremented on a field
  8708. // with the given name. The second boolean return value indicates that this field
  8709. // was not set, or was not defined in the schema.
  8710. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8711. switch name {
  8712. case chatrecords.FieldContentType:
  8713. return m.AddedContentType()
  8714. case chatrecords.FieldSessionID:
  8715. return m.AddedSessionID()
  8716. case chatrecords.FieldUserID:
  8717. return m.AddedUserID()
  8718. case chatrecords.FieldBotID:
  8719. return m.AddedBotID()
  8720. case chatrecords.FieldBotType:
  8721. return m.AddedBotType()
  8722. }
  8723. return nil, false
  8724. }
  8725. // AddField adds the value to the field with the given name. It returns an error if
  8726. // the field is not defined in the schema, or if the type mismatched the field
  8727. // type.
  8728. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8729. switch name {
  8730. case chatrecords.FieldContentType:
  8731. v, ok := value.(int8)
  8732. if !ok {
  8733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8734. }
  8735. m.AddContentType(v)
  8736. return nil
  8737. case chatrecords.FieldSessionID:
  8738. v, ok := value.(int64)
  8739. if !ok {
  8740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8741. }
  8742. m.AddSessionID(v)
  8743. return nil
  8744. case chatrecords.FieldUserID:
  8745. v, ok := value.(int64)
  8746. if !ok {
  8747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8748. }
  8749. m.AddUserID(v)
  8750. return nil
  8751. case chatrecords.FieldBotID:
  8752. v, ok := value.(int64)
  8753. if !ok {
  8754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8755. }
  8756. m.AddBotID(v)
  8757. return nil
  8758. case chatrecords.FieldBotType:
  8759. v, ok := value.(int8)
  8760. if !ok {
  8761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8762. }
  8763. m.AddBotType(v)
  8764. return nil
  8765. }
  8766. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8767. }
  8768. // ClearedFields returns all nullable fields that were cleared during this
  8769. // mutation.
  8770. func (m *ChatRecordsMutation) ClearedFields() []string {
  8771. var fields []string
  8772. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8773. fields = append(fields, chatrecords.FieldDeletedAt)
  8774. }
  8775. return fields
  8776. }
  8777. // FieldCleared returns a boolean indicating if a field with the given name was
  8778. // cleared in this mutation.
  8779. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8780. _, ok := m.clearedFields[name]
  8781. return ok
  8782. }
  8783. // ClearField clears the value of the field with the given name. It returns an
  8784. // error if the field is not defined in the schema.
  8785. func (m *ChatRecordsMutation) ClearField(name string) error {
  8786. switch name {
  8787. case chatrecords.FieldDeletedAt:
  8788. m.ClearDeletedAt()
  8789. return nil
  8790. }
  8791. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8792. }
  8793. // ResetField resets all changes in the mutation for the field with the given name.
  8794. // It returns an error if the field is not defined in the schema.
  8795. func (m *ChatRecordsMutation) ResetField(name string) error {
  8796. switch name {
  8797. case chatrecords.FieldCreatedAt:
  8798. m.ResetCreatedAt()
  8799. return nil
  8800. case chatrecords.FieldUpdatedAt:
  8801. m.ResetUpdatedAt()
  8802. return nil
  8803. case chatrecords.FieldDeletedAt:
  8804. m.ResetDeletedAt()
  8805. return nil
  8806. case chatrecords.FieldContent:
  8807. m.ResetContent()
  8808. return nil
  8809. case chatrecords.FieldContentType:
  8810. m.ResetContentType()
  8811. return nil
  8812. case chatrecords.FieldSessionID:
  8813. m.ResetSessionID()
  8814. return nil
  8815. case chatrecords.FieldUserID:
  8816. m.ResetUserID()
  8817. return nil
  8818. case chatrecords.FieldBotID:
  8819. m.ResetBotID()
  8820. return nil
  8821. case chatrecords.FieldBotType:
  8822. m.ResetBotType()
  8823. return nil
  8824. }
  8825. return fmt.Errorf("unknown ChatRecords field %s", name)
  8826. }
  8827. // AddedEdges returns all edge names that were set/added in this mutation.
  8828. func (m *ChatRecordsMutation) AddedEdges() []string {
  8829. edges := make([]string, 0, 0)
  8830. return edges
  8831. }
  8832. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8833. // name in this mutation.
  8834. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8835. return nil
  8836. }
  8837. // RemovedEdges returns all edge names that were removed in this mutation.
  8838. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8839. edges := make([]string, 0, 0)
  8840. return edges
  8841. }
  8842. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8843. // the given name in this mutation.
  8844. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8845. return nil
  8846. }
  8847. // ClearedEdges returns all edge names that were cleared in this mutation.
  8848. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8849. edges := make([]string, 0, 0)
  8850. return edges
  8851. }
  8852. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8853. // was cleared in this mutation.
  8854. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8855. return false
  8856. }
  8857. // ClearEdge clears the value of the edge with the given name. It returns an error
  8858. // if that edge is not defined in the schema.
  8859. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8860. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8861. }
  8862. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8863. // It returns an error if the edge is not defined in the schema.
  8864. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8865. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8866. }
  8867. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8868. type ChatSessionMutation struct {
  8869. config
  8870. op Op
  8871. typ string
  8872. id *uint64
  8873. created_at *time.Time
  8874. updated_at *time.Time
  8875. deleted_at *time.Time
  8876. name *string
  8877. user_id *uint64
  8878. adduser_id *int64
  8879. bot_id *uint64
  8880. addbot_id *int64
  8881. bot_type *uint8
  8882. addbot_type *int8
  8883. clearedFields map[string]struct{}
  8884. done bool
  8885. oldValue func(context.Context) (*ChatSession, error)
  8886. predicates []predicate.ChatSession
  8887. }
  8888. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8889. // chatsessionOption allows management of the mutation configuration using functional options.
  8890. type chatsessionOption func(*ChatSessionMutation)
  8891. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8892. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8893. m := &ChatSessionMutation{
  8894. config: c,
  8895. op: op,
  8896. typ: TypeChatSession,
  8897. clearedFields: make(map[string]struct{}),
  8898. }
  8899. for _, opt := range opts {
  8900. opt(m)
  8901. }
  8902. return m
  8903. }
  8904. // withChatSessionID sets the ID field of the mutation.
  8905. func withChatSessionID(id uint64) chatsessionOption {
  8906. return func(m *ChatSessionMutation) {
  8907. var (
  8908. err error
  8909. once sync.Once
  8910. value *ChatSession
  8911. )
  8912. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8913. once.Do(func() {
  8914. if m.done {
  8915. err = errors.New("querying old values post mutation is not allowed")
  8916. } else {
  8917. value, err = m.Client().ChatSession.Get(ctx, id)
  8918. }
  8919. })
  8920. return value, err
  8921. }
  8922. m.id = &id
  8923. }
  8924. }
  8925. // withChatSession sets the old ChatSession of the mutation.
  8926. func withChatSession(node *ChatSession) chatsessionOption {
  8927. return func(m *ChatSessionMutation) {
  8928. m.oldValue = func(context.Context) (*ChatSession, error) {
  8929. return node, nil
  8930. }
  8931. m.id = &node.ID
  8932. }
  8933. }
  8934. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8935. // executed in a transaction (ent.Tx), a transactional client is returned.
  8936. func (m ChatSessionMutation) Client() *Client {
  8937. client := &Client{config: m.config}
  8938. client.init()
  8939. return client
  8940. }
  8941. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8942. // it returns an error otherwise.
  8943. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8944. if _, ok := m.driver.(*txDriver); !ok {
  8945. return nil, errors.New("ent: mutation is not running in a transaction")
  8946. }
  8947. tx := &Tx{config: m.config}
  8948. tx.init()
  8949. return tx, nil
  8950. }
  8951. // SetID sets the value of the id field. Note that this
  8952. // operation is only accepted on creation of ChatSession entities.
  8953. func (m *ChatSessionMutation) SetID(id uint64) {
  8954. m.id = &id
  8955. }
  8956. // ID returns the ID value in the mutation. Note that the ID is only available
  8957. // if it was provided to the builder or after it was returned from the database.
  8958. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8959. if m.id == nil {
  8960. return
  8961. }
  8962. return *m.id, true
  8963. }
  8964. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8965. // That means, if the mutation is applied within a transaction with an isolation level such
  8966. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8967. // or updated by the mutation.
  8968. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8969. switch {
  8970. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8971. id, exists := m.ID()
  8972. if exists {
  8973. return []uint64{id}, nil
  8974. }
  8975. fallthrough
  8976. case m.op.Is(OpUpdate | OpDelete):
  8977. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8978. default:
  8979. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8980. }
  8981. }
  8982. // SetCreatedAt sets the "created_at" field.
  8983. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8984. m.created_at = &t
  8985. }
  8986. // CreatedAt returns the value of the "created_at" field in the mutation.
  8987. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8988. v := m.created_at
  8989. if v == nil {
  8990. return
  8991. }
  8992. return *v, true
  8993. }
  8994. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8995. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8997. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8998. if !m.op.Is(OpUpdateOne) {
  8999. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9000. }
  9001. if m.id == nil || m.oldValue == nil {
  9002. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9003. }
  9004. oldValue, err := m.oldValue(ctx)
  9005. if err != nil {
  9006. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9007. }
  9008. return oldValue.CreatedAt, nil
  9009. }
  9010. // ResetCreatedAt resets all changes to the "created_at" field.
  9011. func (m *ChatSessionMutation) ResetCreatedAt() {
  9012. m.created_at = nil
  9013. }
  9014. // SetUpdatedAt sets the "updated_at" field.
  9015. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  9016. m.updated_at = &t
  9017. }
  9018. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9019. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  9020. v := m.updated_at
  9021. if v == nil {
  9022. return
  9023. }
  9024. return *v, true
  9025. }
  9026. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  9027. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9029. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9030. if !m.op.Is(OpUpdateOne) {
  9031. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9032. }
  9033. if m.id == nil || m.oldValue == nil {
  9034. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9035. }
  9036. oldValue, err := m.oldValue(ctx)
  9037. if err != nil {
  9038. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9039. }
  9040. return oldValue.UpdatedAt, nil
  9041. }
  9042. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9043. func (m *ChatSessionMutation) ResetUpdatedAt() {
  9044. m.updated_at = nil
  9045. }
  9046. // SetDeletedAt sets the "deleted_at" field.
  9047. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  9048. m.deleted_at = &t
  9049. }
  9050. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9051. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  9052. v := m.deleted_at
  9053. if v == nil {
  9054. return
  9055. }
  9056. return *v, true
  9057. }
  9058. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  9059. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9061. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9062. if !m.op.Is(OpUpdateOne) {
  9063. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9064. }
  9065. if m.id == nil || m.oldValue == nil {
  9066. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9067. }
  9068. oldValue, err := m.oldValue(ctx)
  9069. if err != nil {
  9070. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9071. }
  9072. return oldValue.DeletedAt, nil
  9073. }
  9074. // ClearDeletedAt clears the value of the "deleted_at" field.
  9075. func (m *ChatSessionMutation) ClearDeletedAt() {
  9076. m.deleted_at = nil
  9077. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  9078. }
  9079. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9080. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  9081. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  9082. return ok
  9083. }
  9084. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9085. func (m *ChatSessionMutation) ResetDeletedAt() {
  9086. m.deleted_at = nil
  9087. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9088. }
  9089. // SetName sets the "name" field.
  9090. func (m *ChatSessionMutation) SetName(s string) {
  9091. m.name = &s
  9092. }
  9093. // Name returns the value of the "name" field in the mutation.
  9094. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9095. v := m.name
  9096. if v == nil {
  9097. return
  9098. }
  9099. return *v, true
  9100. }
  9101. // OldName returns the old "name" field's value of the ChatSession entity.
  9102. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9104. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9105. if !m.op.Is(OpUpdateOne) {
  9106. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9107. }
  9108. if m.id == nil || m.oldValue == nil {
  9109. return v, errors.New("OldName requires an ID field in the mutation")
  9110. }
  9111. oldValue, err := m.oldValue(ctx)
  9112. if err != nil {
  9113. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9114. }
  9115. return oldValue.Name, nil
  9116. }
  9117. // ResetName resets all changes to the "name" field.
  9118. func (m *ChatSessionMutation) ResetName() {
  9119. m.name = nil
  9120. }
  9121. // SetUserID sets the "user_id" field.
  9122. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9123. m.user_id = &u
  9124. m.adduser_id = nil
  9125. }
  9126. // UserID returns the value of the "user_id" field in the mutation.
  9127. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9128. v := m.user_id
  9129. if v == nil {
  9130. return
  9131. }
  9132. return *v, true
  9133. }
  9134. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9135. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9137. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9138. if !m.op.Is(OpUpdateOne) {
  9139. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9140. }
  9141. if m.id == nil || m.oldValue == nil {
  9142. return v, errors.New("OldUserID requires an ID field in the mutation")
  9143. }
  9144. oldValue, err := m.oldValue(ctx)
  9145. if err != nil {
  9146. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9147. }
  9148. return oldValue.UserID, nil
  9149. }
  9150. // AddUserID adds u to the "user_id" field.
  9151. func (m *ChatSessionMutation) AddUserID(u int64) {
  9152. if m.adduser_id != nil {
  9153. *m.adduser_id += u
  9154. } else {
  9155. m.adduser_id = &u
  9156. }
  9157. }
  9158. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9159. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9160. v := m.adduser_id
  9161. if v == nil {
  9162. return
  9163. }
  9164. return *v, true
  9165. }
  9166. // ResetUserID resets all changes to the "user_id" field.
  9167. func (m *ChatSessionMutation) ResetUserID() {
  9168. m.user_id = nil
  9169. m.adduser_id = nil
  9170. }
  9171. // SetBotID sets the "bot_id" field.
  9172. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9173. m.bot_id = &u
  9174. m.addbot_id = nil
  9175. }
  9176. // BotID returns the value of the "bot_id" field in the mutation.
  9177. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9178. v := m.bot_id
  9179. if v == nil {
  9180. return
  9181. }
  9182. return *v, true
  9183. }
  9184. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9185. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9187. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9188. if !m.op.Is(OpUpdateOne) {
  9189. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9190. }
  9191. if m.id == nil || m.oldValue == nil {
  9192. return v, errors.New("OldBotID requires an ID field in the mutation")
  9193. }
  9194. oldValue, err := m.oldValue(ctx)
  9195. if err != nil {
  9196. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9197. }
  9198. return oldValue.BotID, nil
  9199. }
  9200. // AddBotID adds u to the "bot_id" field.
  9201. func (m *ChatSessionMutation) AddBotID(u int64) {
  9202. if m.addbot_id != nil {
  9203. *m.addbot_id += u
  9204. } else {
  9205. m.addbot_id = &u
  9206. }
  9207. }
  9208. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9209. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9210. v := m.addbot_id
  9211. if v == nil {
  9212. return
  9213. }
  9214. return *v, true
  9215. }
  9216. // ResetBotID resets all changes to the "bot_id" field.
  9217. func (m *ChatSessionMutation) ResetBotID() {
  9218. m.bot_id = nil
  9219. m.addbot_id = nil
  9220. }
  9221. // SetBotType sets the "bot_type" field.
  9222. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9223. m.bot_type = &u
  9224. m.addbot_type = nil
  9225. }
  9226. // BotType returns the value of the "bot_type" field in the mutation.
  9227. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9228. v := m.bot_type
  9229. if v == nil {
  9230. return
  9231. }
  9232. return *v, true
  9233. }
  9234. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9235. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9237. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9238. if !m.op.Is(OpUpdateOne) {
  9239. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9240. }
  9241. if m.id == nil || m.oldValue == nil {
  9242. return v, errors.New("OldBotType requires an ID field in the mutation")
  9243. }
  9244. oldValue, err := m.oldValue(ctx)
  9245. if err != nil {
  9246. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9247. }
  9248. return oldValue.BotType, nil
  9249. }
  9250. // AddBotType adds u to the "bot_type" field.
  9251. func (m *ChatSessionMutation) AddBotType(u int8) {
  9252. if m.addbot_type != nil {
  9253. *m.addbot_type += u
  9254. } else {
  9255. m.addbot_type = &u
  9256. }
  9257. }
  9258. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9259. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9260. v := m.addbot_type
  9261. if v == nil {
  9262. return
  9263. }
  9264. return *v, true
  9265. }
  9266. // ResetBotType resets all changes to the "bot_type" field.
  9267. func (m *ChatSessionMutation) ResetBotType() {
  9268. m.bot_type = nil
  9269. m.addbot_type = nil
  9270. }
  9271. // Where appends a list predicates to the ChatSessionMutation builder.
  9272. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9273. m.predicates = append(m.predicates, ps...)
  9274. }
  9275. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9276. // users can use type-assertion to append predicates that do not depend on any generated package.
  9277. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9278. p := make([]predicate.ChatSession, len(ps))
  9279. for i := range ps {
  9280. p[i] = ps[i]
  9281. }
  9282. m.Where(p...)
  9283. }
  9284. // Op returns the operation name.
  9285. func (m *ChatSessionMutation) Op() Op {
  9286. return m.op
  9287. }
  9288. // SetOp allows setting the mutation operation.
  9289. func (m *ChatSessionMutation) SetOp(op Op) {
  9290. m.op = op
  9291. }
  9292. // Type returns the node type of this mutation (ChatSession).
  9293. func (m *ChatSessionMutation) Type() string {
  9294. return m.typ
  9295. }
  9296. // Fields returns all fields that were changed during this mutation. Note that in
  9297. // order to get all numeric fields that were incremented/decremented, call
  9298. // AddedFields().
  9299. func (m *ChatSessionMutation) Fields() []string {
  9300. fields := make([]string, 0, 7)
  9301. if m.created_at != nil {
  9302. fields = append(fields, chatsession.FieldCreatedAt)
  9303. }
  9304. if m.updated_at != nil {
  9305. fields = append(fields, chatsession.FieldUpdatedAt)
  9306. }
  9307. if m.deleted_at != nil {
  9308. fields = append(fields, chatsession.FieldDeletedAt)
  9309. }
  9310. if m.name != nil {
  9311. fields = append(fields, chatsession.FieldName)
  9312. }
  9313. if m.user_id != nil {
  9314. fields = append(fields, chatsession.FieldUserID)
  9315. }
  9316. if m.bot_id != nil {
  9317. fields = append(fields, chatsession.FieldBotID)
  9318. }
  9319. if m.bot_type != nil {
  9320. fields = append(fields, chatsession.FieldBotType)
  9321. }
  9322. return fields
  9323. }
  9324. // Field returns the value of a field with the given name. The second boolean
  9325. // return value indicates that this field was not set, or was not defined in the
  9326. // schema.
  9327. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9328. switch name {
  9329. case chatsession.FieldCreatedAt:
  9330. return m.CreatedAt()
  9331. case chatsession.FieldUpdatedAt:
  9332. return m.UpdatedAt()
  9333. case chatsession.FieldDeletedAt:
  9334. return m.DeletedAt()
  9335. case chatsession.FieldName:
  9336. return m.Name()
  9337. case chatsession.FieldUserID:
  9338. return m.UserID()
  9339. case chatsession.FieldBotID:
  9340. return m.BotID()
  9341. case chatsession.FieldBotType:
  9342. return m.BotType()
  9343. }
  9344. return nil, false
  9345. }
  9346. // OldField returns the old value of the field from the database. An error is
  9347. // returned if the mutation operation is not UpdateOne, or the query to the
  9348. // database failed.
  9349. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9350. switch name {
  9351. case chatsession.FieldCreatedAt:
  9352. return m.OldCreatedAt(ctx)
  9353. case chatsession.FieldUpdatedAt:
  9354. return m.OldUpdatedAt(ctx)
  9355. case chatsession.FieldDeletedAt:
  9356. return m.OldDeletedAt(ctx)
  9357. case chatsession.FieldName:
  9358. return m.OldName(ctx)
  9359. case chatsession.FieldUserID:
  9360. return m.OldUserID(ctx)
  9361. case chatsession.FieldBotID:
  9362. return m.OldBotID(ctx)
  9363. case chatsession.FieldBotType:
  9364. return m.OldBotType(ctx)
  9365. }
  9366. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9367. }
  9368. // SetField sets the value of a field with the given name. It returns an error if
  9369. // the field is not defined in the schema, or if the type mismatched the field
  9370. // type.
  9371. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9372. switch name {
  9373. case chatsession.FieldCreatedAt:
  9374. v, ok := value.(time.Time)
  9375. if !ok {
  9376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9377. }
  9378. m.SetCreatedAt(v)
  9379. return nil
  9380. case chatsession.FieldUpdatedAt:
  9381. v, ok := value.(time.Time)
  9382. if !ok {
  9383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9384. }
  9385. m.SetUpdatedAt(v)
  9386. return nil
  9387. case chatsession.FieldDeletedAt:
  9388. v, ok := value.(time.Time)
  9389. if !ok {
  9390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9391. }
  9392. m.SetDeletedAt(v)
  9393. return nil
  9394. case chatsession.FieldName:
  9395. v, ok := value.(string)
  9396. if !ok {
  9397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9398. }
  9399. m.SetName(v)
  9400. return nil
  9401. case chatsession.FieldUserID:
  9402. v, ok := value.(uint64)
  9403. if !ok {
  9404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9405. }
  9406. m.SetUserID(v)
  9407. return nil
  9408. case chatsession.FieldBotID:
  9409. v, ok := value.(uint64)
  9410. if !ok {
  9411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9412. }
  9413. m.SetBotID(v)
  9414. return nil
  9415. case chatsession.FieldBotType:
  9416. v, ok := value.(uint8)
  9417. if !ok {
  9418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9419. }
  9420. m.SetBotType(v)
  9421. return nil
  9422. }
  9423. return fmt.Errorf("unknown ChatSession field %s", name)
  9424. }
  9425. // AddedFields returns all numeric fields that were incremented/decremented during
  9426. // this mutation.
  9427. func (m *ChatSessionMutation) AddedFields() []string {
  9428. var fields []string
  9429. if m.adduser_id != nil {
  9430. fields = append(fields, chatsession.FieldUserID)
  9431. }
  9432. if m.addbot_id != nil {
  9433. fields = append(fields, chatsession.FieldBotID)
  9434. }
  9435. if m.addbot_type != nil {
  9436. fields = append(fields, chatsession.FieldBotType)
  9437. }
  9438. return fields
  9439. }
  9440. // AddedField returns the numeric value that was incremented/decremented on a field
  9441. // with the given name. The second boolean return value indicates that this field
  9442. // was not set, or was not defined in the schema.
  9443. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9444. switch name {
  9445. case chatsession.FieldUserID:
  9446. return m.AddedUserID()
  9447. case chatsession.FieldBotID:
  9448. return m.AddedBotID()
  9449. case chatsession.FieldBotType:
  9450. return m.AddedBotType()
  9451. }
  9452. return nil, false
  9453. }
  9454. // AddField adds the value to the field with the given name. It returns an error if
  9455. // the field is not defined in the schema, or if the type mismatched the field
  9456. // type.
  9457. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9458. switch name {
  9459. case chatsession.FieldUserID:
  9460. v, ok := value.(int64)
  9461. if !ok {
  9462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9463. }
  9464. m.AddUserID(v)
  9465. return nil
  9466. case chatsession.FieldBotID:
  9467. v, ok := value.(int64)
  9468. if !ok {
  9469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9470. }
  9471. m.AddBotID(v)
  9472. return nil
  9473. case chatsession.FieldBotType:
  9474. v, ok := value.(int8)
  9475. if !ok {
  9476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9477. }
  9478. m.AddBotType(v)
  9479. return nil
  9480. }
  9481. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9482. }
  9483. // ClearedFields returns all nullable fields that were cleared during this
  9484. // mutation.
  9485. func (m *ChatSessionMutation) ClearedFields() []string {
  9486. var fields []string
  9487. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9488. fields = append(fields, chatsession.FieldDeletedAt)
  9489. }
  9490. return fields
  9491. }
  9492. // FieldCleared returns a boolean indicating if a field with the given name was
  9493. // cleared in this mutation.
  9494. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9495. _, ok := m.clearedFields[name]
  9496. return ok
  9497. }
  9498. // ClearField clears the value of the field with the given name. It returns an
  9499. // error if the field is not defined in the schema.
  9500. func (m *ChatSessionMutation) ClearField(name string) error {
  9501. switch name {
  9502. case chatsession.FieldDeletedAt:
  9503. m.ClearDeletedAt()
  9504. return nil
  9505. }
  9506. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9507. }
  9508. // ResetField resets all changes in the mutation for the field with the given name.
  9509. // It returns an error if the field is not defined in the schema.
  9510. func (m *ChatSessionMutation) ResetField(name string) error {
  9511. switch name {
  9512. case chatsession.FieldCreatedAt:
  9513. m.ResetCreatedAt()
  9514. return nil
  9515. case chatsession.FieldUpdatedAt:
  9516. m.ResetUpdatedAt()
  9517. return nil
  9518. case chatsession.FieldDeletedAt:
  9519. m.ResetDeletedAt()
  9520. return nil
  9521. case chatsession.FieldName:
  9522. m.ResetName()
  9523. return nil
  9524. case chatsession.FieldUserID:
  9525. m.ResetUserID()
  9526. return nil
  9527. case chatsession.FieldBotID:
  9528. m.ResetBotID()
  9529. return nil
  9530. case chatsession.FieldBotType:
  9531. m.ResetBotType()
  9532. return nil
  9533. }
  9534. return fmt.Errorf("unknown ChatSession field %s", name)
  9535. }
  9536. // AddedEdges returns all edge names that were set/added in this mutation.
  9537. func (m *ChatSessionMutation) AddedEdges() []string {
  9538. edges := make([]string, 0, 0)
  9539. return edges
  9540. }
  9541. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9542. // name in this mutation.
  9543. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9544. return nil
  9545. }
  9546. // RemovedEdges returns all edge names that were removed in this mutation.
  9547. func (m *ChatSessionMutation) RemovedEdges() []string {
  9548. edges := make([]string, 0, 0)
  9549. return edges
  9550. }
  9551. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9552. // the given name in this mutation.
  9553. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9554. return nil
  9555. }
  9556. // ClearedEdges returns all edge names that were cleared in this mutation.
  9557. func (m *ChatSessionMutation) ClearedEdges() []string {
  9558. edges := make([]string, 0, 0)
  9559. return edges
  9560. }
  9561. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9562. // was cleared in this mutation.
  9563. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9564. return false
  9565. }
  9566. // ClearEdge clears the value of the edge with the given name. It returns an error
  9567. // if that edge is not defined in the schema.
  9568. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9569. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9570. }
  9571. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9572. // It returns an error if the edge is not defined in the schema.
  9573. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9574. return fmt.Errorf("unknown ChatSession edge %s", name)
  9575. }
  9576. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  9577. type CompapiAsynctaskMutation struct {
  9578. config
  9579. op Op
  9580. typ string
  9581. id *uint64
  9582. created_at *time.Time
  9583. updated_at *time.Time
  9584. auth_token *string
  9585. event_type *string
  9586. chat_id *string
  9587. response_chat_item_id *string
  9588. organization_id *uint64
  9589. addorganization_id *int64
  9590. openai_base *string
  9591. openai_key *string
  9592. request_raw *string
  9593. response_raw *string
  9594. callback_url *string
  9595. callback_response_raw *string
  9596. model *string
  9597. task_status *int8
  9598. addtask_status *int8
  9599. retry_count *int8
  9600. addretry_count *int8
  9601. last_error *string
  9602. clearedFields map[string]struct{}
  9603. done bool
  9604. oldValue func(context.Context) (*CompapiAsynctask, error)
  9605. predicates []predicate.CompapiAsynctask
  9606. }
  9607. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  9608. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  9609. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  9610. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  9611. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  9612. m := &CompapiAsynctaskMutation{
  9613. config: c,
  9614. op: op,
  9615. typ: TypeCompapiAsynctask,
  9616. clearedFields: make(map[string]struct{}),
  9617. }
  9618. for _, opt := range opts {
  9619. opt(m)
  9620. }
  9621. return m
  9622. }
  9623. // withCompapiAsynctaskID sets the ID field of the mutation.
  9624. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  9625. return func(m *CompapiAsynctaskMutation) {
  9626. var (
  9627. err error
  9628. once sync.Once
  9629. value *CompapiAsynctask
  9630. )
  9631. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  9632. once.Do(func() {
  9633. if m.done {
  9634. err = errors.New("querying old values post mutation is not allowed")
  9635. } else {
  9636. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  9637. }
  9638. })
  9639. return value, err
  9640. }
  9641. m.id = &id
  9642. }
  9643. }
  9644. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  9645. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  9646. return func(m *CompapiAsynctaskMutation) {
  9647. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  9648. return node, nil
  9649. }
  9650. m.id = &node.ID
  9651. }
  9652. }
  9653. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9654. // executed in a transaction (ent.Tx), a transactional client is returned.
  9655. func (m CompapiAsynctaskMutation) Client() *Client {
  9656. client := &Client{config: m.config}
  9657. client.init()
  9658. return client
  9659. }
  9660. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9661. // it returns an error otherwise.
  9662. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  9663. if _, ok := m.driver.(*txDriver); !ok {
  9664. return nil, errors.New("ent: mutation is not running in a transaction")
  9665. }
  9666. tx := &Tx{config: m.config}
  9667. tx.init()
  9668. return tx, nil
  9669. }
  9670. // SetID sets the value of the id field. Note that this
  9671. // operation is only accepted on creation of CompapiAsynctask entities.
  9672. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  9673. m.id = &id
  9674. }
  9675. // ID returns the ID value in the mutation. Note that the ID is only available
  9676. // if it was provided to the builder or after it was returned from the database.
  9677. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  9678. if m.id == nil {
  9679. return
  9680. }
  9681. return *m.id, true
  9682. }
  9683. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9684. // That means, if the mutation is applied within a transaction with an isolation level such
  9685. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9686. // or updated by the mutation.
  9687. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9688. switch {
  9689. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9690. id, exists := m.ID()
  9691. if exists {
  9692. return []uint64{id}, nil
  9693. }
  9694. fallthrough
  9695. case m.op.Is(OpUpdate | OpDelete):
  9696. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  9697. default:
  9698. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9699. }
  9700. }
  9701. // SetCreatedAt sets the "created_at" field.
  9702. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  9703. m.created_at = &t
  9704. }
  9705. // CreatedAt returns the value of the "created_at" field in the mutation.
  9706. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  9707. v := m.created_at
  9708. if v == nil {
  9709. return
  9710. }
  9711. return *v, true
  9712. }
  9713. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  9714. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9716. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9717. if !m.op.Is(OpUpdateOne) {
  9718. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9719. }
  9720. if m.id == nil || m.oldValue == nil {
  9721. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9722. }
  9723. oldValue, err := m.oldValue(ctx)
  9724. if err != nil {
  9725. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9726. }
  9727. return oldValue.CreatedAt, nil
  9728. }
  9729. // ResetCreatedAt resets all changes to the "created_at" field.
  9730. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  9731. m.created_at = nil
  9732. }
  9733. // SetUpdatedAt sets the "updated_at" field.
  9734. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  9735. m.updated_at = &t
  9736. }
  9737. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9738. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9739. v := m.updated_at
  9740. if v == nil {
  9741. return
  9742. }
  9743. return *v, true
  9744. }
  9745. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  9746. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9748. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9749. if !m.op.Is(OpUpdateOne) {
  9750. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9751. }
  9752. if m.id == nil || m.oldValue == nil {
  9753. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9754. }
  9755. oldValue, err := m.oldValue(ctx)
  9756. if err != nil {
  9757. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9758. }
  9759. return oldValue.UpdatedAt, nil
  9760. }
  9761. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9762. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  9763. m.updated_at = nil
  9764. }
  9765. // SetAuthToken sets the "auth_token" field.
  9766. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  9767. m.auth_token = &s
  9768. }
  9769. // AuthToken returns the value of the "auth_token" field in the mutation.
  9770. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  9771. v := m.auth_token
  9772. if v == nil {
  9773. return
  9774. }
  9775. return *v, true
  9776. }
  9777. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  9778. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9780. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9781. if !m.op.Is(OpUpdateOne) {
  9782. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9783. }
  9784. if m.id == nil || m.oldValue == nil {
  9785. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9786. }
  9787. oldValue, err := m.oldValue(ctx)
  9788. if err != nil {
  9789. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9790. }
  9791. return oldValue.AuthToken, nil
  9792. }
  9793. // ResetAuthToken resets all changes to the "auth_token" field.
  9794. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  9795. m.auth_token = nil
  9796. }
  9797. // SetEventType sets the "event_type" field.
  9798. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  9799. m.event_type = &s
  9800. }
  9801. // EventType returns the value of the "event_type" field in the mutation.
  9802. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  9803. v := m.event_type
  9804. if v == nil {
  9805. return
  9806. }
  9807. return *v, true
  9808. }
  9809. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  9810. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9812. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  9813. if !m.op.Is(OpUpdateOne) {
  9814. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9815. }
  9816. if m.id == nil || m.oldValue == nil {
  9817. return v, errors.New("OldEventType requires an ID field in the mutation")
  9818. }
  9819. oldValue, err := m.oldValue(ctx)
  9820. if err != nil {
  9821. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9822. }
  9823. return oldValue.EventType, nil
  9824. }
  9825. // ResetEventType resets all changes to the "event_type" field.
  9826. func (m *CompapiAsynctaskMutation) ResetEventType() {
  9827. m.event_type = nil
  9828. }
  9829. // SetChatID sets the "chat_id" field.
  9830. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  9831. m.chat_id = &s
  9832. }
  9833. // ChatID returns the value of the "chat_id" field in the mutation.
  9834. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  9835. v := m.chat_id
  9836. if v == nil {
  9837. return
  9838. }
  9839. return *v, true
  9840. }
  9841. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  9842. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9844. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  9845. if !m.op.Is(OpUpdateOne) {
  9846. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9847. }
  9848. if m.id == nil || m.oldValue == nil {
  9849. return v, errors.New("OldChatID requires an ID field in the mutation")
  9850. }
  9851. oldValue, err := m.oldValue(ctx)
  9852. if err != nil {
  9853. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9854. }
  9855. return oldValue.ChatID, nil
  9856. }
  9857. // ClearChatID clears the value of the "chat_id" field.
  9858. func (m *CompapiAsynctaskMutation) ClearChatID() {
  9859. m.chat_id = nil
  9860. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  9861. }
  9862. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9863. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  9864. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  9865. return ok
  9866. }
  9867. // ResetChatID resets all changes to the "chat_id" field.
  9868. func (m *CompapiAsynctaskMutation) ResetChatID() {
  9869. m.chat_id = nil
  9870. delete(m.clearedFields, compapiasynctask.FieldChatID)
  9871. }
  9872. // SetResponseChatItemID sets the "response_chat_item_id" field.
  9873. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  9874. m.response_chat_item_id = &s
  9875. }
  9876. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  9877. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  9878. v := m.response_chat_item_id
  9879. if v == nil {
  9880. return
  9881. }
  9882. return *v, true
  9883. }
  9884. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  9885. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9887. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  9888. if !m.op.Is(OpUpdateOne) {
  9889. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  9890. }
  9891. if m.id == nil || m.oldValue == nil {
  9892. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  9893. }
  9894. oldValue, err := m.oldValue(ctx)
  9895. if err != nil {
  9896. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  9897. }
  9898. return oldValue.ResponseChatItemID, nil
  9899. }
  9900. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  9901. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  9902. m.response_chat_item_id = nil
  9903. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  9904. }
  9905. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  9906. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  9907. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  9908. return ok
  9909. }
  9910. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  9911. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  9912. m.response_chat_item_id = nil
  9913. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  9914. }
  9915. // SetOrganizationID sets the "organization_id" field.
  9916. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  9917. m.organization_id = &u
  9918. m.addorganization_id = nil
  9919. }
  9920. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9921. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  9922. v := m.organization_id
  9923. if v == nil {
  9924. return
  9925. }
  9926. return *v, true
  9927. }
  9928. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  9929. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9931. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9932. if !m.op.Is(OpUpdateOne) {
  9933. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9934. }
  9935. if m.id == nil || m.oldValue == nil {
  9936. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9937. }
  9938. oldValue, err := m.oldValue(ctx)
  9939. if err != nil {
  9940. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9941. }
  9942. return oldValue.OrganizationID, nil
  9943. }
  9944. // AddOrganizationID adds u to the "organization_id" field.
  9945. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  9946. if m.addorganization_id != nil {
  9947. *m.addorganization_id += u
  9948. } else {
  9949. m.addorganization_id = &u
  9950. }
  9951. }
  9952. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9953. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  9954. v := m.addorganization_id
  9955. if v == nil {
  9956. return
  9957. }
  9958. return *v, true
  9959. }
  9960. // ResetOrganizationID resets all changes to the "organization_id" field.
  9961. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  9962. m.organization_id = nil
  9963. m.addorganization_id = nil
  9964. }
  9965. // SetOpenaiBase sets the "openai_base" field.
  9966. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  9967. m.openai_base = &s
  9968. }
  9969. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  9970. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  9971. v := m.openai_base
  9972. if v == nil {
  9973. return
  9974. }
  9975. return *v, true
  9976. }
  9977. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  9978. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9980. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  9981. if !m.op.Is(OpUpdateOne) {
  9982. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  9983. }
  9984. if m.id == nil || m.oldValue == nil {
  9985. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  9986. }
  9987. oldValue, err := m.oldValue(ctx)
  9988. if err != nil {
  9989. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  9990. }
  9991. return oldValue.OpenaiBase, nil
  9992. }
  9993. // ResetOpenaiBase resets all changes to the "openai_base" field.
  9994. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  9995. m.openai_base = nil
  9996. }
  9997. // SetOpenaiKey sets the "openai_key" field.
  9998. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  9999. m.openai_key = &s
  10000. }
  10001. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  10002. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  10003. v := m.openai_key
  10004. if v == nil {
  10005. return
  10006. }
  10007. return *v, true
  10008. }
  10009. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  10010. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10012. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  10013. if !m.op.Is(OpUpdateOne) {
  10014. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  10015. }
  10016. if m.id == nil || m.oldValue == nil {
  10017. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  10018. }
  10019. oldValue, err := m.oldValue(ctx)
  10020. if err != nil {
  10021. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  10022. }
  10023. return oldValue.OpenaiKey, nil
  10024. }
  10025. // ResetOpenaiKey resets all changes to the "openai_key" field.
  10026. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  10027. m.openai_key = nil
  10028. }
  10029. // SetRequestRaw sets the "request_raw" field.
  10030. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  10031. m.request_raw = &s
  10032. }
  10033. // RequestRaw returns the value of the "request_raw" field in the mutation.
  10034. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  10035. v := m.request_raw
  10036. if v == nil {
  10037. return
  10038. }
  10039. return *v, true
  10040. }
  10041. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  10042. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10044. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  10045. if !m.op.Is(OpUpdateOne) {
  10046. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  10047. }
  10048. if m.id == nil || m.oldValue == nil {
  10049. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  10050. }
  10051. oldValue, err := m.oldValue(ctx)
  10052. if err != nil {
  10053. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  10054. }
  10055. return oldValue.RequestRaw, nil
  10056. }
  10057. // ResetRequestRaw resets all changes to the "request_raw" field.
  10058. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  10059. m.request_raw = nil
  10060. }
  10061. // SetResponseRaw sets the "response_raw" field.
  10062. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  10063. m.response_raw = &s
  10064. }
  10065. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  10066. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  10067. v := m.response_raw
  10068. if v == nil {
  10069. return
  10070. }
  10071. return *v, true
  10072. }
  10073. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  10074. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10076. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  10077. if !m.op.Is(OpUpdateOne) {
  10078. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  10079. }
  10080. if m.id == nil || m.oldValue == nil {
  10081. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  10082. }
  10083. oldValue, err := m.oldValue(ctx)
  10084. if err != nil {
  10085. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  10086. }
  10087. return oldValue.ResponseRaw, nil
  10088. }
  10089. // ClearResponseRaw clears the value of the "response_raw" field.
  10090. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  10091. m.response_raw = nil
  10092. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  10093. }
  10094. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  10095. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  10096. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  10097. return ok
  10098. }
  10099. // ResetResponseRaw resets all changes to the "response_raw" field.
  10100. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  10101. m.response_raw = nil
  10102. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  10103. }
  10104. // SetCallbackURL sets the "callback_url" field.
  10105. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  10106. m.callback_url = &s
  10107. }
  10108. // CallbackURL returns the value of the "callback_url" field in the mutation.
  10109. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  10110. v := m.callback_url
  10111. if v == nil {
  10112. return
  10113. }
  10114. return *v, true
  10115. }
  10116. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  10117. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10119. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  10120. if !m.op.Is(OpUpdateOne) {
  10121. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  10122. }
  10123. if m.id == nil || m.oldValue == nil {
  10124. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  10125. }
  10126. oldValue, err := m.oldValue(ctx)
  10127. if err != nil {
  10128. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  10129. }
  10130. return oldValue.CallbackURL, nil
  10131. }
  10132. // ResetCallbackURL resets all changes to the "callback_url" field.
  10133. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  10134. m.callback_url = nil
  10135. }
  10136. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  10137. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  10138. m.callback_response_raw = &s
  10139. }
  10140. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  10141. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  10142. v := m.callback_response_raw
  10143. if v == nil {
  10144. return
  10145. }
  10146. return *v, true
  10147. }
  10148. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  10149. // If the CompapiAsynctask 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 *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  10152. if !m.op.Is(OpUpdateOne) {
  10153. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  10154. }
  10155. if m.id == nil || m.oldValue == nil {
  10156. return v, errors.New("OldCallbackResponseRaw 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 OldCallbackResponseRaw: %w", err)
  10161. }
  10162. return oldValue.CallbackResponseRaw, nil
  10163. }
  10164. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  10165. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  10166. m.callback_response_raw = nil
  10167. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  10168. }
  10169. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  10170. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  10171. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  10172. return ok
  10173. }
  10174. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  10175. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  10176. m.callback_response_raw = nil
  10177. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  10178. }
  10179. // SetModel sets the "model" field.
  10180. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  10181. m.model = &s
  10182. }
  10183. // Model returns the value of the "model" field in the mutation.
  10184. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  10185. v := m.model
  10186. if v == nil {
  10187. return
  10188. }
  10189. return *v, true
  10190. }
  10191. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  10192. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10194. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  10195. if !m.op.Is(OpUpdateOne) {
  10196. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  10197. }
  10198. if m.id == nil || m.oldValue == nil {
  10199. return v, errors.New("OldModel requires an ID field in the mutation")
  10200. }
  10201. oldValue, err := m.oldValue(ctx)
  10202. if err != nil {
  10203. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  10204. }
  10205. return oldValue.Model, nil
  10206. }
  10207. // ClearModel clears the value of the "model" field.
  10208. func (m *CompapiAsynctaskMutation) ClearModel() {
  10209. m.model = nil
  10210. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  10211. }
  10212. // ModelCleared returns if the "model" field was cleared in this mutation.
  10213. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  10214. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  10215. return ok
  10216. }
  10217. // ResetModel resets all changes to the "model" field.
  10218. func (m *CompapiAsynctaskMutation) ResetModel() {
  10219. m.model = nil
  10220. delete(m.clearedFields, compapiasynctask.FieldModel)
  10221. }
  10222. // SetTaskStatus sets the "task_status" field.
  10223. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  10224. m.task_status = &i
  10225. m.addtask_status = nil
  10226. }
  10227. // TaskStatus returns the value of the "task_status" field in the mutation.
  10228. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  10229. v := m.task_status
  10230. if v == nil {
  10231. return
  10232. }
  10233. return *v, true
  10234. }
  10235. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  10236. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10238. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  10239. if !m.op.Is(OpUpdateOne) {
  10240. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  10241. }
  10242. if m.id == nil || m.oldValue == nil {
  10243. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  10244. }
  10245. oldValue, err := m.oldValue(ctx)
  10246. if err != nil {
  10247. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  10248. }
  10249. return oldValue.TaskStatus, nil
  10250. }
  10251. // AddTaskStatus adds i to the "task_status" field.
  10252. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  10253. if m.addtask_status != nil {
  10254. *m.addtask_status += i
  10255. } else {
  10256. m.addtask_status = &i
  10257. }
  10258. }
  10259. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  10260. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  10261. v := m.addtask_status
  10262. if v == nil {
  10263. return
  10264. }
  10265. return *v, true
  10266. }
  10267. // ClearTaskStatus clears the value of the "task_status" field.
  10268. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  10269. m.task_status = nil
  10270. m.addtask_status = nil
  10271. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  10272. }
  10273. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  10274. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  10275. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  10276. return ok
  10277. }
  10278. // ResetTaskStatus resets all changes to the "task_status" field.
  10279. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  10280. m.task_status = nil
  10281. m.addtask_status = nil
  10282. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  10283. }
  10284. // SetRetryCount sets the "retry_count" field.
  10285. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  10286. m.retry_count = &i
  10287. m.addretry_count = nil
  10288. }
  10289. // RetryCount returns the value of the "retry_count" field in the mutation.
  10290. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  10291. v := m.retry_count
  10292. if v == nil {
  10293. return
  10294. }
  10295. return *v, true
  10296. }
  10297. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  10298. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10300. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  10301. if !m.op.Is(OpUpdateOne) {
  10302. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  10303. }
  10304. if m.id == nil || m.oldValue == nil {
  10305. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  10306. }
  10307. oldValue, err := m.oldValue(ctx)
  10308. if err != nil {
  10309. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  10310. }
  10311. return oldValue.RetryCount, nil
  10312. }
  10313. // AddRetryCount adds i to the "retry_count" field.
  10314. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  10315. if m.addretry_count != nil {
  10316. *m.addretry_count += i
  10317. } else {
  10318. m.addretry_count = &i
  10319. }
  10320. }
  10321. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  10322. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  10323. v := m.addretry_count
  10324. if v == nil {
  10325. return
  10326. }
  10327. return *v, true
  10328. }
  10329. // ClearRetryCount clears the value of the "retry_count" field.
  10330. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  10331. m.retry_count = nil
  10332. m.addretry_count = nil
  10333. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  10334. }
  10335. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  10336. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  10337. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  10338. return ok
  10339. }
  10340. // ResetRetryCount resets all changes to the "retry_count" field.
  10341. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  10342. m.retry_count = nil
  10343. m.addretry_count = nil
  10344. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  10345. }
  10346. // SetLastError sets the "last_error" field.
  10347. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  10348. m.last_error = &s
  10349. }
  10350. // LastError returns the value of the "last_error" field in the mutation.
  10351. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  10352. v := m.last_error
  10353. if v == nil {
  10354. return
  10355. }
  10356. return *v, true
  10357. }
  10358. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  10359. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10361. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  10362. if !m.op.Is(OpUpdateOne) {
  10363. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  10364. }
  10365. if m.id == nil || m.oldValue == nil {
  10366. return v, errors.New("OldLastError requires an ID field in the mutation")
  10367. }
  10368. oldValue, err := m.oldValue(ctx)
  10369. if err != nil {
  10370. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  10371. }
  10372. return oldValue.LastError, nil
  10373. }
  10374. // ClearLastError clears the value of the "last_error" field.
  10375. func (m *CompapiAsynctaskMutation) ClearLastError() {
  10376. m.last_error = nil
  10377. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  10378. }
  10379. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  10380. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  10381. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  10382. return ok
  10383. }
  10384. // ResetLastError resets all changes to the "last_error" field.
  10385. func (m *CompapiAsynctaskMutation) ResetLastError() {
  10386. m.last_error = nil
  10387. delete(m.clearedFields, compapiasynctask.FieldLastError)
  10388. }
  10389. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  10390. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  10391. m.predicates = append(m.predicates, ps...)
  10392. }
  10393. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  10394. // users can use type-assertion to append predicates that do not depend on any generated package.
  10395. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  10396. p := make([]predicate.CompapiAsynctask, len(ps))
  10397. for i := range ps {
  10398. p[i] = ps[i]
  10399. }
  10400. m.Where(p...)
  10401. }
  10402. // Op returns the operation name.
  10403. func (m *CompapiAsynctaskMutation) Op() Op {
  10404. return m.op
  10405. }
  10406. // SetOp allows setting the mutation operation.
  10407. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  10408. m.op = op
  10409. }
  10410. // Type returns the node type of this mutation (CompapiAsynctask).
  10411. func (m *CompapiAsynctaskMutation) Type() string {
  10412. return m.typ
  10413. }
  10414. // Fields returns all fields that were changed during this mutation. Note that in
  10415. // order to get all numeric fields that were incremented/decremented, call
  10416. // AddedFields().
  10417. func (m *CompapiAsynctaskMutation) Fields() []string {
  10418. fields := make([]string, 0, 17)
  10419. if m.created_at != nil {
  10420. fields = append(fields, compapiasynctask.FieldCreatedAt)
  10421. }
  10422. if m.updated_at != nil {
  10423. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  10424. }
  10425. if m.auth_token != nil {
  10426. fields = append(fields, compapiasynctask.FieldAuthToken)
  10427. }
  10428. if m.event_type != nil {
  10429. fields = append(fields, compapiasynctask.FieldEventType)
  10430. }
  10431. if m.chat_id != nil {
  10432. fields = append(fields, compapiasynctask.FieldChatID)
  10433. }
  10434. if m.response_chat_item_id != nil {
  10435. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10436. }
  10437. if m.organization_id != nil {
  10438. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10439. }
  10440. if m.openai_base != nil {
  10441. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  10442. }
  10443. if m.openai_key != nil {
  10444. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  10445. }
  10446. if m.request_raw != nil {
  10447. fields = append(fields, compapiasynctask.FieldRequestRaw)
  10448. }
  10449. if m.response_raw != nil {
  10450. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10451. }
  10452. if m.callback_url != nil {
  10453. fields = append(fields, compapiasynctask.FieldCallbackURL)
  10454. }
  10455. if m.callback_response_raw != nil {
  10456. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10457. }
  10458. if m.model != nil {
  10459. fields = append(fields, compapiasynctask.FieldModel)
  10460. }
  10461. if m.task_status != nil {
  10462. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10463. }
  10464. if m.retry_count != nil {
  10465. fields = append(fields, compapiasynctask.FieldRetryCount)
  10466. }
  10467. if m.last_error != nil {
  10468. fields = append(fields, compapiasynctask.FieldLastError)
  10469. }
  10470. return fields
  10471. }
  10472. // Field returns the value of a field with the given name. The second boolean
  10473. // return value indicates that this field was not set, or was not defined in the
  10474. // schema.
  10475. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  10476. switch name {
  10477. case compapiasynctask.FieldCreatedAt:
  10478. return m.CreatedAt()
  10479. case compapiasynctask.FieldUpdatedAt:
  10480. return m.UpdatedAt()
  10481. case compapiasynctask.FieldAuthToken:
  10482. return m.AuthToken()
  10483. case compapiasynctask.FieldEventType:
  10484. return m.EventType()
  10485. case compapiasynctask.FieldChatID:
  10486. return m.ChatID()
  10487. case compapiasynctask.FieldResponseChatItemID:
  10488. return m.ResponseChatItemID()
  10489. case compapiasynctask.FieldOrganizationID:
  10490. return m.OrganizationID()
  10491. case compapiasynctask.FieldOpenaiBase:
  10492. return m.OpenaiBase()
  10493. case compapiasynctask.FieldOpenaiKey:
  10494. return m.OpenaiKey()
  10495. case compapiasynctask.FieldRequestRaw:
  10496. return m.RequestRaw()
  10497. case compapiasynctask.FieldResponseRaw:
  10498. return m.ResponseRaw()
  10499. case compapiasynctask.FieldCallbackURL:
  10500. return m.CallbackURL()
  10501. case compapiasynctask.FieldCallbackResponseRaw:
  10502. return m.CallbackResponseRaw()
  10503. case compapiasynctask.FieldModel:
  10504. return m.Model()
  10505. case compapiasynctask.FieldTaskStatus:
  10506. return m.TaskStatus()
  10507. case compapiasynctask.FieldRetryCount:
  10508. return m.RetryCount()
  10509. case compapiasynctask.FieldLastError:
  10510. return m.LastError()
  10511. }
  10512. return nil, false
  10513. }
  10514. // OldField returns the old value of the field from the database. An error is
  10515. // returned if the mutation operation is not UpdateOne, or the query to the
  10516. // database failed.
  10517. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10518. switch name {
  10519. case compapiasynctask.FieldCreatedAt:
  10520. return m.OldCreatedAt(ctx)
  10521. case compapiasynctask.FieldUpdatedAt:
  10522. return m.OldUpdatedAt(ctx)
  10523. case compapiasynctask.FieldAuthToken:
  10524. return m.OldAuthToken(ctx)
  10525. case compapiasynctask.FieldEventType:
  10526. return m.OldEventType(ctx)
  10527. case compapiasynctask.FieldChatID:
  10528. return m.OldChatID(ctx)
  10529. case compapiasynctask.FieldResponseChatItemID:
  10530. return m.OldResponseChatItemID(ctx)
  10531. case compapiasynctask.FieldOrganizationID:
  10532. return m.OldOrganizationID(ctx)
  10533. case compapiasynctask.FieldOpenaiBase:
  10534. return m.OldOpenaiBase(ctx)
  10535. case compapiasynctask.FieldOpenaiKey:
  10536. return m.OldOpenaiKey(ctx)
  10537. case compapiasynctask.FieldRequestRaw:
  10538. return m.OldRequestRaw(ctx)
  10539. case compapiasynctask.FieldResponseRaw:
  10540. return m.OldResponseRaw(ctx)
  10541. case compapiasynctask.FieldCallbackURL:
  10542. return m.OldCallbackURL(ctx)
  10543. case compapiasynctask.FieldCallbackResponseRaw:
  10544. return m.OldCallbackResponseRaw(ctx)
  10545. case compapiasynctask.FieldModel:
  10546. return m.OldModel(ctx)
  10547. case compapiasynctask.FieldTaskStatus:
  10548. return m.OldTaskStatus(ctx)
  10549. case compapiasynctask.FieldRetryCount:
  10550. return m.OldRetryCount(ctx)
  10551. case compapiasynctask.FieldLastError:
  10552. return m.OldLastError(ctx)
  10553. }
  10554. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10555. }
  10556. // SetField sets the value of a field with the given name. It returns an error if
  10557. // the field is not defined in the schema, or if the type mismatched the field
  10558. // type.
  10559. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  10560. switch name {
  10561. case compapiasynctask.FieldCreatedAt:
  10562. v, ok := value.(time.Time)
  10563. if !ok {
  10564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10565. }
  10566. m.SetCreatedAt(v)
  10567. return nil
  10568. case compapiasynctask.FieldUpdatedAt:
  10569. v, ok := value.(time.Time)
  10570. if !ok {
  10571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10572. }
  10573. m.SetUpdatedAt(v)
  10574. return nil
  10575. case compapiasynctask.FieldAuthToken:
  10576. v, ok := value.(string)
  10577. if !ok {
  10578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10579. }
  10580. m.SetAuthToken(v)
  10581. return nil
  10582. case compapiasynctask.FieldEventType:
  10583. v, ok := value.(string)
  10584. if !ok {
  10585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10586. }
  10587. m.SetEventType(v)
  10588. return nil
  10589. case compapiasynctask.FieldChatID:
  10590. v, ok := value.(string)
  10591. if !ok {
  10592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10593. }
  10594. m.SetChatID(v)
  10595. return nil
  10596. case compapiasynctask.FieldResponseChatItemID:
  10597. v, ok := value.(string)
  10598. if !ok {
  10599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10600. }
  10601. m.SetResponseChatItemID(v)
  10602. return nil
  10603. case compapiasynctask.FieldOrganizationID:
  10604. v, ok := value.(uint64)
  10605. if !ok {
  10606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10607. }
  10608. m.SetOrganizationID(v)
  10609. return nil
  10610. case compapiasynctask.FieldOpenaiBase:
  10611. v, ok := value.(string)
  10612. if !ok {
  10613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10614. }
  10615. m.SetOpenaiBase(v)
  10616. return nil
  10617. case compapiasynctask.FieldOpenaiKey:
  10618. v, ok := value.(string)
  10619. if !ok {
  10620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10621. }
  10622. m.SetOpenaiKey(v)
  10623. return nil
  10624. case compapiasynctask.FieldRequestRaw:
  10625. v, ok := value.(string)
  10626. if !ok {
  10627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10628. }
  10629. m.SetRequestRaw(v)
  10630. return nil
  10631. case compapiasynctask.FieldResponseRaw:
  10632. v, ok := value.(string)
  10633. if !ok {
  10634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10635. }
  10636. m.SetResponseRaw(v)
  10637. return nil
  10638. case compapiasynctask.FieldCallbackURL:
  10639. v, ok := value.(string)
  10640. if !ok {
  10641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10642. }
  10643. m.SetCallbackURL(v)
  10644. return nil
  10645. case compapiasynctask.FieldCallbackResponseRaw:
  10646. v, ok := value.(string)
  10647. if !ok {
  10648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10649. }
  10650. m.SetCallbackResponseRaw(v)
  10651. return nil
  10652. case compapiasynctask.FieldModel:
  10653. v, ok := value.(string)
  10654. if !ok {
  10655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10656. }
  10657. m.SetModel(v)
  10658. return nil
  10659. case compapiasynctask.FieldTaskStatus:
  10660. v, ok := value.(int8)
  10661. if !ok {
  10662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10663. }
  10664. m.SetTaskStatus(v)
  10665. return nil
  10666. case compapiasynctask.FieldRetryCount:
  10667. v, ok := value.(int8)
  10668. if !ok {
  10669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10670. }
  10671. m.SetRetryCount(v)
  10672. return nil
  10673. case compapiasynctask.FieldLastError:
  10674. v, ok := value.(string)
  10675. if !ok {
  10676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10677. }
  10678. m.SetLastError(v)
  10679. return nil
  10680. }
  10681. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10682. }
  10683. // AddedFields returns all numeric fields that were incremented/decremented during
  10684. // this mutation.
  10685. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  10686. var fields []string
  10687. if m.addorganization_id != nil {
  10688. fields = append(fields, compapiasynctask.FieldOrganizationID)
  10689. }
  10690. if m.addtask_status != nil {
  10691. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10692. }
  10693. if m.addretry_count != nil {
  10694. fields = append(fields, compapiasynctask.FieldRetryCount)
  10695. }
  10696. return fields
  10697. }
  10698. // AddedField returns the numeric value that was incremented/decremented on a field
  10699. // with the given name. The second boolean return value indicates that this field
  10700. // was not set, or was not defined in the schema.
  10701. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  10702. switch name {
  10703. case compapiasynctask.FieldOrganizationID:
  10704. return m.AddedOrganizationID()
  10705. case compapiasynctask.FieldTaskStatus:
  10706. return m.AddedTaskStatus()
  10707. case compapiasynctask.FieldRetryCount:
  10708. return m.AddedRetryCount()
  10709. }
  10710. return nil, false
  10711. }
  10712. // AddField adds the value to the field with the given name. It returns an error if
  10713. // the field is not defined in the schema, or if the type mismatched the field
  10714. // type.
  10715. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  10716. switch name {
  10717. case compapiasynctask.FieldOrganizationID:
  10718. v, ok := value.(int64)
  10719. if !ok {
  10720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10721. }
  10722. m.AddOrganizationID(v)
  10723. return nil
  10724. case compapiasynctask.FieldTaskStatus:
  10725. v, ok := value.(int8)
  10726. if !ok {
  10727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10728. }
  10729. m.AddTaskStatus(v)
  10730. return nil
  10731. case compapiasynctask.FieldRetryCount:
  10732. v, ok := value.(int8)
  10733. if !ok {
  10734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10735. }
  10736. m.AddRetryCount(v)
  10737. return nil
  10738. }
  10739. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  10740. }
  10741. // ClearedFields returns all nullable fields that were cleared during this
  10742. // mutation.
  10743. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  10744. var fields []string
  10745. if m.FieldCleared(compapiasynctask.FieldChatID) {
  10746. fields = append(fields, compapiasynctask.FieldChatID)
  10747. }
  10748. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  10749. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  10750. }
  10751. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  10752. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10753. }
  10754. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  10755. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  10756. }
  10757. if m.FieldCleared(compapiasynctask.FieldModel) {
  10758. fields = append(fields, compapiasynctask.FieldModel)
  10759. }
  10760. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  10761. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10762. }
  10763. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  10764. fields = append(fields, compapiasynctask.FieldRetryCount)
  10765. }
  10766. if m.FieldCleared(compapiasynctask.FieldLastError) {
  10767. fields = append(fields, compapiasynctask.FieldLastError)
  10768. }
  10769. return fields
  10770. }
  10771. // FieldCleared returns a boolean indicating if a field with the given name was
  10772. // cleared in this mutation.
  10773. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  10774. _, ok := m.clearedFields[name]
  10775. return ok
  10776. }
  10777. // ClearField clears the value of the field with the given name. It returns an
  10778. // error if the field is not defined in the schema.
  10779. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  10780. switch name {
  10781. case compapiasynctask.FieldChatID:
  10782. m.ClearChatID()
  10783. return nil
  10784. case compapiasynctask.FieldResponseChatItemID:
  10785. m.ClearResponseChatItemID()
  10786. return nil
  10787. case compapiasynctask.FieldResponseRaw:
  10788. m.ClearResponseRaw()
  10789. return nil
  10790. case compapiasynctask.FieldCallbackResponseRaw:
  10791. m.ClearCallbackResponseRaw()
  10792. return nil
  10793. case compapiasynctask.FieldModel:
  10794. m.ClearModel()
  10795. return nil
  10796. case compapiasynctask.FieldTaskStatus:
  10797. m.ClearTaskStatus()
  10798. return nil
  10799. case compapiasynctask.FieldRetryCount:
  10800. m.ClearRetryCount()
  10801. return nil
  10802. case compapiasynctask.FieldLastError:
  10803. m.ClearLastError()
  10804. return nil
  10805. }
  10806. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  10807. }
  10808. // ResetField resets all changes in the mutation for the field with the given name.
  10809. // It returns an error if the field is not defined in the schema.
  10810. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  10811. switch name {
  10812. case compapiasynctask.FieldCreatedAt:
  10813. m.ResetCreatedAt()
  10814. return nil
  10815. case compapiasynctask.FieldUpdatedAt:
  10816. m.ResetUpdatedAt()
  10817. return nil
  10818. case compapiasynctask.FieldAuthToken:
  10819. m.ResetAuthToken()
  10820. return nil
  10821. case compapiasynctask.FieldEventType:
  10822. m.ResetEventType()
  10823. return nil
  10824. case compapiasynctask.FieldChatID:
  10825. m.ResetChatID()
  10826. return nil
  10827. case compapiasynctask.FieldResponseChatItemID:
  10828. m.ResetResponseChatItemID()
  10829. return nil
  10830. case compapiasynctask.FieldOrganizationID:
  10831. m.ResetOrganizationID()
  10832. return nil
  10833. case compapiasynctask.FieldOpenaiBase:
  10834. m.ResetOpenaiBase()
  10835. return nil
  10836. case compapiasynctask.FieldOpenaiKey:
  10837. m.ResetOpenaiKey()
  10838. return nil
  10839. case compapiasynctask.FieldRequestRaw:
  10840. m.ResetRequestRaw()
  10841. return nil
  10842. case compapiasynctask.FieldResponseRaw:
  10843. m.ResetResponseRaw()
  10844. return nil
  10845. case compapiasynctask.FieldCallbackURL:
  10846. m.ResetCallbackURL()
  10847. return nil
  10848. case compapiasynctask.FieldCallbackResponseRaw:
  10849. m.ResetCallbackResponseRaw()
  10850. return nil
  10851. case compapiasynctask.FieldModel:
  10852. m.ResetModel()
  10853. return nil
  10854. case compapiasynctask.FieldTaskStatus:
  10855. m.ResetTaskStatus()
  10856. return nil
  10857. case compapiasynctask.FieldRetryCount:
  10858. m.ResetRetryCount()
  10859. return nil
  10860. case compapiasynctask.FieldLastError:
  10861. m.ResetLastError()
  10862. return nil
  10863. }
  10864. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10865. }
  10866. // AddedEdges returns all edge names that were set/added in this mutation.
  10867. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  10868. edges := make([]string, 0, 0)
  10869. return edges
  10870. }
  10871. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10872. // name in this mutation.
  10873. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  10874. return nil
  10875. }
  10876. // RemovedEdges returns all edge names that were removed in this mutation.
  10877. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  10878. edges := make([]string, 0, 0)
  10879. return edges
  10880. }
  10881. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10882. // the given name in this mutation.
  10883. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  10884. return nil
  10885. }
  10886. // ClearedEdges returns all edge names that were cleared in this mutation.
  10887. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  10888. edges := make([]string, 0, 0)
  10889. return edges
  10890. }
  10891. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10892. // was cleared in this mutation.
  10893. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  10894. return false
  10895. }
  10896. // ClearEdge clears the value of the edge with the given name. It returns an error
  10897. // if that edge is not defined in the schema.
  10898. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  10899. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  10900. }
  10901. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10902. // It returns an error if the edge is not defined in the schema.
  10903. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  10904. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  10905. }
  10906. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10907. type ContactMutation struct {
  10908. config
  10909. op Op
  10910. typ string
  10911. id *uint64
  10912. created_at *time.Time
  10913. updated_at *time.Time
  10914. status *uint8
  10915. addstatus *int8
  10916. deleted_at *time.Time
  10917. wx_wxid *string
  10918. _type *int
  10919. add_type *int
  10920. wxid *string
  10921. account *string
  10922. nickname *string
  10923. markname *string
  10924. headimg *string
  10925. sex *int
  10926. addsex *int
  10927. starrole *string
  10928. dontseeit *int
  10929. adddontseeit *int
  10930. dontseeme *int
  10931. adddontseeme *int
  10932. lag *string
  10933. gid *string
  10934. gname *string
  10935. v3 *string
  10936. organization_id *uint64
  10937. addorganization_id *int64
  10938. ctype *uint64
  10939. addctype *int64
  10940. cage *int
  10941. addcage *int
  10942. cname *string
  10943. carea *string
  10944. cbirthday *string
  10945. cbirtharea *string
  10946. cidcard_no *string
  10947. ctitle *string
  10948. cc *string
  10949. phone *string
  10950. clearedFields map[string]struct{}
  10951. contact_relationships map[uint64]struct{}
  10952. removedcontact_relationships map[uint64]struct{}
  10953. clearedcontact_relationships bool
  10954. contact_fields map[uint64]struct{}
  10955. removedcontact_fields map[uint64]struct{}
  10956. clearedcontact_fields bool
  10957. contact_messages map[uint64]struct{}
  10958. removedcontact_messages map[uint64]struct{}
  10959. clearedcontact_messages bool
  10960. done bool
  10961. oldValue func(context.Context) (*Contact, error)
  10962. predicates []predicate.Contact
  10963. }
  10964. var _ ent.Mutation = (*ContactMutation)(nil)
  10965. // contactOption allows management of the mutation configuration using functional options.
  10966. type contactOption func(*ContactMutation)
  10967. // newContactMutation creates new mutation for the Contact entity.
  10968. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10969. m := &ContactMutation{
  10970. config: c,
  10971. op: op,
  10972. typ: TypeContact,
  10973. clearedFields: make(map[string]struct{}),
  10974. }
  10975. for _, opt := range opts {
  10976. opt(m)
  10977. }
  10978. return m
  10979. }
  10980. // withContactID sets the ID field of the mutation.
  10981. func withContactID(id uint64) contactOption {
  10982. return func(m *ContactMutation) {
  10983. var (
  10984. err error
  10985. once sync.Once
  10986. value *Contact
  10987. )
  10988. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10989. once.Do(func() {
  10990. if m.done {
  10991. err = errors.New("querying old values post mutation is not allowed")
  10992. } else {
  10993. value, err = m.Client().Contact.Get(ctx, id)
  10994. }
  10995. })
  10996. return value, err
  10997. }
  10998. m.id = &id
  10999. }
  11000. }
  11001. // withContact sets the old Contact of the mutation.
  11002. func withContact(node *Contact) contactOption {
  11003. return func(m *ContactMutation) {
  11004. m.oldValue = func(context.Context) (*Contact, error) {
  11005. return node, nil
  11006. }
  11007. m.id = &node.ID
  11008. }
  11009. }
  11010. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11011. // executed in a transaction (ent.Tx), a transactional client is returned.
  11012. func (m ContactMutation) Client() *Client {
  11013. client := &Client{config: m.config}
  11014. client.init()
  11015. return client
  11016. }
  11017. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11018. // it returns an error otherwise.
  11019. func (m ContactMutation) Tx() (*Tx, error) {
  11020. if _, ok := m.driver.(*txDriver); !ok {
  11021. return nil, errors.New("ent: mutation is not running in a transaction")
  11022. }
  11023. tx := &Tx{config: m.config}
  11024. tx.init()
  11025. return tx, nil
  11026. }
  11027. // SetID sets the value of the id field. Note that this
  11028. // operation is only accepted on creation of Contact entities.
  11029. func (m *ContactMutation) SetID(id uint64) {
  11030. m.id = &id
  11031. }
  11032. // ID returns the ID value in the mutation. Note that the ID is only available
  11033. // if it was provided to the builder or after it was returned from the database.
  11034. func (m *ContactMutation) ID() (id uint64, exists bool) {
  11035. if m.id == nil {
  11036. return
  11037. }
  11038. return *m.id, true
  11039. }
  11040. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11041. // That means, if the mutation is applied within a transaction with an isolation level such
  11042. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11043. // or updated by the mutation.
  11044. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  11045. switch {
  11046. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11047. id, exists := m.ID()
  11048. if exists {
  11049. return []uint64{id}, nil
  11050. }
  11051. fallthrough
  11052. case m.op.Is(OpUpdate | OpDelete):
  11053. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  11054. default:
  11055. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11056. }
  11057. }
  11058. // SetCreatedAt sets the "created_at" field.
  11059. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  11060. m.created_at = &t
  11061. }
  11062. // CreatedAt returns the value of the "created_at" field in the mutation.
  11063. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  11064. v := m.created_at
  11065. if v == nil {
  11066. return
  11067. }
  11068. return *v, true
  11069. }
  11070. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  11071. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11073. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11074. if !m.op.Is(OpUpdateOne) {
  11075. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11076. }
  11077. if m.id == nil || m.oldValue == nil {
  11078. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11079. }
  11080. oldValue, err := m.oldValue(ctx)
  11081. if err != nil {
  11082. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11083. }
  11084. return oldValue.CreatedAt, nil
  11085. }
  11086. // ResetCreatedAt resets all changes to the "created_at" field.
  11087. func (m *ContactMutation) ResetCreatedAt() {
  11088. m.created_at = nil
  11089. }
  11090. // SetUpdatedAt sets the "updated_at" field.
  11091. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  11092. m.updated_at = &t
  11093. }
  11094. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11095. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  11096. v := m.updated_at
  11097. if v == nil {
  11098. return
  11099. }
  11100. return *v, true
  11101. }
  11102. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  11103. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11105. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11106. if !m.op.Is(OpUpdateOne) {
  11107. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11108. }
  11109. if m.id == nil || m.oldValue == nil {
  11110. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11111. }
  11112. oldValue, err := m.oldValue(ctx)
  11113. if err != nil {
  11114. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11115. }
  11116. return oldValue.UpdatedAt, nil
  11117. }
  11118. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11119. func (m *ContactMutation) ResetUpdatedAt() {
  11120. m.updated_at = nil
  11121. }
  11122. // SetStatus sets the "status" field.
  11123. func (m *ContactMutation) SetStatus(u uint8) {
  11124. m.status = &u
  11125. m.addstatus = nil
  11126. }
  11127. // Status returns the value of the "status" field in the mutation.
  11128. func (m *ContactMutation) Status() (r uint8, exists bool) {
  11129. v := m.status
  11130. if v == nil {
  11131. return
  11132. }
  11133. return *v, true
  11134. }
  11135. // OldStatus returns the old "status" field's value of the Contact entity.
  11136. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11138. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11139. if !m.op.Is(OpUpdateOne) {
  11140. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11141. }
  11142. if m.id == nil || m.oldValue == nil {
  11143. return v, errors.New("OldStatus requires an ID field in the mutation")
  11144. }
  11145. oldValue, err := m.oldValue(ctx)
  11146. if err != nil {
  11147. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11148. }
  11149. return oldValue.Status, nil
  11150. }
  11151. // AddStatus adds u to the "status" field.
  11152. func (m *ContactMutation) AddStatus(u int8) {
  11153. if m.addstatus != nil {
  11154. *m.addstatus += u
  11155. } else {
  11156. m.addstatus = &u
  11157. }
  11158. }
  11159. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11160. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  11161. v := m.addstatus
  11162. if v == nil {
  11163. return
  11164. }
  11165. return *v, true
  11166. }
  11167. // ClearStatus clears the value of the "status" field.
  11168. func (m *ContactMutation) ClearStatus() {
  11169. m.status = nil
  11170. m.addstatus = nil
  11171. m.clearedFields[contact.FieldStatus] = struct{}{}
  11172. }
  11173. // StatusCleared returns if the "status" field was cleared in this mutation.
  11174. func (m *ContactMutation) StatusCleared() bool {
  11175. _, ok := m.clearedFields[contact.FieldStatus]
  11176. return ok
  11177. }
  11178. // ResetStatus resets all changes to the "status" field.
  11179. func (m *ContactMutation) ResetStatus() {
  11180. m.status = nil
  11181. m.addstatus = nil
  11182. delete(m.clearedFields, contact.FieldStatus)
  11183. }
  11184. // SetDeletedAt sets the "deleted_at" field.
  11185. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  11186. m.deleted_at = &t
  11187. }
  11188. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11189. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  11190. v := m.deleted_at
  11191. if v == nil {
  11192. return
  11193. }
  11194. return *v, true
  11195. }
  11196. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  11197. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11199. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11200. if !m.op.Is(OpUpdateOne) {
  11201. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11202. }
  11203. if m.id == nil || m.oldValue == nil {
  11204. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11205. }
  11206. oldValue, err := m.oldValue(ctx)
  11207. if err != nil {
  11208. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11209. }
  11210. return oldValue.DeletedAt, nil
  11211. }
  11212. // ClearDeletedAt clears the value of the "deleted_at" field.
  11213. func (m *ContactMutation) ClearDeletedAt() {
  11214. m.deleted_at = nil
  11215. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  11216. }
  11217. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11218. func (m *ContactMutation) DeletedAtCleared() bool {
  11219. _, ok := m.clearedFields[contact.FieldDeletedAt]
  11220. return ok
  11221. }
  11222. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11223. func (m *ContactMutation) ResetDeletedAt() {
  11224. m.deleted_at = nil
  11225. delete(m.clearedFields, contact.FieldDeletedAt)
  11226. }
  11227. // SetWxWxid sets the "wx_wxid" field.
  11228. func (m *ContactMutation) SetWxWxid(s string) {
  11229. m.wx_wxid = &s
  11230. }
  11231. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  11232. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  11233. v := m.wx_wxid
  11234. if v == nil {
  11235. return
  11236. }
  11237. return *v, true
  11238. }
  11239. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  11240. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11242. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  11243. if !m.op.Is(OpUpdateOne) {
  11244. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  11245. }
  11246. if m.id == nil || m.oldValue == nil {
  11247. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  11248. }
  11249. oldValue, err := m.oldValue(ctx)
  11250. if err != nil {
  11251. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  11252. }
  11253. return oldValue.WxWxid, nil
  11254. }
  11255. // ResetWxWxid resets all changes to the "wx_wxid" field.
  11256. func (m *ContactMutation) ResetWxWxid() {
  11257. m.wx_wxid = nil
  11258. }
  11259. // SetType sets the "type" field.
  11260. func (m *ContactMutation) SetType(i int) {
  11261. m._type = &i
  11262. m.add_type = nil
  11263. }
  11264. // GetType returns the value of the "type" field in the mutation.
  11265. func (m *ContactMutation) GetType() (r int, exists bool) {
  11266. v := m._type
  11267. if v == nil {
  11268. return
  11269. }
  11270. return *v, true
  11271. }
  11272. // OldType returns the old "type" field's value of the Contact entity.
  11273. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11275. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  11276. if !m.op.Is(OpUpdateOne) {
  11277. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11278. }
  11279. if m.id == nil || m.oldValue == nil {
  11280. return v, errors.New("OldType requires an ID field in the mutation")
  11281. }
  11282. oldValue, err := m.oldValue(ctx)
  11283. if err != nil {
  11284. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11285. }
  11286. return oldValue.Type, nil
  11287. }
  11288. // AddType adds i to the "type" field.
  11289. func (m *ContactMutation) AddType(i int) {
  11290. if m.add_type != nil {
  11291. *m.add_type += i
  11292. } else {
  11293. m.add_type = &i
  11294. }
  11295. }
  11296. // AddedType returns the value that was added to the "type" field in this mutation.
  11297. func (m *ContactMutation) AddedType() (r int, exists bool) {
  11298. v := m.add_type
  11299. if v == nil {
  11300. return
  11301. }
  11302. return *v, true
  11303. }
  11304. // ClearType clears the value of the "type" field.
  11305. func (m *ContactMutation) ClearType() {
  11306. m._type = nil
  11307. m.add_type = nil
  11308. m.clearedFields[contact.FieldType] = struct{}{}
  11309. }
  11310. // TypeCleared returns if the "type" field was cleared in this mutation.
  11311. func (m *ContactMutation) TypeCleared() bool {
  11312. _, ok := m.clearedFields[contact.FieldType]
  11313. return ok
  11314. }
  11315. // ResetType resets all changes to the "type" field.
  11316. func (m *ContactMutation) ResetType() {
  11317. m._type = nil
  11318. m.add_type = nil
  11319. delete(m.clearedFields, contact.FieldType)
  11320. }
  11321. // SetWxid sets the "wxid" field.
  11322. func (m *ContactMutation) SetWxid(s string) {
  11323. m.wxid = &s
  11324. }
  11325. // Wxid returns the value of the "wxid" field in the mutation.
  11326. func (m *ContactMutation) Wxid() (r string, exists bool) {
  11327. v := m.wxid
  11328. if v == nil {
  11329. return
  11330. }
  11331. return *v, true
  11332. }
  11333. // OldWxid returns the old "wxid" field's value of the Contact entity.
  11334. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11336. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  11337. if !m.op.Is(OpUpdateOne) {
  11338. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  11339. }
  11340. if m.id == nil || m.oldValue == nil {
  11341. return v, errors.New("OldWxid requires an ID field in the mutation")
  11342. }
  11343. oldValue, err := m.oldValue(ctx)
  11344. if err != nil {
  11345. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  11346. }
  11347. return oldValue.Wxid, nil
  11348. }
  11349. // ResetWxid resets all changes to the "wxid" field.
  11350. func (m *ContactMutation) ResetWxid() {
  11351. m.wxid = nil
  11352. }
  11353. // SetAccount sets the "account" field.
  11354. func (m *ContactMutation) SetAccount(s string) {
  11355. m.account = &s
  11356. }
  11357. // Account returns the value of the "account" field in the mutation.
  11358. func (m *ContactMutation) Account() (r string, exists bool) {
  11359. v := m.account
  11360. if v == nil {
  11361. return
  11362. }
  11363. return *v, true
  11364. }
  11365. // OldAccount returns the old "account" field's value of the Contact entity.
  11366. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11368. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  11369. if !m.op.Is(OpUpdateOne) {
  11370. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  11371. }
  11372. if m.id == nil || m.oldValue == nil {
  11373. return v, errors.New("OldAccount requires an ID field in the mutation")
  11374. }
  11375. oldValue, err := m.oldValue(ctx)
  11376. if err != nil {
  11377. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  11378. }
  11379. return oldValue.Account, nil
  11380. }
  11381. // ResetAccount resets all changes to the "account" field.
  11382. func (m *ContactMutation) ResetAccount() {
  11383. m.account = nil
  11384. }
  11385. // SetNickname sets the "nickname" field.
  11386. func (m *ContactMutation) SetNickname(s string) {
  11387. m.nickname = &s
  11388. }
  11389. // Nickname returns the value of the "nickname" field in the mutation.
  11390. func (m *ContactMutation) Nickname() (r string, exists bool) {
  11391. v := m.nickname
  11392. if v == nil {
  11393. return
  11394. }
  11395. return *v, true
  11396. }
  11397. // OldNickname returns the old "nickname" field's value of the Contact entity.
  11398. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11400. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  11401. if !m.op.Is(OpUpdateOne) {
  11402. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  11403. }
  11404. if m.id == nil || m.oldValue == nil {
  11405. return v, errors.New("OldNickname requires an ID field in the mutation")
  11406. }
  11407. oldValue, err := m.oldValue(ctx)
  11408. if err != nil {
  11409. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  11410. }
  11411. return oldValue.Nickname, nil
  11412. }
  11413. // ResetNickname resets all changes to the "nickname" field.
  11414. func (m *ContactMutation) ResetNickname() {
  11415. m.nickname = nil
  11416. }
  11417. // SetMarkname sets the "markname" field.
  11418. func (m *ContactMutation) SetMarkname(s string) {
  11419. m.markname = &s
  11420. }
  11421. // Markname returns the value of the "markname" field in the mutation.
  11422. func (m *ContactMutation) Markname() (r string, exists bool) {
  11423. v := m.markname
  11424. if v == nil {
  11425. return
  11426. }
  11427. return *v, true
  11428. }
  11429. // OldMarkname returns the old "markname" field's value of the Contact entity.
  11430. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11432. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  11433. if !m.op.Is(OpUpdateOne) {
  11434. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  11435. }
  11436. if m.id == nil || m.oldValue == nil {
  11437. return v, errors.New("OldMarkname requires an ID field in the mutation")
  11438. }
  11439. oldValue, err := m.oldValue(ctx)
  11440. if err != nil {
  11441. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  11442. }
  11443. return oldValue.Markname, nil
  11444. }
  11445. // ResetMarkname resets all changes to the "markname" field.
  11446. func (m *ContactMutation) ResetMarkname() {
  11447. m.markname = nil
  11448. }
  11449. // SetHeadimg sets the "headimg" field.
  11450. func (m *ContactMutation) SetHeadimg(s string) {
  11451. m.headimg = &s
  11452. }
  11453. // Headimg returns the value of the "headimg" field in the mutation.
  11454. func (m *ContactMutation) Headimg() (r string, exists bool) {
  11455. v := m.headimg
  11456. if v == nil {
  11457. return
  11458. }
  11459. return *v, true
  11460. }
  11461. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  11462. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11464. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  11465. if !m.op.Is(OpUpdateOne) {
  11466. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  11467. }
  11468. if m.id == nil || m.oldValue == nil {
  11469. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  11470. }
  11471. oldValue, err := m.oldValue(ctx)
  11472. if err != nil {
  11473. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  11474. }
  11475. return oldValue.Headimg, nil
  11476. }
  11477. // ResetHeadimg resets all changes to the "headimg" field.
  11478. func (m *ContactMutation) ResetHeadimg() {
  11479. m.headimg = nil
  11480. }
  11481. // SetSex sets the "sex" field.
  11482. func (m *ContactMutation) SetSex(i int) {
  11483. m.sex = &i
  11484. m.addsex = nil
  11485. }
  11486. // Sex returns the value of the "sex" field in the mutation.
  11487. func (m *ContactMutation) Sex() (r int, exists bool) {
  11488. v := m.sex
  11489. if v == nil {
  11490. return
  11491. }
  11492. return *v, true
  11493. }
  11494. // OldSex returns the old "sex" field's value of the Contact entity.
  11495. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11497. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  11498. if !m.op.Is(OpUpdateOne) {
  11499. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  11500. }
  11501. if m.id == nil || m.oldValue == nil {
  11502. return v, errors.New("OldSex requires an ID field in the mutation")
  11503. }
  11504. oldValue, err := m.oldValue(ctx)
  11505. if err != nil {
  11506. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  11507. }
  11508. return oldValue.Sex, nil
  11509. }
  11510. // AddSex adds i to the "sex" field.
  11511. func (m *ContactMutation) AddSex(i int) {
  11512. if m.addsex != nil {
  11513. *m.addsex += i
  11514. } else {
  11515. m.addsex = &i
  11516. }
  11517. }
  11518. // AddedSex returns the value that was added to the "sex" field in this mutation.
  11519. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  11520. v := m.addsex
  11521. if v == nil {
  11522. return
  11523. }
  11524. return *v, true
  11525. }
  11526. // ResetSex resets all changes to the "sex" field.
  11527. func (m *ContactMutation) ResetSex() {
  11528. m.sex = nil
  11529. m.addsex = nil
  11530. }
  11531. // SetStarrole sets the "starrole" field.
  11532. func (m *ContactMutation) SetStarrole(s string) {
  11533. m.starrole = &s
  11534. }
  11535. // Starrole returns the value of the "starrole" field in the mutation.
  11536. func (m *ContactMutation) Starrole() (r string, exists bool) {
  11537. v := m.starrole
  11538. if v == nil {
  11539. return
  11540. }
  11541. return *v, true
  11542. }
  11543. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  11544. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11546. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  11547. if !m.op.Is(OpUpdateOne) {
  11548. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  11549. }
  11550. if m.id == nil || m.oldValue == nil {
  11551. return v, errors.New("OldStarrole requires an ID field in the mutation")
  11552. }
  11553. oldValue, err := m.oldValue(ctx)
  11554. if err != nil {
  11555. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  11556. }
  11557. return oldValue.Starrole, nil
  11558. }
  11559. // ResetStarrole resets all changes to the "starrole" field.
  11560. func (m *ContactMutation) ResetStarrole() {
  11561. m.starrole = nil
  11562. }
  11563. // SetDontseeit sets the "dontseeit" field.
  11564. func (m *ContactMutation) SetDontseeit(i int) {
  11565. m.dontseeit = &i
  11566. m.adddontseeit = nil
  11567. }
  11568. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  11569. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  11570. v := m.dontseeit
  11571. if v == nil {
  11572. return
  11573. }
  11574. return *v, true
  11575. }
  11576. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  11577. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11579. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  11580. if !m.op.Is(OpUpdateOne) {
  11581. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  11582. }
  11583. if m.id == nil || m.oldValue == nil {
  11584. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  11585. }
  11586. oldValue, err := m.oldValue(ctx)
  11587. if err != nil {
  11588. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  11589. }
  11590. return oldValue.Dontseeit, nil
  11591. }
  11592. // AddDontseeit adds i to the "dontseeit" field.
  11593. func (m *ContactMutation) AddDontseeit(i int) {
  11594. if m.adddontseeit != nil {
  11595. *m.adddontseeit += i
  11596. } else {
  11597. m.adddontseeit = &i
  11598. }
  11599. }
  11600. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  11601. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  11602. v := m.adddontseeit
  11603. if v == nil {
  11604. return
  11605. }
  11606. return *v, true
  11607. }
  11608. // ResetDontseeit resets all changes to the "dontseeit" field.
  11609. func (m *ContactMutation) ResetDontseeit() {
  11610. m.dontseeit = nil
  11611. m.adddontseeit = nil
  11612. }
  11613. // SetDontseeme sets the "dontseeme" field.
  11614. func (m *ContactMutation) SetDontseeme(i int) {
  11615. m.dontseeme = &i
  11616. m.adddontseeme = nil
  11617. }
  11618. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  11619. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  11620. v := m.dontseeme
  11621. if v == nil {
  11622. return
  11623. }
  11624. return *v, true
  11625. }
  11626. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  11627. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11629. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  11630. if !m.op.Is(OpUpdateOne) {
  11631. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  11632. }
  11633. if m.id == nil || m.oldValue == nil {
  11634. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  11635. }
  11636. oldValue, err := m.oldValue(ctx)
  11637. if err != nil {
  11638. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  11639. }
  11640. return oldValue.Dontseeme, nil
  11641. }
  11642. // AddDontseeme adds i to the "dontseeme" field.
  11643. func (m *ContactMutation) AddDontseeme(i int) {
  11644. if m.adddontseeme != nil {
  11645. *m.adddontseeme += i
  11646. } else {
  11647. m.adddontseeme = &i
  11648. }
  11649. }
  11650. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  11651. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  11652. v := m.adddontseeme
  11653. if v == nil {
  11654. return
  11655. }
  11656. return *v, true
  11657. }
  11658. // ResetDontseeme resets all changes to the "dontseeme" field.
  11659. func (m *ContactMutation) ResetDontseeme() {
  11660. m.dontseeme = nil
  11661. m.adddontseeme = nil
  11662. }
  11663. // SetLag sets the "lag" field.
  11664. func (m *ContactMutation) SetLag(s string) {
  11665. m.lag = &s
  11666. }
  11667. // Lag returns the value of the "lag" field in the mutation.
  11668. func (m *ContactMutation) Lag() (r string, exists bool) {
  11669. v := m.lag
  11670. if v == nil {
  11671. return
  11672. }
  11673. return *v, true
  11674. }
  11675. // OldLag returns the old "lag" field's value of the Contact entity.
  11676. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11678. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11679. if !m.op.Is(OpUpdateOne) {
  11680. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11681. }
  11682. if m.id == nil || m.oldValue == nil {
  11683. return v, errors.New("OldLag requires an ID field in the mutation")
  11684. }
  11685. oldValue, err := m.oldValue(ctx)
  11686. if err != nil {
  11687. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11688. }
  11689. return oldValue.Lag, nil
  11690. }
  11691. // ResetLag resets all changes to the "lag" field.
  11692. func (m *ContactMutation) ResetLag() {
  11693. m.lag = nil
  11694. }
  11695. // SetGid sets the "gid" field.
  11696. func (m *ContactMutation) SetGid(s string) {
  11697. m.gid = &s
  11698. }
  11699. // Gid returns the value of the "gid" field in the mutation.
  11700. func (m *ContactMutation) Gid() (r string, exists bool) {
  11701. v := m.gid
  11702. if v == nil {
  11703. return
  11704. }
  11705. return *v, true
  11706. }
  11707. // OldGid returns the old "gid" field's value of the Contact entity.
  11708. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11710. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11711. if !m.op.Is(OpUpdateOne) {
  11712. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11713. }
  11714. if m.id == nil || m.oldValue == nil {
  11715. return v, errors.New("OldGid requires an ID field in the mutation")
  11716. }
  11717. oldValue, err := m.oldValue(ctx)
  11718. if err != nil {
  11719. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11720. }
  11721. return oldValue.Gid, nil
  11722. }
  11723. // ResetGid resets all changes to the "gid" field.
  11724. func (m *ContactMutation) ResetGid() {
  11725. m.gid = nil
  11726. }
  11727. // SetGname sets the "gname" field.
  11728. func (m *ContactMutation) SetGname(s string) {
  11729. m.gname = &s
  11730. }
  11731. // Gname returns the value of the "gname" field in the mutation.
  11732. func (m *ContactMutation) Gname() (r string, exists bool) {
  11733. v := m.gname
  11734. if v == nil {
  11735. return
  11736. }
  11737. return *v, true
  11738. }
  11739. // OldGname returns the old "gname" field's value of the Contact entity.
  11740. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11742. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11743. if !m.op.Is(OpUpdateOne) {
  11744. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11745. }
  11746. if m.id == nil || m.oldValue == nil {
  11747. return v, errors.New("OldGname requires an ID field in the mutation")
  11748. }
  11749. oldValue, err := m.oldValue(ctx)
  11750. if err != nil {
  11751. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11752. }
  11753. return oldValue.Gname, nil
  11754. }
  11755. // ResetGname resets all changes to the "gname" field.
  11756. func (m *ContactMutation) ResetGname() {
  11757. m.gname = nil
  11758. }
  11759. // SetV3 sets the "v3" field.
  11760. func (m *ContactMutation) SetV3(s string) {
  11761. m.v3 = &s
  11762. }
  11763. // V3 returns the value of the "v3" field in the mutation.
  11764. func (m *ContactMutation) V3() (r string, exists bool) {
  11765. v := m.v3
  11766. if v == nil {
  11767. return
  11768. }
  11769. return *v, true
  11770. }
  11771. // OldV3 returns the old "v3" field's value of the Contact entity.
  11772. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11774. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11775. if !m.op.Is(OpUpdateOne) {
  11776. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11777. }
  11778. if m.id == nil || m.oldValue == nil {
  11779. return v, errors.New("OldV3 requires an ID field in the mutation")
  11780. }
  11781. oldValue, err := m.oldValue(ctx)
  11782. if err != nil {
  11783. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11784. }
  11785. return oldValue.V3, nil
  11786. }
  11787. // ResetV3 resets all changes to the "v3" field.
  11788. func (m *ContactMutation) ResetV3() {
  11789. m.v3 = nil
  11790. }
  11791. // SetOrganizationID sets the "organization_id" field.
  11792. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11793. m.organization_id = &u
  11794. m.addorganization_id = nil
  11795. }
  11796. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11797. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11798. v := m.organization_id
  11799. if v == nil {
  11800. return
  11801. }
  11802. return *v, true
  11803. }
  11804. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11805. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11807. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11808. if !m.op.Is(OpUpdateOne) {
  11809. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11810. }
  11811. if m.id == nil || m.oldValue == nil {
  11812. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11813. }
  11814. oldValue, err := m.oldValue(ctx)
  11815. if err != nil {
  11816. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11817. }
  11818. return oldValue.OrganizationID, nil
  11819. }
  11820. // AddOrganizationID adds u to the "organization_id" field.
  11821. func (m *ContactMutation) AddOrganizationID(u int64) {
  11822. if m.addorganization_id != nil {
  11823. *m.addorganization_id += u
  11824. } else {
  11825. m.addorganization_id = &u
  11826. }
  11827. }
  11828. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11829. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11830. v := m.addorganization_id
  11831. if v == nil {
  11832. return
  11833. }
  11834. return *v, true
  11835. }
  11836. // ClearOrganizationID clears the value of the "organization_id" field.
  11837. func (m *ContactMutation) ClearOrganizationID() {
  11838. m.organization_id = nil
  11839. m.addorganization_id = nil
  11840. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11841. }
  11842. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11843. func (m *ContactMutation) OrganizationIDCleared() bool {
  11844. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11845. return ok
  11846. }
  11847. // ResetOrganizationID resets all changes to the "organization_id" field.
  11848. func (m *ContactMutation) ResetOrganizationID() {
  11849. m.organization_id = nil
  11850. m.addorganization_id = nil
  11851. delete(m.clearedFields, contact.FieldOrganizationID)
  11852. }
  11853. // SetCtype sets the "ctype" field.
  11854. func (m *ContactMutation) SetCtype(u uint64) {
  11855. m.ctype = &u
  11856. m.addctype = nil
  11857. }
  11858. // Ctype returns the value of the "ctype" field in the mutation.
  11859. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11860. v := m.ctype
  11861. if v == nil {
  11862. return
  11863. }
  11864. return *v, true
  11865. }
  11866. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11867. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11869. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11870. if !m.op.Is(OpUpdateOne) {
  11871. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11872. }
  11873. if m.id == nil || m.oldValue == nil {
  11874. return v, errors.New("OldCtype requires an ID field in the mutation")
  11875. }
  11876. oldValue, err := m.oldValue(ctx)
  11877. if err != nil {
  11878. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11879. }
  11880. return oldValue.Ctype, nil
  11881. }
  11882. // AddCtype adds u to the "ctype" field.
  11883. func (m *ContactMutation) AddCtype(u int64) {
  11884. if m.addctype != nil {
  11885. *m.addctype += u
  11886. } else {
  11887. m.addctype = &u
  11888. }
  11889. }
  11890. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11891. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11892. v := m.addctype
  11893. if v == nil {
  11894. return
  11895. }
  11896. return *v, true
  11897. }
  11898. // ResetCtype resets all changes to the "ctype" field.
  11899. func (m *ContactMutation) ResetCtype() {
  11900. m.ctype = nil
  11901. m.addctype = nil
  11902. }
  11903. // SetCage sets the "cage" field.
  11904. func (m *ContactMutation) SetCage(i int) {
  11905. m.cage = &i
  11906. m.addcage = nil
  11907. }
  11908. // Cage returns the value of the "cage" field in the mutation.
  11909. func (m *ContactMutation) Cage() (r int, exists bool) {
  11910. v := m.cage
  11911. if v == nil {
  11912. return
  11913. }
  11914. return *v, true
  11915. }
  11916. // OldCage returns the old "cage" field's value of the Contact entity.
  11917. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11919. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11920. if !m.op.Is(OpUpdateOne) {
  11921. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11922. }
  11923. if m.id == nil || m.oldValue == nil {
  11924. return v, errors.New("OldCage requires an ID field in the mutation")
  11925. }
  11926. oldValue, err := m.oldValue(ctx)
  11927. if err != nil {
  11928. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11929. }
  11930. return oldValue.Cage, nil
  11931. }
  11932. // AddCage adds i to the "cage" field.
  11933. func (m *ContactMutation) AddCage(i int) {
  11934. if m.addcage != nil {
  11935. *m.addcage += i
  11936. } else {
  11937. m.addcage = &i
  11938. }
  11939. }
  11940. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11941. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11942. v := m.addcage
  11943. if v == nil {
  11944. return
  11945. }
  11946. return *v, true
  11947. }
  11948. // ResetCage resets all changes to the "cage" field.
  11949. func (m *ContactMutation) ResetCage() {
  11950. m.cage = nil
  11951. m.addcage = nil
  11952. }
  11953. // SetCname sets the "cname" field.
  11954. func (m *ContactMutation) SetCname(s string) {
  11955. m.cname = &s
  11956. }
  11957. // Cname returns the value of the "cname" field in the mutation.
  11958. func (m *ContactMutation) Cname() (r string, exists bool) {
  11959. v := m.cname
  11960. if v == nil {
  11961. return
  11962. }
  11963. return *v, true
  11964. }
  11965. // OldCname returns the old "cname" field's value of the Contact entity.
  11966. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11968. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11969. if !m.op.Is(OpUpdateOne) {
  11970. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11971. }
  11972. if m.id == nil || m.oldValue == nil {
  11973. return v, errors.New("OldCname requires an ID field in the mutation")
  11974. }
  11975. oldValue, err := m.oldValue(ctx)
  11976. if err != nil {
  11977. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11978. }
  11979. return oldValue.Cname, nil
  11980. }
  11981. // ResetCname resets all changes to the "cname" field.
  11982. func (m *ContactMutation) ResetCname() {
  11983. m.cname = nil
  11984. }
  11985. // SetCarea sets the "carea" field.
  11986. func (m *ContactMutation) SetCarea(s string) {
  11987. m.carea = &s
  11988. }
  11989. // Carea returns the value of the "carea" field in the mutation.
  11990. func (m *ContactMutation) Carea() (r string, exists bool) {
  11991. v := m.carea
  11992. if v == nil {
  11993. return
  11994. }
  11995. return *v, true
  11996. }
  11997. // OldCarea returns the old "carea" field's value of the Contact entity.
  11998. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12000. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  12001. if !m.op.Is(OpUpdateOne) {
  12002. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  12003. }
  12004. if m.id == nil || m.oldValue == nil {
  12005. return v, errors.New("OldCarea requires an ID field in the mutation")
  12006. }
  12007. oldValue, err := m.oldValue(ctx)
  12008. if err != nil {
  12009. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  12010. }
  12011. return oldValue.Carea, nil
  12012. }
  12013. // ResetCarea resets all changes to the "carea" field.
  12014. func (m *ContactMutation) ResetCarea() {
  12015. m.carea = nil
  12016. }
  12017. // SetCbirthday sets the "cbirthday" field.
  12018. func (m *ContactMutation) SetCbirthday(s string) {
  12019. m.cbirthday = &s
  12020. }
  12021. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  12022. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  12023. v := m.cbirthday
  12024. if v == nil {
  12025. return
  12026. }
  12027. return *v, true
  12028. }
  12029. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  12030. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12032. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  12033. if !m.op.Is(OpUpdateOne) {
  12034. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  12035. }
  12036. if m.id == nil || m.oldValue == nil {
  12037. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  12038. }
  12039. oldValue, err := m.oldValue(ctx)
  12040. if err != nil {
  12041. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  12042. }
  12043. return oldValue.Cbirthday, nil
  12044. }
  12045. // ResetCbirthday resets all changes to the "cbirthday" field.
  12046. func (m *ContactMutation) ResetCbirthday() {
  12047. m.cbirthday = nil
  12048. }
  12049. // SetCbirtharea sets the "cbirtharea" field.
  12050. func (m *ContactMutation) SetCbirtharea(s string) {
  12051. m.cbirtharea = &s
  12052. }
  12053. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  12054. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  12055. v := m.cbirtharea
  12056. if v == nil {
  12057. return
  12058. }
  12059. return *v, true
  12060. }
  12061. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  12062. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12064. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  12065. if !m.op.Is(OpUpdateOne) {
  12066. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  12067. }
  12068. if m.id == nil || m.oldValue == nil {
  12069. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  12070. }
  12071. oldValue, err := m.oldValue(ctx)
  12072. if err != nil {
  12073. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  12074. }
  12075. return oldValue.Cbirtharea, nil
  12076. }
  12077. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  12078. func (m *ContactMutation) ResetCbirtharea() {
  12079. m.cbirtharea = nil
  12080. }
  12081. // SetCidcardNo sets the "cidcard_no" field.
  12082. func (m *ContactMutation) SetCidcardNo(s string) {
  12083. m.cidcard_no = &s
  12084. }
  12085. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  12086. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  12087. v := m.cidcard_no
  12088. if v == nil {
  12089. return
  12090. }
  12091. return *v, true
  12092. }
  12093. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  12094. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12096. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  12097. if !m.op.Is(OpUpdateOne) {
  12098. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  12099. }
  12100. if m.id == nil || m.oldValue == nil {
  12101. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  12102. }
  12103. oldValue, err := m.oldValue(ctx)
  12104. if err != nil {
  12105. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  12106. }
  12107. return oldValue.CidcardNo, nil
  12108. }
  12109. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  12110. func (m *ContactMutation) ResetCidcardNo() {
  12111. m.cidcard_no = nil
  12112. }
  12113. // SetCtitle sets the "ctitle" field.
  12114. func (m *ContactMutation) SetCtitle(s string) {
  12115. m.ctitle = &s
  12116. }
  12117. // Ctitle returns the value of the "ctitle" field in the mutation.
  12118. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  12119. v := m.ctitle
  12120. if v == nil {
  12121. return
  12122. }
  12123. return *v, true
  12124. }
  12125. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  12126. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12128. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  12129. if !m.op.Is(OpUpdateOne) {
  12130. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  12131. }
  12132. if m.id == nil || m.oldValue == nil {
  12133. return v, errors.New("OldCtitle requires an ID field in the mutation")
  12134. }
  12135. oldValue, err := m.oldValue(ctx)
  12136. if err != nil {
  12137. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  12138. }
  12139. return oldValue.Ctitle, nil
  12140. }
  12141. // ResetCtitle resets all changes to the "ctitle" field.
  12142. func (m *ContactMutation) ResetCtitle() {
  12143. m.ctitle = nil
  12144. }
  12145. // SetCc sets the "cc" field.
  12146. func (m *ContactMutation) SetCc(s string) {
  12147. m.cc = &s
  12148. }
  12149. // Cc returns the value of the "cc" field in the mutation.
  12150. func (m *ContactMutation) Cc() (r string, exists bool) {
  12151. v := m.cc
  12152. if v == nil {
  12153. return
  12154. }
  12155. return *v, true
  12156. }
  12157. // OldCc returns the old "cc" field's value of the Contact entity.
  12158. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12160. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  12161. if !m.op.Is(OpUpdateOne) {
  12162. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  12163. }
  12164. if m.id == nil || m.oldValue == nil {
  12165. return v, errors.New("OldCc requires an ID field in the mutation")
  12166. }
  12167. oldValue, err := m.oldValue(ctx)
  12168. if err != nil {
  12169. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  12170. }
  12171. return oldValue.Cc, nil
  12172. }
  12173. // ResetCc resets all changes to the "cc" field.
  12174. func (m *ContactMutation) ResetCc() {
  12175. m.cc = nil
  12176. }
  12177. // SetPhone sets the "phone" field.
  12178. func (m *ContactMutation) SetPhone(s string) {
  12179. m.phone = &s
  12180. }
  12181. // Phone returns the value of the "phone" field in the mutation.
  12182. func (m *ContactMutation) Phone() (r string, exists bool) {
  12183. v := m.phone
  12184. if v == nil {
  12185. return
  12186. }
  12187. return *v, true
  12188. }
  12189. // OldPhone returns the old "phone" field's value of the Contact entity.
  12190. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12192. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  12193. if !m.op.Is(OpUpdateOne) {
  12194. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  12195. }
  12196. if m.id == nil || m.oldValue == nil {
  12197. return v, errors.New("OldPhone requires an ID field in the mutation")
  12198. }
  12199. oldValue, err := m.oldValue(ctx)
  12200. if err != nil {
  12201. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  12202. }
  12203. return oldValue.Phone, nil
  12204. }
  12205. // ResetPhone resets all changes to the "phone" field.
  12206. func (m *ContactMutation) ResetPhone() {
  12207. m.phone = nil
  12208. }
  12209. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  12210. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  12211. if m.contact_relationships == nil {
  12212. m.contact_relationships = make(map[uint64]struct{})
  12213. }
  12214. for i := range ids {
  12215. m.contact_relationships[ids[i]] = struct{}{}
  12216. }
  12217. }
  12218. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  12219. func (m *ContactMutation) ClearContactRelationships() {
  12220. m.clearedcontact_relationships = true
  12221. }
  12222. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  12223. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  12224. return m.clearedcontact_relationships
  12225. }
  12226. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  12227. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  12228. if m.removedcontact_relationships == nil {
  12229. m.removedcontact_relationships = make(map[uint64]struct{})
  12230. }
  12231. for i := range ids {
  12232. delete(m.contact_relationships, ids[i])
  12233. m.removedcontact_relationships[ids[i]] = struct{}{}
  12234. }
  12235. }
  12236. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  12237. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  12238. for id := range m.removedcontact_relationships {
  12239. ids = append(ids, id)
  12240. }
  12241. return
  12242. }
  12243. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  12244. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  12245. for id := range m.contact_relationships {
  12246. ids = append(ids, id)
  12247. }
  12248. return
  12249. }
  12250. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  12251. func (m *ContactMutation) ResetContactRelationships() {
  12252. m.contact_relationships = nil
  12253. m.clearedcontact_relationships = false
  12254. m.removedcontact_relationships = nil
  12255. }
  12256. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  12257. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  12258. if m.contact_fields == nil {
  12259. m.contact_fields = make(map[uint64]struct{})
  12260. }
  12261. for i := range ids {
  12262. m.contact_fields[ids[i]] = struct{}{}
  12263. }
  12264. }
  12265. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  12266. func (m *ContactMutation) ClearContactFields() {
  12267. m.clearedcontact_fields = true
  12268. }
  12269. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  12270. func (m *ContactMutation) ContactFieldsCleared() bool {
  12271. return m.clearedcontact_fields
  12272. }
  12273. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  12274. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  12275. if m.removedcontact_fields == nil {
  12276. m.removedcontact_fields = make(map[uint64]struct{})
  12277. }
  12278. for i := range ids {
  12279. delete(m.contact_fields, ids[i])
  12280. m.removedcontact_fields[ids[i]] = struct{}{}
  12281. }
  12282. }
  12283. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  12284. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  12285. for id := range m.removedcontact_fields {
  12286. ids = append(ids, id)
  12287. }
  12288. return
  12289. }
  12290. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  12291. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  12292. for id := range m.contact_fields {
  12293. ids = append(ids, id)
  12294. }
  12295. return
  12296. }
  12297. // ResetContactFields resets all changes to the "contact_fields" edge.
  12298. func (m *ContactMutation) ResetContactFields() {
  12299. m.contact_fields = nil
  12300. m.clearedcontact_fields = false
  12301. m.removedcontact_fields = nil
  12302. }
  12303. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  12304. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  12305. if m.contact_messages == nil {
  12306. m.contact_messages = make(map[uint64]struct{})
  12307. }
  12308. for i := range ids {
  12309. m.contact_messages[ids[i]] = struct{}{}
  12310. }
  12311. }
  12312. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  12313. func (m *ContactMutation) ClearContactMessages() {
  12314. m.clearedcontact_messages = true
  12315. }
  12316. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  12317. func (m *ContactMutation) ContactMessagesCleared() bool {
  12318. return m.clearedcontact_messages
  12319. }
  12320. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  12321. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  12322. if m.removedcontact_messages == nil {
  12323. m.removedcontact_messages = make(map[uint64]struct{})
  12324. }
  12325. for i := range ids {
  12326. delete(m.contact_messages, ids[i])
  12327. m.removedcontact_messages[ids[i]] = struct{}{}
  12328. }
  12329. }
  12330. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  12331. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  12332. for id := range m.removedcontact_messages {
  12333. ids = append(ids, id)
  12334. }
  12335. return
  12336. }
  12337. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  12338. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  12339. for id := range m.contact_messages {
  12340. ids = append(ids, id)
  12341. }
  12342. return
  12343. }
  12344. // ResetContactMessages resets all changes to the "contact_messages" edge.
  12345. func (m *ContactMutation) ResetContactMessages() {
  12346. m.contact_messages = nil
  12347. m.clearedcontact_messages = false
  12348. m.removedcontact_messages = nil
  12349. }
  12350. // Where appends a list predicates to the ContactMutation builder.
  12351. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  12352. m.predicates = append(m.predicates, ps...)
  12353. }
  12354. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  12355. // users can use type-assertion to append predicates that do not depend on any generated package.
  12356. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  12357. p := make([]predicate.Contact, len(ps))
  12358. for i := range ps {
  12359. p[i] = ps[i]
  12360. }
  12361. m.Where(p...)
  12362. }
  12363. // Op returns the operation name.
  12364. func (m *ContactMutation) Op() Op {
  12365. return m.op
  12366. }
  12367. // SetOp allows setting the mutation operation.
  12368. func (m *ContactMutation) SetOp(op Op) {
  12369. m.op = op
  12370. }
  12371. // Type returns the node type of this mutation (Contact).
  12372. func (m *ContactMutation) Type() string {
  12373. return m.typ
  12374. }
  12375. // Fields returns all fields that were changed during this mutation. Note that in
  12376. // order to get all numeric fields that were incremented/decremented, call
  12377. // AddedFields().
  12378. func (m *ContactMutation) Fields() []string {
  12379. fields := make([]string, 0, 30)
  12380. if m.created_at != nil {
  12381. fields = append(fields, contact.FieldCreatedAt)
  12382. }
  12383. if m.updated_at != nil {
  12384. fields = append(fields, contact.FieldUpdatedAt)
  12385. }
  12386. if m.status != nil {
  12387. fields = append(fields, contact.FieldStatus)
  12388. }
  12389. if m.deleted_at != nil {
  12390. fields = append(fields, contact.FieldDeletedAt)
  12391. }
  12392. if m.wx_wxid != nil {
  12393. fields = append(fields, contact.FieldWxWxid)
  12394. }
  12395. if m._type != nil {
  12396. fields = append(fields, contact.FieldType)
  12397. }
  12398. if m.wxid != nil {
  12399. fields = append(fields, contact.FieldWxid)
  12400. }
  12401. if m.account != nil {
  12402. fields = append(fields, contact.FieldAccount)
  12403. }
  12404. if m.nickname != nil {
  12405. fields = append(fields, contact.FieldNickname)
  12406. }
  12407. if m.markname != nil {
  12408. fields = append(fields, contact.FieldMarkname)
  12409. }
  12410. if m.headimg != nil {
  12411. fields = append(fields, contact.FieldHeadimg)
  12412. }
  12413. if m.sex != nil {
  12414. fields = append(fields, contact.FieldSex)
  12415. }
  12416. if m.starrole != nil {
  12417. fields = append(fields, contact.FieldStarrole)
  12418. }
  12419. if m.dontseeit != nil {
  12420. fields = append(fields, contact.FieldDontseeit)
  12421. }
  12422. if m.dontseeme != nil {
  12423. fields = append(fields, contact.FieldDontseeme)
  12424. }
  12425. if m.lag != nil {
  12426. fields = append(fields, contact.FieldLag)
  12427. }
  12428. if m.gid != nil {
  12429. fields = append(fields, contact.FieldGid)
  12430. }
  12431. if m.gname != nil {
  12432. fields = append(fields, contact.FieldGname)
  12433. }
  12434. if m.v3 != nil {
  12435. fields = append(fields, contact.FieldV3)
  12436. }
  12437. if m.organization_id != nil {
  12438. fields = append(fields, contact.FieldOrganizationID)
  12439. }
  12440. if m.ctype != nil {
  12441. fields = append(fields, contact.FieldCtype)
  12442. }
  12443. if m.cage != nil {
  12444. fields = append(fields, contact.FieldCage)
  12445. }
  12446. if m.cname != nil {
  12447. fields = append(fields, contact.FieldCname)
  12448. }
  12449. if m.carea != nil {
  12450. fields = append(fields, contact.FieldCarea)
  12451. }
  12452. if m.cbirthday != nil {
  12453. fields = append(fields, contact.FieldCbirthday)
  12454. }
  12455. if m.cbirtharea != nil {
  12456. fields = append(fields, contact.FieldCbirtharea)
  12457. }
  12458. if m.cidcard_no != nil {
  12459. fields = append(fields, contact.FieldCidcardNo)
  12460. }
  12461. if m.ctitle != nil {
  12462. fields = append(fields, contact.FieldCtitle)
  12463. }
  12464. if m.cc != nil {
  12465. fields = append(fields, contact.FieldCc)
  12466. }
  12467. if m.phone != nil {
  12468. fields = append(fields, contact.FieldPhone)
  12469. }
  12470. return fields
  12471. }
  12472. // Field returns the value of a field with the given name. The second boolean
  12473. // return value indicates that this field was not set, or was not defined in the
  12474. // schema.
  12475. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  12476. switch name {
  12477. case contact.FieldCreatedAt:
  12478. return m.CreatedAt()
  12479. case contact.FieldUpdatedAt:
  12480. return m.UpdatedAt()
  12481. case contact.FieldStatus:
  12482. return m.Status()
  12483. case contact.FieldDeletedAt:
  12484. return m.DeletedAt()
  12485. case contact.FieldWxWxid:
  12486. return m.WxWxid()
  12487. case contact.FieldType:
  12488. return m.GetType()
  12489. case contact.FieldWxid:
  12490. return m.Wxid()
  12491. case contact.FieldAccount:
  12492. return m.Account()
  12493. case contact.FieldNickname:
  12494. return m.Nickname()
  12495. case contact.FieldMarkname:
  12496. return m.Markname()
  12497. case contact.FieldHeadimg:
  12498. return m.Headimg()
  12499. case contact.FieldSex:
  12500. return m.Sex()
  12501. case contact.FieldStarrole:
  12502. return m.Starrole()
  12503. case contact.FieldDontseeit:
  12504. return m.Dontseeit()
  12505. case contact.FieldDontseeme:
  12506. return m.Dontseeme()
  12507. case contact.FieldLag:
  12508. return m.Lag()
  12509. case contact.FieldGid:
  12510. return m.Gid()
  12511. case contact.FieldGname:
  12512. return m.Gname()
  12513. case contact.FieldV3:
  12514. return m.V3()
  12515. case contact.FieldOrganizationID:
  12516. return m.OrganizationID()
  12517. case contact.FieldCtype:
  12518. return m.Ctype()
  12519. case contact.FieldCage:
  12520. return m.Cage()
  12521. case contact.FieldCname:
  12522. return m.Cname()
  12523. case contact.FieldCarea:
  12524. return m.Carea()
  12525. case contact.FieldCbirthday:
  12526. return m.Cbirthday()
  12527. case contact.FieldCbirtharea:
  12528. return m.Cbirtharea()
  12529. case contact.FieldCidcardNo:
  12530. return m.CidcardNo()
  12531. case contact.FieldCtitle:
  12532. return m.Ctitle()
  12533. case contact.FieldCc:
  12534. return m.Cc()
  12535. case contact.FieldPhone:
  12536. return m.Phone()
  12537. }
  12538. return nil, false
  12539. }
  12540. // OldField returns the old value of the field from the database. An error is
  12541. // returned if the mutation operation is not UpdateOne, or the query to the
  12542. // database failed.
  12543. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12544. switch name {
  12545. case contact.FieldCreatedAt:
  12546. return m.OldCreatedAt(ctx)
  12547. case contact.FieldUpdatedAt:
  12548. return m.OldUpdatedAt(ctx)
  12549. case contact.FieldStatus:
  12550. return m.OldStatus(ctx)
  12551. case contact.FieldDeletedAt:
  12552. return m.OldDeletedAt(ctx)
  12553. case contact.FieldWxWxid:
  12554. return m.OldWxWxid(ctx)
  12555. case contact.FieldType:
  12556. return m.OldType(ctx)
  12557. case contact.FieldWxid:
  12558. return m.OldWxid(ctx)
  12559. case contact.FieldAccount:
  12560. return m.OldAccount(ctx)
  12561. case contact.FieldNickname:
  12562. return m.OldNickname(ctx)
  12563. case contact.FieldMarkname:
  12564. return m.OldMarkname(ctx)
  12565. case contact.FieldHeadimg:
  12566. return m.OldHeadimg(ctx)
  12567. case contact.FieldSex:
  12568. return m.OldSex(ctx)
  12569. case contact.FieldStarrole:
  12570. return m.OldStarrole(ctx)
  12571. case contact.FieldDontseeit:
  12572. return m.OldDontseeit(ctx)
  12573. case contact.FieldDontseeme:
  12574. return m.OldDontseeme(ctx)
  12575. case contact.FieldLag:
  12576. return m.OldLag(ctx)
  12577. case contact.FieldGid:
  12578. return m.OldGid(ctx)
  12579. case contact.FieldGname:
  12580. return m.OldGname(ctx)
  12581. case contact.FieldV3:
  12582. return m.OldV3(ctx)
  12583. case contact.FieldOrganizationID:
  12584. return m.OldOrganizationID(ctx)
  12585. case contact.FieldCtype:
  12586. return m.OldCtype(ctx)
  12587. case contact.FieldCage:
  12588. return m.OldCage(ctx)
  12589. case contact.FieldCname:
  12590. return m.OldCname(ctx)
  12591. case contact.FieldCarea:
  12592. return m.OldCarea(ctx)
  12593. case contact.FieldCbirthday:
  12594. return m.OldCbirthday(ctx)
  12595. case contact.FieldCbirtharea:
  12596. return m.OldCbirtharea(ctx)
  12597. case contact.FieldCidcardNo:
  12598. return m.OldCidcardNo(ctx)
  12599. case contact.FieldCtitle:
  12600. return m.OldCtitle(ctx)
  12601. case contact.FieldCc:
  12602. return m.OldCc(ctx)
  12603. case contact.FieldPhone:
  12604. return m.OldPhone(ctx)
  12605. }
  12606. return nil, fmt.Errorf("unknown Contact field %s", name)
  12607. }
  12608. // SetField sets the value of a field with the given name. It returns an error if
  12609. // the field is not defined in the schema, or if the type mismatched the field
  12610. // type.
  12611. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  12612. switch name {
  12613. case contact.FieldCreatedAt:
  12614. v, ok := value.(time.Time)
  12615. if !ok {
  12616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12617. }
  12618. m.SetCreatedAt(v)
  12619. return nil
  12620. case contact.FieldUpdatedAt:
  12621. v, ok := value.(time.Time)
  12622. if !ok {
  12623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12624. }
  12625. m.SetUpdatedAt(v)
  12626. return nil
  12627. case contact.FieldStatus:
  12628. v, ok := value.(uint8)
  12629. if !ok {
  12630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12631. }
  12632. m.SetStatus(v)
  12633. return nil
  12634. case contact.FieldDeletedAt:
  12635. v, ok := value.(time.Time)
  12636. if !ok {
  12637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12638. }
  12639. m.SetDeletedAt(v)
  12640. return nil
  12641. case contact.FieldWxWxid:
  12642. v, ok := value.(string)
  12643. if !ok {
  12644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12645. }
  12646. m.SetWxWxid(v)
  12647. return nil
  12648. case contact.FieldType:
  12649. v, ok := value.(int)
  12650. if !ok {
  12651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12652. }
  12653. m.SetType(v)
  12654. return nil
  12655. case contact.FieldWxid:
  12656. v, ok := value.(string)
  12657. if !ok {
  12658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12659. }
  12660. m.SetWxid(v)
  12661. return nil
  12662. case contact.FieldAccount:
  12663. v, ok := value.(string)
  12664. if !ok {
  12665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12666. }
  12667. m.SetAccount(v)
  12668. return nil
  12669. case contact.FieldNickname:
  12670. v, ok := value.(string)
  12671. if !ok {
  12672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12673. }
  12674. m.SetNickname(v)
  12675. return nil
  12676. case contact.FieldMarkname:
  12677. v, ok := value.(string)
  12678. if !ok {
  12679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12680. }
  12681. m.SetMarkname(v)
  12682. return nil
  12683. case contact.FieldHeadimg:
  12684. v, ok := value.(string)
  12685. if !ok {
  12686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12687. }
  12688. m.SetHeadimg(v)
  12689. return nil
  12690. case contact.FieldSex:
  12691. v, ok := value.(int)
  12692. if !ok {
  12693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12694. }
  12695. m.SetSex(v)
  12696. return nil
  12697. case contact.FieldStarrole:
  12698. v, ok := value.(string)
  12699. if !ok {
  12700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12701. }
  12702. m.SetStarrole(v)
  12703. return nil
  12704. case contact.FieldDontseeit:
  12705. v, ok := value.(int)
  12706. if !ok {
  12707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12708. }
  12709. m.SetDontseeit(v)
  12710. return nil
  12711. case contact.FieldDontseeme:
  12712. v, ok := value.(int)
  12713. if !ok {
  12714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12715. }
  12716. m.SetDontseeme(v)
  12717. return nil
  12718. case contact.FieldLag:
  12719. v, ok := value.(string)
  12720. if !ok {
  12721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12722. }
  12723. m.SetLag(v)
  12724. return nil
  12725. case contact.FieldGid:
  12726. v, ok := value.(string)
  12727. if !ok {
  12728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12729. }
  12730. m.SetGid(v)
  12731. return nil
  12732. case contact.FieldGname:
  12733. v, ok := value.(string)
  12734. if !ok {
  12735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12736. }
  12737. m.SetGname(v)
  12738. return nil
  12739. case contact.FieldV3:
  12740. v, ok := value.(string)
  12741. if !ok {
  12742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12743. }
  12744. m.SetV3(v)
  12745. return nil
  12746. case contact.FieldOrganizationID:
  12747. v, ok := value.(uint64)
  12748. if !ok {
  12749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12750. }
  12751. m.SetOrganizationID(v)
  12752. return nil
  12753. case contact.FieldCtype:
  12754. v, ok := value.(uint64)
  12755. if !ok {
  12756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12757. }
  12758. m.SetCtype(v)
  12759. return nil
  12760. case contact.FieldCage:
  12761. v, ok := value.(int)
  12762. if !ok {
  12763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12764. }
  12765. m.SetCage(v)
  12766. return nil
  12767. case contact.FieldCname:
  12768. v, ok := value.(string)
  12769. if !ok {
  12770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12771. }
  12772. m.SetCname(v)
  12773. return nil
  12774. case contact.FieldCarea:
  12775. v, ok := value.(string)
  12776. if !ok {
  12777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12778. }
  12779. m.SetCarea(v)
  12780. return nil
  12781. case contact.FieldCbirthday:
  12782. v, ok := value.(string)
  12783. if !ok {
  12784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12785. }
  12786. m.SetCbirthday(v)
  12787. return nil
  12788. case contact.FieldCbirtharea:
  12789. v, ok := value.(string)
  12790. if !ok {
  12791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12792. }
  12793. m.SetCbirtharea(v)
  12794. return nil
  12795. case contact.FieldCidcardNo:
  12796. v, ok := value.(string)
  12797. if !ok {
  12798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12799. }
  12800. m.SetCidcardNo(v)
  12801. return nil
  12802. case contact.FieldCtitle:
  12803. v, ok := value.(string)
  12804. if !ok {
  12805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12806. }
  12807. m.SetCtitle(v)
  12808. return nil
  12809. case contact.FieldCc:
  12810. v, ok := value.(string)
  12811. if !ok {
  12812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12813. }
  12814. m.SetCc(v)
  12815. return nil
  12816. case contact.FieldPhone:
  12817. v, ok := value.(string)
  12818. if !ok {
  12819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12820. }
  12821. m.SetPhone(v)
  12822. return nil
  12823. }
  12824. return fmt.Errorf("unknown Contact field %s", name)
  12825. }
  12826. // AddedFields returns all numeric fields that were incremented/decremented during
  12827. // this mutation.
  12828. func (m *ContactMutation) AddedFields() []string {
  12829. var fields []string
  12830. if m.addstatus != nil {
  12831. fields = append(fields, contact.FieldStatus)
  12832. }
  12833. if m.add_type != nil {
  12834. fields = append(fields, contact.FieldType)
  12835. }
  12836. if m.addsex != nil {
  12837. fields = append(fields, contact.FieldSex)
  12838. }
  12839. if m.adddontseeit != nil {
  12840. fields = append(fields, contact.FieldDontseeit)
  12841. }
  12842. if m.adddontseeme != nil {
  12843. fields = append(fields, contact.FieldDontseeme)
  12844. }
  12845. if m.addorganization_id != nil {
  12846. fields = append(fields, contact.FieldOrganizationID)
  12847. }
  12848. if m.addctype != nil {
  12849. fields = append(fields, contact.FieldCtype)
  12850. }
  12851. if m.addcage != nil {
  12852. fields = append(fields, contact.FieldCage)
  12853. }
  12854. return fields
  12855. }
  12856. // AddedField returns the numeric value that was incremented/decremented on a field
  12857. // with the given name. The second boolean return value indicates that this field
  12858. // was not set, or was not defined in the schema.
  12859. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12860. switch name {
  12861. case contact.FieldStatus:
  12862. return m.AddedStatus()
  12863. case contact.FieldType:
  12864. return m.AddedType()
  12865. case contact.FieldSex:
  12866. return m.AddedSex()
  12867. case contact.FieldDontseeit:
  12868. return m.AddedDontseeit()
  12869. case contact.FieldDontseeme:
  12870. return m.AddedDontseeme()
  12871. case contact.FieldOrganizationID:
  12872. return m.AddedOrganizationID()
  12873. case contact.FieldCtype:
  12874. return m.AddedCtype()
  12875. case contact.FieldCage:
  12876. return m.AddedCage()
  12877. }
  12878. return nil, false
  12879. }
  12880. // AddField adds the value to the field with the given name. It returns an error if
  12881. // the field is not defined in the schema, or if the type mismatched the field
  12882. // type.
  12883. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12884. switch name {
  12885. case contact.FieldStatus:
  12886. v, ok := value.(int8)
  12887. if !ok {
  12888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12889. }
  12890. m.AddStatus(v)
  12891. return nil
  12892. case contact.FieldType:
  12893. v, ok := value.(int)
  12894. if !ok {
  12895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12896. }
  12897. m.AddType(v)
  12898. return nil
  12899. case contact.FieldSex:
  12900. v, ok := value.(int)
  12901. if !ok {
  12902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12903. }
  12904. m.AddSex(v)
  12905. return nil
  12906. case contact.FieldDontseeit:
  12907. v, ok := value.(int)
  12908. if !ok {
  12909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12910. }
  12911. m.AddDontseeit(v)
  12912. return nil
  12913. case contact.FieldDontseeme:
  12914. v, ok := value.(int)
  12915. if !ok {
  12916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12917. }
  12918. m.AddDontseeme(v)
  12919. return nil
  12920. case contact.FieldOrganizationID:
  12921. v, ok := value.(int64)
  12922. if !ok {
  12923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12924. }
  12925. m.AddOrganizationID(v)
  12926. return nil
  12927. case contact.FieldCtype:
  12928. v, ok := value.(int64)
  12929. if !ok {
  12930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12931. }
  12932. m.AddCtype(v)
  12933. return nil
  12934. case contact.FieldCage:
  12935. v, ok := value.(int)
  12936. if !ok {
  12937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12938. }
  12939. m.AddCage(v)
  12940. return nil
  12941. }
  12942. return fmt.Errorf("unknown Contact numeric field %s", name)
  12943. }
  12944. // ClearedFields returns all nullable fields that were cleared during this
  12945. // mutation.
  12946. func (m *ContactMutation) ClearedFields() []string {
  12947. var fields []string
  12948. if m.FieldCleared(contact.FieldStatus) {
  12949. fields = append(fields, contact.FieldStatus)
  12950. }
  12951. if m.FieldCleared(contact.FieldDeletedAt) {
  12952. fields = append(fields, contact.FieldDeletedAt)
  12953. }
  12954. if m.FieldCleared(contact.FieldType) {
  12955. fields = append(fields, contact.FieldType)
  12956. }
  12957. if m.FieldCleared(contact.FieldOrganizationID) {
  12958. fields = append(fields, contact.FieldOrganizationID)
  12959. }
  12960. return fields
  12961. }
  12962. // FieldCleared returns a boolean indicating if a field with the given name was
  12963. // cleared in this mutation.
  12964. func (m *ContactMutation) FieldCleared(name string) bool {
  12965. _, ok := m.clearedFields[name]
  12966. return ok
  12967. }
  12968. // ClearField clears the value of the field with the given name. It returns an
  12969. // error if the field is not defined in the schema.
  12970. func (m *ContactMutation) ClearField(name string) error {
  12971. switch name {
  12972. case contact.FieldStatus:
  12973. m.ClearStatus()
  12974. return nil
  12975. case contact.FieldDeletedAt:
  12976. m.ClearDeletedAt()
  12977. return nil
  12978. case contact.FieldType:
  12979. m.ClearType()
  12980. return nil
  12981. case contact.FieldOrganizationID:
  12982. m.ClearOrganizationID()
  12983. return nil
  12984. }
  12985. return fmt.Errorf("unknown Contact nullable field %s", name)
  12986. }
  12987. // ResetField resets all changes in the mutation for the field with the given name.
  12988. // It returns an error if the field is not defined in the schema.
  12989. func (m *ContactMutation) ResetField(name string) error {
  12990. switch name {
  12991. case contact.FieldCreatedAt:
  12992. m.ResetCreatedAt()
  12993. return nil
  12994. case contact.FieldUpdatedAt:
  12995. m.ResetUpdatedAt()
  12996. return nil
  12997. case contact.FieldStatus:
  12998. m.ResetStatus()
  12999. return nil
  13000. case contact.FieldDeletedAt:
  13001. m.ResetDeletedAt()
  13002. return nil
  13003. case contact.FieldWxWxid:
  13004. m.ResetWxWxid()
  13005. return nil
  13006. case contact.FieldType:
  13007. m.ResetType()
  13008. return nil
  13009. case contact.FieldWxid:
  13010. m.ResetWxid()
  13011. return nil
  13012. case contact.FieldAccount:
  13013. m.ResetAccount()
  13014. return nil
  13015. case contact.FieldNickname:
  13016. m.ResetNickname()
  13017. return nil
  13018. case contact.FieldMarkname:
  13019. m.ResetMarkname()
  13020. return nil
  13021. case contact.FieldHeadimg:
  13022. m.ResetHeadimg()
  13023. return nil
  13024. case contact.FieldSex:
  13025. m.ResetSex()
  13026. return nil
  13027. case contact.FieldStarrole:
  13028. m.ResetStarrole()
  13029. return nil
  13030. case contact.FieldDontseeit:
  13031. m.ResetDontseeit()
  13032. return nil
  13033. case contact.FieldDontseeme:
  13034. m.ResetDontseeme()
  13035. return nil
  13036. case contact.FieldLag:
  13037. m.ResetLag()
  13038. return nil
  13039. case contact.FieldGid:
  13040. m.ResetGid()
  13041. return nil
  13042. case contact.FieldGname:
  13043. m.ResetGname()
  13044. return nil
  13045. case contact.FieldV3:
  13046. m.ResetV3()
  13047. return nil
  13048. case contact.FieldOrganizationID:
  13049. m.ResetOrganizationID()
  13050. return nil
  13051. case contact.FieldCtype:
  13052. m.ResetCtype()
  13053. return nil
  13054. case contact.FieldCage:
  13055. m.ResetCage()
  13056. return nil
  13057. case contact.FieldCname:
  13058. m.ResetCname()
  13059. return nil
  13060. case contact.FieldCarea:
  13061. m.ResetCarea()
  13062. return nil
  13063. case contact.FieldCbirthday:
  13064. m.ResetCbirthday()
  13065. return nil
  13066. case contact.FieldCbirtharea:
  13067. m.ResetCbirtharea()
  13068. return nil
  13069. case contact.FieldCidcardNo:
  13070. m.ResetCidcardNo()
  13071. return nil
  13072. case contact.FieldCtitle:
  13073. m.ResetCtitle()
  13074. return nil
  13075. case contact.FieldCc:
  13076. m.ResetCc()
  13077. return nil
  13078. case contact.FieldPhone:
  13079. m.ResetPhone()
  13080. return nil
  13081. }
  13082. return fmt.Errorf("unknown Contact field %s", name)
  13083. }
  13084. // AddedEdges returns all edge names that were set/added in this mutation.
  13085. func (m *ContactMutation) AddedEdges() []string {
  13086. edges := make([]string, 0, 3)
  13087. if m.contact_relationships != nil {
  13088. edges = append(edges, contact.EdgeContactRelationships)
  13089. }
  13090. if m.contact_fields != nil {
  13091. edges = append(edges, contact.EdgeContactFields)
  13092. }
  13093. if m.contact_messages != nil {
  13094. edges = append(edges, contact.EdgeContactMessages)
  13095. }
  13096. return edges
  13097. }
  13098. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13099. // name in this mutation.
  13100. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  13101. switch name {
  13102. case contact.EdgeContactRelationships:
  13103. ids := make([]ent.Value, 0, len(m.contact_relationships))
  13104. for id := range m.contact_relationships {
  13105. ids = append(ids, id)
  13106. }
  13107. return ids
  13108. case contact.EdgeContactFields:
  13109. ids := make([]ent.Value, 0, len(m.contact_fields))
  13110. for id := range m.contact_fields {
  13111. ids = append(ids, id)
  13112. }
  13113. return ids
  13114. case contact.EdgeContactMessages:
  13115. ids := make([]ent.Value, 0, len(m.contact_messages))
  13116. for id := range m.contact_messages {
  13117. ids = append(ids, id)
  13118. }
  13119. return ids
  13120. }
  13121. return nil
  13122. }
  13123. // RemovedEdges returns all edge names that were removed in this mutation.
  13124. func (m *ContactMutation) RemovedEdges() []string {
  13125. edges := make([]string, 0, 3)
  13126. if m.removedcontact_relationships != nil {
  13127. edges = append(edges, contact.EdgeContactRelationships)
  13128. }
  13129. if m.removedcontact_fields != nil {
  13130. edges = append(edges, contact.EdgeContactFields)
  13131. }
  13132. if m.removedcontact_messages != nil {
  13133. edges = append(edges, contact.EdgeContactMessages)
  13134. }
  13135. return edges
  13136. }
  13137. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13138. // the given name in this mutation.
  13139. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  13140. switch name {
  13141. case contact.EdgeContactRelationships:
  13142. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  13143. for id := range m.removedcontact_relationships {
  13144. ids = append(ids, id)
  13145. }
  13146. return ids
  13147. case contact.EdgeContactFields:
  13148. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  13149. for id := range m.removedcontact_fields {
  13150. ids = append(ids, id)
  13151. }
  13152. return ids
  13153. case contact.EdgeContactMessages:
  13154. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  13155. for id := range m.removedcontact_messages {
  13156. ids = append(ids, id)
  13157. }
  13158. return ids
  13159. }
  13160. return nil
  13161. }
  13162. // ClearedEdges returns all edge names that were cleared in this mutation.
  13163. func (m *ContactMutation) ClearedEdges() []string {
  13164. edges := make([]string, 0, 3)
  13165. if m.clearedcontact_relationships {
  13166. edges = append(edges, contact.EdgeContactRelationships)
  13167. }
  13168. if m.clearedcontact_fields {
  13169. edges = append(edges, contact.EdgeContactFields)
  13170. }
  13171. if m.clearedcontact_messages {
  13172. edges = append(edges, contact.EdgeContactMessages)
  13173. }
  13174. return edges
  13175. }
  13176. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13177. // was cleared in this mutation.
  13178. func (m *ContactMutation) EdgeCleared(name string) bool {
  13179. switch name {
  13180. case contact.EdgeContactRelationships:
  13181. return m.clearedcontact_relationships
  13182. case contact.EdgeContactFields:
  13183. return m.clearedcontact_fields
  13184. case contact.EdgeContactMessages:
  13185. return m.clearedcontact_messages
  13186. }
  13187. return false
  13188. }
  13189. // ClearEdge clears the value of the edge with the given name. It returns an error
  13190. // if that edge is not defined in the schema.
  13191. func (m *ContactMutation) ClearEdge(name string) error {
  13192. switch name {
  13193. }
  13194. return fmt.Errorf("unknown Contact unique edge %s", name)
  13195. }
  13196. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13197. // It returns an error if the edge is not defined in the schema.
  13198. func (m *ContactMutation) ResetEdge(name string) error {
  13199. switch name {
  13200. case contact.EdgeContactRelationships:
  13201. m.ResetContactRelationships()
  13202. return nil
  13203. case contact.EdgeContactFields:
  13204. m.ResetContactFields()
  13205. return nil
  13206. case contact.EdgeContactMessages:
  13207. m.ResetContactMessages()
  13208. return nil
  13209. }
  13210. return fmt.Errorf("unknown Contact edge %s", name)
  13211. }
  13212. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  13213. type ContactFieldMutation struct {
  13214. config
  13215. op Op
  13216. typ string
  13217. id *uint64
  13218. created_at *time.Time
  13219. updated_at *time.Time
  13220. status *uint8
  13221. addstatus *int8
  13222. deleted_at *time.Time
  13223. form_id *string
  13224. value *[]string
  13225. appendvalue []string
  13226. clearedFields map[string]struct{}
  13227. field_contact *uint64
  13228. clearedfield_contact bool
  13229. done bool
  13230. oldValue func(context.Context) (*ContactField, error)
  13231. predicates []predicate.ContactField
  13232. }
  13233. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  13234. // contactfieldOption allows management of the mutation configuration using functional options.
  13235. type contactfieldOption func(*ContactFieldMutation)
  13236. // newContactFieldMutation creates new mutation for the ContactField entity.
  13237. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  13238. m := &ContactFieldMutation{
  13239. config: c,
  13240. op: op,
  13241. typ: TypeContactField,
  13242. clearedFields: make(map[string]struct{}),
  13243. }
  13244. for _, opt := range opts {
  13245. opt(m)
  13246. }
  13247. return m
  13248. }
  13249. // withContactFieldID sets the ID field of the mutation.
  13250. func withContactFieldID(id uint64) contactfieldOption {
  13251. return func(m *ContactFieldMutation) {
  13252. var (
  13253. err error
  13254. once sync.Once
  13255. value *ContactField
  13256. )
  13257. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  13258. once.Do(func() {
  13259. if m.done {
  13260. err = errors.New("querying old values post mutation is not allowed")
  13261. } else {
  13262. value, err = m.Client().ContactField.Get(ctx, id)
  13263. }
  13264. })
  13265. return value, err
  13266. }
  13267. m.id = &id
  13268. }
  13269. }
  13270. // withContactField sets the old ContactField of the mutation.
  13271. func withContactField(node *ContactField) contactfieldOption {
  13272. return func(m *ContactFieldMutation) {
  13273. m.oldValue = func(context.Context) (*ContactField, error) {
  13274. return node, nil
  13275. }
  13276. m.id = &node.ID
  13277. }
  13278. }
  13279. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13280. // executed in a transaction (ent.Tx), a transactional client is returned.
  13281. func (m ContactFieldMutation) Client() *Client {
  13282. client := &Client{config: m.config}
  13283. client.init()
  13284. return client
  13285. }
  13286. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13287. // it returns an error otherwise.
  13288. func (m ContactFieldMutation) Tx() (*Tx, error) {
  13289. if _, ok := m.driver.(*txDriver); !ok {
  13290. return nil, errors.New("ent: mutation is not running in a transaction")
  13291. }
  13292. tx := &Tx{config: m.config}
  13293. tx.init()
  13294. return tx, nil
  13295. }
  13296. // SetID sets the value of the id field. Note that this
  13297. // operation is only accepted on creation of ContactField entities.
  13298. func (m *ContactFieldMutation) SetID(id uint64) {
  13299. m.id = &id
  13300. }
  13301. // ID returns the ID value in the mutation. Note that the ID is only available
  13302. // if it was provided to the builder or after it was returned from the database.
  13303. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  13304. if m.id == nil {
  13305. return
  13306. }
  13307. return *m.id, true
  13308. }
  13309. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13310. // That means, if the mutation is applied within a transaction with an isolation level such
  13311. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13312. // or updated by the mutation.
  13313. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  13314. switch {
  13315. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13316. id, exists := m.ID()
  13317. if exists {
  13318. return []uint64{id}, nil
  13319. }
  13320. fallthrough
  13321. case m.op.Is(OpUpdate | OpDelete):
  13322. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  13323. default:
  13324. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13325. }
  13326. }
  13327. // SetCreatedAt sets the "created_at" field.
  13328. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  13329. m.created_at = &t
  13330. }
  13331. // CreatedAt returns the value of the "created_at" field in the mutation.
  13332. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  13333. v := m.created_at
  13334. if v == nil {
  13335. return
  13336. }
  13337. return *v, true
  13338. }
  13339. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  13340. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13342. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13343. if !m.op.Is(OpUpdateOne) {
  13344. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13345. }
  13346. if m.id == nil || m.oldValue == nil {
  13347. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13348. }
  13349. oldValue, err := m.oldValue(ctx)
  13350. if err != nil {
  13351. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13352. }
  13353. return oldValue.CreatedAt, nil
  13354. }
  13355. // ResetCreatedAt resets all changes to the "created_at" field.
  13356. func (m *ContactFieldMutation) ResetCreatedAt() {
  13357. m.created_at = nil
  13358. }
  13359. // SetUpdatedAt sets the "updated_at" field.
  13360. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  13361. m.updated_at = &t
  13362. }
  13363. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13364. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  13365. v := m.updated_at
  13366. if v == nil {
  13367. return
  13368. }
  13369. return *v, true
  13370. }
  13371. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  13372. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13374. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13375. if !m.op.Is(OpUpdateOne) {
  13376. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13377. }
  13378. if m.id == nil || m.oldValue == nil {
  13379. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13380. }
  13381. oldValue, err := m.oldValue(ctx)
  13382. if err != nil {
  13383. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13384. }
  13385. return oldValue.UpdatedAt, nil
  13386. }
  13387. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13388. func (m *ContactFieldMutation) ResetUpdatedAt() {
  13389. m.updated_at = nil
  13390. }
  13391. // SetStatus sets the "status" field.
  13392. func (m *ContactFieldMutation) SetStatus(u uint8) {
  13393. m.status = &u
  13394. m.addstatus = nil
  13395. }
  13396. // Status returns the value of the "status" field in the mutation.
  13397. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  13398. v := m.status
  13399. if v == nil {
  13400. return
  13401. }
  13402. return *v, true
  13403. }
  13404. // OldStatus returns the old "status" field's value of the ContactField entity.
  13405. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13407. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13408. if !m.op.Is(OpUpdateOne) {
  13409. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13410. }
  13411. if m.id == nil || m.oldValue == nil {
  13412. return v, errors.New("OldStatus requires an ID field in the mutation")
  13413. }
  13414. oldValue, err := m.oldValue(ctx)
  13415. if err != nil {
  13416. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13417. }
  13418. return oldValue.Status, nil
  13419. }
  13420. // AddStatus adds u to the "status" field.
  13421. func (m *ContactFieldMutation) AddStatus(u int8) {
  13422. if m.addstatus != nil {
  13423. *m.addstatus += u
  13424. } else {
  13425. m.addstatus = &u
  13426. }
  13427. }
  13428. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13429. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  13430. v := m.addstatus
  13431. if v == nil {
  13432. return
  13433. }
  13434. return *v, true
  13435. }
  13436. // ClearStatus clears the value of the "status" field.
  13437. func (m *ContactFieldMutation) ClearStatus() {
  13438. m.status = nil
  13439. m.addstatus = nil
  13440. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  13441. }
  13442. // StatusCleared returns if the "status" field was cleared in this mutation.
  13443. func (m *ContactFieldMutation) StatusCleared() bool {
  13444. _, ok := m.clearedFields[contactfield.FieldStatus]
  13445. return ok
  13446. }
  13447. // ResetStatus resets all changes to the "status" field.
  13448. func (m *ContactFieldMutation) ResetStatus() {
  13449. m.status = nil
  13450. m.addstatus = nil
  13451. delete(m.clearedFields, contactfield.FieldStatus)
  13452. }
  13453. // SetDeletedAt sets the "deleted_at" field.
  13454. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  13455. m.deleted_at = &t
  13456. }
  13457. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13458. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  13459. v := m.deleted_at
  13460. if v == nil {
  13461. return
  13462. }
  13463. return *v, true
  13464. }
  13465. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  13466. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13468. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13469. if !m.op.Is(OpUpdateOne) {
  13470. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13471. }
  13472. if m.id == nil || m.oldValue == nil {
  13473. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13474. }
  13475. oldValue, err := m.oldValue(ctx)
  13476. if err != nil {
  13477. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13478. }
  13479. return oldValue.DeletedAt, nil
  13480. }
  13481. // ClearDeletedAt clears the value of the "deleted_at" field.
  13482. func (m *ContactFieldMutation) ClearDeletedAt() {
  13483. m.deleted_at = nil
  13484. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  13485. }
  13486. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13487. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  13488. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  13489. return ok
  13490. }
  13491. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13492. func (m *ContactFieldMutation) ResetDeletedAt() {
  13493. m.deleted_at = nil
  13494. delete(m.clearedFields, contactfield.FieldDeletedAt)
  13495. }
  13496. // SetContactID sets the "contact_id" field.
  13497. func (m *ContactFieldMutation) SetContactID(u uint64) {
  13498. m.field_contact = &u
  13499. }
  13500. // ContactID returns the value of the "contact_id" field in the mutation.
  13501. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  13502. v := m.field_contact
  13503. if v == nil {
  13504. return
  13505. }
  13506. return *v, true
  13507. }
  13508. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  13509. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13511. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  13512. if !m.op.Is(OpUpdateOne) {
  13513. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  13514. }
  13515. if m.id == nil || m.oldValue == nil {
  13516. return v, errors.New("OldContactID requires an ID field in the mutation")
  13517. }
  13518. oldValue, err := m.oldValue(ctx)
  13519. if err != nil {
  13520. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  13521. }
  13522. return oldValue.ContactID, nil
  13523. }
  13524. // ResetContactID resets all changes to the "contact_id" field.
  13525. func (m *ContactFieldMutation) ResetContactID() {
  13526. m.field_contact = nil
  13527. }
  13528. // SetFormID sets the "form_id" field.
  13529. func (m *ContactFieldMutation) SetFormID(s string) {
  13530. m.form_id = &s
  13531. }
  13532. // FormID returns the value of the "form_id" field in the mutation.
  13533. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  13534. v := m.form_id
  13535. if v == nil {
  13536. return
  13537. }
  13538. return *v, true
  13539. }
  13540. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  13541. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13543. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  13544. if !m.op.Is(OpUpdateOne) {
  13545. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  13546. }
  13547. if m.id == nil || m.oldValue == nil {
  13548. return v, errors.New("OldFormID requires an ID field in the mutation")
  13549. }
  13550. oldValue, err := m.oldValue(ctx)
  13551. if err != nil {
  13552. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  13553. }
  13554. return oldValue.FormID, nil
  13555. }
  13556. // ResetFormID resets all changes to the "form_id" field.
  13557. func (m *ContactFieldMutation) ResetFormID() {
  13558. m.form_id = nil
  13559. }
  13560. // SetValue sets the "value" field.
  13561. func (m *ContactFieldMutation) SetValue(s []string) {
  13562. m.value = &s
  13563. m.appendvalue = nil
  13564. }
  13565. // Value returns the value of the "value" field in the mutation.
  13566. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  13567. v := m.value
  13568. if v == nil {
  13569. return
  13570. }
  13571. return *v, true
  13572. }
  13573. // OldValue returns the old "value" field's value of the ContactField entity.
  13574. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  13575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13576. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  13577. if !m.op.Is(OpUpdateOne) {
  13578. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  13579. }
  13580. if m.id == nil || m.oldValue == nil {
  13581. return v, errors.New("OldValue requires an ID field in the mutation")
  13582. }
  13583. oldValue, err := m.oldValue(ctx)
  13584. if err != nil {
  13585. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  13586. }
  13587. return oldValue.Value, nil
  13588. }
  13589. // AppendValue adds s to the "value" field.
  13590. func (m *ContactFieldMutation) AppendValue(s []string) {
  13591. m.appendvalue = append(m.appendvalue, s...)
  13592. }
  13593. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  13594. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  13595. if len(m.appendvalue) == 0 {
  13596. return nil, false
  13597. }
  13598. return m.appendvalue, true
  13599. }
  13600. // ResetValue resets all changes to the "value" field.
  13601. func (m *ContactFieldMutation) ResetValue() {
  13602. m.value = nil
  13603. m.appendvalue = nil
  13604. }
  13605. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  13606. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  13607. m.field_contact = &id
  13608. }
  13609. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  13610. func (m *ContactFieldMutation) ClearFieldContact() {
  13611. m.clearedfield_contact = true
  13612. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  13613. }
  13614. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  13615. func (m *ContactFieldMutation) FieldContactCleared() bool {
  13616. return m.clearedfield_contact
  13617. }
  13618. // FieldContactID returns the "field_contact" edge ID in the mutation.
  13619. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  13620. if m.field_contact != nil {
  13621. return *m.field_contact, true
  13622. }
  13623. return
  13624. }
  13625. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  13626. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  13627. // FieldContactID instead. It exists only for internal usage by the builders.
  13628. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  13629. if id := m.field_contact; id != nil {
  13630. ids = append(ids, *id)
  13631. }
  13632. return
  13633. }
  13634. // ResetFieldContact resets all changes to the "field_contact" edge.
  13635. func (m *ContactFieldMutation) ResetFieldContact() {
  13636. m.field_contact = nil
  13637. m.clearedfield_contact = false
  13638. }
  13639. // Where appends a list predicates to the ContactFieldMutation builder.
  13640. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  13641. m.predicates = append(m.predicates, ps...)
  13642. }
  13643. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  13644. // users can use type-assertion to append predicates that do not depend on any generated package.
  13645. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  13646. p := make([]predicate.ContactField, len(ps))
  13647. for i := range ps {
  13648. p[i] = ps[i]
  13649. }
  13650. m.Where(p...)
  13651. }
  13652. // Op returns the operation name.
  13653. func (m *ContactFieldMutation) Op() Op {
  13654. return m.op
  13655. }
  13656. // SetOp allows setting the mutation operation.
  13657. func (m *ContactFieldMutation) SetOp(op Op) {
  13658. m.op = op
  13659. }
  13660. // Type returns the node type of this mutation (ContactField).
  13661. func (m *ContactFieldMutation) Type() string {
  13662. return m.typ
  13663. }
  13664. // Fields returns all fields that were changed during this mutation. Note that in
  13665. // order to get all numeric fields that were incremented/decremented, call
  13666. // AddedFields().
  13667. func (m *ContactFieldMutation) Fields() []string {
  13668. fields := make([]string, 0, 7)
  13669. if m.created_at != nil {
  13670. fields = append(fields, contactfield.FieldCreatedAt)
  13671. }
  13672. if m.updated_at != nil {
  13673. fields = append(fields, contactfield.FieldUpdatedAt)
  13674. }
  13675. if m.status != nil {
  13676. fields = append(fields, contactfield.FieldStatus)
  13677. }
  13678. if m.deleted_at != nil {
  13679. fields = append(fields, contactfield.FieldDeletedAt)
  13680. }
  13681. if m.field_contact != nil {
  13682. fields = append(fields, contactfield.FieldContactID)
  13683. }
  13684. if m.form_id != nil {
  13685. fields = append(fields, contactfield.FieldFormID)
  13686. }
  13687. if m.value != nil {
  13688. fields = append(fields, contactfield.FieldValue)
  13689. }
  13690. return fields
  13691. }
  13692. // Field returns the value of a field with the given name. The second boolean
  13693. // return value indicates that this field was not set, or was not defined in the
  13694. // schema.
  13695. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  13696. switch name {
  13697. case contactfield.FieldCreatedAt:
  13698. return m.CreatedAt()
  13699. case contactfield.FieldUpdatedAt:
  13700. return m.UpdatedAt()
  13701. case contactfield.FieldStatus:
  13702. return m.Status()
  13703. case contactfield.FieldDeletedAt:
  13704. return m.DeletedAt()
  13705. case contactfield.FieldContactID:
  13706. return m.ContactID()
  13707. case contactfield.FieldFormID:
  13708. return m.FormID()
  13709. case contactfield.FieldValue:
  13710. return m.Value()
  13711. }
  13712. return nil, false
  13713. }
  13714. // OldField returns the old value of the field from the database. An error is
  13715. // returned if the mutation operation is not UpdateOne, or the query to the
  13716. // database failed.
  13717. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13718. switch name {
  13719. case contactfield.FieldCreatedAt:
  13720. return m.OldCreatedAt(ctx)
  13721. case contactfield.FieldUpdatedAt:
  13722. return m.OldUpdatedAt(ctx)
  13723. case contactfield.FieldStatus:
  13724. return m.OldStatus(ctx)
  13725. case contactfield.FieldDeletedAt:
  13726. return m.OldDeletedAt(ctx)
  13727. case contactfield.FieldContactID:
  13728. return m.OldContactID(ctx)
  13729. case contactfield.FieldFormID:
  13730. return m.OldFormID(ctx)
  13731. case contactfield.FieldValue:
  13732. return m.OldValue(ctx)
  13733. }
  13734. return nil, fmt.Errorf("unknown ContactField field %s", name)
  13735. }
  13736. // SetField sets the value of a field with the given name. It returns an error if
  13737. // the field is not defined in the schema, or if the type mismatched the field
  13738. // type.
  13739. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  13740. switch name {
  13741. case contactfield.FieldCreatedAt:
  13742. v, ok := value.(time.Time)
  13743. if !ok {
  13744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13745. }
  13746. m.SetCreatedAt(v)
  13747. return nil
  13748. case contactfield.FieldUpdatedAt:
  13749. v, ok := value.(time.Time)
  13750. if !ok {
  13751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13752. }
  13753. m.SetUpdatedAt(v)
  13754. return nil
  13755. case contactfield.FieldStatus:
  13756. v, ok := value.(uint8)
  13757. if !ok {
  13758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13759. }
  13760. m.SetStatus(v)
  13761. return nil
  13762. case contactfield.FieldDeletedAt:
  13763. v, ok := value.(time.Time)
  13764. if !ok {
  13765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13766. }
  13767. m.SetDeletedAt(v)
  13768. return nil
  13769. case contactfield.FieldContactID:
  13770. v, ok := value.(uint64)
  13771. if !ok {
  13772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13773. }
  13774. m.SetContactID(v)
  13775. return nil
  13776. case contactfield.FieldFormID:
  13777. v, ok := value.(string)
  13778. if !ok {
  13779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13780. }
  13781. m.SetFormID(v)
  13782. return nil
  13783. case contactfield.FieldValue:
  13784. v, ok := value.([]string)
  13785. if !ok {
  13786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13787. }
  13788. m.SetValue(v)
  13789. return nil
  13790. }
  13791. return fmt.Errorf("unknown ContactField field %s", name)
  13792. }
  13793. // AddedFields returns all numeric fields that were incremented/decremented during
  13794. // this mutation.
  13795. func (m *ContactFieldMutation) AddedFields() []string {
  13796. var fields []string
  13797. if m.addstatus != nil {
  13798. fields = append(fields, contactfield.FieldStatus)
  13799. }
  13800. return fields
  13801. }
  13802. // AddedField returns the numeric value that was incremented/decremented on a field
  13803. // with the given name. The second boolean return value indicates that this field
  13804. // was not set, or was not defined in the schema.
  13805. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  13806. switch name {
  13807. case contactfield.FieldStatus:
  13808. return m.AddedStatus()
  13809. }
  13810. return nil, false
  13811. }
  13812. // AddField adds the value to the field with the given name. It returns an error if
  13813. // the field is not defined in the schema, or if the type mismatched the field
  13814. // type.
  13815. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  13816. switch name {
  13817. case contactfield.FieldStatus:
  13818. v, ok := value.(int8)
  13819. if !ok {
  13820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13821. }
  13822. m.AddStatus(v)
  13823. return nil
  13824. }
  13825. return fmt.Errorf("unknown ContactField numeric field %s", name)
  13826. }
  13827. // ClearedFields returns all nullable fields that were cleared during this
  13828. // mutation.
  13829. func (m *ContactFieldMutation) ClearedFields() []string {
  13830. var fields []string
  13831. if m.FieldCleared(contactfield.FieldStatus) {
  13832. fields = append(fields, contactfield.FieldStatus)
  13833. }
  13834. if m.FieldCleared(contactfield.FieldDeletedAt) {
  13835. fields = append(fields, contactfield.FieldDeletedAt)
  13836. }
  13837. return fields
  13838. }
  13839. // FieldCleared returns a boolean indicating if a field with the given name was
  13840. // cleared in this mutation.
  13841. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  13842. _, ok := m.clearedFields[name]
  13843. return ok
  13844. }
  13845. // ClearField clears the value of the field with the given name. It returns an
  13846. // error if the field is not defined in the schema.
  13847. func (m *ContactFieldMutation) ClearField(name string) error {
  13848. switch name {
  13849. case contactfield.FieldStatus:
  13850. m.ClearStatus()
  13851. return nil
  13852. case contactfield.FieldDeletedAt:
  13853. m.ClearDeletedAt()
  13854. return nil
  13855. }
  13856. return fmt.Errorf("unknown ContactField nullable field %s", name)
  13857. }
  13858. // ResetField resets all changes in the mutation for the field with the given name.
  13859. // It returns an error if the field is not defined in the schema.
  13860. func (m *ContactFieldMutation) ResetField(name string) error {
  13861. switch name {
  13862. case contactfield.FieldCreatedAt:
  13863. m.ResetCreatedAt()
  13864. return nil
  13865. case contactfield.FieldUpdatedAt:
  13866. m.ResetUpdatedAt()
  13867. return nil
  13868. case contactfield.FieldStatus:
  13869. m.ResetStatus()
  13870. return nil
  13871. case contactfield.FieldDeletedAt:
  13872. m.ResetDeletedAt()
  13873. return nil
  13874. case contactfield.FieldContactID:
  13875. m.ResetContactID()
  13876. return nil
  13877. case contactfield.FieldFormID:
  13878. m.ResetFormID()
  13879. return nil
  13880. case contactfield.FieldValue:
  13881. m.ResetValue()
  13882. return nil
  13883. }
  13884. return fmt.Errorf("unknown ContactField field %s", name)
  13885. }
  13886. // AddedEdges returns all edge names that were set/added in this mutation.
  13887. func (m *ContactFieldMutation) AddedEdges() []string {
  13888. edges := make([]string, 0, 1)
  13889. if m.field_contact != nil {
  13890. edges = append(edges, contactfield.EdgeFieldContact)
  13891. }
  13892. return edges
  13893. }
  13894. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13895. // name in this mutation.
  13896. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  13897. switch name {
  13898. case contactfield.EdgeFieldContact:
  13899. if id := m.field_contact; id != nil {
  13900. return []ent.Value{*id}
  13901. }
  13902. }
  13903. return nil
  13904. }
  13905. // RemovedEdges returns all edge names that were removed in this mutation.
  13906. func (m *ContactFieldMutation) RemovedEdges() []string {
  13907. edges := make([]string, 0, 1)
  13908. return edges
  13909. }
  13910. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13911. // the given name in this mutation.
  13912. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  13913. return nil
  13914. }
  13915. // ClearedEdges returns all edge names that were cleared in this mutation.
  13916. func (m *ContactFieldMutation) ClearedEdges() []string {
  13917. edges := make([]string, 0, 1)
  13918. if m.clearedfield_contact {
  13919. edges = append(edges, contactfield.EdgeFieldContact)
  13920. }
  13921. return edges
  13922. }
  13923. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13924. // was cleared in this mutation.
  13925. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  13926. switch name {
  13927. case contactfield.EdgeFieldContact:
  13928. return m.clearedfield_contact
  13929. }
  13930. return false
  13931. }
  13932. // ClearEdge clears the value of the edge with the given name. It returns an error
  13933. // if that edge is not defined in the schema.
  13934. func (m *ContactFieldMutation) ClearEdge(name string) error {
  13935. switch name {
  13936. case contactfield.EdgeFieldContact:
  13937. m.ClearFieldContact()
  13938. return nil
  13939. }
  13940. return fmt.Errorf("unknown ContactField unique edge %s", name)
  13941. }
  13942. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13943. // It returns an error if the edge is not defined in the schema.
  13944. func (m *ContactFieldMutation) ResetEdge(name string) error {
  13945. switch name {
  13946. case contactfield.EdgeFieldContact:
  13947. m.ResetFieldContact()
  13948. return nil
  13949. }
  13950. return fmt.Errorf("unknown ContactField edge %s", name)
  13951. }
  13952. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  13953. type ContactFieldTemplateMutation struct {
  13954. config
  13955. op Op
  13956. typ string
  13957. id *uint64
  13958. created_at *time.Time
  13959. updated_at *time.Time
  13960. status *uint8
  13961. addstatus *int8
  13962. deleted_at *time.Time
  13963. organization_id *uint64
  13964. addorganization_id *int64
  13965. template *[]custom_types.ContactFieldTemplate
  13966. appendtemplate []custom_types.ContactFieldTemplate
  13967. clearedFields map[string]struct{}
  13968. done bool
  13969. oldValue func(context.Context) (*ContactFieldTemplate, error)
  13970. predicates []predicate.ContactFieldTemplate
  13971. }
  13972. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  13973. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  13974. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  13975. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  13976. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  13977. m := &ContactFieldTemplateMutation{
  13978. config: c,
  13979. op: op,
  13980. typ: TypeContactFieldTemplate,
  13981. clearedFields: make(map[string]struct{}),
  13982. }
  13983. for _, opt := range opts {
  13984. opt(m)
  13985. }
  13986. return m
  13987. }
  13988. // withContactFieldTemplateID sets the ID field of the mutation.
  13989. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  13990. return func(m *ContactFieldTemplateMutation) {
  13991. var (
  13992. err error
  13993. once sync.Once
  13994. value *ContactFieldTemplate
  13995. )
  13996. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  13997. once.Do(func() {
  13998. if m.done {
  13999. err = errors.New("querying old values post mutation is not allowed")
  14000. } else {
  14001. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  14002. }
  14003. })
  14004. return value, err
  14005. }
  14006. m.id = &id
  14007. }
  14008. }
  14009. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  14010. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  14011. return func(m *ContactFieldTemplateMutation) {
  14012. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  14013. return node, nil
  14014. }
  14015. m.id = &node.ID
  14016. }
  14017. }
  14018. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14019. // executed in a transaction (ent.Tx), a transactional client is returned.
  14020. func (m ContactFieldTemplateMutation) Client() *Client {
  14021. client := &Client{config: m.config}
  14022. client.init()
  14023. return client
  14024. }
  14025. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14026. // it returns an error otherwise.
  14027. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  14028. if _, ok := m.driver.(*txDriver); !ok {
  14029. return nil, errors.New("ent: mutation is not running in a transaction")
  14030. }
  14031. tx := &Tx{config: m.config}
  14032. tx.init()
  14033. return tx, nil
  14034. }
  14035. // SetID sets the value of the id field. Note that this
  14036. // operation is only accepted on creation of ContactFieldTemplate entities.
  14037. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  14038. m.id = &id
  14039. }
  14040. // ID returns the ID value in the mutation. Note that the ID is only available
  14041. // if it was provided to the builder or after it was returned from the database.
  14042. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  14043. if m.id == nil {
  14044. return
  14045. }
  14046. return *m.id, true
  14047. }
  14048. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14049. // That means, if the mutation is applied within a transaction with an isolation level such
  14050. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14051. // or updated by the mutation.
  14052. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  14053. switch {
  14054. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14055. id, exists := m.ID()
  14056. if exists {
  14057. return []uint64{id}, nil
  14058. }
  14059. fallthrough
  14060. case m.op.Is(OpUpdate | OpDelete):
  14061. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  14062. default:
  14063. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14064. }
  14065. }
  14066. // SetCreatedAt sets the "created_at" field.
  14067. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  14068. m.created_at = &t
  14069. }
  14070. // CreatedAt returns the value of the "created_at" field in the mutation.
  14071. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  14072. v := m.created_at
  14073. if v == nil {
  14074. return
  14075. }
  14076. return *v, true
  14077. }
  14078. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  14079. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14081. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14082. if !m.op.Is(OpUpdateOne) {
  14083. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14084. }
  14085. if m.id == nil || m.oldValue == nil {
  14086. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14087. }
  14088. oldValue, err := m.oldValue(ctx)
  14089. if err != nil {
  14090. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14091. }
  14092. return oldValue.CreatedAt, nil
  14093. }
  14094. // ResetCreatedAt resets all changes to the "created_at" field.
  14095. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  14096. m.created_at = nil
  14097. }
  14098. // SetUpdatedAt sets the "updated_at" field.
  14099. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  14100. m.updated_at = &t
  14101. }
  14102. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14103. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  14104. v := m.updated_at
  14105. if v == nil {
  14106. return
  14107. }
  14108. return *v, true
  14109. }
  14110. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  14111. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14113. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14114. if !m.op.Is(OpUpdateOne) {
  14115. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14116. }
  14117. if m.id == nil || m.oldValue == nil {
  14118. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14119. }
  14120. oldValue, err := m.oldValue(ctx)
  14121. if err != nil {
  14122. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14123. }
  14124. return oldValue.UpdatedAt, nil
  14125. }
  14126. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14127. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  14128. m.updated_at = nil
  14129. }
  14130. // SetStatus sets the "status" field.
  14131. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  14132. m.status = &u
  14133. m.addstatus = nil
  14134. }
  14135. // Status returns the value of the "status" field in the mutation.
  14136. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  14137. v := m.status
  14138. if v == nil {
  14139. return
  14140. }
  14141. return *v, true
  14142. }
  14143. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  14144. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14146. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14147. if !m.op.Is(OpUpdateOne) {
  14148. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14149. }
  14150. if m.id == nil || m.oldValue == nil {
  14151. return v, errors.New("OldStatus requires an ID field in the mutation")
  14152. }
  14153. oldValue, err := m.oldValue(ctx)
  14154. if err != nil {
  14155. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14156. }
  14157. return oldValue.Status, nil
  14158. }
  14159. // AddStatus adds u to the "status" field.
  14160. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  14161. if m.addstatus != nil {
  14162. *m.addstatus += u
  14163. } else {
  14164. m.addstatus = &u
  14165. }
  14166. }
  14167. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14168. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  14169. v := m.addstatus
  14170. if v == nil {
  14171. return
  14172. }
  14173. return *v, true
  14174. }
  14175. // ClearStatus clears the value of the "status" field.
  14176. func (m *ContactFieldTemplateMutation) ClearStatus() {
  14177. m.status = nil
  14178. m.addstatus = nil
  14179. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  14180. }
  14181. // StatusCleared returns if the "status" field was cleared in this mutation.
  14182. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  14183. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  14184. return ok
  14185. }
  14186. // ResetStatus resets all changes to the "status" field.
  14187. func (m *ContactFieldTemplateMutation) ResetStatus() {
  14188. m.status = nil
  14189. m.addstatus = nil
  14190. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  14191. }
  14192. // SetDeletedAt sets the "deleted_at" field.
  14193. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  14194. m.deleted_at = &t
  14195. }
  14196. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14197. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  14198. v := m.deleted_at
  14199. if v == nil {
  14200. return
  14201. }
  14202. return *v, true
  14203. }
  14204. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  14205. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14207. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14208. if !m.op.Is(OpUpdateOne) {
  14209. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14210. }
  14211. if m.id == nil || m.oldValue == nil {
  14212. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14213. }
  14214. oldValue, err := m.oldValue(ctx)
  14215. if err != nil {
  14216. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14217. }
  14218. return oldValue.DeletedAt, nil
  14219. }
  14220. // ClearDeletedAt clears the value of the "deleted_at" field.
  14221. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  14222. m.deleted_at = nil
  14223. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  14224. }
  14225. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14226. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  14227. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  14228. return ok
  14229. }
  14230. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14231. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  14232. m.deleted_at = nil
  14233. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  14234. }
  14235. // SetOrganizationID sets the "organization_id" field.
  14236. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  14237. m.organization_id = &u
  14238. m.addorganization_id = nil
  14239. }
  14240. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14241. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  14242. v := m.organization_id
  14243. if v == nil {
  14244. return
  14245. }
  14246. return *v, true
  14247. }
  14248. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  14249. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14251. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14252. if !m.op.Is(OpUpdateOne) {
  14253. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14254. }
  14255. if m.id == nil || m.oldValue == nil {
  14256. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14257. }
  14258. oldValue, err := m.oldValue(ctx)
  14259. if err != nil {
  14260. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14261. }
  14262. return oldValue.OrganizationID, nil
  14263. }
  14264. // AddOrganizationID adds u to the "organization_id" field.
  14265. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  14266. if m.addorganization_id != nil {
  14267. *m.addorganization_id += u
  14268. } else {
  14269. m.addorganization_id = &u
  14270. }
  14271. }
  14272. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14273. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  14274. v := m.addorganization_id
  14275. if v == nil {
  14276. return
  14277. }
  14278. return *v, true
  14279. }
  14280. // ResetOrganizationID resets all changes to the "organization_id" field.
  14281. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  14282. m.organization_id = nil
  14283. m.addorganization_id = nil
  14284. }
  14285. // SetTemplate sets the "template" field.
  14286. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  14287. m.template = &ctft
  14288. m.appendtemplate = nil
  14289. }
  14290. // Template returns the value of the "template" field in the mutation.
  14291. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  14292. v := m.template
  14293. if v == nil {
  14294. return
  14295. }
  14296. return *v, true
  14297. }
  14298. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  14299. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  14300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14301. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  14302. if !m.op.Is(OpUpdateOne) {
  14303. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  14304. }
  14305. if m.id == nil || m.oldValue == nil {
  14306. return v, errors.New("OldTemplate requires an ID field in the mutation")
  14307. }
  14308. oldValue, err := m.oldValue(ctx)
  14309. if err != nil {
  14310. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  14311. }
  14312. return oldValue.Template, nil
  14313. }
  14314. // AppendTemplate adds ctft to the "template" field.
  14315. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  14316. m.appendtemplate = append(m.appendtemplate, ctft...)
  14317. }
  14318. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  14319. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  14320. if len(m.appendtemplate) == 0 {
  14321. return nil, false
  14322. }
  14323. return m.appendtemplate, true
  14324. }
  14325. // ResetTemplate resets all changes to the "template" field.
  14326. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  14327. m.template = nil
  14328. m.appendtemplate = nil
  14329. }
  14330. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  14331. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  14332. m.predicates = append(m.predicates, ps...)
  14333. }
  14334. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  14335. // users can use type-assertion to append predicates that do not depend on any generated package.
  14336. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  14337. p := make([]predicate.ContactFieldTemplate, len(ps))
  14338. for i := range ps {
  14339. p[i] = ps[i]
  14340. }
  14341. m.Where(p...)
  14342. }
  14343. // Op returns the operation name.
  14344. func (m *ContactFieldTemplateMutation) Op() Op {
  14345. return m.op
  14346. }
  14347. // SetOp allows setting the mutation operation.
  14348. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  14349. m.op = op
  14350. }
  14351. // Type returns the node type of this mutation (ContactFieldTemplate).
  14352. func (m *ContactFieldTemplateMutation) Type() string {
  14353. return m.typ
  14354. }
  14355. // Fields returns all fields that were changed during this mutation. Note that in
  14356. // order to get all numeric fields that were incremented/decremented, call
  14357. // AddedFields().
  14358. func (m *ContactFieldTemplateMutation) Fields() []string {
  14359. fields := make([]string, 0, 6)
  14360. if m.created_at != nil {
  14361. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  14362. }
  14363. if m.updated_at != nil {
  14364. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  14365. }
  14366. if m.status != nil {
  14367. fields = append(fields, contactfieldtemplate.FieldStatus)
  14368. }
  14369. if m.deleted_at != nil {
  14370. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14371. }
  14372. if m.organization_id != nil {
  14373. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14374. }
  14375. if m.template != nil {
  14376. fields = append(fields, contactfieldtemplate.FieldTemplate)
  14377. }
  14378. return fields
  14379. }
  14380. // Field returns the value of a field with the given name. The second boolean
  14381. // return value indicates that this field was not set, or was not defined in the
  14382. // schema.
  14383. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  14384. switch name {
  14385. case contactfieldtemplate.FieldCreatedAt:
  14386. return m.CreatedAt()
  14387. case contactfieldtemplate.FieldUpdatedAt:
  14388. return m.UpdatedAt()
  14389. case contactfieldtemplate.FieldStatus:
  14390. return m.Status()
  14391. case contactfieldtemplate.FieldDeletedAt:
  14392. return m.DeletedAt()
  14393. case contactfieldtemplate.FieldOrganizationID:
  14394. return m.OrganizationID()
  14395. case contactfieldtemplate.FieldTemplate:
  14396. return m.Template()
  14397. }
  14398. return nil, false
  14399. }
  14400. // OldField returns the old value of the field from the database. An error is
  14401. // returned if the mutation operation is not UpdateOne, or the query to the
  14402. // database failed.
  14403. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14404. switch name {
  14405. case contactfieldtemplate.FieldCreatedAt:
  14406. return m.OldCreatedAt(ctx)
  14407. case contactfieldtemplate.FieldUpdatedAt:
  14408. return m.OldUpdatedAt(ctx)
  14409. case contactfieldtemplate.FieldStatus:
  14410. return m.OldStatus(ctx)
  14411. case contactfieldtemplate.FieldDeletedAt:
  14412. return m.OldDeletedAt(ctx)
  14413. case contactfieldtemplate.FieldOrganizationID:
  14414. return m.OldOrganizationID(ctx)
  14415. case contactfieldtemplate.FieldTemplate:
  14416. return m.OldTemplate(ctx)
  14417. }
  14418. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14419. }
  14420. // SetField sets the value of a field with the given name. It returns an error if
  14421. // the field is not defined in the schema, or if the type mismatched the field
  14422. // type.
  14423. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  14424. switch name {
  14425. case contactfieldtemplate.FieldCreatedAt:
  14426. v, ok := value.(time.Time)
  14427. if !ok {
  14428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14429. }
  14430. m.SetCreatedAt(v)
  14431. return nil
  14432. case contactfieldtemplate.FieldUpdatedAt:
  14433. v, ok := value.(time.Time)
  14434. if !ok {
  14435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14436. }
  14437. m.SetUpdatedAt(v)
  14438. return nil
  14439. case contactfieldtemplate.FieldStatus:
  14440. v, ok := value.(uint8)
  14441. if !ok {
  14442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14443. }
  14444. m.SetStatus(v)
  14445. return nil
  14446. case contactfieldtemplate.FieldDeletedAt:
  14447. v, ok := value.(time.Time)
  14448. if !ok {
  14449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14450. }
  14451. m.SetDeletedAt(v)
  14452. return nil
  14453. case contactfieldtemplate.FieldOrganizationID:
  14454. v, ok := value.(uint64)
  14455. if !ok {
  14456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14457. }
  14458. m.SetOrganizationID(v)
  14459. return nil
  14460. case contactfieldtemplate.FieldTemplate:
  14461. v, ok := value.([]custom_types.ContactFieldTemplate)
  14462. if !ok {
  14463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14464. }
  14465. m.SetTemplate(v)
  14466. return nil
  14467. }
  14468. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14469. }
  14470. // AddedFields returns all numeric fields that were incremented/decremented during
  14471. // this mutation.
  14472. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  14473. var fields []string
  14474. if m.addstatus != nil {
  14475. fields = append(fields, contactfieldtemplate.FieldStatus)
  14476. }
  14477. if m.addorganization_id != nil {
  14478. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  14479. }
  14480. return fields
  14481. }
  14482. // AddedField returns the numeric value that was incremented/decremented on a field
  14483. // with the given name. The second boolean return value indicates that this field
  14484. // was not set, or was not defined in the schema.
  14485. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  14486. switch name {
  14487. case contactfieldtemplate.FieldStatus:
  14488. return m.AddedStatus()
  14489. case contactfieldtemplate.FieldOrganizationID:
  14490. return m.AddedOrganizationID()
  14491. }
  14492. return nil, false
  14493. }
  14494. // AddField adds the value to the field with the given name. It returns an error if
  14495. // the field is not defined in the schema, or if the type mismatched the field
  14496. // type.
  14497. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  14498. switch name {
  14499. case contactfieldtemplate.FieldStatus:
  14500. v, ok := value.(int8)
  14501. if !ok {
  14502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14503. }
  14504. m.AddStatus(v)
  14505. return nil
  14506. case contactfieldtemplate.FieldOrganizationID:
  14507. v, ok := value.(int64)
  14508. if !ok {
  14509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14510. }
  14511. m.AddOrganizationID(v)
  14512. return nil
  14513. }
  14514. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  14515. }
  14516. // ClearedFields returns all nullable fields that were cleared during this
  14517. // mutation.
  14518. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  14519. var fields []string
  14520. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  14521. fields = append(fields, contactfieldtemplate.FieldStatus)
  14522. }
  14523. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  14524. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  14525. }
  14526. return fields
  14527. }
  14528. // FieldCleared returns a boolean indicating if a field with the given name was
  14529. // cleared in this mutation.
  14530. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  14531. _, ok := m.clearedFields[name]
  14532. return ok
  14533. }
  14534. // ClearField clears the value of the field with the given name. It returns an
  14535. // error if the field is not defined in the schema.
  14536. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  14537. switch name {
  14538. case contactfieldtemplate.FieldStatus:
  14539. m.ClearStatus()
  14540. return nil
  14541. case contactfieldtemplate.FieldDeletedAt:
  14542. m.ClearDeletedAt()
  14543. return nil
  14544. }
  14545. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  14546. }
  14547. // ResetField resets all changes in the mutation for the field with the given name.
  14548. // It returns an error if the field is not defined in the schema.
  14549. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  14550. switch name {
  14551. case contactfieldtemplate.FieldCreatedAt:
  14552. m.ResetCreatedAt()
  14553. return nil
  14554. case contactfieldtemplate.FieldUpdatedAt:
  14555. m.ResetUpdatedAt()
  14556. return nil
  14557. case contactfieldtemplate.FieldStatus:
  14558. m.ResetStatus()
  14559. return nil
  14560. case contactfieldtemplate.FieldDeletedAt:
  14561. m.ResetDeletedAt()
  14562. return nil
  14563. case contactfieldtemplate.FieldOrganizationID:
  14564. m.ResetOrganizationID()
  14565. return nil
  14566. case contactfieldtemplate.FieldTemplate:
  14567. m.ResetTemplate()
  14568. return nil
  14569. }
  14570. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  14571. }
  14572. // AddedEdges returns all edge names that were set/added in this mutation.
  14573. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  14574. edges := make([]string, 0, 0)
  14575. return edges
  14576. }
  14577. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14578. // name in this mutation.
  14579. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  14580. return nil
  14581. }
  14582. // RemovedEdges returns all edge names that were removed in this mutation.
  14583. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  14584. edges := make([]string, 0, 0)
  14585. return edges
  14586. }
  14587. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14588. // the given name in this mutation.
  14589. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  14590. return nil
  14591. }
  14592. // ClearedEdges returns all edge names that were cleared in this mutation.
  14593. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  14594. edges := make([]string, 0, 0)
  14595. return edges
  14596. }
  14597. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14598. // was cleared in this mutation.
  14599. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  14600. return false
  14601. }
  14602. // ClearEdge clears the value of the edge with the given name. It returns an error
  14603. // if that edge is not defined in the schema.
  14604. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  14605. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  14606. }
  14607. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14608. // It returns an error if the edge is not defined in the schema.
  14609. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  14610. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  14611. }
  14612. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  14613. type CreditBalanceMutation struct {
  14614. config
  14615. op Op
  14616. typ string
  14617. id *uint64
  14618. created_at *time.Time
  14619. updated_at *time.Time
  14620. deleted_at *time.Time
  14621. user_id *string
  14622. balance *float64
  14623. addbalance *float64
  14624. status *int
  14625. addstatus *int
  14626. organization_id *uint64
  14627. addorganization_id *int64
  14628. clearedFields map[string]struct{}
  14629. done bool
  14630. oldValue func(context.Context) (*CreditBalance, error)
  14631. predicates []predicate.CreditBalance
  14632. }
  14633. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  14634. // creditbalanceOption allows management of the mutation configuration using functional options.
  14635. type creditbalanceOption func(*CreditBalanceMutation)
  14636. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  14637. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  14638. m := &CreditBalanceMutation{
  14639. config: c,
  14640. op: op,
  14641. typ: TypeCreditBalance,
  14642. clearedFields: make(map[string]struct{}),
  14643. }
  14644. for _, opt := range opts {
  14645. opt(m)
  14646. }
  14647. return m
  14648. }
  14649. // withCreditBalanceID sets the ID field of the mutation.
  14650. func withCreditBalanceID(id uint64) creditbalanceOption {
  14651. return func(m *CreditBalanceMutation) {
  14652. var (
  14653. err error
  14654. once sync.Once
  14655. value *CreditBalance
  14656. )
  14657. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  14658. once.Do(func() {
  14659. if m.done {
  14660. err = errors.New("querying old values post mutation is not allowed")
  14661. } else {
  14662. value, err = m.Client().CreditBalance.Get(ctx, id)
  14663. }
  14664. })
  14665. return value, err
  14666. }
  14667. m.id = &id
  14668. }
  14669. }
  14670. // withCreditBalance sets the old CreditBalance of the mutation.
  14671. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  14672. return func(m *CreditBalanceMutation) {
  14673. m.oldValue = func(context.Context) (*CreditBalance, error) {
  14674. return node, nil
  14675. }
  14676. m.id = &node.ID
  14677. }
  14678. }
  14679. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14680. // executed in a transaction (ent.Tx), a transactional client is returned.
  14681. func (m CreditBalanceMutation) Client() *Client {
  14682. client := &Client{config: m.config}
  14683. client.init()
  14684. return client
  14685. }
  14686. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14687. // it returns an error otherwise.
  14688. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  14689. if _, ok := m.driver.(*txDriver); !ok {
  14690. return nil, errors.New("ent: mutation is not running in a transaction")
  14691. }
  14692. tx := &Tx{config: m.config}
  14693. tx.init()
  14694. return tx, nil
  14695. }
  14696. // SetID sets the value of the id field. Note that this
  14697. // operation is only accepted on creation of CreditBalance entities.
  14698. func (m *CreditBalanceMutation) SetID(id uint64) {
  14699. m.id = &id
  14700. }
  14701. // ID returns the ID value in the mutation. Note that the ID is only available
  14702. // if it was provided to the builder or after it was returned from the database.
  14703. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  14704. if m.id == nil {
  14705. return
  14706. }
  14707. return *m.id, true
  14708. }
  14709. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14710. // That means, if the mutation is applied within a transaction with an isolation level such
  14711. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14712. // or updated by the mutation.
  14713. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  14714. switch {
  14715. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14716. id, exists := m.ID()
  14717. if exists {
  14718. return []uint64{id}, nil
  14719. }
  14720. fallthrough
  14721. case m.op.Is(OpUpdate | OpDelete):
  14722. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  14723. default:
  14724. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14725. }
  14726. }
  14727. // SetCreatedAt sets the "created_at" field.
  14728. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  14729. m.created_at = &t
  14730. }
  14731. // CreatedAt returns the value of the "created_at" field in the mutation.
  14732. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  14733. v := m.created_at
  14734. if v == nil {
  14735. return
  14736. }
  14737. return *v, true
  14738. }
  14739. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  14740. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14742. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14743. if !m.op.Is(OpUpdateOne) {
  14744. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14745. }
  14746. if m.id == nil || m.oldValue == nil {
  14747. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14748. }
  14749. oldValue, err := m.oldValue(ctx)
  14750. if err != nil {
  14751. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14752. }
  14753. return oldValue.CreatedAt, nil
  14754. }
  14755. // ResetCreatedAt resets all changes to the "created_at" field.
  14756. func (m *CreditBalanceMutation) ResetCreatedAt() {
  14757. m.created_at = nil
  14758. }
  14759. // SetUpdatedAt sets the "updated_at" field.
  14760. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  14761. m.updated_at = &t
  14762. }
  14763. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14764. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  14765. v := m.updated_at
  14766. if v == nil {
  14767. return
  14768. }
  14769. return *v, true
  14770. }
  14771. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  14772. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14774. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14775. if !m.op.Is(OpUpdateOne) {
  14776. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14777. }
  14778. if m.id == nil || m.oldValue == nil {
  14779. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14780. }
  14781. oldValue, err := m.oldValue(ctx)
  14782. if err != nil {
  14783. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14784. }
  14785. return oldValue.UpdatedAt, nil
  14786. }
  14787. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14788. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  14789. m.updated_at = nil
  14790. }
  14791. // SetDeletedAt sets the "deleted_at" field.
  14792. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  14793. m.deleted_at = &t
  14794. }
  14795. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14796. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  14797. v := m.deleted_at
  14798. if v == nil {
  14799. return
  14800. }
  14801. return *v, true
  14802. }
  14803. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  14804. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14806. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14807. if !m.op.Is(OpUpdateOne) {
  14808. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14809. }
  14810. if m.id == nil || m.oldValue == nil {
  14811. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14812. }
  14813. oldValue, err := m.oldValue(ctx)
  14814. if err != nil {
  14815. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14816. }
  14817. return oldValue.DeletedAt, nil
  14818. }
  14819. // ClearDeletedAt clears the value of the "deleted_at" field.
  14820. func (m *CreditBalanceMutation) ClearDeletedAt() {
  14821. m.deleted_at = nil
  14822. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  14823. }
  14824. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14825. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  14826. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  14827. return ok
  14828. }
  14829. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14830. func (m *CreditBalanceMutation) ResetDeletedAt() {
  14831. m.deleted_at = nil
  14832. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  14833. }
  14834. // SetUserID sets the "user_id" field.
  14835. func (m *CreditBalanceMutation) SetUserID(s string) {
  14836. m.user_id = &s
  14837. }
  14838. // UserID returns the value of the "user_id" field in the mutation.
  14839. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  14840. v := m.user_id
  14841. if v == nil {
  14842. return
  14843. }
  14844. return *v, true
  14845. }
  14846. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  14847. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14849. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  14850. if !m.op.Is(OpUpdateOne) {
  14851. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  14852. }
  14853. if m.id == nil || m.oldValue == nil {
  14854. return v, errors.New("OldUserID requires an ID field in the mutation")
  14855. }
  14856. oldValue, err := m.oldValue(ctx)
  14857. if err != nil {
  14858. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  14859. }
  14860. return oldValue.UserID, nil
  14861. }
  14862. // ClearUserID clears the value of the "user_id" field.
  14863. func (m *CreditBalanceMutation) ClearUserID() {
  14864. m.user_id = nil
  14865. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  14866. }
  14867. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  14868. func (m *CreditBalanceMutation) UserIDCleared() bool {
  14869. _, ok := m.clearedFields[creditbalance.FieldUserID]
  14870. return ok
  14871. }
  14872. // ResetUserID resets all changes to the "user_id" field.
  14873. func (m *CreditBalanceMutation) ResetUserID() {
  14874. m.user_id = nil
  14875. delete(m.clearedFields, creditbalance.FieldUserID)
  14876. }
  14877. // SetBalance sets the "balance" field.
  14878. func (m *CreditBalanceMutation) SetBalance(f float64) {
  14879. m.balance = &f
  14880. m.addbalance = nil
  14881. }
  14882. // Balance returns the value of the "balance" field in the mutation.
  14883. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  14884. v := m.balance
  14885. if v == nil {
  14886. return
  14887. }
  14888. return *v, true
  14889. }
  14890. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  14891. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14893. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  14894. if !m.op.Is(OpUpdateOne) {
  14895. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  14896. }
  14897. if m.id == nil || m.oldValue == nil {
  14898. return v, errors.New("OldBalance requires an ID field in the mutation")
  14899. }
  14900. oldValue, err := m.oldValue(ctx)
  14901. if err != nil {
  14902. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  14903. }
  14904. return oldValue.Balance, nil
  14905. }
  14906. // AddBalance adds f to the "balance" field.
  14907. func (m *CreditBalanceMutation) AddBalance(f float64) {
  14908. if m.addbalance != nil {
  14909. *m.addbalance += f
  14910. } else {
  14911. m.addbalance = &f
  14912. }
  14913. }
  14914. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  14915. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  14916. v := m.addbalance
  14917. if v == nil {
  14918. return
  14919. }
  14920. return *v, true
  14921. }
  14922. // ResetBalance resets all changes to the "balance" field.
  14923. func (m *CreditBalanceMutation) ResetBalance() {
  14924. m.balance = nil
  14925. m.addbalance = nil
  14926. }
  14927. // SetStatus sets the "status" field.
  14928. func (m *CreditBalanceMutation) SetStatus(i int) {
  14929. m.status = &i
  14930. m.addstatus = nil
  14931. }
  14932. // Status returns the value of the "status" field in the mutation.
  14933. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  14934. v := m.status
  14935. if v == nil {
  14936. return
  14937. }
  14938. return *v, true
  14939. }
  14940. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  14941. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  14942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14943. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  14944. if !m.op.Is(OpUpdateOne) {
  14945. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14946. }
  14947. if m.id == nil || m.oldValue == nil {
  14948. return v, errors.New("OldStatus requires an ID field in the mutation")
  14949. }
  14950. oldValue, err := m.oldValue(ctx)
  14951. if err != nil {
  14952. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14953. }
  14954. return oldValue.Status, nil
  14955. }
  14956. // AddStatus adds i to the "status" field.
  14957. func (m *CreditBalanceMutation) AddStatus(i int) {
  14958. if m.addstatus != nil {
  14959. *m.addstatus += i
  14960. } else {
  14961. m.addstatus = &i
  14962. }
  14963. }
  14964. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14965. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  14966. v := m.addstatus
  14967. if v == nil {
  14968. return
  14969. }
  14970. return *v, true
  14971. }
  14972. // ClearStatus clears the value of the "status" field.
  14973. func (m *CreditBalanceMutation) ClearStatus() {
  14974. m.status = nil
  14975. m.addstatus = nil
  14976. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  14977. }
  14978. // StatusCleared returns if the "status" field was cleared in this mutation.
  14979. func (m *CreditBalanceMutation) StatusCleared() bool {
  14980. _, ok := m.clearedFields[creditbalance.FieldStatus]
  14981. return ok
  14982. }
  14983. // ResetStatus resets all changes to the "status" field.
  14984. func (m *CreditBalanceMutation) ResetStatus() {
  14985. m.status = nil
  14986. m.addstatus = nil
  14987. delete(m.clearedFields, creditbalance.FieldStatus)
  14988. }
  14989. // SetOrganizationID sets the "organization_id" field.
  14990. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  14991. m.organization_id = &u
  14992. m.addorganization_id = nil
  14993. }
  14994. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14995. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  14996. v := m.organization_id
  14997. if v == nil {
  14998. return
  14999. }
  15000. return *v, true
  15001. }
  15002. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  15003. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15005. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15006. if !m.op.Is(OpUpdateOne) {
  15007. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15008. }
  15009. if m.id == nil || m.oldValue == nil {
  15010. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15011. }
  15012. oldValue, err := m.oldValue(ctx)
  15013. if err != nil {
  15014. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15015. }
  15016. return oldValue.OrganizationID, nil
  15017. }
  15018. // AddOrganizationID adds u to the "organization_id" field.
  15019. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  15020. if m.addorganization_id != nil {
  15021. *m.addorganization_id += u
  15022. } else {
  15023. m.addorganization_id = &u
  15024. }
  15025. }
  15026. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15027. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  15028. v := m.addorganization_id
  15029. if v == nil {
  15030. return
  15031. }
  15032. return *v, true
  15033. }
  15034. // ClearOrganizationID clears the value of the "organization_id" field.
  15035. func (m *CreditBalanceMutation) ClearOrganizationID() {
  15036. m.organization_id = nil
  15037. m.addorganization_id = nil
  15038. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  15039. }
  15040. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15041. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  15042. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  15043. return ok
  15044. }
  15045. // ResetOrganizationID resets all changes to the "organization_id" field.
  15046. func (m *CreditBalanceMutation) ResetOrganizationID() {
  15047. m.organization_id = nil
  15048. m.addorganization_id = nil
  15049. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  15050. }
  15051. // Where appends a list predicates to the CreditBalanceMutation builder.
  15052. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  15053. m.predicates = append(m.predicates, ps...)
  15054. }
  15055. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  15056. // users can use type-assertion to append predicates that do not depend on any generated package.
  15057. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  15058. p := make([]predicate.CreditBalance, len(ps))
  15059. for i := range ps {
  15060. p[i] = ps[i]
  15061. }
  15062. m.Where(p...)
  15063. }
  15064. // Op returns the operation name.
  15065. func (m *CreditBalanceMutation) Op() Op {
  15066. return m.op
  15067. }
  15068. // SetOp allows setting the mutation operation.
  15069. func (m *CreditBalanceMutation) SetOp(op Op) {
  15070. m.op = op
  15071. }
  15072. // Type returns the node type of this mutation (CreditBalance).
  15073. func (m *CreditBalanceMutation) Type() string {
  15074. return m.typ
  15075. }
  15076. // Fields returns all fields that were changed during this mutation. Note that in
  15077. // order to get all numeric fields that were incremented/decremented, call
  15078. // AddedFields().
  15079. func (m *CreditBalanceMutation) Fields() []string {
  15080. fields := make([]string, 0, 7)
  15081. if m.created_at != nil {
  15082. fields = append(fields, creditbalance.FieldCreatedAt)
  15083. }
  15084. if m.updated_at != nil {
  15085. fields = append(fields, creditbalance.FieldUpdatedAt)
  15086. }
  15087. if m.deleted_at != nil {
  15088. fields = append(fields, creditbalance.FieldDeletedAt)
  15089. }
  15090. if m.user_id != nil {
  15091. fields = append(fields, creditbalance.FieldUserID)
  15092. }
  15093. if m.balance != nil {
  15094. fields = append(fields, creditbalance.FieldBalance)
  15095. }
  15096. if m.status != nil {
  15097. fields = append(fields, creditbalance.FieldStatus)
  15098. }
  15099. if m.organization_id != nil {
  15100. fields = append(fields, creditbalance.FieldOrganizationID)
  15101. }
  15102. return fields
  15103. }
  15104. // Field returns the value of a field with the given name. The second boolean
  15105. // return value indicates that this field was not set, or was not defined in the
  15106. // schema.
  15107. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  15108. switch name {
  15109. case creditbalance.FieldCreatedAt:
  15110. return m.CreatedAt()
  15111. case creditbalance.FieldUpdatedAt:
  15112. return m.UpdatedAt()
  15113. case creditbalance.FieldDeletedAt:
  15114. return m.DeletedAt()
  15115. case creditbalance.FieldUserID:
  15116. return m.UserID()
  15117. case creditbalance.FieldBalance:
  15118. return m.Balance()
  15119. case creditbalance.FieldStatus:
  15120. return m.Status()
  15121. case creditbalance.FieldOrganizationID:
  15122. return m.OrganizationID()
  15123. }
  15124. return nil, false
  15125. }
  15126. // OldField returns the old value of the field from the database. An error is
  15127. // returned if the mutation operation is not UpdateOne, or the query to the
  15128. // database failed.
  15129. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15130. switch name {
  15131. case creditbalance.FieldCreatedAt:
  15132. return m.OldCreatedAt(ctx)
  15133. case creditbalance.FieldUpdatedAt:
  15134. return m.OldUpdatedAt(ctx)
  15135. case creditbalance.FieldDeletedAt:
  15136. return m.OldDeletedAt(ctx)
  15137. case creditbalance.FieldUserID:
  15138. return m.OldUserID(ctx)
  15139. case creditbalance.FieldBalance:
  15140. return m.OldBalance(ctx)
  15141. case creditbalance.FieldStatus:
  15142. return m.OldStatus(ctx)
  15143. case creditbalance.FieldOrganizationID:
  15144. return m.OldOrganizationID(ctx)
  15145. }
  15146. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  15147. }
  15148. // SetField sets the value of a field with the given name. It returns an error if
  15149. // the field is not defined in the schema, or if the type mismatched the field
  15150. // type.
  15151. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  15152. switch name {
  15153. case creditbalance.FieldCreatedAt:
  15154. v, ok := value.(time.Time)
  15155. if !ok {
  15156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15157. }
  15158. m.SetCreatedAt(v)
  15159. return nil
  15160. case creditbalance.FieldUpdatedAt:
  15161. v, ok := value.(time.Time)
  15162. if !ok {
  15163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15164. }
  15165. m.SetUpdatedAt(v)
  15166. return nil
  15167. case creditbalance.FieldDeletedAt:
  15168. v, ok := value.(time.Time)
  15169. if !ok {
  15170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15171. }
  15172. m.SetDeletedAt(v)
  15173. return nil
  15174. case creditbalance.FieldUserID:
  15175. v, ok := value.(string)
  15176. if !ok {
  15177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15178. }
  15179. m.SetUserID(v)
  15180. return nil
  15181. case creditbalance.FieldBalance:
  15182. v, ok := value.(float64)
  15183. if !ok {
  15184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15185. }
  15186. m.SetBalance(v)
  15187. return nil
  15188. case creditbalance.FieldStatus:
  15189. v, ok := value.(int)
  15190. if !ok {
  15191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15192. }
  15193. m.SetStatus(v)
  15194. return nil
  15195. case creditbalance.FieldOrganizationID:
  15196. v, ok := value.(uint64)
  15197. if !ok {
  15198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15199. }
  15200. m.SetOrganizationID(v)
  15201. return nil
  15202. }
  15203. return fmt.Errorf("unknown CreditBalance field %s", name)
  15204. }
  15205. // AddedFields returns all numeric fields that were incremented/decremented during
  15206. // this mutation.
  15207. func (m *CreditBalanceMutation) AddedFields() []string {
  15208. var fields []string
  15209. if m.addbalance != nil {
  15210. fields = append(fields, creditbalance.FieldBalance)
  15211. }
  15212. if m.addstatus != nil {
  15213. fields = append(fields, creditbalance.FieldStatus)
  15214. }
  15215. if m.addorganization_id != nil {
  15216. fields = append(fields, creditbalance.FieldOrganizationID)
  15217. }
  15218. return fields
  15219. }
  15220. // AddedField returns the numeric value that was incremented/decremented on a field
  15221. // with the given name. The second boolean return value indicates that this field
  15222. // was not set, or was not defined in the schema.
  15223. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  15224. switch name {
  15225. case creditbalance.FieldBalance:
  15226. return m.AddedBalance()
  15227. case creditbalance.FieldStatus:
  15228. return m.AddedStatus()
  15229. case creditbalance.FieldOrganizationID:
  15230. return m.AddedOrganizationID()
  15231. }
  15232. return nil, false
  15233. }
  15234. // AddField adds the value to the field with the given name. It returns an error if
  15235. // the field is not defined in the schema, or if the type mismatched the field
  15236. // type.
  15237. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  15238. switch name {
  15239. case creditbalance.FieldBalance:
  15240. v, ok := value.(float64)
  15241. if !ok {
  15242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15243. }
  15244. m.AddBalance(v)
  15245. return nil
  15246. case creditbalance.FieldStatus:
  15247. v, ok := value.(int)
  15248. if !ok {
  15249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15250. }
  15251. m.AddStatus(v)
  15252. return nil
  15253. case creditbalance.FieldOrganizationID:
  15254. v, ok := value.(int64)
  15255. if !ok {
  15256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15257. }
  15258. m.AddOrganizationID(v)
  15259. return nil
  15260. }
  15261. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  15262. }
  15263. // ClearedFields returns all nullable fields that were cleared during this
  15264. // mutation.
  15265. func (m *CreditBalanceMutation) ClearedFields() []string {
  15266. var fields []string
  15267. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  15268. fields = append(fields, creditbalance.FieldDeletedAt)
  15269. }
  15270. if m.FieldCleared(creditbalance.FieldUserID) {
  15271. fields = append(fields, creditbalance.FieldUserID)
  15272. }
  15273. if m.FieldCleared(creditbalance.FieldStatus) {
  15274. fields = append(fields, creditbalance.FieldStatus)
  15275. }
  15276. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  15277. fields = append(fields, creditbalance.FieldOrganizationID)
  15278. }
  15279. return fields
  15280. }
  15281. // FieldCleared returns a boolean indicating if a field with the given name was
  15282. // cleared in this mutation.
  15283. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  15284. _, ok := m.clearedFields[name]
  15285. return ok
  15286. }
  15287. // ClearField clears the value of the field with the given name. It returns an
  15288. // error if the field is not defined in the schema.
  15289. func (m *CreditBalanceMutation) ClearField(name string) error {
  15290. switch name {
  15291. case creditbalance.FieldDeletedAt:
  15292. m.ClearDeletedAt()
  15293. return nil
  15294. case creditbalance.FieldUserID:
  15295. m.ClearUserID()
  15296. return nil
  15297. case creditbalance.FieldStatus:
  15298. m.ClearStatus()
  15299. return nil
  15300. case creditbalance.FieldOrganizationID:
  15301. m.ClearOrganizationID()
  15302. return nil
  15303. }
  15304. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  15305. }
  15306. // ResetField resets all changes in the mutation for the field with the given name.
  15307. // It returns an error if the field is not defined in the schema.
  15308. func (m *CreditBalanceMutation) ResetField(name string) error {
  15309. switch name {
  15310. case creditbalance.FieldCreatedAt:
  15311. m.ResetCreatedAt()
  15312. return nil
  15313. case creditbalance.FieldUpdatedAt:
  15314. m.ResetUpdatedAt()
  15315. return nil
  15316. case creditbalance.FieldDeletedAt:
  15317. m.ResetDeletedAt()
  15318. return nil
  15319. case creditbalance.FieldUserID:
  15320. m.ResetUserID()
  15321. return nil
  15322. case creditbalance.FieldBalance:
  15323. m.ResetBalance()
  15324. return nil
  15325. case creditbalance.FieldStatus:
  15326. m.ResetStatus()
  15327. return nil
  15328. case creditbalance.FieldOrganizationID:
  15329. m.ResetOrganizationID()
  15330. return nil
  15331. }
  15332. return fmt.Errorf("unknown CreditBalance field %s", name)
  15333. }
  15334. // AddedEdges returns all edge names that were set/added in this mutation.
  15335. func (m *CreditBalanceMutation) AddedEdges() []string {
  15336. edges := make([]string, 0, 0)
  15337. return edges
  15338. }
  15339. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15340. // name in this mutation.
  15341. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  15342. return nil
  15343. }
  15344. // RemovedEdges returns all edge names that were removed in this mutation.
  15345. func (m *CreditBalanceMutation) RemovedEdges() []string {
  15346. edges := make([]string, 0, 0)
  15347. return edges
  15348. }
  15349. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15350. // the given name in this mutation.
  15351. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  15352. return nil
  15353. }
  15354. // ClearedEdges returns all edge names that were cleared in this mutation.
  15355. func (m *CreditBalanceMutation) ClearedEdges() []string {
  15356. edges := make([]string, 0, 0)
  15357. return edges
  15358. }
  15359. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15360. // was cleared in this mutation.
  15361. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  15362. return false
  15363. }
  15364. // ClearEdge clears the value of the edge with the given name. It returns an error
  15365. // if that edge is not defined in the schema.
  15366. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  15367. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  15368. }
  15369. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15370. // It returns an error if the edge is not defined in the schema.
  15371. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  15372. return fmt.Errorf("unknown CreditBalance edge %s", name)
  15373. }
  15374. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  15375. type CreditUsageMutation struct {
  15376. config
  15377. op Op
  15378. typ string
  15379. id *uint64
  15380. created_at *time.Time
  15381. updated_at *time.Time
  15382. deleted_at *time.Time
  15383. user_id *string
  15384. number *float64
  15385. addnumber *float64
  15386. pay_number *float64
  15387. addpay_number *float64
  15388. before_number *float64
  15389. addbefore_number *float64
  15390. after_number *float64
  15391. addafter_number *float64
  15392. pay_method *int
  15393. addpay_method *int
  15394. status *int
  15395. addstatus *int
  15396. ntype *int
  15397. addntype *int
  15398. table *string
  15399. organization_id *uint64
  15400. addorganization_id *int64
  15401. nid *uint64
  15402. addnid *int64
  15403. reason *string
  15404. operator *string
  15405. clearedFields map[string]struct{}
  15406. done bool
  15407. oldValue func(context.Context) (*CreditUsage, error)
  15408. predicates []predicate.CreditUsage
  15409. }
  15410. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  15411. // creditusageOption allows management of the mutation configuration using functional options.
  15412. type creditusageOption func(*CreditUsageMutation)
  15413. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  15414. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  15415. m := &CreditUsageMutation{
  15416. config: c,
  15417. op: op,
  15418. typ: TypeCreditUsage,
  15419. clearedFields: make(map[string]struct{}),
  15420. }
  15421. for _, opt := range opts {
  15422. opt(m)
  15423. }
  15424. return m
  15425. }
  15426. // withCreditUsageID sets the ID field of the mutation.
  15427. func withCreditUsageID(id uint64) creditusageOption {
  15428. return func(m *CreditUsageMutation) {
  15429. var (
  15430. err error
  15431. once sync.Once
  15432. value *CreditUsage
  15433. )
  15434. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  15435. once.Do(func() {
  15436. if m.done {
  15437. err = errors.New("querying old values post mutation is not allowed")
  15438. } else {
  15439. value, err = m.Client().CreditUsage.Get(ctx, id)
  15440. }
  15441. })
  15442. return value, err
  15443. }
  15444. m.id = &id
  15445. }
  15446. }
  15447. // withCreditUsage sets the old CreditUsage of the mutation.
  15448. func withCreditUsage(node *CreditUsage) creditusageOption {
  15449. return func(m *CreditUsageMutation) {
  15450. m.oldValue = func(context.Context) (*CreditUsage, error) {
  15451. return node, nil
  15452. }
  15453. m.id = &node.ID
  15454. }
  15455. }
  15456. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15457. // executed in a transaction (ent.Tx), a transactional client is returned.
  15458. func (m CreditUsageMutation) Client() *Client {
  15459. client := &Client{config: m.config}
  15460. client.init()
  15461. return client
  15462. }
  15463. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15464. // it returns an error otherwise.
  15465. func (m CreditUsageMutation) Tx() (*Tx, error) {
  15466. if _, ok := m.driver.(*txDriver); !ok {
  15467. return nil, errors.New("ent: mutation is not running in a transaction")
  15468. }
  15469. tx := &Tx{config: m.config}
  15470. tx.init()
  15471. return tx, nil
  15472. }
  15473. // SetID sets the value of the id field. Note that this
  15474. // operation is only accepted on creation of CreditUsage entities.
  15475. func (m *CreditUsageMutation) SetID(id uint64) {
  15476. m.id = &id
  15477. }
  15478. // ID returns the ID value in the mutation. Note that the ID is only available
  15479. // if it was provided to the builder or after it was returned from the database.
  15480. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  15481. if m.id == nil {
  15482. return
  15483. }
  15484. return *m.id, true
  15485. }
  15486. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15487. // That means, if the mutation is applied within a transaction with an isolation level such
  15488. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15489. // or updated by the mutation.
  15490. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  15491. switch {
  15492. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15493. id, exists := m.ID()
  15494. if exists {
  15495. return []uint64{id}, nil
  15496. }
  15497. fallthrough
  15498. case m.op.Is(OpUpdate | OpDelete):
  15499. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  15500. default:
  15501. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15502. }
  15503. }
  15504. // SetCreatedAt sets the "created_at" field.
  15505. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  15506. m.created_at = &t
  15507. }
  15508. // CreatedAt returns the value of the "created_at" field in the mutation.
  15509. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  15510. v := m.created_at
  15511. if v == nil {
  15512. return
  15513. }
  15514. return *v, true
  15515. }
  15516. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  15517. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15519. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15520. if !m.op.Is(OpUpdateOne) {
  15521. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15522. }
  15523. if m.id == nil || m.oldValue == nil {
  15524. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15525. }
  15526. oldValue, err := m.oldValue(ctx)
  15527. if err != nil {
  15528. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15529. }
  15530. return oldValue.CreatedAt, nil
  15531. }
  15532. // ResetCreatedAt resets all changes to the "created_at" field.
  15533. func (m *CreditUsageMutation) ResetCreatedAt() {
  15534. m.created_at = nil
  15535. }
  15536. // SetUpdatedAt sets the "updated_at" field.
  15537. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  15538. m.updated_at = &t
  15539. }
  15540. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15541. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  15542. v := m.updated_at
  15543. if v == nil {
  15544. return
  15545. }
  15546. return *v, true
  15547. }
  15548. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  15549. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15551. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15552. if !m.op.Is(OpUpdateOne) {
  15553. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15554. }
  15555. if m.id == nil || m.oldValue == nil {
  15556. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15557. }
  15558. oldValue, err := m.oldValue(ctx)
  15559. if err != nil {
  15560. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15561. }
  15562. return oldValue.UpdatedAt, nil
  15563. }
  15564. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15565. func (m *CreditUsageMutation) ResetUpdatedAt() {
  15566. m.updated_at = nil
  15567. }
  15568. // SetDeletedAt sets the "deleted_at" field.
  15569. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  15570. m.deleted_at = &t
  15571. }
  15572. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15573. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  15574. v := m.deleted_at
  15575. if v == nil {
  15576. return
  15577. }
  15578. return *v, true
  15579. }
  15580. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  15581. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15583. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15584. if !m.op.Is(OpUpdateOne) {
  15585. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15586. }
  15587. if m.id == nil || m.oldValue == nil {
  15588. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15589. }
  15590. oldValue, err := m.oldValue(ctx)
  15591. if err != nil {
  15592. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15593. }
  15594. return oldValue.DeletedAt, nil
  15595. }
  15596. // ClearDeletedAt clears the value of the "deleted_at" field.
  15597. func (m *CreditUsageMutation) ClearDeletedAt() {
  15598. m.deleted_at = nil
  15599. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  15600. }
  15601. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15602. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  15603. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  15604. return ok
  15605. }
  15606. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15607. func (m *CreditUsageMutation) ResetDeletedAt() {
  15608. m.deleted_at = nil
  15609. delete(m.clearedFields, creditusage.FieldDeletedAt)
  15610. }
  15611. // SetUserID sets the "user_id" field.
  15612. func (m *CreditUsageMutation) SetUserID(s string) {
  15613. m.user_id = &s
  15614. }
  15615. // UserID returns the value of the "user_id" field in the mutation.
  15616. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  15617. v := m.user_id
  15618. if v == nil {
  15619. return
  15620. }
  15621. return *v, true
  15622. }
  15623. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  15624. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15626. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  15627. if !m.op.Is(OpUpdateOne) {
  15628. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  15629. }
  15630. if m.id == nil || m.oldValue == nil {
  15631. return v, errors.New("OldUserID requires an ID field in the mutation")
  15632. }
  15633. oldValue, err := m.oldValue(ctx)
  15634. if err != nil {
  15635. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  15636. }
  15637. return oldValue.UserID, nil
  15638. }
  15639. // ClearUserID clears the value of the "user_id" field.
  15640. func (m *CreditUsageMutation) ClearUserID() {
  15641. m.user_id = nil
  15642. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  15643. }
  15644. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  15645. func (m *CreditUsageMutation) UserIDCleared() bool {
  15646. _, ok := m.clearedFields[creditusage.FieldUserID]
  15647. return ok
  15648. }
  15649. // ResetUserID resets all changes to the "user_id" field.
  15650. func (m *CreditUsageMutation) ResetUserID() {
  15651. m.user_id = nil
  15652. delete(m.clearedFields, creditusage.FieldUserID)
  15653. }
  15654. // SetNumber sets the "number" field.
  15655. func (m *CreditUsageMutation) SetNumber(f float64) {
  15656. m.number = &f
  15657. m.addnumber = nil
  15658. }
  15659. // Number returns the value of the "number" field in the mutation.
  15660. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  15661. v := m.number
  15662. if v == nil {
  15663. return
  15664. }
  15665. return *v, true
  15666. }
  15667. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  15668. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15670. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  15671. if !m.op.Is(OpUpdateOne) {
  15672. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  15673. }
  15674. if m.id == nil || m.oldValue == nil {
  15675. return v, errors.New("OldNumber requires an ID field in the mutation")
  15676. }
  15677. oldValue, err := m.oldValue(ctx)
  15678. if err != nil {
  15679. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  15680. }
  15681. return oldValue.Number, nil
  15682. }
  15683. // AddNumber adds f to the "number" field.
  15684. func (m *CreditUsageMutation) AddNumber(f float64) {
  15685. if m.addnumber != nil {
  15686. *m.addnumber += f
  15687. } else {
  15688. m.addnumber = &f
  15689. }
  15690. }
  15691. // AddedNumber returns the value that was added to the "number" field in this mutation.
  15692. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  15693. v := m.addnumber
  15694. if v == nil {
  15695. return
  15696. }
  15697. return *v, true
  15698. }
  15699. // ResetNumber resets all changes to the "number" field.
  15700. func (m *CreditUsageMutation) ResetNumber() {
  15701. m.number = nil
  15702. m.addnumber = nil
  15703. }
  15704. // SetPayNumber sets the "pay_number" field.
  15705. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  15706. m.pay_number = &f
  15707. m.addpay_number = nil
  15708. }
  15709. // PayNumber returns the value of the "pay_number" field in the mutation.
  15710. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  15711. v := m.pay_number
  15712. if v == nil {
  15713. return
  15714. }
  15715. return *v, true
  15716. }
  15717. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  15718. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15720. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  15721. if !m.op.Is(OpUpdateOne) {
  15722. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  15723. }
  15724. if m.id == nil || m.oldValue == nil {
  15725. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  15726. }
  15727. oldValue, err := m.oldValue(ctx)
  15728. if err != nil {
  15729. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  15730. }
  15731. return oldValue.PayNumber, nil
  15732. }
  15733. // AddPayNumber adds f to the "pay_number" field.
  15734. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  15735. if m.addpay_number != nil {
  15736. *m.addpay_number += f
  15737. } else {
  15738. m.addpay_number = &f
  15739. }
  15740. }
  15741. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  15742. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  15743. v := m.addpay_number
  15744. if v == nil {
  15745. return
  15746. }
  15747. return *v, true
  15748. }
  15749. // ClearPayNumber clears the value of the "pay_number" field.
  15750. func (m *CreditUsageMutation) ClearPayNumber() {
  15751. m.pay_number = nil
  15752. m.addpay_number = nil
  15753. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  15754. }
  15755. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  15756. func (m *CreditUsageMutation) PayNumberCleared() bool {
  15757. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  15758. return ok
  15759. }
  15760. // ResetPayNumber resets all changes to the "pay_number" field.
  15761. func (m *CreditUsageMutation) ResetPayNumber() {
  15762. m.pay_number = nil
  15763. m.addpay_number = nil
  15764. delete(m.clearedFields, creditusage.FieldPayNumber)
  15765. }
  15766. // SetBeforeNumber sets the "before_number" field.
  15767. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  15768. m.before_number = &f
  15769. m.addbefore_number = nil
  15770. }
  15771. // BeforeNumber returns the value of the "before_number" field in the mutation.
  15772. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  15773. v := m.before_number
  15774. if v == nil {
  15775. return
  15776. }
  15777. return *v, true
  15778. }
  15779. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  15780. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15782. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  15783. if !m.op.Is(OpUpdateOne) {
  15784. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  15785. }
  15786. if m.id == nil || m.oldValue == nil {
  15787. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  15788. }
  15789. oldValue, err := m.oldValue(ctx)
  15790. if err != nil {
  15791. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  15792. }
  15793. return oldValue.BeforeNumber, nil
  15794. }
  15795. // AddBeforeNumber adds f to the "before_number" field.
  15796. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  15797. if m.addbefore_number != nil {
  15798. *m.addbefore_number += f
  15799. } else {
  15800. m.addbefore_number = &f
  15801. }
  15802. }
  15803. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  15804. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  15805. v := m.addbefore_number
  15806. if v == nil {
  15807. return
  15808. }
  15809. return *v, true
  15810. }
  15811. // ClearBeforeNumber clears the value of the "before_number" field.
  15812. func (m *CreditUsageMutation) ClearBeforeNumber() {
  15813. m.before_number = nil
  15814. m.addbefore_number = nil
  15815. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  15816. }
  15817. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  15818. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  15819. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  15820. return ok
  15821. }
  15822. // ResetBeforeNumber resets all changes to the "before_number" field.
  15823. func (m *CreditUsageMutation) ResetBeforeNumber() {
  15824. m.before_number = nil
  15825. m.addbefore_number = nil
  15826. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  15827. }
  15828. // SetAfterNumber sets the "after_number" field.
  15829. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  15830. m.after_number = &f
  15831. m.addafter_number = nil
  15832. }
  15833. // AfterNumber returns the value of the "after_number" field in the mutation.
  15834. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  15835. v := m.after_number
  15836. if v == nil {
  15837. return
  15838. }
  15839. return *v, true
  15840. }
  15841. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  15842. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15844. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  15845. if !m.op.Is(OpUpdateOne) {
  15846. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  15847. }
  15848. if m.id == nil || m.oldValue == nil {
  15849. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  15850. }
  15851. oldValue, err := m.oldValue(ctx)
  15852. if err != nil {
  15853. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  15854. }
  15855. return oldValue.AfterNumber, nil
  15856. }
  15857. // AddAfterNumber adds f to the "after_number" field.
  15858. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  15859. if m.addafter_number != nil {
  15860. *m.addafter_number += f
  15861. } else {
  15862. m.addafter_number = &f
  15863. }
  15864. }
  15865. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  15866. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  15867. v := m.addafter_number
  15868. if v == nil {
  15869. return
  15870. }
  15871. return *v, true
  15872. }
  15873. // ClearAfterNumber clears the value of the "after_number" field.
  15874. func (m *CreditUsageMutation) ClearAfterNumber() {
  15875. m.after_number = nil
  15876. m.addafter_number = nil
  15877. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  15878. }
  15879. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  15880. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  15881. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  15882. return ok
  15883. }
  15884. // ResetAfterNumber resets all changes to the "after_number" field.
  15885. func (m *CreditUsageMutation) ResetAfterNumber() {
  15886. m.after_number = nil
  15887. m.addafter_number = nil
  15888. delete(m.clearedFields, creditusage.FieldAfterNumber)
  15889. }
  15890. // SetPayMethod sets the "pay_method" field.
  15891. func (m *CreditUsageMutation) SetPayMethod(i int) {
  15892. m.pay_method = &i
  15893. m.addpay_method = nil
  15894. }
  15895. // PayMethod returns the value of the "pay_method" field in the mutation.
  15896. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  15897. v := m.pay_method
  15898. if v == nil {
  15899. return
  15900. }
  15901. return *v, true
  15902. }
  15903. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  15904. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15906. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  15907. if !m.op.Is(OpUpdateOne) {
  15908. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  15909. }
  15910. if m.id == nil || m.oldValue == nil {
  15911. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  15912. }
  15913. oldValue, err := m.oldValue(ctx)
  15914. if err != nil {
  15915. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  15916. }
  15917. return oldValue.PayMethod, nil
  15918. }
  15919. // AddPayMethod adds i to the "pay_method" field.
  15920. func (m *CreditUsageMutation) AddPayMethod(i int) {
  15921. if m.addpay_method != nil {
  15922. *m.addpay_method += i
  15923. } else {
  15924. m.addpay_method = &i
  15925. }
  15926. }
  15927. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  15928. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  15929. v := m.addpay_method
  15930. if v == nil {
  15931. return
  15932. }
  15933. return *v, true
  15934. }
  15935. // ClearPayMethod clears the value of the "pay_method" field.
  15936. func (m *CreditUsageMutation) ClearPayMethod() {
  15937. m.pay_method = nil
  15938. m.addpay_method = nil
  15939. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  15940. }
  15941. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  15942. func (m *CreditUsageMutation) PayMethodCleared() bool {
  15943. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  15944. return ok
  15945. }
  15946. // ResetPayMethod resets all changes to the "pay_method" field.
  15947. func (m *CreditUsageMutation) ResetPayMethod() {
  15948. m.pay_method = nil
  15949. m.addpay_method = nil
  15950. delete(m.clearedFields, creditusage.FieldPayMethod)
  15951. }
  15952. // SetStatus sets the "status" field.
  15953. func (m *CreditUsageMutation) SetStatus(i int) {
  15954. m.status = &i
  15955. m.addstatus = nil
  15956. }
  15957. // Status returns the value of the "status" field in the mutation.
  15958. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  15959. v := m.status
  15960. if v == nil {
  15961. return
  15962. }
  15963. return *v, true
  15964. }
  15965. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  15966. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  15967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15968. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  15969. if !m.op.Is(OpUpdateOne) {
  15970. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15971. }
  15972. if m.id == nil || m.oldValue == nil {
  15973. return v, errors.New("OldStatus requires an ID field in the mutation")
  15974. }
  15975. oldValue, err := m.oldValue(ctx)
  15976. if err != nil {
  15977. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15978. }
  15979. return oldValue.Status, nil
  15980. }
  15981. // AddStatus adds i to the "status" field.
  15982. func (m *CreditUsageMutation) AddStatus(i int) {
  15983. if m.addstatus != nil {
  15984. *m.addstatus += i
  15985. } else {
  15986. m.addstatus = &i
  15987. }
  15988. }
  15989. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15990. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  15991. v := m.addstatus
  15992. if v == nil {
  15993. return
  15994. }
  15995. return *v, true
  15996. }
  15997. // ClearStatus clears the value of the "status" field.
  15998. func (m *CreditUsageMutation) ClearStatus() {
  15999. m.status = nil
  16000. m.addstatus = nil
  16001. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  16002. }
  16003. // StatusCleared returns if the "status" field was cleared in this mutation.
  16004. func (m *CreditUsageMutation) StatusCleared() bool {
  16005. _, ok := m.clearedFields[creditusage.FieldStatus]
  16006. return ok
  16007. }
  16008. // ResetStatus resets all changes to the "status" field.
  16009. func (m *CreditUsageMutation) ResetStatus() {
  16010. m.status = nil
  16011. m.addstatus = nil
  16012. delete(m.clearedFields, creditusage.FieldStatus)
  16013. }
  16014. // SetNtype sets the "ntype" field.
  16015. func (m *CreditUsageMutation) SetNtype(i int) {
  16016. m.ntype = &i
  16017. m.addntype = nil
  16018. }
  16019. // Ntype returns the value of the "ntype" field in the mutation.
  16020. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  16021. v := m.ntype
  16022. if v == nil {
  16023. return
  16024. }
  16025. return *v, true
  16026. }
  16027. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  16028. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16030. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  16031. if !m.op.Is(OpUpdateOne) {
  16032. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  16033. }
  16034. if m.id == nil || m.oldValue == nil {
  16035. return v, errors.New("OldNtype requires an ID field in the mutation")
  16036. }
  16037. oldValue, err := m.oldValue(ctx)
  16038. if err != nil {
  16039. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  16040. }
  16041. return oldValue.Ntype, nil
  16042. }
  16043. // AddNtype adds i to the "ntype" field.
  16044. func (m *CreditUsageMutation) AddNtype(i int) {
  16045. if m.addntype != nil {
  16046. *m.addntype += i
  16047. } else {
  16048. m.addntype = &i
  16049. }
  16050. }
  16051. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  16052. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  16053. v := m.addntype
  16054. if v == nil {
  16055. return
  16056. }
  16057. return *v, true
  16058. }
  16059. // ResetNtype resets all changes to the "ntype" field.
  16060. func (m *CreditUsageMutation) ResetNtype() {
  16061. m.ntype = nil
  16062. m.addntype = nil
  16063. }
  16064. // SetTable sets the "table" field.
  16065. func (m *CreditUsageMutation) SetTable(s string) {
  16066. m.table = &s
  16067. }
  16068. // Table returns the value of the "table" field in the mutation.
  16069. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  16070. v := m.table
  16071. if v == nil {
  16072. return
  16073. }
  16074. return *v, true
  16075. }
  16076. // OldTable returns the old "table" field's value of the CreditUsage entity.
  16077. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16079. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  16080. if !m.op.Is(OpUpdateOne) {
  16081. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  16082. }
  16083. if m.id == nil || m.oldValue == nil {
  16084. return v, errors.New("OldTable requires an ID field in the mutation")
  16085. }
  16086. oldValue, err := m.oldValue(ctx)
  16087. if err != nil {
  16088. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  16089. }
  16090. return oldValue.Table, nil
  16091. }
  16092. // ResetTable resets all changes to the "table" field.
  16093. func (m *CreditUsageMutation) ResetTable() {
  16094. m.table = nil
  16095. }
  16096. // SetOrganizationID sets the "organization_id" field.
  16097. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  16098. m.organization_id = &u
  16099. m.addorganization_id = nil
  16100. }
  16101. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16102. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  16103. v := m.organization_id
  16104. if v == nil {
  16105. return
  16106. }
  16107. return *v, true
  16108. }
  16109. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  16110. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16112. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16113. if !m.op.Is(OpUpdateOne) {
  16114. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16115. }
  16116. if m.id == nil || m.oldValue == nil {
  16117. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16118. }
  16119. oldValue, err := m.oldValue(ctx)
  16120. if err != nil {
  16121. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16122. }
  16123. return oldValue.OrganizationID, nil
  16124. }
  16125. // AddOrganizationID adds u to the "organization_id" field.
  16126. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  16127. if m.addorganization_id != nil {
  16128. *m.addorganization_id += u
  16129. } else {
  16130. m.addorganization_id = &u
  16131. }
  16132. }
  16133. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16134. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  16135. v := m.addorganization_id
  16136. if v == nil {
  16137. return
  16138. }
  16139. return *v, true
  16140. }
  16141. // ClearOrganizationID clears the value of the "organization_id" field.
  16142. func (m *CreditUsageMutation) ClearOrganizationID() {
  16143. m.organization_id = nil
  16144. m.addorganization_id = nil
  16145. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  16146. }
  16147. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16148. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  16149. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  16150. return ok
  16151. }
  16152. // ResetOrganizationID resets all changes to the "organization_id" field.
  16153. func (m *CreditUsageMutation) ResetOrganizationID() {
  16154. m.organization_id = nil
  16155. m.addorganization_id = nil
  16156. delete(m.clearedFields, creditusage.FieldOrganizationID)
  16157. }
  16158. // SetNid sets the "nid" field.
  16159. func (m *CreditUsageMutation) SetNid(u uint64) {
  16160. m.nid = &u
  16161. m.addnid = nil
  16162. }
  16163. // Nid returns the value of the "nid" field in the mutation.
  16164. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  16165. v := m.nid
  16166. if v == nil {
  16167. return
  16168. }
  16169. return *v, true
  16170. }
  16171. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  16172. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16174. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  16175. if !m.op.Is(OpUpdateOne) {
  16176. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  16177. }
  16178. if m.id == nil || m.oldValue == nil {
  16179. return v, errors.New("OldNid requires an ID field in the mutation")
  16180. }
  16181. oldValue, err := m.oldValue(ctx)
  16182. if err != nil {
  16183. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  16184. }
  16185. return oldValue.Nid, nil
  16186. }
  16187. // AddNid adds u to the "nid" field.
  16188. func (m *CreditUsageMutation) AddNid(u int64) {
  16189. if m.addnid != nil {
  16190. *m.addnid += u
  16191. } else {
  16192. m.addnid = &u
  16193. }
  16194. }
  16195. // AddedNid returns the value that was added to the "nid" field in this mutation.
  16196. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  16197. v := m.addnid
  16198. if v == nil {
  16199. return
  16200. }
  16201. return *v, true
  16202. }
  16203. // ResetNid resets all changes to the "nid" field.
  16204. func (m *CreditUsageMutation) ResetNid() {
  16205. m.nid = nil
  16206. m.addnid = nil
  16207. }
  16208. // SetReason sets the "reason" field.
  16209. func (m *CreditUsageMutation) SetReason(s string) {
  16210. m.reason = &s
  16211. }
  16212. // Reason returns the value of the "reason" field in the mutation.
  16213. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  16214. v := m.reason
  16215. if v == nil {
  16216. return
  16217. }
  16218. return *v, true
  16219. }
  16220. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  16221. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16223. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  16224. if !m.op.Is(OpUpdateOne) {
  16225. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  16226. }
  16227. if m.id == nil || m.oldValue == nil {
  16228. return v, errors.New("OldReason requires an ID field in the mutation")
  16229. }
  16230. oldValue, err := m.oldValue(ctx)
  16231. if err != nil {
  16232. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  16233. }
  16234. return oldValue.Reason, nil
  16235. }
  16236. // ResetReason resets all changes to the "reason" field.
  16237. func (m *CreditUsageMutation) ResetReason() {
  16238. m.reason = nil
  16239. }
  16240. // SetOperator sets the "operator" field.
  16241. func (m *CreditUsageMutation) SetOperator(s string) {
  16242. m.operator = &s
  16243. }
  16244. // Operator returns the value of the "operator" field in the mutation.
  16245. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  16246. v := m.operator
  16247. if v == nil {
  16248. return
  16249. }
  16250. return *v, true
  16251. }
  16252. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  16253. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16255. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  16256. if !m.op.Is(OpUpdateOne) {
  16257. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  16258. }
  16259. if m.id == nil || m.oldValue == nil {
  16260. return v, errors.New("OldOperator requires an ID field in the mutation")
  16261. }
  16262. oldValue, err := m.oldValue(ctx)
  16263. if err != nil {
  16264. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  16265. }
  16266. return oldValue.Operator, nil
  16267. }
  16268. // ResetOperator resets all changes to the "operator" field.
  16269. func (m *CreditUsageMutation) ResetOperator() {
  16270. m.operator = nil
  16271. }
  16272. // Where appends a list predicates to the CreditUsageMutation builder.
  16273. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  16274. m.predicates = append(m.predicates, ps...)
  16275. }
  16276. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  16277. // users can use type-assertion to append predicates that do not depend on any generated package.
  16278. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  16279. p := make([]predicate.CreditUsage, len(ps))
  16280. for i := range ps {
  16281. p[i] = ps[i]
  16282. }
  16283. m.Where(p...)
  16284. }
  16285. // Op returns the operation name.
  16286. func (m *CreditUsageMutation) Op() Op {
  16287. return m.op
  16288. }
  16289. // SetOp allows setting the mutation operation.
  16290. func (m *CreditUsageMutation) SetOp(op Op) {
  16291. m.op = op
  16292. }
  16293. // Type returns the node type of this mutation (CreditUsage).
  16294. func (m *CreditUsageMutation) Type() string {
  16295. return m.typ
  16296. }
  16297. // Fields returns all fields that were changed during this mutation. Note that in
  16298. // order to get all numeric fields that were incremented/decremented, call
  16299. // AddedFields().
  16300. func (m *CreditUsageMutation) Fields() []string {
  16301. fields := make([]string, 0, 16)
  16302. if m.created_at != nil {
  16303. fields = append(fields, creditusage.FieldCreatedAt)
  16304. }
  16305. if m.updated_at != nil {
  16306. fields = append(fields, creditusage.FieldUpdatedAt)
  16307. }
  16308. if m.deleted_at != nil {
  16309. fields = append(fields, creditusage.FieldDeletedAt)
  16310. }
  16311. if m.user_id != nil {
  16312. fields = append(fields, creditusage.FieldUserID)
  16313. }
  16314. if m.number != nil {
  16315. fields = append(fields, creditusage.FieldNumber)
  16316. }
  16317. if m.pay_number != nil {
  16318. fields = append(fields, creditusage.FieldPayNumber)
  16319. }
  16320. if m.before_number != nil {
  16321. fields = append(fields, creditusage.FieldBeforeNumber)
  16322. }
  16323. if m.after_number != nil {
  16324. fields = append(fields, creditusage.FieldAfterNumber)
  16325. }
  16326. if m.pay_method != nil {
  16327. fields = append(fields, creditusage.FieldPayMethod)
  16328. }
  16329. if m.status != nil {
  16330. fields = append(fields, creditusage.FieldStatus)
  16331. }
  16332. if m.ntype != nil {
  16333. fields = append(fields, creditusage.FieldNtype)
  16334. }
  16335. if m.table != nil {
  16336. fields = append(fields, creditusage.FieldTable)
  16337. }
  16338. if m.organization_id != nil {
  16339. fields = append(fields, creditusage.FieldOrganizationID)
  16340. }
  16341. if m.nid != nil {
  16342. fields = append(fields, creditusage.FieldNid)
  16343. }
  16344. if m.reason != nil {
  16345. fields = append(fields, creditusage.FieldReason)
  16346. }
  16347. if m.operator != nil {
  16348. fields = append(fields, creditusage.FieldOperator)
  16349. }
  16350. return fields
  16351. }
  16352. // Field returns the value of a field with the given name. The second boolean
  16353. // return value indicates that this field was not set, or was not defined in the
  16354. // schema.
  16355. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  16356. switch name {
  16357. case creditusage.FieldCreatedAt:
  16358. return m.CreatedAt()
  16359. case creditusage.FieldUpdatedAt:
  16360. return m.UpdatedAt()
  16361. case creditusage.FieldDeletedAt:
  16362. return m.DeletedAt()
  16363. case creditusage.FieldUserID:
  16364. return m.UserID()
  16365. case creditusage.FieldNumber:
  16366. return m.Number()
  16367. case creditusage.FieldPayNumber:
  16368. return m.PayNumber()
  16369. case creditusage.FieldBeforeNumber:
  16370. return m.BeforeNumber()
  16371. case creditusage.FieldAfterNumber:
  16372. return m.AfterNumber()
  16373. case creditusage.FieldPayMethod:
  16374. return m.PayMethod()
  16375. case creditusage.FieldStatus:
  16376. return m.Status()
  16377. case creditusage.FieldNtype:
  16378. return m.Ntype()
  16379. case creditusage.FieldTable:
  16380. return m.Table()
  16381. case creditusage.FieldOrganizationID:
  16382. return m.OrganizationID()
  16383. case creditusage.FieldNid:
  16384. return m.Nid()
  16385. case creditusage.FieldReason:
  16386. return m.Reason()
  16387. case creditusage.FieldOperator:
  16388. return m.Operator()
  16389. }
  16390. return nil, false
  16391. }
  16392. // OldField returns the old value of the field from the database. An error is
  16393. // returned if the mutation operation is not UpdateOne, or the query to the
  16394. // database failed.
  16395. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16396. switch name {
  16397. case creditusage.FieldCreatedAt:
  16398. return m.OldCreatedAt(ctx)
  16399. case creditusage.FieldUpdatedAt:
  16400. return m.OldUpdatedAt(ctx)
  16401. case creditusage.FieldDeletedAt:
  16402. return m.OldDeletedAt(ctx)
  16403. case creditusage.FieldUserID:
  16404. return m.OldUserID(ctx)
  16405. case creditusage.FieldNumber:
  16406. return m.OldNumber(ctx)
  16407. case creditusage.FieldPayNumber:
  16408. return m.OldPayNumber(ctx)
  16409. case creditusage.FieldBeforeNumber:
  16410. return m.OldBeforeNumber(ctx)
  16411. case creditusage.FieldAfterNumber:
  16412. return m.OldAfterNumber(ctx)
  16413. case creditusage.FieldPayMethod:
  16414. return m.OldPayMethod(ctx)
  16415. case creditusage.FieldStatus:
  16416. return m.OldStatus(ctx)
  16417. case creditusage.FieldNtype:
  16418. return m.OldNtype(ctx)
  16419. case creditusage.FieldTable:
  16420. return m.OldTable(ctx)
  16421. case creditusage.FieldOrganizationID:
  16422. return m.OldOrganizationID(ctx)
  16423. case creditusage.FieldNid:
  16424. return m.OldNid(ctx)
  16425. case creditusage.FieldReason:
  16426. return m.OldReason(ctx)
  16427. case creditusage.FieldOperator:
  16428. return m.OldOperator(ctx)
  16429. }
  16430. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  16431. }
  16432. // SetField sets the value of a field with the given name. It returns an error if
  16433. // the field is not defined in the schema, or if the type mismatched the field
  16434. // type.
  16435. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  16436. switch name {
  16437. case creditusage.FieldCreatedAt:
  16438. v, ok := value.(time.Time)
  16439. if !ok {
  16440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16441. }
  16442. m.SetCreatedAt(v)
  16443. return nil
  16444. case creditusage.FieldUpdatedAt:
  16445. v, ok := value.(time.Time)
  16446. if !ok {
  16447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16448. }
  16449. m.SetUpdatedAt(v)
  16450. return nil
  16451. case creditusage.FieldDeletedAt:
  16452. v, ok := value.(time.Time)
  16453. if !ok {
  16454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16455. }
  16456. m.SetDeletedAt(v)
  16457. return nil
  16458. case creditusage.FieldUserID:
  16459. v, ok := value.(string)
  16460. if !ok {
  16461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16462. }
  16463. m.SetUserID(v)
  16464. return nil
  16465. case creditusage.FieldNumber:
  16466. v, ok := value.(float64)
  16467. if !ok {
  16468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16469. }
  16470. m.SetNumber(v)
  16471. return nil
  16472. case creditusage.FieldPayNumber:
  16473. v, ok := value.(float64)
  16474. if !ok {
  16475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16476. }
  16477. m.SetPayNumber(v)
  16478. return nil
  16479. case creditusage.FieldBeforeNumber:
  16480. v, ok := value.(float64)
  16481. if !ok {
  16482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16483. }
  16484. m.SetBeforeNumber(v)
  16485. return nil
  16486. case creditusage.FieldAfterNumber:
  16487. v, ok := value.(float64)
  16488. if !ok {
  16489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16490. }
  16491. m.SetAfterNumber(v)
  16492. return nil
  16493. case creditusage.FieldPayMethod:
  16494. v, ok := value.(int)
  16495. if !ok {
  16496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16497. }
  16498. m.SetPayMethod(v)
  16499. return nil
  16500. case creditusage.FieldStatus:
  16501. v, ok := value.(int)
  16502. if !ok {
  16503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16504. }
  16505. m.SetStatus(v)
  16506. return nil
  16507. case creditusage.FieldNtype:
  16508. v, ok := value.(int)
  16509. if !ok {
  16510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16511. }
  16512. m.SetNtype(v)
  16513. return nil
  16514. case creditusage.FieldTable:
  16515. v, ok := value.(string)
  16516. if !ok {
  16517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16518. }
  16519. m.SetTable(v)
  16520. return nil
  16521. case creditusage.FieldOrganizationID:
  16522. v, ok := value.(uint64)
  16523. if !ok {
  16524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16525. }
  16526. m.SetOrganizationID(v)
  16527. return nil
  16528. case creditusage.FieldNid:
  16529. v, ok := value.(uint64)
  16530. if !ok {
  16531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16532. }
  16533. m.SetNid(v)
  16534. return nil
  16535. case creditusage.FieldReason:
  16536. v, ok := value.(string)
  16537. if !ok {
  16538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16539. }
  16540. m.SetReason(v)
  16541. return nil
  16542. case creditusage.FieldOperator:
  16543. v, ok := value.(string)
  16544. if !ok {
  16545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16546. }
  16547. m.SetOperator(v)
  16548. return nil
  16549. }
  16550. return fmt.Errorf("unknown CreditUsage field %s", name)
  16551. }
  16552. // AddedFields returns all numeric fields that were incremented/decremented during
  16553. // this mutation.
  16554. func (m *CreditUsageMutation) AddedFields() []string {
  16555. var fields []string
  16556. if m.addnumber != nil {
  16557. fields = append(fields, creditusage.FieldNumber)
  16558. }
  16559. if m.addpay_number != nil {
  16560. fields = append(fields, creditusage.FieldPayNumber)
  16561. }
  16562. if m.addbefore_number != nil {
  16563. fields = append(fields, creditusage.FieldBeforeNumber)
  16564. }
  16565. if m.addafter_number != nil {
  16566. fields = append(fields, creditusage.FieldAfterNumber)
  16567. }
  16568. if m.addpay_method != nil {
  16569. fields = append(fields, creditusage.FieldPayMethod)
  16570. }
  16571. if m.addstatus != nil {
  16572. fields = append(fields, creditusage.FieldStatus)
  16573. }
  16574. if m.addntype != nil {
  16575. fields = append(fields, creditusage.FieldNtype)
  16576. }
  16577. if m.addorganization_id != nil {
  16578. fields = append(fields, creditusage.FieldOrganizationID)
  16579. }
  16580. if m.addnid != nil {
  16581. fields = append(fields, creditusage.FieldNid)
  16582. }
  16583. return fields
  16584. }
  16585. // AddedField returns the numeric value that was incremented/decremented on a field
  16586. // with the given name. The second boolean return value indicates that this field
  16587. // was not set, or was not defined in the schema.
  16588. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  16589. switch name {
  16590. case creditusage.FieldNumber:
  16591. return m.AddedNumber()
  16592. case creditusage.FieldPayNumber:
  16593. return m.AddedPayNumber()
  16594. case creditusage.FieldBeforeNumber:
  16595. return m.AddedBeforeNumber()
  16596. case creditusage.FieldAfterNumber:
  16597. return m.AddedAfterNumber()
  16598. case creditusage.FieldPayMethod:
  16599. return m.AddedPayMethod()
  16600. case creditusage.FieldStatus:
  16601. return m.AddedStatus()
  16602. case creditusage.FieldNtype:
  16603. return m.AddedNtype()
  16604. case creditusage.FieldOrganizationID:
  16605. return m.AddedOrganizationID()
  16606. case creditusage.FieldNid:
  16607. return m.AddedNid()
  16608. }
  16609. return nil, false
  16610. }
  16611. // AddField adds the value to the field with the given name. It returns an error if
  16612. // the field is not defined in the schema, or if the type mismatched the field
  16613. // type.
  16614. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  16615. switch name {
  16616. case creditusage.FieldNumber:
  16617. v, ok := value.(float64)
  16618. if !ok {
  16619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16620. }
  16621. m.AddNumber(v)
  16622. return nil
  16623. case creditusage.FieldPayNumber:
  16624. v, ok := value.(float64)
  16625. if !ok {
  16626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16627. }
  16628. m.AddPayNumber(v)
  16629. return nil
  16630. case creditusage.FieldBeforeNumber:
  16631. v, ok := value.(float64)
  16632. if !ok {
  16633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16634. }
  16635. m.AddBeforeNumber(v)
  16636. return nil
  16637. case creditusage.FieldAfterNumber:
  16638. v, ok := value.(float64)
  16639. if !ok {
  16640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16641. }
  16642. m.AddAfterNumber(v)
  16643. return nil
  16644. case creditusage.FieldPayMethod:
  16645. v, ok := value.(int)
  16646. if !ok {
  16647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16648. }
  16649. m.AddPayMethod(v)
  16650. return nil
  16651. case creditusage.FieldStatus:
  16652. v, ok := value.(int)
  16653. if !ok {
  16654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16655. }
  16656. m.AddStatus(v)
  16657. return nil
  16658. case creditusage.FieldNtype:
  16659. v, ok := value.(int)
  16660. if !ok {
  16661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16662. }
  16663. m.AddNtype(v)
  16664. return nil
  16665. case creditusage.FieldOrganizationID:
  16666. v, ok := value.(int64)
  16667. if !ok {
  16668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16669. }
  16670. m.AddOrganizationID(v)
  16671. return nil
  16672. case creditusage.FieldNid:
  16673. v, ok := value.(int64)
  16674. if !ok {
  16675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16676. }
  16677. m.AddNid(v)
  16678. return nil
  16679. }
  16680. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  16681. }
  16682. // ClearedFields returns all nullable fields that were cleared during this
  16683. // mutation.
  16684. func (m *CreditUsageMutation) ClearedFields() []string {
  16685. var fields []string
  16686. if m.FieldCleared(creditusage.FieldDeletedAt) {
  16687. fields = append(fields, creditusage.FieldDeletedAt)
  16688. }
  16689. if m.FieldCleared(creditusage.FieldUserID) {
  16690. fields = append(fields, creditusage.FieldUserID)
  16691. }
  16692. if m.FieldCleared(creditusage.FieldPayNumber) {
  16693. fields = append(fields, creditusage.FieldPayNumber)
  16694. }
  16695. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  16696. fields = append(fields, creditusage.FieldBeforeNumber)
  16697. }
  16698. if m.FieldCleared(creditusage.FieldAfterNumber) {
  16699. fields = append(fields, creditusage.FieldAfterNumber)
  16700. }
  16701. if m.FieldCleared(creditusage.FieldPayMethod) {
  16702. fields = append(fields, creditusage.FieldPayMethod)
  16703. }
  16704. if m.FieldCleared(creditusage.FieldStatus) {
  16705. fields = append(fields, creditusage.FieldStatus)
  16706. }
  16707. if m.FieldCleared(creditusage.FieldOrganizationID) {
  16708. fields = append(fields, creditusage.FieldOrganizationID)
  16709. }
  16710. return fields
  16711. }
  16712. // FieldCleared returns a boolean indicating if a field with the given name was
  16713. // cleared in this mutation.
  16714. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  16715. _, ok := m.clearedFields[name]
  16716. return ok
  16717. }
  16718. // ClearField clears the value of the field with the given name. It returns an
  16719. // error if the field is not defined in the schema.
  16720. func (m *CreditUsageMutation) ClearField(name string) error {
  16721. switch name {
  16722. case creditusage.FieldDeletedAt:
  16723. m.ClearDeletedAt()
  16724. return nil
  16725. case creditusage.FieldUserID:
  16726. m.ClearUserID()
  16727. return nil
  16728. case creditusage.FieldPayNumber:
  16729. m.ClearPayNumber()
  16730. return nil
  16731. case creditusage.FieldBeforeNumber:
  16732. m.ClearBeforeNumber()
  16733. return nil
  16734. case creditusage.FieldAfterNumber:
  16735. m.ClearAfterNumber()
  16736. return nil
  16737. case creditusage.FieldPayMethod:
  16738. m.ClearPayMethod()
  16739. return nil
  16740. case creditusage.FieldStatus:
  16741. m.ClearStatus()
  16742. return nil
  16743. case creditusage.FieldOrganizationID:
  16744. m.ClearOrganizationID()
  16745. return nil
  16746. }
  16747. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  16748. }
  16749. // ResetField resets all changes in the mutation for the field with the given name.
  16750. // It returns an error if the field is not defined in the schema.
  16751. func (m *CreditUsageMutation) ResetField(name string) error {
  16752. switch name {
  16753. case creditusage.FieldCreatedAt:
  16754. m.ResetCreatedAt()
  16755. return nil
  16756. case creditusage.FieldUpdatedAt:
  16757. m.ResetUpdatedAt()
  16758. return nil
  16759. case creditusage.FieldDeletedAt:
  16760. m.ResetDeletedAt()
  16761. return nil
  16762. case creditusage.FieldUserID:
  16763. m.ResetUserID()
  16764. return nil
  16765. case creditusage.FieldNumber:
  16766. m.ResetNumber()
  16767. return nil
  16768. case creditusage.FieldPayNumber:
  16769. m.ResetPayNumber()
  16770. return nil
  16771. case creditusage.FieldBeforeNumber:
  16772. m.ResetBeforeNumber()
  16773. return nil
  16774. case creditusage.FieldAfterNumber:
  16775. m.ResetAfterNumber()
  16776. return nil
  16777. case creditusage.FieldPayMethod:
  16778. m.ResetPayMethod()
  16779. return nil
  16780. case creditusage.FieldStatus:
  16781. m.ResetStatus()
  16782. return nil
  16783. case creditusage.FieldNtype:
  16784. m.ResetNtype()
  16785. return nil
  16786. case creditusage.FieldTable:
  16787. m.ResetTable()
  16788. return nil
  16789. case creditusage.FieldOrganizationID:
  16790. m.ResetOrganizationID()
  16791. return nil
  16792. case creditusage.FieldNid:
  16793. m.ResetNid()
  16794. return nil
  16795. case creditusage.FieldReason:
  16796. m.ResetReason()
  16797. return nil
  16798. case creditusage.FieldOperator:
  16799. m.ResetOperator()
  16800. return nil
  16801. }
  16802. return fmt.Errorf("unknown CreditUsage field %s", name)
  16803. }
  16804. // AddedEdges returns all edge names that were set/added in this mutation.
  16805. func (m *CreditUsageMutation) AddedEdges() []string {
  16806. edges := make([]string, 0, 0)
  16807. return edges
  16808. }
  16809. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16810. // name in this mutation.
  16811. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  16812. return nil
  16813. }
  16814. // RemovedEdges returns all edge names that were removed in this mutation.
  16815. func (m *CreditUsageMutation) RemovedEdges() []string {
  16816. edges := make([]string, 0, 0)
  16817. return edges
  16818. }
  16819. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16820. // the given name in this mutation.
  16821. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  16822. return nil
  16823. }
  16824. // ClearedEdges returns all edge names that were cleared in this mutation.
  16825. func (m *CreditUsageMutation) ClearedEdges() []string {
  16826. edges := make([]string, 0, 0)
  16827. return edges
  16828. }
  16829. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16830. // was cleared in this mutation.
  16831. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  16832. return false
  16833. }
  16834. // ClearEdge clears the value of the edge with the given name. It returns an error
  16835. // if that edge is not defined in the schema.
  16836. func (m *CreditUsageMutation) ClearEdge(name string) error {
  16837. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  16838. }
  16839. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16840. // It returns an error if the edge is not defined in the schema.
  16841. func (m *CreditUsageMutation) ResetEdge(name string) error {
  16842. return fmt.Errorf("unknown CreditUsage edge %s", name)
  16843. }
  16844. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  16845. type EmployeeMutation struct {
  16846. config
  16847. op Op
  16848. typ string
  16849. id *uint64
  16850. created_at *time.Time
  16851. updated_at *time.Time
  16852. deleted_at *time.Time
  16853. title *string
  16854. avatar *string
  16855. tags *string
  16856. hire_count *int
  16857. addhire_count *int
  16858. service_count *int
  16859. addservice_count *int
  16860. achievement_count *int
  16861. addachievement_count *int
  16862. intro *string
  16863. estimate *string
  16864. skill *string
  16865. ability_type *string
  16866. scene *string
  16867. switch_in *string
  16868. video_url *string
  16869. organization_id *uint64
  16870. addorganization_id *int64
  16871. category_id *uint64
  16872. addcategory_id *int64
  16873. api_base *string
  16874. api_key *string
  16875. ai_info *string
  16876. is_vip *int
  16877. addis_vip *int
  16878. chat_url *string
  16879. clearedFields map[string]struct{}
  16880. em_work_experiences map[uint64]struct{}
  16881. removedem_work_experiences map[uint64]struct{}
  16882. clearedem_work_experiences bool
  16883. em_tutorial map[uint64]struct{}
  16884. removedem_tutorial map[uint64]struct{}
  16885. clearedem_tutorial bool
  16886. done bool
  16887. oldValue func(context.Context) (*Employee, error)
  16888. predicates []predicate.Employee
  16889. }
  16890. var _ ent.Mutation = (*EmployeeMutation)(nil)
  16891. // employeeOption allows management of the mutation configuration using functional options.
  16892. type employeeOption func(*EmployeeMutation)
  16893. // newEmployeeMutation creates new mutation for the Employee entity.
  16894. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  16895. m := &EmployeeMutation{
  16896. config: c,
  16897. op: op,
  16898. typ: TypeEmployee,
  16899. clearedFields: make(map[string]struct{}),
  16900. }
  16901. for _, opt := range opts {
  16902. opt(m)
  16903. }
  16904. return m
  16905. }
  16906. // withEmployeeID sets the ID field of the mutation.
  16907. func withEmployeeID(id uint64) employeeOption {
  16908. return func(m *EmployeeMutation) {
  16909. var (
  16910. err error
  16911. once sync.Once
  16912. value *Employee
  16913. )
  16914. m.oldValue = func(ctx context.Context) (*Employee, error) {
  16915. once.Do(func() {
  16916. if m.done {
  16917. err = errors.New("querying old values post mutation is not allowed")
  16918. } else {
  16919. value, err = m.Client().Employee.Get(ctx, id)
  16920. }
  16921. })
  16922. return value, err
  16923. }
  16924. m.id = &id
  16925. }
  16926. }
  16927. // withEmployee sets the old Employee of the mutation.
  16928. func withEmployee(node *Employee) employeeOption {
  16929. return func(m *EmployeeMutation) {
  16930. m.oldValue = func(context.Context) (*Employee, error) {
  16931. return node, nil
  16932. }
  16933. m.id = &node.ID
  16934. }
  16935. }
  16936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16937. // executed in a transaction (ent.Tx), a transactional client is returned.
  16938. func (m EmployeeMutation) Client() *Client {
  16939. client := &Client{config: m.config}
  16940. client.init()
  16941. return client
  16942. }
  16943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16944. // it returns an error otherwise.
  16945. func (m EmployeeMutation) Tx() (*Tx, error) {
  16946. if _, ok := m.driver.(*txDriver); !ok {
  16947. return nil, errors.New("ent: mutation is not running in a transaction")
  16948. }
  16949. tx := &Tx{config: m.config}
  16950. tx.init()
  16951. return tx, nil
  16952. }
  16953. // SetID sets the value of the id field. Note that this
  16954. // operation is only accepted on creation of Employee entities.
  16955. func (m *EmployeeMutation) SetID(id uint64) {
  16956. m.id = &id
  16957. }
  16958. // ID returns the ID value in the mutation. Note that the ID is only available
  16959. // if it was provided to the builder or after it was returned from the database.
  16960. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  16961. if m.id == nil {
  16962. return
  16963. }
  16964. return *m.id, true
  16965. }
  16966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16967. // That means, if the mutation is applied within a transaction with an isolation level such
  16968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16969. // or updated by the mutation.
  16970. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  16971. switch {
  16972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16973. id, exists := m.ID()
  16974. if exists {
  16975. return []uint64{id}, nil
  16976. }
  16977. fallthrough
  16978. case m.op.Is(OpUpdate | OpDelete):
  16979. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  16980. default:
  16981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16982. }
  16983. }
  16984. // SetCreatedAt sets the "created_at" field.
  16985. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  16986. m.created_at = &t
  16987. }
  16988. // CreatedAt returns the value of the "created_at" field in the mutation.
  16989. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  16990. v := m.created_at
  16991. if v == nil {
  16992. return
  16993. }
  16994. return *v, true
  16995. }
  16996. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  16997. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  16998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16999. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17000. if !m.op.Is(OpUpdateOne) {
  17001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17002. }
  17003. if m.id == nil || m.oldValue == nil {
  17004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17005. }
  17006. oldValue, err := m.oldValue(ctx)
  17007. if err != nil {
  17008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17009. }
  17010. return oldValue.CreatedAt, nil
  17011. }
  17012. // ResetCreatedAt resets all changes to the "created_at" field.
  17013. func (m *EmployeeMutation) ResetCreatedAt() {
  17014. m.created_at = nil
  17015. }
  17016. // SetUpdatedAt sets the "updated_at" field.
  17017. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  17018. m.updated_at = &t
  17019. }
  17020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17021. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  17022. v := m.updated_at
  17023. if v == nil {
  17024. return
  17025. }
  17026. return *v, true
  17027. }
  17028. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  17029. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17031. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17032. if !m.op.Is(OpUpdateOne) {
  17033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17034. }
  17035. if m.id == nil || m.oldValue == nil {
  17036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17037. }
  17038. oldValue, err := m.oldValue(ctx)
  17039. if err != nil {
  17040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17041. }
  17042. return oldValue.UpdatedAt, nil
  17043. }
  17044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17045. func (m *EmployeeMutation) ResetUpdatedAt() {
  17046. m.updated_at = nil
  17047. }
  17048. // SetDeletedAt sets the "deleted_at" field.
  17049. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  17050. m.deleted_at = &t
  17051. }
  17052. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17053. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  17054. v := m.deleted_at
  17055. if v == nil {
  17056. return
  17057. }
  17058. return *v, true
  17059. }
  17060. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  17061. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17063. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17064. if !m.op.Is(OpUpdateOne) {
  17065. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17066. }
  17067. if m.id == nil || m.oldValue == nil {
  17068. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17069. }
  17070. oldValue, err := m.oldValue(ctx)
  17071. if err != nil {
  17072. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17073. }
  17074. return oldValue.DeletedAt, nil
  17075. }
  17076. // ClearDeletedAt clears the value of the "deleted_at" field.
  17077. func (m *EmployeeMutation) ClearDeletedAt() {
  17078. m.deleted_at = nil
  17079. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  17080. }
  17081. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17082. func (m *EmployeeMutation) DeletedAtCleared() bool {
  17083. _, ok := m.clearedFields[employee.FieldDeletedAt]
  17084. return ok
  17085. }
  17086. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17087. func (m *EmployeeMutation) ResetDeletedAt() {
  17088. m.deleted_at = nil
  17089. delete(m.clearedFields, employee.FieldDeletedAt)
  17090. }
  17091. // SetTitle sets the "title" field.
  17092. func (m *EmployeeMutation) SetTitle(s string) {
  17093. m.title = &s
  17094. }
  17095. // Title returns the value of the "title" field in the mutation.
  17096. func (m *EmployeeMutation) Title() (r string, exists bool) {
  17097. v := m.title
  17098. if v == nil {
  17099. return
  17100. }
  17101. return *v, true
  17102. }
  17103. // OldTitle returns the old "title" field's value of the Employee entity.
  17104. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17106. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  17107. if !m.op.Is(OpUpdateOne) {
  17108. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  17109. }
  17110. if m.id == nil || m.oldValue == nil {
  17111. return v, errors.New("OldTitle requires an ID field in the mutation")
  17112. }
  17113. oldValue, err := m.oldValue(ctx)
  17114. if err != nil {
  17115. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  17116. }
  17117. return oldValue.Title, nil
  17118. }
  17119. // ResetTitle resets all changes to the "title" field.
  17120. func (m *EmployeeMutation) ResetTitle() {
  17121. m.title = nil
  17122. }
  17123. // SetAvatar sets the "avatar" field.
  17124. func (m *EmployeeMutation) SetAvatar(s string) {
  17125. m.avatar = &s
  17126. }
  17127. // Avatar returns the value of the "avatar" field in the mutation.
  17128. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  17129. v := m.avatar
  17130. if v == nil {
  17131. return
  17132. }
  17133. return *v, true
  17134. }
  17135. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  17136. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17138. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  17139. if !m.op.Is(OpUpdateOne) {
  17140. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  17141. }
  17142. if m.id == nil || m.oldValue == nil {
  17143. return v, errors.New("OldAvatar requires an ID field in the mutation")
  17144. }
  17145. oldValue, err := m.oldValue(ctx)
  17146. if err != nil {
  17147. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  17148. }
  17149. return oldValue.Avatar, nil
  17150. }
  17151. // ResetAvatar resets all changes to the "avatar" field.
  17152. func (m *EmployeeMutation) ResetAvatar() {
  17153. m.avatar = nil
  17154. }
  17155. // SetTags sets the "tags" field.
  17156. func (m *EmployeeMutation) SetTags(s string) {
  17157. m.tags = &s
  17158. }
  17159. // Tags returns the value of the "tags" field in the mutation.
  17160. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  17161. v := m.tags
  17162. if v == nil {
  17163. return
  17164. }
  17165. return *v, true
  17166. }
  17167. // OldTags returns the old "tags" field's value of the Employee entity.
  17168. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17170. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  17171. if !m.op.Is(OpUpdateOne) {
  17172. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  17173. }
  17174. if m.id == nil || m.oldValue == nil {
  17175. return v, errors.New("OldTags requires an ID field in the mutation")
  17176. }
  17177. oldValue, err := m.oldValue(ctx)
  17178. if err != nil {
  17179. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  17180. }
  17181. return oldValue.Tags, nil
  17182. }
  17183. // ResetTags resets all changes to the "tags" field.
  17184. func (m *EmployeeMutation) ResetTags() {
  17185. m.tags = nil
  17186. }
  17187. // SetHireCount sets the "hire_count" field.
  17188. func (m *EmployeeMutation) SetHireCount(i int) {
  17189. m.hire_count = &i
  17190. m.addhire_count = nil
  17191. }
  17192. // HireCount returns the value of the "hire_count" field in the mutation.
  17193. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  17194. v := m.hire_count
  17195. if v == nil {
  17196. return
  17197. }
  17198. return *v, true
  17199. }
  17200. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  17201. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17203. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  17204. if !m.op.Is(OpUpdateOne) {
  17205. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  17206. }
  17207. if m.id == nil || m.oldValue == nil {
  17208. return v, errors.New("OldHireCount requires an ID field in the mutation")
  17209. }
  17210. oldValue, err := m.oldValue(ctx)
  17211. if err != nil {
  17212. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  17213. }
  17214. return oldValue.HireCount, nil
  17215. }
  17216. // AddHireCount adds i to the "hire_count" field.
  17217. func (m *EmployeeMutation) AddHireCount(i int) {
  17218. if m.addhire_count != nil {
  17219. *m.addhire_count += i
  17220. } else {
  17221. m.addhire_count = &i
  17222. }
  17223. }
  17224. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  17225. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  17226. v := m.addhire_count
  17227. if v == nil {
  17228. return
  17229. }
  17230. return *v, true
  17231. }
  17232. // ResetHireCount resets all changes to the "hire_count" field.
  17233. func (m *EmployeeMutation) ResetHireCount() {
  17234. m.hire_count = nil
  17235. m.addhire_count = nil
  17236. }
  17237. // SetServiceCount sets the "service_count" field.
  17238. func (m *EmployeeMutation) SetServiceCount(i int) {
  17239. m.service_count = &i
  17240. m.addservice_count = nil
  17241. }
  17242. // ServiceCount returns the value of the "service_count" field in the mutation.
  17243. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  17244. v := m.service_count
  17245. if v == nil {
  17246. return
  17247. }
  17248. return *v, true
  17249. }
  17250. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  17251. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17253. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  17254. if !m.op.Is(OpUpdateOne) {
  17255. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  17256. }
  17257. if m.id == nil || m.oldValue == nil {
  17258. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  17259. }
  17260. oldValue, err := m.oldValue(ctx)
  17261. if err != nil {
  17262. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  17263. }
  17264. return oldValue.ServiceCount, nil
  17265. }
  17266. // AddServiceCount adds i to the "service_count" field.
  17267. func (m *EmployeeMutation) AddServiceCount(i int) {
  17268. if m.addservice_count != nil {
  17269. *m.addservice_count += i
  17270. } else {
  17271. m.addservice_count = &i
  17272. }
  17273. }
  17274. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  17275. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  17276. v := m.addservice_count
  17277. if v == nil {
  17278. return
  17279. }
  17280. return *v, true
  17281. }
  17282. // ResetServiceCount resets all changes to the "service_count" field.
  17283. func (m *EmployeeMutation) ResetServiceCount() {
  17284. m.service_count = nil
  17285. m.addservice_count = nil
  17286. }
  17287. // SetAchievementCount sets the "achievement_count" field.
  17288. func (m *EmployeeMutation) SetAchievementCount(i int) {
  17289. m.achievement_count = &i
  17290. m.addachievement_count = nil
  17291. }
  17292. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  17293. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  17294. v := m.achievement_count
  17295. if v == nil {
  17296. return
  17297. }
  17298. return *v, true
  17299. }
  17300. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  17301. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17303. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  17304. if !m.op.Is(OpUpdateOne) {
  17305. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  17306. }
  17307. if m.id == nil || m.oldValue == nil {
  17308. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  17309. }
  17310. oldValue, err := m.oldValue(ctx)
  17311. if err != nil {
  17312. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  17313. }
  17314. return oldValue.AchievementCount, nil
  17315. }
  17316. // AddAchievementCount adds i to the "achievement_count" field.
  17317. func (m *EmployeeMutation) AddAchievementCount(i int) {
  17318. if m.addachievement_count != nil {
  17319. *m.addachievement_count += i
  17320. } else {
  17321. m.addachievement_count = &i
  17322. }
  17323. }
  17324. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  17325. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  17326. v := m.addachievement_count
  17327. if v == nil {
  17328. return
  17329. }
  17330. return *v, true
  17331. }
  17332. // ResetAchievementCount resets all changes to the "achievement_count" field.
  17333. func (m *EmployeeMutation) ResetAchievementCount() {
  17334. m.achievement_count = nil
  17335. m.addachievement_count = nil
  17336. }
  17337. // SetIntro sets the "intro" field.
  17338. func (m *EmployeeMutation) SetIntro(s string) {
  17339. m.intro = &s
  17340. }
  17341. // Intro returns the value of the "intro" field in the mutation.
  17342. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  17343. v := m.intro
  17344. if v == nil {
  17345. return
  17346. }
  17347. return *v, true
  17348. }
  17349. // OldIntro returns the old "intro" field's value of the Employee entity.
  17350. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17352. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  17353. if !m.op.Is(OpUpdateOne) {
  17354. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  17355. }
  17356. if m.id == nil || m.oldValue == nil {
  17357. return v, errors.New("OldIntro requires an ID field in the mutation")
  17358. }
  17359. oldValue, err := m.oldValue(ctx)
  17360. if err != nil {
  17361. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  17362. }
  17363. return oldValue.Intro, nil
  17364. }
  17365. // ResetIntro resets all changes to the "intro" field.
  17366. func (m *EmployeeMutation) ResetIntro() {
  17367. m.intro = nil
  17368. }
  17369. // SetEstimate sets the "estimate" field.
  17370. func (m *EmployeeMutation) SetEstimate(s string) {
  17371. m.estimate = &s
  17372. }
  17373. // Estimate returns the value of the "estimate" field in the mutation.
  17374. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  17375. v := m.estimate
  17376. if v == nil {
  17377. return
  17378. }
  17379. return *v, true
  17380. }
  17381. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  17382. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17384. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  17385. if !m.op.Is(OpUpdateOne) {
  17386. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  17387. }
  17388. if m.id == nil || m.oldValue == nil {
  17389. return v, errors.New("OldEstimate requires an ID field in the mutation")
  17390. }
  17391. oldValue, err := m.oldValue(ctx)
  17392. if err != nil {
  17393. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  17394. }
  17395. return oldValue.Estimate, nil
  17396. }
  17397. // ResetEstimate resets all changes to the "estimate" field.
  17398. func (m *EmployeeMutation) ResetEstimate() {
  17399. m.estimate = nil
  17400. }
  17401. // SetSkill sets the "skill" field.
  17402. func (m *EmployeeMutation) SetSkill(s string) {
  17403. m.skill = &s
  17404. }
  17405. // Skill returns the value of the "skill" field in the mutation.
  17406. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  17407. v := m.skill
  17408. if v == nil {
  17409. return
  17410. }
  17411. return *v, true
  17412. }
  17413. // OldSkill returns the old "skill" field's value of the Employee entity.
  17414. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17416. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  17417. if !m.op.Is(OpUpdateOne) {
  17418. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  17419. }
  17420. if m.id == nil || m.oldValue == nil {
  17421. return v, errors.New("OldSkill requires an ID field in the mutation")
  17422. }
  17423. oldValue, err := m.oldValue(ctx)
  17424. if err != nil {
  17425. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  17426. }
  17427. return oldValue.Skill, nil
  17428. }
  17429. // ResetSkill resets all changes to the "skill" field.
  17430. func (m *EmployeeMutation) ResetSkill() {
  17431. m.skill = nil
  17432. }
  17433. // SetAbilityType sets the "ability_type" field.
  17434. func (m *EmployeeMutation) SetAbilityType(s string) {
  17435. m.ability_type = &s
  17436. }
  17437. // AbilityType returns the value of the "ability_type" field in the mutation.
  17438. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  17439. v := m.ability_type
  17440. if v == nil {
  17441. return
  17442. }
  17443. return *v, true
  17444. }
  17445. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  17446. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17448. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  17449. if !m.op.Is(OpUpdateOne) {
  17450. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  17451. }
  17452. if m.id == nil || m.oldValue == nil {
  17453. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  17454. }
  17455. oldValue, err := m.oldValue(ctx)
  17456. if err != nil {
  17457. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  17458. }
  17459. return oldValue.AbilityType, nil
  17460. }
  17461. // ResetAbilityType resets all changes to the "ability_type" field.
  17462. func (m *EmployeeMutation) ResetAbilityType() {
  17463. m.ability_type = nil
  17464. }
  17465. // SetScene sets the "scene" field.
  17466. func (m *EmployeeMutation) SetScene(s string) {
  17467. m.scene = &s
  17468. }
  17469. // Scene returns the value of the "scene" field in the mutation.
  17470. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  17471. v := m.scene
  17472. if v == nil {
  17473. return
  17474. }
  17475. return *v, true
  17476. }
  17477. // OldScene returns the old "scene" field's value of the Employee entity.
  17478. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17480. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  17481. if !m.op.Is(OpUpdateOne) {
  17482. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  17483. }
  17484. if m.id == nil || m.oldValue == nil {
  17485. return v, errors.New("OldScene requires an ID field in the mutation")
  17486. }
  17487. oldValue, err := m.oldValue(ctx)
  17488. if err != nil {
  17489. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  17490. }
  17491. return oldValue.Scene, nil
  17492. }
  17493. // ResetScene resets all changes to the "scene" field.
  17494. func (m *EmployeeMutation) ResetScene() {
  17495. m.scene = nil
  17496. }
  17497. // SetSwitchIn sets the "switch_in" field.
  17498. func (m *EmployeeMutation) SetSwitchIn(s string) {
  17499. m.switch_in = &s
  17500. }
  17501. // SwitchIn returns the value of the "switch_in" field in the mutation.
  17502. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  17503. v := m.switch_in
  17504. if v == nil {
  17505. return
  17506. }
  17507. return *v, true
  17508. }
  17509. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  17510. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17512. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  17513. if !m.op.Is(OpUpdateOne) {
  17514. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  17515. }
  17516. if m.id == nil || m.oldValue == nil {
  17517. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  17518. }
  17519. oldValue, err := m.oldValue(ctx)
  17520. if err != nil {
  17521. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  17522. }
  17523. return oldValue.SwitchIn, nil
  17524. }
  17525. // ResetSwitchIn resets all changes to the "switch_in" field.
  17526. func (m *EmployeeMutation) ResetSwitchIn() {
  17527. m.switch_in = nil
  17528. }
  17529. // SetVideoURL sets the "video_url" field.
  17530. func (m *EmployeeMutation) SetVideoURL(s string) {
  17531. m.video_url = &s
  17532. }
  17533. // VideoURL returns the value of the "video_url" field in the mutation.
  17534. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  17535. v := m.video_url
  17536. if v == nil {
  17537. return
  17538. }
  17539. return *v, true
  17540. }
  17541. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  17542. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17544. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  17545. if !m.op.Is(OpUpdateOne) {
  17546. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  17547. }
  17548. if m.id == nil || m.oldValue == nil {
  17549. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  17550. }
  17551. oldValue, err := m.oldValue(ctx)
  17552. if err != nil {
  17553. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  17554. }
  17555. return oldValue.VideoURL, nil
  17556. }
  17557. // ResetVideoURL resets all changes to the "video_url" field.
  17558. func (m *EmployeeMutation) ResetVideoURL() {
  17559. m.video_url = nil
  17560. }
  17561. // SetOrganizationID sets the "organization_id" field.
  17562. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  17563. m.organization_id = &u
  17564. m.addorganization_id = nil
  17565. }
  17566. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17567. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  17568. v := m.organization_id
  17569. if v == nil {
  17570. return
  17571. }
  17572. return *v, true
  17573. }
  17574. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  17575. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17577. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17578. if !m.op.Is(OpUpdateOne) {
  17579. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17580. }
  17581. if m.id == nil || m.oldValue == nil {
  17582. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17583. }
  17584. oldValue, err := m.oldValue(ctx)
  17585. if err != nil {
  17586. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17587. }
  17588. return oldValue.OrganizationID, nil
  17589. }
  17590. // AddOrganizationID adds u to the "organization_id" field.
  17591. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  17592. if m.addorganization_id != nil {
  17593. *m.addorganization_id += u
  17594. } else {
  17595. m.addorganization_id = &u
  17596. }
  17597. }
  17598. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17599. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  17600. v := m.addorganization_id
  17601. if v == nil {
  17602. return
  17603. }
  17604. return *v, true
  17605. }
  17606. // ResetOrganizationID resets all changes to the "organization_id" field.
  17607. func (m *EmployeeMutation) ResetOrganizationID() {
  17608. m.organization_id = nil
  17609. m.addorganization_id = nil
  17610. }
  17611. // SetCategoryID sets the "category_id" field.
  17612. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  17613. m.category_id = &u
  17614. m.addcategory_id = nil
  17615. }
  17616. // CategoryID returns the value of the "category_id" field in the mutation.
  17617. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  17618. v := m.category_id
  17619. if v == nil {
  17620. return
  17621. }
  17622. return *v, true
  17623. }
  17624. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  17625. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17627. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  17628. if !m.op.Is(OpUpdateOne) {
  17629. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  17630. }
  17631. if m.id == nil || m.oldValue == nil {
  17632. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  17633. }
  17634. oldValue, err := m.oldValue(ctx)
  17635. if err != nil {
  17636. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  17637. }
  17638. return oldValue.CategoryID, nil
  17639. }
  17640. // AddCategoryID adds u to the "category_id" field.
  17641. func (m *EmployeeMutation) AddCategoryID(u int64) {
  17642. if m.addcategory_id != nil {
  17643. *m.addcategory_id += u
  17644. } else {
  17645. m.addcategory_id = &u
  17646. }
  17647. }
  17648. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  17649. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  17650. v := m.addcategory_id
  17651. if v == nil {
  17652. return
  17653. }
  17654. return *v, true
  17655. }
  17656. // ResetCategoryID resets all changes to the "category_id" field.
  17657. func (m *EmployeeMutation) ResetCategoryID() {
  17658. m.category_id = nil
  17659. m.addcategory_id = nil
  17660. }
  17661. // SetAPIBase sets the "api_base" field.
  17662. func (m *EmployeeMutation) SetAPIBase(s string) {
  17663. m.api_base = &s
  17664. }
  17665. // APIBase returns the value of the "api_base" field in the mutation.
  17666. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  17667. v := m.api_base
  17668. if v == nil {
  17669. return
  17670. }
  17671. return *v, true
  17672. }
  17673. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  17674. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17676. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  17677. if !m.op.Is(OpUpdateOne) {
  17678. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  17679. }
  17680. if m.id == nil || m.oldValue == nil {
  17681. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  17682. }
  17683. oldValue, err := m.oldValue(ctx)
  17684. if err != nil {
  17685. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  17686. }
  17687. return oldValue.APIBase, nil
  17688. }
  17689. // ResetAPIBase resets all changes to the "api_base" field.
  17690. func (m *EmployeeMutation) ResetAPIBase() {
  17691. m.api_base = nil
  17692. }
  17693. // SetAPIKey sets the "api_key" field.
  17694. func (m *EmployeeMutation) SetAPIKey(s string) {
  17695. m.api_key = &s
  17696. }
  17697. // APIKey returns the value of the "api_key" field in the mutation.
  17698. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  17699. v := m.api_key
  17700. if v == nil {
  17701. return
  17702. }
  17703. return *v, true
  17704. }
  17705. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  17706. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17708. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  17709. if !m.op.Is(OpUpdateOne) {
  17710. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  17711. }
  17712. if m.id == nil || m.oldValue == nil {
  17713. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  17714. }
  17715. oldValue, err := m.oldValue(ctx)
  17716. if err != nil {
  17717. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  17718. }
  17719. return oldValue.APIKey, nil
  17720. }
  17721. // ResetAPIKey resets all changes to the "api_key" field.
  17722. func (m *EmployeeMutation) ResetAPIKey() {
  17723. m.api_key = nil
  17724. }
  17725. // SetAiInfo sets the "ai_info" field.
  17726. func (m *EmployeeMutation) SetAiInfo(s string) {
  17727. m.ai_info = &s
  17728. }
  17729. // AiInfo returns the value of the "ai_info" field in the mutation.
  17730. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  17731. v := m.ai_info
  17732. if v == nil {
  17733. return
  17734. }
  17735. return *v, true
  17736. }
  17737. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  17738. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17740. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  17741. if !m.op.Is(OpUpdateOne) {
  17742. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  17743. }
  17744. if m.id == nil || m.oldValue == nil {
  17745. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  17746. }
  17747. oldValue, err := m.oldValue(ctx)
  17748. if err != nil {
  17749. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  17750. }
  17751. return oldValue.AiInfo, nil
  17752. }
  17753. // ClearAiInfo clears the value of the "ai_info" field.
  17754. func (m *EmployeeMutation) ClearAiInfo() {
  17755. m.ai_info = nil
  17756. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  17757. }
  17758. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  17759. func (m *EmployeeMutation) AiInfoCleared() bool {
  17760. _, ok := m.clearedFields[employee.FieldAiInfo]
  17761. return ok
  17762. }
  17763. // ResetAiInfo resets all changes to the "ai_info" field.
  17764. func (m *EmployeeMutation) ResetAiInfo() {
  17765. m.ai_info = nil
  17766. delete(m.clearedFields, employee.FieldAiInfo)
  17767. }
  17768. // SetIsVip sets the "is_vip" field.
  17769. func (m *EmployeeMutation) SetIsVip(i int) {
  17770. m.is_vip = &i
  17771. m.addis_vip = nil
  17772. }
  17773. // IsVip returns the value of the "is_vip" field in the mutation.
  17774. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  17775. v := m.is_vip
  17776. if v == nil {
  17777. return
  17778. }
  17779. return *v, true
  17780. }
  17781. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  17782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17784. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  17785. if !m.op.Is(OpUpdateOne) {
  17786. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  17787. }
  17788. if m.id == nil || m.oldValue == nil {
  17789. return v, errors.New("OldIsVip requires an ID field in the mutation")
  17790. }
  17791. oldValue, err := m.oldValue(ctx)
  17792. if err != nil {
  17793. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  17794. }
  17795. return oldValue.IsVip, nil
  17796. }
  17797. // AddIsVip adds i to the "is_vip" field.
  17798. func (m *EmployeeMutation) AddIsVip(i int) {
  17799. if m.addis_vip != nil {
  17800. *m.addis_vip += i
  17801. } else {
  17802. m.addis_vip = &i
  17803. }
  17804. }
  17805. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  17806. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  17807. v := m.addis_vip
  17808. if v == nil {
  17809. return
  17810. }
  17811. return *v, true
  17812. }
  17813. // ResetIsVip resets all changes to the "is_vip" field.
  17814. func (m *EmployeeMutation) ResetIsVip() {
  17815. m.is_vip = nil
  17816. m.addis_vip = nil
  17817. }
  17818. // SetChatURL sets the "chat_url" field.
  17819. func (m *EmployeeMutation) SetChatURL(s string) {
  17820. m.chat_url = &s
  17821. }
  17822. // ChatURL returns the value of the "chat_url" field in the mutation.
  17823. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  17824. v := m.chat_url
  17825. if v == nil {
  17826. return
  17827. }
  17828. return *v, true
  17829. }
  17830. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  17831. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  17832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17833. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  17834. if !m.op.Is(OpUpdateOne) {
  17835. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  17836. }
  17837. if m.id == nil || m.oldValue == nil {
  17838. return v, errors.New("OldChatURL requires an ID field in the mutation")
  17839. }
  17840. oldValue, err := m.oldValue(ctx)
  17841. if err != nil {
  17842. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  17843. }
  17844. return oldValue.ChatURL, nil
  17845. }
  17846. // ResetChatURL resets all changes to the "chat_url" field.
  17847. func (m *EmployeeMutation) ResetChatURL() {
  17848. m.chat_url = nil
  17849. }
  17850. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  17851. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  17852. if m.em_work_experiences == nil {
  17853. m.em_work_experiences = make(map[uint64]struct{})
  17854. }
  17855. for i := range ids {
  17856. m.em_work_experiences[ids[i]] = struct{}{}
  17857. }
  17858. }
  17859. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  17860. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  17861. m.clearedem_work_experiences = true
  17862. }
  17863. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  17864. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  17865. return m.clearedem_work_experiences
  17866. }
  17867. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  17868. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  17869. if m.removedem_work_experiences == nil {
  17870. m.removedem_work_experiences = make(map[uint64]struct{})
  17871. }
  17872. for i := range ids {
  17873. delete(m.em_work_experiences, ids[i])
  17874. m.removedem_work_experiences[ids[i]] = struct{}{}
  17875. }
  17876. }
  17877. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  17878. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  17879. for id := range m.removedem_work_experiences {
  17880. ids = append(ids, id)
  17881. }
  17882. return
  17883. }
  17884. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  17885. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  17886. for id := range m.em_work_experiences {
  17887. ids = append(ids, id)
  17888. }
  17889. return
  17890. }
  17891. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  17892. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  17893. m.em_work_experiences = nil
  17894. m.clearedem_work_experiences = false
  17895. m.removedem_work_experiences = nil
  17896. }
  17897. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  17898. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  17899. if m.em_tutorial == nil {
  17900. m.em_tutorial = make(map[uint64]struct{})
  17901. }
  17902. for i := range ids {
  17903. m.em_tutorial[ids[i]] = struct{}{}
  17904. }
  17905. }
  17906. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  17907. func (m *EmployeeMutation) ClearEmTutorial() {
  17908. m.clearedem_tutorial = true
  17909. }
  17910. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  17911. func (m *EmployeeMutation) EmTutorialCleared() bool {
  17912. return m.clearedem_tutorial
  17913. }
  17914. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  17915. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  17916. if m.removedem_tutorial == nil {
  17917. m.removedem_tutorial = make(map[uint64]struct{})
  17918. }
  17919. for i := range ids {
  17920. delete(m.em_tutorial, ids[i])
  17921. m.removedem_tutorial[ids[i]] = struct{}{}
  17922. }
  17923. }
  17924. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  17925. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  17926. for id := range m.removedem_tutorial {
  17927. ids = append(ids, id)
  17928. }
  17929. return
  17930. }
  17931. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  17932. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  17933. for id := range m.em_tutorial {
  17934. ids = append(ids, id)
  17935. }
  17936. return
  17937. }
  17938. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  17939. func (m *EmployeeMutation) ResetEmTutorial() {
  17940. m.em_tutorial = nil
  17941. m.clearedem_tutorial = false
  17942. m.removedem_tutorial = nil
  17943. }
  17944. // Where appends a list predicates to the EmployeeMutation builder.
  17945. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  17946. m.predicates = append(m.predicates, ps...)
  17947. }
  17948. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  17949. // users can use type-assertion to append predicates that do not depend on any generated package.
  17950. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  17951. p := make([]predicate.Employee, len(ps))
  17952. for i := range ps {
  17953. p[i] = ps[i]
  17954. }
  17955. m.Where(p...)
  17956. }
  17957. // Op returns the operation name.
  17958. func (m *EmployeeMutation) Op() Op {
  17959. return m.op
  17960. }
  17961. // SetOp allows setting the mutation operation.
  17962. func (m *EmployeeMutation) SetOp(op Op) {
  17963. m.op = op
  17964. }
  17965. // Type returns the node type of this mutation (Employee).
  17966. func (m *EmployeeMutation) Type() string {
  17967. return m.typ
  17968. }
  17969. // Fields returns all fields that were changed during this mutation. Note that in
  17970. // order to get all numeric fields that were incremented/decremented, call
  17971. // AddedFields().
  17972. func (m *EmployeeMutation) Fields() []string {
  17973. fields := make([]string, 0, 23)
  17974. if m.created_at != nil {
  17975. fields = append(fields, employee.FieldCreatedAt)
  17976. }
  17977. if m.updated_at != nil {
  17978. fields = append(fields, employee.FieldUpdatedAt)
  17979. }
  17980. if m.deleted_at != nil {
  17981. fields = append(fields, employee.FieldDeletedAt)
  17982. }
  17983. if m.title != nil {
  17984. fields = append(fields, employee.FieldTitle)
  17985. }
  17986. if m.avatar != nil {
  17987. fields = append(fields, employee.FieldAvatar)
  17988. }
  17989. if m.tags != nil {
  17990. fields = append(fields, employee.FieldTags)
  17991. }
  17992. if m.hire_count != nil {
  17993. fields = append(fields, employee.FieldHireCount)
  17994. }
  17995. if m.service_count != nil {
  17996. fields = append(fields, employee.FieldServiceCount)
  17997. }
  17998. if m.achievement_count != nil {
  17999. fields = append(fields, employee.FieldAchievementCount)
  18000. }
  18001. if m.intro != nil {
  18002. fields = append(fields, employee.FieldIntro)
  18003. }
  18004. if m.estimate != nil {
  18005. fields = append(fields, employee.FieldEstimate)
  18006. }
  18007. if m.skill != nil {
  18008. fields = append(fields, employee.FieldSkill)
  18009. }
  18010. if m.ability_type != nil {
  18011. fields = append(fields, employee.FieldAbilityType)
  18012. }
  18013. if m.scene != nil {
  18014. fields = append(fields, employee.FieldScene)
  18015. }
  18016. if m.switch_in != nil {
  18017. fields = append(fields, employee.FieldSwitchIn)
  18018. }
  18019. if m.video_url != nil {
  18020. fields = append(fields, employee.FieldVideoURL)
  18021. }
  18022. if m.organization_id != nil {
  18023. fields = append(fields, employee.FieldOrganizationID)
  18024. }
  18025. if m.category_id != nil {
  18026. fields = append(fields, employee.FieldCategoryID)
  18027. }
  18028. if m.api_base != nil {
  18029. fields = append(fields, employee.FieldAPIBase)
  18030. }
  18031. if m.api_key != nil {
  18032. fields = append(fields, employee.FieldAPIKey)
  18033. }
  18034. if m.ai_info != nil {
  18035. fields = append(fields, employee.FieldAiInfo)
  18036. }
  18037. if m.is_vip != nil {
  18038. fields = append(fields, employee.FieldIsVip)
  18039. }
  18040. if m.chat_url != nil {
  18041. fields = append(fields, employee.FieldChatURL)
  18042. }
  18043. return fields
  18044. }
  18045. // Field returns the value of a field with the given name. The second boolean
  18046. // return value indicates that this field was not set, or was not defined in the
  18047. // schema.
  18048. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  18049. switch name {
  18050. case employee.FieldCreatedAt:
  18051. return m.CreatedAt()
  18052. case employee.FieldUpdatedAt:
  18053. return m.UpdatedAt()
  18054. case employee.FieldDeletedAt:
  18055. return m.DeletedAt()
  18056. case employee.FieldTitle:
  18057. return m.Title()
  18058. case employee.FieldAvatar:
  18059. return m.Avatar()
  18060. case employee.FieldTags:
  18061. return m.Tags()
  18062. case employee.FieldHireCount:
  18063. return m.HireCount()
  18064. case employee.FieldServiceCount:
  18065. return m.ServiceCount()
  18066. case employee.FieldAchievementCount:
  18067. return m.AchievementCount()
  18068. case employee.FieldIntro:
  18069. return m.Intro()
  18070. case employee.FieldEstimate:
  18071. return m.Estimate()
  18072. case employee.FieldSkill:
  18073. return m.Skill()
  18074. case employee.FieldAbilityType:
  18075. return m.AbilityType()
  18076. case employee.FieldScene:
  18077. return m.Scene()
  18078. case employee.FieldSwitchIn:
  18079. return m.SwitchIn()
  18080. case employee.FieldVideoURL:
  18081. return m.VideoURL()
  18082. case employee.FieldOrganizationID:
  18083. return m.OrganizationID()
  18084. case employee.FieldCategoryID:
  18085. return m.CategoryID()
  18086. case employee.FieldAPIBase:
  18087. return m.APIBase()
  18088. case employee.FieldAPIKey:
  18089. return m.APIKey()
  18090. case employee.FieldAiInfo:
  18091. return m.AiInfo()
  18092. case employee.FieldIsVip:
  18093. return m.IsVip()
  18094. case employee.FieldChatURL:
  18095. return m.ChatURL()
  18096. }
  18097. return nil, false
  18098. }
  18099. // OldField returns the old value of the field from the database. An error is
  18100. // returned if the mutation operation is not UpdateOne, or the query to the
  18101. // database failed.
  18102. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18103. switch name {
  18104. case employee.FieldCreatedAt:
  18105. return m.OldCreatedAt(ctx)
  18106. case employee.FieldUpdatedAt:
  18107. return m.OldUpdatedAt(ctx)
  18108. case employee.FieldDeletedAt:
  18109. return m.OldDeletedAt(ctx)
  18110. case employee.FieldTitle:
  18111. return m.OldTitle(ctx)
  18112. case employee.FieldAvatar:
  18113. return m.OldAvatar(ctx)
  18114. case employee.FieldTags:
  18115. return m.OldTags(ctx)
  18116. case employee.FieldHireCount:
  18117. return m.OldHireCount(ctx)
  18118. case employee.FieldServiceCount:
  18119. return m.OldServiceCount(ctx)
  18120. case employee.FieldAchievementCount:
  18121. return m.OldAchievementCount(ctx)
  18122. case employee.FieldIntro:
  18123. return m.OldIntro(ctx)
  18124. case employee.FieldEstimate:
  18125. return m.OldEstimate(ctx)
  18126. case employee.FieldSkill:
  18127. return m.OldSkill(ctx)
  18128. case employee.FieldAbilityType:
  18129. return m.OldAbilityType(ctx)
  18130. case employee.FieldScene:
  18131. return m.OldScene(ctx)
  18132. case employee.FieldSwitchIn:
  18133. return m.OldSwitchIn(ctx)
  18134. case employee.FieldVideoURL:
  18135. return m.OldVideoURL(ctx)
  18136. case employee.FieldOrganizationID:
  18137. return m.OldOrganizationID(ctx)
  18138. case employee.FieldCategoryID:
  18139. return m.OldCategoryID(ctx)
  18140. case employee.FieldAPIBase:
  18141. return m.OldAPIBase(ctx)
  18142. case employee.FieldAPIKey:
  18143. return m.OldAPIKey(ctx)
  18144. case employee.FieldAiInfo:
  18145. return m.OldAiInfo(ctx)
  18146. case employee.FieldIsVip:
  18147. return m.OldIsVip(ctx)
  18148. case employee.FieldChatURL:
  18149. return m.OldChatURL(ctx)
  18150. }
  18151. return nil, fmt.Errorf("unknown Employee field %s", name)
  18152. }
  18153. // SetField sets the value of a field with the given name. It returns an error if
  18154. // the field is not defined in the schema, or if the type mismatched the field
  18155. // type.
  18156. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  18157. switch name {
  18158. case employee.FieldCreatedAt:
  18159. v, ok := value.(time.Time)
  18160. if !ok {
  18161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18162. }
  18163. m.SetCreatedAt(v)
  18164. return nil
  18165. case employee.FieldUpdatedAt:
  18166. v, ok := value.(time.Time)
  18167. if !ok {
  18168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18169. }
  18170. m.SetUpdatedAt(v)
  18171. return nil
  18172. case employee.FieldDeletedAt:
  18173. v, ok := value.(time.Time)
  18174. if !ok {
  18175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18176. }
  18177. m.SetDeletedAt(v)
  18178. return nil
  18179. case employee.FieldTitle:
  18180. v, ok := value.(string)
  18181. if !ok {
  18182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18183. }
  18184. m.SetTitle(v)
  18185. return nil
  18186. case employee.FieldAvatar:
  18187. v, ok := value.(string)
  18188. if !ok {
  18189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18190. }
  18191. m.SetAvatar(v)
  18192. return nil
  18193. case employee.FieldTags:
  18194. v, ok := value.(string)
  18195. if !ok {
  18196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18197. }
  18198. m.SetTags(v)
  18199. return nil
  18200. case employee.FieldHireCount:
  18201. v, ok := value.(int)
  18202. if !ok {
  18203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18204. }
  18205. m.SetHireCount(v)
  18206. return nil
  18207. case employee.FieldServiceCount:
  18208. v, ok := value.(int)
  18209. if !ok {
  18210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18211. }
  18212. m.SetServiceCount(v)
  18213. return nil
  18214. case employee.FieldAchievementCount:
  18215. v, ok := value.(int)
  18216. if !ok {
  18217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18218. }
  18219. m.SetAchievementCount(v)
  18220. return nil
  18221. case employee.FieldIntro:
  18222. v, ok := value.(string)
  18223. if !ok {
  18224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18225. }
  18226. m.SetIntro(v)
  18227. return nil
  18228. case employee.FieldEstimate:
  18229. v, ok := value.(string)
  18230. if !ok {
  18231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18232. }
  18233. m.SetEstimate(v)
  18234. return nil
  18235. case employee.FieldSkill:
  18236. v, ok := value.(string)
  18237. if !ok {
  18238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18239. }
  18240. m.SetSkill(v)
  18241. return nil
  18242. case employee.FieldAbilityType:
  18243. v, ok := value.(string)
  18244. if !ok {
  18245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18246. }
  18247. m.SetAbilityType(v)
  18248. return nil
  18249. case employee.FieldScene:
  18250. v, ok := value.(string)
  18251. if !ok {
  18252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18253. }
  18254. m.SetScene(v)
  18255. return nil
  18256. case employee.FieldSwitchIn:
  18257. v, ok := value.(string)
  18258. if !ok {
  18259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18260. }
  18261. m.SetSwitchIn(v)
  18262. return nil
  18263. case employee.FieldVideoURL:
  18264. v, ok := value.(string)
  18265. if !ok {
  18266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18267. }
  18268. m.SetVideoURL(v)
  18269. return nil
  18270. case employee.FieldOrganizationID:
  18271. v, ok := value.(uint64)
  18272. if !ok {
  18273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18274. }
  18275. m.SetOrganizationID(v)
  18276. return nil
  18277. case employee.FieldCategoryID:
  18278. v, ok := value.(uint64)
  18279. if !ok {
  18280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18281. }
  18282. m.SetCategoryID(v)
  18283. return nil
  18284. case employee.FieldAPIBase:
  18285. v, ok := value.(string)
  18286. if !ok {
  18287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18288. }
  18289. m.SetAPIBase(v)
  18290. return nil
  18291. case employee.FieldAPIKey:
  18292. v, ok := value.(string)
  18293. if !ok {
  18294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18295. }
  18296. m.SetAPIKey(v)
  18297. return nil
  18298. case employee.FieldAiInfo:
  18299. v, ok := value.(string)
  18300. if !ok {
  18301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18302. }
  18303. m.SetAiInfo(v)
  18304. return nil
  18305. case employee.FieldIsVip:
  18306. v, ok := value.(int)
  18307. if !ok {
  18308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18309. }
  18310. m.SetIsVip(v)
  18311. return nil
  18312. case employee.FieldChatURL:
  18313. v, ok := value.(string)
  18314. if !ok {
  18315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18316. }
  18317. m.SetChatURL(v)
  18318. return nil
  18319. }
  18320. return fmt.Errorf("unknown Employee field %s", name)
  18321. }
  18322. // AddedFields returns all numeric fields that were incremented/decremented during
  18323. // this mutation.
  18324. func (m *EmployeeMutation) AddedFields() []string {
  18325. var fields []string
  18326. if m.addhire_count != nil {
  18327. fields = append(fields, employee.FieldHireCount)
  18328. }
  18329. if m.addservice_count != nil {
  18330. fields = append(fields, employee.FieldServiceCount)
  18331. }
  18332. if m.addachievement_count != nil {
  18333. fields = append(fields, employee.FieldAchievementCount)
  18334. }
  18335. if m.addorganization_id != nil {
  18336. fields = append(fields, employee.FieldOrganizationID)
  18337. }
  18338. if m.addcategory_id != nil {
  18339. fields = append(fields, employee.FieldCategoryID)
  18340. }
  18341. if m.addis_vip != nil {
  18342. fields = append(fields, employee.FieldIsVip)
  18343. }
  18344. return fields
  18345. }
  18346. // AddedField returns the numeric value that was incremented/decremented on a field
  18347. // with the given name. The second boolean return value indicates that this field
  18348. // was not set, or was not defined in the schema.
  18349. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  18350. switch name {
  18351. case employee.FieldHireCount:
  18352. return m.AddedHireCount()
  18353. case employee.FieldServiceCount:
  18354. return m.AddedServiceCount()
  18355. case employee.FieldAchievementCount:
  18356. return m.AddedAchievementCount()
  18357. case employee.FieldOrganizationID:
  18358. return m.AddedOrganizationID()
  18359. case employee.FieldCategoryID:
  18360. return m.AddedCategoryID()
  18361. case employee.FieldIsVip:
  18362. return m.AddedIsVip()
  18363. }
  18364. return nil, false
  18365. }
  18366. // AddField adds the value to the field with the given name. It returns an error if
  18367. // the field is not defined in the schema, or if the type mismatched the field
  18368. // type.
  18369. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  18370. switch name {
  18371. case employee.FieldHireCount:
  18372. v, ok := value.(int)
  18373. if !ok {
  18374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18375. }
  18376. m.AddHireCount(v)
  18377. return nil
  18378. case employee.FieldServiceCount:
  18379. v, ok := value.(int)
  18380. if !ok {
  18381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18382. }
  18383. m.AddServiceCount(v)
  18384. return nil
  18385. case employee.FieldAchievementCount:
  18386. v, ok := value.(int)
  18387. if !ok {
  18388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18389. }
  18390. m.AddAchievementCount(v)
  18391. return nil
  18392. case employee.FieldOrganizationID:
  18393. v, ok := value.(int64)
  18394. if !ok {
  18395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18396. }
  18397. m.AddOrganizationID(v)
  18398. return nil
  18399. case employee.FieldCategoryID:
  18400. v, ok := value.(int64)
  18401. if !ok {
  18402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18403. }
  18404. m.AddCategoryID(v)
  18405. return nil
  18406. case employee.FieldIsVip:
  18407. v, ok := value.(int)
  18408. if !ok {
  18409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18410. }
  18411. m.AddIsVip(v)
  18412. return nil
  18413. }
  18414. return fmt.Errorf("unknown Employee numeric field %s", name)
  18415. }
  18416. // ClearedFields returns all nullable fields that were cleared during this
  18417. // mutation.
  18418. func (m *EmployeeMutation) ClearedFields() []string {
  18419. var fields []string
  18420. if m.FieldCleared(employee.FieldDeletedAt) {
  18421. fields = append(fields, employee.FieldDeletedAt)
  18422. }
  18423. if m.FieldCleared(employee.FieldAiInfo) {
  18424. fields = append(fields, employee.FieldAiInfo)
  18425. }
  18426. return fields
  18427. }
  18428. // FieldCleared returns a boolean indicating if a field with the given name was
  18429. // cleared in this mutation.
  18430. func (m *EmployeeMutation) FieldCleared(name string) bool {
  18431. _, ok := m.clearedFields[name]
  18432. return ok
  18433. }
  18434. // ClearField clears the value of the field with the given name. It returns an
  18435. // error if the field is not defined in the schema.
  18436. func (m *EmployeeMutation) ClearField(name string) error {
  18437. switch name {
  18438. case employee.FieldDeletedAt:
  18439. m.ClearDeletedAt()
  18440. return nil
  18441. case employee.FieldAiInfo:
  18442. m.ClearAiInfo()
  18443. return nil
  18444. }
  18445. return fmt.Errorf("unknown Employee nullable field %s", name)
  18446. }
  18447. // ResetField resets all changes in the mutation for the field with the given name.
  18448. // It returns an error if the field is not defined in the schema.
  18449. func (m *EmployeeMutation) ResetField(name string) error {
  18450. switch name {
  18451. case employee.FieldCreatedAt:
  18452. m.ResetCreatedAt()
  18453. return nil
  18454. case employee.FieldUpdatedAt:
  18455. m.ResetUpdatedAt()
  18456. return nil
  18457. case employee.FieldDeletedAt:
  18458. m.ResetDeletedAt()
  18459. return nil
  18460. case employee.FieldTitle:
  18461. m.ResetTitle()
  18462. return nil
  18463. case employee.FieldAvatar:
  18464. m.ResetAvatar()
  18465. return nil
  18466. case employee.FieldTags:
  18467. m.ResetTags()
  18468. return nil
  18469. case employee.FieldHireCount:
  18470. m.ResetHireCount()
  18471. return nil
  18472. case employee.FieldServiceCount:
  18473. m.ResetServiceCount()
  18474. return nil
  18475. case employee.FieldAchievementCount:
  18476. m.ResetAchievementCount()
  18477. return nil
  18478. case employee.FieldIntro:
  18479. m.ResetIntro()
  18480. return nil
  18481. case employee.FieldEstimate:
  18482. m.ResetEstimate()
  18483. return nil
  18484. case employee.FieldSkill:
  18485. m.ResetSkill()
  18486. return nil
  18487. case employee.FieldAbilityType:
  18488. m.ResetAbilityType()
  18489. return nil
  18490. case employee.FieldScene:
  18491. m.ResetScene()
  18492. return nil
  18493. case employee.FieldSwitchIn:
  18494. m.ResetSwitchIn()
  18495. return nil
  18496. case employee.FieldVideoURL:
  18497. m.ResetVideoURL()
  18498. return nil
  18499. case employee.FieldOrganizationID:
  18500. m.ResetOrganizationID()
  18501. return nil
  18502. case employee.FieldCategoryID:
  18503. m.ResetCategoryID()
  18504. return nil
  18505. case employee.FieldAPIBase:
  18506. m.ResetAPIBase()
  18507. return nil
  18508. case employee.FieldAPIKey:
  18509. m.ResetAPIKey()
  18510. return nil
  18511. case employee.FieldAiInfo:
  18512. m.ResetAiInfo()
  18513. return nil
  18514. case employee.FieldIsVip:
  18515. m.ResetIsVip()
  18516. return nil
  18517. case employee.FieldChatURL:
  18518. m.ResetChatURL()
  18519. return nil
  18520. }
  18521. return fmt.Errorf("unknown Employee field %s", name)
  18522. }
  18523. // AddedEdges returns all edge names that were set/added in this mutation.
  18524. func (m *EmployeeMutation) AddedEdges() []string {
  18525. edges := make([]string, 0, 2)
  18526. if m.em_work_experiences != nil {
  18527. edges = append(edges, employee.EdgeEmWorkExperiences)
  18528. }
  18529. if m.em_tutorial != nil {
  18530. edges = append(edges, employee.EdgeEmTutorial)
  18531. }
  18532. return edges
  18533. }
  18534. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18535. // name in this mutation.
  18536. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  18537. switch name {
  18538. case employee.EdgeEmWorkExperiences:
  18539. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  18540. for id := range m.em_work_experiences {
  18541. ids = append(ids, id)
  18542. }
  18543. return ids
  18544. case employee.EdgeEmTutorial:
  18545. ids := make([]ent.Value, 0, len(m.em_tutorial))
  18546. for id := range m.em_tutorial {
  18547. ids = append(ids, id)
  18548. }
  18549. return ids
  18550. }
  18551. return nil
  18552. }
  18553. // RemovedEdges returns all edge names that were removed in this mutation.
  18554. func (m *EmployeeMutation) RemovedEdges() []string {
  18555. edges := make([]string, 0, 2)
  18556. if m.removedem_work_experiences != nil {
  18557. edges = append(edges, employee.EdgeEmWorkExperiences)
  18558. }
  18559. if m.removedem_tutorial != nil {
  18560. edges = append(edges, employee.EdgeEmTutorial)
  18561. }
  18562. return edges
  18563. }
  18564. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18565. // the given name in this mutation.
  18566. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  18567. switch name {
  18568. case employee.EdgeEmWorkExperiences:
  18569. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  18570. for id := range m.removedem_work_experiences {
  18571. ids = append(ids, id)
  18572. }
  18573. return ids
  18574. case employee.EdgeEmTutorial:
  18575. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  18576. for id := range m.removedem_tutorial {
  18577. ids = append(ids, id)
  18578. }
  18579. return ids
  18580. }
  18581. return nil
  18582. }
  18583. // ClearedEdges returns all edge names that were cleared in this mutation.
  18584. func (m *EmployeeMutation) ClearedEdges() []string {
  18585. edges := make([]string, 0, 2)
  18586. if m.clearedem_work_experiences {
  18587. edges = append(edges, employee.EdgeEmWorkExperiences)
  18588. }
  18589. if m.clearedem_tutorial {
  18590. edges = append(edges, employee.EdgeEmTutorial)
  18591. }
  18592. return edges
  18593. }
  18594. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18595. // was cleared in this mutation.
  18596. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  18597. switch name {
  18598. case employee.EdgeEmWorkExperiences:
  18599. return m.clearedem_work_experiences
  18600. case employee.EdgeEmTutorial:
  18601. return m.clearedem_tutorial
  18602. }
  18603. return false
  18604. }
  18605. // ClearEdge clears the value of the edge with the given name. It returns an error
  18606. // if that edge is not defined in the schema.
  18607. func (m *EmployeeMutation) ClearEdge(name string) error {
  18608. switch name {
  18609. }
  18610. return fmt.Errorf("unknown Employee unique edge %s", name)
  18611. }
  18612. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18613. // It returns an error if the edge is not defined in the schema.
  18614. func (m *EmployeeMutation) ResetEdge(name string) error {
  18615. switch name {
  18616. case employee.EdgeEmWorkExperiences:
  18617. m.ResetEmWorkExperiences()
  18618. return nil
  18619. case employee.EdgeEmTutorial:
  18620. m.ResetEmTutorial()
  18621. return nil
  18622. }
  18623. return fmt.Errorf("unknown Employee edge %s", name)
  18624. }
  18625. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  18626. type EmployeeConfigMutation struct {
  18627. config
  18628. op Op
  18629. typ string
  18630. id *uint64
  18631. created_at *time.Time
  18632. updated_at *time.Time
  18633. deleted_at *time.Time
  18634. stype *string
  18635. title *string
  18636. photo *string
  18637. organization_id *uint64
  18638. addorganization_id *int64
  18639. clearedFields map[string]struct{}
  18640. done bool
  18641. oldValue func(context.Context) (*EmployeeConfig, error)
  18642. predicates []predicate.EmployeeConfig
  18643. }
  18644. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  18645. // employeeconfigOption allows management of the mutation configuration using functional options.
  18646. type employeeconfigOption func(*EmployeeConfigMutation)
  18647. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  18648. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  18649. m := &EmployeeConfigMutation{
  18650. config: c,
  18651. op: op,
  18652. typ: TypeEmployeeConfig,
  18653. clearedFields: make(map[string]struct{}),
  18654. }
  18655. for _, opt := range opts {
  18656. opt(m)
  18657. }
  18658. return m
  18659. }
  18660. // withEmployeeConfigID sets the ID field of the mutation.
  18661. func withEmployeeConfigID(id uint64) employeeconfigOption {
  18662. return func(m *EmployeeConfigMutation) {
  18663. var (
  18664. err error
  18665. once sync.Once
  18666. value *EmployeeConfig
  18667. )
  18668. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  18669. once.Do(func() {
  18670. if m.done {
  18671. err = errors.New("querying old values post mutation is not allowed")
  18672. } else {
  18673. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  18674. }
  18675. })
  18676. return value, err
  18677. }
  18678. m.id = &id
  18679. }
  18680. }
  18681. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  18682. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  18683. return func(m *EmployeeConfigMutation) {
  18684. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  18685. return node, nil
  18686. }
  18687. m.id = &node.ID
  18688. }
  18689. }
  18690. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18691. // executed in a transaction (ent.Tx), a transactional client is returned.
  18692. func (m EmployeeConfigMutation) Client() *Client {
  18693. client := &Client{config: m.config}
  18694. client.init()
  18695. return client
  18696. }
  18697. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18698. // it returns an error otherwise.
  18699. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  18700. if _, ok := m.driver.(*txDriver); !ok {
  18701. return nil, errors.New("ent: mutation is not running in a transaction")
  18702. }
  18703. tx := &Tx{config: m.config}
  18704. tx.init()
  18705. return tx, nil
  18706. }
  18707. // SetID sets the value of the id field. Note that this
  18708. // operation is only accepted on creation of EmployeeConfig entities.
  18709. func (m *EmployeeConfigMutation) SetID(id uint64) {
  18710. m.id = &id
  18711. }
  18712. // ID returns the ID value in the mutation. Note that the ID is only available
  18713. // if it was provided to the builder or after it was returned from the database.
  18714. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  18715. if m.id == nil {
  18716. return
  18717. }
  18718. return *m.id, true
  18719. }
  18720. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18721. // That means, if the mutation is applied within a transaction with an isolation level such
  18722. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18723. // or updated by the mutation.
  18724. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  18725. switch {
  18726. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18727. id, exists := m.ID()
  18728. if exists {
  18729. return []uint64{id}, nil
  18730. }
  18731. fallthrough
  18732. case m.op.Is(OpUpdate | OpDelete):
  18733. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  18734. default:
  18735. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18736. }
  18737. }
  18738. // SetCreatedAt sets the "created_at" field.
  18739. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  18740. m.created_at = &t
  18741. }
  18742. // CreatedAt returns the value of the "created_at" field in the mutation.
  18743. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  18744. v := m.created_at
  18745. if v == nil {
  18746. return
  18747. }
  18748. return *v, true
  18749. }
  18750. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  18751. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18753. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18754. if !m.op.Is(OpUpdateOne) {
  18755. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18756. }
  18757. if m.id == nil || m.oldValue == nil {
  18758. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18759. }
  18760. oldValue, err := m.oldValue(ctx)
  18761. if err != nil {
  18762. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18763. }
  18764. return oldValue.CreatedAt, nil
  18765. }
  18766. // ResetCreatedAt resets all changes to the "created_at" field.
  18767. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  18768. m.created_at = nil
  18769. }
  18770. // SetUpdatedAt sets the "updated_at" field.
  18771. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  18772. m.updated_at = &t
  18773. }
  18774. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18775. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  18776. v := m.updated_at
  18777. if v == nil {
  18778. return
  18779. }
  18780. return *v, true
  18781. }
  18782. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  18783. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18785. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18786. if !m.op.Is(OpUpdateOne) {
  18787. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18788. }
  18789. if m.id == nil || m.oldValue == nil {
  18790. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18791. }
  18792. oldValue, err := m.oldValue(ctx)
  18793. if err != nil {
  18794. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18795. }
  18796. return oldValue.UpdatedAt, nil
  18797. }
  18798. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18799. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  18800. m.updated_at = nil
  18801. }
  18802. // SetDeletedAt sets the "deleted_at" field.
  18803. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  18804. m.deleted_at = &t
  18805. }
  18806. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18807. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  18808. v := m.deleted_at
  18809. if v == nil {
  18810. return
  18811. }
  18812. return *v, true
  18813. }
  18814. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  18815. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18817. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18818. if !m.op.Is(OpUpdateOne) {
  18819. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18820. }
  18821. if m.id == nil || m.oldValue == nil {
  18822. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18823. }
  18824. oldValue, err := m.oldValue(ctx)
  18825. if err != nil {
  18826. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18827. }
  18828. return oldValue.DeletedAt, nil
  18829. }
  18830. // ClearDeletedAt clears the value of the "deleted_at" field.
  18831. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  18832. m.deleted_at = nil
  18833. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  18834. }
  18835. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18836. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  18837. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  18838. return ok
  18839. }
  18840. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18841. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  18842. m.deleted_at = nil
  18843. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  18844. }
  18845. // SetStype sets the "stype" field.
  18846. func (m *EmployeeConfigMutation) SetStype(s string) {
  18847. m.stype = &s
  18848. }
  18849. // Stype returns the value of the "stype" field in the mutation.
  18850. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  18851. v := m.stype
  18852. if v == nil {
  18853. return
  18854. }
  18855. return *v, true
  18856. }
  18857. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  18858. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18860. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  18861. if !m.op.Is(OpUpdateOne) {
  18862. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  18863. }
  18864. if m.id == nil || m.oldValue == nil {
  18865. return v, errors.New("OldStype requires an ID field in the mutation")
  18866. }
  18867. oldValue, err := m.oldValue(ctx)
  18868. if err != nil {
  18869. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  18870. }
  18871. return oldValue.Stype, nil
  18872. }
  18873. // ResetStype resets all changes to the "stype" field.
  18874. func (m *EmployeeConfigMutation) ResetStype() {
  18875. m.stype = nil
  18876. }
  18877. // SetTitle sets the "title" field.
  18878. func (m *EmployeeConfigMutation) SetTitle(s string) {
  18879. m.title = &s
  18880. }
  18881. // Title returns the value of the "title" field in the mutation.
  18882. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  18883. v := m.title
  18884. if v == nil {
  18885. return
  18886. }
  18887. return *v, true
  18888. }
  18889. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  18890. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18892. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  18893. if !m.op.Is(OpUpdateOne) {
  18894. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18895. }
  18896. if m.id == nil || m.oldValue == nil {
  18897. return v, errors.New("OldTitle requires an ID field in the mutation")
  18898. }
  18899. oldValue, err := m.oldValue(ctx)
  18900. if err != nil {
  18901. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18902. }
  18903. return oldValue.Title, nil
  18904. }
  18905. // ResetTitle resets all changes to the "title" field.
  18906. func (m *EmployeeConfigMutation) ResetTitle() {
  18907. m.title = nil
  18908. }
  18909. // SetPhoto sets the "photo" field.
  18910. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  18911. m.photo = &s
  18912. }
  18913. // Photo returns the value of the "photo" field in the mutation.
  18914. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  18915. v := m.photo
  18916. if v == nil {
  18917. return
  18918. }
  18919. return *v, true
  18920. }
  18921. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  18922. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18924. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  18925. if !m.op.Is(OpUpdateOne) {
  18926. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  18927. }
  18928. if m.id == nil || m.oldValue == nil {
  18929. return v, errors.New("OldPhoto requires an ID field in the mutation")
  18930. }
  18931. oldValue, err := m.oldValue(ctx)
  18932. if err != nil {
  18933. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  18934. }
  18935. return oldValue.Photo, nil
  18936. }
  18937. // ResetPhoto resets all changes to the "photo" field.
  18938. func (m *EmployeeConfigMutation) ResetPhoto() {
  18939. m.photo = nil
  18940. }
  18941. // SetOrganizationID sets the "organization_id" field.
  18942. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  18943. m.organization_id = &u
  18944. m.addorganization_id = nil
  18945. }
  18946. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18947. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  18948. v := m.organization_id
  18949. if v == nil {
  18950. return
  18951. }
  18952. return *v, true
  18953. }
  18954. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  18955. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  18956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18957. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18958. if !m.op.Is(OpUpdateOne) {
  18959. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18960. }
  18961. if m.id == nil || m.oldValue == nil {
  18962. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18963. }
  18964. oldValue, err := m.oldValue(ctx)
  18965. if err != nil {
  18966. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18967. }
  18968. return oldValue.OrganizationID, nil
  18969. }
  18970. // AddOrganizationID adds u to the "organization_id" field.
  18971. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  18972. if m.addorganization_id != nil {
  18973. *m.addorganization_id += u
  18974. } else {
  18975. m.addorganization_id = &u
  18976. }
  18977. }
  18978. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18979. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  18980. v := m.addorganization_id
  18981. if v == nil {
  18982. return
  18983. }
  18984. return *v, true
  18985. }
  18986. // ClearOrganizationID clears the value of the "organization_id" field.
  18987. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  18988. m.organization_id = nil
  18989. m.addorganization_id = nil
  18990. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  18991. }
  18992. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18993. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  18994. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  18995. return ok
  18996. }
  18997. // ResetOrganizationID resets all changes to the "organization_id" field.
  18998. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  18999. m.organization_id = nil
  19000. m.addorganization_id = nil
  19001. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  19002. }
  19003. // Where appends a list predicates to the EmployeeConfigMutation builder.
  19004. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  19005. m.predicates = append(m.predicates, ps...)
  19006. }
  19007. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  19008. // users can use type-assertion to append predicates that do not depend on any generated package.
  19009. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  19010. p := make([]predicate.EmployeeConfig, len(ps))
  19011. for i := range ps {
  19012. p[i] = ps[i]
  19013. }
  19014. m.Where(p...)
  19015. }
  19016. // Op returns the operation name.
  19017. func (m *EmployeeConfigMutation) Op() Op {
  19018. return m.op
  19019. }
  19020. // SetOp allows setting the mutation operation.
  19021. func (m *EmployeeConfigMutation) SetOp(op Op) {
  19022. m.op = op
  19023. }
  19024. // Type returns the node type of this mutation (EmployeeConfig).
  19025. func (m *EmployeeConfigMutation) Type() string {
  19026. return m.typ
  19027. }
  19028. // Fields returns all fields that were changed during this mutation. Note that in
  19029. // order to get all numeric fields that were incremented/decremented, call
  19030. // AddedFields().
  19031. func (m *EmployeeConfigMutation) Fields() []string {
  19032. fields := make([]string, 0, 7)
  19033. if m.created_at != nil {
  19034. fields = append(fields, employeeconfig.FieldCreatedAt)
  19035. }
  19036. if m.updated_at != nil {
  19037. fields = append(fields, employeeconfig.FieldUpdatedAt)
  19038. }
  19039. if m.deleted_at != nil {
  19040. fields = append(fields, employeeconfig.FieldDeletedAt)
  19041. }
  19042. if m.stype != nil {
  19043. fields = append(fields, employeeconfig.FieldStype)
  19044. }
  19045. if m.title != nil {
  19046. fields = append(fields, employeeconfig.FieldTitle)
  19047. }
  19048. if m.photo != nil {
  19049. fields = append(fields, employeeconfig.FieldPhoto)
  19050. }
  19051. if m.organization_id != nil {
  19052. fields = append(fields, employeeconfig.FieldOrganizationID)
  19053. }
  19054. return fields
  19055. }
  19056. // Field returns the value of a field with the given name. The second boolean
  19057. // return value indicates that this field was not set, or was not defined in the
  19058. // schema.
  19059. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  19060. switch name {
  19061. case employeeconfig.FieldCreatedAt:
  19062. return m.CreatedAt()
  19063. case employeeconfig.FieldUpdatedAt:
  19064. return m.UpdatedAt()
  19065. case employeeconfig.FieldDeletedAt:
  19066. return m.DeletedAt()
  19067. case employeeconfig.FieldStype:
  19068. return m.Stype()
  19069. case employeeconfig.FieldTitle:
  19070. return m.Title()
  19071. case employeeconfig.FieldPhoto:
  19072. return m.Photo()
  19073. case employeeconfig.FieldOrganizationID:
  19074. return m.OrganizationID()
  19075. }
  19076. return nil, false
  19077. }
  19078. // OldField returns the old value of the field from the database. An error is
  19079. // returned if the mutation operation is not UpdateOne, or the query to the
  19080. // database failed.
  19081. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19082. switch name {
  19083. case employeeconfig.FieldCreatedAt:
  19084. return m.OldCreatedAt(ctx)
  19085. case employeeconfig.FieldUpdatedAt:
  19086. return m.OldUpdatedAt(ctx)
  19087. case employeeconfig.FieldDeletedAt:
  19088. return m.OldDeletedAt(ctx)
  19089. case employeeconfig.FieldStype:
  19090. return m.OldStype(ctx)
  19091. case employeeconfig.FieldTitle:
  19092. return m.OldTitle(ctx)
  19093. case employeeconfig.FieldPhoto:
  19094. return m.OldPhoto(ctx)
  19095. case employeeconfig.FieldOrganizationID:
  19096. return m.OldOrganizationID(ctx)
  19097. }
  19098. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  19099. }
  19100. // SetField sets the value of a field with the given name. It returns an error if
  19101. // the field is not defined in the schema, or if the type mismatched the field
  19102. // type.
  19103. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  19104. switch name {
  19105. case employeeconfig.FieldCreatedAt:
  19106. v, ok := value.(time.Time)
  19107. if !ok {
  19108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19109. }
  19110. m.SetCreatedAt(v)
  19111. return nil
  19112. case employeeconfig.FieldUpdatedAt:
  19113. v, ok := value.(time.Time)
  19114. if !ok {
  19115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19116. }
  19117. m.SetUpdatedAt(v)
  19118. return nil
  19119. case employeeconfig.FieldDeletedAt:
  19120. v, ok := value.(time.Time)
  19121. if !ok {
  19122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19123. }
  19124. m.SetDeletedAt(v)
  19125. return nil
  19126. case employeeconfig.FieldStype:
  19127. v, ok := value.(string)
  19128. if !ok {
  19129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19130. }
  19131. m.SetStype(v)
  19132. return nil
  19133. case employeeconfig.FieldTitle:
  19134. v, ok := value.(string)
  19135. if !ok {
  19136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19137. }
  19138. m.SetTitle(v)
  19139. return nil
  19140. case employeeconfig.FieldPhoto:
  19141. v, ok := value.(string)
  19142. if !ok {
  19143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19144. }
  19145. m.SetPhoto(v)
  19146. return nil
  19147. case employeeconfig.FieldOrganizationID:
  19148. v, ok := value.(uint64)
  19149. if !ok {
  19150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19151. }
  19152. m.SetOrganizationID(v)
  19153. return nil
  19154. }
  19155. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  19156. }
  19157. // AddedFields returns all numeric fields that were incremented/decremented during
  19158. // this mutation.
  19159. func (m *EmployeeConfigMutation) AddedFields() []string {
  19160. var fields []string
  19161. if m.addorganization_id != nil {
  19162. fields = append(fields, employeeconfig.FieldOrganizationID)
  19163. }
  19164. return fields
  19165. }
  19166. // AddedField returns the numeric value that was incremented/decremented on a field
  19167. // with the given name. The second boolean return value indicates that this field
  19168. // was not set, or was not defined in the schema.
  19169. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  19170. switch name {
  19171. case employeeconfig.FieldOrganizationID:
  19172. return m.AddedOrganizationID()
  19173. }
  19174. return nil, false
  19175. }
  19176. // AddField adds the value to the field with the given name. It returns an error if
  19177. // the field is not defined in the schema, or if the type mismatched the field
  19178. // type.
  19179. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  19180. switch name {
  19181. case employeeconfig.FieldOrganizationID:
  19182. v, ok := value.(int64)
  19183. if !ok {
  19184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19185. }
  19186. m.AddOrganizationID(v)
  19187. return nil
  19188. }
  19189. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  19190. }
  19191. // ClearedFields returns all nullable fields that were cleared during this
  19192. // mutation.
  19193. func (m *EmployeeConfigMutation) ClearedFields() []string {
  19194. var fields []string
  19195. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  19196. fields = append(fields, employeeconfig.FieldDeletedAt)
  19197. }
  19198. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  19199. fields = append(fields, employeeconfig.FieldOrganizationID)
  19200. }
  19201. return fields
  19202. }
  19203. // FieldCleared returns a boolean indicating if a field with the given name was
  19204. // cleared in this mutation.
  19205. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  19206. _, ok := m.clearedFields[name]
  19207. return ok
  19208. }
  19209. // ClearField clears the value of the field with the given name. It returns an
  19210. // error if the field is not defined in the schema.
  19211. func (m *EmployeeConfigMutation) ClearField(name string) error {
  19212. switch name {
  19213. case employeeconfig.FieldDeletedAt:
  19214. m.ClearDeletedAt()
  19215. return nil
  19216. case employeeconfig.FieldOrganizationID:
  19217. m.ClearOrganizationID()
  19218. return nil
  19219. }
  19220. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  19221. }
  19222. // ResetField resets all changes in the mutation for the field with the given name.
  19223. // It returns an error if the field is not defined in the schema.
  19224. func (m *EmployeeConfigMutation) ResetField(name string) error {
  19225. switch name {
  19226. case employeeconfig.FieldCreatedAt:
  19227. m.ResetCreatedAt()
  19228. return nil
  19229. case employeeconfig.FieldUpdatedAt:
  19230. m.ResetUpdatedAt()
  19231. return nil
  19232. case employeeconfig.FieldDeletedAt:
  19233. m.ResetDeletedAt()
  19234. return nil
  19235. case employeeconfig.FieldStype:
  19236. m.ResetStype()
  19237. return nil
  19238. case employeeconfig.FieldTitle:
  19239. m.ResetTitle()
  19240. return nil
  19241. case employeeconfig.FieldPhoto:
  19242. m.ResetPhoto()
  19243. return nil
  19244. case employeeconfig.FieldOrganizationID:
  19245. m.ResetOrganizationID()
  19246. return nil
  19247. }
  19248. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  19249. }
  19250. // AddedEdges returns all edge names that were set/added in this mutation.
  19251. func (m *EmployeeConfigMutation) AddedEdges() []string {
  19252. edges := make([]string, 0, 0)
  19253. return edges
  19254. }
  19255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19256. // name in this mutation.
  19257. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  19258. return nil
  19259. }
  19260. // RemovedEdges returns all edge names that were removed in this mutation.
  19261. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  19262. edges := make([]string, 0, 0)
  19263. return edges
  19264. }
  19265. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19266. // the given name in this mutation.
  19267. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  19268. return nil
  19269. }
  19270. // ClearedEdges returns all edge names that were cleared in this mutation.
  19271. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  19272. edges := make([]string, 0, 0)
  19273. return edges
  19274. }
  19275. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19276. // was cleared in this mutation.
  19277. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  19278. return false
  19279. }
  19280. // ClearEdge clears the value of the edge with the given name. It returns an error
  19281. // if that edge is not defined in the schema.
  19282. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  19283. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  19284. }
  19285. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19286. // It returns an error if the edge is not defined in the schema.
  19287. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  19288. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  19289. }
  19290. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  19291. type LabelMutation struct {
  19292. config
  19293. op Op
  19294. typ string
  19295. id *uint64
  19296. created_at *time.Time
  19297. updated_at *time.Time
  19298. status *uint8
  19299. addstatus *int8
  19300. _type *int
  19301. add_type *int
  19302. name *string
  19303. from *int
  19304. addfrom *int
  19305. mode *int
  19306. addmode *int
  19307. conditions *string
  19308. organization_id *uint64
  19309. addorganization_id *int64
  19310. clearedFields map[string]struct{}
  19311. label_relationships map[uint64]struct{}
  19312. removedlabel_relationships map[uint64]struct{}
  19313. clearedlabel_relationships bool
  19314. done bool
  19315. oldValue func(context.Context) (*Label, error)
  19316. predicates []predicate.Label
  19317. }
  19318. var _ ent.Mutation = (*LabelMutation)(nil)
  19319. // labelOption allows management of the mutation configuration using functional options.
  19320. type labelOption func(*LabelMutation)
  19321. // newLabelMutation creates new mutation for the Label entity.
  19322. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  19323. m := &LabelMutation{
  19324. config: c,
  19325. op: op,
  19326. typ: TypeLabel,
  19327. clearedFields: make(map[string]struct{}),
  19328. }
  19329. for _, opt := range opts {
  19330. opt(m)
  19331. }
  19332. return m
  19333. }
  19334. // withLabelID sets the ID field of the mutation.
  19335. func withLabelID(id uint64) labelOption {
  19336. return func(m *LabelMutation) {
  19337. var (
  19338. err error
  19339. once sync.Once
  19340. value *Label
  19341. )
  19342. m.oldValue = func(ctx context.Context) (*Label, error) {
  19343. once.Do(func() {
  19344. if m.done {
  19345. err = errors.New("querying old values post mutation is not allowed")
  19346. } else {
  19347. value, err = m.Client().Label.Get(ctx, id)
  19348. }
  19349. })
  19350. return value, err
  19351. }
  19352. m.id = &id
  19353. }
  19354. }
  19355. // withLabel sets the old Label of the mutation.
  19356. func withLabel(node *Label) labelOption {
  19357. return func(m *LabelMutation) {
  19358. m.oldValue = func(context.Context) (*Label, error) {
  19359. return node, nil
  19360. }
  19361. m.id = &node.ID
  19362. }
  19363. }
  19364. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19365. // executed in a transaction (ent.Tx), a transactional client is returned.
  19366. func (m LabelMutation) Client() *Client {
  19367. client := &Client{config: m.config}
  19368. client.init()
  19369. return client
  19370. }
  19371. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19372. // it returns an error otherwise.
  19373. func (m LabelMutation) Tx() (*Tx, error) {
  19374. if _, ok := m.driver.(*txDriver); !ok {
  19375. return nil, errors.New("ent: mutation is not running in a transaction")
  19376. }
  19377. tx := &Tx{config: m.config}
  19378. tx.init()
  19379. return tx, nil
  19380. }
  19381. // SetID sets the value of the id field. Note that this
  19382. // operation is only accepted on creation of Label entities.
  19383. func (m *LabelMutation) SetID(id uint64) {
  19384. m.id = &id
  19385. }
  19386. // ID returns the ID value in the mutation. Note that the ID is only available
  19387. // if it was provided to the builder or after it was returned from the database.
  19388. func (m *LabelMutation) ID() (id uint64, exists bool) {
  19389. if m.id == nil {
  19390. return
  19391. }
  19392. return *m.id, true
  19393. }
  19394. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19395. // That means, if the mutation is applied within a transaction with an isolation level such
  19396. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19397. // or updated by the mutation.
  19398. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  19399. switch {
  19400. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19401. id, exists := m.ID()
  19402. if exists {
  19403. return []uint64{id}, nil
  19404. }
  19405. fallthrough
  19406. case m.op.Is(OpUpdate | OpDelete):
  19407. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  19408. default:
  19409. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19410. }
  19411. }
  19412. // SetCreatedAt sets the "created_at" field.
  19413. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  19414. m.created_at = &t
  19415. }
  19416. // CreatedAt returns the value of the "created_at" field in the mutation.
  19417. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  19418. v := m.created_at
  19419. if v == nil {
  19420. return
  19421. }
  19422. return *v, true
  19423. }
  19424. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  19425. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19427. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19428. if !m.op.Is(OpUpdateOne) {
  19429. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19430. }
  19431. if m.id == nil || m.oldValue == nil {
  19432. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19433. }
  19434. oldValue, err := m.oldValue(ctx)
  19435. if err != nil {
  19436. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19437. }
  19438. return oldValue.CreatedAt, nil
  19439. }
  19440. // ResetCreatedAt resets all changes to the "created_at" field.
  19441. func (m *LabelMutation) ResetCreatedAt() {
  19442. m.created_at = nil
  19443. }
  19444. // SetUpdatedAt sets the "updated_at" field.
  19445. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  19446. m.updated_at = &t
  19447. }
  19448. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19449. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  19450. v := m.updated_at
  19451. if v == nil {
  19452. return
  19453. }
  19454. return *v, true
  19455. }
  19456. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  19457. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19459. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19460. if !m.op.Is(OpUpdateOne) {
  19461. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19462. }
  19463. if m.id == nil || m.oldValue == nil {
  19464. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19465. }
  19466. oldValue, err := m.oldValue(ctx)
  19467. if err != nil {
  19468. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19469. }
  19470. return oldValue.UpdatedAt, nil
  19471. }
  19472. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19473. func (m *LabelMutation) ResetUpdatedAt() {
  19474. m.updated_at = nil
  19475. }
  19476. // SetStatus sets the "status" field.
  19477. func (m *LabelMutation) SetStatus(u uint8) {
  19478. m.status = &u
  19479. m.addstatus = nil
  19480. }
  19481. // Status returns the value of the "status" field in the mutation.
  19482. func (m *LabelMutation) Status() (r uint8, exists bool) {
  19483. v := m.status
  19484. if v == nil {
  19485. return
  19486. }
  19487. return *v, true
  19488. }
  19489. // OldStatus returns the old "status" field's value of the Label entity.
  19490. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19492. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19493. if !m.op.Is(OpUpdateOne) {
  19494. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19495. }
  19496. if m.id == nil || m.oldValue == nil {
  19497. return v, errors.New("OldStatus requires an ID field in the mutation")
  19498. }
  19499. oldValue, err := m.oldValue(ctx)
  19500. if err != nil {
  19501. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19502. }
  19503. return oldValue.Status, nil
  19504. }
  19505. // AddStatus adds u to the "status" field.
  19506. func (m *LabelMutation) AddStatus(u int8) {
  19507. if m.addstatus != nil {
  19508. *m.addstatus += u
  19509. } else {
  19510. m.addstatus = &u
  19511. }
  19512. }
  19513. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19514. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  19515. v := m.addstatus
  19516. if v == nil {
  19517. return
  19518. }
  19519. return *v, true
  19520. }
  19521. // ClearStatus clears the value of the "status" field.
  19522. func (m *LabelMutation) ClearStatus() {
  19523. m.status = nil
  19524. m.addstatus = nil
  19525. m.clearedFields[label.FieldStatus] = struct{}{}
  19526. }
  19527. // StatusCleared returns if the "status" field was cleared in this mutation.
  19528. func (m *LabelMutation) StatusCleared() bool {
  19529. _, ok := m.clearedFields[label.FieldStatus]
  19530. return ok
  19531. }
  19532. // ResetStatus resets all changes to the "status" field.
  19533. func (m *LabelMutation) ResetStatus() {
  19534. m.status = nil
  19535. m.addstatus = nil
  19536. delete(m.clearedFields, label.FieldStatus)
  19537. }
  19538. // SetType sets the "type" field.
  19539. func (m *LabelMutation) SetType(i int) {
  19540. m._type = &i
  19541. m.add_type = nil
  19542. }
  19543. // GetType returns the value of the "type" field in the mutation.
  19544. func (m *LabelMutation) GetType() (r int, exists bool) {
  19545. v := m._type
  19546. if v == nil {
  19547. return
  19548. }
  19549. return *v, true
  19550. }
  19551. // OldType returns the old "type" field's value of the Label entity.
  19552. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19554. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  19555. if !m.op.Is(OpUpdateOne) {
  19556. return v, errors.New("OldType is only allowed on UpdateOne operations")
  19557. }
  19558. if m.id == nil || m.oldValue == nil {
  19559. return v, errors.New("OldType requires an ID field in the mutation")
  19560. }
  19561. oldValue, err := m.oldValue(ctx)
  19562. if err != nil {
  19563. return v, fmt.Errorf("querying old value for OldType: %w", err)
  19564. }
  19565. return oldValue.Type, nil
  19566. }
  19567. // AddType adds i to the "type" field.
  19568. func (m *LabelMutation) AddType(i int) {
  19569. if m.add_type != nil {
  19570. *m.add_type += i
  19571. } else {
  19572. m.add_type = &i
  19573. }
  19574. }
  19575. // AddedType returns the value that was added to the "type" field in this mutation.
  19576. func (m *LabelMutation) AddedType() (r int, exists bool) {
  19577. v := m.add_type
  19578. if v == nil {
  19579. return
  19580. }
  19581. return *v, true
  19582. }
  19583. // ResetType resets all changes to the "type" field.
  19584. func (m *LabelMutation) ResetType() {
  19585. m._type = nil
  19586. m.add_type = nil
  19587. }
  19588. // SetName sets the "name" field.
  19589. func (m *LabelMutation) SetName(s string) {
  19590. m.name = &s
  19591. }
  19592. // Name returns the value of the "name" field in the mutation.
  19593. func (m *LabelMutation) Name() (r string, exists bool) {
  19594. v := m.name
  19595. if v == nil {
  19596. return
  19597. }
  19598. return *v, true
  19599. }
  19600. // OldName returns the old "name" field's value of the Label entity.
  19601. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19603. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  19604. if !m.op.Is(OpUpdateOne) {
  19605. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19606. }
  19607. if m.id == nil || m.oldValue == nil {
  19608. return v, errors.New("OldName requires an ID field in the mutation")
  19609. }
  19610. oldValue, err := m.oldValue(ctx)
  19611. if err != nil {
  19612. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19613. }
  19614. return oldValue.Name, nil
  19615. }
  19616. // ResetName resets all changes to the "name" field.
  19617. func (m *LabelMutation) ResetName() {
  19618. m.name = nil
  19619. }
  19620. // SetFrom sets the "from" field.
  19621. func (m *LabelMutation) SetFrom(i int) {
  19622. m.from = &i
  19623. m.addfrom = nil
  19624. }
  19625. // From returns the value of the "from" field in the mutation.
  19626. func (m *LabelMutation) From() (r int, exists bool) {
  19627. v := m.from
  19628. if v == nil {
  19629. return
  19630. }
  19631. return *v, true
  19632. }
  19633. // OldFrom returns the old "from" field's value of the Label entity.
  19634. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19636. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  19637. if !m.op.Is(OpUpdateOne) {
  19638. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  19639. }
  19640. if m.id == nil || m.oldValue == nil {
  19641. return v, errors.New("OldFrom requires an ID field in the mutation")
  19642. }
  19643. oldValue, err := m.oldValue(ctx)
  19644. if err != nil {
  19645. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  19646. }
  19647. return oldValue.From, nil
  19648. }
  19649. // AddFrom adds i to the "from" field.
  19650. func (m *LabelMutation) AddFrom(i int) {
  19651. if m.addfrom != nil {
  19652. *m.addfrom += i
  19653. } else {
  19654. m.addfrom = &i
  19655. }
  19656. }
  19657. // AddedFrom returns the value that was added to the "from" field in this mutation.
  19658. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  19659. v := m.addfrom
  19660. if v == nil {
  19661. return
  19662. }
  19663. return *v, true
  19664. }
  19665. // ResetFrom resets all changes to the "from" field.
  19666. func (m *LabelMutation) ResetFrom() {
  19667. m.from = nil
  19668. m.addfrom = nil
  19669. }
  19670. // SetMode sets the "mode" field.
  19671. func (m *LabelMutation) SetMode(i int) {
  19672. m.mode = &i
  19673. m.addmode = nil
  19674. }
  19675. // Mode returns the value of the "mode" field in the mutation.
  19676. func (m *LabelMutation) Mode() (r int, exists bool) {
  19677. v := m.mode
  19678. if v == nil {
  19679. return
  19680. }
  19681. return *v, true
  19682. }
  19683. // OldMode returns the old "mode" field's value of the Label entity.
  19684. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19686. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  19687. if !m.op.Is(OpUpdateOne) {
  19688. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  19689. }
  19690. if m.id == nil || m.oldValue == nil {
  19691. return v, errors.New("OldMode requires an ID field in the mutation")
  19692. }
  19693. oldValue, err := m.oldValue(ctx)
  19694. if err != nil {
  19695. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  19696. }
  19697. return oldValue.Mode, nil
  19698. }
  19699. // AddMode adds i to the "mode" field.
  19700. func (m *LabelMutation) AddMode(i int) {
  19701. if m.addmode != nil {
  19702. *m.addmode += i
  19703. } else {
  19704. m.addmode = &i
  19705. }
  19706. }
  19707. // AddedMode returns the value that was added to the "mode" field in this mutation.
  19708. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  19709. v := m.addmode
  19710. if v == nil {
  19711. return
  19712. }
  19713. return *v, true
  19714. }
  19715. // ResetMode resets all changes to the "mode" field.
  19716. func (m *LabelMutation) ResetMode() {
  19717. m.mode = nil
  19718. m.addmode = nil
  19719. }
  19720. // SetConditions sets the "conditions" field.
  19721. func (m *LabelMutation) SetConditions(s string) {
  19722. m.conditions = &s
  19723. }
  19724. // Conditions returns the value of the "conditions" field in the mutation.
  19725. func (m *LabelMutation) Conditions() (r string, exists bool) {
  19726. v := m.conditions
  19727. if v == nil {
  19728. return
  19729. }
  19730. return *v, true
  19731. }
  19732. // OldConditions returns the old "conditions" field's value of the Label entity.
  19733. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19735. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  19736. if !m.op.Is(OpUpdateOne) {
  19737. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  19738. }
  19739. if m.id == nil || m.oldValue == nil {
  19740. return v, errors.New("OldConditions requires an ID field in the mutation")
  19741. }
  19742. oldValue, err := m.oldValue(ctx)
  19743. if err != nil {
  19744. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19745. }
  19746. return oldValue.Conditions, nil
  19747. }
  19748. // ClearConditions clears the value of the "conditions" field.
  19749. func (m *LabelMutation) ClearConditions() {
  19750. m.conditions = nil
  19751. m.clearedFields[label.FieldConditions] = struct{}{}
  19752. }
  19753. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  19754. func (m *LabelMutation) ConditionsCleared() bool {
  19755. _, ok := m.clearedFields[label.FieldConditions]
  19756. return ok
  19757. }
  19758. // ResetConditions resets all changes to the "conditions" field.
  19759. func (m *LabelMutation) ResetConditions() {
  19760. m.conditions = nil
  19761. delete(m.clearedFields, label.FieldConditions)
  19762. }
  19763. // SetOrganizationID sets the "organization_id" field.
  19764. func (m *LabelMutation) SetOrganizationID(u uint64) {
  19765. m.organization_id = &u
  19766. m.addorganization_id = nil
  19767. }
  19768. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19769. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  19770. v := m.organization_id
  19771. if v == nil {
  19772. return
  19773. }
  19774. return *v, true
  19775. }
  19776. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  19777. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  19778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19779. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19780. if !m.op.Is(OpUpdateOne) {
  19781. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19782. }
  19783. if m.id == nil || m.oldValue == nil {
  19784. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19785. }
  19786. oldValue, err := m.oldValue(ctx)
  19787. if err != nil {
  19788. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19789. }
  19790. return oldValue.OrganizationID, nil
  19791. }
  19792. // AddOrganizationID adds u to the "organization_id" field.
  19793. func (m *LabelMutation) AddOrganizationID(u int64) {
  19794. if m.addorganization_id != nil {
  19795. *m.addorganization_id += u
  19796. } else {
  19797. m.addorganization_id = &u
  19798. }
  19799. }
  19800. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19801. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  19802. v := m.addorganization_id
  19803. if v == nil {
  19804. return
  19805. }
  19806. return *v, true
  19807. }
  19808. // ClearOrganizationID clears the value of the "organization_id" field.
  19809. func (m *LabelMutation) ClearOrganizationID() {
  19810. m.organization_id = nil
  19811. m.addorganization_id = nil
  19812. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  19813. }
  19814. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19815. func (m *LabelMutation) OrganizationIDCleared() bool {
  19816. _, ok := m.clearedFields[label.FieldOrganizationID]
  19817. return ok
  19818. }
  19819. // ResetOrganizationID resets all changes to the "organization_id" field.
  19820. func (m *LabelMutation) ResetOrganizationID() {
  19821. m.organization_id = nil
  19822. m.addorganization_id = nil
  19823. delete(m.clearedFields, label.FieldOrganizationID)
  19824. }
  19825. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  19826. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  19827. if m.label_relationships == nil {
  19828. m.label_relationships = make(map[uint64]struct{})
  19829. }
  19830. for i := range ids {
  19831. m.label_relationships[ids[i]] = struct{}{}
  19832. }
  19833. }
  19834. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  19835. func (m *LabelMutation) ClearLabelRelationships() {
  19836. m.clearedlabel_relationships = true
  19837. }
  19838. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  19839. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  19840. return m.clearedlabel_relationships
  19841. }
  19842. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  19843. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  19844. if m.removedlabel_relationships == nil {
  19845. m.removedlabel_relationships = make(map[uint64]struct{})
  19846. }
  19847. for i := range ids {
  19848. delete(m.label_relationships, ids[i])
  19849. m.removedlabel_relationships[ids[i]] = struct{}{}
  19850. }
  19851. }
  19852. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  19853. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  19854. for id := range m.removedlabel_relationships {
  19855. ids = append(ids, id)
  19856. }
  19857. return
  19858. }
  19859. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  19860. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  19861. for id := range m.label_relationships {
  19862. ids = append(ids, id)
  19863. }
  19864. return
  19865. }
  19866. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  19867. func (m *LabelMutation) ResetLabelRelationships() {
  19868. m.label_relationships = nil
  19869. m.clearedlabel_relationships = false
  19870. m.removedlabel_relationships = nil
  19871. }
  19872. // Where appends a list predicates to the LabelMutation builder.
  19873. func (m *LabelMutation) Where(ps ...predicate.Label) {
  19874. m.predicates = append(m.predicates, ps...)
  19875. }
  19876. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  19877. // users can use type-assertion to append predicates that do not depend on any generated package.
  19878. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  19879. p := make([]predicate.Label, len(ps))
  19880. for i := range ps {
  19881. p[i] = ps[i]
  19882. }
  19883. m.Where(p...)
  19884. }
  19885. // Op returns the operation name.
  19886. func (m *LabelMutation) Op() Op {
  19887. return m.op
  19888. }
  19889. // SetOp allows setting the mutation operation.
  19890. func (m *LabelMutation) SetOp(op Op) {
  19891. m.op = op
  19892. }
  19893. // Type returns the node type of this mutation (Label).
  19894. func (m *LabelMutation) Type() string {
  19895. return m.typ
  19896. }
  19897. // Fields returns all fields that were changed during this mutation. Note that in
  19898. // order to get all numeric fields that were incremented/decremented, call
  19899. // AddedFields().
  19900. func (m *LabelMutation) Fields() []string {
  19901. fields := make([]string, 0, 9)
  19902. if m.created_at != nil {
  19903. fields = append(fields, label.FieldCreatedAt)
  19904. }
  19905. if m.updated_at != nil {
  19906. fields = append(fields, label.FieldUpdatedAt)
  19907. }
  19908. if m.status != nil {
  19909. fields = append(fields, label.FieldStatus)
  19910. }
  19911. if m._type != nil {
  19912. fields = append(fields, label.FieldType)
  19913. }
  19914. if m.name != nil {
  19915. fields = append(fields, label.FieldName)
  19916. }
  19917. if m.from != nil {
  19918. fields = append(fields, label.FieldFrom)
  19919. }
  19920. if m.mode != nil {
  19921. fields = append(fields, label.FieldMode)
  19922. }
  19923. if m.conditions != nil {
  19924. fields = append(fields, label.FieldConditions)
  19925. }
  19926. if m.organization_id != nil {
  19927. fields = append(fields, label.FieldOrganizationID)
  19928. }
  19929. return fields
  19930. }
  19931. // Field returns the value of a field with the given name. The second boolean
  19932. // return value indicates that this field was not set, or was not defined in the
  19933. // schema.
  19934. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  19935. switch name {
  19936. case label.FieldCreatedAt:
  19937. return m.CreatedAt()
  19938. case label.FieldUpdatedAt:
  19939. return m.UpdatedAt()
  19940. case label.FieldStatus:
  19941. return m.Status()
  19942. case label.FieldType:
  19943. return m.GetType()
  19944. case label.FieldName:
  19945. return m.Name()
  19946. case label.FieldFrom:
  19947. return m.From()
  19948. case label.FieldMode:
  19949. return m.Mode()
  19950. case label.FieldConditions:
  19951. return m.Conditions()
  19952. case label.FieldOrganizationID:
  19953. return m.OrganizationID()
  19954. }
  19955. return nil, false
  19956. }
  19957. // OldField returns the old value of the field from the database. An error is
  19958. // returned if the mutation operation is not UpdateOne, or the query to the
  19959. // database failed.
  19960. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19961. switch name {
  19962. case label.FieldCreatedAt:
  19963. return m.OldCreatedAt(ctx)
  19964. case label.FieldUpdatedAt:
  19965. return m.OldUpdatedAt(ctx)
  19966. case label.FieldStatus:
  19967. return m.OldStatus(ctx)
  19968. case label.FieldType:
  19969. return m.OldType(ctx)
  19970. case label.FieldName:
  19971. return m.OldName(ctx)
  19972. case label.FieldFrom:
  19973. return m.OldFrom(ctx)
  19974. case label.FieldMode:
  19975. return m.OldMode(ctx)
  19976. case label.FieldConditions:
  19977. return m.OldConditions(ctx)
  19978. case label.FieldOrganizationID:
  19979. return m.OldOrganizationID(ctx)
  19980. }
  19981. return nil, fmt.Errorf("unknown Label field %s", name)
  19982. }
  19983. // SetField sets the value of a field with the given name. It returns an error if
  19984. // the field is not defined in the schema, or if the type mismatched the field
  19985. // type.
  19986. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  19987. switch name {
  19988. case label.FieldCreatedAt:
  19989. v, ok := value.(time.Time)
  19990. if !ok {
  19991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19992. }
  19993. m.SetCreatedAt(v)
  19994. return nil
  19995. case label.FieldUpdatedAt:
  19996. v, ok := value.(time.Time)
  19997. if !ok {
  19998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19999. }
  20000. m.SetUpdatedAt(v)
  20001. return nil
  20002. case label.FieldStatus:
  20003. v, ok := value.(uint8)
  20004. if !ok {
  20005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20006. }
  20007. m.SetStatus(v)
  20008. return nil
  20009. case label.FieldType:
  20010. v, ok := value.(int)
  20011. if !ok {
  20012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20013. }
  20014. m.SetType(v)
  20015. return nil
  20016. case label.FieldName:
  20017. v, ok := value.(string)
  20018. if !ok {
  20019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20020. }
  20021. m.SetName(v)
  20022. return nil
  20023. case label.FieldFrom:
  20024. v, ok := value.(int)
  20025. if !ok {
  20026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20027. }
  20028. m.SetFrom(v)
  20029. return nil
  20030. case label.FieldMode:
  20031. v, ok := value.(int)
  20032. if !ok {
  20033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20034. }
  20035. m.SetMode(v)
  20036. return nil
  20037. case label.FieldConditions:
  20038. v, ok := value.(string)
  20039. if !ok {
  20040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20041. }
  20042. m.SetConditions(v)
  20043. return nil
  20044. case label.FieldOrganizationID:
  20045. v, ok := value.(uint64)
  20046. if !ok {
  20047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20048. }
  20049. m.SetOrganizationID(v)
  20050. return nil
  20051. }
  20052. return fmt.Errorf("unknown Label field %s", name)
  20053. }
  20054. // AddedFields returns all numeric fields that were incremented/decremented during
  20055. // this mutation.
  20056. func (m *LabelMutation) AddedFields() []string {
  20057. var fields []string
  20058. if m.addstatus != nil {
  20059. fields = append(fields, label.FieldStatus)
  20060. }
  20061. if m.add_type != nil {
  20062. fields = append(fields, label.FieldType)
  20063. }
  20064. if m.addfrom != nil {
  20065. fields = append(fields, label.FieldFrom)
  20066. }
  20067. if m.addmode != nil {
  20068. fields = append(fields, label.FieldMode)
  20069. }
  20070. if m.addorganization_id != nil {
  20071. fields = append(fields, label.FieldOrganizationID)
  20072. }
  20073. return fields
  20074. }
  20075. // AddedField returns the numeric value that was incremented/decremented on a field
  20076. // with the given name. The second boolean return value indicates that this field
  20077. // was not set, or was not defined in the schema.
  20078. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  20079. switch name {
  20080. case label.FieldStatus:
  20081. return m.AddedStatus()
  20082. case label.FieldType:
  20083. return m.AddedType()
  20084. case label.FieldFrom:
  20085. return m.AddedFrom()
  20086. case label.FieldMode:
  20087. return m.AddedMode()
  20088. case label.FieldOrganizationID:
  20089. return m.AddedOrganizationID()
  20090. }
  20091. return nil, false
  20092. }
  20093. // AddField adds the value to the field with the given name. It returns an error if
  20094. // the field is not defined in the schema, or if the type mismatched the field
  20095. // type.
  20096. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  20097. switch name {
  20098. case label.FieldStatus:
  20099. v, ok := value.(int8)
  20100. if !ok {
  20101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20102. }
  20103. m.AddStatus(v)
  20104. return nil
  20105. case label.FieldType:
  20106. v, ok := value.(int)
  20107. if !ok {
  20108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20109. }
  20110. m.AddType(v)
  20111. return nil
  20112. case label.FieldFrom:
  20113. v, ok := value.(int)
  20114. if !ok {
  20115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20116. }
  20117. m.AddFrom(v)
  20118. return nil
  20119. case label.FieldMode:
  20120. v, ok := value.(int)
  20121. if !ok {
  20122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20123. }
  20124. m.AddMode(v)
  20125. return nil
  20126. case label.FieldOrganizationID:
  20127. v, ok := value.(int64)
  20128. if !ok {
  20129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20130. }
  20131. m.AddOrganizationID(v)
  20132. return nil
  20133. }
  20134. return fmt.Errorf("unknown Label numeric field %s", name)
  20135. }
  20136. // ClearedFields returns all nullable fields that were cleared during this
  20137. // mutation.
  20138. func (m *LabelMutation) ClearedFields() []string {
  20139. var fields []string
  20140. if m.FieldCleared(label.FieldStatus) {
  20141. fields = append(fields, label.FieldStatus)
  20142. }
  20143. if m.FieldCleared(label.FieldConditions) {
  20144. fields = append(fields, label.FieldConditions)
  20145. }
  20146. if m.FieldCleared(label.FieldOrganizationID) {
  20147. fields = append(fields, label.FieldOrganizationID)
  20148. }
  20149. return fields
  20150. }
  20151. // FieldCleared returns a boolean indicating if a field with the given name was
  20152. // cleared in this mutation.
  20153. func (m *LabelMutation) FieldCleared(name string) bool {
  20154. _, ok := m.clearedFields[name]
  20155. return ok
  20156. }
  20157. // ClearField clears the value of the field with the given name. It returns an
  20158. // error if the field is not defined in the schema.
  20159. func (m *LabelMutation) ClearField(name string) error {
  20160. switch name {
  20161. case label.FieldStatus:
  20162. m.ClearStatus()
  20163. return nil
  20164. case label.FieldConditions:
  20165. m.ClearConditions()
  20166. return nil
  20167. case label.FieldOrganizationID:
  20168. m.ClearOrganizationID()
  20169. return nil
  20170. }
  20171. return fmt.Errorf("unknown Label nullable field %s", name)
  20172. }
  20173. // ResetField resets all changes in the mutation for the field with the given name.
  20174. // It returns an error if the field is not defined in the schema.
  20175. func (m *LabelMutation) ResetField(name string) error {
  20176. switch name {
  20177. case label.FieldCreatedAt:
  20178. m.ResetCreatedAt()
  20179. return nil
  20180. case label.FieldUpdatedAt:
  20181. m.ResetUpdatedAt()
  20182. return nil
  20183. case label.FieldStatus:
  20184. m.ResetStatus()
  20185. return nil
  20186. case label.FieldType:
  20187. m.ResetType()
  20188. return nil
  20189. case label.FieldName:
  20190. m.ResetName()
  20191. return nil
  20192. case label.FieldFrom:
  20193. m.ResetFrom()
  20194. return nil
  20195. case label.FieldMode:
  20196. m.ResetMode()
  20197. return nil
  20198. case label.FieldConditions:
  20199. m.ResetConditions()
  20200. return nil
  20201. case label.FieldOrganizationID:
  20202. m.ResetOrganizationID()
  20203. return nil
  20204. }
  20205. return fmt.Errorf("unknown Label field %s", name)
  20206. }
  20207. // AddedEdges returns all edge names that were set/added in this mutation.
  20208. func (m *LabelMutation) AddedEdges() []string {
  20209. edges := make([]string, 0, 1)
  20210. if m.label_relationships != nil {
  20211. edges = append(edges, label.EdgeLabelRelationships)
  20212. }
  20213. return edges
  20214. }
  20215. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20216. // name in this mutation.
  20217. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  20218. switch name {
  20219. case label.EdgeLabelRelationships:
  20220. ids := make([]ent.Value, 0, len(m.label_relationships))
  20221. for id := range m.label_relationships {
  20222. ids = append(ids, id)
  20223. }
  20224. return ids
  20225. }
  20226. return nil
  20227. }
  20228. // RemovedEdges returns all edge names that were removed in this mutation.
  20229. func (m *LabelMutation) RemovedEdges() []string {
  20230. edges := make([]string, 0, 1)
  20231. if m.removedlabel_relationships != nil {
  20232. edges = append(edges, label.EdgeLabelRelationships)
  20233. }
  20234. return edges
  20235. }
  20236. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20237. // the given name in this mutation.
  20238. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  20239. switch name {
  20240. case label.EdgeLabelRelationships:
  20241. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  20242. for id := range m.removedlabel_relationships {
  20243. ids = append(ids, id)
  20244. }
  20245. return ids
  20246. }
  20247. return nil
  20248. }
  20249. // ClearedEdges returns all edge names that were cleared in this mutation.
  20250. func (m *LabelMutation) ClearedEdges() []string {
  20251. edges := make([]string, 0, 1)
  20252. if m.clearedlabel_relationships {
  20253. edges = append(edges, label.EdgeLabelRelationships)
  20254. }
  20255. return edges
  20256. }
  20257. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20258. // was cleared in this mutation.
  20259. func (m *LabelMutation) EdgeCleared(name string) bool {
  20260. switch name {
  20261. case label.EdgeLabelRelationships:
  20262. return m.clearedlabel_relationships
  20263. }
  20264. return false
  20265. }
  20266. // ClearEdge clears the value of the edge with the given name. It returns an error
  20267. // if that edge is not defined in the schema.
  20268. func (m *LabelMutation) ClearEdge(name string) error {
  20269. switch name {
  20270. }
  20271. return fmt.Errorf("unknown Label unique edge %s", name)
  20272. }
  20273. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20274. // It returns an error if the edge is not defined in the schema.
  20275. func (m *LabelMutation) ResetEdge(name string) error {
  20276. switch name {
  20277. case label.EdgeLabelRelationships:
  20278. m.ResetLabelRelationships()
  20279. return nil
  20280. }
  20281. return fmt.Errorf("unknown Label edge %s", name)
  20282. }
  20283. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  20284. type LabelRelationshipMutation struct {
  20285. config
  20286. op Op
  20287. typ string
  20288. id *uint64
  20289. created_at *time.Time
  20290. updated_at *time.Time
  20291. status *uint8
  20292. addstatus *int8
  20293. organization_id *uint64
  20294. addorganization_id *int64
  20295. clearedFields map[string]struct{}
  20296. contacts *uint64
  20297. clearedcontacts bool
  20298. labels *uint64
  20299. clearedlabels bool
  20300. done bool
  20301. oldValue func(context.Context) (*LabelRelationship, error)
  20302. predicates []predicate.LabelRelationship
  20303. }
  20304. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  20305. // labelrelationshipOption allows management of the mutation configuration using functional options.
  20306. type labelrelationshipOption func(*LabelRelationshipMutation)
  20307. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  20308. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  20309. m := &LabelRelationshipMutation{
  20310. config: c,
  20311. op: op,
  20312. typ: TypeLabelRelationship,
  20313. clearedFields: make(map[string]struct{}),
  20314. }
  20315. for _, opt := range opts {
  20316. opt(m)
  20317. }
  20318. return m
  20319. }
  20320. // withLabelRelationshipID sets the ID field of the mutation.
  20321. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  20322. return func(m *LabelRelationshipMutation) {
  20323. var (
  20324. err error
  20325. once sync.Once
  20326. value *LabelRelationship
  20327. )
  20328. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  20329. once.Do(func() {
  20330. if m.done {
  20331. err = errors.New("querying old values post mutation is not allowed")
  20332. } else {
  20333. value, err = m.Client().LabelRelationship.Get(ctx, id)
  20334. }
  20335. })
  20336. return value, err
  20337. }
  20338. m.id = &id
  20339. }
  20340. }
  20341. // withLabelRelationship sets the old LabelRelationship of the mutation.
  20342. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  20343. return func(m *LabelRelationshipMutation) {
  20344. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  20345. return node, nil
  20346. }
  20347. m.id = &node.ID
  20348. }
  20349. }
  20350. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20351. // executed in a transaction (ent.Tx), a transactional client is returned.
  20352. func (m LabelRelationshipMutation) Client() *Client {
  20353. client := &Client{config: m.config}
  20354. client.init()
  20355. return client
  20356. }
  20357. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20358. // it returns an error otherwise.
  20359. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  20360. if _, ok := m.driver.(*txDriver); !ok {
  20361. return nil, errors.New("ent: mutation is not running in a transaction")
  20362. }
  20363. tx := &Tx{config: m.config}
  20364. tx.init()
  20365. return tx, nil
  20366. }
  20367. // SetID sets the value of the id field. Note that this
  20368. // operation is only accepted on creation of LabelRelationship entities.
  20369. func (m *LabelRelationshipMutation) SetID(id uint64) {
  20370. m.id = &id
  20371. }
  20372. // ID returns the ID value in the mutation. Note that the ID is only available
  20373. // if it was provided to the builder or after it was returned from the database.
  20374. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  20375. if m.id == nil {
  20376. return
  20377. }
  20378. return *m.id, true
  20379. }
  20380. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20381. // That means, if the mutation is applied within a transaction with an isolation level such
  20382. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20383. // or updated by the mutation.
  20384. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  20385. switch {
  20386. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20387. id, exists := m.ID()
  20388. if exists {
  20389. return []uint64{id}, nil
  20390. }
  20391. fallthrough
  20392. case m.op.Is(OpUpdate | OpDelete):
  20393. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  20394. default:
  20395. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20396. }
  20397. }
  20398. // SetCreatedAt sets the "created_at" field.
  20399. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  20400. m.created_at = &t
  20401. }
  20402. // CreatedAt returns the value of the "created_at" field in the mutation.
  20403. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  20404. v := m.created_at
  20405. if v == nil {
  20406. return
  20407. }
  20408. return *v, true
  20409. }
  20410. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  20411. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20413. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20414. if !m.op.Is(OpUpdateOne) {
  20415. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20416. }
  20417. if m.id == nil || m.oldValue == nil {
  20418. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20419. }
  20420. oldValue, err := m.oldValue(ctx)
  20421. if err != nil {
  20422. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20423. }
  20424. return oldValue.CreatedAt, nil
  20425. }
  20426. // ResetCreatedAt resets all changes to the "created_at" field.
  20427. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  20428. m.created_at = nil
  20429. }
  20430. // SetUpdatedAt sets the "updated_at" field.
  20431. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  20432. m.updated_at = &t
  20433. }
  20434. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20435. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  20436. v := m.updated_at
  20437. if v == nil {
  20438. return
  20439. }
  20440. return *v, true
  20441. }
  20442. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  20443. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20445. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20446. if !m.op.Is(OpUpdateOne) {
  20447. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20448. }
  20449. if m.id == nil || m.oldValue == nil {
  20450. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20451. }
  20452. oldValue, err := m.oldValue(ctx)
  20453. if err != nil {
  20454. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20455. }
  20456. return oldValue.UpdatedAt, nil
  20457. }
  20458. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20459. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  20460. m.updated_at = nil
  20461. }
  20462. // SetStatus sets the "status" field.
  20463. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  20464. m.status = &u
  20465. m.addstatus = nil
  20466. }
  20467. // Status returns the value of the "status" field in the mutation.
  20468. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  20469. v := m.status
  20470. if v == nil {
  20471. return
  20472. }
  20473. return *v, true
  20474. }
  20475. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  20476. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20478. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20479. if !m.op.Is(OpUpdateOne) {
  20480. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20481. }
  20482. if m.id == nil || m.oldValue == nil {
  20483. return v, errors.New("OldStatus requires an ID field in the mutation")
  20484. }
  20485. oldValue, err := m.oldValue(ctx)
  20486. if err != nil {
  20487. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20488. }
  20489. return oldValue.Status, nil
  20490. }
  20491. // AddStatus adds u to the "status" field.
  20492. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  20493. if m.addstatus != nil {
  20494. *m.addstatus += u
  20495. } else {
  20496. m.addstatus = &u
  20497. }
  20498. }
  20499. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20500. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  20501. v := m.addstatus
  20502. if v == nil {
  20503. return
  20504. }
  20505. return *v, true
  20506. }
  20507. // ClearStatus clears the value of the "status" field.
  20508. func (m *LabelRelationshipMutation) ClearStatus() {
  20509. m.status = nil
  20510. m.addstatus = nil
  20511. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  20512. }
  20513. // StatusCleared returns if the "status" field was cleared in this mutation.
  20514. func (m *LabelRelationshipMutation) StatusCleared() bool {
  20515. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  20516. return ok
  20517. }
  20518. // ResetStatus resets all changes to the "status" field.
  20519. func (m *LabelRelationshipMutation) ResetStatus() {
  20520. m.status = nil
  20521. m.addstatus = nil
  20522. delete(m.clearedFields, labelrelationship.FieldStatus)
  20523. }
  20524. // SetLabelID sets the "label_id" field.
  20525. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  20526. m.labels = &u
  20527. }
  20528. // LabelID returns the value of the "label_id" field in the mutation.
  20529. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  20530. v := m.labels
  20531. if v == nil {
  20532. return
  20533. }
  20534. return *v, true
  20535. }
  20536. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  20537. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20539. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  20540. if !m.op.Is(OpUpdateOne) {
  20541. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  20542. }
  20543. if m.id == nil || m.oldValue == nil {
  20544. return v, errors.New("OldLabelID requires an ID field in the mutation")
  20545. }
  20546. oldValue, err := m.oldValue(ctx)
  20547. if err != nil {
  20548. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  20549. }
  20550. return oldValue.LabelID, nil
  20551. }
  20552. // ResetLabelID resets all changes to the "label_id" field.
  20553. func (m *LabelRelationshipMutation) ResetLabelID() {
  20554. m.labels = nil
  20555. }
  20556. // SetContactID sets the "contact_id" field.
  20557. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  20558. m.contacts = &u
  20559. }
  20560. // ContactID returns the value of the "contact_id" field in the mutation.
  20561. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  20562. v := m.contacts
  20563. if v == nil {
  20564. return
  20565. }
  20566. return *v, true
  20567. }
  20568. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  20569. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20571. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20572. if !m.op.Is(OpUpdateOne) {
  20573. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20574. }
  20575. if m.id == nil || m.oldValue == nil {
  20576. return v, errors.New("OldContactID requires an ID field in the mutation")
  20577. }
  20578. oldValue, err := m.oldValue(ctx)
  20579. if err != nil {
  20580. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  20581. }
  20582. return oldValue.ContactID, nil
  20583. }
  20584. // ResetContactID resets all changes to the "contact_id" field.
  20585. func (m *LabelRelationshipMutation) ResetContactID() {
  20586. m.contacts = nil
  20587. }
  20588. // SetOrganizationID sets the "organization_id" field.
  20589. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  20590. m.organization_id = &u
  20591. m.addorganization_id = nil
  20592. }
  20593. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20594. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  20595. v := m.organization_id
  20596. if v == nil {
  20597. return
  20598. }
  20599. return *v, true
  20600. }
  20601. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  20602. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  20603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20604. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20605. if !m.op.Is(OpUpdateOne) {
  20606. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20607. }
  20608. if m.id == nil || m.oldValue == nil {
  20609. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20610. }
  20611. oldValue, err := m.oldValue(ctx)
  20612. if err != nil {
  20613. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20614. }
  20615. return oldValue.OrganizationID, nil
  20616. }
  20617. // AddOrganizationID adds u to the "organization_id" field.
  20618. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  20619. if m.addorganization_id != nil {
  20620. *m.addorganization_id += u
  20621. } else {
  20622. m.addorganization_id = &u
  20623. }
  20624. }
  20625. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20626. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  20627. v := m.addorganization_id
  20628. if v == nil {
  20629. return
  20630. }
  20631. return *v, true
  20632. }
  20633. // ClearOrganizationID clears the value of the "organization_id" field.
  20634. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  20635. m.organization_id = nil
  20636. m.addorganization_id = nil
  20637. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  20638. }
  20639. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20640. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  20641. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  20642. return ok
  20643. }
  20644. // ResetOrganizationID resets all changes to the "organization_id" field.
  20645. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  20646. m.organization_id = nil
  20647. m.addorganization_id = nil
  20648. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  20649. }
  20650. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  20651. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  20652. m.contacts = &id
  20653. }
  20654. // ClearContacts clears the "contacts" edge to the Contact entity.
  20655. func (m *LabelRelationshipMutation) ClearContacts() {
  20656. m.clearedcontacts = true
  20657. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  20658. }
  20659. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  20660. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  20661. return m.clearedcontacts
  20662. }
  20663. // ContactsID returns the "contacts" edge ID in the mutation.
  20664. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  20665. if m.contacts != nil {
  20666. return *m.contacts, true
  20667. }
  20668. return
  20669. }
  20670. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  20671. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20672. // ContactsID instead. It exists only for internal usage by the builders.
  20673. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  20674. if id := m.contacts; id != nil {
  20675. ids = append(ids, *id)
  20676. }
  20677. return
  20678. }
  20679. // ResetContacts resets all changes to the "contacts" edge.
  20680. func (m *LabelRelationshipMutation) ResetContacts() {
  20681. m.contacts = nil
  20682. m.clearedcontacts = false
  20683. }
  20684. // SetLabelsID sets the "labels" edge to the Label entity by id.
  20685. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  20686. m.labels = &id
  20687. }
  20688. // ClearLabels clears the "labels" edge to the Label entity.
  20689. func (m *LabelRelationshipMutation) ClearLabels() {
  20690. m.clearedlabels = true
  20691. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  20692. }
  20693. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  20694. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  20695. return m.clearedlabels
  20696. }
  20697. // LabelsID returns the "labels" edge ID in the mutation.
  20698. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  20699. if m.labels != nil {
  20700. return *m.labels, true
  20701. }
  20702. return
  20703. }
  20704. // LabelsIDs returns the "labels" edge IDs in the mutation.
  20705. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20706. // LabelsID instead. It exists only for internal usage by the builders.
  20707. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  20708. if id := m.labels; id != nil {
  20709. ids = append(ids, *id)
  20710. }
  20711. return
  20712. }
  20713. // ResetLabels resets all changes to the "labels" edge.
  20714. func (m *LabelRelationshipMutation) ResetLabels() {
  20715. m.labels = nil
  20716. m.clearedlabels = false
  20717. }
  20718. // Where appends a list predicates to the LabelRelationshipMutation builder.
  20719. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  20720. m.predicates = append(m.predicates, ps...)
  20721. }
  20722. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  20723. // users can use type-assertion to append predicates that do not depend on any generated package.
  20724. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  20725. p := make([]predicate.LabelRelationship, len(ps))
  20726. for i := range ps {
  20727. p[i] = ps[i]
  20728. }
  20729. m.Where(p...)
  20730. }
  20731. // Op returns the operation name.
  20732. func (m *LabelRelationshipMutation) Op() Op {
  20733. return m.op
  20734. }
  20735. // SetOp allows setting the mutation operation.
  20736. func (m *LabelRelationshipMutation) SetOp(op Op) {
  20737. m.op = op
  20738. }
  20739. // Type returns the node type of this mutation (LabelRelationship).
  20740. func (m *LabelRelationshipMutation) Type() string {
  20741. return m.typ
  20742. }
  20743. // Fields returns all fields that were changed during this mutation. Note that in
  20744. // order to get all numeric fields that were incremented/decremented, call
  20745. // AddedFields().
  20746. func (m *LabelRelationshipMutation) Fields() []string {
  20747. fields := make([]string, 0, 6)
  20748. if m.created_at != nil {
  20749. fields = append(fields, labelrelationship.FieldCreatedAt)
  20750. }
  20751. if m.updated_at != nil {
  20752. fields = append(fields, labelrelationship.FieldUpdatedAt)
  20753. }
  20754. if m.status != nil {
  20755. fields = append(fields, labelrelationship.FieldStatus)
  20756. }
  20757. if m.labels != nil {
  20758. fields = append(fields, labelrelationship.FieldLabelID)
  20759. }
  20760. if m.contacts != nil {
  20761. fields = append(fields, labelrelationship.FieldContactID)
  20762. }
  20763. if m.organization_id != nil {
  20764. fields = append(fields, labelrelationship.FieldOrganizationID)
  20765. }
  20766. return fields
  20767. }
  20768. // Field returns the value of a field with the given name. The second boolean
  20769. // return value indicates that this field was not set, or was not defined in the
  20770. // schema.
  20771. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  20772. switch name {
  20773. case labelrelationship.FieldCreatedAt:
  20774. return m.CreatedAt()
  20775. case labelrelationship.FieldUpdatedAt:
  20776. return m.UpdatedAt()
  20777. case labelrelationship.FieldStatus:
  20778. return m.Status()
  20779. case labelrelationship.FieldLabelID:
  20780. return m.LabelID()
  20781. case labelrelationship.FieldContactID:
  20782. return m.ContactID()
  20783. case labelrelationship.FieldOrganizationID:
  20784. return m.OrganizationID()
  20785. }
  20786. return nil, false
  20787. }
  20788. // OldField returns the old value of the field from the database. An error is
  20789. // returned if the mutation operation is not UpdateOne, or the query to the
  20790. // database failed.
  20791. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20792. switch name {
  20793. case labelrelationship.FieldCreatedAt:
  20794. return m.OldCreatedAt(ctx)
  20795. case labelrelationship.FieldUpdatedAt:
  20796. return m.OldUpdatedAt(ctx)
  20797. case labelrelationship.FieldStatus:
  20798. return m.OldStatus(ctx)
  20799. case labelrelationship.FieldLabelID:
  20800. return m.OldLabelID(ctx)
  20801. case labelrelationship.FieldContactID:
  20802. return m.OldContactID(ctx)
  20803. case labelrelationship.FieldOrganizationID:
  20804. return m.OldOrganizationID(ctx)
  20805. }
  20806. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  20807. }
  20808. // SetField sets the value of a field with the given name. It returns an error if
  20809. // the field is not defined in the schema, or if the type mismatched the field
  20810. // type.
  20811. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  20812. switch name {
  20813. case labelrelationship.FieldCreatedAt:
  20814. v, ok := value.(time.Time)
  20815. if !ok {
  20816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20817. }
  20818. m.SetCreatedAt(v)
  20819. return nil
  20820. case labelrelationship.FieldUpdatedAt:
  20821. v, ok := value.(time.Time)
  20822. if !ok {
  20823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20824. }
  20825. m.SetUpdatedAt(v)
  20826. return nil
  20827. case labelrelationship.FieldStatus:
  20828. v, ok := value.(uint8)
  20829. if !ok {
  20830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20831. }
  20832. m.SetStatus(v)
  20833. return nil
  20834. case labelrelationship.FieldLabelID:
  20835. v, ok := value.(uint64)
  20836. if !ok {
  20837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20838. }
  20839. m.SetLabelID(v)
  20840. return nil
  20841. case labelrelationship.FieldContactID:
  20842. v, ok := value.(uint64)
  20843. if !ok {
  20844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20845. }
  20846. m.SetContactID(v)
  20847. return nil
  20848. case labelrelationship.FieldOrganizationID:
  20849. v, ok := value.(uint64)
  20850. if !ok {
  20851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20852. }
  20853. m.SetOrganizationID(v)
  20854. return nil
  20855. }
  20856. return fmt.Errorf("unknown LabelRelationship field %s", name)
  20857. }
  20858. // AddedFields returns all numeric fields that were incremented/decremented during
  20859. // this mutation.
  20860. func (m *LabelRelationshipMutation) AddedFields() []string {
  20861. var fields []string
  20862. if m.addstatus != nil {
  20863. fields = append(fields, labelrelationship.FieldStatus)
  20864. }
  20865. if m.addorganization_id != nil {
  20866. fields = append(fields, labelrelationship.FieldOrganizationID)
  20867. }
  20868. return fields
  20869. }
  20870. // AddedField returns the numeric value that was incremented/decremented on a field
  20871. // with the given name. The second boolean return value indicates that this field
  20872. // was not set, or was not defined in the schema.
  20873. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  20874. switch name {
  20875. case labelrelationship.FieldStatus:
  20876. return m.AddedStatus()
  20877. case labelrelationship.FieldOrganizationID:
  20878. return m.AddedOrganizationID()
  20879. }
  20880. return nil, false
  20881. }
  20882. // AddField adds the value to the field with the given name. It returns an error if
  20883. // the field is not defined in the schema, or if the type mismatched the field
  20884. // type.
  20885. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  20886. switch name {
  20887. case labelrelationship.FieldStatus:
  20888. v, ok := value.(int8)
  20889. if !ok {
  20890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20891. }
  20892. m.AddStatus(v)
  20893. return nil
  20894. case labelrelationship.FieldOrganizationID:
  20895. v, ok := value.(int64)
  20896. if !ok {
  20897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20898. }
  20899. m.AddOrganizationID(v)
  20900. return nil
  20901. }
  20902. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  20903. }
  20904. // ClearedFields returns all nullable fields that were cleared during this
  20905. // mutation.
  20906. func (m *LabelRelationshipMutation) ClearedFields() []string {
  20907. var fields []string
  20908. if m.FieldCleared(labelrelationship.FieldStatus) {
  20909. fields = append(fields, labelrelationship.FieldStatus)
  20910. }
  20911. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  20912. fields = append(fields, labelrelationship.FieldOrganizationID)
  20913. }
  20914. return fields
  20915. }
  20916. // FieldCleared returns a boolean indicating if a field with the given name was
  20917. // cleared in this mutation.
  20918. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  20919. _, ok := m.clearedFields[name]
  20920. return ok
  20921. }
  20922. // ClearField clears the value of the field with the given name. It returns an
  20923. // error if the field is not defined in the schema.
  20924. func (m *LabelRelationshipMutation) ClearField(name string) error {
  20925. switch name {
  20926. case labelrelationship.FieldStatus:
  20927. m.ClearStatus()
  20928. return nil
  20929. case labelrelationship.FieldOrganizationID:
  20930. m.ClearOrganizationID()
  20931. return nil
  20932. }
  20933. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  20934. }
  20935. // ResetField resets all changes in the mutation for the field with the given name.
  20936. // It returns an error if the field is not defined in the schema.
  20937. func (m *LabelRelationshipMutation) ResetField(name string) error {
  20938. switch name {
  20939. case labelrelationship.FieldCreatedAt:
  20940. m.ResetCreatedAt()
  20941. return nil
  20942. case labelrelationship.FieldUpdatedAt:
  20943. m.ResetUpdatedAt()
  20944. return nil
  20945. case labelrelationship.FieldStatus:
  20946. m.ResetStatus()
  20947. return nil
  20948. case labelrelationship.FieldLabelID:
  20949. m.ResetLabelID()
  20950. return nil
  20951. case labelrelationship.FieldContactID:
  20952. m.ResetContactID()
  20953. return nil
  20954. case labelrelationship.FieldOrganizationID:
  20955. m.ResetOrganizationID()
  20956. return nil
  20957. }
  20958. return fmt.Errorf("unknown LabelRelationship field %s", name)
  20959. }
  20960. // AddedEdges returns all edge names that were set/added in this mutation.
  20961. func (m *LabelRelationshipMutation) AddedEdges() []string {
  20962. edges := make([]string, 0, 2)
  20963. if m.contacts != nil {
  20964. edges = append(edges, labelrelationship.EdgeContacts)
  20965. }
  20966. if m.labels != nil {
  20967. edges = append(edges, labelrelationship.EdgeLabels)
  20968. }
  20969. return edges
  20970. }
  20971. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20972. // name in this mutation.
  20973. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  20974. switch name {
  20975. case labelrelationship.EdgeContacts:
  20976. if id := m.contacts; id != nil {
  20977. return []ent.Value{*id}
  20978. }
  20979. case labelrelationship.EdgeLabels:
  20980. if id := m.labels; id != nil {
  20981. return []ent.Value{*id}
  20982. }
  20983. }
  20984. return nil
  20985. }
  20986. // RemovedEdges returns all edge names that were removed in this mutation.
  20987. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  20988. edges := make([]string, 0, 2)
  20989. return edges
  20990. }
  20991. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20992. // the given name in this mutation.
  20993. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  20994. return nil
  20995. }
  20996. // ClearedEdges returns all edge names that were cleared in this mutation.
  20997. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  20998. edges := make([]string, 0, 2)
  20999. if m.clearedcontacts {
  21000. edges = append(edges, labelrelationship.EdgeContacts)
  21001. }
  21002. if m.clearedlabels {
  21003. edges = append(edges, labelrelationship.EdgeLabels)
  21004. }
  21005. return edges
  21006. }
  21007. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21008. // was cleared in this mutation.
  21009. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  21010. switch name {
  21011. case labelrelationship.EdgeContacts:
  21012. return m.clearedcontacts
  21013. case labelrelationship.EdgeLabels:
  21014. return m.clearedlabels
  21015. }
  21016. return false
  21017. }
  21018. // ClearEdge clears the value of the edge with the given name. It returns an error
  21019. // if that edge is not defined in the schema.
  21020. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  21021. switch name {
  21022. case labelrelationship.EdgeContacts:
  21023. m.ClearContacts()
  21024. return nil
  21025. case labelrelationship.EdgeLabels:
  21026. m.ClearLabels()
  21027. return nil
  21028. }
  21029. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  21030. }
  21031. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21032. // It returns an error if the edge is not defined in the schema.
  21033. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  21034. switch name {
  21035. case labelrelationship.EdgeContacts:
  21036. m.ResetContacts()
  21037. return nil
  21038. case labelrelationship.EdgeLabels:
  21039. m.ResetLabels()
  21040. return nil
  21041. }
  21042. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  21043. }
  21044. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  21045. type LabelTaggingMutation struct {
  21046. config
  21047. op Op
  21048. typ string
  21049. id *uint64
  21050. created_at *time.Time
  21051. updated_at *time.Time
  21052. status *uint8
  21053. addstatus *int8
  21054. deleted_at *time.Time
  21055. organization_id *uint64
  21056. addorganization_id *int64
  21057. _type *int
  21058. add_type *int
  21059. conditions *string
  21060. action_label_add *[]uint64
  21061. appendaction_label_add []uint64
  21062. action_label_del *[]uint64
  21063. appendaction_label_del []uint64
  21064. clearedFields map[string]struct{}
  21065. done bool
  21066. oldValue func(context.Context) (*LabelTagging, error)
  21067. predicates []predicate.LabelTagging
  21068. }
  21069. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  21070. // labeltaggingOption allows management of the mutation configuration using functional options.
  21071. type labeltaggingOption func(*LabelTaggingMutation)
  21072. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  21073. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  21074. m := &LabelTaggingMutation{
  21075. config: c,
  21076. op: op,
  21077. typ: TypeLabelTagging,
  21078. clearedFields: make(map[string]struct{}),
  21079. }
  21080. for _, opt := range opts {
  21081. opt(m)
  21082. }
  21083. return m
  21084. }
  21085. // withLabelTaggingID sets the ID field of the mutation.
  21086. func withLabelTaggingID(id uint64) labeltaggingOption {
  21087. return func(m *LabelTaggingMutation) {
  21088. var (
  21089. err error
  21090. once sync.Once
  21091. value *LabelTagging
  21092. )
  21093. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  21094. once.Do(func() {
  21095. if m.done {
  21096. err = errors.New("querying old values post mutation is not allowed")
  21097. } else {
  21098. value, err = m.Client().LabelTagging.Get(ctx, id)
  21099. }
  21100. })
  21101. return value, err
  21102. }
  21103. m.id = &id
  21104. }
  21105. }
  21106. // withLabelTagging sets the old LabelTagging of the mutation.
  21107. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  21108. return func(m *LabelTaggingMutation) {
  21109. m.oldValue = func(context.Context) (*LabelTagging, error) {
  21110. return node, nil
  21111. }
  21112. m.id = &node.ID
  21113. }
  21114. }
  21115. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21116. // executed in a transaction (ent.Tx), a transactional client is returned.
  21117. func (m LabelTaggingMutation) Client() *Client {
  21118. client := &Client{config: m.config}
  21119. client.init()
  21120. return client
  21121. }
  21122. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21123. // it returns an error otherwise.
  21124. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  21125. if _, ok := m.driver.(*txDriver); !ok {
  21126. return nil, errors.New("ent: mutation is not running in a transaction")
  21127. }
  21128. tx := &Tx{config: m.config}
  21129. tx.init()
  21130. return tx, nil
  21131. }
  21132. // SetID sets the value of the id field. Note that this
  21133. // operation is only accepted on creation of LabelTagging entities.
  21134. func (m *LabelTaggingMutation) SetID(id uint64) {
  21135. m.id = &id
  21136. }
  21137. // ID returns the ID value in the mutation. Note that the ID is only available
  21138. // if it was provided to the builder or after it was returned from the database.
  21139. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  21140. if m.id == nil {
  21141. return
  21142. }
  21143. return *m.id, true
  21144. }
  21145. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21146. // That means, if the mutation is applied within a transaction with an isolation level such
  21147. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21148. // or updated by the mutation.
  21149. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  21150. switch {
  21151. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21152. id, exists := m.ID()
  21153. if exists {
  21154. return []uint64{id}, nil
  21155. }
  21156. fallthrough
  21157. case m.op.Is(OpUpdate | OpDelete):
  21158. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  21159. default:
  21160. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21161. }
  21162. }
  21163. // SetCreatedAt sets the "created_at" field.
  21164. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  21165. m.created_at = &t
  21166. }
  21167. // CreatedAt returns the value of the "created_at" field in the mutation.
  21168. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  21169. v := m.created_at
  21170. if v == nil {
  21171. return
  21172. }
  21173. return *v, true
  21174. }
  21175. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  21176. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21178. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21179. if !m.op.Is(OpUpdateOne) {
  21180. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21181. }
  21182. if m.id == nil || m.oldValue == nil {
  21183. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21184. }
  21185. oldValue, err := m.oldValue(ctx)
  21186. if err != nil {
  21187. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21188. }
  21189. return oldValue.CreatedAt, nil
  21190. }
  21191. // ResetCreatedAt resets all changes to the "created_at" field.
  21192. func (m *LabelTaggingMutation) ResetCreatedAt() {
  21193. m.created_at = nil
  21194. }
  21195. // SetUpdatedAt sets the "updated_at" field.
  21196. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  21197. m.updated_at = &t
  21198. }
  21199. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21200. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  21201. v := m.updated_at
  21202. if v == nil {
  21203. return
  21204. }
  21205. return *v, true
  21206. }
  21207. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  21208. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21210. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21211. if !m.op.Is(OpUpdateOne) {
  21212. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21213. }
  21214. if m.id == nil || m.oldValue == nil {
  21215. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21216. }
  21217. oldValue, err := m.oldValue(ctx)
  21218. if err != nil {
  21219. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21220. }
  21221. return oldValue.UpdatedAt, nil
  21222. }
  21223. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21224. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  21225. m.updated_at = nil
  21226. }
  21227. // SetStatus sets the "status" field.
  21228. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  21229. m.status = &u
  21230. m.addstatus = nil
  21231. }
  21232. // Status returns the value of the "status" field in the mutation.
  21233. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  21234. v := m.status
  21235. if v == nil {
  21236. return
  21237. }
  21238. return *v, true
  21239. }
  21240. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  21241. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21243. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21244. if !m.op.Is(OpUpdateOne) {
  21245. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21246. }
  21247. if m.id == nil || m.oldValue == nil {
  21248. return v, errors.New("OldStatus requires an ID field in the mutation")
  21249. }
  21250. oldValue, err := m.oldValue(ctx)
  21251. if err != nil {
  21252. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21253. }
  21254. return oldValue.Status, nil
  21255. }
  21256. // AddStatus adds u to the "status" field.
  21257. func (m *LabelTaggingMutation) AddStatus(u int8) {
  21258. if m.addstatus != nil {
  21259. *m.addstatus += u
  21260. } else {
  21261. m.addstatus = &u
  21262. }
  21263. }
  21264. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21265. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  21266. v := m.addstatus
  21267. if v == nil {
  21268. return
  21269. }
  21270. return *v, true
  21271. }
  21272. // ClearStatus clears the value of the "status" field.
  21273. func (m *LabelTaggingMutation) ClearStatus() {
  21274. m.status = nil
  21275. m.addstatus = nil
  21276. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  21277. }
  21278. // StatusCleared returns if the "status" field was cleared in this mutation.
  21279. func (m *LabelTaggingMutation) StatusCleared() bool {
  21280. _, ok := m.clearedFields[labeltagging.FieldStatus]
  21281. return ok
  21282. }
  21283. // ResetStatus resets all changes to the "status" field.
  21284. func (m *LabelTaggingMutation) ResetStatus() {
  21285. m.status = nil
  21286. m.addstatus = nil
  21287. delete(m.clearedFields, labeltagging.FieldStatus)
  21288. }
  21289. // SetDeletedAt sets the "deleted_at" field.
  21290. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  21291. m.deleted_at = &t
  21292. }
  21293. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21294. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  21295. v := m.deleted_at
  21296. if v == nil {
  21297. return
  21298. }
  21299. return *v, true
  21300. }
  21301. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  21302. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21304. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21305. if !m.op.Is(OpUpdateOne) {
  21306. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21307. }
  21308. if m.id == nil || m.oldValue == nil {
  21309. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21310. }
  21311. oldValue, err := m.oldValue(ctx)
  21312. if err != nil {
  21313. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21314. }
  21315. return oldValue.DeletedAt, nil
  21316. }
  21317. // ClearDeletedAt clears the value of the "deleted_at" field.
  21318. func (m *LabelTaggingMutation) ClearDeletedAt() {
  21319. m.deleted_at = nil
  21320. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  21321. }
  21322. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21323. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  21324. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  21325. return ok
  21326. }
  21327. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21328. func (m *LabelTaggingMutation) ResetDeletedAt() {
  21329. m.deleted_at = nil
  21330. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  21331. }
  21332. // SetOrganizationID sets the "organization_id" field.
  21333. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  21334. m.organization_id = &u
  21335. m.addorganization_id = nil
  21336. }
  21337. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21338. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  21339. v := m.organization_id
  21340. if v == nil {
  21341. return
  21342. }
  21343. return *v, true
  21344. }
  21345. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  21346. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21348. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21349. if !m.op.Is(OpUpdateOne) {
  21350. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21351. }
  21352. if m.id == nil || m.oldValue == nil {
  21353. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21354. }
  21355. oldValue, err := m.oldValue(ctx)
  21356. if err != nil {
  21357. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21358. }
  21359. return oldValue.OrganizationID, nil
  21360. }
  21361. // AddOrganizationID adds u to the "organization_id" field.
  21362. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  21363. if m.addorganization_id != nil {
  21364. *m.addorganization_id += u
  21365. } else {
  21366. m.addorganization_id = &u
  21367. }
  21368. }
  21369. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21370. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  21371. v := m.addorganization_id
  21372. if v == nil {
  21373. return
  21374. }
  21375. return *v, true
  21376. }
  21377. // ResetOrganizationID resets all changes to the "organization_id" field.
  21378. func (m *LabelTaggingMutation) ResetOrganizationID() {
  21379. m.organization_id = nil
  21380. m.addorganization_id = nil
  21381. }
  21382. // SetType sets the "type" field.
  21383. func (m *LabelTaggingMutation) SetType(i int) {
  21384. m._type = &i
  21385. m.add_type = nil
  21386. }
  21387. // GetType returns the value of the "type" field in the mutation.
  21388. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  21389. v := m._type
  21390. if v == nil {
  21391. return
  21392. }
  21393. return *v, true
  21394. }
  21395. // OldType returns the old "type" field's value of the LabelTagging entity.
  21396. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21398. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  21399. if !m.op.Is(OpUpdateOne) {
  21400. return v, errors.New("OldType is only allowed on UpdateOne operations")
  21401. }
  21402. if m.id == nil || m.oldValue == nil {
  21403. return v, errors.New("OldType requires an ID field in the mutation")
  21404. }
  21405. oldValue, err := m.oldValue(ctx)
  21406. if err != nil {
  21407. return v, fmt.Errorf("querying old value for OldType: %w", err)
  21408. }
  21409. return oldValue.Type, nil
  21410. }
  21411. // AddType adds i to the "type" field.
  21412. func (m *LabelTaggingMutation) AddType(i int) {
  21413. if m.add_type != nil {
  21414. *m.add_type += i
  21415. } else {
  21416. m.add_type = &i
  21417. }
  21418. }
  21419. // AddedType returns the value that was added to the "type" field in this mutation.
  21420. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  21421. v := m.add_type
  21422. if v == nil {
  21423. return
  21424. }
  21425. return *v, true
  21426. }
  21427. // ResetType resets all changes to the "type" field.
  21428. func (m *LabelTaggingMutation) ResetType() {
  21429. m._type = nil
  21430. m.add_type = nil
  21431. }
  21432. // SetConditions sets the "conditions" field.
  21433. func (m *LabelTaggingMutation) SetConditions(s string) {
  21434. m.conditions = &s
  21435. }
  21436. // Conditions returns the value of the "conditions" field in the mutation.
  21437. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  21438. v := m.conditions
  21439. if v == nil {
  21440. return
  21441. }
  21442. return *v, true
  21443. }
  21444. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  21445. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21447. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  21448. if !m.op.Is(OpUpdateOne) {
  21449. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  21450. }
  21451. if m.id == nil || m.oldValue == nil {
  21452. return v, errors.New("OldConditions requires an ID field in the mutation")
  21453. }
  21454. oldValue, err := m.oldValue(ctx)
  21455. if err != nil {
  21456. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  21457. }
  21458. return oldValue.Conditions, nil
  21459. }
  21460. // ResetConditions resets all changes to the "conditions" field.
  21461. func (m *LabelTaggingMutation) ResetConditions() {
  21462. m.conditions = nil
  21463. }
  21464. // SetActionLabelAdd sets the "action_label_add" field.
  21465. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  21466. m.action_label_add = &u
  21467. m.appendaction_label_add = nil
  21468. }
  21469. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21470. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21471. v := m.action_label_add
  21472. if v == nil {
  21473. return
  21474. }
  21475. return *v, true
  21476. }
  21477. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  21478. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21480. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21481. if !m.op.Is(OpUpdateOne) {
  21482. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21483. }
  21484. if m.id == nil || m.oldValue == nil {
  21485. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21486. }
  21487. oldValue, err := m.oldValue(ctx)
  21488. if err != nil {
  21489. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21490. }
  21491. return oldValue.ActionLabelAdd, nil
  21492. }
  21493. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21494. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  21495. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21496. }
  21497. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21498. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21499. if len(m.appendaction_label_add) == 0 {
  21500. return nil, false
  21501. }
  21502. return m.appendaction_label_add, true
  21503. }
  21504. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21505. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  21506. m.action_label_add = nil
  21507. m.appendaction_label_add = nil
  21508. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  21509. }
  21510. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21511. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  21512. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  21513. return ok
  21514. }
  21515. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21516. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  21517. m.action_label_add = nil
  21518. m.appendaction_label_add = nil
  21519. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  21520. }
  21521. // SetActionLabelDel sets the "action_label_del" field.
  21522. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  21523. m.action_label_del = &u
  21524. m.appendaction_label_del = nil
  21525. }
  21526. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21527. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  21528. v := m.action_label_del
  21529. if v == nil {
  21530. return
  21531. }
  21532. return *v, true
  21533. }
  21534. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  21535. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  21536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21537. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21538. if !m.op.Is(OpUpdateOne) {
  21539. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21540. }
  21541. if m.id == nil || m.oldValue == nil {
  21542. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21543. }
  21544. oldValue, err := m.oldValue(ctx)
  21545. if err != nil {
  21546. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21547. }
  21548. return oldValue.ActionLabelDel, nil
  21549. }
  21550. // AppendActionLabelDel adds u to the "action_label_del" field.
  21551. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  21552. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21553. }
  21554. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21555. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21556. if len(m.appendaction_label_del) == 0 {
  21557. return nil, false
  21558. }
  21559. return m.appendaction_label_del, true
  21560. }
  21561. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21562. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  21563. m.action_label_del = nil
  21564. m.appendaction_label_del = nil
  21565. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  21566. }
  21567. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21568. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  21569. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  21570. return ok
  21571. }
  21572. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21573. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  21574. m.action_label_del = nil
  21575. m.appendaction_label_del = nil
  21576. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  21577. }
  21578. // Where appends a list predicates to the LabelTaggingMutation builder.
  21579. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  21580. m.predicates = append(m.predicates, ps...)
  21581. }
  21582. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  21583. // users can use type-assertion to append predicates that do not depend on any generated package.
  21584. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  21585. p := make([]predicate.LabelTagging, len(ps))
  21586. for i := range ps {
  21587. p[i] = ps[i]
  21588. }
  21589. m.Where(p...)
  21590. }
  21591. // Op returns the operation name.
  21592. func (m *LabelTaggingMutation) Op() Op {
  21593. return m.op
  21594. }
  21595. // SetOp allows setting the mutation operation.
  21596. func (m *LabelTaggingMutation) SetOp(op Op) {
  21597. m.op = op
  21598. }
  21599. // Type returns the node type of this mutation (LabelTagging).
  21600. func (m *LabelTaggingMutation) Type() string {
  21601. return m.typ
  21602. }
  21603. // Fields returns all fields that were changed during this mutation. Note that in
  21604. // order to get all numeric fields that were incremented/decremented, call
  21605. // AddedFields().
  21606. func (m *LabelTaggingMutation) Fields() []string {
  21607. fields := make([]string, 0, 9)
  21608. if m.created_at != nil {
  21609. fields = append(fields, labeltagging.FieldCreatedAt)
  21610. }
  21611. if m.updated_at != nil {
  21612. fields = append(fields, labeltagging.FieldUpdatedAt)
  21613. }
  21614. if m.status != nil {
  21615. fields = append(fields, labeltagging.FieldStatus)
  21616. }
  21617. if m.deleted_at != nil {
  21618. fields = append(fields, labeltagging.FieldDeletedAt)
  21619. }
  21620. if m.organization_id != nil {
  21621. fields = append(fields, labeltagging.FieldOrganizationID)
  21622. }
  21623. if m._type != nil {
  21624. fields = append(fields, labeltagging.FieldType)
  21625. }
  21626. if m.conditions != nil {
  21627. fields = append(fields, labeltagging.FieldConditions)
  21628. }
  21629. if m.action_label_add != nil {
  21630. fields = append(fields, labeltagging.FieldActionLabelAdd)
  21631. }
  21632. if m.action_label_del != nil {
  21633. fields = append(fields, labeltagging.FieldActionLabelDel)
  21634. }
  21635. return fields
  21636. }
  21637. // Field returns the value of a field with the given name. The second boolean
  21638. // return value indicates that this field was not set, or was not defined in the
  21639. // schema.
  21640. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  21641. switch name {
  21642. case labeltagging.FieldCreatedAt:
  21643. return m.CreatedAt()
  21644. case labeltagging.FieldUpdatedAt:
  21645. return m.UpdatedAt()
  21646. case labeltagging.FieldStatus:
  21647. return m.Status()
  21648. case labeltagging.FieldDeletedAt:
  21649. return m.DeletedAt()
  21650. case labeltagging.FieldOrganizationID:
  21651. return m.OrganizationID()
  21652. case labeltagging.FieldType:
  21653. return m.GetType()
  21654. case labeltagging.FieldConditions:
  21655. return m.Conditions()
  21656. case labeltagging.FieldActionLabelAdd:
  21657. return m.ActionLabelAdd()
  21658. case labeltagging.FieldActionLabelDel:
  21659. return m.ActionLabelDel()
  21660. }
  21661. return nil, false
  21662. }
  21663. // OldField returns the old value of the field from the database. An error is
  21664. // returned if the mutation operation is not UpdateOne, or the query to the
  21665. // database failed.
  21666. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21667. switch name {
  21668. case labeltagging.FieldCreatedAt:
  21669. return m.OldCreatedAt(ctx)
  21670. case labeltagging.FieldUpdatedAt:
  21671. return m.OldUpdatedAt(ctx)
  21672. case labeltagging.FieldStatus:
  21673. return m.OldStatus(ctx)
  21674. case labeltagging.FieldDeletedAt:
  21675. return m.OldDeletedAt(ctx)
  21676. case labeltagging.FieldOrganizationID:
  21677. return m.OldOrganizationID(ctx)
  21678. case labeltagging.FieldType:
  21679. return m.OldType(ctx)
  21680. case labeltagging.FieldConditions:
  21681. return m.OldConditions(ctx)
  21682. case labeltagging.FieldActionLabelAdd:
  21683. return m.OldActionLabelAdd(ctx)
  21684. case labeltagging.FieldActionLabelDel:
  21685. return m.OldActionLabelDel(ctx)
  21686. }
  21687. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  21688. }
  21689. // SetField sets the value of a field with the given name. It returns an error if
  21690. // the field is not defined in the schema, or if the type mismatched the field
  21691. // type.
  21692. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  21693. switch name {
  21694. case labeltagging.FieldCreatedAt:
  21695. v, ok := value.(time.Time)
  21696. if !ok {
  21697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21698. }
  21699. m.SetCreatedAt(v)
  21700. return nil
  21701. case labeltagging.FieldUpdatedAt:
  21702. v, ok := value.(time.Time)
  21703. if !ok {
  21704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21705. }
  21706. m.SetUpdatedAt(v)
  21707. return nil
  21708. case labeltagging.FieldStatus:
  21709. v, ok := value.(uint8)
  21710. if !ok {
  21711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21712. }
  21713. m.SetStatus(v)
  21714. return nil
  21715. case labeltagging.FieldDeletedAt:
  21716. v, ok := value.(time.Time)
  21717. if !ok {
  21718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21719. }
  21720. m.SetDeletedAt(v)
  21721. return nil
  21722. case labeltagging.FieldOrganizationID:
  21723. v, ok := value.(uint64)
  21724. if !ok {
  21725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21726. }
  21727. m.SetOrganizationID(v)
  21728. return nil
  21729. case labeltagging.FieldType:
  21730. v, ok := value.(int)
  21731. if !ok {
  21732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21733. }
  21734. m.SetType(v)
  21735. return nil
  21736. case labeltagging.FieldConditions:
  21737. v, ok := value.(string)
  21738. if !ok {
  21739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21740. }
  21741. m.SetConditions(v)
  21742. return nil
  21743. case labeltagging.FieldActionLabelAdd:
  21744. v, ok := value.([]uint64)
  21745. if !ok {
  21746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21747. }
  21748. m.SetActionLabelAdd(v)
  21749. return nil
  21750. case labeltagging.FieldActionLabelDel:
  21751. v, ok := value.([]uint64)
  21752. if !ok {
  21753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21754. }
  21755. m.SetActionLabelDel(v)
  21756. return nil
  21757. }
  21758. return fmt.Errorf("unknown LabelTagging field %s", name)
  21759. }
  21760. // AddedFields returns all numeric fields that were incremented/decremented during
  21761. // this mutation.
  21762. func (m *LabelTaggingMutation) AddedFields() []string {
  21763. var fields []string
  21764. if m.addstatus != nil {
  21765. fields = append(fields, labeltagging.FieldStatus)
  21766. }
  21767. if m.addorganization_id != nil {
  21768. fields = append(fields, labeltagging.FieldOrganizationID)
  21769. }
  21770. if m.add_type != nil {
  21771. fields = append(fields, labeltagging.FieldType)
  21772. }
  21773. return fields
  21774. }
  21775. // AddedField returns the numeric value that was incremented/decremented on a field
  21776. // with the given name. The second boolean return value indicates that this field
  21777. // was not set, or was not defined in the schema.
  21778. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  21779. switch name {
  21780. case labeltagging.FieldStatus:
  21781. return m.AddedStatus()
  21782. case labeltagging.FieldOrganizationID:
  21783. return m.AddedOrganizationID()
  21784. case labeltagging.FieldType:
  21785. return m.AddedType()
  21786. }
  21787. return nil, false
  21788. }
  21789. // AddField adds the value to the field with the given name. It returns an error if
  21790. // the field is not defined in the schema, or if the type mismatched the field
  21791. // type.
  21792. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  21793. switch name {
  21794. case labeltagging.FieldStatus:
  21795. v, ok := value.(int8)
  21796. if !ok {
  21797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21798. }
  21799. m.AddStatus(v)
  21800. return nil
  21801. case labeltagging.FieldOrganizationID:
  21802. v, ok := value.(int64)
  21803. if !ok {
  21804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21805. }
  21806. m.AddOrganizationID(v)
  21807. return nil
  21808. case labeltagging.FieldType:
  21809. v, ok := value.(int)
  21810. if !ok {
  21811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21812. }
  21813. m.AddType(v)
  21814. return nil
  21815. }
  21816. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  21817. }
  21818. // ClearedFields returns all nullable fields that were cleared during this
  21819. // mutation.
  21820. func (m *LabelTaggingMutation) ClearedFields() []string {
  21821. var fields []string
  21822. if m.FieldCleared(labeltagging.FieldStatus) {
  21823. fields = append(fields, labeltagging.FieldStatus)
  21824. }
  21825. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  21826. fields = append(fields, labeltagging.FieldDeletedAt)
  21827. }
  21828. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  21829. fields = append(fields, labeltagging.FieldActionLabelAdd)
  21830. }
  21831. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  21832. fields = append(fields, labeltagging.FieldActionLabelDel)
  21833. }
  21834. return fields
  21835. }
  21836. // FieldCleared returns a boolean indicating if a field with the given name was
  21837. // cleared in this mutation.
  21838. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  21839. _, ok := m.clearedFields[name]
  21840. return ok
  21841. }
  21842. // ClearField clears the value of the field with the given name. It returns an
  21843. // error if the field is not defined in the schema.
  21844. func (m *LabelTaggingMutation) ClearField(name string) error {
  21845. switch name {
  21846. case labeltagging.FieldStatus:
  21847. m.ClearStatus()
  21848. return nil
  21849. case labeltagging.FieldDeletedAt:
  21850. m.ClearDeletedAt()
  21851. return nil
  21852. case labeltagging.FieldActionLabelAdd:
  21853. m.ClearActionLabelAdd()
  21854. return nil
  21855. case labeltagging.FieldActionLabelDel:
  21856. m.ClearActionLabelDel()
  21857. return nil
  21858. }
  21859. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  21860. }
  21861. // ResetField resets all changes in the mutation for the field with the given name.
  21862. // It returns an error if the field is not defined in the schema.
  21863. func (m *LabelTaggingMutation) ResetField(name string) error {
  21864. switch name {
  21865. case labeltagging.FieldCreatedAt:
  21866. m.ResetCreatedAt()
  21867. return nil
  21868. case labeltagging.FieldUpdatedAt:
  21869. m.ResetUpdatedAt()
  21870. return nil
  21871. case labeltagging.FieldStatus:
  21872. m.ResetStatus()
  21873. return nil
  21874. case labeltagging.FieldDeletedAt:
  21875. m.ResetDeletedAt()
  21876. return nil
  21877. case labeltagging.FieldOrganizationID:
  21878. m.ResetOrganizationID()
  21879. return nil
  21880. case labeltagging.FieldType:
  21881. m.ResetType()
  21882. return nil
  21883. case labeltagging.FieldConditions:
  21884. m.ResetConditions()
  21885. return nil
  21886. case labeltagging.FieldActionLabelAdd:
  21887. m.ResetActionLabelAdd()
  21888. return nil
  21889. case labeltagging.FieldActionLabelDel:
  21890. m.ResetActionLabelDel()
  21891. return nil
  21892. }
  21893. return fmt.Errorf("unknown LabelTagging field %s", name)
  21894. }
  21895. // AddedEdges returns all edge names that were set/added in this mutation.
  21896. func (m *LabelTaggingMutation) AddedEdges() []string {
  21897. edges := make([]string, 0, 0)
  21898. return edges
  21899. }
  21900. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21901. // name in this mutation.
  21902. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  21903. return nil
  21904. }
  21905. // RemovedEdges returns all edge names that were removed in this mutation.
  21906. func (m *LabelTaggingMutation) RemovedEdges() []string {
  21907. edges := make([]string, 0, 0)
  21908. return edges
  21909. }
  21910. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21911. // the given name in this mutation.
  21912. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  21913. return nil
  21914. }
  21915. // ClearedEdges returns all edge names that were cleared in this mutation.
  21916. func (m *LabelTaggingMutation) ClearedEdges() []string {
  21917. edges := make([]string, 0, 0)
  21918. return edges
  21919. }
  21920. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21921. // was cleared in this mutation.
  21922. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  21923. return false
  21924. }
  21925. // ClearEdge clears the value of the edge with the given name. It returns an error
  21926. // if that edge is not defined in the schema.
  21927. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  21928. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  21929. }
  21930. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21931. // It returns an error if the edge is not defined in the schema.
  21932. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  21933. return fmt.Errorf("unknown LabelTagging edge %s", name)
  21934. }
  21935. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  21936. type MessageMutation struct {
  21937. config
  21938. op Op
  21939. typ string
  21940. id *int
  21941. wx_wxid *string
  21942. wxid *string
  21943. content *string
  21944. clearedFields map[string]struct{}
  21945. done bool
  21946. oldValue func(context.Context) (*Message, error)
  21947. predicates []predicate.Message
  21948. }
  21949. var _ ent.Mutation = (*MessageMutation)(nil)
  21950. // messageOption allows management of the mutation configuration using functional options.
  21951. type messageOption func(*MessageMutation)
  21952. // newMessageMutation creates new mutation for the Message entity.
  21953. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  21954. m := &MessageMutation{
  21955. config: c,
  21956. op: op,
  21957. typ: TypeMessage,
  21958. clearedFields: make(map[string]struct{}),
  21959. }
  21960. for _, opt := range opts {
  21961. opt(m)
  21962. }
  21963. return m
  21964. }
  21965. // withMessageID sets the ID field of the mutation.
  21966. func withMessageID(id int) messageOption {
  21967. return func(m *MessageMutation) {
  21968. var (
  21969. err error
  21970. once sync.Once
  21971. value *Message
  21972. )
  21973. m.oldValue = func(ctx context.Context) (*Message, error) {
  21974. once.Do(func() {
  21975. if m.done {
  21976. err = errors.New("querying old values post mutation is not allowed")
  21977. } else {
  21978. value, err = m.Client().Message.Get(ctx, id)
  21979. }
  21980. })
  21981. return value, err
  21982. }
  21983. m.id = &id
  21984. }
  21985. }
  21986. // withMessage sets the old Message of the mutation.
  21987. func withMessage(node *Message) messageOption {
  21988. return func(m *MessageMutation) {
  21989. m.oldValue = func(context.Context) (*Message, error) {
  21990. return node, nil
  21991. }
  21992. m.id = &node.ID
  21993. }
  21994. }
  21995. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21996. // executed in a transaction (ent.Tx), a transactional client is returned.
  21997. func (m MessageMutation) Client() *Client {
  21998. client := &Client{config: m.config}
  21999. client.init()
  22000. return client
  22001. }
  22002. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22003. // it returns an error otherwise.
  22004. func (m MessageMutation) Tx() (*Tx, error) {
  22005. if _, ok := m.driver.(*txDriver); !ok {
  22006. return nil, errors.New("ent: mutation is not running in a transaction")
  22007. }
  22008. tx := &Tx{config: m.config}
  22009. tx.init()
  22010. return tx, nil
  22011. }
  22012. // ID returns the ID value in the mutation. Note that the ID is only available
  22013. // if it was provided to the builder or after it was returned from the database.
  22014. func (m *MessageMutation) ID() (id int, exists bool) {
  22015. if m.id == nil {
  22016. return
  22017. }
  22018. return *m.id, true
  22019. }
  22020. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22021. // That means, if the mutation is applied within a transaction with an isolation level such
  22022. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22023. // or updated by the mutation.
  22024. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  22025. switch {
  22026. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22027. id, exists := m.ID()
  22028. if exists {
  22029. return []int{id}, nil
  22030. }
  22031. fallthrough
  22032. case m.op.Is(OpUpdate | OpDelete):
  22033. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  22034. default:
  22035. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22036. }
  22037. }
  22038. // SetWxWxid sets the "wx_wxid" field.
  22039. func (m *MessageMutation) SetWxWxid(s string) {
  22040. m.wx_wxid = &s
  22041. }
  22042. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  22043. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  22044. v := m.wx_wxid
  22045. if v == nil {
  22046. return
  22047. }
  22048. return *v, true
  22049. }
  22050. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  22051. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22053. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  22054. if !m.op.Is(OpUpdateOne) {
  22055. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  22056. }
  22057. if m.id == nil || m.oldValue == nil {
  22058. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  22059. }
  22060. oldValue, err := m.oldValue(ctx)
  22061. if err != nil {
  22062. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  22063. }
  22064. return oldValue.WxWxid, nil
  22065. }
  22066. // ClearWxWxid clears the value of the "wx_wxid" field.
  22067. func (m *MessageMutation) ClearWxWxid() {
  22068. m.wx_wxid = nil
  22069. m.clearedFields[message.FieldWxWxid] = struct{}{}
  22070. }
  22071. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  22072. func (m *MessageMutation) WxWxidCleared() bool {
  22073. _, ok := m.clearedFields[message.FieldWxWxid]
  22074. return ok
  22075. }
  22076. // ResetWxWxid resets all changes to the "wx_wxid" field.
  22077. func (m *MessageMutation) ResetWxWxid() {
  22078. m.wx_wxid = nil
  22079. delete(m.clearedFields, message.FieldWxWxid)
  22080. }
  22081. // SetWxid sets the "wxid" field.
  22082. func (m *MessageMutation) SetWxid(s string) {
  22083. m.wxid = &s
  22084. }
  22085. // Wxid returns the value of the "wxid" field in the mutation.
  22086. func (m *MessageMutation) Wxid() (r string, exists bool) {
  22087. v := m.wxid
  22088. if v == nil {
  22089. return
  22090. }
  22091. return *v, true
  22092. }
  22093. // OldWxid returns the old "wxid" field's value of the Message entity.
  22094. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22096. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  22097. if !m.op.Is(OpUpdateOne) {
  22098. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  22099. }
  22100. if m.id == nil || m.oldValue == nil {
  22101. return v, errors.New("OldWxid requires an ID field in the mutation")
  22102. }
  22103. oldValue, err := m.oldValue(ctx)
  22104. if err != nil {
  22105. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  22106. }
  22107. return oldValue.Wxid, nil
  22108. }
  22109. // ResetWxid resets all changes to the "wxid" field.
  22110. func (m *MessageMutation) ResetWxid() {
  22111. m.wxid = nil
  22112. }
  22113. // SetContent sets the "content" field.
  22114. func (m *MessageMutation) SetContent(s string) {
  22115. m.content = &s
  22116. }
  22117. // Content returns the value of the "content" field in the mutation.
  22118. func (m *MessageMutation) Content() (r string, exists bool) {
  22119. v := m.content
  22120. if v == nil {
  22121. return
  22122. }
  22123. return *v, true
  22124. }
  22125. // OldContent returns the old "content" field's value of the Message entity.
  22126. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  22127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22128. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  22129. if !m.op.Is(OpUpdateOne) {
  22130. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22131. }
  22132. if m.id == nil || m.oldValue == nil {
  22133. return v, errors.New("OldContent requires an ID field in the mutation")
  22134. }
  22135. oldValue, err := m.oldValue(ctx)
  22136. if err != nil {
  22137. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22138. }
  22139. return oldValue.Content, nil
  22140. }
  22141. // ResetContent resets all changes to the "content" field.
  22142. func (m *MessageMutation) ResetContent() {
  22143. m.content = nil
  22144. }
  22145. // Where appends a list predicates to the MessageMutation builder.
  22146. func (m *MessageMutation) Where(ps ...predicate.Message) {
  22147. m.predicates = append(m.predicates, ps...)
  22148. }
  22149. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  22150. // users can use type-assertion to append predicates that do not depend on any generated package.
  22151. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  22152. p := make([]predicate.Message, len(ps))
  22153. for i := range ps {
  22154. p[i] = ps[i]
  22155. }
  22156. m.Where(p...)
  22157. }
  22158. // Op returns the operation name.
  22159. func (m *MessageMutation) Op() Op {
  22160. return m.op
  22161. }
  22162. // SetOp allows setting the mutation operation.
  22163. func (m *MessageMutation) SetOp(op Op) {
  22164. m.op = op
  22165. }
  22166. // Type returns the node type of this mutation (Message).
  22167. func (m *MessageMutation) Type() string {
  22168. return m.typ
  22169. }
  22170. // Fields returns all fields that were changed during this mutation. Note that in
  22171. // order to get all numeric fields that were incremented/decremented, call
  22172. // AddedFields().
  22173. func (m *MessageMutation) Fields() []string {
  22174. fields := make([]string, 0, 3)
  22175. if m.wx_wxid != nil {
  22176. fields = append(fields, message.FieldWxWxid)
  22177. }
  22178. if m.wxid != nil {
  22179. fields = append(fields, message.FieldWxid)
  22180. }
  22181. if m.content != nil {
  22182. fields = append(fields, message.FieldContent)
  22183. }
  22184. return fields
  22185. }
  22186. // Field returns the value of a field with the given name. The second boolean
  22187. // return value indicates that this field was not set, or was not defined in the
  22188. // schema.
  22189. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  22190. switch name {
  22191. case message.FieldWxWxid:
  22192. return m.WxWxid()
  22193. case message.FieldWxid:
  22194. return m.Wxid()
  22195. case message.FieldContent:
  22196. return m.Content()
  22197. }
  22198. return nil, false
  22199. }
  22200. // OldField returns the old value of the field from the database. An error is
  22201. // returned if the mutation operation is not UpdateOne, or the query to the
  22202. // database failed.
  22203. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22204. switch name {
  22205. case message.FieldWxWxid:
  22206. return m.OldWxWxid(ctx)
  22207. case message.FieldWxid:
  22208. return m.OldWxid(ctx)
  22209. case message.FieldContent:
  22210. return m.OldContent(ctx)
  22211. }
  22212. return nil, fmt.Errorf("unknown Message field %s", name)
  22213. }
  22214. // SetField sets the value of a field with the given name. It returns an error if
  22215. // the field is not defined in the schema, or if the type mismatched the field
  22216. // type.
  22217. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  22218. switch name {
  22219. case message.FieldWxWxid:
  22220. v, ok := value.(string)
  22221. if !ok {
  22222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22223. }
  22224. m.SetWxWxid(v)
  22225. return nil
  22226. case message.FieldWxid:
  22227. v, ok := value.(string)
  22228. if !ok {
  22229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22230. }
  22231. m.SetWxid(v)
  22232. return nil
  22233. case message.FieldContent:
  22234. v, ok := value.(string)
  22235. if !ok {
  22236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22237. }
  22238. m.SetContent(v)
  22239. return nil
  22240. }
  22241. return fmt.Errorf("unknown Message field %s", name)
  22242. }
  22243. // AddedFields returns all numeric fields that were incremented/decremented during
  22244. // this mutation.
  22245. func (m *MessageMutation) AddedFields() []string {
  22246. return nil
  22247. }
  22248. // AddedField returns the numeric value that was incremented/decremented on a field
  22249. // with the given name. The second boolean return value indicates that this field
  22250. // was not set, or was not defined in the schema.
  22251. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  22252. return nil, false
  22253. }
  22254. // AddField adds the value to the field with the given name. It returns an error if
  22255. // the field is not defined in the schema, or if the type mismatched the field
  22256. // type.
  22257. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  22258. switch name {
  22259. }
  22260. return fmt.Errorf("unknown Message numeric field %s", name)
  22261. }
  22262. // ClearedFields returns all nullable fields that were cleared during this
  22263. // mutation.
  22264. func (m *MessageMutation) ClearedFields() []string {
  22265. var fields []string
  22266. if m.FieldCleared(message.FieldWxWxid) {
  22267. fields = append(fields, message.FieldWxWxid)
  22268. }
  22269. return fields
  22270. }
  22271. // FieldCleared returns a boolean indicating if a field with the given name was
  22272. // cleared in this mutation.
  22273. func (m *MessageMutation) FieldCleared(name string) bool {
  22274. _, ok := m.clearedFields[name]
  22275. return ok
  22276. }
  22277. // ClearField clears the value of the field with the given name. It returns an
  22278. // error if the field is not defined in the schema.
  22279. func (m *MessageMutation) ClearField(name string) error {
  22280. switch name {
  22281. case message.FieldWxWxid:
  22282. m.ClearWxWxid()
  22283. return nil
  22284. }
  22285. return fmt.Errorf("unknown Message nullable field %s", name)
  22286. }
  22287. // ResetField resets all changes in the mutation for the field with the given name.
  22288. // It returns an error if the field is not defined in the schema.
  22289. func (m *MessageMutation) ResetField(name string) error {
  22290. switch name {
  22291. case message.FieldWxWxid:
  22292. m.ResetWxWxid()
  22293. return nil
  22294. case message.FieldWxid:
  22295. m.ResetWxid()
  22296. return nil
  22297. case message.FieldContent:
  22298. m.ResetContent()
  22299. return nil
  22300. }
  22301. return fmt.Errorf("unknown Message field %s", name)
  22302. }
  22303. // AddedEdges returns all edge names that were set/added in this mutation.
  22304. func (m *MessageMutation) AddedEdges() []string {
  22305. edges := make([]string, 0, 0)
  22306. return edges
  22307. }
  22308. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22309. // name in this mutation.
  22310. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  22311. return nil
  22312. }
  22313. // RemovedEdges returns all edge names that were removed in this mutation.
  22314. func (m *MessageMutation) RemovedEdges() []string {
  22315. edges := make([]string, 0, 0)
  22316. return edges
  22317. }
  22318. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22319. // the given name in this mutation.
  22320. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  22321. return nil
  22322. }
  22323. // ClearedEdges returns all edge names that were cleared in this mutation.
  22324. func (m *MessageMutation) ClearedEdges() []string {
  22325. edges := make([]string, 0, 0)
  22326. return edges
  22327. }
  22328. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22329. // was cleared in this mutation.
  22330. func (m *MessageMutation) EdgeCleared(name string) bool {
  22331. return false
  22332. }
  22333. // ClearEdge clears the value of the edge with the given name. It returns an error
  22334. // if that edge is not defined in the schema.
  22335. func (m *MessageMutation) ClearEdge(name string) error {
  22336. return fmt.Errorf("unknown Message unique edge %s", name)
  22337. }
  22338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22339. // It returns an error if the edge is not defined in the schema.
  22340. func (m *MessageMutation) ResetEdge(name string) error {
  22341. return fmt.Errorf("unknown Message edge %s", name)
  22342. }
  22343. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  22344. type MessageRecordsMutation struct {
  22345. config
  22346. op Op
  22347. typ string
  22348. id *uint64
  22349. created_at *time.Time
  22350. updated_at *time.Time
  22351. status *uint8
  22352. addstatus *int8
  22353. bot_wxid *string
  22354. contact_type *int
  22355. addcontact_type *int
  22356. contact_wxid *string
  22357. content_type *int
  22358. addcontent_type *int
  22359. content *string
  22360. meta *custom_types.Meta
  22361. error_detail *string
  22362. send_time *time.Time
  22363. source_type *int
  22364. addsource_type *int
  22365. organization_id *uint64
  22366. addorganization_id *int64
  22367. clearedFields map[string]struct{}
  22368. sop_stage *uint64
  22369. clearedsop_stage bool
  22370. sop_node *uint64
  22371. clearedsop_node bool
  22372. message_contact *uint64
  22373. clearedmessage_contact bool
  22374. done bool
  22375. oldValue func(context.Context) (*MessageRecords, error)
  22376. predicates []predicate.MessageRecords
  22377. }
  22378. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  22379. // messagerecordsOption allows management of the mutation configuration using functional options.
  22380. type messagerecordsOption func(*MessageRecordsMutation)
  22381. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  22382. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  22383. m := &MessageRecordsMutation{
  22384. config: c,
  22385. op: op,
  22386. typ: TypeMessageRecords,
  22387. clearedFields: make(map[string]struct{}),
  22388. }
  22389. for _, opt := range opts {
  22390. opt(m)
  22391. }
  22392. return m
  22393. }
  22394. // withMessageRecordsID sets the ID field of the mutation.
  22395. func withMessageRecordsID(id uint64) messagerecordsOption {
  22396. return func(m *MessageRecordsMutation) {
  22397. var (
  22398. err error
  22399. once sync.Once
  22400. value *MessageRecords
  22401. )
  22402. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  22403. once.Do(func() {
  22404. if m.done {
  22405. err = errors.New("querying old values post mutation is not allowed")
  22406. } else {
  22407. value, err = m.Client().MessageRecords.Get(ctx, id)
  22408. }
  22409. })
  22410. return value, err
  22411. }
  22412. m.id = &id
  22413. }
  22414. }
  22415. // withMessageRecords sets the old MessageRecords of the mutation.
  22416. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  22417. return func(m *MessageRecordsMutation) {
  22418. m.oldValue = func(context.Context) (*MessageRecords, error) {
  22419. return node, nil
  22420. }
  22421. m.id = &node.ID
  22422. }
  22423. }
  22424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22425. // executed in a transaction (ent.Tx), a transactional client is returned.
  22426. func (m MessageRecordsMutation) Client() *Client {
  22427. client := &Client{config: m.config}
  22428. client.init()
  22429. return client
  22430. }
  22431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22432. // it returns an error otherwise.
  22433. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  22434. if _, ok := m.driver.(*txDriver); !ok {
  22435. return nil, errors.New("ent: mutation is not running in a transaction")
  22436. }
  22437. tx := &Tx{config: m.config}
  22438. tx.init()
  22439. return tx, nil
  22440. }
  22441. // SetID sets the value of the id field. Note that this
  22442. // operation is only accepted on creation of MessageRecords entities.
  22443. func (m *MessageRecordsMutation) SetID(id uint64) {
  22444. m.id = &id
  22445. }
  22446. // ID returns the ID value in the mutation. Note that the ID is only available
  22447. // if it was provided to the builder or after it was returned from the database.
  22448. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  22449. if m.id == nil {
  22450. return
  22451. }
  22452. return *m.id, true
  22453. }
  22454. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22455. // That means, if the mutation is applied within a transaction with an isolation level such
  22456. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22457. // or updated by the mutation.
  22458. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  22459. switch {
  22460. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22461. id, exists := m.ID()
  22462. if exists {
  22463. return []uint64{id}, nil
  22464. }
  22465. fallthrough
  22466. case m.op.Is(OpUpdate | OpDelete):
  22467. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  22468. default:
  22469. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22470. }
  22471. }
  22472. // SetCreatedAt sets the "created_at" field.
  22473. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  22474. m.created_at = &t
  22475. }
  22476. // CreatedAt returns the value of the "created_at" field in the mutation.
  22477. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  22478. v := m.created_at
  22479. if v == nil {
  22480. return
  22481. }
  22482. return *v, true
  22483. }
  22484. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  22485. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22487. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22488. if !m.op.Is(OpUpdateOne) {
  22489. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22490. }
  22491. if m.id == nil || m.oldValue == nil {
  22492. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22493. }
  22494. oldValue, err := m.oldValue(ctx)
  22495. if err != nil {
  22496. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22497. }
  22498. return oldValue.CreatedAt, nil
  22499. }
  22500. // ResetCreatedAt resets all changes to the "created_at" field.
  22501. func (m *MessageRecordsMutation) ResetCreatedAt() {
  22502. m.created_at = nil
  22503. }
  22504. // SetUpdatedAt sets the "updated_at" field.
  22505. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  22506. m.updated_at = &t
  22507. }
  22508. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22509. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  22510. v := m.updated_at
  22511. if v == nil {
  22512. return
  22513. }
  22514. return *v, true
  22515. }
  22516. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  22517. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22519. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22520. if !m.op.Is(OpUpdateOne) {
  22521. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22522. }
  22523. if m.id == nil || m.oldValue == nil {
  22524. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22525. }
  22526. oldValue, err := m.oldValue(ctx)
  22527. if err != nil {
  22528. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22529. }
  22530. return oldValue.UpdatedAt, nil
  22531. }
  22532. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22533. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  22534. m.updated_at = nil
  22535. }
  22536. // SetStatus sets the "status" field.
  22537. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  22538. m.status = &u
  22539. m.addstatus = nil
  22540. }
  22541. // Status returns the value of the "status" field in the mutation.
  22542. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  22543. v := m.status
  22544. if v == nil {
  22545. return
  22546. }
  22547. return *v, true
  22548. }
  22549. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  22550. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22552. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22553. if !m.op.Is(OpUpdateOne) {
  22554. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22555. }
  22556. if m.id == nil || m.oldValue == nil {
  22557. return v, errors.New("OldStatus requires an ID field in the mutation")
  22558. }
  22559. oldValue, err := m.oldValue(ctx)
  22560. if err != nil {
  22561. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22562. }
  22563. return oldValue.Status, nil
  22564. }
  22565. // AddStatus adds u to the "status" field.
  22566. func (m *MessageRecordsMutation) AddStatus(u int8) {
  22567. if m.addstatus != nil {
  22568. *m.addstatus += u
  22569. } else {
  22570. m.addstatus = &u
  22571. }
  22572. }
  22573. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22574. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  22575. v := m.addstatus
  22576. if v == nil {
  22577. return
  22578. }
  22579. return *v, true
  22580. }
  22581. // ClearStatus clears the value of the "status" field.
  22582. func (m *MessageRecordsMutation) ClearStatus() {
  22583. m.status = nil
  22584. m.addstatus = nil
  22585. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  22586. }
  22587. // StatusCleared returns if the "status" field was cleared in this mutation.
  22588. func (m *MessageRecordsMutation) StatusCleared() bool {
  22589. _, ok := m.clearedFields[messagerecords.FieldStatus]
  22590. return ok
  22591. }
  22592. // ResetStatus resets all changes to the "status" field.
  22593. func (m *MessageRecordsMutation) ResetStatus() {
  22594. m.status = nil
  22595. m.addstatus = nil
  22596. delete(m.clearedFields, messagerecords.FieldStatus)
  22597. }
  22598. // SetBotWxid sets the "bot_wxid" field.
  22599. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  22600. m.bot_wxid = &s
  22601. }
  22602. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  22603. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  22604. v := m.bot_wxid
  22605. if v == nil {
  22606. return
  22607. }
  22608. return *v, true
  22609. }
  22610. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  22611. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22613. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  22614. if !m.op.Is(OpUpdateOne) {
  22615. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  22616. }
  22617. if m.id == nil || m.oldValue == nil {
  22618. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  22619. }
  22620. oldValue, err := m.oldValue(ctx)
  22621. if err != nil {
  22622. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  22623. }
  22624. return oldValue.BotWxid, nil
  22625. }
  22626. // ResetBotWxid resets all changes to the "bot_wxid" field.
  22627. func (m *MessageRecordsMutation) ResetBotWxid() {
  22628. m.bot_wxid = nil
  22629. }
  22630. // SetContactID sets the "contact_id" field.
  22631. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  22632. m.message_contact = &u
  22633. }
  22634. // ContactID returns the value of the "contact_id" field in the mutation.
  22635. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  22636. v := m.message_contact
  22637. if v == nil {
  22638. return
  22639. }
  22640. return *v, true
  22641. }
  22642. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  22643. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22645. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22646. if !m.op.Is(OpUpdateOne) {
  22647. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22648. }
  22649. if m.id == nil || m.oldValue == nil {
  22650. return v, errors.New("OldContactID requires an ID field in the mutation")
  22651. }
  22652. oldValue, err := m.oldValue(ctx)
  22653. if err != nil {
  22654. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22655. }
  22656. return oldValue.ContactID, nil
  22657. }
  22658. // ClearContactID clears the value of the "contact_id" field.
  22659. func (m *MessageRecordsMutation) ClearContactID() {
  22660. m.message_contact = nil
  22661. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  22662. }
  22663. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  22664. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  22665. _, ok := m.clearedFields[messagerecords.FieldContactID]
  22666. return ok
  22667. }
  22668. // ResetContactID resets all changes to the "contact_id" field.
  22669. func (m *MessageRecordsMutation) ResetContactID() {
  22670. m.message_contact = nil
  22671. delete(m.clearedFields, messagerecords.FieldContactID)
  22672. }
  22673. // SetContactType sets the "contact_type" field.
  22674. func (m *MessageRecordsMutation) SetContactType(i int) {
  22675. m.contact_type = &i
  22676. m.addcontact_type = nil
  22677. }
  22678. // ContactType returns the value of the "contact_type" field in the mutation.
  22679. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  22680. v := m.contact_type
  22681. if v == nil {
  22682. return
  22683. }
  22684. return *v, true
  22685. }
  22686. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  22687. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22689. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  22690. if !m.op.Is(OpUpdateOne) {
  22691. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  22692. }
  22693. if m.id == nil || m.oldValue == nil {
  22694. return v, errors.New("OldContactType requires an ID field in the mutation")
  22695. }
  22696. oldValue, err := m.oldValue(ctx)
  22697. if err != nil {
  22698. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  22699. }
  22700. return oldValue.ContactType, nil
  22701. }
  22702. // AddContactType adds i to the "contact_type" field.
  22703. func (m *MessageRecordsMutation) AddContactType(i int) {
  22704. if m.addcontact_type != nil {
  22705. *m.addcontact_type += i
  22706. } else {
  22707. m.addcontact_type = &i
  22708. }
  22709. }
  22710. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  22711. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  22712. v := m.addcontact_type
  22713. if v == nil {
  22714. return
  22715. }
  22716. return *v, true
  22717. }
  22718. // ResetContactType resets all changes to the "contact_type" field.
  22719. func (m *MessageRecordsMutation) ResetContactType() {
  22720. m.contact_type = nil
  22721. m.addcontact_type = nil
  22722. }
  22723. // SetContactWxid sets the "contact_wxid" field.
  22724. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  22725. m.contact_wxid = &s
  22726. }
  22727. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  22728. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  22729. v := m.contact_wxid
  22730. if v == nil {
  22731. return
  22732. }
  22733. return *v, true
  22734. }
  22735. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  22736. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22738. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  22739. if !m.op.Is(OpUpdateOne) {
  22740. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  22741. }
  22742. if m.id == nil || m.oldValue == nil {
  22743. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  22744. }
  22745. oldValue, err := m.oldValue(ctx)
  22746. if err != nil {
  22747. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  22748. }
  22749. return oldValue.ContactWxid, nil
  22750. }
  22751. // ResetContactWxid resets all changes to the "contact_wxid" field.
  22752. func (m *MessageRecordsMutation) ResetContactWxid() {
  22753. m.contact_wxid = nil
  22754. }
  22755. // SetContentType sets the "content_type" field.
  22756. func (m *MessageRecordsMutation) SetContentType(i int) {
  22757. m.content_type = &i
  22758. m.addcontent_type = nil
  22759. }
  22760. // ContentType returns the value of the "content_type" field in the mutation.
  22761. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  22762. v := m.content_type
  22763. if v == nil {
  22764. return
  22765. }
  22766. return *v, true
  22767. }
  22768. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  22769. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22771. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  22772. if !m.op.Is(OpUpdateOne) {
  22773. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  22774. }
  22775. if m.id == nil || m.oldValue == nil {
  22776. return v, errors.New("OldContentType requires an ID field in the mutation")
  22777. }
  22778. oldValue, err := m.oldValue(ctx)
  22779. if err != nil {
  22780. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  22781. }
  22782. return oldValue.ContentType, nil
  22783. }
  22784. // AddContentType adds i to the "content_type" field.
  22785. func (m *MessageRecordsMutation) AddContentType(i int) {
  22786. if m.addcontent_type != nil {
  22787. *m.addcontent_type += i
  22788. } else {
  22789. m.addcontent_type = &i
  22790. }
  22791. }
  22792. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  22793. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  22794. v := m.addcontent_type
  22795. if v == nil {
  22796. return
  22797. }
  22798. return *v, true
  22799. }
  22800. // ResetContentType resets all changes to the "content_type" field.
  22801. func (m *MessageRecordsMutation) ResetContentType() {
  22802. m.content_type = nil
  22803. m.addcontent_type = nil
  22804. }
  22805. // SetContent sets the "content" field.
  22806. func (m *MessageRecordsMutation) SetContent(s string) {
  22807. m.content = &s
  22808. }
  22809. // Content returns the value of the "content" field in the mutation.
  22810. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  22811. v := m.content
  22812. if v == nil {
  22813. return
  22814. }
  22815. return *v, true
  22816. }
  22817. // OldContent returns the old "content" field's value of the MessageRecords entity.
  22818. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22820. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  22821. if !m.op.Is(OpUpdateOne) {
  22822. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22823. }
  22824. if m.id == nil || m.oldValue == nil {
  22825. return v, errors.New("OldContent requires an ID field in the mutation")
  22826. }
  22827. oldValue, err := m.oldValue(ctx)
  22828. if err != nil {
  22829. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22830. }
  22831. return oldValue.Content, nil
  22832. }
  22833. // ResetContent resets all changes to the "content" field.
  22834. func (m *MessageRecordsMutation) ResetContent() {
  22835. m.content = nil
  22836. }
  22837. // SetMeta sets the "meta" field.
  22838. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  22839. m.meta = &ct
  22840. }
  22841. // Meta returns the value of the "meta" field in the mutation.
  22842. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  22843. v := m.meta
  22844. if v == nil {
  22845. return
  22846. }
  22847. return *v, true
  22848. }
  22849. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  22850. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22852. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  22853. if !m.op.Is(OpUpdateOne) {
  22854. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  22855. }
  22856. if m.id == nil || m.oldValue == nil {
  22857. return v, errors.New("OldMeta requires an ID field in the mutation")
  22858. }
  22859. oldValue, err := m.oldValue(ctx)
  22860. if err != nil {
  22861. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  22862. }
  22863. return oldValue.Meta, nil
  22864. }
  22865. // ClearMeta clears the value of the "meta" field.
  22866. func (m *MessageRecordsMutation) ClearMeta() {
  22867. m.meta = nil
  22868. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  22869. }
  22870. // MetaCleared returns if the "meta" field was cleared in this mutation.
  22871. func (m *MessageRecordsMutation) MetaCleared() bool {
  22872. _, ok := m.clearedFields[messagerecords.FieldMeta]
  22873. return ok
  22874. }
  22875. // ResetMeta resets all changes to the "meta" field.
  22876. func (m *MessageRecordsMutation) ResetMeta() {
  22877. m.meta = nil
  22878. delete(m.clearedFields, messagerecords.FieldMeta)
  22879. }
  22880. // SetErrorDetail sets the "error_detail" field.
  22881. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  22882. m.error_detail = &s
  22883. }
  22884. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  22885. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  22886. v := m.error_detail
  22887. if v == nil {
  22888. return
  22889. }
  22890. return *v, true
  22891. }
  22892. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  22893. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22895. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  22896. if !m.op.Is(OpUpdateOne) {
  22897. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  22898. }
  22899. if m.id == nil || m.oldValue == nil {
  22900. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  22901. }
  22902. oldValue, err := m.oldValue(ctx)
  22903. if err != nil {
  22904. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  22905. }
  22906. return oldValue.ErrorDetail, nil
  22907. }
  22908. // ResetErrorDetail resets all changes to the "error_detail" field.
  22909. func (m *MessageRecordsMutation) ResetErrorDetail() {
  22910. m.error_detail = nil
  22911. }
  22912. // SetSendTime sets the "send_time" field.
  22913. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  22914. m.send_time = &t
  22915. }
  22916. // SendTime returns the value of the "send_time" field in the mutation.
  22917. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  22918. v := m.send_time
  22919. if v == nil {
  22920. return
  22921. }
  22922. return *v, true
  22923. }
  22924. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  22925. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22927. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  22928. if !m.op.Is(OpUpdateOne) {
  22929. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  22930. }
  22931. if m.id == nil || m.oldValue == nil {
  22932. return v, errors.New("OldSendTime requires an ID field in the mutation")
  22933. }
  22934. oldValue, err := m.oldValue(ctx)
  22935. if err != nil {
  22936. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  22937. }
  22938. return oldValue.SendTime, nil
  22939. }
  22940. // ClearSendTime clears the value of the "send_time" field.
  22941. func (m *MessageRecordsMutation) ClearSendTime() {
  22942. m.send_time = nil
  22943. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  22944. }
  22945. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  22946. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  22947. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  22948. return ok
  22949. }
  22950. // ResetSendTime resets all changes to the "send_time" field.
  22951. func (m *MessageRecordsMutation) ResetSendTime() {
  22952. m.send_time = nil
  22953. delete(m.clearedFields, messagerecords.FieldSendTime)
  22954. }
  22955. // SetSourceType sets the "source_type" field.
  22956. func (m *MessageRecordsMutation) SetSourceType(i int) {
  22957. m.source_type = &i
  22958. m.addsource_type = nil
  22959. }
  22960. // SourceType returns the value of the "source_type" field in the mutation.
  22961. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  22962. v := m.source_type
  22963. if v == nil {
  22964. return
  22965. }
  22966. return *v, true
  22967. }
  22968. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  22969. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  22970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22971. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  22972. if !m.op.Is(OpUpdateOne) {
  22973. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  22974. }
  22975. if m.id == nil || m.oldValue == nil {
  22976. return v, errors.New("OldSourceType requires an ID field in the mutation")
  22977. }
  22978. oldValue, err := m.oldValue(ctx)
  22979. if err != nil {
  22980. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  22981. }
  22982. return oldValue.SourceType, nil
  22983. }
  22984. // AddSourceType adds i to the "source_type" field.
  22985. func (m *MessageRecordsMutation) AddSourceType(i int) {
  22986. if m.addsource_type != nil {
  22987. *m.addsource_type += i
  22988. } else {
  22989. m.addsource_type = &i
  22990. }
  22991. }
  22992. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  22993. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  22994. v := m.addsource_type
  22995. if v == nil {
  22996. return
  22997. }
  22998. return *v, true
  22999. }
  23000. // ResetSourceType resets all changes to the "source_type" field.
  23001. func (m *MessageRecordsMutation) ResetSourceType() {
  23002. m.source_type = nil
  23003. m.addsource_type = nil
  23004. }
  23005. // SetSourceID sets the "source_id" field.
  23006. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  23007. m.sop_stage = &u
  23008. }
  23009. // SourceID returns the value of the "source_id" field in the mutation.
  23010. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  23011. v := m.sop_stage
  23012. if v == nil {
  23013. return
  23014. }
  23015. return *v, true
  23016. }
  23017. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  23018. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23020. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  23021. if !m.op.Is(OpUpdateOne) {
  23022. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  23023. }
  23024. if m.id == nil || m.oldValue == nil {
  23025. return v, errors.New("OldSourceID requires an ID field in the mutation")
  23026. }
  23027. oldValue, err := m.oldValue(ctx)
  23028. if err != nil {
  23029. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  23030. }
  23031. return oldValue.SourceID, nil
  23032. }
  23033. // ClearSourceID clears the value of the "source_id" field.
  23034. func (m *MessageRecordsMutation) ClearSourceID() {
  23035. m.sop_stage = nil
  23036. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23037. }
  23038. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  23039. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  23040. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  23041. return ok
  23042. }
  23043. // ResetSourceID resets all changes to the "source_id" field.
  23044. func (m *MessageRecordsMutation) ResetSourceID() {
  23045. m.sop_stage = nil
  23046. delete(m.clearedFields, messagerecords.FieldSourceID)
  23047. }
  23048. // SetSubSourceID sets the "sub_source_id" field.
  23049. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  23050. m.sop_node = &u
  23051. }
  23052. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  23053. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  23054. v := m.sop_node
  23055. if v == nil {
  23056. return
  23057. }
  23058. return *v, true
  23059. }
  23060. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  23061. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23063. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  23064. if !m.op.Is(OpUpdateOne) {
  23065. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  23066. }
  23067. if m.id == nil || m.oldValue == nil {
  23068. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  23069. }
  23070. oldValue, err := m.oldValue(ctx)
  23071. if err != nil {
  23072. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  23073. }
  23074. return oldValue.SubSourceID, nil
  23075. }
  23076. // ClearSubSourceID clears the value of the "sub_source_id" field.
  23077. func (m *MessageRecordsMutation) ClearSubSourceID() {
  23078. m.sop_node = nil
  23079. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23080. }
  23081. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  23082. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  23083. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  23084. return ok
  23085. }
  23086. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  23087. func (m *MessageRecordsMutation) ResetSubSourceID() {
  23088. m.sop_node = nil
  23089. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  23090. }
  23091. // SetOrganizationID sets the "organization_id" field.
  23092. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  23093. m.organization_id = &u
  23094. m.addorganization_id = nil
  23095. }
  23096. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23097. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  23098. v := m.organization_id
  23099. if v == nil {
  23100. return
  23101. }
  23102. return *v, true
  23103. }
  23104. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  23105. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  23106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23107. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23108. if !m.op.Is(OpUpdateOne) {
  23109. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23110. }
  23111. if m.id == nil || m.oldValue == nil {
  23112. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23113. }
  23114. oldValue, err := m.oldValue(ctx)
  23115. if err != nil {
  23116. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23117. }
  23118. return oldValue.OrganizationID, nil
  23119. }
  23120. // AddOrganizationID adds u to the "organization_id" field.
  23121. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  23122. if m.addorganization_id != nil {
  23123. *m.addorganization_id += u
  23124. } else {
  23125. m.addorganization_id = &u
  23126. }
  23127. }
  23128. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23129. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  23130. v := m.addorganization_id
  23131. if v == nil {
  23132. return
  23133. }
  23134. return *v, true
  23135. }
  23136. // ClearOrganizationID clears the value of the "organization_id" field.
  23137. func (m *MessageRecordsMutation) ClearOrganizationID() {
  23138. m.organization_id = nil
  23139. m.addorganization_id = nil
  23140. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  23141. }
  23142. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23143. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  23144. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  23145. return ok
  23146. }
  23147. // ResetOrganizationID resets all changes to the "organization_id" field.
  23148. func (m *MessageRecordsMutation) ResetOrganizationID() {
  23149. m.organization_id = nil
  23150. m.addorganization_id = nil
  23151. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  23152. }
  23153. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  23154. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  23155. m.sop_stage = &id
  23156. }
  23157. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  23158. func (m *MessageRecordsMutation) ClearSopStage() {
  23159. m.clearedsop_stage = true
  23160. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  23161. }
  23162. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  23163. func (m *MessageRecordsMutation) SopStageCleared() bool {
  23164. return m.SourceIDCleared() || m.clearedsop_stage
  23165. }
  23166. // SopStageID returns the "sop_stage" edge ID in the mutation.
  23167. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  23168. if m.sop_stage != nil {
  23169. return *m.sop_stage, true
  23170. }
  23171. return
  23172. }
  23173. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  23174. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23175. // SopStageID instead. It exists only for internal usage by the builders.
  23176. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  23177. if id := m.sop_stage; id != nil {
  23178. ids = append(ids, *id)
  23179. }
  23180. return
  23181. }
  23182. // ResetSopStage resets all changes to the "sop_stage" edge.
  23183. func (m *MessageRecordsMutation) ResetSopStage() {
  23184. m.sop_stage = nil
  23185. m.clearedsop_stage = false
  23186. }
  23187. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  23188. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  23189. m.sop_node = &id
  23190. }
  23191. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  23192. func (m *MessageRecordsMutation) ClearSopNode() {
  23193. m.clearedsop_node = true
  23194. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  23195. }
  23196. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  23197. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  23198. return m.SubSourceIDCleared() || m.clearedsop_node
  23199. }
  23200. // SopNodeID returns the "sop_node" edge ID in the mutation.
  23201. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  23202. if m.sop_node != nil {
  23203. return *m.sop_node, true
  23204. }
  23205. return
  23206. }
  23207. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  23208. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23209. // SopNodeID instead. It exists only for internal usage by the builders.
  23210. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  23211. if id := m.sop_node; id != nil {
  23212. ids = append(ids, *id)
  23213. }
  23214. return
  23215. }
  23216. // ResetSopNode resets all changes to the "sop_node" edge.
  23217. func (m *MessageRecordsMutation) ResetSopNode() {
  23218. m.sop_node = nil
  23219. m.clearedsop_node = false
  23220. }
  23221. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  23222. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  23223. m.message_contact = &id
  23224. }
  23225. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  23226. func (m *MessageRecordsMutation) ClearMessageContact() {
  23227. m.clearedmessage_contact = true
  23228. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  23229. }
  23230. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  23231. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  23232. return m.ContactIDCleared() || m.clearedmessage_contact
  23233. }
  23234. // MessageContactID returns the "message_contact" edge ID in the mutation.
  23235. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  23236. if m.message_contact != nil {
  23237. return *m.message_contact, true
  23238. }
  23239. return
  23240. }
  23241. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  23242. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  23243. // MessageContactID instead. It exists only for internal usage by the builders.
  23244. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  23245. if id := m.message_contact; id != nil {
  23246. ids = append(ids, *id)
  23247. }
  23248. return
  23249. }
  23250. // ResetMessageContact resets all changes to the "message_contact" edge.
  23251. func (m *MessageRecordsMutation) ResetMessageContact() {
  23252. m.message_contact = nil
  23253. m.clearedmessage_contact = false
  23254. }
  23255. // Where appends a list predicates to the MessageRecordsMutation builder.
  23256. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  23257. m.predicates = append(m.predicates, ps...)
  23258. }
  23259. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  23260. // users can use type-assertion to append predicates that do not depend on any generated package.
  23261. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  23262. p := make([]predicate.MessageRecords, len(ps))
  23263. for i := range ps {
  23264. p[i] = ps[i]
  23265. }
  23266. m.Where(p...)
  23267. }
  23268. // Op returns the operation name.
  23269. func (m *MessageRecordsMutation) Op() Op {
  23270. return m.op
  23271. }
  23272. // SetOp allows setting the mutation operation.
  23273. func (m *MessageRecordsMutation) SetOp(op Op) {
  23274. m.op = op
  23275. }
  23276. // Type returns the node type of this mutation (MessageRecords).
  23277. func (m *MessageRecordsMutation) Type() string {
  23278. return m.typ
  23279. }
  23280. // Fields returns all fields that were changed during this mutation. Note that in
  23281. // order to get all numeric fields that were incremented/decremented, call
  23282. // AddedFields().
  23283. func (m *MessageRecordsMutation) Fields() []string {
  23284. fields := make([]string, 0, 16)
  23285. if m.created_at != nil {
  23286. fields = append(fields, messagerecords.FieldCreatedAt)
  23287. }
  23288. if m.updated_at != nil {
  23289. fields = append(fields, messagerecords.FieldUpdatedAt)
  23290. }
  23291. if m.status != nil {
  23292. fields = append(fields, messagerecords.FieldStatus)
  23293. }
  23294. if m.bot_wxid != nil {
  23295. fields = append(fields, messagerecords.FieldBotWxid)
  23296. }
  23297. if m.message_contact != nil {
  23298. fields = append(fields, messagerecords.FieldContactID)
  23299. }
  23300. if m.contact_type != nil {
  23301. fields = append(fields, messagerecords.FieldContactType)
  23302. }
  23303. if m.contact_wxid != nil {
  23304. fields = append(fields, messagerecords.FieldContactWxid)
  23305. }
  23306. if m.content_type != nil {
  23307. fields = append(fields, messagerecords.FieldContentType)
  23308. }
  23309. if m.content != nil {
  23310. fields = append(fields, messagerecords.FieldContent)
  23311. }
  23312. if m.meta != nil {
  23313. fields = append(fields, messagerecords.FieldMeta)
  23314. }
  23315. if m.error_detail != nil {
  23316. fields = append(fields, messagerecords.FieldErrorDetail)
  23317. }
  23318. if m.send_time != nil {
  23319. fields = append(fields, messagerecords.FieldSendTime)
  23320. }
  23321. if m.source_type != nil {
  23322. fields = append(fields, messagerecords.FieldSourceType)
  23323. }
  23324. if m.sop_stage != nil {
  23325. fields = append(fields, messagerecords.FieldSourceID)
  23326. }
  23327. if m.sop_node != nil {
  23328. fields = append(fields, messagerecords.FieldSubSourceID)
  23329. }
  23330. if m.organization_id != nil {
  23331. fields = append(fields, messagerecords.FieldOrganizationID)
  23332. }
  23333. return fields
  23334. }
  23335. // Field returns the value of a field with the given name. The second boolean
  23336. // return value indicates that this field was not set, or was not defined in the
  23337. // schema.
  23338. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  23339. switch name {
  23340. case messagerecords.FieldCreatedAt:
  23341. return m.CreatedAt()
  23342. case messagerecords.FieldUpdatedAt:
  23343. return m.UpdatedAt()
  23344. case messagerecords.FieldStatus:
  23345. return m.Status()
  23346. case messagerecords.FieldBotWxid:
  23347. return m.BotWxid()
  23348. case messagerecords.FieldContactID:
  23349. return m.ContactID()
  23350. case messagerecords.FieldContactType:
  23351. return m.ContactType()
  23352. case messagerecords.FieldContactWxid:
  23353. return m.ContactWxid()
  23354. case messagerecords.FieldContentType:
  23355. return m.ContentType()
  23356. case messagerecords.FieldContent:
  23357. return m.Content()
  23358. case messagerecords.FieldMeta:
  23359. return m.Meta()
  23360. case messagerecords.FieldErrorDetail:
  23361. return m.ErrorDetail()
  23362. case messagerecords.FieldSendTime:
  23363. return m.SendTime()
  23364. case messagerecords.FieldSourceType:
  23365. return m.SourceType()
  23366. case messagerecords.FieldSourceID:
  23367. return m.SourceID()
  23368. case messagerecords.FieldSubSourceID:
  23369. return m.SubSourceID()
  23370. case messagerecords.FieldOrganizationID:
  23371. return m.OrganizationID()
  23372. }
  23373. return nil, false
  23374. }
  23375. // OldField returns the old value of the field from the database. An error is
  23376. // returned if the mutation operation is not UpdateOne, or the query to the
  23377. // database failed.
  23378. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23379. switch name {
  23380. case messagerecords.FieldCreatedAt:
  23381. return m.OldCreatedAt(ctx)
  23382. case messagerecords.FieldUpdatedAt:
  23383. return m.OldUpdatedAt(ctx)
  23384. case messagerecords.FieldStatus:
  23385. return m.OldStatus(ctx)
  23386. case messagerecords.FieldBotWxid:
  23387. return m.OldBotWxid(ctx)
  23388. case messagerecords.FieldContactID:
  23389. return m.OldContactID(ctx)
  23390. case messagerecords.FieldContactType:
  23391. return m.OldContactType(ctx)
  23392. case messagerecords.FieldContactWxid:
  23393. return m.OldContactWxid(ctx)
  23394. case messagerecords.FieldContentType:
  23395. return m.OldContentType(ctx)
  23396. case messagerecords.FieldContent:
  23397. return m.OldContent(ctx)
  23398. case messagerecords.FieldMeta:
  23399. return m.OldMeta(ctx)
  23400. case messagerecords.FieldErrorDetail:
  23401. return m.OldErrorDetail(ctx)
  23402. case messagerecords.FieldSendTime:
  23403. return m.OldSendTime(ctx)
  23404. case messagerecords.FieldSourceType:
  23405. return m.OldSourceType(ctx)
  23406. case messagerecords.FieldSourceID:
  23407. return m.OldSourceID(ctx)
  23408. case messagerecords.FieldSubSourceID:
  23409. return m.OldSubSourceID(ctx)
  23410. case messagerecords.FieldOrganizationID:
  23411. return m.OldOrganizationID(ctx)
  23412. }
  23413. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  23414. }
  23415. // SetField sets the value of a field with the given name. It returns an error if
  23416. // the field is not defined in the schema, or if the type mismatched the field
  23417. // type.
  23418. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  23419. switch name {
  23420. case messagerecords.FieldCreatedAt:
  23421. v, ok := value.(time.Time)
  23422. if !ok {
  23423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23424. }
  23425. m.SetCreatedAt(v)
  23426. return nil
  23427. case messagerecords.FieldUpdatedAt:
  23428. v, ok := value.(time.Time)
  23429. if !ok {
  23430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23431. }
  23432. m.SetUpdatedAt(v)
  23433. return nil
  23434. case messagerecords.FieldStatus:
  23435. v, ok := value.(uint8)
  23436. if !ok {
  23437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23438. }
  23439. m.SetStatus(v)
  23440. return nil
  23441. case messagerecords.FieldBotWxid:
  23442. v, ok := value.(string)
  23443. if !ok {
  23444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23445. }
  23446. m.SetBotWxid(v)
  23447. return nil
  23448. case messagerecords.FieldContactID:
  23449. v, ok := value.(uint64)
  23450. if !ok {
  23451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23452. }
  23453. m.SetContactID(v)
  23454. return nil
  23455. case messagerecords.FieldContactType:
  23456. v, ok := value.(int)
  23457. if !ok {
  23458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23459. }
  23460. m.SetContactType(v)
  23461. return nil
  23462. case messagerecords.FieldContactWxid:
  23463. v, ok := value.(string)
  23464. if !ok {
  23465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23466. }
  23467. m.SetContactWxid(v)
  23468. return nil
  23469. case messagerecords.FieldContentType:
  23470. v, ok := value.(int)
  23471. if !ok {
  23472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23473. }
  23474. m.SetContentType(v)
  23475. return nil
  23476. case messagerecords.FieldContent:
  23477. v, ok := value.(string)
  23478. if !ok {
  23479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23480. }
  23481. m.SetContent(v)
  23482. return nil
  23483. case messagerecords.FieldMeta:
  23484. v, ok := value.(custom_types.Meta)
  23485. if !ok {
  23486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23487. }
  23488. m.SetMeta(v)
  23489. return nil
  23490. case messagerecords.FieldErrorDetail:
  23491. v, ok := value.(string)
  23492. if !ok {
  23493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23494. }
  23495. m.SetErrorDetail(v)
  23496. return nil
  23497. case messagerecords.FieldSendTime:
  23498. v, ok := value.(time.Time)
  23499. if !ok {
  23500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23501. }
  23502. m.SetSendTime(v)
  23503. return nil
  23504. case messagerecords.FieldSourceType:
  23505. v, ok := value.(int)
  23506. if !ok {
  23507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23508. }
  23509. m.SetSourceType(v)
  23510. return nil
  23511. case messagerecords.FieldSourceID:
  23512. v, ok := value.(uint64)
  23513. if !ok {
  23514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23515. }
  23516. m.SetSourceID(v)
  23517. return nil
  23518. case messagerecords.FieldSubSourceID:
  23519. v, ok := value.(uint64)
  23520. if !ok {
  23521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23522. }
  23523. m.SetSubSourceID(v)
  23524. return nil
  23525. case messagerecords.FieldOrganizationID:
  23526. v, ok := value.(uint64)
  23527. if !ok {
  23528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23529. }
  23530. m.SetOrganizationID(v)
  23531. return nil
  23532. }
  23533. return fmt.Errorf("unknown MessageRecords field %s", name)
  23534. }
  23535. // AddedFields returns all numeric fields that were incremented/decremented during
  23536. // this mutation.
  23537. func (m *MessageRecordsMutation) AddedFields() []string {
  23538. var fields []string
  23539. if m.addstatus != nil {
  23540. fields = append(fields, messagerecords.FieldStatus)
  23541. }
  23542. if m.addcontact_type != nil {
  23543. fields = append(fields, messagerecords.FieldContactType)
  23544. }
  23545. if m.addcontent_type != nil {
  23546. fields = append(fields, messagerecords.FieldContentType)
  23547. }
  23548. if m.addsource_type != nil {
  23549. fields = append(fields, messagerecords.FieldSourceType)
  23550. }
  23551. if m.addorganization_id != nil {
  23552. fields = append(fields, messagerecords.FieldOrganizationID)
  23553. }
  23554. return fields
  23555. }
  23556. // AddedField returns the numeric value that was incremented/decremented on a field
  23557. // with the given name. The second boolean return value indicates that this field
  23558. // was not set, or was not defined in the schema.
  23559. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  23560. switch name {
  23561. case messagerecords.FieldStatus:
  23562. return m.AddedStatus()
  23563. case messagerecords.FieldContactType:
  23564. return m.AddedContactType()
  23565. case messagerecords.FieldContentType:
  23566. return m.AddedContentType()
  23567. case messagerecords.FieldSourceType:
  23568. return m.AddedSourceType()
  23569. case messagerecords.FieldOrganizationID:
  23570. return m.AddedOrganizationID()
  23571. }
  23572. return nil, false
  23573. }
  23574. // AddField adds the value to the field with the given name. It returns an error if
  23575. // the field is not defined in the schema, or if the type mismatched the field
  23576. // type.
  23577. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  23578. switch name {
  23579. case messagerecords.FieldStatus:
  23580. v, ok := value.(int8)
  23581. if !ok {
  23582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23583. }
  23584. m.AddStatus(v)
  23585. return nil
  23586. case messagerecords.FieldContactType:
  23587. v, ok := value.(int)
  23588. if !ok {
  23589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23590. }
  23591. m.AddContactType(v)
  23592. return nil
  23593. case messagerecords.FieldContentType:
  23594. v, ok := value.(int)
  23595. if !ok {
  23596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23597. }
  23598. m.AddContentType(v)
  23599. return nil
  23600. case messagerecords.FieldSourceType:
  23601. v, ok := value.(int)
  23602. if !ok {
  23603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23604. }
  23605. m.AddSourceType(v)
  23606. return nil
  23607. case messagerecords.FieldOrganizationID:
  23608. v, ok := value.(int64)
  23609. if !ok {
  23610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23611. }
  23612. m.AddOrganizationID(v)
  23613. return nil
  23614. }
  23615. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  23616. }
  23617. // ClearedFields returns all nullable fields that were cleared during this
  23618. // mutation.
  23619. func (m *MessageRecordsMutation) ClearedFields() []string {
  23620. var fields []string
  23621. if m.FieldCleared(messagerecords.FieldStatus) {
  23622. fields = append(fields, messagerecords.FieldStatus)
  23623. }
  23624. if m.FieldCleared(messagerecords.FieldContactID) {
  23625. fields = append(fields, messagerecords.FieldContactID)
  23626. }
  23627. if m.FieldCleared(messagerecords.FieldMeta) {
  23628. fields = append(fields, messagerecords.FieldMeta)
  23629. }
  23630. if m.FieldCleared(messagerecords.FieldSendTime) {
  23631. fields = append(fields, messagerecords.FieldSendTime)
  23632. }
  23633. if m.FieldCleared(messagerecords.FieldSourceID) {
  23634. fields = append(fields, messagerecords.FieldSourceID)
  23635. }
  23636. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  23637. fields = append(fields, messagerecords.FieldSubSourceID)
  23638. }
  23639. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  23640. fields = append(fields, messagerecords.FieldOrganizationID)
  23641. }
  23642. return fields
  23643. }
  23644. // FieldCleared returns a boolean indicating if a field with the given name was
  23645. // cleared in this mutation.
  23646. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  23647. _, ok := m.clearedFields[name]
  23648. return ok
  23649. }
  23650. // ClearField clears the value of the field with the given name. It returns an
  23651. // error if the field is not defined in the schema.
  23652. func (m *MessageRecordsMutation) ClearField(name string) error {
  23653. switch name {
  23654. case messagerecords.FieldStatus:
  23655. m.ClearStatus()
  23656. return nil
  23657. case messagerecords.FieldContactID:
  23658. m.ClearContactID()
  23659. return nil
  23660. case messagerecords.FieldMeta:
  23661. m.ClearMeta()
  23662. return nil
  23663. case messagerecords.FieldSendTime:
  23664. m.ClearSendTime()
  23665. return nil
  23666. case messagerecords.FieldSourceID:
  23667. m.ClearSourceID()
  23668. return nil
  23669. case messagerecords.FieldSubSourceID:
  23670. m.ClearSubSourceID()
  23671. return nil
  23672. case messagerecords.FieldOrganizationID:
  23673. m.ClearOrganizationID()
  23674. return nil
  23675. }
  23676. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  23677. }
  23678. // ResetField resets all changes in the mutation for the field with the given name.
  23679. // It returns an error if the field is not defined in the schema.
  23680. func (m *MessageRecordsMutation) ResetField(name string) error {
  23681. switch name {
  23682. case messagerecords.FieldCreatedAt:
  23683. m.ResetCreatedAt()
  23684. return nil
  23685. case messagerecords.FieldUpdatedAt:
  23686. m.ResetUpdatedAt()
  23687. return nil
  23688. case messagerecords.FieldStatus:
  23689. m.ResetStatus()
  23690. return nil
  23691. case messagerecords.FieldBotWxid:
  23692. m.ResetBotWxid()
  23693. return nil
  23694. case messagerecords.FieldContactID:
  23695. m.ResetContactID()
  23696. return nil
  23697. case messagerecords.FieldContactType:
  23698. m.ResetContactType()
  23699. return nil
  23700. case messagerecords.FieldContactWxid:
  23701. m.ResetContactWxid()
  23702. return nil
  23703. case messagerecords.FieldContentType:
  23704. m.ResetContentType()
  23705. return nil
  23706. case messagerecords.FieldContent:
  23707. m.ResetContent()
  23708. return nil
  23709. case messagerecords.FieldMeta:
  23710. m.ResetMeta()
  23711. return nil
  23712. case messagerecords.FieldErrorDetail:
  23713. m.ResetErrorDetail()
  23714. return nil
  23715. case messagerecords.FieldSendTime:
  23716. m.ResetSendTime()
  23717. return nil
  23718. case messagerecords.FieldSourceType:
  23719. m.ResetSourceType()
  23720. return nil
  23721. case messagerecords.FieldSourceID:
  23722. m.ResetSourceID()
  23723. return nil
  23724. case messagerecords.FieldSubSourceID:
  23725. m.ResetSubSourceID()
  23726. return nil
  23727. case messagerecords.FieldOrganizationID:
  23728. m.ResetOrganizationID()
  23729. return nil
  23730. }
  23731. return fmt.Errorf("unknown MessageRecords field %s", name)
  23732. }
  23733. // AddedEdges returns all edge names that were set/added in this mutation.
  23734. func (m *MessageRecordsMutation) AddedEdges() []string {
  23735. edges := make([]string, 0, 3)
  23736. if m.sop_stage != nil {
  23737. edges = append(edges, messagerecords.EdgeSopStage)
  23738. }
  23739. if m.sop_node != nil {
  23740. edges = append(edges, messagerecords.EdgeSopNode)
  23741. }
  23742. if m.message_contact != nil {
  23743. edges = append(edges, messagerecords.EdgeMessageContact)
  23744. }
  23745. return edges
  23746. }
  23747. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23748. // name in this mutation.
  23749. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  23750. switch name {
  23751. case messagerecords.EdgeSopStage:
  23752. if id := m.sop_stage; id != nil {
  23753. return []ent.Value{*id}
  23754. }
  23755. case messagerecords.EdgeSopNode:
  23756. if id := m.sop_node; id != nil {
  23757. return []ent.Value{*id}
  23758. }
  23759. case messagerecords.EdgeMessageContact:
  23760. if id := m.message_contact; id != nil {
  23761. return []ent.Value{*id}
  23762. }
  23763. }
  23764. return nil
  23765. }
  23766. // RemovedEdges returns all edge names that were removed in this mutation.
  23767. func (m *MessageRecordsMutation) RemovedEdges() []string {
  23768. edges := make([]string, 0, 3)
  23769. return edges
  23770. }
  23771. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23772. // the given name in this mutation.
  23773. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  23774. return nil
  23775. }
  23776. // ClearedEdges returns all edge names that were cleared in this mutation.
  23777. func (m *MessageRecordsMutation) ClearedEdges() []string {
  23778. edges := make([]string, 0, 3)
  23779. if m.clearedsop_stage {
  23780. edges = append(edges, messagerecords.EdgeSopStage)
  23781. }
  23782. if m.clearedsop_node {
  23783. edges = append(edges, messagerecords.EdgeSopNode)
  23784. }
  23785. if m.clearedmessage_contact {
  23786. edges = append(edges, messagerecords.EdgeMessageContact)
  23787. }
  23788. return edges
  23789. }
  23790. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23791. // was cleared in this mutation.
  23792. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  23793. switch name {
  23794. case messagerecords.EdgeSopStage:
  23795. return m.clearedsop_stage
  23796. case messagerecords.EdgeSopNode:
  23797. return m.clearedsop_node
  23798. case messagerecords.EdgeMessageContact:
  23799. return m.clearedmessage_contact
  23800. }
  23801. return false
  23802. }
  23803. // ClearEdge clears the value of the edge with the given name. It returns an error
  23804. // if that edge is not defined in the schema.
  23805. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  23806. switch name {
  23807. case messagerecords.EdgeSopStage:
  23808. m.ClearSopStage()
  23809. return nil
  23810. case messagerecords.EdgeSopNode:
  23811. m.ClearSopNode()
  23812. return nil
  23813. case messagerecords.EdgeMessageContact:
  23814. m.ClearMessageContact()
  23815. return nil
  23816. }
  23817. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  23818. }
  23819. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23820. // It returns an error if the edge is not defined in the schema.
  23821. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  23822. switch name {
  23823. case messagerecords.EdgeSopStage:
  23824. m.ResetSopStage()
  23825. return nil
  23826. case messagerecords.EdgeSopNode:
  23827. m.ResetSopNode()
  23828. return nil
  23829. case messagerecords.EdgeMessageContact:
  23830. m.ResetMessageContact()
  23831. return nil
  23832. }
  23833. return fmt.Errorf("unknown MessageRecords edge %s", name)
  23834. }
  23835. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  23836. type MsgMutation struct {
  23837. config
  23838. op Op
  23839. typ string
  23840. id *uint64
  23841. created_at *time.Time
  23842. updated_at *time.Time
  23843. deleted_at *time.Time
  23844. status *uint8
  23845. addstatus *int8
  23846. fromwxid *string
  23847. toid *string
  23848. msgtype *int32
  23849. addmsgtype *int32
  23850. msg *string
  23851. batch_no *string
  23852. cc *string
  23853. phone *string
  23854. clearedFields map[string]struct{}
  23855. done bool
  23856. oldValue func(context.Context) (*Msg, error)
  23857. predicates []predicate.Msg
  23858. }
  23859. var _ ent.Mutation = (*MsgMutation)(nil)
  23860. // msgOption allows management of the mutation configuration using functional options.
  23861. type msgOption func(*MsgMutation)
  23862. // newMsgMutation creates new mutation for the Msg entity.
  23863. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  23864. m := &MsgMutation{
  23865. config: c,
  23866. op: op,
  23867. typ: TypeMsg,
  23868. clearedFields: make(map[string]struct{}),
  23869. }
  23870. for _, opt := range opts {
  23871. opt(m)
  23872. }
  23873. return m
  23874. }
  23875. // withMsgID sets the ID field of the mutation.
  23876. func withMsgID(id uint64) msgOption {
  23877. return func(m *MsgMutation) {
  23878. var (
  23879. err error
  23880. once sync.Once
  23881. value *Msg
  23882. )
  23883. m.oldValue = func(ctx context.Context) (*Msg, error) {
  23884. once.Do(func() {
  23885. if m.done {
  23886. err = errors.New("querying old values post mutation is not allowed")
  23887. } else {
  23888. value, err = m.Client().Msg.Get(ctx, id)
  23889. }
  23890. })
  23891. return value, err
  23892. }
  23893. m.id = &id
  23894. }
  23895. }
  23896. // withMsg sets the old Msg of the mutation.
  23897. func withMsg(node *Msg) msgOption {
  23898. return func(m *MsgMutation) {
  23899. m.oldValue = func(context.Context) (*Msg, error) {
  23900. return node, nil
  23901. }
  23902. m.id = &node.ID
  23903. }
  23904. }
  23905. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23906. // executed in a transaction (ent.Tx), a transactional client is returned.
  23907. func (m MsgMutation) Client() *Client {
  23908. client := &Client{config: m.config}
  23909. client.init()
  23910. return client
  23911. }
  23912. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23913. // it returns an error otherwise.
  23914. func (m MsgMutation) Tx() (*Tx, error) {
  23915. if _, ok := m.driver.(*txDriver); !ok {
  23916. return nil, errors.New("ent: mutation is not running in a transaction")
  23917. }
  23918. tx := &Tx{config: m.config}
  23919. tx.init()
  23920. return tx, nil
  23921. }
  23922. // SetID sets the value of the id field. Note that this
  23923. // operation is only accepted on creation of Msg entities.
  23924. func (m *MsgMutation) SetID(id uint64) {
  23925. m.id = &id
  23926. }
  23927. // ID returns the ID value in the mutation. Note that the ID is only available
  23928. // if it was provided to the builder or after it was returned from the database.
  23929. func (m *MsgMutation) ID() (id uint64, exists bool) {
  23930. if m.id == nil {
  23931. return
  23932. }
  23933. return *m.id, true
  23934. }
  23935. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23936. // That means, if the mutation is applied within a transaction with an isolation level such
  23937. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23938. // or updated by the mutation.
  23939. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  23940. switch {
  23941. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23942. id, exists := m.ID()
  23943. if exists {
  23944. return []uint64{id}, nil
  23945. }
  23946. fallthrough
  23947. case m.op.Is(OpUpdate | OpDelete):
  23948. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  23949. default:
  23950. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23951. }
  23952. }
  23953. // SetCreatedAt sets the "created_at" field.
  23954. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  23955. m.created_at = &t
  23956. }
  23957. // CreatedAt returns the value of the "created_at" field in the mutation.
  23958. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  23959. v := m.created_at
  23960. if v == nil {
  23961. return
  23962. }
  23963. return *v, true
  23964. }
  23965. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  23966. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23968. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23969. if !m.op.Is(OpUpdateOne) {
  23970. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23971. }
  23972. if m.id == nil || m.oldValue == nil {
  23973. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23974. }
  23975. oldValue, err := m.oldValue(ctx)
  23976. if err != nil {
  23977. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23978. }
  23979. return oldValue.CreatedAt, nil
  23980. }
  23981. // ResetCreatedAt resets all changes to the "created_at" field.
  23982. func (m *MsgMutation) ResetCreatedAt() {
  23983. m.created_at = nil
  23984. }
  23985. // SetUpdatedAt sets the "updated_at" field.
  23986. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  23987. m.updated_at = &t
  23988. }
  23989. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23990. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  23991. v := m.updated_at
  23992. if v == nil {
  23993. return
  23994. }
  23995. return *v, true
  23996. }
  23997. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  23998. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  23999. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24000. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24001. if !m.op.Is(OpUpdateOne) {
  24002. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24003. }
  24004. if m.id == nil || m.oldValue == nil {
  24005. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24006. }
  24007. oldValue, err := m.oldValue(ctx)
  24008. if err != nil {
  24009. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24010. }
  24011. return oldValue.UpdatedAt, nil
  24012. }
  24013. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24014. func (m *MsgMutation) ResetUpdatedAt() {
  24015. m.updated_at = nil
  24016. }
  24017. // SetDeletedAt sets the "deleted_at" field.
  24018. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  24019. m.deleted_at = &t
  24020. }
  24021. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24022. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  24023. v := m.deleted_at
  24024. if v == nil {
  24025. return
  24026. }
  24027. return *v, true
  24028. }
  24029. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  24030. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24032. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24033. if !m.op.Is(OpUpdateOne) {
  24034. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24035. }
  24036. if m.id == nil || m.oldValue == nil {
  24037. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24038. }
  24039. oldValue, err := m.oldValue(ctx)
  24040. if err != nil {
  24041. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24042. }
  24043. return oldValue.DeletedAt, nil
  24044. }
  24045. // ClearDeletedAt clears the value of the "deleted_at" field.
  24046. func (m *MsgMutation) ClearDeletedAt() {
  24047. m.deleted_at = nil
  24048. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  24049. }
  24050. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24051. func (m *MsgMutation) DeletedAtCleared() bool {
  24052. _, ok := m.clearedFields[msg.FieldDeletedAt]
  24053. return ok
  24054. }
  24055. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24056. func (m *MsgMutation) ResetDeletedAt() {
  24057. m.deleted_at = nil
  24058. delete(m.clearedFields, msg.FieldDeletedAt)
  24059. }
  24060. // SetStatus sets the "status" field.
  24061. func (m *MsgMutation) SetStatus(u uint8) {
  24062. m.status = &u
  24063. m.addstatus = nil
  24064. }
  24065. // Status returns the value of the "status" field in the mutation.
  24066. func (m *MsgMutation) Status() (r uint8, exists bool) {
  24067. v := m.status
  24068. if v == nil {
  24069. return
  24070. }
  24071. return *v, true
  24072. }
  24073. // OldStatus returns the old "status" field's value of the Msg entity.
  24074. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24076. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24077. if !m.op.Is(OpUpdateOne) {
  24078. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24079. }
  24080. if m.id == nil || m.oldValue == nil {
  24081. return v, errors.New("OldStatus requires an ID field in the mutation")
  24082. }
  24083. oldValue, err := m.oldValue(ctx)
  24084. if err != nil {
  24085. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24086. }
  24087. return oldValue.Status, nil
  24088. }
  24089. // AddStatus adds u to the "status" field.
  24090. func (m *MsgMutation) AddStatus(u int8) {
  24091. if m.addstatus != nil {
  24092. *m.addstatus += u
  24093. } else {
  24094. m.addstatus = &u
  24095. }
  24096. }
  24097. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24098. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  24099. v := m.addstatus
  24100. if v == nil {
  24101. return
  24102. }
  24103. return *v, true
  24104. }
  24105. // ClearStatus clears the value of the "status" field.
  24106. func (m *MsgMutation) ClearStatus() {
  24107. m.status = nil
  24108. m.addstatus = nil
  24109. m.clearedFields[msg.FieldStatus] = struct{}{}
  24110. }
  24111. // StatusCleared returns if the "status" field was cleared in this mutation.
  24112. func (m *MsgMutation) StatusCleared() bool {
  24113. _, ok := m.clearedFields[msg.FieldStatus]
  24114. return ok
  24115. }
  24116. // ResetStatus resets all changes to the "status" field.
  24117. func (m *MsgMutation) ResetStatus() {
  24118. m.status = nil
  24119. m.addstatus = nil
  24120. delete(m.clearedFields, msg.FieldStatus)
  24121. }
  24122. // SetFromwxid sets the "fromwxid" field.
  24123. func (m *MsgMutation) SetFromwxid(s string) {
  24124. m.fromwxid = &s
  24125. }
  24126. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  24127. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  24128. v := m.fromwxid
  24129. if v == nil {
  24130. return
  24131. }
  24132. return *v, true
  24133. }
  24134. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  24135. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24137. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  24138. if !m.op.Is(OpUpdateOne) {
  24139. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  24140. }
  24141. if m.id == nil || m.oldValue == nil {
  24142. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  24143. }
  24144. oldValue, err := m.oldValue(ctx)
  24145. if err != nil {
  24146. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  24147. }
  24148. return oldValue.Fromwxid, nil
  24149. }
  24150. // ClearFromwxid clears the value of the "fromwxid" field.
  24151. func (m *MsgMutation) ClearFromwxid() {
  24152. m.fromwxid = nil
  24153. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  24154. }
  24155. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  24156. func (m *MsgMutation) FromwxidCleared() bool {
  24157. _, ok := m.clearedFields[msg.FieldFromwxid]
  24158. return ok
  24159. }
  24160. // ResetFromwxid resets all changes to the "fromwxid" field.
  24161. func (m *MsgMutation) ResetFromwxid() {
  24162. m.fromwxid = nil
  24163. delete(m.clearedFields, msg.FieldFromwxid)
  24164. }
  24165. // SetToid sets the "toid" field.
  24166. func (m *MsgMutation) SetToid(s string) {
  24167. m.toid = &s
  24168. }
  24169. // Toid returns the value of the "toid" field in the mutation.
  24170. func (m *MsgMutation) Toid() (r string, exists bool) {
  24171. v := m.toid
  24172. if v == nil {
  24173. return
  24174. }
  24175. return *v, true
  24176. }
  24177. // OldToid returns the old "toid" field's value of the Msg entity.
  24178. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24180. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  24181. if !m.op.Is(OpUpdateOne) {
  24182. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  24183. }
  24184. if m.id == nil || m.oldValue == nil {
  24185. return v, errors.New("OldToid requires an ID field in the mutation")
  24186. }
  24187. oldValue, err := m.oldValue(ctx)
  24188. if err != nil {
  24189. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  24190. }
  24191. return oldValue.Toid, nil
  24192. }
  24193. // ClearToid clears the value of the "toid" field.
  24194. func (m *MsgMutation) ClearToid() {
  24195. m.toid = nil
  24196. m.clearedFields[msg.FieldToid] = struct{}{}
  24197. }
  24198. // ToidCleared returns if the "toid" field was cleared in this mutation.
  24199. func (m *MsgMutation) ToidCleared() bool {
  24200. _, ok := m.clearedFields[msg.FieldToid]
  24201. return ok
  24202. }
  24203. // ResetToid resets all changes to the "toid" field.
  24204. func (m *MsgMutation) ResetToid() {
  24205. m.toid = nil
  24206. delete(m.clearedFields, msg.FieldToid)
  24207. }
  24208. // SetMsgtype sets the "msgtype" field.
  24209. func (m *MsgMutation) SetMsgtype(i int32) {
  24210. m.msgtype = &i
  24211. m.addmsgtype = nil
  24212. }
  24213. // Msgtype returns the value of the "msgtype" field in the mutation.
  24214. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  24215. v := m.msgtype
  24216. if v == nil {
  24217. return
  24218. }
  24219. return *v, true
  24220. }
  24221. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  24222. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24224. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  24225. if !m.op.Is(OpUpdateOne) {
  24226. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  24227. }
  24228. if m.id == nil || m.oldValue == nil {
  24229. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  24230. }
  24231. oldValue, err := m.oldValue(ctx)
  24232. if err != nil {
  24233. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  24234. }
  24235. return oldValue.Msgtype, nil
  24236. }
  24237. // AddMsgtype adds i to the "msgtype" field.
  24238. func (m *MsgMutation) AddMsgtype(i int32) {
  24239. if m.addmsgtype != nil {
  24240. *m.addmsgtype += i
  24241. } else {
  24242. m.addmsgtype = &i
  24243. }
  24244. }
  24245. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  24246. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  24247. v := m.addmsgtype
  24248. if v == nil {
  24249. return
  24250. }
  24251. return *v, true
  24252. }
  24253. // ClearMsgtype clears the value of the "msgtype" field.
  24254. func (m *MsgMutation) ClearMsgtype() {
  24255. m.msgtype = nil
  24256. m.addmsgtype = nil
  24257. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  24258. }
  24259. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  24260. func (m *MsgMutation) MsgtypeCleared() bool {
  24261. _, ok := m.clearedFields[msg.FieldMsgtype]
  24262. return ok
  24263. }
  24264. // ResetMsgtype resets all changes to the "msgtype" field.
  24265. func (m *MsgMutation) ResetMsgtype() {
  24266. m.msgtype = nil
  24267. m.addmsgtype = nil
  24268. delete(m.clearedFields, msg.FieldMsgtype)
  24269. }
  24270. // SetMsg sets the "msg" field.
  24271. func (m *MsgMutation) SetMsg(s string) {
  24272. m.msg = &s
  24273. }
  24274. // Msg returns the value of the "msg" field in the mutation.
  24275. func (m *MsgMutation) Msg() (r string, exists bool) {
  24276. v := m.msg
  24277. if v == nil {
  24278. return
  24279. }
  24280. return *v, true
  24281. }
  24282. // OldMsg returns the old "msg" field's value of the Msg entity.
  24283. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24285. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  24286. if !m.op.Is(OpUpdateOne) {
  24287. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  24288. }
  24289. if m.id == nil || m.oldValue == nil {
  24290. return v, errors.New("OldMsg requires an ID field in the mutation")
  24291. }
  24292. oldValue, err := m.oldValue(ctx)
  24293. if err != nil {
  24294. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  24295. }
  24296. return oldValue.Msg, nil
  24297. }
  24298. // ClearMsg clears the value of the "msg" field.
  24299. func (m *MsgMutation) ClearMsg() {
  24300. m.msg = nil
  24301. m.clearedFields[msg.FieldMsg] = struct{}{}
  24302. }
  24303. // MsgCleared returns if the "msg" field was cleared in this mutation.
  24304. func (m *MsgMutation) MsgCleared() bool {
  24305. _, ok := m.clearedFields[msg.FieldMsg]
  24306. return ok
  24307. }
  24308. // ResetMsg resets all changes to the "msg" field.
  24309. func (m *MsgMutation) ResetMsg() {
  24310. m.msg = nil
  24311. delete(m.clearedFields, msg.FieldMsg)
  24312. }
  24313. // SetBatchNo sets the "batch_no" field.
  24314. func (m *MsgMutation) SetBatchNo(s string) {
  24315. m.batch_no = &s
  24316. }
  24317. // BatchNo returns the value of the "batch_no" field in the mutation.
  24318. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  24319. v := m.batch_no
  24320. if v == nil {
  24321. return
  24322. }
  24323. return *v, true
  24324. }
  24325. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  24326. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24328. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  24329. if !m.op.Is(OpUpdateOne) {
  24330. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  24331. }
  24332. if m.id == nil || m.oldValue == nil {
  24333. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  24334. }
  24335. oldValue, err := m.oldValue(ctx)
  24336. if err != nil {
  24337. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  24338. }
  24339. return oldValue.BatchNo, nil
  24340. }
  24341. // ClearBatchNo clears the value of the "batch_no" field.
  24342. func (m *MsgMutation) ClearBatchNo() {
  24343. m.batch_no = nil
  24344. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  24345. }
  24346. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  24347. func (m *MsgMutation) BatchNoCleared() bool {
  24348. _, ok := m.clearedFields[msg.FieldBatchNo]
  24349. return ok
  24350. }
  24351. // ResetBatchNo resets all changes to the "batch_no" field.
  24352. func (m *MsgMutation) ResetBatchNo() {
  24353. m.batch_no = nil
  24354. delete(m.clearedFields, msg.FieldBatchNo)
  24355. }
  24356. // SetCc sets the "cc" field.
  24357. func (m *MsgMutation) SetCc(s string) {
  24358. m.cc = &s
  24359. }
  24360. // Cc returns the value of the "cc" field in the mutation.
  24361. func (m *MsgMutation) Cc() (r string, exists bool) {
  24362. v := m.cc
  24363. if v == nil {
  24364. return
  24365. }
  24366. return *v, true
  24367. }
  24368. // OldCc returns the old "cc" field's value of the Msg entity.
  24369. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24371. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  24372. if !m.op.Is(OpUpdateOne) {
  24373. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  24374. }
  24375. if m.id == nil || m.oldValue == nil {
  24376. return v, errors.New("OldCc requires an ID field in the mutation")
  24377. }
  24378. oldValue, err := m.oldValue(ctx)
  24379. if err != nil {
  24380. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  24381. }
  24382. return oldValue.Cc, nil
  24383. }
  24384. // ResetCc resets all changes to the "cc" field.
  24385. func (m *MsgMutation) ResetCc() {
  24386. m.cc = nil
  24387. }
  24388. // SetPhone sets the "phone" field.
  24389. func (m *MsgMutation) SetPhone(s string) {
  24390. m.phone = &s
  24391. }
  24392. // Phone returns the value of the "phone" field in the mutation.
  24393. func (m *MsgMutation) Phone() (r string, exists bool) {
  24394. v := m.phone
  24395. if v == nil {
  24396. return
  24397. }
  24398. return *v, true
  24399. }
  24400. // OldPhone returns the old "phone" field's value of the Msg entity.
  24401. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  24402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24403. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  24404. if !m.op.Is(OpUpdateOne) {
  24405. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  24406. }
  24407. if m.id == nil || m.oldValue == nil {
  24408. return v, errors.New("OldPhone requires an ID field in the mutation")
  24409. }
  24410. oldValue, err := m.oldValue(ctx)
  24411. if err != nil {
  24412. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  24413. }
  24414. return oldValue.Phone, nil
  24415. }
  24416. // ResetPhone resets all changes to the "phone" field.
  24417. func (m *MsgMutation) ResetPhone() {
  24418. m.phone = nil
  24419. }
  24420. // Where appends a list predicates to the MsgMutation builder.
  24421. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  24422. m.predicates = append(m.predicates, ps...)
  24423. }
  24424. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  24425. // users can use type-assertion to append predicates that do not depend on any generated package.
  24426. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  24427. p := make([]predicate.Msg, len(ps))
  24428. for i := range ps {
  24429. p[i] = ps[i]
  24430. }
  24431. m.Where(p...)
  24432. }
  24433. // Op returns the operation name.
  24434. func (m *MsgMutation) Op() Op {
  24435. return m.op
  24436. }
  24437. // SetOp allows setting the mutation operation.
  24438. func (m *MsgMutation) SetOp(op Op) {
  24439. m.op = op
  24440. }
  24441. // Type returns the node type of this mutation (Msg).
  24442. func (m *MsgMutation) Type() string {
  24443. return m.typ
  24444. }
  24445. // Fields returns all fields that were changed during this mutation. Note that in
  24446. // order to get all numeric fields that were incremented/decremented, call
  24447. // AddedFields().
  24448. func (m *MsgMutation) Fields() []string {
  24449. fields := make([]string, 0, 11)
  24450. if m.created_at != nil {
  24451. fields = append(fields, msg.FieldCreatedAt)
  24452. }
  24453. if m.updated_at != nil {
  24454. fields = append(fields, msg.FieldUpdatedAt)
  24455. }
  24456. if m.deleted_at != nil {
  24457. fields = append(fields, msg.FieldDeletedAt)
  24458. }
  24459. if m.status != nil {
  24460. fields = append(fields, msg.FieldStatus)
  24461. }
  24462. if m.fromwxid != nil {
  24463. fields = append(fields, msg.FieldFromwxid)
  24464. }
  24465. if m.toid != nil {
  24466. fields = append(fields, msg.FieldToid)
  24467. }
  24468. if m.msgtype != nil {
  24469. fields = append(fields, msg.FieldMsgtype)
  24470. }
  24471. if m.msg != nil {
  24472. fields = append(fields, msg.FieldMsg)
  24473. }
  24474. if m.batch_no != nil {
  24475. fields = append(fields, msg.FieldBatchNo)
  24476. }
  24477. if m.cc != nil {
  24478. fields = append(fields, msg.FieldCc)
  24479. }
  24480. if m.phone != nil {
  24481. fields = append(fields, msg.FieldPhone)
  24482. }
  24483. return fields
  24484. }
  24485. // Field returns the value of a field with the given name. The second boolean
  24486. // return value indicates that this field was not set, or was not defined in the
  24487. // schema.
  24488. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  24489. switch name {
  24490. case msg.FieldCreatedAt:
  24491. return m.CreatedAt()
  24492. case msg.FieldUpdatedAt:
  24493. return m.UpdatedAt()
  24494. case msg.FieldDeletedAt:
  24495. return m.DeletedAt()
  24496. case msg.FieldStatus:
  24497. return m.Status()
  24498. case msg.FieldFromwxid:
  24499. return m.Fromwxid()
  24500. case msg.FieldToid:
  24501. return m.Toid()
  24502. case msg.FieldMsgtype:
  24503. return m.Msgtype()
  24504. case msg.FieldMsg:
  24505. return m.Msg()
  24506. case msg.FieldBatchNo:
  24507. return m.BatchNo()
  24508. case msg.FieldCc:
  24509. return m.Cc()
  24510. case msg.FieldPhone:
  24511. return m.Phone()
  24512. }
  24513. return nil, false
  24514. }
  24515. // OldField returns the old value of the field from the database. An error is
  24516. // returned if the mutation operation is not UpdateOne, or the query to the
  24517. // database failed.
  24518. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24519. switch name {
  24520. case msg.FieldCreatedAt:
  24521. return m.OldCreatedAt(ctx)
  24522. case msg.FieldUpdatedAt:
  24523. return m.OldUpdatedAt(ctx)
  24524. case msg.FieldDeletedAt:
  24525. return m.OldDeletedAt(ctx)
  24526. case msg.FieldStatus:
  24527. return m.OldStatus(ctx)
  24528. case msg.FieldFromwxid:
  24529. return m.OldFromwxid(ctx)
  24530. case msg.FieldToid:
  24531. return m.OldToid(ctx)
  24532. case msg.FieldMsgtype:
  24533. return m.OldMsgtype(ctx)
  24534. case msg.FieldMsg:
  24535. return m.OldMsg(ctx)
  24536. case msg.FieldBatchNo:
  24537. return m.OldBatchNo(ctx)
  24538. case msg.FieldCc:
  24539. return m.OldCc(ctx)
  24540. case msg.FieldPhone:
  24541. return m.OldPhone(ctx)
  24542. }
  24543. return nil, fmt.Errorf("unknown Msg field %s", name)
  24544. }
  24545. // SetField sets the value of a field with the given name. It returns an error if
  24546. // the field is not defined in the schema, or if the type mismatched the field
  24547. // type.
  24548. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  24549. switch name {
  24550. case msg.FieldCreatedAt:
  24551. v, ok := value.(time.Time)
  24552. if !ok {
  24553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24554. }
  24555. m.SetCreatedAt(v)
  24556. return nil
  24557. case msg.FieldUpdatedAt:
  24558. v, ok := value.(time.Time)
  24559. if !ok {
  24560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24561. }
  24562. m.SetUpdatedAt(v)
  24563. return nil
  24564. case msg.FieldDeletedAt:
  24565. v, ok := value.(time.Time)
  24566. if !ok {
  24567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24568. }
  24569. m.SetDeletedAt(v)
  24570. return nil
  24571. case msg.FieldStatus:
  24572. v, ok := value.(uint8)
  24573. if !ok {
  24574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24575. }
  24576. m.SetStatus(v)
  24577. return nil
  24578. case msg.FieldFromwxid:
  24579. v, ok := value.(string)
  24580. if !ok {
  24581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24582. }
  24583. m.SetFromwxid(v)
  24584. return nil
  24585. case msg.FieldToid:
  24586. v, ok := value.(string)
  24587. if !ok {
  24588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24589. }
  24590. m.SetToid(v)
  24591. return nil
  24592. case msg.FieldMsgtype:
  24593. v, ok := value.(int32)
  24594. if !ok {
  24595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24596. }
  24597. m.SetMsgtype(v)
  24598. return nil
  24599. case msg.FieldMsg:
  24600. v, ok := value.(string)
  24601. if !ok {
  24602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24603. }
  24604. m.SetMsg(v)
  24605. return nil
  24606. case msg.FieldBatchNo:
  24607. v, ok := value.(string)
  24608. if !ok {
  24609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24610. }
  24611. m.SetBatchNo(v)
  24612. return nil
  24613. case msg.FieldCc:
  24614. v, ok := value.(string)
  24615. if !ok {
  24616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24617. }
  24618. m.SetCc(v)
  24619. return nil
  24620. case msg.FieldPhone:
  24621. v, ok := value.(string)
  24622. if !ok {
  24623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24624. }
  24625. m.SetPhone(v)
  24626. return nil
  24627. }
  24628. return fmt.Errorf("unknown Msg field %s", name)
  24629. }
  24630. // AddedFields returns all numeric fields that were incremented/decremented during
  24631. // this mutation.
  24632. func (m *MsgMutation) AddedFields() []string {
  24633. var fields []string
  24634. if m.addstatus != nil {
  24635. fields = append(fields, msg.FieldStatus)
  24636. }
  24637. if m.addmsgtype != nil {
  24638. fields = append(fields, msg.FieldMsgtype)
  24639. }
  24640. return fields
  24641. }
  24642. // AddedField returns the numeric value that was incremented/decremented on a field
  24643. // with the given name. The second boolean return value indicates that this field
  24644. // was not set, or was not defined in the schema.
  24645. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  24646. switch name {
  24647. case msg.FieldStatus:
  24648. return m.AddedStatus()
  24649. case msg.FieldMsgtype:
  24650. return m.AddedMsgtype()
  24651. }
  24652. return nil, false
  24653. }
  24654. // AddField adds the value to the field with the given name. It returns an error if
  24655. // the field is not defined in the schema, or if the type mismatched the field
  24656. // type.
  24657. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  24658. switch name {
  24659. case msg.FieldStatus:
  24660. v, ok := value.(int8)
  24661. if !ok {
  24662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24663. }
  24664. m.AddStatus(v)
  24665. return nil
  24666. case msg.FieldMsgtype:
  24667. v, ok := value.(int32)
  24668. if !ok {
  24669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24670. }
  24671. m.AddMsgtype(v)
  24672. return nil
  24673. }
  24674. return fmt.Errorf("unknown Msg numeric field %s", name)
  24675. }
  24676. // ClearedFields returns all nullable fields that were cleared during this
  24677. // mutation.
  24678. func (m *MsgMutation) ClearedFields() []string {
  24679. var fields []string
  24680. if m.FieldCleared(msg.FieldDeletedAt) {
  24681. fields = append(fields, msg.FieldDeletedAt)
  24682. }
  24683. if m.FieldCleared(msg.FieldStatus) {
  24684. fields = append(fields, msg.FieldStatus)
  24685. }
  24686. if m.FieldCleared(msg.FieldFromwxid) {
  24687. fields = append(fields, msg.FieldFromwxid)
  24688. }
  24689. if m.FieldCleared(msg.FieldToid) {
  24690. fields = append(fields, msg.FieldToid)
  24691. }
  24692. if m.FieldCleared(msg.FieldMsgtype) {
  24693. fields = append(fields, msg.FieldMsgtype)
  24694. }
  24695. if m.FieldCleared(msg.FieldMsg) {
  24696. fields = append(fields, msg.FieldMsg)
  24697. }
  24698. if m.FieldCleared(msg.FieldBatchNo) {
  24699. fields = append(fields, msg.FieldBatchNo)
  24700. }
  24701. return fields
  24702. }
  24703. // FieldCleared returns a boolean indicating if a field with the given name was
  24704. // cleared in this mutation.
  24705. func (m *MsgMutation) FieldCleared(name string) bool {
  24706. _, ok := m.clearedFields[name]
  24707. return ok
  24708. }
  24709. // ClearField clears the value of the field with the given name. It returns an
  24710. // error if the field is not defined in the schema.
  24711. func (m *MsgMutation) ClearField(name string) error {
  24712. switch name {
  24713. case msg.FieldDeletedAt:
  24714. m.ClearDeletedAt()
  24715. return nil
  24716. case msg.FieldStatus:
  24717. m.ClearStatus()
  24718. return nil
  24719. case msg.FieldFromwxid:
  24720. m.ClearFromwxid()
  24721. return nil
  24722. case msg.FieldToid:
  24723. m.ClearToid()
  24724. return nil
  24725. case msg.FieldMsgtype:
  24726. m.ClearMsgtype()
  24727. return nil
  24728. case msg.FieldMsg:
  24729. m.ClearMsg()
  24730. return nil
  24731. case msg.FieldBatchNo:
  24732. m.ClearBatchNo()
  24733. return nil
  24734. }
  24735. return fmt.Errorf("unknown Msg nullable field %s", name)
  24736. }
  24737. // ResetField resets all changes in the mutation for the field with the given name.
  24738. // It returns an error if the field is not defined in the schema.
  24739. func (m *MsgMutation) ResetField(name string) error {
  24740. switch name {
  24741. case msg.FieldCreatedAt:
  24742. m.ResetCreatedAt()
  24743. return nil
  24744. case msg.FieldUpdatedAt:
  24745. m.ResetUpdatedAt()
  24746. return nil
  24747. case msg.FieldDeletedAt:
  24748. m.ResetDeletedAt()
  24749. return nil
  24750. case msg.FieldStatus:
  24751. m.ResetStatus()
  24752. return nil
  24753. case msg.FieldFromwxid:
  24754. m.ResetFromwxid()
  24755. return nil
  24756. case msg.FieldToid:
  24757. m.ResetToid()
  24758. return nil
  24759. case msg.FieldMsgtype:
  24760. m.ResetMsgtype()
  24761. return nil
  24762. case msg.FieldMsg:
  24763. m.ResetMsg()
  24764. return nil
  24765. case msg.FieldBatchNo:
  24766. m.ResetBatchNo()
  24767. return nil
  24768. case msg.FieldCc:
  24769. m.ResetCc()
  24770. return nil
  24771. case msg.FieldPhone:
  24772. m.ResetPhone()
  24773. return nil
  24774. }
  24775. return fmt.Errorf("unknown Msg field %s", name)
  24776. }
  24777. // AddedEdges returns all edge names that were set/added in this mutation.
  24778. func (m *MsgMutation) AddedEdges() []string {
  24779. edges := make([]string, 0, 0)
  24780. return edges
  24781. }
  24782. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24783. // name in this mutation.
  24784. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  24785. return nil
  24786. }
  24787. // RemovedEdges returns all edge names that were removed in this mutation.
  24788. func (m *MsgMutation) RemovedEdges() []string {
  24789. edges := make([]string, 0, 0)
  24790. return edges
  24791. }
  24792. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24793. // the given name in this mutation.
  24794. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  24795. return nil
  24796. }
  24797. // ClearedEdges returns all edge names that were cleared in this mutation.
  24798. func (m *MsgMutation) ClearedEdges() []string {
  24799. edges := make([]string, 0, 0)
  24800. return edges
  24801. }
  24802. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24803. // was cleared in this mutation.
  24804. func (m *MsgMutation) EdgeCleared(name string) bool {
  24805. return false
  24806. }
  24807. // ClearEdge clears the value of the edge with the given name. It returns an error
  24808. // if that edge is not defined in the schema.
  24809. func (m *MsgMutation) ClearEdge(name string) error {
  24810. return fmt.Errorf("unknown Msg unique edge %s", name)
  24811. }
  24812. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24813. // It returns an error if the edge is not defined in the schema.
  24814. func (m *MsgMutation) ResetEdge(name string) error {
  24815. return fmt.Errorf("unknown Msg edge %s", name)
  24816. }
  24817. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  24818. type PayRechargeMutation struct {
  24819. config
  24820. op Op
  24821. typ string
  24822. id *uint64
  24823. created_at *time.Time
  24824. updated_at *time.Time
  24825. deleted_at *time.Time
  24826. user_id *string
  24827. number *float32
  24828. addnumber *float32
  24829. status *int
  24830. addstatus *int
  24831. money *float32
  24832. addmoney *float32
  24833. out_trade_no *string
  24834. organization_id *uint64
  24835. addorganization_id *int64
  24836. clearedFields map[string]struct{}
  24837. done bool
  24838. oldValue func(context.Context) (*PayRecharge, error)
  24839. predicates []predicate.PayRecharge
  24840. }
  24841. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  24842. // payrechargeOption allows management of the mutation configuration using functional options.
  24843. type payrechargeOption func(*PayRechargeMutation)
  24844. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  24845. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  24846. m := &PayRechargeMutation{
  24847. config: c,
  24848. op: op,
  24849. typ: TypePayRecharge,
  24850. clearedFields: make(map[string]struct{}),
  24851. }
  24852. for _, opt := range opts {
  24853. opt(m)
  24854. }
  24855. return m
  24856. }
  24857. // withPayRechargeID sets the ID field of the mutation.
  24858. func withPayRechargeID(id uint64) payrechargeOption {
  24859. return func(m *PayRechargeMutation) {
  24860. var (
  24861. err error
  24862. once sync.Once
  24863. value *PayRecharge
  24864. )
  24865. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  24866. once.Do(func() {
  24867. if m.done {
  24868. err = errors.New("querying old values post mutation is not allowed")
  24869. } else {
  24870. value, err = m.Client().PayRecharge.Get(ctx, id)
  24871. }
  24872. })
  24873. return value, err
  24874. }
  24875. m.id = &id
  24876. }
  24877. }
  24878. // withPayRecharge sets the old PayRecharge of the mutation.
  24879. func withPayRecharge(node *PayRecharge) payrechargeOption {
  24880. return func(m *PayRechargeMutation) {
  24881. m.oldValue = func(context.Context) (*PayRecharge, error) {
  24882. return node, nil
  24883. }
  24884. m.id = &node.ID
  24885. }
  24886. }
  24887. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24888. // executed in a transaction (ent.Tx), a transactional client is returned.
  24889. func (m PayRechargeMutation) Client() *Client {
  24890. client := &Client{config: m.config}
  24891. client.init()
  24892. return client
  24893. }
  24894. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24895. // it returns an error otherwise.
  24896. func (m PayRechargeMutation) Tx() (*Tx, error) {
  24897. if _, ok := m.driver.(*txDriver); !ok {
  24898. return nil, errors.New("ent: mutation is not running in a transaction")
  24899. }
  24900. tx := &Tx{config: m.config}
  24901. tx.init()
  24902. return tx, nil
  24903. }
  24904. // SetID sets the value of the id field. Note that this
  24905. // operation is only accepted on creation of PayRecharge entities.
  24906. func (m *PayRechargeMutation) SetID(id uint64) {
  24907. m.id = &id
  24908. }
  24909. // ID returns the ID value in the mutation. Note that the ID is only available
  24910. // if it was provided to the builder or after it was returned from the database.
  24911. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  24912. if m.id == nil {
  24913. return
  24914. }
  24915. return *m.id, true
  24916. }
  24917. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24918. // That means, if the mutation is applied within a transaction with an isolation level such
  24919. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24920. // or updated by the mutation.
  24921. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24922. switch {
  24923. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24924. id, exists := m.ID()
  24925. if exists {
  24926. return []uint64{id}, nil
  24927. }
  24928. fallthrough
  24929. case m.op.Is(OpUpdate | OpDelete):
  24930. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  24931. default:
  24932. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24933. }
  24934. }
  24935. // SetCreatedAt sets the "created_at" field.
  24936. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  24937. m.created_at = &t
  24938. }
  24939. // CreatedAt returns the value of the "created_at" field in the mutation.
  24940. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  24941. v := m.created_at
  24942. if v == nil {
  24943. return
  24944. }
  24945. return *v, true
  24946. }
  24947. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  24948. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24950. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24951. if !m.op.Is(OpUpdateOne) {
  24952. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24953. }
  24954. if m.id == nil || m.oldValue == nil {
  24955. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24956. }
  24957. oldValue, err := m.oldValue(ctx)
  24958. if err != nil {
  24959. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24960. }
  24961. return oldValue.CreatedAt, nil
  24962. }
  24963. // ResetCreatedAt resets all changes to the "created_at" field.
  24964. func (m *PayRechargeMutation) ResetCreatedAt() {
  24965. m.created_at = nil
  24966. }
  24967. // SetUpdatedAt sets the "updated_at" field.
  24968. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  24969. m.updated_at = &t
  24970. }
  24971. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24972. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  24973. v := m.updated_at
  24974. if v == nil {
  24975. return
  24976. }
  24977. return *v, true
  24978. }
  24979. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  24980. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  24981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24982. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24983. if !m.op.Is(OpUpdateOne) {
  24984. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24985. }
  24986. if m.id == nil || m.oldValue == nil {
  24987. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24988. }
  24989. oldValue, err := m.oldValue(ctx)
  24990. if err != nil {
  24991. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24992. }
  24993. return oldValue.UpdatedAt, nil
  24994. }
  24995. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24996. func (m *PayRechargeMutation) ResetUpdatedAt() {
  24997. m.updated_at = nil
  24998. }
  24999. // SetDeletedAt sets the "deleted_at" field.
  25000. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  25001. m.deleted_at = &t
  25002. }
  25003. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25004. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  25005. v := m.deleted_at
  25006. if v == nil {
  25007. return
  25008. }
  25009. return *v, true
  25010. }
  25011. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  25012. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25014. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25015. if !m.op.Is(OpUpdateOne) {
  25016. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25017. }
  25018. if m.id == nil || m.oldValue == nil {
  25019. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25020. }
  25021. oldValue, err := m.oldValue(ctx)
  25022. if err != nil {
  25023. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25024. }
  25025. return oldValue.DeletedAt, nil
  25026. }
  25027. // ClearDeletedAt clears the value of the "deleted_at" field.
  25028. func (m *PayRechargeMutation) ClearDeletedAt() {
  25029. m.deleted_at = nil
  25030. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  25031. }
  25032. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25033. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  25034. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  25035. return ok
  25036. }
  25037. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25038. func (m *PayRechargeMutation) ResetDeletedAt() {
  25039. m.deleted_at = nil
  25040. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  25041. }
  25042. // SetUserID sets the "user_id" field.
  25043. func (m *PayRechargeMutation) SetUserID(s string) {
  25044. m.user_id = &s
  25045. }
  25046. // UserID returns the value of the "user_id" field in the mutation.
  25047. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  25048. v := m.user_id
  25049. if v == nil {
  25050. return
  25051. }
  25052. return *v, true
  25053. }
  25054. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  25055. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25057. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  25058. if !m.op.Is(OpUpdateOne) {
  25059. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  25060. }
  25061. if m.id == nil || m.oldValue == nil {
  25062. return v, errors.New("OldUserID requires an ID field in the mutation")
  25063. }
  25064. oldValue, err := m.oldValue(ctx)
  25065. if err != nil {
  25066. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  25067. }
  25068. return oldValue.UserID, nil
  25069. }
  25070. // ResetUserID resets all changes to the "user_id" field.
  25071. func (m *PayRechargeMutation) ResetUserID() {
  25072. m.user_id = nil
  25073. }
  25074. // SetNumber sets the "number" field.
  25075. func (m *PayRechargeMutation) SetNumber(f float32) {
  25076. m.number = &f
  25077. m.addnumber = nil
  25078. }
  25079. // Number returns the value of the "number" field in the mutation.
  25080. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  25081. v := m.number
  25082. if v == nil {
  25083. return
  25084. }
  25085. return *v, true
  25086. }
  25087. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  25088. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25090. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  25091. if !m.op.Is(OpUpdateOne) {
  25092. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  25093. }
  25094. if m.id == nil || m.oldValue == nil {
  25095. return v, errors.New("OldNumber requires an ID field in the mutation")
  25096. }
  25097. oldValue, err := m.oldValue(ctx)
  25098. if err != nil {
  25099. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  25100. }
  25101. return oldValue.Number, nil
  25102. }
  25103. // AddNumber adds f to the "number" field.
  25104. func (m *PayRechargeMutation) AddNumber(f float32) {
  25105. if m.addnumber != nil {
  25106. *m.addnumber += f
  25107. } else {
  25108. m.addnumber = &f
  25109. }
  25110. }
  25111. // AddedNumber returns the value that was added to the "number" field in this mutation.
  25112. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  25113. v := m.addnumber
  25114. if v == nil {
  25115. return
  25116. }
  25117. return *v, true
  25118. }
  25119. // ResetNumber resets all changes to the "number" field.
  25120. func (m *PayRechargeMutation) ResetNumber() {
  25121. m.number = nil
  25122. m.addnumber = nil
  25123. }
  25124. // SetStatus sets the "status" field.
  25125. func (m *PayRechargeMutation) SetStatus(i int) {
  25126. m.status = &i
  25127. m.addstatus = nil
  25128. }
  25129. // Status returns the value of the "status" field in the mutation.
  25130. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  25131. v := m.status
  25132. if v == nil {
  25133. return
  25134. }
  25135. return *v, true
  25136. }
  25137. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  25138. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25140. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  25141. if !m.op.Is(OpUpdateOne) {
  25142. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25143. }
  25144. if m.id == nil || m.oldValue == nil {
  25145. return v, errors.New("OldStatus requires an ID field in the mutation")
  25146. }
  25147. oldValue, err := m.oldValue(ctx)
  25148. if err != nil {
  25149. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25150. }
  25151. return oldValue.Status, nil
  25152. }
  25153. // AddStatus adds i to the "status" field.
  25154. func (m *PayRechargeMutation) AddStatus(i int) {
  25155. if m.addstatus != nil {
  25156. *m.addstatus += i
  25157. } else {
  25158. m.addstatus = &i
  25159. }
  25160. }
  25161. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25162. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  25163. v := m.addstatus
  25164. if v == nil {
  25165. return
  25166. }
  25167. return *v, true
  25168. }
  25169. // ClearStatus clears the value of the "status" field.
  25170. func (m *PayRechargeMutation) ClearStatus() {
  25171. m.status = nil
  25172. m.addstatus = nil
  25173. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  25174. }
  25175. // StatusCleared returns if the "status" field was cleared in this mutation.
  25176. func (m *PayRechargeMutation) StatusCleared() bool {
  25177. _, ok := m.clearedFields[payrecharge.FieldStatus]
  25178. return ok
  25179. }
  25180. // ResetStatus resets all changes to the "status" field.
  25181. func (m *PayRechargeMutation) ResetStatus() {
  25182. m.status = nil
  25183. m.addstatus = nil
  25184. delete(m.clearedFields, payrecharge.FieldStatus)
  25185. }
  25186. // SetMoney sets the "money" field.
  25187. func (m *PayRechargeMutation) SetMoney(f float32) {
  25188. m.money = &f
  25189. m.addmoney = nil
  25190. }
  25191. // Money returns the value of the "money" field in the mutation.
  25192. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  25193. v := m.money
  25194. if v == nil {
  25195. return
  25196. }
  25197. return *v, true
  25198. }
  25199. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  25200. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25202. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  25203. if !m.op.Is(OpUpdateOne) {
  25204. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  25205. }
  25206. if m.id == nil || m.oldValue == nil {
  25207. return v, errors.New("OldMoney requires an ID field in the mutation")
  25208. }
  25209. oldValue, err := m.oldValue(ctx)
  25210. if err != nil {
  25211. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  25212. }
  25213. return oldValue.Money, nil
  25214. }
  25215. // AddMoney adds f to the "money" field.
  25216. func (m *PayRechargeMutation) AddMoney(f float32) {
  25217. if m.addmoney != nil {
  25218. *m.addmoney += f
  25219. } else {
  25220. m.addmoney = &f
  25221. }
  25222. }
  25223. // AddedMoney returns the value that was added to the "money" field in this mutation.
  25224. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  25225. v := m.addmoney
  25226. if v == nil {
  25227. return
  25228. }
  25229. return *v, true
  25230. }
  25231. // ClearMoney clears the value of the "money" field.
  25232. func (m *PayRechargeMutation) ClearMoney() {
  25233. m.money = nil
  25234. m.addmoney = nil
  25235. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  25236. }
  25237. // MoneyCleared returns if the "money" field was cleared in this mutation.
  25238. func (m *PayRechargeMutation) MoneyCleared() bool {
  25239. _, ok := m.clearedFields[payrecharge.FieldMoney]
  25240. return ok
  25241. }
  25242. // ResetMoney resets all changes to the "money" field.
  25243. func (m *PayRechargeMutation) ResetMoney() {
  25244. m.money = nil
  25245. m.addmoney = nil
  25246. delete(m.clearedFields, payrecharge.FieldMoney)
  25247. }
  25248. // SetOutTradeNo sets the "out_trade_no" field.
  25249. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  25250. m.out_trade_no = &s
  25251. }
  25252. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  25253. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  25254. v := m.out_trade_no
  25255. if v == nil {
  25256. return
  25257. }
  25258. return *v, true
  25259. }
  25260. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  25261. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25263. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  25264. if !m.op.Is(OpUpdateOne) {
  25265. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  25266. }
  25267. if m.id == nil || m.oldValue == nil {
  25268. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  25269. }
  25270. oldValue, err := m.oldValue(ctx)
  25271. if err != nil {
  25272. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  25273. }
  25274. return oldValue.OutTradeNo, nil
  25275. }
  25276. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  25277. func (m *PayRechargeMutation) ClearOutTradeNo() {
  25278. m.out_trade_no = nil
  25279. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  25280. }
  25281. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  25282. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  25283. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  25284. return ok
  25285. }
  25286. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  25287. func (m *PayRechargeMutation) ResetOutTradeNo() {
  25288. m.out_trade_no = nil
  25289. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  25290. }
  25291. // SetOrganizationID sets the "organization_id" field.
  25292. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  25293. m.organization_id = &u
  25294. m.addorganization_id = nil
  25295. }
  25296. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25297. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  25298. v := m.organization_id
  25299. if v == nil {
  25300. return
  25301. }
  25302. return *v, true
  25303. }
  25304. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  25305. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  25306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25307. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25308. if !m.op.Is(OpUpdateOne) {
  25309. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25310. }
  25311. if m.id == nil || m.oldValue == nil {
  25312. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25313. }
  25314. oldValue, err := m.oldValue(ctx)
  25315. if err != nil {
  25316. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25317. }
  25318. return oldValue.OrganizationID, nil
  25319. }
  25320. // AddOrganizationID adds u to the "organization_id" field.
  25321. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  25322. if m.addorganization_id != nil {
  25323. *m.addorganization_id += u
  25324. } else {
  25325. m.addorganization_id = &u
  25326. }
  25327. }
  25328. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25329. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  25330. v := m.addorganization_id
  25331. if v == nil {
  25332. return
  25333. }
  25334. return *v, true
  25335. }
  25336. // ResetOrganizationID resets all changes to the "organization_id" field.
  25337. func (m *PayRechargeMutation) ResetOrganizationID() {
  25338. m.organization_id = nil
  25339. m.addorganization_id = nil
  25340. }
  25341. // Where appends a list predicates to the PayRechargeMutation builder.
  25342. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  25343. m.predicates = append(m.predicates, ps...)
  25344. }
  25345. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  25346. // users can use type-assertion to append predicates that do not depend on any generated package.
  25347. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  25348. p := make([]predicate.PayRecharge, len(ps))
  25349. for i := range ps {
  25350. p[i] = ps[i]
  25351. }
  25352. m.Where(p...)
  25353. }
  25354. // Op returns the operation name.
  25355. func (m *PayRechargeMutation) Op() Op {
  25356. return m.op
  25357. }
  25358. // SetOp allows setting the mutation operation.
  25359. func (m *PayRechargeMutation) SetOp(op Op) {
  25360. m.op = op
  25361. }
  25362. // Type returns the node type of this mutation (PayRecharge).
  25363. func (m *PayRechargeMutation) Type() string {
  25364. return m.typ
  25365. }
  25366. // Fields returns all fields that were changed during this mutation. Note that in
  25367. // order to get all numeric fields that were incremented/decremented, call
  25368. // AddedFields().
  25369. func (m *PayRechargeMutation) Fields() []string {
  25370. fields := make([]string, 0, 9)
  25371. if m.created_at != nil {
  25372. fields = append(fields, payrecharge.FieldCreatedAt)
  25373. }
  25374. if m.updated_at != nil {
  25375. fields = append(fields, payrecharge.FieldUpdatedAt)
  25376. }
  25377. if m.deleted_at != nil {
  25378. fields = append(fields, payrecharge.FieldDeletedAt)
  25379. }
  25380. if m.user_id != nil {
  25381. fields = append(fields, payrecharge.FieldUserID)
  25382. }
  25383. if m.number != nil {
  25384. fields = append(fields, payrecharge.FieldNumber)
  25385. }
  25386. if m.status != nil {
  25387. fields = append(fields, payrecharge.FieldStatus)
  25388. }
  25389. if m.money != nil {
  25390. fields = append(fields, payrecharge.FieldMoney)
  25391. }
  25392. if m.out_trade_no != nil {
  25393. fields = append(fields, payrecharge.FieldOutTradeNo)
  25394. }
  25395. if m.organization_id != nil {
  25396. fields = append(fields, payrecharge.FieldOrganizationID)
  25397. }
  25398. return fields
  25399. }
  25400. // Field returns the value of a field with the given name. The second boolean
  25401. // return value indicates that this field was not set, or was not defined in the
  25402. // schema.
  25403. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  25404. switch name {
  25405. case payrecharge.FieldCreatedAt:
  25406. return m.CreatedAt()
  25407. case payrecharge.FieldUpdatedAt:
  25408. return m.UpdatedAt()
  25409. case payrecharge.FieldDeletedAt:
  25410. return m.DeletedAt()
  25411. case payrecharge.FieldUserID:
  25412. return m.UserID()
  25413. case payrecharge.FieldNumber:
  25414. return m.Number()
  25415. case payrecharge.FieldStatus:
  25416. return m.Status()
  25417. case payrecharge.FieldMoney:
  25418. return m.Money()
  25419. case payrecharge.FieldOutTradeNo:
  25420. return m.OutTradeNo()
  25421. case payrecharge.FieldOrganizationID:
  25422. return m.OrganizationID()
  25423. }
  25424. return nil, false
  25425. }
  25426. // OldField returns the old value of the field from the database. An error is
  25427. // returned if the mutation operation is not UpdateOne, or the query to the
  25428. // database failed.
  25429. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25430. switch name {
  25431. case payrecharge.FieldCreatedAt:
  25432. return m.OldCreatedAt(ctx)
  25433. case payrecharge.FieldUpdatedAt:
  25434. return m.OldUpdatedAt(ctx)
  25435. case payrecharge.FieldDeletedAt:
  25436. return m.OldDeletedAt(ctx)
  25437. case payrecharge.FieldUserID:
  25438. return m.OldUserID(ctx)
  25439. case payrecharge.FieldNumber:
  25440. return m.OldNumber(ctx)
  25441. case payrecharge.FieldStatus:
  25442. return m.OldStatus(ctx)
  25443. case payrecharge.FieldMoney:
  25444. return m.OldMoney(ctx)
  25445. case payrecharge.FieldOutTradeNo:
  25446. return m.OldOutTradeNo(ctx)
  25447. case payrecharge.FieldOrganizationID:
  25448. return m.OldOrganizationID(ctx)
  25449. }
  25450. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  25451. }
  25452. // SetField sets the value of a field with the given name. It returns an error if
  25453. // the field is not defined in the schema, or if the type mismatched the field
  25454. // type.
  25455. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  25456. switch name {
  25457. case payrecharge.FieldCreatedAt:
  25458. v, ok := value.(time.Time)
  25459. if !ok {
  25460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25461. }
  25462. m.SetCreatedAt(v)
  25463. return nil
  25464. case payrecharge.FieldUpdatedAt:
  25465. v, ok := value.(time.Time)
  25466. if !ok {
  25467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25468. }
  25469. m.SetUpdatedAt(v)
  25470. return nil
  25471. case payrecharge.FieldDeletedAt:
  25472. v, ok := value.(time.Time)
  25473. if !ok {
  25474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25475. }
  25476. m.SetDeletedAt(v)
  25477. return nil
  25478. case payrecharge.FieldUserID:
  25479. v, ok := value.(string)
  25480. if !ok {
  25481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25482. }
  25483. m.SetUserID(v)
  25484. return nil
  25485. case payrecharge.FieldNumber:
  25486. v, ok := value.(float32)
  25487. if !ok {
  25488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25489. }
  25490. m.SetNumber(v)
  25491. return nil
  25492. case payrecharge.FieldStatus:
  25493. v, ok := value.(int)
  25494. if !ok {
  25495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25496. }
  25497. m.SetStatus(v)
  25498. return nil
  25499. case payrecharge.FieldMoney:
  25500. v, ok := value.(float32)
  25501. if !ok {
  25502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25503. }
  25504. m.SetMoney(v)
  25505. return nil
  25506. case payrecharge.FieldOutTradeNo:
  25507. v, ok := value.(string)
  25508. if !ok {
  25509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25510. }
  25511. m.SetOutTradeNo(v)
  25512. return nil
  25513. case payrecharge.FieldOrganizationID:
  25514. v, ok := value.(uint64)
  25515. if !ok {
  25516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25517. }
  25518. m.SetOrganizationID(v)
  25519. return nil
  25520. }
  25521. return fmt.Errorf("unknown PayRecharge field %s", name)
  25522. }
  25523. // AddedFields returns all numeric fields that were incremented/decremented during
  25524. // this mutation.
  25525. func (m *PayRechargeMutation) AddedFields() []string {
  25526. var fields []string
  25527. if m.addnumber != nil {
  25528. fields = append(fields, payrecharge.FieldNumber)
  25529. }
  25530. if m.addstatus != nil {
  25531. fields = append(fields, payrecharge.FieldStatus)
  25532. }
  25533. if m.addmoney != nil {
  25534. fields = append(fields, payrecharge.FieldMoney)
  25535. }
  25536. if m.addorganization_id != nil {
  25537. fields = append(fields, payrecharge.FieldOrganizationID)
  25538. }
  25539. return fields
  25540. }
  25541. // AddedField returns the numeric value that was incremented/decremented on a field
  25542. // with the given name. The second boolean return value indicates that this field
  25543. // was not set, or was not defined in the schema.
  25544. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  25545. switch name {
  25546. case payrecharge.FieldNumber:
  25547. return m.AddedNumber()
  25548. case payrecharge.FieldStatus:
  25549. return m.AddedStatus()
  25550. case payrecharge.FieldMoney:
  25551. return m.AddedMoney()
  25552. case payrecharge.FieldOrganizationID:
  25553. return m.AddedOrganizationID()
  25554. }
  25555. return nil, false
  25556. }
  25557. // AddField adds the value to the field with the given name. It returns an error if
  25558. // the field is not defined in the schema, or if the type mismatched the field
  25559. // type.
  25560. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  25561. switch name {
  25562. case payrecharge.FieldNumber:
  25563. v, ok := value.(float32)
  25564. if !ok {
  25565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25566. }
  25567. m.AddNumber(v)
  25568. return nil
  25569. case payrecharge.FieldStatus:
  25570. v, ok := value.(int)
  25571. if !ok {
  25572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25573. }
  25574. m.AddStatus(v)
  25575. return nil
  25576. case payrecharge.FieldMoney:
  25577. v, ok := value.(float32)
  25578. if !ok {
  25579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25580. }
  25581. m.AddMoney(v)
  25582. return nil
  25583. case payrecharge.FieldOrganizationID:
  25584. v, ok := value.(int64)
  25585. if !ok {
  25586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25587. }
  25588. m.AddOrganizationID(v)
  25589. return nil
  25590. }
  25591. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  25592. }
  25593. // ClearedFields returns all nullable fields that were cleared during this
  25594. // mutation.
  25595. func (m *PayRechargeMutation) ClearedFields() []string {
  25596. var fields []string
  25597. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  25598. fields = append(fields, payrecharge.FieldDeletedAt)
  25599. }
  25600. if m.FieldCleared(payrecharge.FieldStatus) {
  25601. fields = append(fields, payrecharge.FieldStatus)
  25602. }
  25603. if m.FieldCleared(payrecharge.FieldMoney) {
  25604. fields = append(fields, payrecharge.FieldMoney)
  25605. }
  25606. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  25607. fields = append(fields, payrecharge.FieldOutTradeNo)
  25608. }
  25609. return fields
  25610. }
  25611. // FieldCleared returns a boolean indicating if a field with the given name was
  25612. // cleared in this mutation.
  25613. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  25614. _, ok := m.clearedFields[name]
  25615. return ok
  25616. }
  25617. // ClearField clears the value of the field with the given name. It returns an
  25618. // error if the field is not defined in the schema.
  25619. func (m *PayRechargeMutation) ClearField(name string) error {
  25620. switch name {
  25621. case payrecharge.FieldDeletedAt:
  25622. m.ClearDeletedAt()
  25623. return nil
  25624. case payrecharge.FieldStatus:
  25625. m.ClearStatus()
  25626. return nil
  25627. case payrecharge.FieldMoney:
  25628. m.ClearMoney()
  25629. return nil
  25630. case payrecharge.FieldOutTradeNo:
  25631. m.ClearOutTradeNo()
  25632. return nil
  25633. }
  25634. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  25635. }
  25636. // ResetField resets all changes in the mutation for the field with the given name.
  25637. // It returns an error if the field is not defined in the schema.
  25638. func (m *PayRechargeMutation) ResetField(name string) error {
  25639. switch name {
  25640. case payrecharge.FieldCreatedAt:
  25641. m.ResetCreatedAt()
  25642. return nil
  25643. case payrecharge.FieldUpdatedAt:
  25644. m.ResetUpdatedAt()
  25645. return nil
  25646. case payrecharge.FieldDeletedAt:
  25647. m.ResetDeletedAt()
  25648. return nil
  25649. case payrecharge.FieldUserID:
  25650. m.ResetUserID()
  25651. return nil
  25652. case payrecharge.FieldNumber:
  25653. m.ResetNumber()
  25654. return nil
  25655. case payrecharge.FieldStatus:
  25656. m.ResetStatus()
  25657. return nil
  25658. case payrecharge.FieldMoney:
  25659. m.ResetMoney()
  25660. return nil
  25661. case payrecharge.FieldOutTradeNo:
  25662. m.ResetOutTradeNo()
  25663. return nil
  25664. case payrecharge.FieldOrganizationID:
  25665. m.ResetOrganizationID()
  25666. return nil
  25667. }
  25668. return fmt.Errorf("unknown PayRecharge field %s", name)
  25669. }
  25670. // AddedEdges returns all edge names that were set/added in this mutation.
  25671. func (m *PayRechargeMutation) AddedEdges() []string {
  25672. edges := make([]string, 0, 0)
  25673. return edges
  25674. }
  25675. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25676. // name in this mutation.
  25677. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  25678. return nil
  25679. }
  25680. // RemovedEdges returns all edge names that were removed in this mutation.
  25681. func (m *PayRechargeMutation) RemovedEdges() []string {
  25682. edges := make([]string, 0, 0)
  25683. return edges
  25684. }
  25685. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25686. // the given name in this mutation.
  25687. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  25688. return nil
  25689. }
  25690. // ClearedEdges returns all edge names that were cleared in this mutation.
  25691. func (m *PayRechargeMutation) ClearedEdges() []string {
  25692. edges := make([]string, 0, 0)
  25693. return edges
  25694. }
  25695. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25696. // was cleared in this mutation.
  25697. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  25698. return false
  25699. }
  25700. // ClearEdge clears the value of the edge with the given name. It returns an error
  25701. // if that edge is not defined in the schema.
  25702. func (m *PayRechargeMutation) ClearEdge(name string) error {
  25703. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  25704. }
  25705. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25706. // It returns an error if the edge is not defined in the schema.
  25707. func (m *PayRechargeMutation) ResetEdge(name string) error {
  25708. return fmt.Errorf("unknown PayRecharge edge %s", name)
  25709. }
  25710. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  25711. type ServerMutation struct {
  25712. config
  25713. op Op
  25714. typ string
  25715. id *uint64
  25716. created_at *time.Time
  25717. updated_at *time.Time
  25718. status *uint8
  25719. addstatus *int8
  25720. deleted_at *time.Time
  25721. name *string
  25722. public_ip *string
  25723. private_ip *string
  25724. admin_port *string
  25725. clearedFields map[string]struct{}
  25726. wxs map[uint64]struct{}
  25727. removedwxs map[uint64]struct{}
  25728. clearedwxs bool
  25729. done bool
  25730. oldValue func(context.Context) (*Server, error)
  25731. predicates []predicate.Server
  25732. }
  25733. var _ ent.Mutation = (*ServerMutation)(nil)
  25734. // serverOption allows management of the mutation configuration using functional options.
  25735. type serverOption func(*ServerMutation)
  25736. // newServerMutation creates new mutation for the Server entity.
  25737. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  25738. m := &ServerMutation{
  25739. config: c,
  25740. op: op,
  25741. typ: TypeServer,
  25742. clearedFields: make(map[string]struct{}),
  25743. }
  25744. for _, opt := range opts {
  25745. opt(m)
  25746. }
  25747. return m
  25748. }
  25749. // withServerID sets the ID field of the mutation.
  25750. func withServerID(id uint64) serverOption {
  25751. return func(m *ServerMutation) {
  25752. var (
  25753. err error
  25754. once sync.Once
  25755. value *Server
  25756. )
  25757. m.oldValue = func(ctx context.Context) (*Server, error) {
  25758. once.Do(func() {
  25759. if m.done {
  25760. err = errors.New("querying old values post mutation is not allowed")
  25761. } else {
  25762. value, err = m.Client().Server.Get(ctx, id)
  25763. }
  25764. })
  25765. return value, err
  25766. }
  25767. m.id = &id
  25768. }
  25769. }
  25770. // withServer sets the old Server of the mutation.
  25771. func withServer(node *Server) serverOption {
  25772. return func(m *ServerMutation) {
  25773. m.oldValue = func(context.Context) (*Server, error) {
  25774. return node, nil
  25775. }
  25776. m.id = &node.ID
  25777. }
  25778. }
  25779. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25780. // executed in a transaction (ent.Tx), a transactional client is returned.
  25781. func (m ServerMutation) Client() *Client {
  25782. client := &Client{config: m.config}
  25783. client.init()
  25784. return client
  25785. }
  25786. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25787. // it returns an error otherwise.
  25788. func (m ServerMutation) Tx() (*Tx, error) {
  25789. if _, ok := m.driver.(*txDriver); !ok {
  25790. return nil, errors.New("ent: mutation is not running in a transaction")
  25791. }
  25792. tx := &Tx{config: m.config}
  25793. tx.init()
  25794. return tx, nil
  25795. }
  25796. // SetID sets the value of the id field. Note that this
  25797. // operation is only accepted on creation of Server entities.
  25798. func (m *ServerMutation) SetID(id uint64) {
  25799. m.id = &id
  25800. }
  25801. // ID returns the ID value in the mutation. Note that the ID is only available
  25802. // if it was provided to the builder or after it was returned from the database.
  25803. func (m *ServerMutation) ID() (id uint64, exists bool) {
  25804. if m.id == nil {
  25805. return
  25806. }
  25807. return *m.id, true
  25808. }
  25809. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25810. // That means, if the mutation is applied within a transaction with an isolation level such
  25811. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25812. // or updated by the mutation.
  25813. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  25814. switch {
  25815. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25816. id, exists := m.ID()
  25817. if exists {
  25818. return []uint64{id}, nil
  25819. }
  25820. fallthrough
  25821. case m.op.Is(OpUpdate | OpDelete):
  25822. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  25823. default:
  25824. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25825. }
  25826. }
  25827. // SetCreatedAt sets the "created_at" field.
  25828. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  25829. m.created_at = &t
  25830. }
  25831. // CreatedAt returns the value of the "created_at" field in the mutation.
  25832. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  25833. v := m.created_at
  25834. if v == nil {
  25835. return
  25836. }
  25837. return *v, true
  25838. }
  25839. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  25840. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25842. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25843. if !m.op.Is(OpUpdateOne) {
  25844. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25845. }
  25846. if m.id == nil || m.oldValue == nil {
  25847. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25848. }
  25849. oldValue, err := m.oldValue(ctx)
  25850. if err != nil {
  25851. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25852. }
  25853. return oldValue.CreatedAt, nil
  25854. }
  25855. // ResetCreatedAt resets all changes to the "created_at" field.
  25856. func (m *ServerMutation) ResetCreatedAt() {
  25857. m.created_at = nil
  25858. }
  25859. // SetUpdatedAt sets the "updated_at" field.
  25860. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  25861. m.updated_at = &t
  25862. }
  25863. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25864. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  25865. v := m.updated_at
  25866. if v == nil {
  25867. return
  25868. }
  25869. return *v, true
  25870. }
  25871. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  25872. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25874. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25875. if !m.op.Is(OpUpdateOne) {
  25876. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25877. }
  25878. if m.id == nil || m.oldValue == nil {
  25879. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25880. }
  25881. oldValue, err := m.oldValue(ctx)
  25882. if err != nil {
  25883. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25884. }
  25885. return oldValue.UpdatedAt, nil
  25886. }
  25887. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25888. func (m *ServerMutation) ResetUpdatedAt() {
  25889. m.updated_at = nil
  25890. }
  25891. // SetStatus sets the "status" field.
  25892. func (m *ServerMutation) SetStatus(u uint8) {
  25893. m.status = &u
  25894. m.addstatus = nil
  25895. }
  25896. // Status returns the value of the "status" field in the mutation.
  25897. func (m *ServerMutation) Status() (r uint8, exists bool) {
  25898. v := m.status
  25899. if v == nil {
  25900. return
  25901. }
  25902. return *v, true
  25903. }
  25904. // OldStatus returns the old "status" field's value of the Server entity.
  25905. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25907. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25908. if !m.op.Is(OpUpdateOne) {
  25909. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25910. }
  25911. if m.id == nil || m.oldValue == nil {
  25912. return v, errors.New("OldStatus requires an ID field in the mutation")
  25913. }
  25914. oldValue, err := m.oldValue(ctx)
  25915. if err != nil {
  25916. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25917. }
  25918. return oldValue.Status, nil
  25919. }
  25920. // AddStatus adds u to the "status" field.
  25921. func (m *ServerMutation) AddStatus(u int8) {
  25922. if m.addstatus != nil {
  25923. *m.addstatus += u
  25924. } else {
  25925. m.addstatus = &u
  25926. }
  25927. }
  25928. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25929. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  25930. v := m.addstatus
  25931. if v == nil {
  25932. return
  25933. }
  25934. return *v, true
  25935. }
  25936. // ClearStatus clears the value of the "status" field.
  25937. func (m *ServerMutation) ClearStatus() {
  25938. m.status = nil
  25939. m.addstatus = nil
  25940. m.clearedFields[server.FieldStatus] = struct{}{}
  25941. }
  25942. // StatusCleared returns if the "status" field was cleared in this mutation.
  25943. func (m *ServerMutation) StatusCleared() bool {
  25944. _, ok := m.clearedFields[server.FieldStatus]
  25945. return ok
  25946. }
  25947. // ResetStatus resets all changes to the "status" field.
  25948. func (m *ServerMutation) ResetStatus() {
  25949. m.status = nil
  25950. m.addstatus = nil
  25951. delete(m.clearedFields, server.FieldStatus)
  25952. }
  25953. // SetDeletedAt sets the "deleted_at" field.
  25954. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  25955. m.deleted_at = &t
  25956. }
  25957. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25958. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  25959. v := m.deleted_at
  25960. if v == nil {
  25961. return
  25962. }
  25963. return *v, true
  25964. }
  25965. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  25966. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  25967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25968. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25969. if !m.op.Is(OpUpdateOne) {
  25970. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25971. }
  25972. if m.id == nil || m.oldValue == nil {
  25973. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25974. }
  25975. oldValue, err := m.oldValue(ctx)
  25976. if err != nil {
  25977. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25978. }
  25979. return oldValue.DeletedAt, nil
  25980. }
  25981. // ClearDeletedAt clears the value of the "deleted_at" field.
  25982. func (m *ServerMutation) ClearDeletedAt() {
  25983. m.deleted_at = nil
  25984. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  25985. }
  25986. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25987. func (m *ServerMutation) DeletedAtCleared() bool {
  25988. _, ok := m.clearedFields[server.FieldDeletedAt]
  25989. return ok
  25990. }
  25991. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25992. func (m *ServerMutation) ResetDeletedAt() {
  25993. m.deleted_at = nil
  25994. delete(m.clearedFields, server.FieldDeletedAt)
  25995. }
  25996. // SetName sets the "name" field.
  25997. func (m *ServerMutation) SetName(s string) {
  25998. m.name = &s
  25999. }
  26000. // Name returns the value of the "name" field in the mutation.
  26001. func (m *ServerMutation) Name() (r string, exists bool) {
  26002. v := m.name
  26003. if v == nil {
  26004. return
  26005. }
  26006. return *v, true
  26007. }
  26008. // OldName returns the old "name" field's value of the Server entity.
  26009. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26011. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  26012. if !m.op.Is(OpUpdateOne) {
  26013. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26014. }
  26015. if m.id == nil || m.oldValue == nil {
  26016. return v, errors.New("OldName requires an ID field in the mutation")
  26017. }
  26018. oldValue, err := m.oldValue(ctx)
  26019. if err != nil {
  26020. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26021. }
  26022. return oldValue.Name, nil
  26023. }
  26024. // ResetName resets all changes to the "name" field.
  26025. func (m *ServerMutation) ResetName() {
  26026. m.name = nil
  26027. }
  26028. // SetPublicIP sets the "public_ip" field.
  26029. func (m *ServerMutation) SetPublicIP(s string) {
  26030. m.public_ip = &s
  26031. }
  26032. // PublicIP returns the value of the "public_ip" field in the mutation.
  26033. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  26034. v := m.public_ip
  26035. if v == nil {
  26036. return
  26037. }
  26038. return *v, true
  26039. }
  26040. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  26041. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26043. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  26044. if !m.op.Is(OpUpdateOne) {
  26045. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  26046. }
  26047. if m.id == nil || m.oldValue == nil {
  26048. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  26049. }
  26050. oldValue, err := m.oldValue(ctx)
  26051. if err != nil {
  26052. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  26053. }
  26054. return oldValue.PublicIP, nil
  26055. }
  26056. // ResetPublicIP resets all changes to the "public_ip" field.
  26057. func (m *ServerMutation) ResetPublicIP() {
  26058. m.public_ip = nil
  26059. }
  26060. // SetPrivateIP sets the "private_ip" field.
  26061. func (m *ServerMutation) SetPrivateIP(s string) {
  26062. m.private_ip = &s
  26063. }
  26064. // PrivateIP returns the value of the "private_ip" field in the mutation.
  26065. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  26066. v := m.private_ip
  26067. if v == nil {
  26068. return
  26069. }
  26070. return *v, true
  26071. }
  26072. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  26073. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26075. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  26076. if !m.op.Is(OpUpdateOne) {
  26077. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  26078. }
  26079. if m.id == nil || m.oldValue == nil {
  26080. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  26081. }
  26082. oldValue, err := m.oldValue(ctx)
  26083. if err != nil {
  26084. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  26085. }
  26086. return oldValue.PrivateIP, nil
  26087. }
  26088. // ResetPrivateIP resets all changes to the "private_ip" field.
  26089. func (m *ServerMutation) ResetPrivateIP() {
  26090. m.private_ip = nil
  26091. }
  26092. // SetAdminPort sets the "admin_port" field.
  26093. func (m *ServerMutation) SetAdminPort(s string) {
  26094. m.admin_port = &s
  26095. }
  26096. // AdminPort returns the value of the "admin_port" field in the mutation.
  26097. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  26098. v := m.admin_port
  26099. if v == nil {
  26100. return
  26101. }
  26102. return *v, true
  26103. }
  26104. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  26105. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  26106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26107. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  26108. if !m.op.Is(OpUpdateOne) {
  26109. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  26110. }
  26111. if m.id == nil || m.oldValue == nil {
  26112. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  26113. }
  26114. oldValue, err := m.oldValue(ctx)
  26115. if err != nil {
  26116. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  26117. }
  26118. return oldValue.AdminPort, nil
  26119. }
  26120. // ResetAdminPort resets all changes to the "admin_port" field.
  26121. func (m *ServerMutation) ResetAdminPort() {
  26122. m.admin_port = nil
  26123. }
  26124. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  26125. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  26126. if m.wxs == nil {
  26127. m.wxs = make(map[uint64]struct{})
  26128. }
  26129. for i := range ids {
  26130. m.wxs[ids[i]] = struct{}{}
  26131. }
  26132. }
  26133. // ClearWxs clears the "wxs" edge to the Wx entity.
  26134. func (m *ServerMutation) ClearWxs() {
  26135. m.clearedwxs = true
  26136. }
  26137. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  26138. func (m *ServerMutation) WxsCleared() bool {
  26139. return m.clearedwxs
  26140. }
  26141. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  26142. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  26143. if m.removedwxs == nil {
  26144. m.removedwxs = make(map[uint64]struct{})
  26145. }
  26146. for i := range ids {
  26147. delete(m.wxs, ids[i])
  26148. m.removedwxs[ids[i]] = struct{}{}
  26149. }
  26150. }
  26151. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  26152. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  26153. for id := range m.removedwxs {
  26154. ids = append(ids, id)
  26155. }
  26156. return
  26157. }
  26158. // WxsIDs returns the "wxs" edge IDs in the mutation.
  26159. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  26160. for id := range m.wxs {
  26161. ids = append(ids, id)
  26162. }
  26163. return
  26164. }
  26165. // ResetWxs resets all changes to the "wxs" edge.
  26166. func (m *ServerMutation) ResetWxs() {
  26167. m.wxs = nil
  26168. m.clearedwxs = false
  26169. m.removedwxs = nil
  26170. }
  26171. // Where appends a list predicates to the ServerMutation builder.
  26172. func (m *ServerMutation) Where(ps ...predicate.Server) {
  26173. m.predicates = append(m.predicates, ps...)
  26174. }
  26175. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  26176. // users can use type-assertion to append predicates that do not depend on any generated package.
  26177. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  26178. p := make([]predicate.Server, len(ps))
  26179. for i := range ps {
  26180. p[i] = ps[i]
  26181. }
  26182. m.Where(p...)
  26183. }
  26184. // Op returns the operation name.
  26185. func (m *ServerMutation) Op() Op {
  26186. return m.op
  26187. }
  26188. // SetOp allows setting the mutation operation.
  26189. func (m *ServerMutation) SetOp(op Op) {
  26190. m.op = op
  26191. }
  26192. // Type returns the node type of this mutation (Server).
  26193. func (m *ServerMutation) Type() string {
  26194. return m.typ
  26195. }
  26196. // Fields returns all fields that were changed during this mutation. Note that in
  26197. // order to get all numeric fields that were incremented/decremented, call
  26198. // AddedFields().
  26199. func (m *ServerMutation) Fields() []string {
  26200. fields := make([]string, 0, 8)
  26201. if m.created_at != nil {
  26202. fields = append(fields, server.FieldCreatedAt)
  26203. }
  26204. if m.updated_at != nil {
  26205. fields = append(fields, server.FieldUpdatedAt)
  26206. }
  26207. if m.status != nil {
  26208. fields = append(fields, server.FieldStatus)
  26209. }
  26210. if m.deleted_at != nil {
  26211. fields = append(fields, server.FieldDeletedAt)
  26212. }
  26213. if m.name != nil {
  26214. fields = append(fields, server.FieldName)
  26215. }
  26216. if m.public_ip != nil {
  26217. fields = append(fields, server.FieldPublicIP)
  26218. }
  26219. if m.private_ip != nil {
  26220. fields = append(fields, server.FieldPrivateIP)
  26221. }
  26222. if m.admin_port != nil {
  26223. fields = append(fields, server.FieldAdminPort)
  26224. }
  26225. return fields
  26226. }
  26227. // Field returns the value of a field with the given name. The second boolean
  26228. // return value indicates that this field was not set, or was not defined in the
  26229. // schema.
  26230. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  26231. switch name {
  26232. case server.FieldCreatedAt:
  26233. return m.CreatedAt()
  26234. case server.FieldUpdatedAt:
  26235. return m.UpdatedAt()
  26236. case server.FieldStatus:
  26237. return m.Status()
  26238. case server.FieldDeletedAt:
  26239. return m.DeletedAt()
  26240. case server.FieldName:
  26241. return m.Name()
  26242. case server.FieldPublicIP:
  26243. return m.PublicIP()
  26244. case server.FieldPrivateIP:
  26245. return m.PrivateIP()
  26246. case server.FieldAdminPort:
  26247. return m.AdminPort()
  26248. }
  26249. return nil, false
  26250. }
  26251. // OldField returns the old value of the field from the database. An error is
  26252. // returned if the mutation operation is not UpdateOne, or the query to the
  26253. // database failed.
  26254. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26255. switch name {
  26256. case server.FieldCreatedAt:
  26257. return m.OldCreatedAt(ctx)
  26258. case server.FieldUpdatedAt:
  26259. return m.OldUpdatedAt(ctx)
  26260. case server.FieldStatus:
  26261. return m.OldStatus(ctx)
  26262. case server.FieldDeletedAt:
  26263. return m.OldDeletedAt(ctx)
  26264. case server.FieldName:
  26265. return m.OldName(ctx)
  26266. case server.FieldPublicIP:
  26267. return m.OldPublicIP(ctx)
  26268. case server.FieldPrivateIP:
  26269. return m.OldPrivateIP(ctx)
  26270. case server.FieldAdminPort:
  26271. return m.OldAdminPort(ctx)
  26272. }
  26273. return nil, fmt.Errorf("unknown Server field %s", name)
  26274. }
  26275. // SetField sets the value of a field with the given name. It returns an error if
  26276. // the field is not defined in the schema, or if the type mismatched the field
  26277. // type.
  26278. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  26279. switch name {
  26280. case server.FieldCreatedAt:
  26281. v, ok := value.(time.Time)
  26282. if !ok {
  26283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26284. }
  26285. m.SetCreatedAt(v)
  26286. return nil
  26287. case server.FieldUpdatedAt:
  26288. v, ok := value.(time.Time)
  26289. if !ok {
  26290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26291. }
  26292. m.SetUpdatedAt(v)
  26293. return nil
  26294. case server.FieldStatus:
  26295. v, ok := value.(uint8)
  26296. if !ok {
  26297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26298. }
  26299. m.SetStatus(v)
  26300. return nil
  26301. case server.FieldDeletedAt:
  26302. v, ok := value.(time.Time)
  26303. if !ok {
  26304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26305. }
  26306. m.SetDeletedAt(v)
  26307. return nil
  26308. case server.FieldName:
  26309. v, ok := value.(string)
  26310. if !ok {
  26311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26312. }
  26313. m.SetName(v)
  26314. return nil
  26315. case server.FieldPublicIP:
  26316. v, ok := value.(string)
  26317. if !ok {
  26318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26319. }
  26320. m.SetPublicIP(v)
  26321. return nil
  26322. case server.FieldPrivateIP:
  26323. v, ok := value.(string)
  26324. if !ok {
  26325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26326. }
  26327. m.SetPrivateIP(v)
  26328. return nil
  26329. case server.FieldAdminPort:
  26330. v, ok := value.(string)
  26331. if !ok {
  26332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26333. }
  26334. m.SetAdminPort(v)
  26335. return nil
  26336. }
  26337. return fmt.Errorf("unknown Server field %s", name)
  26338. }
  26339. // AddedFields returns all numeric fields that were incremented/decremented during
  26340. // this mutation.
  26341. func (m *ServerMutation) AddedFields() []string {
  26342. var fields []string
  26343. if m.addstatus != nil {
  26344. fields = append(fields, server.FieldStatus)
  26345. }
  26346. return fields
  26347. }
  26348. // AddedField returns the numeric value that was incremented/decremented on a field
  26349. // with the given name. The second boolean return value indicates that this field
  26350. // was not set, or was not defined in the schema.
  26351. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  26352. switch name {
  26353. case server.FieldStatus:
  26354. return m.AddedStatus()
  26355. }
  26356. return nil, false
  26357. }
  26358. // AddField adds the value to the field with the given name. It returns an error if
  26359. // the field is not defined in the schema, or if the type mismatched the field
  26360. // type.
  26361. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  26362. switch name {
  26363. case server.FieldStatus:
  26364. v, ok := value.(int8)
  26365. if !ok {
  26366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26367. }
  26368. m.AddStatus(v)
  26369. return nil
  26370. }
  26371. return fmt.Errorf("unknown Server numeric field %s", name)
  26372. }
  26373. // ClearedFields returns all nullable fields that were cleared during this
  26374. // mutation.
  26375. func (m *ServerMutation) ClearedFields() []string {
  26376. var fields []string
  26377. if m.FieldCleared(server.FieldStatus) {
  26378. fields = append(fields, server.FieldStatus)
  26379. }
  26380. if m.FieldCleared(server.FieldDeletedAt) {
  26381. fields = append(fields, server.FieldDeletedAt)
  26382. }
  26383. return fields
  26384. }
  26385. // FieldCleared returns a boolean indicating if a field with the given name was
  26386. // cleared in this mutation.
  26387. func (m *ServerMutation) FieldCleared(name string) bool {
  26388. _, ok := m.clearedFields[name]
  26389. return ok
  26390. }
  26391. // ClearField clears the value of the field with the given name. It returns an
  26392. // error if the field is not defined in the schema.
  26393. func (m *ServerMutation) ClearField(name string) error {
  26394. switch name {
  26395. case server.FieldStatus:
  26396. m.ClearStatus()
  26397. return nil
  26398. case server.FieldDeletedAt:
  26399. m.ClearDeletedAt()
  26400. return nil
  26401. }
  26402. return fmt.Errorf("unknown Server nullable field %s", name)
  26403. }
  26404. // ResetField resets all changes in the mutation for the field with the given name.
  26405. // It returns an error if the field is not defined in the schema.
  26406. func (m *ServerMutation) ResetField(name string) error {
  26407. switch name {
  26408. case server.FieldCreatedAt:
  26409. m.ResetCreatedAt()
  26410. return nil
  26411. case server.FieldUpdatedAt:
  26412. m.ResetUpdatedAt()
  26413. return nil
  26414. case server.FieldStatus:
  26415. m.ResetStatus()
  26416. return nil
  26417. case server.FieldDeletedAt:
  26418. m.ResetDeletedAt()
  26419. return nil
  26420. case server.FieldName:
  26421. m.ResetName()
  26422. return nil
  26423. case server.FieldPublicIP:
  26424. m.ResetPublicIP()
  26425. return nil
  26426. case server.FieldPrivateIP:
  26427. m.ResetPrivateIP()
  26428. return nil
  26429. case server.FieldAdminPort:
  26430. m.ResetAdminPort()
  26431. return nil
  26432. }
  26433. return fmt.Errorf("unknown Server field %s", name)
  26434. }
  26435. // AddedEdges returns all edge names that were set/added in this mutation.
  26436. func (m *ServerMutation) AddedEdges() []string {
  26437. edges := make([]string, 0, 1)
  26438. if m.wxs != nil {
  26439. edges = append(edges, server.EdgeWxs)
  26440. }
  26441. return edges
  26442. }
  26443. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26444. // name in this mutation.
  26445. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  26446. switch name {
  26447. case server.EdgeWxs:
  26448. ids := make([]ent.Value, 0, len(m.wxs))
  26449. for id := range m.wxs {
  26450. ids = append(ids, id)
  26451. }
  26452. return ids
  26453. }
  26454. return nil
  26455. }
  26456. // RemovedEdges returns all edge names that were removed in this mutation.
  26457. func (m *ServerMutation) RemovedEdges() []string {
  26458. edges := make([]string, 0, 1)
  26459. if m.removedwxs != nil {
  26460. edges = append(edges, server.EdgeWxs)
  26461. }
  26462. return edges
  26463. }
  26464. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26465. // the given name in this mutation.
  26466. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  26467. switch name {
  26468. case server.EdgeWxs:
  26469. ids := make([]ent.Value, 0, len(m.removedwxs))
  26470. for id := range m.removedwxs {
  26471. ids = append(ids, id)
  26472. }
  26473. return ids
  26474. }
  26475. return nil
  26476. }
  26477. // ClearedEdges returns all edge names that were cleared in this mutation.
  26478. func (m *ServerMutation) ClearedEdges() []string {
  26479. edges := make([]string, 0, 1)
  26480. if m.clearedwxs {
  26481. edges = append(edges, server.EdgeWxs)
  26482. }
  26483. return edges
  26484. }
  26485. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26486. // was cleared in this mutation.
  26487. func (m *ServerMutation) EdgeCleared(name string) bool {
  26488. switch name {
  26489. case server.EdgeWxs:
  26490. return m.clearedwxs
  26491. }
  26492. return false
  26493. }
  26494. // ClearEdge clears the value of the edge with the given name. It returns an error
  26495. // if that edge is not defined in the schema.
  26496. func (m *ServerMutation) ClearEdge(name string) error {
  26497. switch name {
  26498. }
  26499. return fmt.Errorf("unknown Server unique edge %s", name)
  26500. }
  26501. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26502. // It returns an error if the edge is not defined in the schema.
  26503. func (m *ServerMutation) ResetEdge(name string) error {
  26504. switch name {
  26505. case server.EdgeWxs:
  26506. m.ResetWxs()
  26507. return nil
  26508. }
  26509. return fmt.Errorf("unknown Server edge %s", name)
  26510. }
  26511. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  26512. type SopNodeMutation struct {
  26513. config
  26514. op Op
  26515. typ string
  26516. id *uint64
  26517. created_at *time.Time
  26518. updated_at *time.Time
  26519. status *uint8
  26520. addstatus *int8
  26521. deleted_at *time.Time
  26522. parent_id *uint64
  26523. addparent_id *int64
  26524. name *string
  26525. condition_type *int
  26526. addcondition_type *int
  26527. condition_list *[]string
  26528. appendcondition_list []string
  26529. no_reply_condition *uint64
  26530. addno_reply_condition *int64
  26531. no_reply_unit *string
  26532. action_message *[]custom_types.Action
  26533. appendaction_message []custom_types.Action
  26534. action_label_add *[]uint64
  26535. appendaction_label_add []uint64
  26536. action_label_del *[]uint64
  26537. appendaction_label_del []uint64
  26538. action_forward **custom_types.ActionForward
  26539. clearedFields map[string]struct{}
  26540. sop_stage *uint64
  26541. clearedsop_stage bool
  26542. node_messages map[uint64]struct{}
  26543. removednode_messages map[uint64]struct{}
  26544. clearednode_messages bool
  26545. done bool
  26546. oldValue func(context.Context) (*SopNode, error)
  26547. predicates []predicate.SopNode
  26548. }
  26549. var _ ent.Mutation = (*SopNodeMutation)(nil)
  26550. // sopnodeOption allows management of the mutation configuration using functional options.
  26551. type sopnodeOption func(*SopNodeMutation)
  26552. // newSopNodeMutation creates new mutation for the SopNode entity.
  26553. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  26554. m := &SopNodeMutation{
  26555. config: c,
  26556. op: op,
  26557. typ: TypeSopNode,
  26558. clearedFields: make(map[string]struct{}),
  26559. }
  26560. for _, opt := range opts {
  26561. opt(m)
  26562. }
  26563. return m
  26564. }
  26565. // withSopNodeID sets the ID field of the mutation.
  26566. func withSopNodeID(id uint64) sopnodeOption {
  26567. return func(m *SopNodeMutation) {
  26568. var (
  26569. err error
  26570. once sync.Once
  26571. value *SopNode
  26572. )
  26573. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  26574. once.Do(func() {
  26575. if m.done {
  26576. err = errors.New("querying old values post mutation is not allowed")
  26577. } else {
  26578. value, err = m.Client().SopNode.Get(ctx, id)
  26579. }
  26580. })
  26581. return value, err
  26582. }
  26583. m.id = &id
  26584. }
  26585. }
  26586. // withSopNode sets the old SopNode of the mutation.
  26587. func withSopNode(node *SopNode) sopnodeOption {
  26588. return func(m *SopNodeMutation) {
  26589. m.oldValue = func(context.Context) (*SopNode, error) {
  26590. return node, nil
  26591. }
  26592. m.id = &node.ID
  26593. }
  26594. }
  26595. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26596. // executed in a transaction (ent.Tx), a transactional client is returned.
  26597. func (m SopNodeMutation) Client() *Client {
  26598. client := &Client{config: m.config}
  26599. client.init()
  26600. return client
  26601. }
  26602. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26603. // it returns an error otherwise.
  26604. func (m SopNodeMutation) Tx() (*Tx, error) {
  26605. if _, ok := m.driver.(*txDriver); !ok {
  26606. return nil, errors.New("ent: mutation is not running in a transaction")
  26607. }
  26608. tx := &Tx{config: m.config}
  26609. tx.init()
  26610. return tx, nil
  26611. }
  26612. // SetID sets the value of the id field. Note that this
  26613. // operation is only accepted on creation of SopNode entities.
  26614. func (m *SopNodeMutation) SetID(id uint64) {
  26615. m.id = &id
  26616. }
  26617. // ID returns the ID value in the mutation. Note that the ID is only available
  26618. // if it was provided to the builder or after it was returned from the database.
  26619. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  26620. if m.id == nil {
  26621. return
  26622. }
  26623. return *m.id, true
  26624. }
  26625. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26626. // That means, if the mutation is applied within a transaction with an isolation level such
  26627. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26628. // or updated by the mutation.
  26629. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26630. switch {
  26631. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26632. id, exists := m.ID()
  26633. if exists {
  26634. return []uint64{id}, nil
  26635. }
  26636. fallthrough
  26637. case m.op.Is(OpUpdate | OpDelete):
  26638. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  26639. default:
  26640. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26641. }
  26642. }
  26643. // SetCreatedAt sets the "created_at" field.
  26644. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  26645. m.created_at = &t
  26646. }
  26647. // CreatedAt returns the value of the "created_at" field in the mutation.
  26648. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  26649. v := m.created_at
  26650. if v == nil {
  26651. return
  26652. }
  26653. return *v, true
  26654. }
  26655. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  26656. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26658. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26659. if !m.op.Is(OpUpdateOne) {
  26660. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26661. }
  26662. if m.id == nil || m.oldValue == nil {
  26663. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26664. }
  26665. oldValue, err := m.oldValue(ctx)
  26666. if err != nil {
  26667. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26668. }
  26669. return oldValue.CreatedAt, nil
  26670. }
  26671. // ResetCreatedAt resets all changes to the "created_at" field.
  26672. func (m *SopNodeMutation) ResetCreatedAt() {
  26673. m.created_at = nil
  26674. }
  26675. // SetUpdatedAt sets the "updated_at" field.
  26676. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  26677. m.updated_at = &t
  26678. }
  26679. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26680. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  26681. v := m.updated_at
  26682. if v == nil {
  26683. return
  26684. }
  26685. return *v, true
  26686. }
  26687. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  26688. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26690. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26691. if !m.op.Is(OpUpdateOne) {
  26692. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26693. }
  26694. if m.id == nil || m.oldValue == nil {
  26695. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26696. }
  26697. oldValue, err := m.oldValue(ctx)
  26698. if err != nil {
  26699. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26700. }
  26701. return oldValue.UpdatedAt, nil
  26702. }
  26703. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26704. func (m *SopNodeMutation) ResetUpdatedAt() {
  26705. m.updated_at = nil
  26706. }
  26707. // SetStatus sets the "status" field.
  26708. func (m *SopNodeMutation) SetStatus(u uint8) {
  26709. m.status = &u
  26710. m.addstatus = nil
  26711. }
  26712. // Status returns the value of the "status" field in the mutation.
  26713. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  26714. v := m.status
  26715. if v == nil {
  26716. return
  26717. }
  26718. return *v, true
  26719. }
  26720. // OldStatus returns the old "status" field's value of the SopNode entity.
  26721. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26723. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26724. if !m.op.Is(OpUpdateOne) {
  26725. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26726. }
  26727. if m.id == nil || m.oldValue == nil {
  26728. return v, errors.New("OldStatus requires an ID field in the mutation")
  26729. }
  26730. oldValue, err := m.oldValue(ctx)
  26731. if err != nil {
  26732. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26733. }
  26734. return oldValue.Status, nil
  26735. }
  26736. // AddStatus adds u to the "status" field.
  26737. func (m *SopNodeMutation) AddStatus(u int8) {
  26738. if m.addstatus != nil {
  26739. *m.addstatus += u
  26740. } else {
  26741. m.addstatus = &u
  26742. }
  26743. }
  26744. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26745. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  26746. v := m.addstatus
  26747. if v == nil {
  26748. return
  26749. }
  26750. return *v, true
  26751. }
  26752. // ClearStatus clears the value of the "status" field.
  26753. func (m *SopNodeMutation) ClearStatus() {
  26754. m.status = nil
  26755. m.addstatus = nil
  26756. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  26757. }
  26758. // StatusCleared returns if the "status" field was cleared in this mutation.
  26759. func (m *SopNodeMutation) StatusCleared() bool {
  26760. _, ok := m.clearedFields[sopnode.FieldStatus]
  26761. return ok
  26762. }
  26763. // ResetStatus resets all changes to the "status" field.
  26764. func (m *SopNodeMutation) ResetStatus() {
  26765. m.status = nil
  26766. m.addstatus = nil
  26767. delete(m.clearedFields, sopnode.FieldStatus)
  26768. }
  26769. // SetDeletedAt sets the "deleted_at" field.
  26770. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  26771. m.deleted_at = &t
  26772. }
  26773. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26774. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  26775. v := m.deleted_at
  26776. if v == nil {
  26777. return
  26778. }
  26779. return *v, true
  26780. }
  26781. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  26782. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26784. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26785. if !m.op.Is(OpUpdateOne) {
  26786. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26787. }
  26788. if m.id == nil || m.oldValue == nil {
  26789. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26790. }
  26791. oldValue, err := m.oldValue(ctx)
  26792. if err != nil {
  26793. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26794. }
  26795. return oldValue.DeletedAt, nil
  26796. }
  26797. // ClearDeletedAt clears the value of the "deleted_at" field.
  26798. func (m *SopNodeMutation) ClearDeletedAt() {
  26799. m.deleted_at = nil
  26800. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  26801. }
  26802. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26803. func (m *SopNodeMutation) DeletedAtCleared() bool {
  26804. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  26805. return ok
  26806. }
  26807. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26808. func (m *SopNodeMutation) ResetDeletedAt() {
  26809. m.deleted_at = nil
  26810. delete(m.clearedFields, sopnode.FieldDeletedAt)
  26811. }
  26812. // SetStageID sets the "stage_id" field.
  26813. func (m *SopNodeMutation) SetStageID(u uint64) {
  26814. m.sop_stage = &u
  26815. }
  26816. // StageID returns the value of the "stage_id" field in the mutation.
  26817. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  26818. v := m.sop_stage
  26819. if v == nil {
  26820. return
  26821. }
  26822. return *v, true
  26823. }
  26824. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  26825. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26827. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  26828. if !m.op.Is(OpUpdateOne) {
  26829. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  26830. }
  26831. if m.id == nil || m.oldValue == nil {
  26832. return v, errors.New("OldStageID requires an ID field in the mutation")
  26833. }
  26834. oldValue, err := m.oldValue(ctx)
  26835. if err != nil {
  26836. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  26837. }
  26838. return oldValue.StageID, nil
  26839. }
  26840. // ResetStageID resets all changes to the "stage_id" field.
  26841. func (m *SopNodeMutation) ResetStageID() {
  26842. m.sop_stage = nil
  26843. }
  26844. // SetParentID sets the "parent_id" field.
  26845. func (m *SopNodeMutation) SetParentID(u uint64) {
  26846. m.parent_id = &u
  26847. m.addparent_id = nil
  26848. }
  26849. // ParentID returns the value of the "parent_id" field in the mutation.
  26850. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  26851. v := m.parent_id
  26852. if v == nil {
  26853. return
  26854. }
  26855. return *v, true
  26856. }
  26857. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  26858. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26860. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  26861. if !m.op.Is(OpUpdateOne) {
  26862. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  26863. }
  26864. if m.id == nil || m.oldValue == nil {
  26865. return v, errors.New("OldParentID requires an ID field in the mutation")
  26866. }
  26867. oldValue, err := m.oldValue(ctx)
  26868. if err != nil {
  26869. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  26870. }
  26871. return oldValue.ParentID, nil
  26872. }
  26873. // AddParentID adds u to the "parent_id" field.
  26874. func (m *SopNodeMutation) AddParentID(u int64) {
  26875. if m.addparent_id != nil {
  26876. *m.addparent_id += u
  26877. } else {
  26878. m.addparent_id = &u
  26879. }
  26880. }
  26881. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  26882. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  26883. v := m.addparent_id
  26884. if v == nil {
  26885. return
  26886. }
  26887. return *v, true
  26888. }
  26889. // ResetParentID resets all changes to the "parent_id" field.
  26890. func (m *SopNodeMutation) ResetParentID() {
  26891. m.parent_id = nil
  26892. m.addparent_id = nil
  26893. }
  26894. // SetName sets the "name" field.
  26895. func (m *SopNodeMutation) SetName(s string) {
  26896. m.name = &s
  26897. }
  26898. // Name returns the value of the "name" field in the mutation.
  26899. func (m *SopNodeMutation) Name() (r string, exists bool) {
  26900. v := m.name
  26901. if v == nil {
  26902. return
  26903. }
  26904. return *v, true
  26905. }
  26906. // OldName returns the old "name" field's value of the SopNode entity.
  26907. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26909. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  26910. if !m.op.Is(OpUpdateOne) {
  26911. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26912. }
  26913. if m.id == nil || m.oldValue == nil {
  26914. return v, errors.New("OldName requires an ID field in the mutation")
  26915. }
  26916. oldValue, err := m.oldValue(ctx)
  26917. if err != nil {
  26918. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26919. }
  26920. return oldValue.Name, nil
  26921. }
  26922. // ResetName resets all changes to the "name" field.
  26923. func (m *SopNodeMutation) ResetName() {
  26924. m.name = nil
  26925. }
  26926. // SetConditionType sets the "condition_type" field.
  26927. func (m *SopNodeMutation) SetConditionType(i int) {
  26928. m.condition_type = &i
  26929. m.addcondition_type = nil
  26930. }
  26931. // ConditionType returns the value of the "condition_type" field in the mutation.
  26932. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  26933. v := m.condition_type
  26934. if v == nil {
  26935. return
  26936. }
  26937. return *v, true
  26938. }
  26939. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  26940. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26942. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  26943. if !m.op.Is(OpUpdateOne) {
  26944. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  26945. }
  26946. if m.id == nil || m.oldValue == nil {
  26947. return v, errors.New("OldConditionType requires an ID field in the mutation")
  26948. }
  26949. oldValue, err := m.oldValue(ctx)
  26950. if err != nil {
  26951. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  26952. }
  26953. return oldValue.ConditionType, nil
  26954. }
  26955. // AddConditionType adds i to the "condition_type" field.
  26956. func (m *SopNodeMutation) AddConditionType(i int) {
  26957. if m.addcondition_type != nil {
  26958. *m.addcondition_type += i
  26959. } else {
  26960. m.addcondition_type = &i
  26961. }
  26962. }
  26963. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  26964. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  26965. v := m.addcondition_type
  26966. if v == nil {
  26967. return
  26968. }
  26969. return *v, true
  26970. }
  26971. // ResetConditionType resets all changes to the "condition_type" field.
  26972. func (m *SopNodeMutation) ResetConditionType() {
  26973. m.condition_type = nil
  26974. m.addcondition_type = nil
  26975. }
  26976. // SetConditionList sets the "condition_list" field.
  26977. func (m *SopNodeMutation) SetConditionList(s []string) {
  26978. m.condition_list = &s
  26979. m.appendcondition_list = nil
  26980. }
  26981. // ConditionList returns the value of the "condition_list" field in the mutation.
  26982. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  26983. v := m.condition_list
  26984. if v == nil {
  26985. return
  26986. }
  26987. return *v, true
  26988. }
  26989. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  26990. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  26991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26992. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  26993. if !m.op.Is(OpUpdateOne) {
  26994. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  26995. }
  26996. if m.id == nil || m.oldValue == nil {
  26997. return v, errors.New("OldConditionList requires an ID field in the mutation")
  26998. }
  26999. oldValue, err := m.oldValue(ctx)
  27000. if err != nil {
  27001. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  27002. }
  27003. return oldValue.ConditionList, nil
  27004. }
  27005. // AppendConditionList adds s to the "condition_list" field.
  27006. func (m *SopNodeMutation) AppendConditionList(s []string) {
  27007. m.appendcondition_list = append(m.appendcondition_list, s...)
  27008. }
  27009. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  27010. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  27011. if len(m.appendcondition_list) == 0 {
  27012. return nil, false
  27013. }
  27014. return m.appendcondition_list, true
  27015. }
  27016. // ClearConditionList clears the value of the "condition_list" field.
  27017. func (m *SopNodeMutation) ClearConditionList() {
  27018. m.condition_list = nil
  27019. m.appendcondition_list = nil
  27020. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  27021. }
  27022. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  27023. func (m *SopNodeMutation) ConditionListCleared() bool {
  27024. _, ok := m.clearedFields[sopnode.FieldConditionList]
  27025. return ok
  27026. }
  27027. // ResetConditionList resets all changes to the "condition_list" field.
  27028. func (m *SopNodeMutation) ResetConditionList() {
  27029. m.condition_list = nil
  27030. m.appendcondition_list = nil
  27031. delete(m.clearedFields, sopnode.FieldConditionList)
  27032. }
  27033. // SetNoReplyCondition sets the "no_reply_condition" field.
  27034. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  27035. m.no_reply_condition = &u
  27036. m.addno_reply_condition = nil
  27037. }
  27038. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  27039. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  27040. v := m.no_reply_condition
  27041. if v == nil {
  27042. return
  27043. }
  27044. return *v, true
  27045. }
  27046. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  27047. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27049. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  27050. if !m.op.Is(OpUpdateOne) {
  27051. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  27052. }
  27053. if m.id == nil || m.oldValue == nil {
  27054. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  27055. }
  27056. oldValue, err := m.oldValue(ctx)
  27057. if err != nil {
  27058. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  27059. }
  27060. return oldValue.NoReplyCondition, nil
  27061. }
  27062. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  27063. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  27064. if m.addno_reply_condition != nil {
  27065. *m.addno_reply_condition += u
  27066. } else {
  27067. m.addno_reply_condition = &u
  27068. }
  27069. }
  27070. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  27071. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  27072. v := m.addno_reply_condition
  27073. if v == nil {
  27074. return
  27075. }
  27076. return *v, true
  27077. }
  27078. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  27079. func (m *SopNodeMutation) ResetNoReplyCondition() {
  27080. m.no_reply_condition = nil
  27081. m.addno_reply_condition = nil
  27082. }
  27083. // SetNoReplyUnit sets the "no_reply_unit" field.
  27084. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  27085. m.no_reply_unit = &s
  27086. }
  27087. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  27088. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  27089. v := m.no_reply_unit
  27090. if v == nil {
  27091. return
  27092. }
  27093. return *v, true
  27094. }
  27095. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  27096. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27098. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  27099. if !m.op.Is(OpUpdateOne) {
  27100. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  27101. }
  27102. if m.id == nil || m.oldValue == nil {
  27103. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  27104. }
  27105. oldValue, err := m.oldValue(ctx)
  27106. if err != nil {
  27107. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  27108. }
  27109. return oldValue.NoReplyUnit, nil
  27110. }
  27111. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  27112. func (m *SopNodeMutation) ResetNoReplyUnit() {
  27113. m.no_reply_unit = nil
  27114. }
  27115. // SetActionMessage sets the "action_message" field.
  27116. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  27117. m.action_message = &ct
  27118. m.appendaction_message = nil
  27119. }
  27120. // ActionMessage returns the value of the "action_message" field in the mutation.
  27121. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  27122. v := m.action_message
  27123. if v == nil {
  27124. return
  27125. }
  27126. return *v, true
  27127. }
  27128. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  27129. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27131. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  27132. if !m.op.Is(OpUpdateOne) {
  27133. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  27134. }
  27135. if m.id == nil || m.oldValue == nil {
  27136. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  27137. }
  27138. oldValue, err := m.oldValue(ctx)
  27139. if err != nil {
  27140. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  27141. }
  27142. return oldValue.ActionMessage, nil
  27143. }
  27144. // AppendActionMessage adds ct to the "action_message" field.
  27145. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  27146. m.appendaction_message = append(m.appendaction_message, ct...)
  27147. }
  27148. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  27149. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  27150. if len(m.appendaction_message) == 0 {
  27151. return nil, false
  27152. }
  27153. return m.appendaction_message, true
  27154. }
  27155. // ClearActionMessage clears the value of the "action_message" field.
  27156. func (m *SopNodeMutation) ClearActionMessage() {
  27157. m.action_message = nil
  27158. m.appendaction_message = nil
  27159. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  27160. }
  27161. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  27162. func (m *SopNodeMutation) ActionMessageCleared() bool {
  27163. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  27164. return ok
  27165. }
  27166. // ResetActionMessage resets all changes to the "action_message" field.
  27167. func (m *SopNodeMutation) ResetActionMessage() {
  27168. m.action_message = nil
  27169. m.appendaction_message = nil
  27170. delete(m.clearedFields, sopnode.FieldActionMessage)
  27171. }
  27172. // SetActionLabelAdd sets the "action_label_add" field.
  27173. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  27174. m.action_label_add = &u
  27175. m.appendaction_label_add = nil
  27176. }
  27177. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  27178. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  27179. v := m.action_label_add
  27180. if v == nil {
  27181. return
  27182. }
  27183. return *v, true
  27184. }
  27185. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  27186. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27188. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  27189. if !m.op.Is(OpUpdateOne) {
  27190. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  27191. }
  27192. if m.id == nil || m.oldValue == nil {
  27193. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  27194. }
  27195. oldValue, err := m.oldValue(ctx)
  27196. if err != nil {
  27197. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  27198. }
  27199. return oldValue.ActionLabelAdd, nil
  27200. }
  27201. // AppendActionLabelAdd adds u to the "action_label_add" field.
  27202. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  27203. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  27204. }
  27205. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  27206. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  27207. if len(m.appendaction_label_add) == 0 {
  27208. return nil, false
  27209. }
  27210. return m.appendaction_label_add, true
  27211. }
  27212. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  27213. func (m *SopNodeMutation) ClearActionLabelAdd() {
  27214. m.action_label_add = nil
  27215. m.appendaction_label_add = nil
  27216. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  27217. }
  27218. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  27219. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  27220. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  27221. return ok
  27222. }
  27223. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  27224. func (m *SopNodeMutation) ResetActionLabelAdd() {
  27225. m.action_label_add = nil
  27226. m.appendaction_label_add = nil
  27227. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  27228. }
  27229. // SetActionLabelDel sets the "action_label_del" field.
  27230. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  27231. m.action_label_del = &u
  27232. m.appendaction_label_del = nil
  27233. }
  27234. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  27235. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  27236. v := m.action_label_del
  27237. if v == nil {
  27238. return
  27239. }
  27240. return *v, true
  27241. }
  27242. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  27243. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27245. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  27246. if !m.op.Is(OpUpdateOne) {
  27247. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  27248. }
  27249. if m.id == nil || m.oldValue == nil {
  27250. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  27251. }
  27252. oldValue, err := m.oldValue(ctx)
  27253. if err != nil {
  27254. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  27255. }
  27256. return oldValue.ActionLabelDel, nil
  27257. }
  27258. // AppendActionLabelDel adds u to the "action_label_del" field.
  27259. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  27260. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  27261. }
  27262. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  27263. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  27264. if len(m.appendaction_label_del) == 0 {
  27265. return nil, false
  27266. }
  27267. return m.appendaction_label_del, true
  27268. }
  27269. // ClearActionLabelDel clears the value of the "action_label_del" field.
  27270. func (m *SopNodeMutation) ClearActionLabelDel() {
  27271. m.action_label_del = nil
  27272. m.appendaction_label_del = nil
  27273. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  27274. }
  27275. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  27276. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  27277. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  27278. return ok
  27279. }
  27280. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  27281. func (m *SopNodeMutation) ResetActionLabelDel() {
  27282. m.action_label_del = nil
  27283. m.appendaction_label_del = nil
  27284. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  27285. }
  27286. // SetActionForward sets the "action_forward" field.
  27287. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  27288. m.action_forward = &ctf
  27289. }
  27290. // ActionForward returns the value of the "action_forward" field in the mutation.
  27291. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  27292. v := m.action_forward
  27293. if v == nil {
  27294. return
  27295. }
  27296. return *v, true
  27297. }
  27298. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  27299. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  27300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27301. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  27302. if !m.op.Is(OpUpdateOne) {
  27303. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  27304. }
  27305. if m.id == nil || m.oldValue == nil {
  27306. return v, errors.New("OldActionForward requires an ID field in the mutation")
  27307. }
  27308. oldValue, err := m.oldValue(ctx)
  27309. if err != nil {
  27310. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  27311. }
  27312. return oldValue.ActionForward, nil
  27313. }
  27314. // ClearActionForward clears the value of the "action_forward" field.
  27315. func (m *SopNodeMutation) ClearActionForward() {
  27316. m.action_forward = nil
  27317. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  27318. }
  27319. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  27320. func (m *SopNodeMutation) ActionForwardCleared() bool {
  27321. _, ok := m.clearedFields[sopnode.FieldActionForward]
  27322. return ok
  27323. }
  27324. // ResetActionForward resets all changes to the "action_forward" field.
  27325. func (m *SopNodeMutation) ResetActionForward() {
  27326. m.action_forward = nil
  27327. delete(m.clearedFields, sopnode.FieldActionForward)
  27328. }
  27329. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  27330. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  27331. m.sop_stage = &id
  27332. }
  27333. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  27334. func (m *SopNodeMutation) ClearSopStage() {
  27335. m.clearedsop_stage = true
  27336. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  27337. }
  27338. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  27339. func (m *SopNodeMutation) SopStageCleared() bool {
  27340. return m.clearedsop_stage
  27341. }
  27342. // SopStageID returns the "sop_stage" edge ID in the mutation.
  27343. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  27344. if m.sop_stage != nil {
  27345. return *m.sop_stage, true
  27346. }
  27347. return
  27348. }
  27349. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  27350. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27351. // SopStageID instead. It exists only for internal usage by the builders.
  27352. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  27353. if id := m.sop_stage; id != nil {
  27354. ids = append(ids, *id)
  27355. }
  27356. return
  27357. }
  27358. // ResetSopStage resets all changes to the "sop_stage" edge.
  27359. func (m *SopNodeMutation) ResetSopStage() {
  27360. m.sop_stage = nil
  27361. m.clearedsop_stage = false
  27362. }
  27363. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  27364. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  27365. if m.node_messages == nil {
  27366. m.node_messages = make(map[uint64]struct{})
  27367. }
  27368. for i := range ids {
  27369. m.node_messages[ids[i]] = struct{}{}
  27370. }
  27371. }
  27372. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  27373. func (m *SopNodeMutation) ClearNodeMessages() {
  27374. m.clearednode_messages = true
  27375. }
  27376. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  27377. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  27378. return m.clearednode_messages
  27379. }
  27380. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  27381. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  27382. if m.removednode_messages == nil {
  27383. m.removednode_messages = make(map[uint64]struct{})
  27384. }
  27385. for i := range ids {
  27386. delete(m.node_messages, ids[i])
  27387. m.removednode_messages[ids[i]] = struct{}{}
  27388. }
  27389. }
  27390. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  27391. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  27392. for id := range m.removednode_messages {
  27393. ids = append(ids, id)
  27394. }
  27395. return
  27396. }
  27397. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  27398. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  27399. for id := range m.node_messages {
  27400. ids = append(ids, id)
  27401. }
  27402. return
  27403. }
  27404. // ResetNodeMessages resets all changes to the "node_messages" edge.
  27405. func (m *SopNodeMutation) ResetNodeMessages() {
  27406. m.node_messages = nil
  27407. m.clearednode_messages = false
  27408. m.removednode_messages = nil
  27409. }
  27410. // Where appends a list predicates to the SopNodeMutation builder.
  27411. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  27412. m.predicates = append(m.predicates, ps...)
  27413. }
  27414. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  27415. // users can use type-assertion to append predicates that do not depend on any generated package.
  27416. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  27417. p := make([]predicate.SopNode, len(ps))
  27418. for i := range ps {
  27419. p[i] = ps[i]
  27420. }
  27421. m.Where(p...)
  27422. }
  27423. // Op returns the operation name.
  27424. func (m *SopNodeMutation) Op() Op {
  27425. return m.op
  27426. }
  27427. // SetOp allows setting the mutation operation.
  27428. func (m *SopNodeMutation) SetOp(op Op) {
  27429. m.op = op
  27430. }
  27431. // Type returns the node type of this mutation (SopNode).
  27432. func (m *SopNodeMutation) Type() string {
  27433. return m.typ
  27434. }
  27435. // Fields returns all fields that were changed during this mutation. Note that in
  27436. // order to get all numeric fields that were incremented/decremented, call
  27437. // AddedFields().
  27438. func (m *SopNodeMutation) Fields() []string {
  27439. fields := make([]string, 0, 15)
  27440. if m.created_at != nil {
  27441. fields = append(fields, sopnode.FieldCreatedAt)
  27442. }
  27443. if m.updated_at != nil {
  27444. fields = append(fields, sopnode.FieldUpdatedAt)
  27445. }
  27446. if m.status != nil {
  27447. fields = append(fields, sopnode.FieldStatus)
  27448. }
  27449. if m.deleted_at != nil {
  27450. fields = append(fields, sopnode.FieldDeletedAt)
  27451. }
  27452. if m.sop_stage != nil {
  27453. fields = append(fields, sopnode.FieldStageID)
  27454. }
  27455. if m.parent_id != nil {
  27456. fields = append(fields, sopnode.FieldParentID)
  27457. }
  27458. if m.name != nil {
  27459. fields = append(fields, sopnode.FieldName)
  27460. }
  27461. if m.condition_type != nil {
  27462. fields = append(fields, sopnode.FieldConditionType)
  27463. }
  27464. if m.condition_list != nil {
  27465. fields = append(fields, sopnode.FieldConditionList)
  27466. }
  27467. if m.no_reply_condition != nil {
  27468. fields = append(fields, sopnode.FieldNoReplyCondition)
  27469. }
  27470. if m.no_reply_unit != nil {
  27471. fields = append(fields, sopnode.FieldNoReplyUnit)
  27472. }
  27473. if m.action_message != nil {
  27474. fields = append(fields, sopnode.FieldActionMessage)
  27475. }
  27476. if m.action_label_add != nil {
  27477. fields = append(fields, sopnode.FieldActionLabelAdd)
  27478. }
  27479. if m.action_label_del != nil {
  27480. fields = append(fields, sopnode.FieldActionLabelDel)
  27481. }
  27482. if m.action_forward != nil {
  27483. fields = append(fields, sopnode.FieldActionForward)
  27484. }
  27485. return fields
  27486. }
  27487. // Field returns the value of a field with the given name. The second boolean
  27488. // return value indicates that this field was not set, or was not defined in the
  27489. // schema.
  27490. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  27491. switch name {
  27492. case sopnode.FieldCreatedAt:
  27493. return m.CreatedAt()
  27494. case sopnode.FieldUpdatedAt:
  27495. return m.UpdatedAt()
  27496. case sopnode.FieldStatus:
  27497. return m.Status()
  27498. case sopnode.FieldDeletedAt:
  27499. return m.DeletedAt()
  27500. case sopnode.FieldStageID:
  27501. return m.StageID()
  27502. case sopnode.FieldParentID:
  27503. return m.ParentID()
  27504. case sopnode.FieldName:
  27505. return m.Name()
  27506. case sopnode.FieldConditionType:
  27507. return m.ConditionType()
  27508. case sopnode.FieldConditionList:
  27509. return m.ConditionList()
  27510. case sopnode.FieldNoReplyCondition:
  27511. return m.NoReplyCondition()
  27512. case sopnode.FieldNoReplyUnit:
  27513. return m.NoReplyUnit()
  27514. case sopnode.FieldActionMessage:
  27515. return m.ActionMessage()
  27516. case sopnode.FieldActionLabelAdd:
  27517. return m.ActionLabelAdd()
  27518. case sopnode.FieldActionLabelDel:
  27519. return m.ActionLabelDel()
  27520. case sopnode.FieldActionForward:
  27521. return m.ActionForward()
  27522. }
  27523. return nil, false
  27524. }
  27525. // OldField returns the old value of the field from the database. An error is
  27526. // returned if the mutation operation is not UpdateOne, or the query to the
  27527. // database failed.
  27528. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27529. switch name {
  27530. case sopnode.FieldCreatedAt:
  27531. return m.OldCreatedAt(ctx)
  27532. case sopnode.FieldUpdatedAt:
  27533. return m.OldUpdatedAt(ctx)
  27534. case sopnode.FieldStatus:
  27535. return m.OldStatus(ctx)
  27536. case sopnode.FieldDeletedAt:
  27537. return m.OldDeletedAt(ctx)
  27538. case sopnode.FieldStageID:
  27539. return m.OldStageID(ctx)
  27540. case sopnode.FieldParentID:
  27541. return m.OldParentID(ctx)
  27542. case sopnode.FieldName:
  27543. return m.OldName(ctx)
  27544. case sopnode.FieldConditionType:
  27545. return m.OldConditionType(ctx)
  27546. case sopnode.FieldConditionList:
  27547. return m.OldConditionList(ctx)
  27548. case sopnode.FieldNoReplyCondition:
  27549. return m.OldNoReplyCondition(ctx)
  27550. case sopnode.FieldNoReplyUnit:
  27551. return m.OldNoReplyUnit(ctx)
  27552. case sopnode.FieldActionMessage:
  27553. return m.OldActionMessage(ctx)
  27554. case sopnode.FieldActionLabelAdd:
  27555. return m.OldActionLabelAdd(ctx)
  27556. case sopnode.FieldActionLabelDel:
  27557. return m.OldActionLabelDel(ctx)
  27558. case sopnode.FieldActionForward:
  27559. return m.OldActionForward(ctx)
  27560. }
  27561. return nil, fmt.Errorf("unknown SopNode field %s", name)
  27562. }
  27563. // SetField sets the value of a field with the given name. It returns an error if
  27564. // the field is not defined in the schema, or if the type mismatched the field
  27565. // type.
  27566. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  27567. switch name {
  27568. case sopnode.FieldCreatedAt:
  27569. v, ok := value.(time.Time)
  27570. if !ok {
  27571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27572. }
  27573. m.SetCreatedAt(v)
  27574. return nil
  27575. case sopnode.FieldUpdatedAt:
  27576. v, ok := value.(time.Time)
  27577. if !ok {
  27578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27579. }
  27580. m.SetUpdatedAt(v)
  27581. return nil
  27582. case sopnode.FieldStatus:
  27583. v, ok := value.(uint8)
  27584. if !ok {
  27585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27586. }
  27587. m.SetStatus(v)
  27588. return nil
  27589. case sopnode.FieldDeletedAt:
  27590. v, ok := value.(time.Time)
  27591. if !ok {
  27592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27593. }
  27594. m.SetDeletedAt(v)
  27595. return nil
  27596. case sopnode.FieldStageID:
  27597. v, ok := value.(uint64)
  27598. if !ok {
  27599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27600. }
  27601. m.SetStageID(v)
  27602. return nil
  27603. case sopnode.FieldParentID:
  27604. v, ok := value.(uint64)
  27605. if !ok {
  27606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27607. }
  27608. m.SetParentID(v)
  27609. return nil
  27610. case sopnode.FieldName:
  27611. v, ok := value.(string)
  27612. if !ok {
  27613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27614. }
  27615. m.SetName(v)
  27616. return nil
  27617. case sopnode.FieldConditionType:
  27618. v, ok := value.(int)
  27619. if !ok {
  27620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27621. }
  27622. m.SetConditionType(v)
  27623. return nil
  27624. case sopnode.FieldConditionList:
  27625. v, ok := value.([]string)
  27626. if !ok {
  27627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27628. }
  27629. m.SetConditionList(v)
  27630. return nil
  27631. case sopnode.FieldNoReplyCondition:
  27632. v, ok := value.(uint64)
  27633. if !ok {
  27634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27635. }
  27636. m.SetNoReplyCondition(v)
  27637. return nil
  27638. case sopnode.FieldNoReplyUnit:
  27639. v, ok := value.(string)
  27640. if !ok {
  27641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27642. }
  27643. m.SetNoReplyUnit(v)
  27644. return nil
  27645. case sopnode.FieldActionMessage:
  27646. v, ok := value.([]custom_types.Action)
  27647. if !ok {
  27648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27649. }
  27650. m.SetActionMessage(v)
  27651. return nil
  27652. case sopnode.FieldActionLabelAdd:
  27653. v, ok := value.([]uint64)
  27654. if !ok {
  27655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27656. }
  27657. m.SetActionLabelAdd(v)
  27658. return nil
  27659. case sopnode.FieldActionLabelDel:
  27660. v, ok := value.([]uint64)
  27661. if !ok {
  27662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27663. }
  27664. m.SetActionLabelDel(v)
  27665. return nil
  27666. case sopnode.FieldActionForward:
  27667. v, ok := value.(*custom_types.ActionForward)
  27668. if !ok {
  27669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27670. }
  27671. m.SetActionForward(v)
  27672. return nil
  27673. }
  27674. return fmt.Errorf("unknown SopNode field %s", name)
  27675. }
  27676. // AddedFields returns all numeric fields that were incremented/decremented during
  27677. // this mutation.
  27678. func (m *SopNodeMutation) AddedFields() []string {
  27679. var fields []string
  27680. if m.addstatus != nil {
  27681. fields = append(fields, sopnode.FieldStatus)
  27682. }
  27683. if m.addparent_id != nil {
  27684. fields = append(fields, sopnode.FieldParentID)
  27685. }
  27686. if m.addcondition_type != nil {
  27687. fields = append(fields, sopnode.FieldConditionType)
  27688. }
  27689. if m.addno_reply_condition != nil {
  27690. fields = append(fields, sopnode.FieldNoReplyCondition)
  27691. }
  27692. return fields
  27693. }
  27694. // AddedField returns the numeric value that was incremented/decremented on a field
  27695. // with the given name. The second boolean return value indicates that this field
  27696. // was not set, or was not defined in the schema.
  27697. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  27698. switch name {
  27699. case sopnode.FieldStatus:
  27700. return m.AddedStatus()
  27701. case sopnode.FieldParentID:
  27702. return m.AddedParentID()
  27703. case sopnode.FieldConditionType:
  27704. return m.AddedConditionType()
  27705. case sopnode.FieldNoReplyCondition:
  27706. return m.AddedNoReplyCondition()
  27707. }
  27708. return nil, false
  27709. }
  27710. // AddField adds the value to the field with the given name. It returns an error if
  27711. // the field is not defined in the schema, or if the type mismatched the field
  27712. // type.
  27713. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  27714. switch name {
  27715. case sopnode.FieldStatus:
  27716. v, ok := value.(int8)
  27717. if !ok {
  27718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27719. }
  27720. m.AddStatus(v)
  27721. return nil
  27722. case sopnode.FieldParentID:
  27723. v, ok := value.(int64)
  27724. if !ok {
  27725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27726. }
  27727. m.AddParentID(v)
  27728. return nil
  27729. case sopnode.FieldConditionType:
  27730. v, ok := value.(int)
  27731. if !ok {
  27732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27733. }
  27734. m.AddConditionType(v)
  27735. return nil
  27736. case sopnode.FieldNoReplyCondition:
  27737. v, ok := value.(int64)
  27738. if !ok {
  27739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27740. }
  27741. m.AddNoReplyCondition(v)
  27742. return nil
  27743. }
  27744. return fmt.Errorf("unknown SopNode numeric field %s", name)
  27745. }
  27746. // ClearedFields returns all nullable fields that were cleared during this
  27747. // mutation.
  27748. func (m *SopNodeMutation) ClearedFields() []string {
  27749. var fields []string
  27750. if m.FieldCleared(sopnode.FieldStatus) {
  27751. fields = append(fields, sopnode.FieldStatus)
  27752. }
  27753. if m.FieldCleared(sopnode.FieldDeletedAt) {
  27754. fields = append(fields, sopnode.FieldDeletedAt)
  27755. }
  27756. if m.FieldCleared(sopnode.FieldConditionList) {
  27757. fields = append(fields, sopnode.FieldConditionList)
  27758. }
  27759. if m.FieldCleared(sopnode.FieldActionMessage) {
  27760. fields = append(fields, sopnode.FieldActionMessage)
  27761. }
  27762. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  27763. fields = append(fields, sopnode.FieldActionLabelAdd)
  27764. }
  27765. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  27766. fields = append(fields, sopnode.FieldActionLabelDel)
  27767. }
  27768. if m.FieldCleared(sopnode.FieldActionForward) {
  27769. fields = append(fields, sopnode.FieldActionForward)
  27770. }
  27771. return fields
  27772. }
  27773. // FieldCleared returns a boolean indicating if a field with the given name was
  27774. // cleared in this mutation.
  27775. func (m *SopNodeMutation) FieldCleared(name string) bool {
  27776. _, ok := m.clearedFields[name]
  27777. return ok
  27778. }
  27779. // ClearField clears the value of the field with the given name. It returns an
  27780. // error if the field is not defined in the schema.
  27781. func (m *SopNodeMutation) ClearField(name string) error {
  27782. switch name {
  27783. case sopnode.FieldStatus:
  27784. m.ClearStatus()
  27785. return nil
  27786. case sopnode.FieldDeletedAt:
  27787. m.ClearDeletedAt()
  27788. return nil
  27789. case sopnode.FieldConditionList:
  27790. m.ClearConditionList()
  27791. return nil
  27792. case sopnode.FieldActionMessage:
  27793. m.ClearActionMessage()
  27794. return nil
  27795. case sopnode.FieldActionLabelAdd:
  27796. m.ClearActionLabelAdd()
  27797. return nil
  27798. case sopnode.FieldActionLabelDel:
  27799. m.ClearActionLabelDel()
  27800. return nil
  27801. case sopnode.FieldActionForward:
  27802. m.ClearActionForward()
  27803. return nil
  27804. }
  27805. return fmt.Errorf("unknown SopNode nullable field %s", name)
  27806. }
  27807. // ResetField resets all changes in the mutation for the field with the given name.
  27808. // It returns an error if the field is not defined in the schema.
  27809. func (m *SopNodeMutation) ResetField(name string) error {
  27810. switch name {
  27811. case sopnode.FieldCreatedAt:
  27812. m.ResetCreatedAt()
  27813. return nil
  27814. case sopnode.FieldUpdatedAt:
  27815. m.ResetUpdatedAt()
  27816. return nil
  27817. case sopnode.FieldStatus:
  27818. m.ResetStatus()
  27819. return nil
  27820. case sopnode.FieldDeletedAt:
  27821. m.ResetDeletedAt()
  27822. return nil
  27823. case sopnode.FieldStageID:
  27824. m.ResetStageID()
  27825. return nil
  27826. case sopnode.FieldParentID:
  27827. m.ResetParentID()
  27828. return nil
  27829. case sopnode.FieldName:
  27830. m.ResetName()
  27831. return nil
  27832. case sopnode.FieldConditionType:
  27833. m.ResetConditionType()
  27834. return nil
  27835. case sopnode.FieldConditionList:
  27836. m.ResetConditionList()
  27837. return nil
  27838. case sopnode.FieldNoReplyCondition:
  27839. m.ResetNoReplyCondition()
  27840. return nil
  27841. case sopnode.FieldNoReplyUnit:
  27842. m.ResetNoReplyUnit()
  27843. return nil
  27844. case sopnode.FieldActionMessage:
  27845. m.ResetActionMessage()
  27846. return nil
  27847. case sopnode.FieldActionLabelAdd:
  27848. m.ResetActionLabelAdd()
  27849. return nil
  27850. case sopnode.FieldActionLabelDel:
  27851. m.ResetActionLabelDel()
  27852. return nil
  27853. case sopnode.FieldActionForward:
  27854. m.ResetActionForward()
  27855. return nil
  27856. }
  27857. return fmt.Errorf("unknown SopNode field %s", name)
  27858. }
  27859. // AddedEdges returns all edge names that were set/added in this mutation.
  27860. func (m *SopNodeMutation) AddedEdges() []string {
  27861. edges := make([]string, 0, 2)
  27862. if m.sop_stage != nil {
  27863. edges = append(edges, sopnode.EdgeSopStage)
  27864. }
  27865. if m.node_messages != nil {
  27866. edges = append(edges, sopnode.EdgeNodeMessages)
  27867. }
  27868. return edges
  27869. }
  27870. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27871. // name in this mutation.
  27872. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  27873. switch name {
  27874. case sopnode.EdgeSopStage:
  27875. if id := m.sop_stage; id != nil {
  27876. return []ent.Value{*id}
  27877. }
  27878. case sopnode.EdgeNodeMessages:
  27879. ids := make([]ent.Value, 0, len(m.node_messages))
  27880. for id := range m.node_messages {
  27881. ids = append(ids, id)
  27882. }
  27883. return ids
  27884. }
  27885. return nil
  27886. }
  27887. // RemovedEdges returns all edge names that were removed in this mutation.
  27888. func (m *SopNodeMutation) RemovedEdges() []string {
  27889. edges := make([]string, 0, 2)
  27890. if m.removednode_messages != nil {
  27891. edges = append(edges, sopnode.EdgeNodeMessages)
  27892. }
  27893. return edges
  27894. }
  27895. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27896. // the given name in this mutation.
  27897. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  27898. switch name {
  27899. case sopnode.EdgeNodeMessages:
  27900. ids := make([]ent.Value, 0, len(m.removednode_messages))
  27901. for id := range m.removednode_messages {
  27902. ids = append(ids, id)
  27903. }
  27904. return ids
  27905. }
  27906. return nil
  27907. }
  27908. // ClearedEdges returns all edge names that were cleared in this mutation.
  27909. func (m *SopNodeMutation) ClearedEdges() []string {
  27910. edges := make([]string, 0, 2)
  27911. if m.clearedsop_stage {
  27912. edges = append(edges, sopnode.EdgeSopStage)
  27913. }
  27914. if m.clearednode_messages {
  27915. edges = append(edges, sopnode.EdgeNodeMessages)
  27916. }
  27917. return edges
  27918. }
  27919. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27920. // was cleared in this mutation.
  27921. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  27922. switch name {
  27923. case sopnode.EdgeSopStage:
  27924. return m.clearedsop_stage
  27925. case sopnode.EdgeNodeMessages:
  27926. return m.clearednode_messages
  27927. }
  27928. return false
  27929. }
  27930. // ClearEdge clears the value of the edge with the given name. It returns an error
  27931. // if that edge is not defined in the schema.
  27932. func (m *SopNodeMutation) ClearEdge(name string) error {
  27933. switch name {
  27934. case sopnode.EdgeSopStage:
  27935. m.ClearSopStage()
  27936. return nil
  27937. }
  27938. return fmt.Errorf("unknown SopNode unique edge %s", name)
  27939. }
  27940. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27941. // It returns an error if the edge is not defined in the schema.
  27942. func (m *SopNodeMutation) ResetEdge(name string) error {
  27943. switch name {
  27944. case sopnode.EdgeSopStage:
  27945. m.ResetSopStage()
  27946. return nil
  27947. case sopnode.EdgeNodeMessages:
  27948. m.ResetNodeMessages()
  27949. return nil
  27950. }
  27951. return fmt.Errorf("unknown SopNode edge %s", name)
  27952. }
  27953. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  27954. type SopStageMutation struct {
  27955. config
  27956. op Op
  27957. typ string
  27958. id *uint64
  27959. created_at *time.Time
  27960. updated_at *time.Time
  27961. status *uint8
  27962. addstatus *int8
  27963. deleted_at *time.Time
  27964. name *string
  27965. condition_type *int
  27966. addcondition_type *int
  27967. condition_operator *int
  27968. addcondition_operator *int
  27969. condition_list *[]custom_types.Condition
  27970. appendcondition_list []custom_types.Condition
  27971. action_message *[]custom_types.Action
  27972. appendaction_message []custom_types.Action
  27973. action_label_add *[]uint64
  27974. appendaction_label_add []uint64
  27975. action_label_del *[]uint64
  27976. appendaction_label_del []uint64
  27977. action_forward **custom_types.ActionForward
  27978. index_sort *int
  27979. addindex_sort *int
  27980. clearedFields map[string]struct{}
  27981. sop_task *uint64
  27982. clearedsop_task bool
  27983. stage_nodes map[uint64]struct{}
  27984. removedstage_nodes map[uint64]struct{}
  27985. clearedstage_nodes bool
  27986. stage_messages map[uint64]struct{}
  27987. removedstage_messages map[uint64]struct{}
  27988. clearedstage_messages bool
  27989. done bool
  27990. oldValue func(context.Context) (*SopStage, error)
  27991. predicates []predicate.SopStage
  27992. }
  27993. var _ ent.Mutation = (*SopStageMutation)(nil)
  27994. // sopstageOption allows management of the mutation configuration using functional options.
  27995. type sopstageOption func(*SopStageMutation)
  27996. // newSopStageMutation creates new mutation for the SopStage entity.
  27997. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  27998. m := &SopStageMutation{
  27999. config: c,
  28000. op: op,
  28001. typ: TypeSopStage,
  28002. clearedFields: make(map[string]struct{}),
  28003. }
  28004. for _, opt := range opts {
  28005. opt(m)
  28006. }
  28007. return m
  28008. }
  28009. // withSopStageID sets the ID field of the mutation.
  28010. func withSopStageID(id uint64) sopstageOption {
  28011. return func(m *SopStageMutation) {
  28012. var (
  28013. err error
  28014. once sync.Once
  28015. value *SopStage
  28016. )
  28017. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  28018. once.Do(func() {
  28019. if m.done {
  28020. err = errors.New("querying old values post mutation is not allowed")
  28021. } else {
  28022. value, err = m.Client().SopStage.Get(ctx, id)
  28023. }
  28024. })
  28025. return value, err
  28026. }
  28027. m.id = &id
  28028. }
  28029. }
  28030. // withSopStage sets the old SopStage of the mutation.
  28031. func withSopStage(node *SopStage) sopstageOption {
  28032. return func(m *SopStageMutation) {
  28033. m.oldValue = func(context.Context) (*SopStage, error) {
  28034. return node, nil
  28035. }
  28036. m.id = &node.ID
  28037. }
  28038. }
  28039. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28040. // executed in a transaction (ent.Tx), a transactional client is returned.
  28041. func (m SopStageMutation) Client() *Client {
  28042. client := &Client{config: m.config}
  28043. client.init()
  28044. return client
  28045. }
  28046. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28047. // it returns an error otherwise.
  28048. func (m SopStageMutation) Tx() (*Tx, error) {
  28049. if _, ok := m.driver.(*txDriver); !ok {
  28050. return nil, errors.New("ent: mutation is not running in a transaction")
  28051. }
  28052. tx := &Tx{config: m.config}
  28053. tx.init()
  28054. return tx, nil
  28055. }
  28056. // SetID sets the value of the id field. Note that this
  28057. // operation is only accepted on creation of SopStage entities.
  28058. func (m *SopStageMutation) SetID(id uint64) {
  28059. m.id = &id
  28060. }
  28061. // ID returns the ID value in the mutation. Note that the ID is only available
  28062. // if it was provided to the builder or after it was returned from the database.
  28063. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  28064. if m.id == nil {
  28065. return
  28066. }
  28067. return *m.id, true
  28068. }
  28069. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28070. // That means, if the mutation is applied within a transaction with an isolation level such
  28071. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28072. // or updated by the mutation.
  28073. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  28074. switch {
  28075. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28076. id, exists := m.ID()
  28077. if exists {
  28078. return []uint64{id}, nil
  28079. }
  28080. fallthrough
  28081. case m.op.Is(OpUpdate | OpDelete):
  28082. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  28083. default:
  28084. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28085. }
  28086. }
  28087. // SetCreatedAt sets the "created_at" field.
  28088. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  28089. m.created_at = &t
  28090. }
  28091. // CreatedAt returns the value of the "created_at" field in the mutation.
  28092. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  28093. v := m.created_at
  28094. if v == nil {
  28095. return
  28096. }
  28097. return *v, true
  28098. }
  28099. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  28100. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28102. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28103. if !m.op.Is(OpUpdateOne) {
  28104. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28105. }
  28106. if m.id == nil || m.oldValue == nil {
  28107. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28108. }
  28109. oldValue, err := m.oldValue(ctx)
  28110. if err != nil {
  28111. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28112. }
  28113. return oldValue.CreatedAt, nil
  28114. }
  28115. // ResetCreatedAt resets all changes to the "created_at" field.
  28116. func (m *SopStageMutation) ResetCreatedAt() {
  28117. m.created_at = nil
  28118. }
  28119. // SetUpdatedAt sets the "updated_at" field.
  28120. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  28121. m.updated_at = &t
  28122. }
  28123. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28124. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  28125. v := m.updated_at
  28126. if v == nil {
  28127. return
  28128. }
  28129. return *v, true
  28130. }
  28131. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  28132. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28134. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28135. if !m.op.Is(OpUpdateOne) {
  28136. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28137. }
  28138. if m.id == nil || m.oldValue == nil {
  28139. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28140. }
  28141. oldValue, err := m.oldValue(ctx)
  28142. if err != nil {
  28143. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28144. }
  28145. return oldValue.UpdatedAt, nil
  28146. }
  28147. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28148. func (m *SopStageMutation) ResetUpdatedAt() {
  28149. m.updated_at = nil
  28150. }
  28151. // SetStatus sets the "status" field.
  28152. func (m *SopStageMutation) SetStatus(u uint8) {
  28153. m.status = &u
  28154. m.addstatus = nil
  28155. }
  28156. // Status returns the value of the "status" field in the mutation.
  28157. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  28158. v := m.status
  28159. if v == nil {
  28160. return
  28161. }
  28162. return *v, true
  28163. }
  28164. // OldStatus returns the old "status" field's value of the SopStage entity.
  28165. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28167. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28168. if !m.op.Is(OpUpdateOne) {
  28169. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28170. }
  28171. if m.id == nil || m.oldValue == nil {
  28172. return v, errors.New("OldStatus requires an ID field in the mutation")
  28173. }
  28174. oldValue, err := m.oldValue(ctx)
  28175. if err != nil {
  28176. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28177. }
  28178. return oldValue.Status, nil
  28179. }
  28180. // AddStatus adds u to the "status" field.
  28181. func (m *SopStageMutation) AddStatus(u int8) {
  28182. if m.addstatus != nil {
  28183. *m.addstatus += u
  28184. } else {
  28185. m.addstatus = &u
  28186. }
  28187. }
  28188. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28189. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  28190. v := m.addstatus
  28191. if v == nil {
  28192. return
  28193. }
  28194. return *v, true
  28195. }
  28196. // ClearStatus clears the value of the "status" field.
  28197. func (m *SopStageMutation) ClearStatus() {
  28198. m.status = nil
  28199. m.addstatus = nil
  28200. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  28201. }
  28202. // StatusCleared returns if the "status" field was cleared in this mutation.
  28203. func (m *SopStageMutation) StatusCleared() bool {
  28204. _, ok := m.clearedFields[sopstage.FieldStatus]
  28205. return ok
  28206. }
  28207. // ResetStatus resets all changes to the "status" field.
  28208. func (m *SopStageMutation) ResetStatus() {
  28209. m.status = nil
  28210. m.addstatus = nil
  28211. delete(m.clearedFields, sopstage.FieldStatus)
  28212. }
  28213. // SetDeletedAt sets the "deleted_at" field.
  28214. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  28215. m.deleted_at = &t
  28216. }
  28217. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28218. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  28219. v := m.deleted_at
  28220. if v == nil {
  28221. return
  28222. }
  28223. return *v, true
  28224. }
  28225. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  28226. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28228. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28229. if !m.op.Is(OpUpdateOne) {
  28230. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28231. }
  28232. if m.id == nil || m.oldValue == nil {
  28233. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28234. }
  28235. oldValue, err := m.oldValue(ctx)
  28236. if err != nil {
  28237. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28238. }
  28239. return oldValue.DeletedAt, nil
  28240. }
  28241. // ClearDeletedAt clears the value of the "deleted_at" field.
  28242. func (m *SopStageMutation) ClearDeletedAt() {
  28243. m.deleted_at = nil
  28244. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  28245. }
  28246. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28247. func (m *SopStageMutation) DeletedAtCleared() bool {
  28248. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  28249. return ok
  28250. }
  28251. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28252. func (m *SopStageMutation) ResetDeletedAt() {
  28253. m.deleted_at = nil
  28254. delete(m.clearedFields, sopstage.FieldDeletedAt)
  28255. }
  28256. // SetTaskID sets the "task_id" field.
  28257. func (m *SopStageMutation) SetTaskID(u uint64) {
  28258. m.sop_task = &u
  28259. }
  28260. // TaskID returns the value of the "task_id" field in the mutation.
  28261. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  28262. v := m.sop_task
  28263. if v == nil {
  28264. return
  28265. }
  28266. return *v, true
  28267. }
  28268. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  28269. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28271. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  28272. if !m.op.Is(OpUpdateOne) {
  28273. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  28274. }
  28275. if m.id == nil || m.oldValue == nil {
  28276. return v, errors.New("OldTaskID requires an ID field in the mutation")
  28277. }
  28278. oldValue, err := m.oldValue(ctx)
  28279. if err != nil {
  28280. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  28281. }
  28282. return oldValue.TaskID, nil
  28283. }
  28284. // ResetTaskID resets all changes to the "task_id" field.
  28285. func (m *SopStageMutation) ResetTaskID() {
  28286. m.sop_task = nil
  28287. }
  28288. // SetName sets the "name" field.
  28289. func (m *SopStageMutation) SetName(s string) {
  28290. m.name = &s
  28291. }
  28292. // Name returns the value of the "name" field in the mutation.
  28293. func (m *SopStageMutation) Name() (r string, exists bool) {
  28294. v := m.name
  28295. if v == nil {
  28296. return
  28297. }
  28298. return *v, true
  28299. }
  28300. // OldName returns the old "name" field's value of the SopStage entity.
  28301. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28303. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  28304. if !m.op.Is(OpUpdateOne) {
  28305. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28306. }
  28307. if m.id == nil || m.oldValue == nil {
  28308. return v, errors.New("OldName requires an ID field in the mutation")
  28309. }
  28310. oldValue, err := m.oldValue(ctx)
  28311. if err != nil {
  28312. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28313. }
  28314. return oldValue.Name, nil
  28315. }
  28316. // ResetName resets all changes to the "name" field.
  28317. func (m *SopStageMutation) ResetName() {
  28318. m.name = nil
  28319. }
  28320. // SetConditionType sets the "condition_type" field.
  28321. func (m *SopStageMutation) SetConditionType(i int) {
  28322. m.condition_type = &i
  28323. m.addcondition_type = nil
  28324. }
  28325. // ConditionType returns the value of the "condition_type" field in the mutation.
  28326. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  28327. v := m.condition_type
  28328. if v == nil {
  28329. return
  28330. }
  28331. return *v, true
  28332. }
  28333. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  28334. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28336. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28337. if !m.op.Is(OpUpdateOne) {
  28338. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28339. }
  28340. if m.id == nil || m.oldValue == nil {
  28341. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28342. }
  28343. oldValue, err := m.oldValue(ctx)
  28344. if err != nil {
  28345. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28346. }
  28347. return oldValue.ConditionType, nil
  28348. }
  28349. // AddConditionType adds i to the "condition_type" field.
  28350. func (m *SopStageMutation) AddConditionType(i int) {
  28351. if m.addcondition_type != nil {
  28352. *m.addcondition_type += i
  28353. } else {
  28354. m.addcondition_type = &i
  28355. }
  28356. }
  28357. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28358. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  28359. v := m.addcondition_type
  28360. if v == nil {
  28361. return
  28362. }
  28363. return *v, true
  28364. }
  28365. // ResetConditionType resets all changes to the "condition_type" field.
  28366. func (m *SopStageMutation) ResetConditionType() {
  28367. m.condition_type = nil
  28368. m.addcondition_type = nil
  28369. }
  28370. // SetConditionOperator sets the "condition_operator" field.
  28371. func (m *SopStageMutation) SetConditionOperator(i int) {
  28372. m.condition_operator = &i
  28373. m.addcondition_operator = nil
  28374. }
  28375. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  28376. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  28377. v := m.condition_operator
  28378. if v == nil {
  28379. return
  28380. }
  28381. return *v, true
  28382. }
  28383. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  28384. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28386. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  28387. if !m.op.Is(OpUpdateOne) {
  28388. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  28389. }
  28390. if m.id == nil || m.oldValue == nil {
  28391. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  28392. }
  28393. oldValue, err := m.oldValue(ctx)
  28394. if err != nil {
  28395. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  28396. }
  28397. return oldValue.ConditionOperator, nil
  28398. }
  28399. // AddConditionOperator adds i to the "condition_operator" field.
  28400. func (m *SopStageMutation) AddConditionOperator(i int) {
  28401. if m.addcondition_operator != nil {
  28402. *m.addcondition_operator += i
  28403. } else {
  28404. m.addcondition_operator = &i
  28405. }
  28406. }
  28407. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  28408. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  28409. v := m.addcondition_operator
  28410. if v == nil {
  28411. return
  28412. }
  28413. return *v, true
  28414. }
  28415. // ResetConditionOperator resets all changes to the "condition_operator" field.
  28416. func (m *SopStageMutation) ResetConditionOperator() {
  28417. m.condition_operator = nil
  28418. m.addcondition_operator = nil
  28419. }
  28420. // SetConditionList sets the "condition_list" field.
  28421. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  28422. m.condition_list = &ct
  28423. m.appendcondition_list = nil
  28424. }
  28425. // ConditionList returns the value of the "condition_list" field in the mutation.
  28426. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  28427. v := m.condition_list
  28428. if v == nil {
  28429. return
  28430. }
  28431. return *v, true
  28432. }
  28433. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  28434. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28436. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  28437. if !m.op.Is(OpUpdateOne) {
  28438. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  28439. }
  28440. if m.id == nil || m.oldValue == nil {
  28441. return v, errors.New("OldConditionList requires an ID field in the mutation")
  28442. }
  28443. oldValue, err := m.oldValue(ctx)
  28444. if err != nil {
  28445. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  28446. }
  28447. return oldValue.ConditionList, nil
  28448. }
  28449. // AppendConditionList adds ct to the "condition_list" field.
  28450. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  28451. m.appendcondition_list = append(m.appendcondition_list, ct...)
  28452. }
  28453. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  28454. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  28455. if len(m.appendcondition_list) == 0 {
  28456. return nil, false
  28457. }
  28458. return m.appendcondition_list, true
  28459. }
  28460. // ResetConditionList resets all changes to the "condition_list" field.
  28461. func (m *SopStageMutation) ResetConditionList() {
  28462. m.condition_list = nil
  28463. m.appendcondition_list = nil
  28464. }
  28465. // SetActionMessage sets the "action_message" field.
  28466. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  28467. m.action_message = &ct
  28468. m.appendaction_message = nil
  28469. }
  28470. // ActionMessage returns the value of the "action_message" field in the mutation.
  28471. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  28472. v := m.action_message
  28473. if v == nil {
  28474. return
  28475. }
  28476. return *v, true
  28477. }
  28478. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  28479. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28481. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  28482. if !m.op.Is(OpUpdateOne) {
  28483. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  28484. }
  28485. if m.id == nil || m.oldValue == nil {
  28486. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  28487. }
  28488. oldValue, err := m.oldValue(ctx)
  28489. if err != nil {
  28490. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  28491. }
  28492. return oldValue.ActionMessage, nil
  28493. }
  28494. // AppendActionMessage adds ct to the "action_message" field.
  28495. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  28496. m.appendaction_message = append(m.appendaction_message, ct...)
  28497. }
  28498. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  28499. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  28500. if len(m.appendaction_message) == 0 {
  28501. return nil, false
  28502. }
  28503. return m.appendaction_message, true
  28504. }
  28505. // ClearActionMessage clears the value of the "action_message" field.
  28506. func (m *SopStageMutation) ClearActionMessage() {
  28507. m.action_message = nil
  28508. m.appendaction_message = nil
  28509. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  28510. }
  28511. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  28512. func (m *SopStageMutation) ActionMessageCleared() bool {
  28513. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  28514. return ok
  28515. }
  28516. // ResetActionMessage resets all changes to the "action_message" field.
  28517. func (m *SopStageMutation) ResetActionMessage() {
  28518. m.action_message = nil
  28519. m.appendaction_message = nil
  28520. delete(m.clearedFields, sopstage.FieldActionMessage)
  28521. }
  28522. // SetActionLabelAdd sets the "action_label_add" field.
  28523. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  28524. m.action_label_add = &u
  28525. m.appendaction_label_add = nil
  28526. }
  28527. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  28528. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  28529. v := m.action_label_add
  28530. if v == nil {
  28531. return
  28532. }
  28533. return *v, true
  28534. }
  28535. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  28536. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28538. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  28539. if !m.op.Is(OpUpdateOne) {
  28540. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  28541. }
  28542. if m.id == nil || m.oldValue == nil {
  28543. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  28544. }
  28545. oldValue, err := m.oldValue(ctx)
  28546. if err != nil {
  28547. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  28548. }
  28549. return oldValue.ActionLabelAdd, nil
  28550. }
  28551. // AppendActionLabelAdd adds u to the "action_label_add" field.
  28552. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  28553. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  28554. }
  28555. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  28556. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  28557. if len(m.appendaction_label_add) == 0 {
  28558. return nil, false
  28559. }
  28560. return m.appendaction_label_add, true
  28561. }
  28562. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  28563. func (m *SopStageMutation) ClearActionLabelAdd() {
  28564. m.action_label_add = nil
  28565. m.appendaction_label_add = nil
  28566. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  28567. }
  28568. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  28569. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  28570. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  28571. return ok
  28572. }
  28573. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  28574. func (m *SopStageMutation) ResetActionLabelAdd() {
  28575. m.action_label_add = nil
  28576. m.appendaction_label_add = nil
  28577. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  28578. }
  28579. // SetActionLabelDel sets the "action_label_del" field.
  28580. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  28581. m.action_label_del = &u
  28582. m.appendaction_label_del = nil
  28583. }
  28584. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  28585. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  28586. v := m.action_label_del
  28587. if v == nil {
  28588. return
  28589. }
  28590. return *v, true
  28591. }
  28592. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  28593. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28595. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  28596. if !m.op.Is(OpUpdateOne) {
  28597. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  28598. }
  28599. if m.id == nil || m.oldValue == nil {
  28600. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  28601. }
  28602. oldValue, err := m.oldValue(ctx)
  28603. if err != nil {
  28604. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  28605. }
  28606. return oldValue.ActionLabelDel, nil
  28607. }
  28608. // AppendActionLabelDel adds u to the "action_label_del" field.
  28609. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  28610. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  28611. }
  28612. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  28613. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  28614. if len(m.appendaction_label_del) == 0 {
  28615. return nil, false
  28616. }
  28617. return m.appendaction_label_del, true
  28618. }
  28619. // ClearActionLabelDel clears the value of the "action_label_del" field.
  28620. func (m *SopStageMutation) ClearActionLabelDel() {
  28621. m.action_label_del = nil
  28622. m.appendaction_label_del = nil
  28623. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  28624. }
  28625. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  28626. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  28627. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  28628. return ok
  28629. }
  28630. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  28631. func (m *SopStageMutation) ResetActionLabelDel() {
  28632. m.action_label_del = nil
  28633. m.appendaction_label_del = nil
  28634. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  28635. }
  28636. // SetActionForward sets the "action_forward" field.
  28637. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  28638. m.action_forward = &ctf
  28639. }
  28640. // ActionForward returns the value of the "action_forward" field in the mutation.
  28641. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  28642. v := m.action_forward
  28643. if v == nil {
  28644. return
  28645. }
  28646. return *v, true
  28647. }
  28648. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  28649. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28651. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  28652. if !m.op.Is(OpUpdateOne) {
  28653. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  28654. }
  28655. if m.id == nil || m.oldValue == nil {
  28656. return v, errors.New("OldActionForward requires an ID field in the mutation")
  28657. }
  28658. oldValue, err := m.oldValue(ctx)
  28659. if err != nil {
  28660. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  28661. }
  28662. return oldValue.ActionForward, nil
  28663. }
  28664. // ClearActionForward clears the value of the "action_forward" field.
  28665. func (m *SopStageMutation) ClearActionForward() {
  28666. m.action_forward = nil
  28667. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  28668. }
  28669. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  28670. func (m *SopStageMutation) ActionForwardCleared() bool {
  28671. _, ok := m.clearedFields[sopstage.FieldActionForward]
  28672. return ok
  28673. }
  28674. // ResetActionForward resets all changes to the "action_forward" field.
  28675. func (m *SopStageMutation) ResetActionForward() {
  28676. m.action_forward = nil
  28677. delete(m.clearedFields, sopstage.FieldActionForward)
  28678. }
  28679. // SetIndexSort sets the "index_sort" field.
  28680. func (m *SopStageMutation) SetIndexSort(i int) {
  28681. m.index_sort = &i
  28682. m.addindex_sort = nil
  28683. }
  28684. // IndexSort returns the value of the "index_sort" field in the mutation.
  28685. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  28686. v := m.index_sort
  28687. if v == nil {
  28688. return
  28689. }
  28690. return *v, true
  28691. }
  28692. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  28693. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  28694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28695. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  28696. if !m.op.Is(OpUpdateOne) {
  28697. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  28698. }
  28699. if m.id == nil || m.oldValue == nil {
  28700. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  28701. }
  28702. oldValue, err := m.oldValue(ctx)
  28703. if err != nil {
  28704. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  28705. }
  28706. return oldValue.IndexSort, nil
  28707. }
  28708. // AddIndexSort adds i to the "index_sort" field.
  28709. func (m *SopStageMutation) AddIndexSort(i int) {
  28710. if m.addindex_sort != nil {
  28711. *m.addindex_sort += i
  28712. } else {
  28713. m.addindex_sort = &i
  28714. }
  28715. }
  28716. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  28717. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  28718. v := m.addindex_sort
  28719. if v == nil {
  28720. return
  28721. }
  28722. return *v, true
  28723. }
  28724. // ClearIndexSort clears the value of the "index_sort" field.
  28725. func (m *SopStageMutation) ClearIndexSort() {
  28726. m.index_sort = nil
  28727. m.addindex_sort = nil
  28728. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  28729. }
  28730. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  28731. func (m *SopStageMutation) IndexSortCleared() bool {
  28732. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  28733. return ok
  28734. }
  28735. // ResetIndexSort resets all changes to the "index_sort" field.
  28736. func (m *SopStageMutation) ResetIndexSort() {
  28737. m.index_sort = nil
  28738. m.addindex_sort = nil
  28739. delete(m.clearedFields, sopstage.FieldIndexSort)
  28740. }
  28741. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  28742. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  28743. m.sop_task = &id
  28744. }
  28745. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  28746. func (m *SopStageMutation) ClearSopTask() {
  28747. m.clearedsop_task = true
  28748. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  28749. }
  28750. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  28751. func (m *SopStageMutation) SopTaskCleared() bool {
  28752. return m.clearedsop_task
  28753. }
  28754. // SopTaskID returns the "sop_task" edge ID in the mutation.
  28755. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  28756. if m.sop_task != nil {
  28757. return *m.sop_task, true
  28758. }
  28759. return
  28760. }
  28761. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  28762. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28763. // SopTaskID instead. It exists only for internal usage by the builders.
  28764. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  28765. if id := m.sop_task; id != nil {
  28766. ids = append(ids, *id)
  28767. }
  28768. return
  28769. }
  28770. // ResetSopTask resets all changes to the "sop_task" edge.
  28771. func (m *SopStageMutation) ResetSopTask() {
  28772. m.sop_task = nil
  28773. m.clearedsop_task = false
  28774. }
  28775. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  28776. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  28777. if m.stage_nodes == nil {
  28778. m.stage_nodes = make(map[uint64]struct{})
  28779. }
  28780. for i := range ids {
  28781. m.stage_nodes[ids[i]] = struct{}{}
  28782. }
  28783. }
  28784. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  28785. func (m *SopStageMutation) ClearStageNodes() {
  28786. m.clearedstage_nodes = true
  28787. }
  28788. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  28789. func (m *SopStageMutation) StageNodesCleared() bool {
  28790. return m.clearedstage_nodes
  28791. }
  28792. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  28793. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  28794. if m.removedstage_nodes == nil {
  28795. m.removedstage_nodes = make(map[uint64]struct{})
  28796. }
  28797. for i := range ids {
  28798. delete(m.stage_nodes, ids[i])
  28799. m.removedstage_nodes[ids[i]] = struct{}{}
  28800. }
  28801. }
  28802. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  28803. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  28804. for id := range m.removedstage_nodes {
  28805. ids = append(ids, id)
  28806. }
  28807. return
  28808. }
  28809. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  28810. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  28811. for id := range m.stage_nodes {
  28812. ids = append(ids, id)
  28813. }
  28814. return
  28815. }
  28816. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  28817. func (m *SopStageMutation) ResetStageNodes() {
  28818. m.stage_nodes = nil
  28819. m.clearedstage_nodes = false
  28820. m.removedstage_nodes = nil
  28821. }
  28822. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  28823. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  28824. if m.stage_messages == nil {
  28825. m.stage_messages = make(map[uint64]struct{})
  28826. }
  28827. for i := range ids {
  28828. m.stage_messages[ids[i]] = struct{}{}
  28829. }
  28830. }
  28831. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  28832. func (m *SopStageMutation) ClearStageMessages() {
  28833. m.clearedstage_messages = true
  28834. }
  28835. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  28836. func (m *SopStageMutation) StageMessagesCleared() bool {
  28837. return m.clearedstage_messages
  28838. }
  28839. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  28840. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  28841. if m.removedstage_messages == nil {
  28842. m.removedstage_messages = make(map[uint64]struct{})
  28843. }
  28844. for i := range ids {
  28845. delete(m.stage_messages, ids[i])
  28846. m.removedstage_messages[ids[i]] = struct{}{}
  28847. }
  28848. }
  28849. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  28850. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  28851. for id := range m.removedstage_messages {
  28852. ids = append(ids, id)
  28853. }
  28854. return
  28855. }
  28856. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  28857. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  28858. for id := range m.stage_messages {
  28859. ids = append(ids, id)
  28860. }
  28861. return
  28862. }
  28863. // ResetStageMessages resets all changes to the "stage_messages" edge.
  28864. func (m *SopStageMutation) ResetStageMessages() {
  28865. m.stage_messages = nil
  28866. m.clearedstage_messages = false
  28867. m.removedstage_messages = nil
  28868. }
  28869. // Where appends a list predicates to the SopStageMutation builder.
  28870. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  28871. m.predicates = append(m.predicates, ps...)
  28872. }
  28873. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  28874. // users can use type-assertion to append predicates that do not depend on any generated package.
  28875. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  28876. p := make([]predicate.SopStage, len(ps))
  28877. for i := range ps {
  28878. p[i] = ps[i]
  28879. }
  28880. m.Where(p...)
  28881. }
  28882. // Op returns the operation name.
  28883. func (m *SopStageMutation) Op() Op {
  28884. return m.op
  28885. }
  28886. // SetOp allows setting the mutation operation.
  28887. func (m *SopStageMutation) SetOp(op Op) {
  28888. m.op = op
  28889. }
  28890. // Type returns the node type of this mutation (SopStage).
  28891. func (m *SopStageMutation) Type() string {
  28892. return m.typ
  28893. }
  28894. // Fields returns all fields that were changed during this mutation. Note that in
  28895. // order to get all numeric fields that were incremented/decremented, call
  28896. // AddedFields().
  28897. func (m *SopStageMutation) Fields() []string {
  28898. fields := make([]string, 0, 14)
  28899. if m.created_at != nil {
  28900. fields = append(fields, sopstage.FieldCreatedAt)
  28901. }
  28902. if m.updated_at != nil {
  28903. fields = append(fields, sopstage.FieldUpdatedAt)
  28904. }
  28905. if m.status != nil {
  28906. fields = append(fields, sopstage.FieldStatus)
  28907. }
  28908. if m.deleted_at != nil {
  28909. fields = append(fields, sopstage.FieldDeletedAt)
  28910. }
  28911. if m.sop_task != nil {
  28912. fields = append(fields, sopstage.FieldTaskID)
  28913. }
  28914. if m.name != nil {
  28915. fields = append(fields, sopstage.FieldName)
  28916. }
  28917. if m.condition_type != nil {
  28918. fields = append(fields, sopstage.FieldConditionType)
  28919. }
  28920. if m.condition_operator != nil {
  28921. fields = append(fields, sopstage.FieldConditionOperator)
  28922. }
  28923. if m.condition_list != nil {
  28924. fields = append(fields, sopstage.FieldConditionList)
  28925. }
  28926. if m.action_message != nil {
  28927. fields = append(fields, sopstage.FieldActionMessage)
  28928. }
  28929. if m.action_label_add != nil {
  28930. fields = append(fields, sopstage.FieldActionLabelAdd)
  28931. }
  28932. if m.action_label_del != nil {
  28933. fields = append(fields, sopstage.FieldActionLabelDel)
  28934. }
  28935. if m.action_forward != nil {
  28936. fields = append(fields, sopstage.FieldActionForward)
  28937. }
  28938. if m.index_sort != nil {
  28939. fields = append(fields, sopstage.FieldIndexSort)
  28940. }
  28941. return fields
  28942. }
  28943. // Field returns the value of a field with the given name. The second boolean
  28944. // return value indicates that this field was not set, or was not defined in the
  28945. // schema.
  28946. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  28947. switch name {
  28948. case sopstage.FieldCreatedAt:
  28949. return m.CreatedAt()
  28950. case sopstage.FieldUpdatedAt:
  28951. return m.UpdatedAt()
  28952. case sopstage.FieldStatus:
  28953. return m.Status()
  28954. case sopstage.FieldDeletedAt:
  28955. return m.DeletedAt()
  28956. case sopstage.FieldTaskID:
  28957. return m.TaskID()
  28958. case sopstage.FieldName:
  28959. return m.Name()
  28960. case sopstage.FieldConditionType:
  28961. return m.ConditionType()
  28962. case sopstage.FieldConditionOperator:
  28963. return m.ConditionOperator()
  28964. case sopstage.FieldConditionList:
  28965. return m.ConditionList()
  28966. case sopstage.FieldActionMessage:
  28967. return m.ActionMessage()
  28968. case sopstage.FieldActionLabelAdd:
  28969. return m.ActionLabelAdd()
  28970. case sopstage.FieldActionLabelDel:
  28971. return m.ActionLabelDel()
  28972. case sopstage.FieldActionForward:
  28973. return m.ActionForward()
  28974. case sopstage.FieldIndexSort:
  28975. return m.IndexSort()
  28976. }
  28977. return nil, false
  28978. }
  28979. // OldField returns the old value of the field from the database. An error is
  28980. // returned if the mutation operation is not UpdateOne, or the query to the
  28981. // database failed.
  28982. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28983. switch name {
  28984. case sopstage.FieldCreatedAt:
  28985. return m.OldCreatedAt(ctx)
  28986. case sopstage.FieldUpdatedAt:
  28987. return m.OldUpdatedAt(ctx)
  28988. case sopstage.FieldStatus:
  28989. return m.OldStatus(ctx)
  28990. case sopstage.FieldDeletedAt:
  28991. return m.OldDeletedAt(ctx)
  28992. case sopstage.FieldTaskID:
  28993. return m.OldTaskID(ctx)
  28994. case sopstage.FieldName:
  28995. return m.OldName(ctx)
  28996. case sopstage.FieldConditionType:
  28997. return m.OldConditionType(ctx)
  28998. case sopstage.FieldConditionOperator:
  28999. return m.OldConditionOperator(ctx)
  29000. case sopstage.FieldConditionList:
  29001. return m.OldConditionList(ctx)
  29002. case sopstage.FieldActionMessage:
  29003. return m.OldActionMessage(ctx)
  29004. case sopstage.FieldActionLabelAdd:
  29005. return m.OldActionLabelAdd(ctx)
  29006. case sopstage.FieldActionLabelDel:
  29007. return m.OldActionLabelDel(ctx)
  29008. case sopstage.FieldActionForward:
  29009. return m.OldActionForward(ctx)
  29010. case sopstage.FieldIndexSort:
  29011. return m.OldIndexSort(ctx)
  29012. }
  29013. return nil, fmt.Errorf("unknown SopStage field %s", name)
  29014. }
  29015. // SetField sets the value of a field with the given name. It returns an error if
  29016. // the field is not defined in the schema, or if the type mismatched the field
  29017. // type.
  29018. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  29019. switch name {
  29020. case sopstage.FieldCreatedAt:
  29021. v, ok := value.(time.Time)
  29022. if !ok {
  29023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29024. }
  29025. m.SetCreatedAt(v)
  29026. return nil
  29027. case sopstage.FieldUpdatedAt:
  29028. v, ok := value.(time.Time)
  29029. if !ok {
  29030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29031. }
  29032. m.SetUpdatedAt(v)
  29033. return nil
  29034. case sopstage.FieldStatus:
  29035. v, ok := value.(uint8)
  29036. if !ok {
  29037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29038. }
  29039. m.SetStatus(v)
  29040. return nil
  29041. case sopstage.FieldDeletedAt:
  29042. v, ok := value.(time.Time)
  29043. if !ok {
  29044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29045. }
  29046. m.SetDeletedAt(v)
  29047. return nil
  29048. case sopstage.FieldTaskID:
  29049. v, ok := value.(uint64)
  29050. if !ok {
  29051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29052. }
  29053. m.SetTaskID(v)
  29054. return nil
  29055. case sopstage.FieldName:
  29056. v, ok := value.(string)
  29057. if !ok {
  29058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29059. }
  29060. m.SetName(v)
  29061. return nil
  29062. case sopstage.FieldConditionType:
  29063. v, ok := value.(int)
  29064. if !ok {
  29065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29066. }
  29067. m.SetConditionType(v)
  29068. return nil
  29069. case sopstage.FieldConditionOperator:
  29070. v, ok := value.(int)
  29071. if !ok {
  29072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29073. }
  29074. m.SetConditionOperator(v)
  29075. return nil
  29076. case sopstage.FieldConditionList:
  29077. v, ok := value.([]custom_types.Condition)
  29078. if !ok {
  29079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29080. }
  29081. m.SetConditionList(v)
  29082. return nil
  29083. case sopstage.FieldActionMessage:
  29084. v, ok := value.([]custom_types.Action)
  29085. if !ok {
  29086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29087. }
  29088. m.SetActionMessage(v)
  29089. return nil
  29090. case sopstage.FieldActionLabelAdd:
  29091. v, ok := value.([]uint64)
  29092. if !ok {
  29093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29094. }
  29095. m.SetActionLabelAdd(v)
  29096. return nil
  29097. case sopstage.FieldActionLabelDel:
  29098. v, ok := value.([]uint64)
  29099. if !ok {
  29100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29101. }
  29102. m.SetActionLabelDel(v)
  29103. return nil
  29104. case sopstage.FieldActionForward:
  29105. v, ok := value.(*custom_types.ActionForward)
  29106. if !ok {
  29107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29108. }
  29109. m.SetActionForward(v)
  29110. return nil
  29111. case sopstage.FieldIndexSort:
  29112. v, ok := value.(int)
  29113. if !ok {
  29114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29115. }
  29116. m.SetIndexSort(v)
  29117. return nil
  29118. }
  29119. return fmt.Errorf("unknown SopStage field %s", name)
  29120. }
  29121. // AddedFields returns all numeric fields that were incremented/decremented during
  29122. // this mutation.
  29123. func (m *SopStageMutation) AddedFields() []string {
  29124. var fields []string
  29125. if m.addstatus != nil {
  29126. fields = append(fields, sopstage.FieldStatus)
  29127. }
  29128. if m.addcondition_type != nil {
  29129. fields = append(fields, sopstage.FieldConditionType)
  29130. }
  29131. if m.addcondition_operator != nil {
  29132. fields = append(fields, sopstage.FieldConditionOperator)
  29133. }
  29134. if m.addindex_sort != nil {
  29135. fields = append(fields, sopstage.FieldIndexSort)
  29136. }
  29137. return fields
  29138. }
  29139. // AddedField returns the numeric value that was incremented/decremented on a field
  29140. // with the given name. The second boolean return value indicates that this field
  29141. // was not set, or was not defined in the schema.
  29142. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  29143. switch name {
  29144. case sopstage.FieldStatus:
  29145. return m.AddedStatus()
  29146. case sopstage.FieldConditionType:
  29147. return m.AddedConditionType()
  29148. case sopstage.FieldConditionOperator:
  29149. return m.AddedConditionOperator()
  29150. case sopstage.FieldIndexSort:
  29151. return m.AddedIndexSort()
  29152. }
  29153. return nil, false
  29154. }
  29155. // AddField adds the value to the field with the given name. It returns an error if
  29156. // the field is not defined in the schema, or if the type mismatched the field
  29157. // type.
  29158. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  29159. switch name {
  29160. case sopstage.FieldStatus:
  29161. v, ok := value.(int8)
  29162. if !ok {
  29163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29164. }
  29165. m.AddStatus(v)
  29166. return nil
  29167. case sopstage.FieldConditionType:
  29168. v, ok := value.(int)
  29169. if !ok {
  29170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29171. }
  29172. m.AddConditionType(v)
  29173. return nil
  29174. case sopstage.FieldConditionOperator:
  29175. v, ok := value.(int)
  29176. if !ok {
  29177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29178. }
  29179. m.AddConditionOperator(v)
  29180. return nil
  29181. case sopstage.FieldIndexSort:
  29182. v, ok := value.(int)
  29183. if !ok {
  29184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29185. }
  29186. m.AddIndexSort(v)
  29187. return nil
  29188. }
  29189. return fmt.Errorf("unknown SopStage numeric field %s", name)
  29190. }
  29191. // ClearedFields returns all nullable fields that were cleared during this
  29192. // mutation.
  29193. func (m *SopStageMutation) ClearedFields() []string {
  29194. var fields []string
  29195. if m.FieldCleared(sopstage.FieldStatus) {
  29196. fields = append(fields, sopstage.FieldStatus)
  29197. }
  29198. if m.FieldCleared(sopstage.FieldDeletedAt) {
  29199. fields = append(fields, sopstage.FieldDeletedAt)
  29200. }
  29201. if m.FieldCleared(sopstage.FieldActionMessage) {
  29202. fields = append(fields, sopstage.FieldActionMessage)
  29203. }
  29204. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  29205. fields = append(fields, sopstage.FieldActionLabelAdd)
  29206. }
  29207. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  29208. fields = append(fields, sopstage.FieldActionLabelDel)
  29209. }
  29210. if m.FieldCleared(sopstage.FieldActionForward) {
  29211. fields = append(fields, sopstage.FieldActionForward)
  29212. }
  29213. if m.FieldCleared(sopstage.FieldIndexSort) {
  29214. fields = append(fields, sopstage.FieldIndexSort)
  29215. }
  29216. return fields
  29217. }
  29218. // FieldCleared returns a boolean indicating if a field with the given name was
  29219. // cleared in this mutation.
  29220. func (m *SopStageMutation) FieldCleared(name string) bool {
  29221. _, ok := m.clearedFields[name]
  29222. return ok
  29223. }
  29224. // ClearField clears the value of the field with the given name. It returns an
  29225. // error if the field is not defined in the schema.
  29226. func (m *SopStageMutation) ClearField(name string) error {
  29227. switch name {
  29228. case sopstage.FieldStatus:
  29229. m.ClearStatus()
  29230. return nil
  29231. case sopstage.FieldDeletedAt:
  29232. m.ClearDeletedAt()
  29233. return nil
  29234. case sopstage.FieldActionMessage:
  29235. m.ClearActionMessage()
  29236. return nil
  29237. case sopstage.FieldActionLabelAdd:
  29238. m.ClearActionLabelAdd()
  29239. return nil
  29240. case sopstage.FieldActionLabelDel:
  29241. m.ClearActionLabelDel()
  29242. return nil
  29243. case sopstage.FieldActionForward:
  29244. m.ClearActionForward()
  29245. return nil
  29246. case sopstage.FieldIndexSort:
  29247. m.ClearIndexSort()
  29248. return nil
  29249. }
  29250. return fmt.Errorf("unknown SopStage nullable field %s", name)
  29251. }
  29252. // ResetField resets all changes in the mutation for the field with the given name.
  29253. // It returns an error if the field is not defined in the schema.
  29254. func (m *SopStageMutation) ResetField(name string) error {
  29255. switch name {
  29256. case sopstage.FieldCreatedAt:
  29257. m.ResetCreatedAt()
  29258. return nil
  29259. case sopstage.FieldUpdatedAt:
  29260. m.ResetUpdatedAt()
  29261. return nil
  29262. case sopstage.FieldStatus:
  29263. m.ResetStatus()
  29264. return nil
  29265. case sopstage.FieldDeletedAt:
  29266. m.ResetDeletedAt()
  29267. return nil
  29268. case sopstage.FieldTaskID:
  29269. m.ResetTaskID()
  29270. return nil
  29271. case sopstage.FieldName:
  29272. m.ResetName()
  29273. return nil
  29274. case sopstage.FieldConditionType:
  29275. m.ResetConditionType()
  29276. return nil
  29277. case sopstage.FieldConditionOperator:
  29278. m.ResetConditionOperator()
  29279. return nil
  29280. case sopstage.FieldConditionList:
  29281. m.ResetConditionList()
  29282. return nil
  29283. case sopstage.FieldActionMessage:
  29284. m.ResetActionMessage()
  29285. return nil
  29286. case sopstage.FieldActionLabelAdd:
  29287. m.ResetActionLabelAdd()
  29288. return nil
  29289. case sopstage.FieldActionLabelDel:
  29290. m.ResetActionLabelDel()
  29291. return nil
  29292. case sopstage.FieldActionForward:
  29293. m.ResetActionForward()
  29294. return nil
  29295. case sopstage.FieldIndexSort:
  29296. m.ResetIndexSort()
  29297. return nil
  29298. }
  29299. return fmt.Errorf("unknown SopStage field %s", name)
  29300. }
  29301. // AddedEdges returns all edge names that were set/added in this mutation.
  29302. func (m *SopStageMutation) AddedEdges() []string {
  29303. edges := make([]string, 0, 3)
  29304. if m.sop_task != nil {
  29305. edges = append(edges, sopstage.EdgeSopTask)
  29306. }
  29307. if m.stage_nodes != nil {
  29308. edges = append(edges, sopstage.EdgeStageNodes)
  29309. }
  29310. if m.stage_messages != nil {
  29311. edges = append(edges, sopstage.EdgeStageMessages)
  29312. }
  29313. return edges
  29314. }
  29315. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29316. // name in this mutation.
  29317. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  29318. switch name {
  29319. case sopstage.EdgeSopTask:
  29320. if id := m.sop_task; id != nil {
  29321. return []ent.Value{*id}
  29322. }
  29323. case sopstage.EdgeStageNodes:
  29324. ids := make([]ent.Value, 0, len(m.stage_nodes))
  29325. for id := range m.stage_nodes {
  29326. ids = append(ids, id)
  29327. }
  29328. return ids
  29329. case sopstage.EdgeStageMessages:
  29330. ids := make([]ent.Value, 0, len(m.stage_messages))
  29331. for id := range m.stage_messages {
  29332. ids = append(ids, id)
  29333. }
  29334. return ids
  29335. }
  29336. return nil
  29337. }
  29338. // RemovedEdges returns all edge names that were removed in this mutation.
  29339. func (m *SopStageMutation) RemovedEdges() []string {
  29340. edges := make([]string, 0, 3)
  29341. if m.removedstage_nodes != nil {
  29342. edges = append(edges, sopstage.EdgeStageNodes)
  29343. }
  29344. if m.removedstage_messages != nil {
  29345. edges = append(edges, sopstage.EdgeStageMessages)
  29346. }
  29347. return edges
  29348. }
  29349. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29350. // the given name in this mutation.
  29351. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  29352. switch name {
  29353. case sopstage.EdgeStageNodes:
  29354. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  29355. for id := range m.removedstage_nodes {
  29356. ids = append(ids, id)
  29357. }
  29358. return ids
  29359. case sopstage.EdgeStageMessages:
  29360. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  29361. for id := range m.removedstage_messages {
  29362. ids = append(ids, id)
  29363. }
  29364. return ids
  29365. }
  29366. return nil
  29367. }
  29368. // ClearedEdges returns all edge names that were cleared in this mutation.
  29369. func (m *SopStageMutation) ClearedEdges() []string {
  29370. edges := make([]string, 0, 3)
  29371. if m.clearedsop_task {
  29372. edges = append(edges, sopstage.EdgeSopTask)
  29373. }
  29374. if m.clearedstage_nodes {
  29375. edges = append(edges, sopstage.EdgeStageNodes)
  29376. }
  29377. if m.clearedstage_messages {
  29378. edges = append(edges, sopstage.EdgeStageMessages)
  29379. }
  29380. return edges
  29381. }
  29382. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29383. // was cleared in this mutation.
  29384. func (m *SopStageMutation) EdgeCleared(name string) bool {
  29385. switch name {
  29386. case sopstage.EdgeSopTask:
  29387. return m.clearedsop_task
  29388. case sopstage.EdgeStageNodes:
  29389. return m.clearedstage_nodes
  29390. case sopstage.EdgeStageMessages:
  29391. return m.clearedstage_messages
  29392. }
  29393. return false
  29394. }
  29395. // ClearEdge clears the value of the edge with the given name. It returns an error
  29396. // if that edge is not defined in the schema.
  29397. func (m *SopStageMutation) ClearEdge(name string) error {
  29398. switch name {
  29399. case sopstage.EdgeSopTask:
  29400. m.ClearSopTask()
  29401. return nil
  29402. }
  29403. return fmt.Errorf("unknown SopStage unique edge %s", name)
  29404. }
  29405. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29406. // It returns an error if the edge is not defined in the schema.
  29407. func (m *SopStageMutation) ResetEdge(name string) error {
  29408. switch name {
  29409. case sopstage.EdgeSopTask:
  29410. m.ResetSopTask()
  29411. return nil
  29412. case sopstage.EdgeStageNodes:
  29413. m.ResetStageNodes()
  29414. return nil
  29415. case sopstage.EdgeStageMessages:
  29416. m.ResetStageMessages()
  29417. return nil
  29418. }
  29419. return fmt.Errorf("unknown SopStage edge %s", name)
  29420. }
  29421. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  29422. type SopTaskMutation struct {
  29423. config
  29424. op Op
  29425. typ string
  29426. id *uint64
  29427. created_at *time.Time
  29428. updated_at *time.Time
  29429. status *uint8
  29430. addstatus *int8
  29431. deleted_at *time.Time
  29432. name *string
  29433. bot_wxid_list *[]string
  29434. appendbot_wxid_list []string
  29435. _type *int
  29436. add_type *int
  29437. plan_start_time *time.Time
  29438. plan_end_time *time.Time
  29439. creator_id *string
  29440. organization_id *uint64
  29441. addorganization_id *int64
  29442. token *[]string
  29443. appendtoken []string
  29444. clearedFields map[string]struct{}
  29445. task_stages map[uint64]struct{}
  29446. removedtask_stages map[uint64]struct{}
  29447. clearedtask_stages bool
  29448. done bool
  29449. oldValue func(context.Context) (*SopTask, error)
  29450. predicates []predicate.SopTask
  29451. }
  29452. var _ ent.Mutation = (*SopTaskMutation)(nil)
  29453. // soptaskOption allows management of the mutation configuration using functional options.
  29454. type soptaskOption func(*SopTaskMutation)
  29455. // newSopTaskMutation creates new mutation for the SopTask entity.
  29456. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  29457. m := &SopTaskMutation{
  29458. config: c,
  29459. op: op,
  29460. typ: TypeSopTask,
  29461. clearedFields: make(map[string]struct{}),
  29462. }
  29463. for _, opt := range opts {
  29464. opt(m)
  29465. }
  29466. return m
  29467. }
  29468. // withSopTaskID sets the ID field of the mutation.
  29469. func withSopTaskID(id uint64) soptaskOption {
  29470. return func(m *SopTaskMutation) {
  29471. var (
  29472. err error
  29473. once sync.Once
  29474. value *SopTask
  29475. )
  29476. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  29477. once.Do(func() {
  29478. if m.done {
  29479. err = errors.New("querying old values post mutation is not allowed")
  29480. } else {
  29481. value, err = m.Client().SopTask.Get(ctx, id)
  29482. }
  29483. })
  29484. return value, err
  29485. }
  29486. m.id = &id
  29487. }
  29488. }
  29489. // withSopTask sets the old SopTask of the mutation.
  29490. func withSopTask(node *SopTask) soptaskOption {
  29491. return func(m *SopTaskMutation) {
  29492. m.oldValue = func(context.Context) (*SopTask, error) {
  29493. return node, nil
  29494. }
  29495. m.id = &node.ID
  29496. }
  29497. }
  29498. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29499. // executed in a transaction (ent.Tx), a transactional client is returned.
  29500. func (m SopTaskMutation) Client() *Client {
  29501. client := &Client{config: m.config}
  29502. client.init()
  29503. return client
  29504. }
  29505. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29506. // it returns an error otherwise.
  29507. func (m SopTaskMutation) Tx() (*Tx, error) {
  29508. if _, ok := m.driver.(*txDriver); !ok {
  29509. return nil, errors.New("ent: mutation is not running in a transaction")
  29510. }
  29511. tx := &Tx{config: m.config}
  29512. tx.init()
  29513. return tx, nil
  29514. }
  29515. // SetID sets the value of the id field. Note that this
  29516. // operation is only accepted on creation of SopTask entities.
  29517. func (m *SopTaskMutation) SetID(id uint64) {
  29518. m.id = &id
  29519. }
  29520. // ID returns the ID value in the mutation. Note that the ID is only available
  29521. // if it was provided to the builder or after it was returned from the database.
  29522. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  29523. if m.id == nil {
  29524. return
  29525. }
  29526. return *m.id, true
  29527. }
  29528. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29529. // That means, if the mutation is applied within a transaction with an isolation level such
  29530. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29531. // or updated by the mutation.
  29532. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  29533. switch {
  29534. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29535. id, exists := m.ID()
  29536. if exists {
  29537. return []uint64{id}, nil
  29538. }
  29539. fallthrough
  29540. case m.op.Is(OpUpdate | OpDelete):
  29541. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  29542. default:
  29543. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29544. }
  29545. }
  29546. // SetCreatedAt sets the "created_at" field.
  29547. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  29548. m.created_at = &t
  29549. }
  29550. // CreatedAt returns the value of the "created_at" field in the mutation.
  29551. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  29552. v := m.created_at
  29553. if v == nil {
  29554. return
  29555. }
  29556. return *v, true
  29557. }
  29558. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  29559. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29561. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29562. if !m.op.Is(OpUpdateOne) {
  29563. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29564. }
  29565. if m.id == nil || m.oldValue == nil {
  29566. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29567. }
  29568. oldValue, err := m.oldValue(ctx)
  29569. if err != nil {
  29570. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29571. }
  29572. return oldValue.CreatedAt, nil
  29573. }
  29574. // ResetCreatedAt resets all changes to the "created_at" field.
  29575. func (m *SopTaskMutation) ResetCreatedAt() {
  29576. m.created_at = nil
  29577. }
  29578. // SetUpdatedAt sets the "updated_at" field.
  29579. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  29580. m.updated_at = &t
  29581. }
  29582. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29583. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  29584. v := m.updated_at
  29585. if v == nil {
  29586. return
  29587. }
  29588. return *v, true
  29589. }
  29590. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  29591. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29593. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29594. if !m.op.Is(OpUpdateOne) {
  29595. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29596. }
  29597. if m.id == nil || m.oldValue == nil {
  29598. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29599. }
  29600. oldValue, err := m.oldValue(ctx)
  29601. if err != nil {
  29602. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29603. }
  29604. return oldValue.UpdatedAt, nil
  29605. }
  29606. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29607. func (m *SopTaskMutation) ResetUpdatedAt() {
  29608. m.updated_at = nil
  29609. }
  29610. // SetStatus sets the "status" field.
  29611. func (m *SopTaskMutation) SetStatus(u uint8) {
  29612. m.status = &u
  29613. m.addstatus = nil
  29614. }
  29615. // Status returns the value of the "status" field in the mutation.
  29616. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  29617. v := m.status
  29618. if v == nil {
  29619. return
  29620. }
  29621. return *v, true
  29622. }
  29623. // OldStatus returns the old "status" field's value of the SopTask entity.
  29624. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29626. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29627. if !m.op.Is(OpUpdateOne) {
  29628. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29629. }
  29630. if m.id == nil || m.oldValue == nil {
  29631. return v, errors.New("OldStatus requires an ID field in the mutation")
  29632. }
  29633. oldValue, err := m.oldValue(ctx)
  29634. if err != nil {
  29635. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29636. }
  29637. return oldValue.Status, nil
  29638. }
  29639. // AddStatus adds u to the "status" field.
  29640. func (m *SopTaskMutation) AddStatus(u int8) {
  29641. if m.addstatus != nil {
  29642. *m.addstatus += u
  29643. } else {
  29644. m.addstatus = &u
  29645. }
  29646. }
  29647. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29648. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  29649. v := m.addstatus
  29650. if v == nil {
  29651. return
  29652. }
  29653. return *v, true
  29654. }
  29655. // ClearStatus clears the value of the "status" field.
  29656. func (m *SopTaskMutation) ClearStatus() {
  29657. m.status = nil
  29658. m.addstatus = nil
  29659. m.clearedFields[soptask.FieldStatus] = struct{}{}
  29660. }
  29661. // StatusCleared returns if the "status" field was cleared in this mutation.
  29662. func (m *SopTaskMutation) StatusCleared() bool {
  29663. _, ok := m.clearedFields[soptask.FieldStatus]
  29664. return ok
  29665. }
  29666. // ResetStatus resets all changes to the "status" field.
  29667. func (m *SopTaskMutation) ResetStatus() {
  29668. m.status = nil
  29669. m.addstatus = nil
  29670. delete(m.clearedFields, soptask.FieldStatus)
  29671. }
  29672. // SetDeletedAt sets the "deleted_at" field.
  29673. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  29674. m.deleted_at = &t
  29675. }
  29676. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29677. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  29678. v := m.deleted_at
  29679. if v == nil {
  29680. return
  29681. }
  29682. return *v, true
  29683. }
  29684. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  29685. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29687. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29688. if !m.op.Is(OpUpdateOne) {
  29689. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29690. }
  29691. if m.id == nil || m.oldValue == nil {
  29692. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29693. }
  29694. oldValue, err := m.oldValue(ctx)
  29695. if err != nil {
  29696. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29697. }
  29698. return oldValue.DeletedAt, nil
  29699. }
  29700. // ClearDeletedAt clears the value of the "deleted_at" field.
  29701. func (m *SopTaskMutation) ClearDeletedAt() {
  29702. m.deleted_at = nil
  29703. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  29704. }
  29705. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29706. func (m *SopTaskMutation) DeletedAtCleared() bool {
  29707. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  29708. return ok
  29709. }
  29710. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29711. func (m *SopTaskMutation) ResetDeletedAt() {
  29712. m.deleted_at = nil
  29713. delete(m.clearedFields, soptask.FieldDeletedAt)
  29714. }
  29715. // SetName sets the "name" field.
  29716. func (m *SopTaskMutation) SetName(s string) {
  29717. m.name = &s
  29718. }
  29719. // Name returns the value of the "name" field in the mutation.
  29720. func (m *SopTaskMutation) Name() (r string, exists bool) {
  29721. v := m.name
  29722. if v == nil {
  29723. return
  29724. }
  29725. return *v, true
  29726. }
  29727. // OldName returns the old "name" field's value of the SopTask entity.
  29728. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29730. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  29731. if !m.op.Is(OpUpdateOne) {
  29732. return v, errors.New("OldName is only allowed on UpdateOne operations")
  29733. }
  29734. if m.id == nil || m.oldValue == nil {
  29735. return v, errors.New("OldName requires an ID field in the mutation")
  29736. }
  29737. oldValue, err := m.oldValue(ctx)
  29738. if err != nil {
  29739. return v, fmt.Errorf("querying old value for OldName: %w", err)
  29740. }
  29741. return oldValue.Name, nil
  29742. }
  29743. // ResetName resets all changes to the "name" field.
  29744. func (m *SopTaskMutation) ResetName() {
  29745. m.name = nil
  29746. }
  29747. // SetBotWxidList sets the "bot_wxid_list" field.
  29748. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  29749. m.bot_wxid_list = &s
  29750. m.appendbot_wxid_list = nil
  29751. }
  29752. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  29753. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  29754. v := m.bot_wxid_list
  29755. if v == nil {
  29756. return
  29757. }
  29758. return *v, true
  29759. }
  29760. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  29761. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29763. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  29764. if !m.op.Is(OpUpdateOne) {
  29765. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  29766. }
  29767. if m.id == nil || m.oldValue == nil {
  29768. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  29769. }
  29770. oldValue, err := m.oldValue(ctx)
  29771. if err != nil {
  29772. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  29773. }
  29774. return oldValue.BotWxidList, nil
  29775. }
  29776. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  29777. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  29778. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  29779. }
  29780. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  29781. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  29782. if len(m.appendbot_wxid_list) == 0 {
  29783. return nil, false
  29784. }
  29785. return m.appendbot_wxid_list, true
  29786. }
  29787. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  29788. func (m *SopTaskMutation) ClearBotWxidList() {
  29789. m.bot_wxid_list = nil
  29790. m.appendbot_wxid_list = nil
  29791. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  29792. }
  29793. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  29794. func (m *SopTaskMutation) BotWxidListCleared() bool {
  29795. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  29796. return ok
  29797. }
  29798. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  29799. func (m *SopTaskMutation) ResetBotWxidList() {
  29800. m.bot_wxid_list = nil
  29801. m.appendbot_wxid_list = nil
  29802. delete(m.clearedFields, soptask.FieldBotWxidList)
  29803. }
  29804. // SetType sets the "type" field.
  29805. func (m *SopTaskMutation) SetType(i int) {
  29806. m._type = &i
  29807. m.add_type = nil
  29808. }
  29809. // GetType returns the value of the "type" field in the mutation.
  29810. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  29811. v := m._type
  29812. if v == nil {
  29813. return
  29814. }
  29815. return *v, true
  29816. }
  29817. // OldType returns the old "type" field's value of the SopTask entity.
  29818. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29820. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  29821. if !m.op.Is(OpUpdateOne) {
  29822. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29823. }
  29824. if m.id == nil || m.oldValue == nil {
  29825. return v, errors.New("OldType requires an ID field in the mutation")
  29826. }
  29827. oldValue, err := m.oldValue(ctx)
  29828. if err != nil {
  29829. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29830. }
  29831. return oldValue.Type, nil
  29832. }
  29833. // AddType adds i to the "type" field.
  29834. func (m *SopTaskMutation) AddType(i int) {
  29835. if m.add_type != nil {
  29836. *m.add_type += i
  29837. } else {
  29838. m.add_type = &i
  29839. }
  29840. }
  29841. // AddedType returns the value that was added to the "type" field in this mutation.
  29842. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  29843. v := m.add_type
  29844. if v == nil {
  29845. return
  29846. }
  29847. return *v, true
  29848. }
  29849. // ResetType resets all changes to the "type" field.
  29850. func (m *SopTaskMutation) ResetType() {
  29851. m._type = nil
  29852. m.add_type = nil
  29853. }
  29854. // SetPlanStartTime sets the "plan_start_time" field.
  29855. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  29856. m.plan_start_time = &t
  29857. }
  29858. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  29859. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  29860. v := m.plan_start_time
  29861. if v == nil {
  29862. return
  29863. }
  29864. return *v, true
  29865. }
  29866. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  29867. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29869. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  29870. if !m.op.Is(OpUpdateOne) {
  29871. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  29872. }
  29873. if m.id == nil || m.oldValue == nil {
  29874. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  29875. }
  29876. oldValue, err := m.oldValue(ctx)
  29877. if err != nil {
  29878. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  29879. }
  29880. return oldValue.PlanStartTime, nil
  29881. }
  29882. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  29883. func (m *SopTaskMutation) ClearPlanStartTime() {
  29884. m.plan_start_time = nil
  29885. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  29886. }
  29887. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  29888. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  29889. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  29890. return ok
  29891. }
  29892. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  29893. func (m *SopTaskMutation) ResetPlanStartTime() {
  29894. m.plan_start_time = nil
  29895. delete(m.clearedFields, soptask.FieldPlanStartTime)
  29896. }
  29897. // SetPlanEndTime sets the "plan_end_time" field.
  29898. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  29899. m.plan_end_time = &t
  29900. }
  29901. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  29902. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  29903. v := m.plan_end_time
  29904. if v == nil {
  29905. return
  29906. }
  29907. return *v, true
  29908. }
  29909. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  29910. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29912. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  29913. if !m.op.Is(OpUpdateOne) {
  29914. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  29915. }
  29916. if m.id == nil || m.oldValue == nil {
  29917. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  29918. }
  29919. oldValue, err := m.oldValue(ctx)
  29920. if err != nil {
  29921. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  29922. }
  29923. return oldValue.PlanEndTime, nil
  29924. }
  29925. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  29926. func (m *SopTaskMutation) ClearPlanEndTime() {
  29927. m.plan_end_time = nil
  29928. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  29929. }
  29930. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  29931. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  29932. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  29933. return ok
  29934. }
  29935. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  29936. func (m *SopTaskMutation) ResetPlanEndTime() {
  29937. m.plan_end_time = nil
  29938. delete(m.clearedFields, soptask.FieldPlanEndTime)
  29939. }
  29940. // SetCreatorID sets the "creator_id" field.
  29941. func (m *SopTaskMutation) SetCreatorID(s string) {
  29942. m.creator_id = &s
  29943. }
  29944. // CreatorID returns the value of the "creator_id" field in the mutation.
  29945. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  29946. v := m.creator_id
  29947. if v == nil {
  29948. return
  29949. }
  29950. return *v, true
  29951. }
  29952. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  29953. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29955. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  29956. if !m.op.Is(OpUpdateOne) {
  29957. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  29958. }
  29959. if m.id == nil || m.oldValue == nil {
  29960. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  29961. }
  29962. oldValue, err := m.oldValue(ctx)
  29963. if err != nil {
  29964. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  29965. }
  29966. return oldValue.CreatorID, nil
  29967. }
  29968. // ClearCreatorID clears the value of the "creator_id" field.
  29969. func (m *SopTaskMutation) ClearCreatorID() {
  29970. m.creator_id = nil
  29971. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  29972. }
  29973. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  29974. func (m *SopTaskMutation) CreatorIDCleared() bool {
  29975. _, ok := m.clearedFields[soptask.FieldCreatorID]
  29976. return ok
  29977. }
  29978. // ResetCreatorID resets all changes to the "creator_id" field.
  29979. func (m *SopTaskMutation) ResetCreatorID() {
  29980. m.creator_id = nil
  29981. delete(m.clearedFields, soptask.FieldCreatorID)
  29982. }
  29983. // SetOrganizationID sets the "organization_id" field.
  29984. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  29985. m.organization_id = &u
  29986. m.addorganization_id = nil
  29987. }
  29988. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29989. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  29990. v := m.organization_id
  29991. if v == nil {
  29992. return
  29993. }
  29994. return *v, true
  29995. }
  29996. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  29997. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  29998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29999. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30000. if !m.op.Is(OpUpdateOne) {
  30001. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30002. }
  30003. if m.id == nil || m.oldValue == nil {
  30004. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30005. }
  30006. oldValue, err := m.oldValue(ctx)
  30007. if err != nil {
  30008. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30009. }
  30010. return oldValue.OrganizationID, nil
  30011. }
  30012. // AddOrganizationID adds u to the "organization_id" field.
  30013. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  30014. if m.addorganization_id != nil {
  30015. *m.addorganization_id += u
  30016. } else {
  30017. m.addorganization_id = &u
  30018. }
  30019. }
  30020. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30021. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  30022. v := m.addorganization_id
  30023. if v == nil {
  30024. return
  30025. }
  30026. return *v, true
  30027. }
  30028. // ClearOrganizationID clears the value of the "organization_id" field.
  30029. func (m *SopTaskMutation) ClearOrganizationID() {
  30030. m.organization_id = nil
  30031. m.addorganization_id = nil
  30032. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  30033. }
  30034. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30035. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  30036. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  30037. return ok
  30038. }
  30039. // ResetOrganizationID resets all changes to the "organization_id" field.
  30040. func (m *SopTaskMutation) ResetOrganizationID() {
  30041. m.organization_id = nil
  30042. m.addorganization_id = nil
  30043. delete(m.clearedFields, soptask.FieldOrganizationID)
  30044. }
  30045. // SetToken sets the "token" field.
  30046. func (m *SopTaskMutation) SetToken(s []string) {
  30047. m.token = &s
  30048. m.appendtoken = nil
  30049. }
  30050. // Token returns the value of the "token" field in the mutation.
  30051. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  30052. v := m.token
  30053. if v == nil {
  30054. return
  30055. }
  30056. return *v, true
  30057. }
  30058. // OldToken returns the old "token" field's value of the SopTask entity.
  30059. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  30060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30061. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  30062. if !m.op.Is(OpUpdateOne) {
  30063. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  30064. }
  30065. if m.id == nil || m.oldValue == nil {
  30066. return v, errors.New("OldToken requires an ID field in the mutation")
  30067. }
  30068. oldValue, err := m.oldValue(ctx)
  30069. if err != nil {
  30070. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  30071. }
  30072. return oldValue.Token, nil
  30073. }
  30074. // AppendToken adds s to the "token" field.
  30075. func (m *SopTaskMutation) AppendToken(s []string) {
  30076. m.appendtoken = append(m.appendtoken, s...)
  30077. }
  30078. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  30079. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  30080. if len(m.appendtoken) == 0 {
  30081. return nil, false
  30082. }
  30083. return m.appendtoken, true
  30084. }
  30085. // ClearToken clears the value of the "token" field.
  30086. func (m *SopTaskMutation) ClearToken() {
  30087. m.token = nil
  30088. m.appendtoken = nil
  30089. m.clearedFields[soptask.FieldToken] = struct{}{}
  30090. }
  30091. // TokenCleared returns if the "token" field was cleared in this mutation.
  30092. func (m *SopTaskMutation) TokenCleared() bool {
  30093. _, ok := m.clearedFields[soptask.FieldToken]
  30094. return ok
  30095. }
  30096. // ResetToken resets all changes to the "token" field.
  30097. func (m *SopTaskMutation) ResetToken() {
  30098. m.token = nil
  30099. m.appendtoken = nil
  30100. delete(m.clearedFields, soptask.FieldToken)
  30101. }
  30102. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  30103. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  30104. if m.task_stages == nil {
  30105. m.task_stages = make(map[uint64]struct{})
  30106. }
  30107. for i := range ids {
  30108. m.task_stages[ids[i]] = struct{}{}
  30109. }
  30110. }
  30111. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  30112. func (m *SopTaskMutation) ClearTaskStages() {
  30113. m.clearedtask_stages = true
  30114. }
  30115. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  30116. func (m *SopTaskMutation) TaskStagesCleared() bool {
  30117. return m.clearedtask_stages
  30118. }
  30119. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  30120. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  30121. if m.removedtask_stages == nil {
  30122. m.removedtask_stages = make(map[uint64]struct{})
  30123. }
  30124. for i := range ids {
  30125. delete(m.task_stages, ids[i])
  30126. m.removedtask_stages[ids[i]] = struct{}{}
  30127. }
  30128. }
  30129. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  30130. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  30131. for id := range m.removedtask_stages {
  30132. ids = append(ids, id)
  30133. }
  30134. return
  30135. }
  30136. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  30137. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  30138. for id := range m.task_stages {
  30139. ids = append(ids, id)
  30140. }
  30141. return
  30142. }
  30143. // ResetTaskStages resets all changes to the "task_stages" edge.
  30144. func (m *SopTaskMutation) ResetTaskStages() {
  30145. m.task_stages = nil
  30146. m.clearedtask_stages = false
  30147. m.removedtask_stages = nil
  30148. }
  30149. // Where appends a list predicates to the SopTaskMutation builder.
  30150. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  30151. m.predicates = append(m.predicates, ps...)
  30152. }
  30153. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  30154. // users can use type-assertion to append predicates that do not depend on any generated package.
  30155. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  30156. p := make([]predicate.SopTask, len(ps))
  30157. for i := range ps {
  30158. p[i] = ps[i]
  30159. }
  30160. m.Where(p...)
  30161. }
  30162. // Op returns the operation name.
  30163. func (m *SopTaskMutation) Op() Op {
  30164. return m.op
  30165. }
  30166. // SetOp allows setting the mutation operation.
  30167. func (m *SopTaskMutation) SetOp(op Op) {
  30168. m.op = op
  30169. }
  30170. // Type returns the node type of this mutation (SopTask).
  30171. func (m *SopTaskMutation) Type() string {
  30172. return m.typ
  30173. }
  30174. // Fields returns all fields that were changed during this mutation. Note that in
  30175. // order to get all numeric fields that were incremented/decremented, call
  30176. // AddedFields().
  30177. func (m *SopTaskMutation) Fields() []string {
  30178. fields := make([]string, 0, 12)
  30179. if m.created_at != nil {
  30180. fields = append(fields, soptask.FieldCreatedAt)
  30181. }
  30182. if m.updated_at != nil {
  30183. fields = append(fields, soptask.FieldUpdatedAt)
  30184. }
  30185. if m.status != nil {
  30186. fields = append(fields, soptask.FieldStatus)
  30187. }
  30188. if m.deleted_at != nil {
  30189. fields = append(fields, soptask.FieldDeletedAt)
  30190. }
  30191. if m.name != nil {
  30192. fields = append(fields, soptask.FieldName)
  30193. }
  30194. if m.bot_wxid_list != nil {
  30195. fields = append(fields, soptask.FieldBotWxidList)
  30196. }
  30197. if m._type != nil {
  30198. fields = append(fields, soptask.FieldType)
  30199. }
  30200. if m.plan_start_time != nil {
  30201. fields = append(fields, soptask.FieldPlanStartTime)
  30202. }
  30203. if m.plan_end_time != nil {
  30204. fields = append(fields, soptask.FieldPlanEndTime)
  30205. }
  30206. if m.creator_id != nil {
  30207. fields = append(fields, soptask.FieldCreatorID)
  30208. }
  30209. if m.organization_id != nil {
  30210. fields = append(fields, soptask.FieldOrganizationID)
  30211. }
  30212. if m.token != nil {
  30213. fields = append(fields, soptask.FieldToken)
  30214. }
  30215. return fields
  30216. }
  30217. // Field returns the value of a field with the given name. The second boolean
  30218. // return value indicates that this field was not set, or was not defined in the
  30219. // schema.
  30220. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  30221. switch name {
  30222. case soptask.FieldCreatedAt:
  30223. return m.CreatedAt()
  30224. case soptask.FieldUpdatedAt:
  30225. return m.UpdatedAt()
  30226. case soptask.FieldStatus:
  30227. return m.Status()
  30228. case soptask.FieldDeletedAt:
  30229. return m.DeletedAt()
  30230. case soptask.FieldName:
  30231. return m.Name()
  30232. case soptask.FieldBotWxidList:
  30233. return m.BotWxidList()
  30234. case soptask.FieldType:
  30235. return m.GetType()
  30236. case soptask.FieldPlanStartTime:
  30237. return m.PlanStartTime()
  30238. case soptask.FieldPlanEndTime:
  30239. return m.PlanEndTime()
  30240. case soptask.FieldCreatorID:
  30241. return m.CreatorID()
  30242. case soptask.FieldOrganizationID:
  30243. return m.OrganizationID()
  30244. case soptask.FieldToken:
  30245. return m.Token()
  30246. }
  30247. return nil, false
  30248. }
  30249. // OldField returns the old value of the field from the database. An error is
  30250. // returned if the mutation operation is not UpdateOne, or the query to the
  30251. // database failed.
  30252. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30253. switch name {
  30254. case soptask.FieldCreatedAt:
  30255. return m.OldCreatedAt(ctx)
  30256. case soptask.FieldUpdatedAt:
  30257. return m.OldUpdatedAt(ctx)
  30258. case soptask.FieldStatus:
  30259. return m.OldStatus(ctx)
  30260. case soptask.FieldDeletedAt:
  30261. return m.OldDeletedAt(ctx)
  30262. case soptask.FieldName:
  30263. return m.OldName(ctx)
  30264. case soptask.FieldBotWxidList:
  30265. return m.OldBotWxidList(ctx)
  30266. case soptask.FieldType:
  30267. return m.OldType(ctx)
  30268. case soptask.FieldPlanStartTime:
  30269. return m.OldPlanStartTime(ctx)
  30270. case soptask.FieldPlanEndTime:
  30271. return m.OldPlanEndTime(ctx)
  30272. case soptask.FieldCreatorID:
  30273. return m.OldCreatorID(ctx)
  30274. case soptask.FieldOrganizationID:
  30275. return m.OldOrganizationID(ctx)
  30276. case soptask.FieldToken:
  30277. return m.OldToken(ctx)
  30278. }
  30279. return nil, fmt.Errorf("unknown SopTask field %s", name)
  30280. }
  30281. // SetField sets the value of a field with the given name. It returns an error if
  30282. // the field is not defined in the schema, or if the type mismatched the field
  30283. // type.
  30284. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  30285. switch name {
  30286. case soptask.FieldCreatedAt:
  30287. v, ok := value.(time.Time)
  30288. if !ok {
  30289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30290. }
  30291. m.SetCreatedAt(v)
  30292. return nil
  30293. case soptask.FieldUpdatedAt:
  30294. v, ok := value.(time.Time)
  30295. if !ok {
  30296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30297. }
  30298. m.SetUpdatedAt(v)
  30299. return nil
  30300. case soptask.FieldStatus:
  30301. v, ok := value.(uint8)
  30302. if !ok {
  30303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30304. }
  30305. m.SetStatus(v)
  30306. return nil
  30307. case soptask.FieldDeletedAt:
  30308. v, ok := value.(time.Time)
  30309. if !ok {
  30310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30311. }
  30312. m.SetDeletedAt(v)
  30313. return nil
  30314. case soptask.FieldName:
  30315. v, ok := value.(string)
  30316. if !ok {
  30317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30318. }
  30319. m.SetName(v)
  30320. return nil
  30321. case soptask.FieldBotWxidList:
  30322. v, ok := value.([]string)
  30323. if !ok {
  30324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30325. }
  30326. m.SetBotWxidList(v)
  30327. return nil
  30328. case soptask.FieldType:
  30329. v, ok := value.(int)
  30330. if !ok {
  30331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30332. }
  30333. m.SetType(v)
  30334. return nil
  30335. case soptask.FieldPlanStartTime:
  30336. v, ok := value.(time.Time)
  30337. if !ok {
  30338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30339. }
  30340. m.SetPlanStartTime(v)
  30341. return nil
  30342. case soptask.FieldPlanEndTime:
  30343. v, ok := value.(time.Time)
  30344. if !ok {
  30345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30346. }
  30347. m.SetPlanEndTime(v)
  30348. return nil
  30349. case soptask.FieldCreatorID:
  30350. v, ok := value.(string)
  30351. if !ok {
  30352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30353. }
  30354. m.SetCreatorID(v)
  30355. return nil
  30356. case soptask.FieldOrganizationID:
  30357. v, ok := value.(uint64)
  30358. if !ok {
  30359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30360. }
  30361. m.SetOrganizationID(v)
  30362. return nil
  30363. case soptask.FieldToken:
  30364. v, ok := value.([]string)
  30365. if !ok {
  30366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30367. }
  30368. m.SetToken(v)
  30369. return nil
  30370. }
  30371. return fmt.Errorf("unknown SopTask field %s", name)
  30372. }
  30373. // AddedFields returns all numeric fields that were incremented/decremented during
  30374. // this mutation.
  30375. func (m *SopTaskMutation) AddedFields() []string {
  30376. var fields []string
  30377. if m.addstatus != nil {
  30378. fields = append(fields, soptask.FieldStatus)
  30379. }
  30380. if m.add_type != nil {
  30381. fields = append(fields, soptask.FieldType)
  30382. }
  30383. if m.addorganization_id != nil {
  30384. fields = append(fields, soptask.FieldOrganizationID)
  30385. }
  30386. return fields
  30387. }
  30388. // AddedField returns the numeric value that was incremented/decremented on a field
  30389. // with the given name. The second boolean return value indicates that this field
  30390. // was not set, or was not defined in the schema.
  30391. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  30392. switch name {
  30393. case soptask.FieldStatus:
  30394. return m.AddedStatus()
  30395. case soptask.FieldType:
  30396. return m.AddedType()
  30397. case soptask.FieldOrganizationID:
  30398. return m.AddedOrganizationID()
  30399. }
  30400. return nil, false
  30401. }
  30402. // AddField adds the value to the field with the given name. It returns an error if
  30403. // the field is not defined in the schema, or if the type mismatched the field
  30404. // type.
  30405. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  30406. switch name {
  30407. case soptask.FieldStatus:
  30408. v, ok := value.(int8)
  30409. if !ok {
  30410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30411. }
  30412. m.AddStatus(v)
  30413. return nil
  30414. case soptask.FieldType:
  30415. v, ok := value.(int)
  30416. if !ok {
  30417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30418. }
  30419. m.AddType(v)
  30420. return nil
  30421. case soptask.FieldOrganizationID:
  30422. v, ok := value.(int64)
  30423. if !ok {
  30424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30425. }
  30426. m.AddOrganizationID(v)
  30427. return nil
  30428. }
  30429. return fmt.Errorf("unknown SopTask numeric field %s", name)
  30430. }
  30431. // ClearedFields returns all nullable fields that were cleared during this
  30432. // mutation.
  30433. func (m *SopTaskMutation) ClearedFields() []string {
  30434. var fields []string
  30435. if m.FieldCleared(soptask.FieldStatus) {
  30436. fields = append(fields, soptask.FieldStatus)
  30437. }
  30438. if m.FieldCleared(soptask.FieldDeletedAt) {
  30439. fields = append(fields, soptask.FieldDeletedAt)
  30440. }
  30441. if m.FieldCleared(soptask.FieldBotWxidList) {
  30442. fields = append(fields, soptask.FieldBotWxidList)
  30443. }
  30444. if m.FieldCleared(soptask.FieldPlanStartTime) {
  30445. fields = append(fields, soptask.FieldPlanStartTime)
  30446. }
  30447. if m.FieldCleared(soptask.FieldPlanEndTime) {
  30448. fields = append(fields, soptask.FieldPlanEndTime)
  30449. }
  30450. if m.FieldCleared(soptask.FieldCreatorID) {
  30451. fields = append(fields, soptask.FieldCreatorID)
  30452. }
  30453. if m.FieldCleared(soptask.FieldOrganizationID) {
  30454. fields = append(fields, soptask.FieldOrganizationID)
  30455. }
  30456. if m.FieldCleared(soptask.FieldToken) {
  30457. fields = append(fields, soptask.FieldToken)
  30458. }
  30459. return fields
  30460. }
  30461. // FieldCleared returns a boolean indicating if a field with the given name was
  30462. // cleared in this mutation.
  30463. func (m *SopTaskMutation) FieldCleared(name string) bool {
  30464. _, ok := m.clearedFields[name]
  30465. return ok
  30466. }
  30467. // ClearField clears the value of the field with the given name. It returns an
  30468. // error if the field is not defined in the schema.
  30469. func (m *SopTaskMutation) ClearField(name string) error {
  30470. switch name {
  30471. case soptask.FieldStatus:
  30472. m.ClearStatus()
  30473. return nil
  30474. case soptask.FieldDeletedAt:
  30475. m.ClearDeletedAt()
  30476. return nil
  30477. case soptask.FieldBotWxidList:
  30478. m.ClearBotWxidList()
  30479. return nil
  30480. case soptask.FieldPlanStartTime:
  30481. m.ClearPlanStartTime()
  30482. return nil
  30483. case soptask.FieldPlanEndTime:
  30484. m.ClearPlanEndTime()
  30485. return nil
  30486. case soptask.FieldCreatorID:
  30487. m.ClearCreatorID()
  30488. return nil
  30489. case soptask.FieldOrganizationID:
  30490. m.ClearOrganizationID()
  30491. return nil
  30492. case soptask.FieldToken:
  30493. m.ClearToken()
  30494. return nil
  30495. }
  30496. return fmt.Errorf("unknown SopTask nullable field %s", name)
  30497. }
  30498. // ResetField resets all changes in the mutation for the field with the given name.
  30499. // It returns an error if the field is not defined in the schema.
  30500. func (m *SopTaskMutation) ResetField(name string) error {
  30501. switch name {
  30502. case soptask.FieldCreatedAt:
  30503. m.ResetCreatedAt()
  30504. return nil
  30505. case soptask.FieldUpdatedAt:
  30506. m.ResetUpdatedAt()
  30507. return nil
  30508. case soptask.FieldStatus:
  30509. m.ResetStatus()
  30510. return nil
  30511. case soptask.FieldDeletedAt:
  30512. m.ResetDeletedAt()
  30513. return nil
  30514. case soptask.FieldName:
  30515. m.ResetName()
  30516. return nil
  30517. case soptask.FieldBotWxidList:
  30518. m.ResetBotWxidList()
  30519. return nil
  30520. case soptask.FieldType:
  30521. m.ResetType()
  30522. return nil
  30523. case soptask.FieldPlanStartTime:
  30524. m.ResetPlanStartTime()
  30525. return nil
  30526. case soptask.FieldPlanEndTime:
  30527. m.ResetPlanEndTime()
  30528. return nil
  30529. case soptask.FieldCreatorID:
  30530. m.ResetCreatorID()
  30531. return nil
  30532. case soptask.FieldOrganizationID:
  30533. m.ResetOrganizationID()
  30534. return nil
  30535. case soptask.FieldToken:
  30536. m.ResetToken()
  30537. return nil
  30538. }
  30539. return fmt.Errorf("unknown SopTask field %s", name)
  30540. }
  30541. // AddedEdges returns all edge names that were set/added in this mutation.
  30542. func (m *SopTaskMutation) AddedEdges() []string {
  30543. edges := make([]string, 0, 1)
  30544. if m.task_stages != nil {
  30545. edges = append(edges, soptask.EdgeTaskStages)
  30546. }
  30547. return edges
  30548. }
  30549. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30550. // name in this mutation.
  30551. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  30552. switch name {
  30553. case soptask.EdgeTaskStages:
  30554. ids := make([]ent.Value, 0, len(m.task_stages))
  30555. for id := range m.task_stages {
  30556. ids = append(ids, id)
  30557. }
  30558. return ids
  30559. }
  30560. return nil
  30561. }
  30562. // RemovedEdges returns all edge names that were removed in this mutation.
  30563. func (m *SopTaskMutation) RemovedEdges() []string {
  30564. edges := make([]string, 0, 1)
  30565. if m.removedtask_stages != nil {
  30566. edges = append(edges, soptask.EdgeTaskStages)
  30567. }
  30568. return edges
  30569. }
  30570. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30571. // the given name in this mutation.
  30572. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  30573. switch name {
  30574. case soptask.EdgeTaskStages:
  30575. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  30576. for id := range m.removedtask_stages {
  30577. ids = append(ids, id)
  30578. }
  30579. return ids
  30580. }
  30581. return nil
  30582. }
  30583. // ClearedEdges returns all edge names that were cleared in this mutation.
  30584. func (m *SopTaskMutation) ClearedEdges() []string {
  30585. edges := make([]string, 0, 1)
  30586. if m.clearedtask_stages {
  30587. edges = append(edges, soptask.EdgeTaskStages)
  30588. }
  30589. return edges
  30590. }
  30591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30592. // was cleared in this mutation.
  30593. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  30594. switch name {
  30595. case soptask.EdgeTaskStages:
  30596. return m.clearedtask_stages
  30597. }
  30598. return false
  30599. }
  30600. // ClearEdge clears the value of the edge with the given name. It returns an error
  30601. // if that edge is not defined in the schema.
  30602. func (m *SopTaskMutation) ClearEdge(name string) error {
  30603. switch name {
  30604. }
  30605. return fmt.Errorf("unknown SopTask unique edge %s", name)
  30606. }
  30607. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30608. // It returns an error if the edge is not defined in the schema.
  30609. func (m *SopTaskMutation) ResetEdge(name string) error {
  30610. switch name {
  30611. case soptask.EdgeTaskStages:
  30612. m.ResetTaskStages()
  30613. return nil
  30614. }
  30615. return fmt.Errorf("unknown SopTask edge %s", name)
  30616. }
  30617. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  30618. type TokenMutation struct {
  30619. config
  30620. op Op
  30621. typ string
  30622. id *uint64
  30623. created_at *time.Time
  30624. updated_at *time.Time
  30625. deleted_at *time.Time
  30626. expire_at *time.Time
  30627. token *string
  30628. mac *string
  30629. organization_id *uint64
  30630. addorganization_id *int64
  30631. custom_agent_base *string
  30632. custom_agent_key *string
  30633. openai_base *string
  30634. openai_key *string
  30635. clearedFields map[string]struct{}
  30636. agent *uint64
  30637. clearedagent bool
  30638. done bool
  30639. oldValue func(context.Context) (*Token, error)
  30640. predicates []predicate.Token
  30641. }
  30642. var _ ent.Mutation = (*TokenMutation)(nil)
  30643. // tokenOption allows management of the mutation configuration using functional options.
  30644. type tokenOption func(*TokenMutation)
  30645. // newTokenMutation creates new mutation for the Token entity.
  30646. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  30647. m := &TokenMutation{
  30648. config: c,
  30649. op: op,
  30650. typ: TypeToken,
  30651. clearedFields: make(map[string]struct{}),
  30652. }
  30653. for _, opt := range opts {
  30654. opt(m)
  30655. }
  30656. return m
  30657. }
  30658. // withTokenID sets the ID field of the mutation.
  30659. func withTokenID(id uint64) tokenOption {
  30660. return func(m *TokenMutation) {
  30661. var (
  30662. err error
  30663. once sync.Once
  30664. value *Token
  30665. )
  30666. m.oldValue = func(ctx context.Context) (*Token, error) {
  30667. once.Do(func() {
  30668. if m.done {
  30669. err = errors.New("querying old values post mutation is not allowed")
  30670. } else {
  30671. value, err = m.Client().Token.Get(ctx, id)
  30672. }
  30673. })
  30674. return value, err
  30675. }
  30676. m.id = &id
  30677. }
  30678. }
  30679. // withToken sets the old Token of the mutation.
  30680. func withToken(node *Token) tokenOption {
  30681. return func(m *TokenMutation) {
  30682. m.oldValue = func(context.Context) (*Token, error) {
  30683. return node, nil
  30684. }
  30685. m.id = &node.ID
  30686. }
  30687. }
  30688. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30689. // executed in a transaction (ent.Tx), a transactional client is returned.
  30690. func (m TokenMutation) Client() *Client {
  30691. client := &Client{config: m.config}
  30692. client.init()
  30693. return client
  30694. }
  30695. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30696. // it returns an error otherwise.
  30697. func (m TokenMutation) Tx() (*Tx, error) {
  30698. if _, ok := m.driver.(*txDriver); !ok {
  30699. return nil, errors.New("ent: mutation is not running in a transaction")
  30700. }
  30701. tx := &Tx{config: m.config}
  30702. tx.init()
  30703. return tx, nil
  30704. }
  30705. // SetID sets the value of the id field. Note that this
  30706. // operation is only accepted on creation of Token entities.
  30707. func (m *TokenMutation) SetID(id uint64) {
  30708. m.id = &id
  30709. }
  30710. // ID returns the ID value in the mutation. Note that the ID is only available
  30711. // if it was provided to the builder or after it was returned from the database.
  30712. func (m *TokenMutation) ID() (id uint64, exists bool) {
  30713. if m.id == nil {
  30714. return
  30715. }
  30716. return *m.id, true
  30717. }
  30718. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30719. // That means, if the mutation is applied within a transaction with an isolation level such
  30720. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30721. // or updated by the mutation.
  30722. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  30723. switch {
  30724. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30725. id, exists := m.ID()
  30726. if exists {
  30727. return []uint64{id}, nil
  30728. }
  30729. fallthrough
  30730. case m.op.Is(OpUpdate | OpDelete):
  30731. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  30732. default:
  30733. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30734. }
  30735. }
  30736. // SetCreatedAt sets the "created_at" field.
  30737. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  30738. m.created_at = &t
  30739. }
  30740. // CreatedAt returns the value of the "created_at" field in the mutation.
  30741. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  30742. v := m.created_at
  30743. if v == nil {
  30744. return
  30745. }
  30746. return *v, true
  30747. }
  30748. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  30749. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30751. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30752. if !m.op.Is(OpUpdateOne) {
  30753. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30754. }
  30755. if m.id == nil || m.oldValue == nil {
  30756. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30757. }
  30758. oldValue, err := m.oldValue(ctx)
  30759. if err != nil {
  30760. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30761. }
  30762. return oldValue.CreatedAt, nil
  30763. }
  30764. // ResetCreatedAt resets all changes to the "created_at" field.
  30765. func (m *TokenMutation) ResetCreatedAt() {
  30766. m.created_at = nil
  30767. }
  30768. // SetUpdatedAt sets the "updated_at" field.
  30769. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  30770. m.updated_at = &t
  30771. }
  30772. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30773. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  30774. v := m.updated_at
  30775. if v == nil {
  30776. return
  30777. }
  30778. return *v, true
  30779. }
  30780. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  30781. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30783. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30784. if !m.op.Is(OpUpdateOne) {
  30785. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30786. }
  30787. if m.id == nil || m.oldValue == nil {
  30788. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30789. }
  30790. oldValue, err := m.oldValue(ctx)
  30791. if err != nil {
  30792. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30793. }
  30794. return oldValue.UpdatedAt, nil
  30795. }
  30796. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30797. func (m *TokenMutation) ResetUpdatedAt() {
  30798. m.updated_at = nil
  30799. }
  30800. // SetDeletedAt sets the "deleted_at" field.
  30801. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  30802. m.deleted_at = &t
  30803. }
  30804. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30805. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  30806. v := m.deleted_at
  30807. if v == nil {
  30808. return
  30809. }
  30810. return *v, true
  30811. }
  30812. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  30813. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30815. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30816. if !m.op.Is(OpUpdateOne) {
  30817. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30818. }
  30819. if m.id == nil || m.oldValue == nil {
  30820. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30821. }
  30822. oldValue, err := m.oldValue(ctx)
  30823. if err != nil {
  30824. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30825. }
  30826. return oldValue.DeletedAt, nil
  30827. }
  30828. // ClearDeletedAt clears the value of the "deleted_at" field.
  30829. func (m *TokenMutation) ClearDeletedAt() {
  30830. m.deleted_at = nil
  30831. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  30832. }
  30833. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30834. func (m *TokenMutation) DeletedAtCleared() bool {
  30835. _, ok := m.clearedFields[token.FieldDeletedAt]
  30836. return ok
  30837. }
  30838. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30839. func (m *TokenMutation) ResetDeletedAt() {
  30840. m.deleted_at = nil
  30841. delete(m.clearedFields, token.FieldDeletedAt)
  30842. }
  30843. // SetExpireAt sets the "expire_at" field.
  30844. func (m *TokenMutation) SetExpireAt(t time.Time) {
  30845. m.expire_at = &t
  30846. }
  30847. // ExpireAt returns the value of the "expire_at" field in the mutation.
  30848. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  30849. v := m.expire_at
  30850. if v == nil {
  30851. return
  30852. }
  30853. return *v, true
  30854. }
  30855. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  30856. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30858. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  30859. if !m.op.Is(OpUpdateOne) {
  30860. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  30861. }
  30862. if m.id == nil || m.oldValue == nil {
  30863. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  30864. }
  30865. oldValue, err := m.oldValue(ctx)
  30866. if err != nil {
  30867. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  30868. }
  30869. return oldValue.ExpireAt, nil
  30870. }
  30871. // ClearExpireAt clears the value of the "expire_at" field.
  30872. func (m *TokenMutation) ClearExpireAt() {
  30873. m.expire_at = nil
  30874. m.clearedFields[token.FieldExpireAt] = struct{}{}
  30875. }
  30876. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  30877. func (m *TokenMutation) ExpireAtCleared() bool {
  30878. _, ok := m.clearedFields[token.FieldExpireAt]
  30879. return ok
  30880. }
  30881. // ResetExpireAt resets all changes to the "expire_at" field.
  30882. func (m *TokenMutation) ResetExpireAt() {
  30883. m.expire_at = nil
  30884. delete(m.clearedFields, token.FieldExpireAt)
  30885. }
  30886. // SetToken sets the "token" field.
  30887. func (m *TokenMutation) SetToken(s string) {
  30888. m.token = &s
  30889. }
  30890. // Token returns the value of the "token" field in the mutation.
  30891. func (m *TokenMutation) Token() (r string, exists bool) {
  30892. v := m.token
  30893. if v == nil {
  30894. return
  30895. }
  30896. return *v, true
  30897. }
  30898. // OldToken returns the old "token" field's value of the Token entity.
  30899. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30901. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  30902. if !m.op.Is(OpUpdateOne) {
  30903. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  30904. }
  30905. if m.id == nil || m.oldValue == nil {
  30906. return v, errors.New("OldToken requires an ID field in the mutation")
  30907. }
  30908. oldValue, err := m.oldValue(ctx)
  30909. if err != nil {
  30910. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  30911. }
  30912. return oldValue.Token, nil
  30913. }
  30914. // ClearToken clears the value of the "token" field.
  30915. func (m *TokenMutation) ClearToken() {
  30916. m.token = nil
  30917. m.clearedFields[token.FieldToken] = struct{}{}
  30918. }
  30919. // TokenCleared returns if the "token" field was cleared in this mutation.
  30920. func (m *TokenMutation) TokenCleared() bool {
  30921. _, ok := m.clearedFields[token.FieldToken]
  30922. return ok
  30923. }
  30924. // ResetToken resets all changes to the "token" field.
  30925. func (m *TokenMutation) ResetToken() {
  30926. m.token = nil
  30927. delete(m.clearedFields, token.FieldToken)
  30928. }
  30929. // SetMAC sets the "mac" field.
  30930. func (m *TokenMutation) SetMAC(s string) {
  30931. m.mac = &s
  30932. }
  30933. // MAC returns the value of the "mac" field in the mutation.
  30934. func (m *TokenMutation) MAC() (r string, exists bool) {
  30935. v := m.mac
  30936. if v == nil {
  30937. return
  30938. }
  30939. return *v, true
  30940. }
  30941. // OldMAC returns the old "mac" field's value of the Token entity.
  30942. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30944. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  30945. if !m.op.Is(OpUpdateOne) {
  30946. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  30947. }
  30948. if m.id == nil || m.oldValue == nil {
  30949. return v, errors.New("OldMAC requires an ID field in the mutation")
  30950. }
  30951. oldValue, err := m.oldValue(ctx)
  30952. if err != nil {
  30953. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  30954. }
  30955. return oldValue.MAC, nil
  30956. }
  30957. // ClearMAC clears the value of the "mac" field.
  30958. func (m *TokenMutation) ClearMAC() {
  30959. m.mac = nil
  30960. m.clearedFields[token.FieldMAC] = struct{}{}
  30961. }
  30962. // MACCleared returns if the "mac" field was cleared in this mutation.
  30963. func (m *TokenMutation) MACCleared() bool {
  30964. _, ok := m.clearedFields[token.FieldMAC]
  30965. return ok
  30966. }
  30967. // ResetMAC resets all changes to the "mac" field.
  30968. func (m *TokenMutation) ResetMAC() {
  30969. m.mac = nil
  30970. delete(m.clearedFields, token.FieldMAC)
  30971. }
  30972. // SetOrganizationID sets the "organization_id" field.
  30973. func (m *TokenMutation) SetOrganizationID(u uint64) {
  30974. m.organization_id = &u
  30975. m.addorganization_id = nil
  30976. }
  30977. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30978. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  30979. v := m.organization_id
  30980. if v == nil {
  30981. return
  30982. }
  30983. return *v, true
  30984. }
  30985. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  30986. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  30987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30988. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30989. if !m.op.Is(OpUpdateOne) {
  30990. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30991. }
  30992. if m.id == nil || m.oldValue == nil {
  30993. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30994. }
  30995. oldValue, err := m.oldValue(ctx)
  30996. if err != nil {
  30997. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30998. }
  30999. return oldValue.OrganizationID, nil
  31000. }
  31001. // AddOrganizationID adds u to the "organization_id" field.
  31002. func (m *TokenMutation) AddOrganizationID(u int64) {
  31003. if m.addorganization_id != nil {
  31004. *m.addorganization_id += u
  31005. } else {
  31006. m.addorganization_id = &u
  31007. }
  31008. }
  31009. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31010. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  31011. v := m.addorganization_id
  31012. if v == nil {
  31013. return
  31014. }
  31015. return *v, true
  31016. }
  31017. // ResetOrganizationID resets all changes to the "organization_id" field.
  31018. func (m *TokenMutation) ResetOrganizationID() {
  31019. m.organization_id = nil
  31020. m.addorganization_id = nil
  31021. }
  31022. // SetAgentID sets the "agent_id" field.
  31023. func (m *TokenMutation) SetAgentID(u uint64) {
  31024. m.agent = &u
  31025. }
  31026. // AgentID returns the value of the "agent_id" field in the mutation.
  31027. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  31028. v := m.agent
  31029. if v == nil {
  31030. return
  31031. }
  31032. return *v, true
  31033. }
  31034. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  31035. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31037. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  31038. if !m.op.Is(OpUpdateOne) {
  31039. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  31040. }
  31041. if m.id == nil || m.oldValue == nil {
  31042. return v, errors.New("OldAgentID requires an ID field in the mutation")
  31043. }
  31044. oldValue, err := m.oldValue(ctx)
  31045. if err != nil {
  31046. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  31047. }
  31048. return oldValue.AgentID, nil
  31049. }
  31050. // ResetAgentID resets all changes to the "agent_id" field.
  31051. func (m *TokenMutation) ResetAgentID() {
  31052. m.agent = nil
  31053. }
  31054. // SetCustomAgentBase sets the "custom_agent_base" field.
  31055. func (m *TokenMutation) SetCustomAgentBase(s string) {
  31056. m.custom_agent_base = &s
  31057. }
  31058. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  31059. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  31060. v := m.custom_agent_base
  31061. if v == nil {
  31062. return
  31063. }
  31064. return *v, true
  31065. }
  31066. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  31067. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31069. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  31070. if !m.op.Is(OpUpdateOne) {
  31071. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  31072. }
  31073. if m.id == nil || m.oldValue == nil {
  31074. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  31075. }
  31076. oldValue, err := m.oldValue(ctx)
  31077. if err != nil {
  31078. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  31079. }
  31080. return oldValue.CustomAgentBase, nil
  31081. }
  31082. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  31083. func (m *TokenMutation) ClearCustomAgentBase() {
  31084. m.custom_agent_base = nil
  31085. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  31086. }
  31087. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  31088. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  31089. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  31090. return ok
  31091. }
  31092. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  31093. func (m *TokenMutation) ResetCustomAgentBase() {
  31094. m.custom_agent_base = nil
  31095. delete(m.clearedFields, token.FieldCustomAgentBase)
  31096. }
  31097. // SetCustomAgentKey sets the "custom_agent_key" field.
  31098. func (m *TokenMutation) SetCustomAgentKey(s string) {
  31099. m.custom_agent_key = &s
  31100. }
  31101. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  31102. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  31103. v := m.custom_agent_key
  31104. if v == nil {
  31105. return
  31106. }
  31107. return *v, true
  31108. }
  31109. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  31110. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31112. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  31113. if !m.op.Is(OpUpdateOne) {
  31114. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  31115. }
  31116. if m.id == nil || m.oldValue == nil {
  31117. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  31118. }
  31119. oldValue, err := m.oldValue(ctx)
  31120. if err != nil {
  31121. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  31122. }
  31123. return oldValue.CustomAgentKey, nil
  31124. }
  31125. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  31126. func (m *TokenMutation) ClearCustomAgentKey() {
  31127. m.custom_agent_key = nil
  31128. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  31129. }
  31130. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  31131. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  31132. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  31133. return ok
  31134. }
  31135. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  31136. func (m *TokenMutation) ResetCustomAgentKey() {
  31137. m.custom_agent_key = nil
  31138. delete(m.clearedFields, token.FieldCustomAgentKey)
  31139. }
  31140. // SetOpenaiBase sets the "openai_base" field.
  31141. func (m *TokenMutation) SetOpenaiBase(s string) {
  31142. m.openai_base = &s
  31143. }
  31144. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  31145. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  31146. v := m.openai_base
  31147. if v == nil {
  31148. return
  31149. }
  31150. return *v, true
  31151. }
  31152. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  31153. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31155. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  31156. if !m.op.Is(OpUpdateOne) {
  31157. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  31158. }
  31159. if m.id == nil || m.oldValue == nil {
  31160. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  31161. }
  31162. oldValue, err := m.oldValue(ctx)
  31163. if err != nil {
  31164. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  31165. }
  31166. return oldValue.OpenaiBase, nil
  31167. }
  31168. // ClearOpenaiBase clears the value of the "openai_base" field.
  31169. func (m *TokenMutation) ClearOpenaiBase() {
  31170. m.openai_base = nil
  31171. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  31172. }
  31173. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  31174. func (m *TokenMutation) OpenaiBaseCleared() bool {
  31175. _, ok := m.clearedFields[token.FieldOpenaiBase]
  31176. return ok
  31177. }
  31178. // ResetOpenaiBase resets all changes to the "openai_base" field.
  31179. func (m *TokenMutation) ResetOpenaiBase() {
  31180. m.openai_base = nil
  31181. delete(m.clearedFields, token.FieldOpenaiBase)
  31182. }
  31183. // SetOpenaiKey sets the "openai_key" field.
  31184. func (m *TokenMutation) SetOpenaiKey(s string) {
  31185. m.openai_key = &s
  31186. }
  31187. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  31188. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  31189. v := m.openai_key
  31190. if v == nil {
  31191. return
  31192. }
  31193. return *v, true
  31194. }
  31195. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  31196. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  31197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31198. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  31199. if !m.op.Is(OpUpdateOne) {
  31200. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  31201. }
  31202. if m.id == nil || m.oldValue == nil {
  31203. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  31204. }
  31205. oldValue, err := m.oldValue(ctx)
  31206. if err != nil {
  31207. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  31208. }
  31209. return oldValue.OpenaiKey, nil
  31210. }
  31211. // ClearOpenaiKey clears the value of the "openai_key" field.
  31212. func (m *TokenMutation) ClearOpenaiKey() {
  31213. m.openai_key = nil
  31214. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  31215. }
  31216. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  31217. func (m *TokenMutation) OpenaiKeyCleared() bool {
  31218. _, ok := m.clearedFields[token.FieldOpenaiKey]
  31219. return ok
  31220. }
  31221. // ResetOpenaiKey resets all changes to the "openai_key" field.
  31222. func (m *TokenMutation) ResetOpenaiKey() {
  31223. m.openai_key = nil
  31224. delete(m.clearedFields, token.FieldOpenaiKey)
  31225. }
  31226. // ClearAgent clears the "agent" edge to the Agent entity.
  31227. func (m *TokenMutation) ClearAgent() {
  31228. m.clearedagent = true
  31229. m.clearedFields[token.FieldAgentID] = struct{}{}
  31230. }
  31231. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  31232. func (m *TokenMutation) AgentCleared() bool {
  31233. return m.clearedagent
  31234. }
  31235. // AgentIDs returns the "agent" edge IDs in the mutation.
  31236. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  31237. // AgentID instead. It exists only for internal usage by the builders.
  31238. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  31239. if id := m.agent; id != nil {
  31240. ids = append(ids, *id)
  31241. }
  31242. return
  31243. }
  31244. // ResetAgent resets all changes to the "agent" edge.
  31245. func (m *TokenMutation) ResetAgent() {
  31246. m.agent = nil
  31247. m.clearedagent = false
  31248. }
  31249. // Where appends a list predicates to the TokenMutation builder.
  31250. func (m *TokenMutation) Where(ps ...predicate.Token) {
  31251. m.predicates = append(m.predicates, ps...)
  31252. }
  31253. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  31254. // users can use type-assertion to append predicates that do not depend on any generated package.
  31255. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  31256. p := make([]predicate.Token, len(ps))
  31257. for i := range ps {
  31258. p[i] = ps[i]
  31259. }
  31260. m.Where(p...)
  31261. }
  31262. // Op returns the operation name.
  31263. func (m *TokenMutation) Op() Op {
  31264. return m.op
  31265. }
  31266. // SetOp allows setting the mutation operation.
  31267. func (m *TokenMutation) SetOp(op Op) {
  31268. m.op = op
  31269. }
  31270. // Type returns the node type of this mutation (Token).
  31271. func (m *TokenMutation) Type() string {
  31272. return m.typ
  31273. }
  31274. // Fields returns all fields that were changed during this mutation. Note that in
  31275. // order to get all numeric fields that were incremented/decremented, call
  31276. // AddedFields().
  31277. func (m *TokenMutation) Fields() []string {
  31278. fields := make([]string, 0, 12)
  31279. if m.created_at != nil {
  31280. fields = append(fields, token.FieldCreatedAt)
  31281. }
  31282. if m.updated_at != nil {
  31283. fields = append(fields, token.FieldUpdatedAt)
  31284. }
  31285. if m.deleted_at != nil {
  31286. fields = append(fields, token.FieldDeletedAt)
  31287. }
  31288. if m.expire_at != nil {
  31289. fields = append(fields, token.FieldExpireAt)
  31290. }
  31291. if m.token != nil {
  31292. fields = append(fields, token.FieldToken)
  31293. }
  31294. if m.mac != nil {
  31295. fields = append(fields, token.FieldMAC)
  31296. }
  31297. if m.organization_id != nil {
  31298. fields = append(fields, token.FieldOrganizationID)
  31299. }
  31300. if m.agent != nil {
  31301. fields = append(fields, token.FieldAgentID)
  31302. }
  31303. if m.custom_agent_base != nil {
  31304. fields = append(fields, token.FieldCustomAgentBase)
  31305. }
  31306. if m.custom_agent_key != nil {
  31307. fields = append(fields, token.FieldCustomAgentKey)
  31308. }
  31309. if m.openai_base != nil {
  31310. fields = append(fields, token.FieldOpenaiBase)
  31311. }
  31312. if m.openai_key != nil {
  31313. fields = append(fields, token.FieldOpenaiKey)
  31314. }
  31315. return fields
  31316. }
  31317. // Field returns the value of a field with the given name. The second boolean
  31318. // return value indicates that this field was not set, or was not defined in the
  31319. // schema.
  31320. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  31321. switch name {
  31322. case token.FieldCreatedAt:
  31323. return m.CreatedAt()
  31324. case token.FieldUpdatedAt:
  31325. return m.UpdatedAt()
  31326. case token.FieldDeletedAt:
  31327. return m.DeletedAt()
  31328. case token.FieldExpireAt:
  31329. return m.ExpireAt()
  31330. case token.FieldToken:
  31331. return m.Token()
  31332. case token.FieldMAC:
  31333. return m.MAC()
  31334. case token.FieldOrganizationID:
  31335. return m.OrganizationID()
  31336. case token.FieldAgentID:
  31337. return m.AgentID()
  31338. case token.FieldCustomAgentBase:
  31339. return m.CustomAgentBase()
  31340. case token.FieldCustomAgentKey:
  31341. return m.CustomAgentKey()
  31342. case token.FieldOpenaiBase:
  31343. return m.OpenaiBase()
  31344. case token.FieldOpenaiKey:
  31345. return m.OpenaiKey()
  31346. }
  31347. return nil, false
  31348. }
  31349. // OldField returns the old value of the field from the database. An error is
  31350. // returned if the mutation operation is not UpdateOne, or the query to the
  31351. // database failed.
  31352. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31353. switch name {
  31354. case token.FieldCreatedAt:
  31355. return m.OldCreatedAt(ctx)
  31356. case token.FieldUpdatedAt:
  31357. return m.OldUpdatedAt(ctx)
  31358. case token.FieldDeletedAt:
  31359. return m.OldDeletedAt(ctx)
  31360. case token.FieldExpireAt:
  31361. return m.OldExpireAt(ctx)
  31362. case token.FieldToken:
  31363. return m.OldToken(ctx)
  31364. case token.FieldMAC:
  31365. return m.OldMAC(ctx)
  31366. case token.FieldOrganizationID:
  31367. return m.OldOrganizationID(ctx)
  31368. case token.FieldAgentID:
  31369. return m.OldAgentID(ctx)
  31370. case token.FieldCustomAgentBase:
  31371. return m.OldCustomAgentBase(ctx)
  31372. case token.FieldCustomAgentKey:
  31373. return m.OldCustomAgentKey(ctx)
  31374. case token.FieldOpenaiBase:
  31375. return m.OldOpenaiBase(ctx)
  31376. case token.FieldOpenaiKey:
  31377. return m.OldOpenaiKey(ctx)
  31378. }
  31379. return nil, fmt.Errorf("unknown Token field %s", name)
  31380. }
  31381. // SetField sets the value of a field with the given name. It returns an error if
  31382. // the field is not defined in the schema, or if the type mismatched the field
  31383. // type.
  31384. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  31385. switch name {
  31386. case token.FieldCreatedAt:
  31387. v, ok := value.(time.Time)
  31388. if !ok {
  31389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31390. }
  31391. m.SetCreatedAt(v)
  31392. return nil
  31393. case token.FieldUpdatedAt:
  31394. v, ok := value.(time.Time)
  31395. if !ok {
  31396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31397. }
  31398. m.SetUpdatedAt(v)
  31399. return nil
  31400. case token.FieldDeletedAt:
  31401. v, ok := value.(time.Time)
  31402. if !ok {
  31403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31404. }
  31405. m.SetDeletedAt(v)
  31406. return nil
  31407. case token.FieldExpireAt:
  31408. v, ok := value.(time.Time)
  31409. if !ok {
  31410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31411. }
  31412. m.SetExpireAt(v)
  31413. return nil
  31414. case token.FieldToken:
  31415. v, ok := value.(string)
  31416. if !ok {
  31417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31418. }
  31419. m.SetToken(v)
  31420. return nil
  31421. case token.FieldMAC:
  31422. v, ok := value.(string)
  31423. if !ok {
  31424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31425. }
  31426. m.SetMAC(v)
  31427. return nil
  31428. case token.FieldOrganizationID:
  31429. v, ok := value.(uint64)
  31430. if !ok {
  31431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31432. }
  31433. m.SetOrganizationID(v)
  31434. return nil
  31435. case token.FieldAgentID:
  31436. v, ok := value.(uint64)
  31437. if !ok {
  31438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31439. }
  31440. m.SetAgentID(v)
  31441. return nil
  31442. case token.FieldCustomAgentBase:
  31443. v, ok := value.(string)
  31444. if !ok {
  31445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31446. }
  31447. m.SetCustomAgentBase(v)
  31448. return nil
  31449. case token.FieldCustomAgentKey:
  31450. v, ok := value.(string)
  31451. if !ok {
  31452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31453. }
  31454. m.SetCustomAgentKey(v)
  31455. return nil
  31456. case token.FieldOpenaiBase:
  31457. v, ok := value.(string)
  31458. if !ok {
  31459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31460. }
  31461. m.SetOpenaiBase(v)
  31462. return nil
  31463. case token.FieldOpenaiKey:
  31464. v, ok := value.(string)
  31465. if !ok {
  31466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31467. }
  31468. m.SetOpenaiKey(v)
  31469. return nil
  31470. }
  31471. return fmt.Errorf("unknown Token field %s", name)
  31472. }
  31473. // AddedFields returns all numeric fields that were incremented/decremented during
  31474. // this mutation.
  31475. func (m *TokenMutation) AddedFields() []string {
  31476. var fields []string
  31477. if m.addorganization_id != nil {
  31478. fields = append(fields, token.FieldOrganizationID)
  31479. }
  31480. return fields
  31481. }
  31482. // AddedField returns the numeric value that was incremented/decremented on a field
  31483. // with the given name. The second boolean return value indicates that this field
  31484. // was not set, or was not defined in the schema.
  31485. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  31486. switch name {
  31487. case token.FieldOrganizationID:
  31488. return m.AddedOrganizationID()
  31489. }
  31490. return nil, false
  31491. }
  31492. // AddField adds the value to the field with the given name. It returns an error if
  31493. // the field is not defined in the schema, or if the type mismatched the field
  31494. // type.
  31495. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  31496. switch name {
  31497. case token.FieldOrganizationID:
  31498. v, ok := value.(int64)
  31499. if !ok {
  31500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31501. }
  31502. m.AddOrganizationID(v)
  31503. return nil
  31504. }
  31505. return fmt.Errorf("unknown Token numeric field %s", name)
  31506. }
  31507. // ClearedFields returns all nullable fields that were cleared during this
  31508. // mutation.
  31509. func (m *TokenMutation) ClearedFields() []string {
  31510. var fields []string
  31511. if m.FieldCleared(token.FieldDeletedAt) {
  31512. fields = append(fields, token.FieldDeletedAt)
  31513. }
  31514. if m.FieldCleared(token.FieldExpireAt) {
  31515. fields = append(fields, token.FieldExpireAt)
  31516. }
  31517. if m.FieldCleared(token.FieldToken) {
  31518. fields = append(fields, token.FieldToken)
  31519. }
  31520. if m.FieldCleared(token.FieldMAC) {
  31521. fields = append(fields, token.FieldMAC)
  31522. }
  31523. if m.FieldCleared(token.FieldCustomAgentBase) {
  31524. fields = append(fields, token.FieldCustomAgentBase)
  31525. }
  31526. if m.FieldCleared(token.FieldCustomAgentKey) {
  31527. fields = append(fields, token.FieldCustomAgentKey)
  31528. }
  31529. if m.FieldCleared(token.FieldOpenaiBase) {
  31530. fields = append(fields, token.FieldOpenaiBase)
  31531. }
  31532. if m.FieldCleared(token.FieldOpenaiKey) {
  31533. fields = append(fields, token.FieldOpenaiKey)
  31534. }
  31535. return fields
  31536. }
  31537. // FieldCleared returns a boolean indicating if a field with the given name was
  31538. // cleared in this mutation.
  31539. func (m *TokenMutation) FieldCleared(name string) bool {
  31540. _, ok := m.clearedFields[name]
  31541. return ok
  31542. }
  31543. // ClearField clears the value of the field with the given name. It returns an
  31544. // error if the field is not defined in the schema.
  31545. func (m *TokenMutation) ClearField(name string) error {
  31546. switch name {
  31547. case token.FieldDeletedAt:
  31548. m.ClearDeletedAt()
  31549. return nil
  31550. case token.FieldExpireAt:
  31551. m.ClearExpireAt()
  31552. return nil
  31553. case token.FieldToken:
  31554. m.ClearToken()
  31555. return nil
  31556. case token.FieldMAC:
  31557. m.ClearMAC()
  31558. return nil
  31559. case token.FieldCustomAgentBase:
  31560. m.ClearCustomAgentBase()
  31561. return nil
  31562. case token.FieldCustomAgentKey:
  31563. m.ClearCustomAgentKey()
  31564. return nil
  31565. case token.FieldOpenaiBase:
  31566. m.ClearOpenaiBase()
  31567. return nil
  31568. case token.FieldOpenaiKey:
  31569. m.ClearOpenaiKey()
  31570. return nil
  31571. }
  31572. return fmt.Errorf("unknown Token nullable field %s", name)
  31573. }
  31574. // ResetField resets all changes in the mutation for the field with the given name.
  31575. // It returns an error if the field is not defined in the schema.
  31576. func (m *TokenMutation) ResetField(name string) error {
  31577. switch name {
  31578. case token.FieldCreatedAt:
  31579. m.ResetCreatedAt()
  31580. return nil
  31581. case token.FieldUpdatedAt:
  31582. m.ResetUpdatedAt()
  31583. return nil
  31584. case token.FieldDeletedAt:
  31585. m.ResetDeletedAt()
  31586. return nil
  31587. case token.FieldExpireAt:
  31588. m.ResetExpireAt()
  31589. return nil
  31590. case token.FieldToken:
  31591. m.ResetToken()
  31592. return nil
  31593. case token.FieldMAC:
  31594. m.ResetMAC()
  31595. return nil
  31596. case token.FieldOrganizationID:
  31597. m.ResetOrganizationID()
  31598. return nil
  31599. case token.FieldAgentID:
  31600. m.ResetAgentID()
  31601. return nil
  31602. case token.FieldCustomAgentBase:
  31603. m.ResetCustomAgentBase()
  31604. return nil
  31605. case token.FieldCustomAgentKey:
  31606. m.ResetCustomAgentKey()
  31607. return nil
  31608. case token.FieldOpenaiBase:
  31609. m.ResetOpenaiBase()
  31610. return nil
  31611. case token.FieldOpenaiKey:
  31612. m.ResetOpenaiKey()
  31613. return nil
  31614. }
  31615. return fmt.Errorf("unknown Token field %s", name)
  31616. }
  31617. // AddedEdges returns all edge names that were set/added in this mutation.
  31618. func (m *TokenMutation) AddedEdges() []string {
  31619. edges := make([]string, 0, 1)
  31620. if m.agent != nil {
  31621. edges = append(edges, token.EdgeAgent)
  31622. }
  31623. return edges
  31624. }
  31625. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31626. // name in this mutation.
  31627. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  31628. switch name {
  31629. case token.EdgeAgent:
  31630. if id := m.agent; id != nil {
  31631. return []ent.Value{*id}
  31632. }
  31633. }
  31634. return nil
  31635. }
  31636. // RemovedEdges returns all edge names that were removed in this mutation.
  31637. func (m *TokenMutation) RemovedEdges() []string {
  31638. edges := make([]string, 0, 1)
  31639. return edges
  31640. }
  31641. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31642. // the given name in this mutation.
  31643. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  31644. return nil
  31645. }
  31646. // ClearedEdges returns all edge names that were cleared in this mutation.
  31647. func (m *TokenMutation) ClearedEdges() []string {
  31648. edges := make([]string, 0, 1)
  31649. if m.clearedagent {
  31650. edges = append(edges, token.EdgeAgent)
  31651. }
  31652. return edges
  31653. }
  31654. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31655. // was cleared in this mutation.
  31656. func (m *TokenMutation) EdgeCleared(name string) bool {
  31657. switch name {
  31658. case token.EdgeAgent:
  31659. return m.clearedagent
  31660. }
  31661. return false
  31662. }
  31663. // ClearEdge clears the value of the edge with the given name. It returns an error
  31664. // if that edge is not defined in the schema.
  31665. func (m *TokenMutation) ClearEdge(name string) error {
  31666. switch name {
  31667. case token.EdgeAgent:
  31668. m.ClearAgent()
  31669. return nil
  31670. }
  31671. return fmt.Errorf("unknown Token unique edge %s", name)
  31672. }
  31673. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31674. // It returns an error if the edge is not defined in the schema.
  31675. func (m *TokenMutation) ResetEdge(name string) error {
  31676. switch name {
  31677. case token.EdgeAgent:
  31678. m.ResetAgent()
  31679. return nil
  31680. }
  31681. return fmt.Errorf("unknown Token edge %s", name)
  31682. }
  31683. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  31684. type TutorialMutation struct {
  31685. config
  31686. op Op
  31687. typ string
  31688. id *uint64
  31689. created_at *time.Time
  31690. updated_at *time.Time
  31691. deleted_at *time.Time
  31692. index *int
  31693. addindex *int
  31694. title *string
  31695. content *string
  31696. organization_id *uint64
  31697. addorganization_id *int64
  31698. clearedFields map[string]struct{}
  31699. employee *uint64
  31700. clearedemployee bool
  31701. done bool
  31702. oldValue func(context.Context) (*Tutorial, error)
  31703. predicates []predicate.Tutorial
  31704. }
  31705. var _ ent.Mutation = (*TutorialMutation)(nil)
  31706. // tutorialOption allows management of the mutation configuration using functional options.
  31707. type tutorialOption func(*TutorialMutation)
  31708. // newTutorialMutation creates new mutation for the Tutorial entity.
  31709. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  31710. m := &TutorialMutation{
  31711. config: c,
  31712. op: op,
  31713. typ: TypeTutorial,
  31714. clearedFields: make(map[string]struct{}),
  31715. }
  31716. for _, opt := range opts {
  31717. opt(m)
  31718. }
  31719. return m
  31720. }
  31721. // withTutorialID sets the ID field of the mutation.
  31722. func withTutorialID(id uint64) tutorialOption {
  31723. return func(m *TutorialMutation) {
  31724. var (
  31725. err error
  31726. once sync.Once
  31727. value *Tutorial
  31728. )
  31729. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  31730. once.Do(func() {
  31731. if m.done {
  31732. err = errors.New("querying old values post mutation is not allowed")
  31733. } else {
  31734. value, err = m.Client().Tutorial.Get(ctx, id)
  31735. }
  31736. })
  31737. return value, err
  31738. }
  31739. m.id = &id
  31740. }
  31741. }
  31742. // withTutorial sets the old Tutorial of the mutation.
  31743. func withTutorial(node *Tutorial) tutorialOption {
  31744. return func(m *TutorialMutation) {
  31745. m.oldValue = func(context.Context) (*Tutorial, error) {
  31746. return node, nil
  31747. }
  31748. m.id = &node.ID
  31749. }
  31750. }
  31751. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31752. // executed in a transaction (ent.Tx), a transactional client is returned.
  31753. func (m TutorialMutation) Client() *Client {
  31754. client := &Client{config: m.config}
  31755. client.init()
  31756. return client
  31757. }
  31758. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31759. // it returns an error otherwise.
  31760. func (m TutorialMutation) Tx() (*Tx, error) {
  31761. if _, ok := m.driver.(*txDriver); !ok {
  31762. return nil, errors.New("ent: mutation is not running in a transaction")
  31763. }
  31764. tx := &Tx{config: m.config}
  31765. tx.init()
  31766. return tx, nil
  31767. }
  31768. // SetID sets the value of the id field. Note that this
  31769. // operation is only accepted on creation of Tutorial entities.
  31770. func (m *TutorialMutation) SetID(id uint64) {
  31771. m.id = &id
  31772. }
  31773. // ID returns the ID value in the mutation. Note that the ID is only available
  31774. // if it was provided to the builder or after it was returned from the database.
  31775. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  31776. if m.id == nil {
  31777. return
  31778. }
  31779. return *m.id, true
  31780. }
  31781. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31782. // That means, if the mutation is applied within a transaction with an isolation level such
  31783. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31784. // or updated by the mutation.
  31785. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  31786. switch {
  31787. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31788. id, exists := m.ID()
  31789. if exists {
  31790. return []uint64{id}, nil
  31791. }
  31792. fallthrough
  31793. case m.op.Is(OpUpdate | OpDelete):
  31794. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  31795. default:
  31796. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31797. }
  31798. }
  31799. // SetCreatedAt sets the "created_at" field.
  31800. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  31801. m.created_at = &t
  31802. }
  31803. // CreatedAt returns the value of the "created_at" field in the mutation.
  31804. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  31805. v := m.created_at
  31806. if v == nil {
  31807. return
  31808. }
  31809. return *v, true
  31810. }
  31811. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  31812. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31814. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31815. if !m.op.Is(OpUpdateOne) {
  31816. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31817. }
  31818. if m.id == nil || m.oldValue == nil {
  31819. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31820. }
  31821. oldValue, err := m.oldValue(ctx)
  31822. if err != nil {
  31823. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31824. }
  31825. return oldValue.CreatedAt, nil
  31826. }
  31827. // ResetCreatedAt resets all changes to the "created_at" field.
  31828. func (m *TutorialMutation) ResetCreatedAt() {
  31829. m.created_at = nil
  31830. }
  31831. // SetUpdatedAt sets the "updated_at" field.
  31832. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  31833. m.updated_at = &t
  31834. }
  31835. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31836. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  31837. v := m.updated_at
  31838. if v == nil {
  31839. return
  31840. }
  31841. return *v, true
  31842. }
  31843. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  31844. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31846. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31847. if !m.op.Is(OpUpdateOne) {
  31848. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31849. }
  31850. if m.id == nil || m.oldValue == nil {
  31851. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31852. }
  31853. oldValue, err := m.oldValue(ctx)
  31854. if err != nil {
  31855. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31856. }
  31857. return oldValue.UpdatedAt, nil
  31858. }
  31859. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31860. func (m *TutorialMutation) ResetUpdatedAt() {
  31861. m.updated_at = nil
  31862. }
  31863. // SetDeletedAt sets the "deleted_at" field.
  31864. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  31865. m.deleted_at = &t
  31866. }
  31867. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31868. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  31869. v := m.deleted_at
  31870. if v == nil {
  31871. return
  31872. }
  31873. return *v, true
  31874. }
  31875. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  31876. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31878. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31879. if !m.op.Is(OpUpdateOne) {
  31880. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31881. }
  31882. if m.id == nil || m.oldValue == nil {
  31883. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31884. }
  31885. oldValue, err := m.oldValue(ctx)
  31886. if err != nil {
  31887. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31888. }
  31889. return oldValue.DeletedAt, nil
  31890. }
  31891. // ClearDeletedAt clears the value of the "deleted_at" field.
  31892. func (m *TutorialMutation) ClearDeletedAt() {
  31893. m.deleted_at = nil
  31894. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  31895. }
  31896. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31897. func (m *TutorialMutation) DeletedAtCleared() bool {
  31898. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  31899. return ok
  31900. }
  31901. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31902. func (m *TutorialMutation) ResetDeletedAt() {
  31903. m.deleted_at = nil
  31904. delete(m.clearedFields, tutorial.FieldDeletedAt)
  31905. }
  31906. // SetEmployeeID sets the "employee_id" field.
  31907. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  31908. m.employee = &u
  31909. }
  31910. // EmployeeID returns the value of the "employee_id" field in the mutation.
  31911. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  31912. v := m.employee
  31913. if v == nil {
  31914. return
  31915. }
  31916. return *v, true
  31917. }
  31918. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  31919. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31921. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  31922. if !m.op.Is(OpUpdateOne) {
  31923. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  31924. }
  31925. if m.id == nil || m.oldValue == nil {
  31926. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  31927. }
  31928. oldValue, err := m.oldValue(ctx)
  31929. if err != nil {
  31930. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  31931. }
  31932. return oldValue.EmployeeID, nil
  31933. }
  31934. // ResetEmployeeID resets all changes to the "employee_id" field.
  31935. func (m *TutorialMutation) ResetEmployeeID() {
  31936. m.employee = nil
  31937. }
  31938. // SetIndex sets the "index" field.
  31939. func (m *TutorialMutation) SetIndex(i int) {
  31940. m.index = &i
  31941. m.addindex = nil
  31942. }
  31943. // Index returns the value of the "index" field in the mutation.
  31944. func (m *TutorialMutation) Index() (r int, exists bool) {
  31945. v := m.index
  31946. if v == nil {
  31947. return
  31948. }
  31949. return *v, true
  31950. }
  31951. // OldIndex returns the old "index" field's value of the Tutorial entity.
  31952. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  31953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31954. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  31955. if !m.op.Is(OpUpdateOne) {
  31956. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  31957. }
  31958. if m.id == nil || m.oldValue == nil {
  31959. return v, errors.New("OldIndex requires an ID field in the mutation")
  31960. }
  31961. oldValue, err := m.oldValue(ctx)
  31962. if err != nil {
  31963. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  31964. }
  31965. return oldValue.Index, nil
  31966. }
  31967. // AddIndex adds i to the "index" field.
  31968. func (m *TutorialMutation) AddIndex(i int) {
  31969. if m.addindex != nil {
  31970. *m.addindex += i
  31971. } else {
  31972. m.addindex = &i
  31973. }
  31974. }
  31975. // AddedIndex returns the value that was added to the "index" field in this mutation.
  31976. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  31977. v := m.addindex
  31978. if v == nil {
  31979. return
  31980. }
  31981. return *v, true
  31982. }
  31983. // ResetIndex resets all changes to the "index" field.
  31984. func (m *TutorialMutation) ResetIndex() {
  31985. m.index = nil
  31986. m.addindex = nil
  31987. }
  31988. // SetTitle sets the "title" field.
  31989. func (m *TutorialMutation) SetTitle(s string) {
  31990. m.title = &s
  31991. }
  31992. // Title returns the value of the "title" field in the mutation.
  31993. func (m *TutorialMutation) Title() (r string, exists bool) {
  31994. v := m.title
  31995. if v == nil {
  31996. return
  31997. }
  31998. return *v, true
  31999. }
  32000. // OldTitle returns the old "title" field's value of the Tutorial entity.
  32001. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32003. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  32004. if !m.op.Is(OpUpdateOne) {
  32005. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  32006. }
  32007. if m.id == nil || m.oldValue == nil {
  32008. return v, errors.New("OldTitle requires an ID field in the mutation")
  32009. }
  32010. oldValue, err := m.oldValue(ctx)
  32011. if err != nil {
  32012. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  32013. }
  32014. return oldValue.Title, nil
  32015. }
  32016. // ResetTitle resets all changes to the "title" field.
  32017. func (m *TutorialMutation) ResetTitle() {
  32018. m.title = nil
  32019. }
  32020. // SetContent sets the "content" field.
  32021. func (m *TutorialMutation) SetContent(s string) {
  32022. m.content = &s
  32023. }
  32024. // Content returns the value of the "content" field in the mutation.
  32025. func (m *TutorialMutation) Content() (r string, exists bool) {
  32026. v := m.content
  32027. if v == nil {
  32028. return
  32029. }
  32030. return *v, true
  32031. }
  32032. // OldContent returns the old "content" field's value of the Tutorial entity.
  32033. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32035. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  32036. if !m.op.Is(OpUpdateOne) {
  32037. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  32038. }
  32039. if m.id == nil || m.oldValue == nil {
  32040. return v, errors.New("OldContent requires an ID field in the mutation")
  32041. }
  32042. oldValue, err := m.oldValue(ctx)
  32043. if err != nil {
  32044. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  32045. }
  32046. return oldValue.Content, nil
  32047. }
  32048. // ResetContent resets all changes to the "content" field.
  32049. func (m *TutorialMutation) ResetContent() {
  32050. m.content = nil
  32051. }
  32052. // SetOrganizationID sets the "organization_id" field.
  32053. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  32054. m.organization_id = &u
  32055. m.addorganization_id = nil
  32056. }
  32057. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32058. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  32059. v := m.organization_id
  32060. if v == nil {
  32061. return
  32062. }
  32063. return *v, true
  32064. }
  32065. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  32066. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  32067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32068. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32069. if !m.op.Is(OpUpdateOne) {
  32070. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32071. }
  32072. if m.id == nil || m.oldValue == nil {
  32073. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32074. }
  32075. oldValue, err := m.oldValue(ctx)
  32076. if err != nil {
  32077. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32078. }
  32079. return oldValue.OrganizationID, nil
  32080. }
  32081. // AddOrganizationID adds u to the "organization_id" field.
  32082. func (m *TutorialMutation) AddOrganizationID(u int64) {
  32083. if m.addorganization_id != nil {
  32084. *m.addorganization_id += u
  32085. } else {
  32086. m.addorganization_id = &u
  32087. }
  32088. }
  32089. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32090. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  32091. v := m.addorganization_id
  32092. if v == nil {
  32093. return
  32094. }
  32095. return *v, true
  32096. }
  32097. // ResetOrganizationID resets all changes to the "organization_id" field.
  32098. func (m *TutorialMutation) ResetOrganizationID() {
  32099. m.organization_id = nil
  32100. m.addorganization_id = nil
  32101. }
  32102. // ClearEmployee clears the "employee" edge to the Employee entity.
  32103. func (m *TutorialMutation) ClearEmployee() {
  32104. m.clearedemployee = true
  32105. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  32106. }
  32107. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  32108. func (m *TutorialMutation) EmployeeCleared() bool {
  32109. return m.clearedemployee
  32110. }
  32111. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  32112. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  32113. // EmployeeID instead. It exists only for internal usage by the builders.
  32114. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  32115. if id := m.employee; id != nil {
  32116. ids = append(ids, *id)
  32117. }
  32118. return
  32119. }
  32120. // ResetEmployee resets all changes to the "employee" edge.
  32121. func (m *TutorialMutation) ResetEmployee() {
  32122. m.employee = nil
  32123. m.clearedemployee = false
  32124. }
  32125. // Where appends a list predicates to the TutorialMutation builder.
  32126. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  32127. m.predicates = append(m.predicates, ps...)
  32128. }
  32129. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  32130. // users can use type-assertion to append predicates that do not depend on any generated package.
  32131. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  32132. p := make([]predicate.Tutorial, len(ps))
  32133. for i := range ps {
  32134. p[i] = ps[i]
  32135. }
  32136. m.Where(p...)
  32137. }
  32138. // Op returns the operation name.
  32139. func (m *TutorialMutation) Op() Op {
  32140. return m.op
  32141. }
  32142. // SetOp allows setting the mutation operation.
  32143. func (m *TutorialMutation) SetOp(op Op) {
  32144. m.op = op
  32145. }
  32146. // Type returns the node type of this mutation (Tutorial).
  32147. func (m *TutorialMutation) Type() string {
  32148. return m.typ
  32149. }
  32150. // Fields returns all fields that were changed during this mutation. Note that in
  32151. // order to get all numeric fields that were incremented/decremented, call
  32152. // AddedFields().
  32153. func (m *TutorialMutation) Fields() []string {
  32154. fields := make([]string, 0, 8)
  32155. if m.created_at != nil {
  32156. fields = append(fields, tutorial.FieldCreatedAt)
  32157. }
  32158. if m.updated_at != nil {
  32159. fields = append(fields, tutorial.FieldUpdatedAt)
  32160. }
  32161. if m.deleted_at != nil {
  32162. fields = append(fields, tutorial.FieldDeletedAt)
  32163. }
  32164. if m.employee != nil {
  32165. fields = append(fields, tutorial.FieldEmployeeID)
  32166. }
  32167. if m.index != nil {
  32168. fields = append(fields, tutorial.FieldIndex)
  32169. }
  32170. if m.title != nil {
  32171. fields = append(fields, tutorial.FieldTitle)
  32172. }
  32173. if m.content != nil {
  32174. fields = append(fields, tutorial.FieldContent)
  32175. }
  32176. if m.organization_id != nil {
  32177. fields = append(fields, tutorial.FieldOrganizationID)
  32178. }
  32179. return fields
  32180. }
  32181. // Field returns the value of a field with the given name. The second boolean
  32182. // return value indicates that this field was not set, or was not defined in the
  32183. // schema.
  32184. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  32185. switch name {
  32186. case tutorial.FieldCreatedAt:
  32187. return m.CreatedAt()
  32188. case tutorial.FieldUpdatedAt:
  32189. return m.UpdatedAt()
  32190. case tutorial.FieldDeletedAt:
  32191. return m.DeletedAt()
  32192. case tutorial.FieldEmployeeID:
  32193. return m.EmployeeID()
  32194. case tutorial.FieldIndex:
  32195. return m.Index()
  32196. case tutorial.FieldTitle:
  32197. return m.Title()
  32198. case tutorial.FieldContent:
  32199. return m.Content()
  32200. case tutorial.FieldOrganizationID:
  32201. return m.OrganizationID()
  32202. }
  32203. return nil, false
  32204. }
  32205. // OldField returns the old value of the field from the database. An error is
  32206. // returned if the mutation operation is not UpdateOne, or the query to the
  32207. // database failed.
  32208. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32209. switch name {
  32210. case tutorial.FieldCreatedAt:
  32211. return m.OldCreatedAt(ctx)
  32212. case tutorial.FieldUpdatedAt:
  32213. return m.OldUpdatedAt(ctx)
  32214. case tutorial.FieldDeletedAt:
  32215. return m.OldDeletedAt(ctx)
  32216. case tutorial.FieldEmployeeID:
  32217. return m.OldEmployeeID(ctx)
  32218. case tutorial.FieldIndex:
  32219. return m.OldIndex(ctx)
  32220. case tutorial.FieldTitle:
  32221. return m.OldTitle(ctx)
  32222. case tutorial.FieldContent:
  32223. return m.OldContent(ctx)
  32224. case tutorial.FieldOrganizationID:
  32225. return m.OldOrganizationID(ctx)
  32226. }
  32227. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  32228. }
  32229. // SetField sets the value of a field with the given name. It returns an error if
  32230. // the field is not defined in the schema, or if the type mismatched the field
  32231. // type.
  32232. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  32233. switch name {
  32234. case tutorial.FieldCreatedAt:
  32235. v, ok := value.(time.Time)
  32236. if !ok {
  32237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32238. }
  32239. m.SetCreatedAt(v)
  32240. return nil
  32241. case tutorial.FieldUpdatedAt:
  32242. v, ok := value.(time.Time)
  32243. if !ok {
  32244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32245. }
  32246. m.SetUpdatedAt(v)
  32247. return nil
  32248. case tutorial.FieldDeletedAt:
  32249. v, ok := value.(time.Time)
  32250. if !ok {
  32251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32252. }
  32253. m.SetDeletedAt(v)
  32254. return nil
  32255. case tutorial.FieldEmployeeID:
  32256. v, ok := value.(uint64)
  32257. if !ok {
  32258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32259. }
  32260. m.SetEmployeeID(v)
  32261. return nil
  32262. case tutorial.FieldIndex:
  32263. v, ok := value.(int)
  32264. if !ok {
  32265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32266. }
  32267. m.SetIndex(v)
  32268. return nil
  32269. case tutorial.FieldTitle:
  32270. v, ok := value.(string)
  32271. if !ok {
  32272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32273. }
  32274. m.SetTitle(v)
  32275. return nil
  32276. case tutorial.FieldContent:
  32277. v, ok := value.(string)
  32278. if !ok {
  32279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32280. }
  32281. m.SetContent(v)
  32282. return nil
  32283. case tutorial.FieldOrganizationID:
  32284. v, ok := value.(uint64)
  32285. if !ok {
  32286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32287. }
  32288. m.SetOrganizationID(v)
  32289. return nil
  32290. }
  32291. return fmt.Errorf("unknown Tutorial field %s", name)
  32292. }
  32293. // AddedFields returns all numeric fields that were incremented/decremented during
  32294. // this mutation.
  32295. func (m *TutorialMutation) AddedFields() []string {
  32296. var fields []string
  32297. if m.addindex != nil {
  32298. fields = append(fields, tutorial.FieldIndex)
  32299. }
  32300. if m.addorganization_id != nil {
  32301. fields = append(fields, tutorial.FieldOrganizationID)
  32302. }
  32303. return fields
  32304. }
  32305. // AddedField returns the numeric value that was incremented/decremented on a field
  32306. // with the given name. The second boolean return value indicates that this field
  32307. // was not set, or was not defined in the schema.
  32308. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  32309. switch name {
  32310. case tutorial.FieldIndex:
  32311. return m.AddedIndex()
  32312. case tutorial.FieldOrganizationID:
  32313. return m.AddedOrganizationID()
  32314. }
  32315. return nil, false
  32316. }
  32317. // AddField adds the value to the field with the given name. It returns an error if
  32318. // the field is not defined in the schema, or if the type mismatched the field
  32319. // type.
  32320. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  32321. switch name {
  32322. case tutorial.FieldIndex:
  32323. v, ok := value.(int)
  32324. if !ok {
  32325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32326. }
  32327. m.AddIndex(v)
  32328. return nil
  32329. case tutorial.FieldOrganizationID:
  32330. v, ok := value.(int64)
  32331. if !ok {
  32332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32333. }
  32334. m.AddOrganizationID(v)
  32335. return nil
  32336. }
  32337. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  32338. }
  32339. // ClearedFields returns all nullable fields that were cleared during this
  32340. // mutation.
  32341. func (m *TutorialMutation) ClearedFields() []string {
  32342. var fields []string
  32343. if m.FieldCleared(tutorial.FieldDeletedAt) {
  32344. fields = append(fields, tutorial.FieldDeletedAt)
  32345. }
  32346. return fields
  32347. }
  32348. // FieldCleared returns a boolean indicating if a field with the given name was
  32349. // cleared in this mutation.
  32350. func (m *TutorialMutation) FieldCleared(name string) bool {
  32351. _, ok := m.clearedFields[name]
  32352. return ok
  32353. }
  32354. // ClearField clears the value of the field with the given name. It returns an
  32355. // error if the field is not defined in the schema.
  32356. func (m *TutorialMutation) ClearField(name string) error {
  32357. switch name {
  32358. case tutorial.FieldDeletedAt:
  32359. m.ClearDeletedAt()
  32360. return nil
  32361. }
  32362. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  32363. }
  32364. // ResetField resets all changes in the mutation for the field with the given name.
  32365. // It returns an error if the field is not defined in the schema.
  32366. func (m *TutorialMutation) ResetField(name string) error {
  32367. switch name {
  32368. case tutorial.FieldCreatedAt:
  32369. m.ResetCreatedAt()
  32370. return nil
  32371. case tutorial.FieldUpdatedAt:
  32372. m.ResetUpdatedAt()
  32373. return nil
  32374. case tutorial.FieldDeletedAt:
  32375. m.ResetDeletedAt()
  32376. return nil
  32377. case tutorial.FieldEmployeeID:
  32378. m.ResetEmployeeID()
  32379. return nil
  32380. case tutorial.FieldIndex:
  32381. m.ResetIndex()
  32382. return nil
  32383. case tutorial.FieldTitle:
  32384. m.ResetTitle()
  32385. return nil
  32386. case tutorial.FieldContent:
  32387. m.ResetContent()
  32388. return nil
  32389. case tutorial.FieldOrganizationID:
  32390. m.ResetOrganizationID()
  32391. return nil
  32392. }
  32393. return fmt.Errorf("unknown Tutorial field %s", name)
  32394. }
  32395. // AddedEdges returns all edge names that were set/added in this mutation.
  32396. func (m *TutorialMutation) AddedEdges() []string {
  32397. edges := make([]string, 0, 1)
  32398. if m.employee != nil {
  32399. edges = append(edges, tutorial.EdgeEmployee)
  32400. }
  32401. return edges
  32402. }
  32403. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32404. // name in this mutation.
  32405. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  32406. switch name {
  32407. case tutorial.EdgeEmployee:
  32408. if id := m.employee; id != nil {
  32409. return []ent.Value{*id}
  32410. }
  32411. }
  32412. return nil
  32413. }
  32414. // RemovedEdges returns all edge names that were removed in this mutation.
  32415. func (m *TutorialMutation) RemovedEdges() []string {
  32416. edges := make([]string, 0, 1)
  32417. return edges
  32418. }
  32419. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32420. // the given name in this mutation.
  32421. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  32422. return nil
  32423. }
  32424. // ClearedEdges returns all edge names that were cleared in this mutation.
  32425. func (m *TutorialMutation) ClearedEdges() []string {
  32426. edges := make([]string, 0, 1)
  32427. if m.clearedemployee {
  32428. edges = append(edges, tutorial.EdgeEmployee)
  32429. }
  32430. return edges
  32431. }
  32432. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32433. // was cleared in this mutation.
  32434. func (m *TutorialMutation) EdgeCleared(name string) bool {
  32435. switch name {
  32436. case tutorial.EdgeEmployee:
  32437. return m.clearedemployee
  32438. }
  32439. return false
  32440. }
  32441. // ClearEdge clears the value of the edge with the given name. It returns an error
  32442. // if that edge is not defined in the schema.
  32443. func (m *TutorialMutation) ClearEdge(name string) error {
  32444. switch name {
  32445. case tutorial.EdgeEmployee:
  32446. m.ClearEmployee()
  32447. return nil
  32448. }
  32449. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  32450. }
  32451. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32452. // It returns an error if the edge is not defined in the schema.
  32453. func (m *TutorialMutation) ResetEdge(name string) error {
  32454. switch name {
  32455. case tutorial.EdgeEmployee:
  32456. m.ResetEmployee()
  32457. return nil
  32458. }
  32459. return fmt.Errorf("unknown Tutorial edge %s", name)
  32460. }
  32461. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  32462. type UsageDetailMutation struct {
  32463. config
  32464. op Op
  32465. typ string
  32466. id *uint64
  32467. created_at *time.Time
  32468. updated_at *time.Time
  32469. status *uint8
  32470. addstatus *int8
  32471. _type *int
  32472. add_type *int
  32473. bot_id *string
  32474. receiver_id *string
  32475. app *int
  32476. addapp *int
  32477. session_id *uint64
  32478. addsession_id *int64
  32479. request *string
  32480. response *string
  32481. original_data *custom_types.OriginalData
  32482. total_tokens *uint64
  32483. addtotal_tokens *int64
  32484. prompt_tokens *uint64
  32485. addprompt_tokens *int64
  32486. completion_tokens *uint64
  32487. addcompletion_tokens *int64
  32488. organization_id *uint64
  32489. addorganization_id *int64
  32490. clearedFields map[string]struct{}
  32491. done bool
  32492. oldValue func(context.Context) (*UsageDetail, error)
  32493. predicates []predicate.UsageDetail
  32494. }
  32495. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  32496. // usagedetailOption allows management of the mutation configuration using functional options.
  32497. type usagedetailOption func(*UsageDetailMutation)
  32498. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  32499. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  32500. m := &UsageDetailMutation{
  32501. config: c,
  32502. op: op,
  32503. typ: TypeUsageDetail,
  32504. clearedFields: make(map[string]struct{}),
  32505. }
  32506. for _, opt := range opts {
  32507. opt(m)
  32508. }
  32509. return m
  32510. }
  32511. // withUsageDetailID sets the ID field of the mutation.
  32512. func withUsageDetailID(id uint64) usagedetailOption {
  32513. return func(m *UsageDetailMutation) {
  32514. var (
  32515. err error
  32516. once sync.Once
  32517. value *UsageDetail
  32518. )
  32519. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  32520. once.Do(func() {
  32521. if m.done {
  32522. err = errors.New("querying old values post mutation is not allowed")
  32523. } else {
  32524. value, err = m.Client().UsageDetail.Get(ctx, id)
  32525. }
  32526. })
  32527. return value, err
  32528. }
  32529. m.id = &id
  32530. }
  32531. }
  32532. // withUsageDetail sets the old UsageDetail of the mutation.
  32533. func withUsageDetail(node *UsageDetail) usagedetailOption {
  32534. return func(m *UsageDetailMutation) {
  32535. m.oldValue = func(context.Context) (*UsageDetail, error) {
  32536. return node, nil
  32537. }
  32538. m.id = &node.ID
  32539. }
  32540. }
  32541. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32542. // executed in a transaction (ent.Tx), a transactional client is returned.
  32543. func (m UsageDetailMutation) Client() *Client {
  32544. client := &Client{config: m.config}
  32545. client.init()
  32546. return client
  32547. }
  32548. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32549. // it returns an error otherwise.
  32550. func (m UsageDetailMutation) Tx() (*Tx, error) {
  32551. if _, ok := m.driver.(*txDriver); !ok {
  32552. return nil, errors.New("ent: mutation is not running in a transaction")
  32553. }
  32554. tx := &Tx{config: m.config}
  32555. tx.init()
  32556. return tx, nil
  32557. }
  32558. // SetID sets the value of the id field. Note that this
  32559. // operation is only accepted on creation of UsageDetail entities.
  32560. func (m *UsageDetailMutation) SetID(id uint64) {
  32561. m.id = &id
  32562. }
  32563. // ID returns the ID value in the mutation. Note that the ID is only available
  32564. // if it was provided to the builder or after it was returned from the database.
  32565. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  32566. if m.id == nil {
  32567. return
  32568. }
  32569. return *m.id, true
  32570. }
  32571. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32572. // That means, if the mutation is applied within a transaction with an isolation level such
  32573. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32574. // or updated by the mutation.
  32575. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  32576. switch {
  32577. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32578. id, exists := m.ID()
  32579. if exists {
  32580. return []uint64{id}, nil
  32581. }
  32582. fallthrough
  32583. case m.op.Is(OpUpdate | OpDelete):
  32584. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  32585. default:
  32586. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32587. }
  32588. }
  32589. // SetCreatedAt sets the "created_at" field.
  32590. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  32591. m.created_at = &t
  32592. }
  32593. // CreatedAt returns the value of the "created_at" field in the mutation.
  32594. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  32595. v := m.created_at
  32596. if v == nil {
  32597. return
  32598. }
  32599. return *v, true
  32600. }
  32601. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  32602. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32604. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32605. if !m.op.Is(OpUpdateOne) {
  32606. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32607. }
  32608. if m.id == nil || m.oldValue == nil {
  32609. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32610. }
  32611. oldValue, err := m.oldValue(ctx)
  32612. if err != nil {
  32613. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32614. }
  32615. return oldValue.CreatedAt, nil
  32616. }
  32617. // ResetCreatedAt resets all changes to the "created_at" field.
  32618. func (m *UsageDetailMutation) ResetCreatedAt() {
  32619. m.created_at = nil
  32620. }
  32621. // SetUpdatedAt sets the "updated_at" field.
  32622. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  32623. m.updated_at = &t
  32624. }
  32625. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32626. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  32627. v := m.updated_at
  32628. if v == nil {
  32629. return
  32630. }
  32631. return *v, true
  32632. }
  32633. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  32634. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32636. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32637. if !m.op.Is(OpUpdateOne) {
  32638. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32639. }
  32640. if m.id == nil || m.oldValue == nil {
  32641. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32642. }
  32643. oldValue, err := m.oldValue(ctx)
  32644. if err != nil {
  32645. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32646. }
  32647. return oldValue.UpdatedAt, nil
  32648. }
  32649. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32650. func (m *UsageDetailMutation) ResetUpdatedAt() {
  32651. m.updated_at = nil
  32652. }
  32653. // SetStatus sets the "status" field.
  32654. func (m *UsageDetailMutation) SetStatus(u uint8) {
  32655. m.status = &u
  32656. m.addstatus = nil
  32657. }
  32658. // Status returns the value of the "status" field in the mutation.
  32659. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  32660. v := m.status
  32661. if v == nil {
  32662. return
  32663. }
  32664. return *v, true
  32665. }
  32666. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  32667. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32669. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32670. if !m.op.Is(OpUpdateOne) {
  32671. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32672. }
  32673. if m.id == nil || m.oldValue == nil {
  32674. return v, errors.New("OldStatus requires an ID field in the mutation")
  32675. }
  32676. oldValue, err := m.oldValue(ctx)
  32677. if err != nil {
  32678. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32679. }
  32680. return oldValue.Status, nil
  32681. }
  32682. // AddStatus adds u to the "status" field.
  32683. func (m *UsageDetailMutation) AddStatus(u int8) {
  32684. if m.addstatus != nil {
  32685. *m.addstatus += u
  32686. } else {
  32687. m.addstatus = &u
  32688. }
  32689. }
  32690. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32691. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  32692. v := m.addstatus
  32693. if v == nil {
  32694. return
  32695. }
  32696. return *v, true
  32697. }
  32698. // ClearStatus clears the value of the "status" field.
  32699. func (m *UsageDetailMutation) ClearStatus() {
  32700. m.status = nil
  32701. m.addstatus = nil
  32702. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  32703. }
  32704. // StatusCleared returns if the "status" field was cleared in this mutation.
  32705. func (m *UsageDetailMutation) StatusCleared() bool {
  32706. _, ok := m.clearedFields[usagedetail.FieldStatus]
  32707. return ok
  32708. }
  32709. // ResetStatus resets all changes to the "status" field.
  32710. func (m *UsageDetailMutation) ResetStatus() {
  32711. m.status = nil
  32712. m.addstatus = nil
  32713. delete(m.clearedFields, usagedetail.FieldStatus)
  32714. }
  32715. // SetType sets the "type" field.
  32716. func (m *UsageDetailMutation) SetType(i int) {
  32717. m._type = &i
  32718. m.add_type = nil
  32719. }
  32720. // GetType returns the value of the "type" field in the mutation.
  32721. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  32722. v := m._type
  32723. if v == nil {
  32724. return
  32725. }
  32726. return *v, true
  32727. }
  32728. // OldType returns the old "type" field's value of the UsageDetail entity.
  32729. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32731. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  32732. if !m.op.Is(OpUpdateOne) {
  32733. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32734. }
  32735. if m.id == nil || m.oldValue == nil {
  32736. return v, errors.New("OldType requires an ID field in the mutation")
  32737. }
  32738. oldValue, err := m.oldValue(ctx)
  32739. if err != nil {
  32740. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32741. }
  32742. return oldValue.Type, nil
  32743. }
  32744. // AddType adds i to the "type" field.
  32745. func (m *UsageDetailMutation) AddType(i int) {
  32746. if m.add_type != nil {
  32747. *m.add_type += i
  32748. } else {
  32749. m.add_type = &i
  32750. }
  32751. }
  32752. // AddedType returns the value that was added to the "type" field in this mutation.
  32753. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  32754. v := m.add_type
  32755. if v == nil {
  32756. return
  32757. }
  32758. return *v, true
  32759. }
  32760. // ClearType clears the value of the "type" field.
  32761. func (m *UsageDetailMutation) ClearType() {
  32762. m._type = nil
  32763. m.add_type = nil
  32764. m.clearedFields[usagedetail.FieldType] = struct{}{}
  32765. }
  32766. // TypeCleared returns if the "type" field was cleared in this mutation.
  32767. func (m *UsageDetailMutation) TypeCleared() bool {
  32768. _, ok := m.clearedFields[usagedetail.FieldType]
  32769. return ok
  32770. }
  32771. // ResetType resets all changes to the "type" field.
  32772. func (m *UsageDetailMutation) ResetType() {
  32773. m._type = nil
  32774. m.add_type = nil
  32775. delete(m.clearedFields, usagedetail.FieldType)
  32776. }
  32777. // SetBotID sets the "bot_id" field.
  32778. func (m *UsageDetailMutation) SetBotID(s string) {
  32779. m.bot_id = &s
  32780. }
  32781. // BotID returns the value of the "bot_id" field in the mutation.
  32782. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  32783. v := m.bot_id
  32784. if v == nil {
  32785. return
  32786. }
  32787. return *v, true
  32788. }
  32789. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  32790. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32791. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32792. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  32793. if !m.op.Is(OpUpdateOne) {
  32794. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32795. }
  32796. if m.id == nil || m.oldValue == nil {
  32797. return v, errors.New("OldBotID requires an ID field in the mutation")
  32798. }
  32799. oldValue, err := m.oldValue(ctx)
  32800. if err != nil {
  32801. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32802. }
  32803. return oldValue.BotID, nil
  32804. }
  32805. // ResetBotID resets all changes to the "bot_id" field.
  32806. func (m *UsageDetailMutation) ResetBotID() {
  32807. m.bot_id = nil
  32808. }
  32809. // SetReceiverID sets the "receiver_id" field.
  32810. func (m *UsageDetailMutation) SetReceiverID(s string) {
  32811. m.receiver_id = &s
  32812. }
  32813. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  32814. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  32815. v := m.receiver_id
  32816. if v == nil {
  32817. return
  32818. }
  32819. return *v, true
  32820. }
  32821. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  32822. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32824. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  32825. if !m.op.Is(OpUpdateOne) {
  32826. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  32827. }
  32828. if m.id == nil || m.oldValue == nil {
  32829. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  32830. }
  32831. oldValue, err := m.oldValue(ctx)
  32832. if err != nil {
  32833. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  32834. }
  32835. return oldValue.ReceiverID, nil
  32836. }
  32837. // ResetReceiverID resets all changes to the "receiver_id" field.
  32838. func (m *UsageDetailMutation) ResetReceiverID() {
  32839. m.receiver_id = nil
  32840. }
  32841. // SetApp sets the "app" field.
  32842. func (m *UsageDetailMutation) SetApp(i int) {
  32843. m.app = &i
  32844. m.addapp = nil
  32845. }
  32846. // App returns the value of the "app" field in the mutation.
  32847. func (m *UsageDetailMutation) App() (r int, exists bool) {
  32848. v := m.app
  32849. if v == nil {
  32850. return
  32851. }
  32852. return *v, true
  32853. }
  32854. // OldApp returns the old "app" field's value of the UsageDetail entity.
  32855. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32857. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  32858. if !m.op.Is(OpUpdateOne) {
  32859. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  32860. }
  32861. if m.id == nil || m.oldValue == nil {
  32862. return v, errors.New("OldApp requires an ID field in the mutation")
  32863. }
  32864. oldValue, err := m.oldValue(ctx)
  32865. if err != nil {
  32866. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  32867. }
  32868. return oldValue.App, nil
  32869. }
  32870. // AddApp adds i to the "app" field.
  32871. func (m *UsageDetailMutation) AddApp(i int) {
  32872. if m.addapp != nil {
  32873. *m.addapp += i
  32874. } else {
  32875. m.addapp = &i
  32876. }
  32877. }
  32878. // AddedApp returns the value that was added to the "app" field in this mutation.
  32879. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  32880. v := m.addapp
  32881. if v == nil {
  32882. return
  32883. }
  32884. return *v, true
  32885. }
  32886. // ClearApp clears the value of the "app" field.
  32887. func (m *UsageDetailMutation) ClearApp() {
  32888. m.app = nil
  32889. m.addapp = nil
  32890. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  32891. }
  32892. // AppCleared returns if the "app" field was cleared in this mutation.
  32893. func (m *UsageDetailMutation) AppCleared() bool {
  32894. _, ok := m.clearedFields[usagedetail.FieldApp]
  32895. return ok
  32896. }
  32897. // ResetApp resets all changes to the "app" field.
  32898. func (m *UsageDetailMutation) ResetApp() {
  32899. m.app = nil
  32900. m.addapp = nil
  32901. delete(m.clearedFields, usagedetail.FieldApp)
  32902. }
  32903. // SetSessionID sets the "session_id" field.
  32904. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  32905. m.session_id = &u
  32906. m.addsession_id = nil
  32907. }
  32908. // SessionID returns the value of the "session_id" field in the mutation.
  32909. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  32910. v := m.session_id
  32911. if v == nil {
  32912. return
  32913. }
  32914. return *v, true
  32915. }
  32916. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  32917. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32919. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  32920. if !m.op.Is(OpUpdateOne) {
  32921. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  32922. }
  32923. if m.id == nil || m.oldValue == nil {
  32924. return v, errors.New("OldSessionID requires an ID field in the mutation")
  32925. }
  32926. oldValue, err := m.oldValue(ctx)
  32927. if err != nil {
  32928. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  32929. }
  32930. return oldValue.SessionID, nil
  32931. }
  32932. // AddSessionID adds u to the "session_id" field.
  32933. func (m *UsageDetailMutation) AddSessionID(u int64) {
  32934. if m.addsession_id != nil {
  32935. *m.addsession_id += u
  32936. } else {
  32937. m.addsession_id = &u
  32938. }
  32939. }
  32940. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  32941. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  32942. v := m.addsession_id
  32943. if v == nil {
  32944. return
  32945. }
  32946. return *v, true
  32947. }
  32948. // ClearSessionID clears the value of the "session_id" field.
  32949. func (m *UsageDetailMutation) ClearSessionID() {
  32950. m.session_id = nil
  32951. m.addsession_id = nil
  32952. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  32953. }
  32954. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  32955. func (m *UsageDetailMutation) SessionIDCleared() bool {
  32956. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  32957. return ok
  32958. }
  32959. // ResetSessionID resets all changes to the "session_id" field.
  32960. func (m *UsageDetailMutation) ResetSessionID() {
  32961. m.session_id = nil
  32962. m.addsession_id = nil
  32963. delete(m.clearedFields, usagedetail.FieldSessionID)
  32964. }
  32965. // SetRequest sets the "request" field.
  32966. func (m *UsageDetailMutation) SetRequest(s string) {
  32967. m.request = &s
  32968. }
  32969. // Request returns the value of the "request" field in the mutation.
  32970. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  32971. v := m.request
  32972. if v == nil {
  32973. return
  32974. }
  32975. return *v, true
  32976. }
  32977. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  32978. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  32979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32980. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  32981. if !m.op.Is(OpUpdateOne) {
  32982. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  32983. }
  32984. if m.id == nil || m.oldValue == nil {
  32985. return v, errors.New("OldRequest requires an ID field in the mutation")
  32986. }
  32987. oldValue, err := m.oldValue(ctx)
  32988. if err != nil {
  32989. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  32990. }
  32991. return oldValue.Request, nil
  32992. }
  32993. // ResetRequest resets all changes to the "request" field.
  32994. func (m *UsageDetailMutation) ResetRequest() {
  32995. m.request = nil
  32996. }
  32997. // SetResponse sets the "response" field.
  32998. func (m *UsageDetailMutation) SetResponse(s string) {
  32999. m.response = &s
  33000. }
  33001. // Response returns the value of the "response" field in the mutation.
  33002. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  33003. v := m.response
  33004. if v == nil {
  33005. return
  33006. }
  33007. return *v, true
  33008. }
  33009. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  33010. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33012. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  33013. if !m.op.Is(OpUpdateOne) {
  33014. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  33015. }
  33016. if m.id == nil || m.oldValue == nil {
  33017. return v, errors.New("OldResponse requires an ID field in the mutation")
  33018. }
  33019. oldValue, err := m.oldValue(ctx)
  33020. if err != nil {
  33021. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  33022. }
  33023. return oldValue.Response, nil
  33024. }
  33025. // ResetResponse resets all changes to the "response" field.
  33026. func (m *UsageDetailMutation) ResetResponse() {
  33027. m.response = nil
  33028. }
  33029. // SetOriginalData sets the "original_data" field.
  33030. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  33031. m.original_data = &ctd
  33032. }
  33033. // OriginalData returns the value of the "original_data" field in the mutation.
  33034. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  33035. v := m.original_data
  33036. if v == nil {
  33037. return
  33038. }
  33039. return *v, true
  33040. }
  33041. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  33042. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33044. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  33045. if !m.op.Is(OpUpdateOne) {
  33046. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  33047. }
  33048. if m.id == nil || m.oldValue == nil {
  33049. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  33050. }
  33051. oldValue, err := m.oldValue(ctx)
  33052. if err != nil {
  33053. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  33054. }
  33055. return oldValue.OriginalData, nil
  33056. }
  33057. // ResetOriginalData resets all changes to the "original_data" field.
  33058. func (m *UsageDetailMutation) ResetOriginalData() {
  33059. m.original_data = nil
  33060. }
  33061. // SetTotalTokens sets the "total_tokens" field.
  33062. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  33063. m.total_tokens = &u
  33064. m.addtotal_tokens = nil
  33065. }
  33066. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33067. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  33068. v := m.total_tokens
  33069. if v == nil {
  33070. return
  33071. }
  33072. return *v, true
  33073. }
  33074. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  33075. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33077. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33078. if !m.op.Is(OpUpdateOne) {
  33079. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33080. }
  33081. if m.id == nil || m.oldValue == nil {
  33082. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33083. }
  33084. oldValue, err := m.oldValue(ctx)
  33085. if err != nil {
  33086. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33087. }
  33088. return oldValue.TotalTokens, nil
  33089. }
  33090. // AddTotalTokens adds u to the "total_tokens" field.
  33091. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  33092. if m.addtotal_tokens != nil {
  33093. *m.addtotal_tokens += u
  33094. } else {
  33095. m.addtotal_tokens = &u
  33096. }
  33097. }
  33098. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33099. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  33100. v := m.addtotal_tokens
  33101. if v == nil {
  33102. return
  33103. }
  33104. return *v, true
  33105. }
  33106. // ClearTotalTokens clears the value of the "total_tokens" field.
  33107. func (m *UsageDetailMutation) ClearTotalTokens() {
  33108. m.total_tokens = nil
  33109. m.addtotal_tokens = nil
  33110. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  33111. }
  33112. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33113. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  33114. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  33115. return ok
  33116. }
  33117. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33118. func (m *UsageDetailMutation) ResetTotalTokens() {
  33119. m.total_tokens = nil
  33120. m.addtotal_tokens = nil
  33121. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  33122. }
  33123. // SetPromptTokens sets the "prompt_tokens" field.
  33124. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  33125. m.prompt_tokens = &u
  33126. m.addprompt_tokens = nil
  33127. }
  33128. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  33129. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  33130. v := m.prompt_tokens
  33131. if v == nil {
  33132. return
  33133. }
  33134. return *v, true
  33135. }
  33136. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  33137. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33139. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  33140. if !m.op.Is(OpUpdateOne) {
  33141. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  33142. }
  33143. if m.id == nil || m.oldValue == nil {
  33144. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  33145. }
  33146. oldValue, err := m.oldValue(ctx)
  33147. if err != nil {
  33148. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  33149. }
  33150. return oldValue.PromptTokens, nil
  33151. }
  33152. // AddPromptTokens adds u to the "prompt_tokens" field.
  33153. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  33154. if m.addprompt_tokens != nil {
  33155. *m.addprompt_tokens += u
  33156. } else {
  33157. m.addprompt_tokens = &u
  33158. }
  33159. }
  33160. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  33161. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  33162. v := m.addprompt_tokens
  33163. if v == nil {
  33164. return
  33165. }
  33166. return *v, true
  33167. }
  33168. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  33169. func (m *UsageDetailMutation) ClearPromptTokens() {
  33170. m.prompt_tokens = nil
  33171. m.addprompt_tokens = nil
  33172. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  33173. }
  33174. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  33175. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  33176. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  33177. return ok
  33178. }
  33179. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  33180. func (m *UsageDetailMutation) ResetPromptTokens() {
  33181. m.prompt_tokens = nil
  33182. m.addprompt_tokens = nil
  33183. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  33184. }
  33185. // SetCompletionTokens sets the "completion_tokens" field.
  33186. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  33187. m.completion_tokens = &u
  33188. m.addcompletion_tokens = nil
  33189. }
  33190. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  33191. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  33192. v := m.completion_tokens
  33193. if v == nil {
  33194. return
  33195. }
  33196. return *v, true
  33197. }
  33198. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  33199. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33201. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  33202. if !m.op.Is(OpUpdateOne) {
  33203. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  33204. }
  33205. if m.id == nil || m.oldValue == nil {
  33206. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  33207. }
  33208. oldValue, err := m.oldValue(ctx)
  33209. if err != nil {
  33210. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  33211. }
  33212. return oldValue.CompletionTokens, nil
  33213. }
  33214. // AddCompletionTokens adds u to the "completion_tokens" field.
  33215. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  33216. if m.addcompletion_tokens != nil {
  33217. *m.addcompletion_tokens += u
  33218. } else {
  33219. m.addcompletion_tokens = &u
  33220. }
  33221. }
  33222. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  33223. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  33224. v := m.addcompletion_tokens
  33225. if v == nil {
  33226. return
  33227. }
  33228. return *v, true
  33229. }
  33230. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  33231. func (m *UsageDetailMutation) ClearCompletionTokens() {
  33232. m.completion_tokens = nil
  33233. m.addcompletion_tokens = nil
  33234. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  33235. }
  33236. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  33237. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  33238. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  33239. return ok
  33240. }
  33241. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  33242. func (m *UsageDetailMutation) ResetCompletionTokens() {
  33243. m.completion_tokens = nil
  33244. m.addcompletion_tokens = nil
  33245. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  33246. }
  33247. // SetOrganizationID sets the "organization_id" field.
  33248. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  33249. m.organization_id = &u
  33250. m.addorganization_id = nil
  33251. }
  33252. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33253. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  33254. v := m.organization_id
  33255. if v == nil {
  33256. return
  33257. }
  33258. return *v, true
  33259. }
  33260. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  33261. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  33262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33263. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33264. if !m.op.Is(OpUpdateOne) {
  33265. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33266. }
  33267. if m.id == nil || m.oldValue == nil {
  33268. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33269. }
  33270. oldValue, err := m.oldValue(ctx)
  33271. if err != nil {
  33272. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33273. }
  33274. return oldValue.OrganizationID, nil
  33275. }
  33276. // AddOrganizationID adds u to the "organization_id" field.
  33277. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  33278. if m.addorganization_id != nil {
  33279. *m.addorganization_id += u
  33280. } else {
  33281. m.addorganization_id = &u
  33282. }
  33283. }
  33284. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33285. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  33286. v := m.addorganization_id
  33287. if v == nil {
  33288. return
  33289. }
  33290. return *v, true
  33291. }
  33292. // ClearOrganizationID clears the value of the "organization_id" field.
  33293. func (m *UsageDetailMutation) ClearOrganizationID() {
  33294. m.organization_id = nil
  33295. m.addorganization_id = nil
  33296. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  33297. }
  33298. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33299. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  33300. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  33301. return ok
  33302. }
  33303. // ResetOrganizationID resets all changes to the "organization_id" field.
  33304. func (m *UsageDetailMutation) ResetOrganizationID() {
  33305. m.organization_id = nil
  33306. m.addorganization_id = nil
  33307. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  33308. }
  33309. // Where appends a list predicates to the UsageDetailMutation builder.
  33310. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  33311. m.predicates = append(m.predicates, ps...)
  33312. }
  33313. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  33314. // users can use type-assertion to append predicates that do not depend on any generated package.
  33315. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  33316. p := make([]predicate.UsageDetail, len(ps))
  33317. for i := range ps {
  33318. p[i] = ps[i]
  33319. }
  33320. m.Where(p...)
  33321. }
  33322. // Op returns the operation name.
  33323. func (m *UsageDetailMutation) Op() Op {
  33324. return m.op
  33325. }
  33326. // SetOp allows setting the mutation operation.
  33327. func (m *UsageDetailMutation) SetOp(op Op) {
  33328. m.op = op
  33329. }
  33330. // Type returns the node type of this mutation (UsageDetail).
  33331. func (m *UsageDetailMutation) Type() string {
  33332. return m.typ
  33333. }
  33334. // Fields returns all fields that were changed during this mutation. Note that in
  33335. // order to get all numeric fields that were incremented/decremented, call
  33336. // AddedFields().
  33337. func (m *UsageDetailMutation) Fields() []string {
  33338. fields := make([]string, 0, 15)
  33339. if m.created_at != nil {
  33340. fields = append(fields, usagedetail.FieldCreatedAt)
  33341. }
  33342. if m.updated_at != nil {
  33343. fields = append(fields, usagedetail.FieldUpdatedAt)
  33344. }
  33345. if m.status != nil {
  33346. fields = append(fields, usagedetail.FieldStatus)
  33347. }
  33348. if m._type != nil {
  33349. fields = append(fields, usagedetail.FieldType)
  33350. }
  33351. if m.bot_id != nil {
  33352. fields = append(fields, usagedetail.FieldBotID)
  33353. }
  33354. if m.receiver_id != nil {
  33355. fields = append(fields, usagedetail.FieldReceiverID)
  33356. }
  33357. if m.app != nil {
  33358. fields = append(fields, usagedetail.FieldApp)
  33359. }
  33360. if m.session_id != nil {
  33361. fields = append(fields, usagedetail.FieldSessionID)
  33362. }
  33363. if m.request != nil {
  33364. fields = append(fields, usagedetail.FieldRequest)
  33365. }
  33366. if m.response != nil {
  33367. fields = append(fields, usagedetail.FieldResponse)
  33368. }
  33369. if m.original_data != nil {
  33370. fields = append(fields, usagedetail.FieldOriginalData)
  33371. }
  33372. if m.total_tokens != nil {
  33373. fields = append(fields, usagedetail.FieldTotalTokens)
  33374. }
  33375. if m.prompt_tokens != nil {
  33376. fields = append(fields, usagedetail.FieldPromptTokens)
  33377. }
  33378. if m.completion_tokens != nil {
  33379. fields = append(fields, usagedetail.FieldCompletionTokens)
  33380. }
  33381. if m.organization_id != nil {
  33382. fields = append(fields, usagedetail.FieldOrganizationID)
  33383. }
  33384. return fields
  33385. }
  33386. // Field returns the value of a field with the given name. The second boolean
  33387. // return value indicates that this field was not set, or was not defined in the
  33388. // schema.
  33389. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  33390. switch name {
  33391. case usagedetail.FieldCreatedAt:
  33392. return m.CreatedAt()
  33393. case usagedetail.FieldUpdatedAt:
  33394. return m.UpdatedAt()
  33395. case usagedetail.FieldStatus:
  33396. return m.Status()
  33397. case usagedetail.FieldType:
  33398. return m.GetType()
  33399. case usagedetail.FieldBotID:
  33400. return m.BotID()
  33401. case usagedetail.FieldReceiverID:
  33402. return m.ReceiverID()
  33403. case usagedetail.FieldApp:
  33404. return m.App()
  33405. case usagedetail.FieldSessionID:
  33406. return m.SessionID()
  33407. case usagedetail.FieldRequest:
  33408. return m.Request()
  33409. case usagedetail.FieldResponse:
  33410. return m.Response()
  33411. case usagedetail.FieldOriginalData:
  33412. return m.OriginalData()
  33413. case usagedetail.FieldTotalTokens:
  33414. return m.TotalTokens()
  33415. case usagedetail.FieldPromptTokens:
  33416. return m.PromptTokens()
  33417. case usagedetail.FieldCompletionTokens:
  33418. return m.CompletionTokens()
  33419. case usagedetail.FieldOrganizationID:
  33420. return m.OrganizationID()
  33421. }
  33422. return nil, false
  33423. }
  33424. // OldField returns the old value of the field from the database. An error is
  33425. // returned if the mutation operation is not UpdateOne, or the query to the
  33426. // database failed.
  33427. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33428. switch name {
  33429. case usagedetail.FieldCreatedAt:
  33430. return m.OldCreatedAt(ctx)
  33431. case usagedetail.FieldUpdatedAt:
  33432. return m.OldUpdatedAt(ctx)
  33433. case usagedetail.FieldStatus:
  33434. return m.OldStatus(ctx)
  33435. case usagedetail.FieldType:
  33436. return m.OldType(ctx)
  33437. case usagedetail.FieldBotID:
  33438. return m.OldBotID(ctx)
  33439. case usagedetail.FieldReceiverID:
  33440. return m.OldReceiverID(ctx)
  33441. case usagedetail.FieldApp:
  33442. return m.OldApp(ctx)
  33443. case usagedetail.FieldSessionID:
  33444. return m.OldSessionID(ctx)
  33445. case usagedetail.FieldRequest:
  33446. return m.OldRequest(ctx)
  33447. case usagedetail.FieldResponse:
  33448. return m.OldResponse(ctx)
  33449. case usagedetail.FieldOriginalData:
  33450. return m.OldOriginalData(ctx)
  33451. case usagedetail.FieldTotalTokens:
  33452. return m.OldTotalTokens(ctx)
  33453. case usagedetail.FieldPromptTokens:
  33454. return m.OldPromptTokens(ctx)
  33455. case usagedetail.FieldCompletionTokens:
  33456. return m.OldCompletionTokens(ctx)
  33457. case usagedetail.FieldOrganizationID:
  33458. return m.OldOrganizationID(ctx)
  33459. }
  33460. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  33461. }
  33462. // SetField sets the value of a field with the given name. It returns an error if
  33463. // the field is not defined in the schema, or if the type mismatched the field
  33464. // type.
  33465. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  33466. switch name {
  33467. case usagedetail.FieldCreatedAt:
  33468. v, ok := value.(time.Time)
  33469. if !ok {
  33470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33471. }
  33472. m.SetCreatedAt(v)
  33473. return nil
  33474. case usagedetail.FieldUpdatedAt:
  33475. v, ok := value.(time.Time)
  33476. if !ok {
  33477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33478. }
  33479. m.SetUpdatedAt(v)
  33480. return nil
  33481. case usagedetail.FieldStatus:
  33482. v, ok := value.(uint8)
  33483. if !ok {
  33484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33485. }
  33486. m.SetStatus(v)
  33487. return nil
  33488. case usagedetail.FieldType:
  33489. v, ok := value.(int)
  33490. if !ok {
  33491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33492. }
  33493. m.SetType(v)
  33494. return nil
  33495. case usagedetail.FieldBotID:
  33496. v, ok := value.(string)
  33497. if !ok {
  33498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33499. }
  33500. m.SetBotID(v)
  33501. return nil
  33502. case usagedetail.FieldReceiverID:
  33503. v, ok := value.(string)
  33504. if !ok {
  33505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33506. }
  33507. m.SetReceiverID(v)
  33508. return nil
  33509. case usagedetail.FieldApp:
  33510. v, ok := value.(int)
  33511. if !ok {
  33512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33513. }
  33514. m.SetApp(v)
  33515. return nil
  33516. case usagedetail.FieldSessionID:
  33517. v, ok := value.(uint64)
  33518. if !ok {
  33519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33520. }
  33521. m.SetSessionID(v)
  33522. return nil
  33523. case usagedetail.FieldRequest:
  33524. v, ok := value.(string)
  33525. if !ok {
  33526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33527. }
  33528. m.SetRequest(v)
  33529. return nil
  33530. case usagedetail.FieldResponse:
  33531. v, ok := value.(string)
  33532. if !ok {
  33533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33534. }
  33535. m.SetResponse(v)
  33536. return nil
  33537. case usagedetail.FieldOriginalData:
  33538. v, ok := value.(custom_types.OriginalData)
  33539. if !ok {
  33540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33541. }
  33542. m.SetOriginalData(v)
  33543. return nil
  33544. case usagedetail.FieldTotalTokens:
  33545. v, ok := value.(uint64)
  33546. if !ok {
  33547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33548. }
  33549. m.SetTotalTokens(v)
  33550. return nil
  33551. case usagedetail.FieldPromptTokens:
  33552. v, ok := value.(uint64)
  33553. if !ok {
  33554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33555. }
  33556. m.SetPromptTokens(v)
  33557. return nil
  33558. case usagedetail.FieldCompletionTokens:
  33559. v, ok := value.(uint64)
  33560. if !ok {
  33561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33562. }
  33563. m.SetCompletionTokens(v)
  33564. return nil
  33565. case usagedetail.FieldOrganizationID:
  33566. v, ok := value.(uint64)
  33567. if !ok {
  33568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33569. }
  33570. m.SetOrganizationID(v)
  33571. return nil
  33572. }
  33573. return fmt.Errorf("unknown UsageDetail field %s", name)
  33574. }
  33575. // AddedFields returns all numeric fields that were incremented/decremented during
  33576. // this mutation.
  33577. func (m *UsageDetailMutation) AddedFields() []string {
  33578. var fields []string
  33579. if m.addstatus != nil {
  33580. fields = append(fields, usagedetail.FieldStatus)
  33581. }
  33582. if m.add_type != nil {
  33583. fields = append(fields, usagedetail.FieldType)
  33584. }
  33585. if m.addapp != nil {
  33586. fields = append(fields, usagedetail.FieldApp)
  33587. }
  33588. if m.addsession_id != nil {
  33589. fields = append(fields, usagedetail.FieldSessionID)
  33590. }
  33591. if m.addtotal_tokens != nil {
  33592. fields = append(fields, usagedetail.FieldTotalTokens)
  33593. }
  33594. if m.addprompt_tokens != nil {
  33595. fields = append(fields, usagedetail.FieldPromptTokens)
  33596. }
  33597. if m.addcompletion_tokens != nil {
  33598. fields = append(fields, usagedetail.FieldCompletionTokens)
  33599. }
  33600. if m.addorganization_id != nil {
  33601. fields = append(fields, usagedetail.FieldOrganizationID)
  33602. }
  33603. return fields
  33604. }
  33605. // AddedField returns the numeric value that was incremented/decremented on a field
  33606. // with the given name. The second boolean return value indicates that this field
  33607. // was not set, or was not defined in the schema.
  33608. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  33609. switch name {
  33610. case usagedetail.FieldStatus:
  33611. return m.AddedStatus()
  33612. case usagedetail.FieldType:
  33613. return m.AddedType()
  33614. case usagedetail.FieldApp:
  33615. return m.AddedApp()
  33616. case usagedetail.FieldSessionID:
  33617. return m.AddedSessionID()
  33618. case usagedetail.FieldTotalTokens:
  33619. return m.AddedTotalTokens()
  33620. case usagedetail.FieldPromptTokens:
  33621. return m.AddedPromptTokens()
  33622. case usagedetail.FieldCompletionTokens:
  33623. return m.AddedCompletionTokens()
  33624. case usagedetail.FieldOrganizationID:
  33625. return m.AddedOrganizationID()
  33626. }
  33627. return nil, false
  33628. }
  33629. // AddField adds the value to the field with the given name. It returns an error if
  33630. // the field is not defined in the schema, or if the type mismatched the field
  33631. // type.
  33632. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  33633. switch name {
  33634. case usagedetail.FieldStatus:
  33635. v, ok := value.(int8)
  33636. if !ok {
  33637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33638. }
  33639. m.AddStatus(v)
  33640. return nil
  33641. case usagedetail.FieldType:
  33642. v, ok := value.(int)
  33643. if !ok {
  33644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33645. }
  33646. m.AddType(v)
  33647. return nil
  33648. case usagedetail.FieldApp:
  33649. v, ok := value.(int)
  33650. if !ok {
  33651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33652. }
  33653. m.AddApp(v)
  33654. return nil
  33655. case usagedetail.FieldSessionID:
  33656. v, ok := value.(int64)
  33657. if !ok {
  33658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33659. }
  33660. m.AddSessionID(v)
  33661. return nil
  33662. case usagedetail.FieldTotalTokens:
  33663. v, ok := value.(int64)
  33664. if !ok {
  33665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33666. }
  33667. m.AddTotalTokens(v)
  33668. return nil
  33669. case usagedetail.FieldPromptTokens:
  33670. v, ok := value.(int64)
  33671. if !ok {
  33672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33673. }
  33674. m.AddPromptTokens(v)
  33675. return nil
  33676. case usagedetail.FieldCompletionTokens:
  33677. v, ok := value.(int64)
  33678. if !ok {
  33679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33680. }
  33681. m.AddCompletionTokens(v)
  33682. return nil
  33683. case usagedetail.FieldOrganizationID:
  33684. v, ok := value.(int64)
  33685. if !ok {
  33686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33687. }
  33688. m.AddOrganizationID(v)
  33689. return nil
  33690. }
  33691. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  33692. }
  33693. // ClearedFields returns all nullable fields that were cleared during this
  33694. // mutation.
  33695. func (m *UsageDetailMutation) ClearedFields() []string {
  33696. var fields []string
  33697. if m.FieldCleared(usagedetail.FieldStatus) {
  33698. fields = append(fields, usagedetail.FieldStatus)
  33699. }
  33700. if m.FieldCleared(usagedetail.FieldType) {
  33701. fields = append(fields, usagedetail.FieldType)
  33702. }
  33703. if m.FieldCleared(usagedetail.FieldApp) {
  33704. fields = append(fields, usagedetail.FieldApp)
  33705. }
  33706. if m.FieldCleared(usagedetail.FieldSessionID) {
  33707. fields = append(fields, usagedetail.FieldSessionID)
  33708. }
  33709. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  33710. fields = append(fields, usagedetail.FieldTotalTokens)
  33711. }
  33712. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  33713. fields = append(fields, usagedetail.FieldPromptTokens)
  33714. }
  33715. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  33716. fields = append(fields, usagedetail.FieldCompletionTokens)
  33717. }
  33718. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  33719. fields = append(fields, usagedetail.FieldOrganizationID)
  33720. }
  33721. return fields
  33722. }
  33723. // FieldCleared returns a boolean indicating if a field with the given name was
  33724. // cleared in this mutation.
  33725. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  33726. _, ok := m.clearedFields[name]
  33727. return ok
  33728. }
  33729. // ClearField clears the value of the field with the given name. It returns an
  33730. // error if the field is not defined in the schema.
  33731. func (m *UsageDetailMutation) ClearField(name string) error {
  33732. switch name {
  33733. case usagedetail.FieldStatus:
  33734. m.ClearStatus()
  33735. return nil
  33736. case usagedetail.FieldType:
  33737. m.ClearType()
  33738. return nil
  33739. case usagedetail.FieldApp:
  33740. m.ClearApp()
  33741. return nil
  33742. case usagedetail.FieldSessionID:
  33743. m.ClearSessionID()
  33744. return nil
  33745. case usagedetail.FieldTotalTokens:
  33746. m.ClearTotalTokens()
  33747. return nil
  33748. case usagedetail.FieldPromptTokens:
  33749. m.ClearPromptTokens()
  33750. return nil
  33751. case usagedetail.FieldCompletionTokens:
  33752. m.ClearCompletionTokens()
  33753. return nil
  33754. case usagedetail.FieldOrganizationID:
  33755. m.ClearOrganizationID()
  33756. return nil
  33757. }
  33758. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  33759. }
  33760. // ResetField resets all changes in the mutation for the field with the given name.
  33761. // It returns an error if the field is not defined in the schema.
  33762. func (m *UsageDetailMutation) ResetField(name string) error {
  33763. switch name {
  33764. case usagedetail.FieldCreatedAt:
  33765. m.ResetCreatedAt()
  33766. return nil
  33767. case usagedetail.FieldUpdatedAt:
  33768. m.ResetUpdatedAt()
  33769. return nil
  33770. case usagedetail.FieldStatus:
  33771. m.ResetStatus()
  33772. return nil
  33773. case usagedetail.FieldType:
  33774. m.ResetType()
  33775. return nil
  33776. case usagedetail.FieldBotID:
  33777. m.ResetBotID()
  33778. return nil
  33779. case usagedetail.FieldReceiverID:
  33780. m.ResetReceiverID()
  33781. return nil
  33782. case usagedetail.FieldApp:
  33783. m.ResetApp()
  33784. return nil
  33785. case usagedetail.FieldSessionID:
  33786. m.ResetSessionID()
  33787. return nil
  33788. case usagedetail.FieldRequest:
  33789. m.ResetRequest()
  33790. return nil
  33791. case usagedetail.FieldResponse:
  33792. m.ResetResponse()
  33793. return nil
  33794. case usagedetail.FieldOriginalData:
  33795. m.ResetOriginalData()
  33796. return nil
  33797. case usagedetail.FieldTotalTokens:
  33798. m.ResetTotalTokens()
  33799. return nil
  33800. case usagedetail.FieldPromptTokens:
  33801. m.ResetPromptTokens()
  33802. return nil
  33803. case usagedetail.FieldCompletionTokens:
  33804. m.ResetCompletionTokens()
  33805. return nil
  33806. case usagedetail.FieldOrganizationID:
  33807. m.ResetOrganizationID()
  33808. return nil
  33809. }
  33810. return fmt.Errorf("unknown UsageDetail field %s", name)
  33811. }
  33812. // AddedEdges returns all edge names that were set/added in this mutation.
  33813. func (m *UsageDetailMutation) AddedEdges() []string {
  33814. edges := make([]string, 0, 0)
  33815. return edges
  33816. }
  33817. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33818. // name in this mutation.
  33819. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  33820. return nil
  33821. }
  33822. // RemovedEdges returns all edge names that were removed in this mutation.
  33823. func (m *UsageDetailMutation) RemovedEdges() []string {
  33824. edges := make([]string, 0, 0)
  33825. return edges
  33826. }
  33827. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33828. // the given name in this mutation.
  33829. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  33830. return nil
  33831. }
  33832. // ClearedEdges returns all edge names that were cleared in this mutation.
  33833. func (m *UsageDetailMutation) ClearedEdges() []string {
  33834. edges := make([]string, 0, 0)
  33835. return edges
  33836. }
  33837. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33838. // was cleared in this mutation.
  33839. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  33840. return false
  33841. }
  33842. // ClearEdge clears the value of the edge with the given name. It returns an error
  33843. // if that edge is not defined in the schema.
  33844. func (m *UsageDetailMutation) ClearEdge(name string) error {
  33845. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  33846. }
  33847. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33848. // It returns an error if the edge is not defined in the schema.
  33849. func (m *UsageDetailMutation) ResetEdge(name string) error {
  33850. return fmt.Errorf("unknown UsageDetail edge %s", name)
  33851. }
  33852. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  33853. type UsageStatisticDayMutation struct {
  33854. config
  33855. op Op
  33856. typ string
  33857. id *uint64
  33858. created_at *time.Time
  33859. updated_at *time.Time
  33860. status *uint8
  33861. addstatus *int8
  33862. deleted_at *time.Time
  33863. addtime *uint64
  33864. addaddtime *int64
  33865. _type *int
  33866. add_type *int
  33867. bot_id *string
  33868. organization_id *uint64
  33869. addorganization_id *int64
  33870. ai_response *uint64
  33871. addai_response *int64
  33872. sop_run *uint64
  33873. addsop_run *int64
  33874. total_friend *uint64
  33875. addtotal_friend *int64
  33876. total_group *uint64
  33877. addtotal_group *int64
  33878. account_balance *uint64
  33879. addaccount_balance *int64
  33880. consume_token *uint64
  33881. addconsume_token *int64
  33882. active_user *uint64
  33883. addactive_user *int64
  33884. new_user *int64
  33885. addnew_user *int64
  33886. label_dist *[]custom_types.LabelDist
  33887. appendlabel_dist []custom_types.LabelDist
  33888. clearedFields map[string]struct{}
  33889. done bool
  33890. oldValue func(context.Context) (*UsageStatisticDay, error)
  33891. predicates []predicate.UsageStatisticDay
  33892. }
  33893. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  33894. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  33895. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  33896. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  33897. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  33898. m := &UsageStatisticDayMutation{
  33899. config: c,
  33900. op: op,
  33901. typ: TypeUsageStatisticDay,
  33902. clearedFields: make(map[string]struct{}),
  33903. }
  33904. for _, opt := range opts {
  33905. opt(m)
  33906. }
  33907. return m
  33908. }
  33909. // withUsageStatisticDayID sets the ID field of the mutation.
  33910. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  33911. return func(m *UsageStatisticDayMutation) {
  33912. var (
  33913. err error
  33914. once sync.Once
  33915. value *UsageStatisticDay
  33916. )
  33917. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  33918. once.Do(func() {
  33919. if m.done {
  33920. err = errors.New("querying old values post mutation is not allowed")
  33921. } else {
  33922. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  33923. }
  33924. })
  33925. return value, err
  33926. }
  33927. m.id = &id
  33928. }
  33929. }
  33930. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  33931. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  33932. return func(m *UsageStatisticDayMutation) {
  33933. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  33934. return node, nil
  33935. }
  33936. m.id = &node.ID
  33937. }
  33938. }
  33939. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33940. // executed in a transaction (ent.Tx), a transactional client is returned.
  33941. func (m UsageStatisticDayMutation) Client() *Client {
  33942. client := &Client{config: m.config}
  33943. client.init()
  33944. return client
  33945. }
  33946. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33947. // it returns an error otherwise.
  33948. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  33949. if _, ok := m.driver.(*txDriver); !ok {
  33950. return nil, errors.New("ent: mutation is not running in a transaction")
  33951. }
  33952. tx := &Tx{config: m.config}
  33953. tx.init()
  33954. return tx, nil
  33955. }
  33956. // SetID sets the value of the id field. Note that this
  33957. // operation is only accepted on creation of UsageStatisticDay entities.
  33958. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  33959. m.id = &id
  33960. }
  33961. // ID returns the ID value in the mutation. Note that the ID is only available
  33962. // if it was provided to the builder or after it was returned from the database.
  33963. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  33964. if m.id == nil {
  33965. return
  33966. }
  33967. return *m.id, true
  33968. }
  33969. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33970. // That means, if the mutation is applied within a transaction with an isolation level such
  33971. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33972. // or updated by the mutation.
  33973. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  33974. switch {
  33975. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33976. id, exists := m.ID()
  33977. if exists {
  33978. return []uint64{id}, nil
  33979. }
  33980. fallthrough
  33981. case m.op.Is(OpUpdate | OpDelete):
  33982. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  33983. default:
  33984. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33985. }
  33986. }
  33987. // SetCreatedAt sets the "created_at" field.
  33988. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  33989. m.created_at = &t
  33990. }
  33991. // CreatedAt returns the value of the "created_at" field in the mutation.
  33992. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  33993. v := m.created_at
  33994. if v == nil {
  33995. return
  33996. }
  33997. return *v, true
  33998. }
  33999. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  34000. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34002. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34003. if !m.op.Is(OpUpdateOne) {
  34004. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34005. }
  34006. if m.id == nil || m.oldValue == nil {
  34007. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34008. }
  34009. oldValue, err := m.oldValue(ctx)
  34010. if err != nil {
  34011. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34012. }
  34013. return oldValue.CreatedAt, nil
  34014. }
  34015. // ResetCreatedAt resets all changes to the "created_at" field.
  34016. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  34017. m.created_at = nil
  34018. }
  34019. // SetUpdatedAt sets the "updated_at" field.
  34020. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  34021. m.updated_at = &t
  34022. }
  34023. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34024. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  34025. v := m.updated_at
  34026. if v == nil {
  34027. return
  34028. }
  34029. return *v, true
  34030. }
  34031. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  34032. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34034. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34035. if !m.op.Is(OpUpdateOne) {
  34036. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34037. }
  34038. if m.id == nil || m.oldValue == nil {
  34039. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34040. }
  34041. oldValue, err := m.oldValue(ctx)
  34042. if err != nil {
  34043. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34044. }
  34045. return oldValue.UpdatedAt, nil
  34046. }
  34047. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34048. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  34049. m.updated_at = nil
  34050. }
  34051. // SetStatus sets the "status" field.
  34052. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  34053. m.status = &u
  34054. m.addstatus = nil
  34055. }
  34056. // Status returns the value of the "status" field in the mutation.
  34057. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  34058. v := m.status
  34059. if v == nil {
  34060. return
  34061. }
  34062. return *v, true
  34063. }
  34064. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  34065. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34066. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34067. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34068. if !m.op.Is(OpUpdateOne) {
  34069. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34070. }
  34071. if m.id == nil || m.oldValue == nil {
  34072. return v, errors.New("OldStatus requires an ID field in the mutation")
  34073. }
  34074. oldValue, err := m.oldValue(ctx)
  34075. if err != nil {
  34076. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34077. }
  34078. return oldValue.Status, nil
  34079. }
  34080. // AddStatus adds u to the "status" field.
  34081. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  34082. if m.addstatus != nil {
  34083. *m.addstatus += u
  34084. } else {
  34085. m.addstatus = &u
  34086. }
  34087. }
  34088. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34089. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  34090. v := m.addstatus
  34091. if v == nil {
  34092. return
  34093. }
  34094. return *v, true
  34095. }
  34096. // ClearStatus clears the value of the "status" field.
  34097. func (m *UsageStatisticDayMutation) ClearStatus() {
  34098. m.status = nil
  34099. m.addstatus = nil
  34100. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  34101. }
  34102. // StatusCleared returns if the "status" field was cleared in this mutation.
  34103. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  34104. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  34105. return ok
  34106. }
  34107. // ResetStatus resets all changes to the "status" field.
  34108. func (m *UsageStatisticDayMutation) ResetStatus() {
  34109. m.status = nil
  34110. m.addstatus = nil
  34111. delete(m.clearedFields, usagestatisticday.FieldStatus)
  34112. }
  34113. // SetDeletedAt sets the "deleted_at" field.
  34114. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  34115. m.deleted_at = &t
  34116. }
  34117. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34118. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  34119. v := m.deleted_at
  34120. if v == nil {
  34121. return
  34122. }
  34123. return *v, true
  34124. }
  34125. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  34126. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34128. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34129. if !m.op.Is(OpUpdateOne) {
  34130. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34131. }
  34132. if m.id == nil || m.oldValue == nil {
  34133. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34134. }
  34135. oldValue, err := m.oldValue(ctx)
  34136. if err != nil {
  34137. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34138. }
  34139. return oldValue.DeletedAt, nil
  34140. }
  34141. // ClearDeletedAt clears the value of the "deleted_at" field.
  34142. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  34143. m.deleted_at = nil
  34144. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  34145. }
  34146. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34147. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  34148. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  34149. return ok
  34150. }
  34151. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34152. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  34153. m.deleted_at = nil
  34154. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  34155. }
  34156. // SetAddtime sets the "addtime" field.
  34157. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  34158. m.addtime = &u
  34159. m.addaddtime = nil
  34160. }
  34161. // Addtime returns the value of the "addtime" field in the mutation.
  34162. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  34163. v := m.addtime
  34164. if v == nil {
  34165. return
  34166. }
  34167. return *v, true
  34168. }
  34169. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  34170. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34172. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34173. if !m.op.Is(OpUpdateOne) {
  34174. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34175. }
  34176. if m.id == nil || m.oldValue == nil {
  34177. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34178. }
  34179. oldValue, err := m.oldValue(ctx)
  34180. if err != nil {
  34181. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34182. }
  34183. return oldValue.Addtime, nil
  34184. }
  34185. // AddAddtime adds u to the "addtime" field.
  34186. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  34187. if m.addaddtime != nil {
  34188. *m.addaddtime += u
  34189. } else {
  34190. m.addaddtime = &u
  34191. }
  34192. }
  34193. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34194. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  34195. v := m.addaddtime
  34196. if v == nil {
  34197. return
  34198. }
  34199. return *v, true
  34200. }
  34201. // ResetAddtime resets all changes to the "addtime" field.
  34202. func (m *UsageStatisticDayMutation) ResetAddtime() {
  34203. m.addtime = nil
  34204. m.addaddtime = nil
  34205. }
  34206. // SetType sets the "type" field.
  34207. func (m *UsageStatisticDayMutation) SetType(i int) {
  34208. m._type = &i
  34209. m.add_type = nil
  34210. }
  34211. // GetType returns the value of the "type" field in the mutation.
  34212. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  34213. v := m._type
  34214. if v == nil {
  34215. return
  34216. }
  34217. return *v, true
  34218. }
  34219. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  34220. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34222. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  34223. if !m.op.Is(OpUpdateOne) {
  34224. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34225. }
  34226. if m.id == nil || m.oldValue == nil {
  34227. return v, errors.New("OldType requires an ID field in the mutation")
  34228. }
  34229. oldValue, err := m.oldValue(ctx)
  34230. if err != nil {
  34231. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34232. }
  34233. return oldValue.Type, nil
  34234. }
  34235. // AddType adds i to the "type" field.
  34236. func (m *UsageStatisticDayMutation) AddType(i int) {
  34237. if m.add_type != nil {
  34238. *m.add_type += i
  34239. } else {
  34240. m.add_type = &i
  34241. }
  34242. }
  34243. // AddedType returns the value that was added to the "type" field in this mutation.
  34244. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  34245. v := m.add_type
  34246. if v == nil {
  34247. return
  34248. }
  34249. return *v, true
  34250. }
  34251. // ResetType resets all changes to the "type" field.
  34252. func (m *UsageStatisticDayMutation) ResetType() {
  34253. m._type = nil
  34254. m.add_type = nil
  34255. }
  34256. // SetBotID sets the "bot_id" field.
  34257. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  34258. m.bot_id = &s
  34259. }
  34260. // BotID returns the value of the "bot_id" field in the mutation.
  34261. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  34262. v := m.bot_id
  34263. if v == nil {
  34264. return
  34265. }
  34266. return *v, true
  34267. }
  34268. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  34269. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34271. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  34272. if !m.op.Is(OpUpdateOne) {
  34273. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34274. }
  34275. if m.id == nil || m.oldValue == nil {
  34276. return v, errors.New("OldBotID requires an ID field in the mutation")
  34277. }
  34278. oldValue, err := m.oldValue(ctx)
  34279. if err != nil {
  34280. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34281. }
  34282. return oldValue.BotID, nil
  34283. }
  34284. // ClearBotID clears the value of the "bot_id" field.
  34285. func (m *UsageStatisticDayMutation) ClearBotID() {
  34286. m.bot_id = nil
  34287. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  34288. }
  34289. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34290. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  34291. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  34292. return ok
  34293. }
  34294. // ResetBotID resets all changes to the "bot_id" field.
  34295. func (m *UsageStatisticDayMutation) ResetBotID() {
  34296. m.bot_id = nil
  34297. delete(m.clearedFields, usagestatisticday.FieldBotID)
  34298. }
  34299. // SetOrganizationID sets the "organization_id" field.
  34300. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  34301. m.organization_id = &u
  34302. m.addorganization_id = nil
  34303. }
  34304. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34305. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  34306. v := m.organization_id
  34307. if v == nil {
  34308. return
  34309. }
  34310. return *v, true
  34311. }
  34312. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  34313. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34315. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34316. if !m.op.Is(OpUpdateOne) {
  34317. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34318. }
  34319. if m.id == nil || m.oldValue == nil {
  34320. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34321. }
  34322. oldValue, err := m.oldValue(ctx)
  34323. if err != nil {
  34324. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34325. }
  34326. return oldValue.OrganizationID, nil
  34327. }
  34328. // AddOrganizationID adds u to the "organization_id" field.
  34329. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  34330. if m.addorganization_id != nil {
  34331. *m.addorganization_id += u
  34332. } else {
  34333. m.addorganization_id = &u
  34334. }
  34335. }
  34336. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34337. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  34338. v := m.addorganization_id
  34339. if v == nil {
  34340. return
  34341. }
  34342. return *v, true
  34343. }
  34344. // ClearOrganizationID clears the value of the "organization_id" field.
  34345. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  34346. m.organization_id = nil
  34347. m.addorganization_id = nil
  34348. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  34349. }
  34350. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34351. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  34352. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  34353. return ok
  34354. }
  34355. // ResetOrganizationID resets all changes to the "organization_id" field.
  34356. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  34357. m.organization_id = nil
  34358. m.addorganization_id = nil
  34359. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  34360. }
  34361. // SetAiResponse sets the "ai_response" field.
  34362. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  34363. m.ai_response = &u
  34364. m.addai_response = nil
  34365. }
  34366. // AiResponse returns the value of the "ai_response" field in the mutation.
  34367. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  34368. v := m.ai_response
  34369. if v == nil {
  34370. return
  34371. }
  34372. return *v, true
  34373. }
  34374. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  34375. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34377. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34378. if !m.op.Is(OpUpdateOne) {
  34379. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34380. }
  34381. if m.id == nil || m.oldValue == nil {
  34382. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34383. }
  34384. oldValue, err := m.oldValue(ctx)
  34385. if err != nil {
  34386. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34387. }
  34388. return oldValue.AiResponse, nil
  34389. }
  34390. // AddAiResponse adds u to the "ai_response" field.
  34391. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  34392. if m.addai_response != nil {
  34393. *m.addai_response += u
  34394. } else {
  34395. m.addai_response = &u
  34396. }
  34397. }
  34398. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34399. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  34400. v := m.addai_response
  34401. if v == nil {
  34402. return
  34403. }
  34404. return *v, true
  34405. }
  34406. // ResetAiResponse resets all changes to the "ai_response" field.
  34407. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  34408. m.ai_response = nil
  34409. m.addai_response = nil
  34410. }
  34411. // SetSopRun sets the "sop_run" field.
  34412. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  34413. m.sop_run = &u
  34414. m.addsop_run = nil
  34415. }
  34416. // SopRun returns the value of the "sop_run" field in the mutation.
  34417. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  34418. v := m.sop_run
  34419. if v == nil {
  34420. return
  34421. }
  34422. return *v, true
  34423. }
  34424. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  34425. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34427. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34428. if !m.op.Is(OpUpdateOne) {
  34429. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34430. }
  34431. if m.id == nil || m.oldValue == nil {
  34432. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34433. }
  34434. oldValue, err := m.oldValue(ctx)
  34435. if err != nil {
  34436. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34437. }
  34438. return oldValue.SopRun, nil
  34439. }
  34440. // AddSopRun adds u to the "sop_run" field.
  34441. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  34442. if m.addsop_run != nil {
  34443. *m.addsop_run += u
  34444. } else {
  34445. m.addsop_run = &u
  34446. }
  34447. }
  34448. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34449. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  34450. v := m.addsop_run
  34451. if v == nil {
  34452. return
  34453. }
  34454. return *v, true
  34455. }
  34456. // ResetSopRun resets all changes to the "sop_run" field.
  34457. func (m *UsageStatisticDayMutation) ResetSopRun() {
  34458. m.sop_run = nil
  34459. m.addsop_run = nil
  34460. }
  34461. // SetTotalFriend sets the "total_friend" field.
  34462. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  34463. m.total_friend = &u
  34464. m.addtotal_friend = nil
  34465. }
  34466. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34467. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  34468. v := m.total_friend
  34469. if v == nil {
  34470. return
  34471. }
  34472. return *v, true
  34473. }
  34474. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  34475. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34477. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34478. if !m.op.Is(OpUpdateOne) {
  34479. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34480. }
  34481. if m.id == nil || m.oldValue == nil {
  34482. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34483. }
  34484. oldValue, err := m.oldValue(ctx)
  34485. if err != nil {
  34486. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34487. }
  34488. return oldValue.TotalFriend, nil
  34489. }
  34490. // AddTotalFriend adds u to the "total_friend" field.
  34491. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  34492. if m.addtotal_friend != nil {
  34493. *m.addtotal_friend += u
  34494. } else {
  34495. m.addtotal_friend = &u
  34496. }
  34497. }
  34498. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34499. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  34500. v := m.addtotal_friend
  34501. if v == nil {
  34502. return
  34503. }
  34504. return *v, true
  34505. }
  34506. // ResetTotalFriend resets all changes to the "total_friend" field.
  34507. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  34508. m.total_friend = nil
  34509. m.addtotal_friend = nil
  34510. }
  34511. // SetTotalGroup sets the "total_group" field.
  34512. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  34513. m.total_group = &u
  34514. m.addtotal_group = nil
  34515. }
  34516. // TotalGroup returns the value of the "total_group" field in the mutation.
  34517. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  34518. v := m.total_group
  34519. if v == nil {
  34520. return
  34521. }
  34522. return *v, true
  34523. }
  34524. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  34525. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34527. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34528. if !m.op.Is(OpUpdateOne) {
  34529. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34530. }
  34531. if m.id == nil || m.oldValue == nil {
  34532. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34533. }
  34534. oldValue, err := m.oldValue(ctx)
  34535. if err != nil {
  34536. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34537. }
  34538. return oldValue.TotalGroup, nil
  34539. }
  34540. // AddTotalGroup adds u to the "total_group" field.
  34541. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  34542. if m.addtotal_group != nil {
  34543. *m.addtotal_group += u
  34544. } else {
  34545. m.addtotal_group = &u
  34546. }
  34547. }
  34548. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34549. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  34550. v := m.addtotal_group
  34551. if v == nil {
  34552. return
  34553. }
  34554. return *v, true
  34555. }
  34556. // ResetTotalGroup resets all changes to the "total_group" field.
  34557. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  34558. m.total_group = nil
  34559. m.addtotal_group = nil
  34560. }
  34561. // SetAccountBalance sets the "account_balance" field.
  34562. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  34563. m.account_balance = &u
  34564. m.addaccount_balance = nil
  34565. }
  34566. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34567. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  34568. v := m.account_balance
  34569. if v == nil {
  34570. return
  34571. }
  34572. return *v, true
  34573. }
  34574. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  34575. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34577. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34578. if !m.op.Is(OpUpdateOne) {
  34579. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34580. }
  34581. if m.id == nil || m.oldValue == nil {
  34582. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34583. }
  34584. oldValue, err := m.oldValue(ctx)
  34585. if err != nil {
  34586. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34587. }
  34588. return oldValue.AccountBalance, nil
  34589. }
  34590. // AddAccountBalance adds u to the "account_balance" field.
  34591. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  34592. if m.addaccount_balance != nil {
  34593. *m.addaccount_balance += u
  34594. } else {
  34595. m.addaccount_balance = &u
  34596. }
  34597. }
  34598. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34599. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  34600. v := m.addaccount_balance
  34601. if v == nil {
  34602. return
  34603. }
  34604. return *v, true
  34605. }
  34606. // ResetAccountBalance resets all changes to the "account_balance" field.
  34607. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  34608. m.account_balance = nil
  34609. m.addaccount_balance = nil
  34610. }
  34611. // SetConsumeToken sets the "consume_token" field.
  34612. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  34613. m.consume_token = &u
  34614. m.addconsume_token = nil
  34615. }
  34616. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34617. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  34618. v := m.consume_token
  34619. if v == nil {
  34620. return
  34621. }
  34622. return *v, true
  34623. }
  34624. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  34625. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34627. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34628. if !m.op.Is(OpUpdateOne) {
  34629. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34630. }
  34631. if m.id == nil || m.oldValue == nil {
  34632. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34633. }
  34634. oldValue, err := m.oldValue(ctx)
  34635. if err != nil {
  34636. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34637. }
  34638. return oldValue.ConsumeToken, nil
  34639. }
  34640. // AddConsumeToken adds u to the "consume_token" field.
  34641. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  34642. if m.addconsume_token != nil {
  34643. *m.addconsume_token += u
  34644. } else {
  34645. m.addconsume_token = &u
  34646. }
  34647. }
  34648. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34649. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  34650. v := m.addconsume_token
  34651. if v == nil {
  34652. return
  34653. }
  34654. return *v, true
  34655. }
  34656. // ResetConsumeToken resets all changes to the "consume_token" field.
  34657. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  34658. m.consume_token = nil
  34659. m.addconsume_token = nil
  34660. }
  34661. // SetActiveUser sets the "active_user" field.
  34662. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  34663. m.active_user = &u
  34664. m.addactive_user = nil
  34665. }
  34666. // ActiveUser returns the value of the "active_user" field in the mutation.
  34667. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  34668. v := m.active_user
  34669. if v == nil {
  34670. return
  34671. }
  34672. return *v, true
  34673. }
  34674. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  34675. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34677. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34678. if !m.op.Is(OpUpdateOne) {
  34679. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34680. }
  34681. if m.id == nil || m.oldValue == nil {
  34682. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34683. }
  34684. oldValue, err := m.oldValue(ctx)
  34685. if err != nil {
  34686. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34687. }
  34688. return oldValue.ActiveUser, nil
  34689. }
  34690. // AddActiveUser adds u to the "active_user" field.
  34691. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  34692. if m.addactive_user != nil {
  34693. *m.addactive_user += u
  34694. } else {
  34695. m.addactive_user = &u
  34696. }
  34697. }
  34698. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34699. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  34700. v := m.addactive_user
  34701. if v == nil {
  34702. return
  34703. }
  34704. return *v, true
  34705. }
  34706. // ResetActiveUser resets all changes to the "active_user" field.
  34707. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  34708. m.active_user = nil
  34709. m.addactive_user = nil
  34710. }
  34711. // SetNewUser sets the "new_user" field.
  34712. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  34713. m.new_user = &i
  34714. m.addnew_user = nil
  34715. }
  34716. // NewUser returns the value of the "new_user" field in the mutation.
  34717. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  34718. v := m.new_user
  34719. if v == nil {
  34720. return
  34721. }
  34722. return *v, true
  34723. }
  34724. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  34725. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34727. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34728. if !m.op.Is(OpUpdateOne) {
  34729. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34730. }
  34731. if m.id == nil || m.oldValue == nil {
  34732. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34733. }
  34734. oldValue, err := m.oldValue(ctx)
  34735. if err != nil {
  34736. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34737. }
  34738. return oldValue.NewUser, nil
  34739. }
  34740. // AddNewUser adds i to the "new_user" field.
  34741. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  34742. if m.addnew_user != nil {
  34743. *m.addnew_user += i
  34744. } else {
  34745. m.addnew_user = &i
  34746. }
  34747. }
  34748. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34749. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  34750. v := m.addnew_user
  34751. if v == nil {
  34752. return
  34753. }
  34754. return *v, true
  34755. }
  34756. // ResetNewUser resets all changes to the "new_user" field.
  34757. func (m *UsageStatisticDayMutation) ResetNewUser() {
  34758. m.new_user = nil
  34759. m.addnew_user = nil
  34760. }
  34761. // SetLabelDist sets the "label_dist" field.
  34762. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34763. m.label_dist = &ctd
  34764. m.appendlabel_dist = nil
  34765. }
  34766. // LabelDist returns the value of the "label_dist" field in the mutation.
  34767. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34768. v := m.label_dist
  34769. if v == nil {
  34770. return
  34771. }
  34772. return *v, true
  34773. }
  34774. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  34775. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  34776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34777. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34778. if !m.op.Is(OpUpdateOne) {
  34779. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34780. }
  34781. if m.id == nil || m.oldValue == nil {
  34782. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34783. }
  34784. oldValue, err := m.oldValue(ctx)
  34785. if err != nil {
  34786. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34787. }
  34788. return oldValue.LabelDist, nil
  34789. }
  34790. // AppendLabelDist adds ctd to the "label_dist" field.
  34791. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34792. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34793. }
  34794. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34795. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34796. if len(m.appendlabel_dist) == 0 {
  34797. return nil, false
  34798. }
  34799. return m.appendlabel_dist, true
  34800. }
  34801. // ResetLabelDist resets all changes to the "label_dist" field.
  34802. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  34803. m.label_dist = nil
  34804. m.appendlabel_dist = nil
  34805. }
  34806. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  34807. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  34808. m.predicates = append(m.predicates, ps...)
  34809. }
  34810. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  34811. // users can use type-assertion to append predicates that do not depend on any generated package.
  34812. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  34813. p := make([]predicate.UsageStatisticDay, len(ps))
  34814. for i := range ps {
  34815. p[i] = ps[i]
  34816. }
  34817. m.Where(p...)
  34818. }
  34819. // Op returns the operation name.
  34820. func (m *UsageStatisticDayMutation) Op() Op {
  34821. return m.op
  34822. }
  34823. // SetOp allows setting the mutation operation.
  34824. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  34825. m.op = op
  34826. }
  34827. // Type returns the node type of this mutation (UsageStatisticDay).
  34828. func (m *UsageStatisticDayMutation) Type() string {
  34829. return m.typ
  34830. }
  34831. // Fields returns all fields that were changed during this mutation. Note that in
  34832. // order to get all numeric fields that were incremented/decremented, call
  34833. // AddedFields().
  34834. func (m *UsageStatisticDayMutation) Fields() []string {
  34835. fields := make([]string, 0, 17)
  34836. if m.created_at != nil {
  34837. fields = append(fields, usagestatisticday.FieldCreatedAt)
  34838. }
  34839. if m.updated_at != nil {
  34840. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  34841. }
  34842. if m.status != nil {
  34843. fields = append(fields, usagestatisticday.FieldStatus)
  34844. }
  34845. if m.deleted_at != nil {
  34846. fields = append(fields, usagestatisticday.FieldDeletedAt)
  34847. }
  34848. if m.addtime != nil {
  34849. fields = append(fields, usagestatisticday.FieldAddtime)
  34850. }
  34851. if m._type != nil {
  34852. fields = append(fields, usagestatisticday.FieldType)
  34853. }
  34854. if m.bot_id != nil {
  34855. fields = append(fields, usagestatisticday.FieldBotID)
  34856. }
  34857. if m.organization_id != nil {
  34858. fields = append(fields, usagestatisticday.FieldOrganizationID)
  34859. }
  34860. if m.ai_response != nil {
  34861. fields = append(fields, usagestatisticday.FieldAiResponse)
  34862. }
  34863. if m.sop_run != nil {
  34864. fields = append(fields, usagestatisticday.FieldSopRun)
  34865. }
  34866. if m.total_friend != nil {
  34867. fields = append(fields, usagestatisticday.FieldTotalFriend)
  34868. }
  34869. if m.total_group != nil {
  34870. fields = append(fields, usagestatisticday.FieldTotalGroup)
  34871. }
  34872. if m.account_balance != nil {
  34873. fields = append(fields, usagestatisticday.FieldAccountBalance)
  34874. }
  34875. if m.consume_token != nil {
  34876. fields = append(fields, usagestatisticday.FieldConsumeToken)
  34877. }
  34878. if m.active_user != nil {
  34879. fields = append(fields, usagestatisticday.FieldActiveUser)
  34880. }
  34881. if m.new_user != nil {
  34882. fields = append(fields, usagestatisticday.FieldNewUser)
  34883. }
  34884. if m.label_dist != nil {
  34885. fields = append(fields, usagestatisticday.FieldLabelDist)
  34886. }
  34887. return fields
  34888. }
  34889. // Field returns the value of a field with the given name. The second boolean
  34890. // return value indicates that this field was not set, or was not defined in the
  34891. // schema.
  34892. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  34893. switch name {
  34894. case usagestatisticday.FieldCreatedAt:
  34895. return m.CreatedAt()
  34896. case usagestatisticday.FieldUpdatedAt:
  34897. return m.UpdatedAt()
  34898. case usagestatisticday.FieldStatus:
  34899. return m.Status()
  34900. case usagestatisticday.FieldDeletedAt:
  34901. return m.DeletedAt()
  34902. case usagestatisticday.FieldAddtime:
  34903. return m.Addtime()
  34904. case usagestatisticday.FieldType:
  34905. return m.GetType()
  34906. case usagestatisticday.FieldBotID:
  34907. return m.BotID()
  34908. case usagestatisticday.FieldOrganizationID:
  34909. return m.OrganizationID()
  34910. case usagestatisticday.FieldAiResponse:
  34911. return m.AiResponse()
  34912. case usagestatisticday.FieldSopRun:
  34913. return m.SopRun()
  34914. case usagestatisticday.FieldTotalFriend:
  34915. return m.TotalFriend()
  34916. case usagestatisticday.FieldTotalGroup:
  34917. return m.TotalGroup()
  34918. case usagestatisticday.FieldAccountBalance:
  34919. return m.AccountBalance()
  34920. case usagestatisticday.FieldConsumeToken:
  34921. return m.ConsumeToken()
  34922. case usagestatisticday.FieldActiveUser:
  34923. return m.ActiveUser()
  34924. case usagestatisticday.FieldNewUser:
  34925. return m.NewUser()
  34926. case usagestatisticday.FieldLabelDist:
  34927. return m.LabelDist()
  34928. }
  34929. return nil, false
  34930. }
  34931. // OldField returns the old value of the field from the database. An error is
  34932. // returned if the mutation operation is not UpdateOne, or the query to the
  34933. // database failed.
  34934. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34935. switch name {
  34936. case usagestatisticday.FieldCreatedAt:
  34937. return m.OldCreatedAt(ctx)
  34938. case usagestatisticday.FieldUpdatedAt:
  34939. return m.OldUpdatedAt(ctx)
  34940. case usagestatisticday.FieldStatus:
  34941. return m.OldStatus(ctx)
  34942. case usagestatisticday.FieldDeletedAt:
  34943. return m.OldDeletedAt(ctx)
  34944. case usagestatisticday.FieldAddtime:
  34945. return m.OldAddtime(ctx)
  34946. case usagestatisticday.FieldType:
  34947. return m.OldType(ctx)
  34948. case usagestatisticday.FieldBotID:
  34949. return m.OldBotID(ctx)
  34950. case usagestatisticday.FieldOrganizationID:
  34951. return m.OldOrganizationID(ctx)
  34952. case usagestatisticday.FieldAiResponse:
  34953. return m.OldAiResponse(ctx)
  34954. case usagestatisticday.FieldSopRun:
  34955. return m.OldSopRun(ctx)
  34956. case usagestatisticday.FieldTotalFriend:
  34957. return m.OldTotalFriend(ctx)
  34958. case usagestatisticday.FieldTotalGroup:
  34959. return m.OldTotalGroup(ctx)
  34960. case usagestatisticday.FieldAccountBalance:
  34961. return m.OldAccountBalance(ctx)
  34962. case usagestatisticday.FieldConsumeToken:
  34963. return m.OldConsumeToken(ctx)
  34964. case usagestatisticday.FieldActiveUser:
  34965. return m.OldActiveUser(ctx)
  34966. case usagestatisticday.FieldNewUser:
  34967. return m.OldNewUser(ctx)
  34968. case usagestatisticday.FieldLabelDist:
  34969. return m.OldLabelDist(ctx)
  34970. }
  34971. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  34972. }
  34973. // SetField sets the value of a field with the given name. It returns an error if
  34974. // the field is not defined in the schema, or if the type mismatched the field
  34975. // type.
  34976. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  34977. switch name {
  34978. case usagestatisticday.FieldCreatedAt:
  34979. v, ok := value.(time.Time)
  34980. if !ok {
  34981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34982. }
  34983. m.SetCreatedAt(v)
  34984. return nil
  34985. case usagestatisticday.FieldUpdatedAt:
  34986. v, ok := value.(time.Time)
  34987. if !ok {
  34988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34989. }
  34990. m.SetUpdatedAt(v)
  34991. return nil
  34992. case usagestatisticday.FieldStatus:
  34993. v, ok := value.(uint8)
  34994. if !ok {
  34995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34996. }
  34997. m.SetStatus(v)
  34998. return nil
  34999. case usagestatisticday.FieldDeletedAt:
  35000. v, ok := value.(time.Time)
  35001. if !ok {
  35002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35003. }
  35004. m.SetDeletedAt(v)
  35005. return nil
  35006. case usagestatisticday.FieldAddtime:
  35007. v, ok := value.(uint64)
  35008. if !ok {
  35009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35010. }
  35011. m.SetAddtime(v)
  35012. return nil
  35013. case usagestatisticday.FieldType:
  35014. v, ok := value.(int)
  35015. if !ok {
  35016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35017. }
  35018. m.SetType(v)
  35019. return nil
  35020. case usagestatisticday.FieldBotID:
  35021. v, ok := value.(string)
  35022. if !ok {
  35023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35024. }
  35025. m.SetBotID(v)
  35026. return nil
  35027. case usagestatisticday.FieldOrganizationID:
  35028. v, ok := value.(uint64)
  35029. if !ok {
  35030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35031. }
  35032. m.SetOrganizationID(v)
  35033. return nil
  35034. case usagestatisticday.FieldAiResponse:
  35035. v, ok := value.(uint64)
  35036. if !ok {
  35037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35038. }
  35039. m.SetAiResponse(v)
  35040. return nil
  35041. case usagestatisticday.FieldSopRun:
  35042. v, ok := value.(uint64)
  35043. if !ok {
  35044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35045. }
  35046. m.SetSopRun(v)
  35047. return nil
  35048. case usagestatisticday.FieldTotalFriend:
  35049. v, ok := value.(uint64)
  35050. if !ok {
  35051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35052. }
  35053. m.SetTotalFriend(v)
  35054. return nil
  35055. case usagestatisticday.FieldTotalGroup:
  35056. v, ok := value.(uint64)
  35057. if !ok {
  35058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35059. }
  35060. m.SetTotalGroup(v)
  35061. return nil
  35062. case usagestatisticday.FieldAccountBalance:
  35063. v, ok := value.(uint64)
  35064. if !ok {
  35065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35066. }
  35067. m.SetAccountBalance(v)
  35068. return nil
  35069. case usagestatisticday.FieldConsumeToken:
  35070. v, ok := value.(uint64)
  35071. if !ok {
  35072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35073. }
  35074. m.SetConsumeToken(v)
  35075. return nil
  35076. case usagestatisticday.FieldActiveUser:
  35077. v, ok := value.(uint64)
  35078. if !ok {
  35079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35080. }
  35081. m.SetActiveUser(v)
  35082. return nil
  35083. case usagestatisticday.FieldNewUser:
  35084. v, ok := value.(int64)
  35085. if !ok {
  35086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35087. }
  35088. m.SetNewUser(v)
  35089. return nil
  35090. case usagestatisticday.FieldLabelDist:
  35091. v, ok := value.([]custom_types.LabelDist)
  35092. if !ok {
  35093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35094. }
  35095. m.SetLabelDist(v)
  35096. return nil
  35097. }
  35098. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35099. }
  35100. // AddedFields returns all numeric fields that were incremented/decremented during
  35101. // this mutation.
  35102. func (m *UsageStatisticDayMutation) AddedFields() []string {
  35103. var fields []string
  35104. if m.addstatus != nil {
  35105. fields = append(fields, usagestatisticday.FieldStatus)
  35106. }
  35107. if m.addaddtime != nil {
  35108. fields = append(fields, usagestatisticday.FieldAddtime)
  35109. }
  35110. if m.add_type != nil {
  35111. fields = append(fields, usagestatisticday.FieldType)
  35112. }
  35113. if m.addorganization_id != nil {
  35114. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35115. }
  35116. if m.addai_response != nil {
  35117. fields = append(fields, usagestatisticday.FieldAiResponse)
  35118. }
  35119. if m.addsop_run != nil {
  35120. fields = append(fields, usagestatisticday.FieldSopRun)
  35121. }
  35122. if m.addtotal_friend != nil {
  35123. fields = append(fields, usagestatisticday.FieldTotalFriend)
  35124. }
  35125. if m.addtotal_group != nil {
  35126. fields = append(fields, usagestatisticday.FieldTotalGroup)
  35127. }
  35128. if m.addaccount_balance != nil {
  35129. fields = append(fields, usagestatisticday.FieldAccountBalance)
  35130. }
  35131. if m.addconsume_token != nil {
  35132. fields = append(fields, usagestatisticday.FieldConsumeToken)
  35133. }
  35134. if m.addactive_user != nil {
  35135. fields = append(fields, usagestatisticday.FieldActiveUser)
  35136. }
  35137. if m.addnew_user != nil {
  35138. fields = append(fields, usagestatisticday.FieldNewUser)
  35139. }
  35140. return fields
  35141. }
  35142. // AddedField returns the numeric value that was incremented/decremented on a field
  35143. // with the given name. The second boolean return value indicates that this field
  35144. // was not set, or was not defined in the schema.
  35145. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  35146. switch name {
  35147. case usagestatisticday.FieldStatus:
  35148. return m.AddedStatus()
  35149. case usagestatisticday.FieldAddtime:
  35150. return m.AddedAddtime()
  35151. case usagestatisticday.FieldType:
  35152. return m.AddedType()
  35153. case usagestatisticday.FieldOrganizationID:
  35154. return m.AddedOrganizationID()
  35155. case usagestatisticday.FieldAiResponse:
  35156. return m.AddedAiResponse()
  35157. case usagestatisticday.FieldSopRun:
  35158. return m.AddedSopRun()
  35159. case usagestatisticday.FieldTotalFriend:
  35160. return m.AddedTotalFriend()
  35161. case usagestatisticday.FieldTotalGroup:
  35162. return m.AddedTotalGroup()
  35163. case usagestatisticday.FieldAccountBalance:
  35164. return m.AddedAccountBalance()
  35165. case usagestatisticday.FieldConsumeToken:
  35166. return m.AddedConsumeToken()
  35167. case usagestatisticday.FieldActiveUser:
  35168. return m.AddedActiveUser()
  35169. case usagestatisticday.FieldNewUser:
  35170. return m.AddedNewUser()
  35171. }
  35172. return nil, false
  35173. }
  35174. // AddField adds the value to the field with the given name. It returns an error if
  35175. // the field is not defined in the schema, or if the type mismatched the field
  35176. // type.
  35177. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  35178. switch name {
  35179. case usagestatisticday.FieldStatus:
  35180. v, ok := value.(int8)
  35181. if !ok {
  35182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35183. }
  35184. m.AddStatus(v)
  35185. return nil
  35186. case usagestatisticday.FieldAddtime:
  35187. v, ok := value.(int64)
  35188. if !ok {
  35189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35190. }
  35191. m.AddAddtime(v)
  35192. return nil
  35193. case usagestatisticday.FieldType:
  35194. v, ok := value.(int)
  35195. if !ok {
  35196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35197. }
  35198. m.AddType(v)
  35199. return nil
  35200. case usagestatisticday.FieldOrganizationID:
  35201. v, ok := value.(int64)
  35202. if !ok {
  35203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35204. }
  35205. m.AddOrganizationID(v)
  35206. return nil
  35207. case usagestatisticday.FieldAiResponse:
  35208. v, ok := value.(int64)
  35209. if !ok {
  35210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35211. }
  35212. m.AddAiResponse(v)
  35213. return nil
  35214. case usagestatisticday.FieldSopRun:
  35215. v, ok := value.(int64)
  35216. if !ok {
  35217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35218. }
  35219. m.AddSopRun(v)
  35220. return nil
  35221. case usagestatisticday.FieldTotalFriend:
  35222. v, ok := value.(int64)
  35223. if !ok {
  35224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35225. }
  35226. m.AddTotalFriend(v)
  35227. return nil
  35228. case usagestatisticday.FieldTotalGroup:
  35229. v, ok := value.(int64)
  35230. if !ok {
  35231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35232. }
  35233. m.AddTotalGroup(v)
  35234. return nil
  35235. case usagestatisticday.FieldAccountBalance:
  35236. v, ok := value.(int64)
  35237. if !ok {
  35238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35239. }
  35240. m.AddAccountBalance(v)
  35241. return nil
  35242. case usagestatisticday.FieldConsumeToken:
  35243. v, ok := value.(int64)
  35244. if !ok {
  35245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35246. }
  35247. m.AddConsumeToken(v)
  35248. return nil
  35249. case usagestatisticday.FieldActiveUser:
  35250. v, ok := value.(int64)
  35251. if !ok {
  35252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35253. }
  35254. m.AddActiveUser(v)
  35255. return nil
  35256. case usagestatisticday.FieldNewUser:
  35257. v, ok := value.(int64)
  35258. if !ok {
  35259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35260. }
  35261. m.AddNewUser(v)
  35262. return nil
  35263. }
  35264. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  35265. }
  35266. // ClearedFields returns all nullable fields that were cleared during this
  35267. // mutation.
  35268. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  35269. var fields []string
  35270. if m.FieldCleared(usagestatisticday.FieldStatus) {
  35271. fields = append(fields, usagestatisticday.FieldStatus)
  35272. }
  35273. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  35274. fields = append(fields, usagestatisticday.FieldDeletedAt)
  35275. }
  35276. if m.FieldCleared(usagestatisticday.FieldBotID) {
  35277. fields = append(fields, usagestatisticday.FieldBotID)
  35278. }
  35279. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  35280. fields = append(fields, usagestatisticday.FieldOrganizationID)
  35281. }
  35282. return fields
  35283. }
  35284. // FieldCleared returns a boolean indicating if a field with the given name was
  35285. // cleared in this mutation.
  35286. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  35287. _, ok := m.clearedFields[name]
  35288. return ok
  35289. }
  35290. // ClearField clears the value of the field with the given name. It returns an
  35291. // error if the field is not defined in the schema.
  35292. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  35293. switch name {
  35294. case usagestatisticday.FieldStatus:
  35295. m.ClearStatus()
  35296. return nil
  35297. case usagestatisticday.FieldDeletedAt:
  35298. m.ClearDeletedAt()
  35299. return nil
  35300. case usagestatisticday.FieldBotID:
  35301. m.ClearBotID()
  35302. return nil
  35303. case usagestatisticday.FieldOrganizationID:
  35304. m.ClearOrganizationID()
  35305. return nil
  35306. }
  35307. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  35308. }
  35309. // ResetField resets all changes in the mutation for the field with the given name.
  35310. // It returns an error if the field is not defined in the schema.
  35311. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  35312. switch name {
  35313. case usagestatisticday.FieldCreatedAt:
  35314. m.ResetCreatedAt()
  35315. return nil
  35316. case usagestatisticday.FieldUpdatedAt:
  35317. m.ResetUpdatedAt()
  35318. return nil
  35319. case usagestatisticday.FieldStatus:
  35320. m.ResetStatus()
  35321. return nil
  35322. case usagestatisticday.FieldDeletedAt:
  35323. m.ResetDeletedAt()
  35324. return nil
  35325. case usagestatisticday.FieldAddtime:
  35326. m.ResetAddtime()
  35327. return nil
  35328. case usagestatisticday.FieldType:
  35329. m.ResetType()
  35330. return nil
  35331. case usagestatisticday.FieldBotID:
  35332. m.ResetBotID()
  35333. return nil
  35334. case usagestatisticday.FieldOrganizationID:
  35335. m.ResetOrganizationID()
  35336. return nil
  35337. case usagestatisticday.FieldAiResponse:
  35338. m.ResetAiResponse()
  35339. return nil
  35340. case usagestatisticday.FieldSopRun:
  35341. m.ResetSopRun()
  35342. return nil
  35343. case usagestatisticday.FieldTotalFriend:
  35344. m.ResetTotalFriend()
  35345. return nil
  35346. case usagestatisticday.FieldTotalGroup:
  35347. m.ResetTotalGroup()
  35348. return nil
  35349. case usagestatisticday.FieldAccountBalance:
  35350. m.ResetAccountBalance()
  35351. return nil
  35352. case usagestatisticday.FieldConsumeToken:
  35353. m.ResetConsumeToken()
  35354. return nil
  35355. case usagestatisticday.FieldActiveUser:
  35356. m.ResetActiveUser()
  35357. return nil
  35358. case usagestatisticday.FieldNewUser:
  35359. m.ResetNewUser()
  35360. return nil
  35361. case usagestatisticday.FieldLabelDist:
  35362. m.ResetLabelDist()
  35363. return nil
  35364. }
  35365. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  35366. }
  35367. // AddedEdges returns all edge names that were set/added in this mutation.
  35368. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  35369. edges := make([]string, 0, 0)
  35370. return edges
  35371. }
  35372. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35373. // name in this mutation.
  35374. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  35375. return nil
  35376. }
  35377. // RemovedEdges returns all edge names that were removed in this mutation.
  35378. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  35379. edges := make([]string, 0, 0)
  35380. return edges
  35381. }
  35382. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35383. // the given name in this mutation.
  35384. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  35385. return nil
  35386. }
  35387. // ClearedEdges returns all edge names that were cleared in this mutation.
  35388. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  35389. edges := make([]string, 0, 0)
  35390. return edges
  35391. }
  35392. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35393. // was cleared in this mutation.
  35394. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  35395. return false
  35396. }
  35397. // ClearEdge clears the value of the edge with the given name. It returns an error
  35398. // if that edge is not defined in the schema.
  35399. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  35400. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  35401. }
  35402. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35403. // It returns an error if the edge is not defined in the schema.
  35404. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  35405. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  35406. }
  35407. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  35408. type UsageStatisticHourMutation struct {
  35409. config
  35410. op Op
  35411. typ string
  35412. id *uint64
  35413. created_at *time.Time
  35414. updated_at *time.Time
  35415. status *uint8
  35416. addstatus *int8
  35417. deleted_at *time.Time
  35418. addtime *uint64
  35419. addaddtime *int64
  35420. _type *int
  35421. add_type *int
  35422. bot_id *string
  35423. organization_id *uint64
  35424. addorganization_id *int64
  35425. ai_response *uint64
  35426. addai_response *int64
  35427. sop_run *uint64
  35428. addsop_run *int64
  35429. total_friend *uint64
  35430. addtotal_friend *int64
  35431. total_group *uint64
  35432. addtotal_group *int64
  35433. account_balance *uint64
  35434. addaccount_balance *int64
  35435. consume_token *uint64
  35436. addconsume_token *int64
  35437. active_user *uint64
  35438. addactive_user *int64
  35439. new_user *int64
  35440. addnew_user *int64
  35441. label_dist *[]custom_types.LabelDist
  35442. appendlabel_dist []custom_types.LabelDist
  35443. clearedFields map[string]struct{}
  35444. done bool
  35445. oldValue func(context.Context) (*UsageStatisticHour, error)
  35446. predicates []predicate.UsageStatisticHour
  35447. }
  35448. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  35449. // usagestatistichourOption allows management of the mutation configuration using functional options.
  35450. type usagestatistichourOption func(*UsageStatisticHourMutation)
  35451. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  35452. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  35453. m := &UsageStatisticHourMutation{
  35454. config: c,
  35455. op: op,
  35456. typ: TypeUsageStatisticHour,
  35457. clearedFields: make(map[string]struct{}),
  35458. }
  35459. for _, opt := range opts {
  35460. opt(m)
  35461. }
  35462. return m
  35463. }
  35464. // withUsageStatisticHourID sets the ID field of the mutation.
  35465. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  35466. return func(m *UsageStatisticHourMutation) {
  35467. var (
  35468. err error
  35469. once sync.Once
  35470. value *UsageStatisticHour
  35471. )
  35472. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  35473. once.Do(func() {
  35474. if m.done {
  35475. err = errors.New("querying old values post mutation is not allowed")
  35476. } else {
  35477. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  35478. }
  35479. })
  35480. return value, err
  35481. }
  35482. m.id = &id
  35483. }
  35484. }
  35485. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  35486. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  35487. return func(m *UsageStatisticHourMutation) {
  35488. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  35489. return node, nil
  35490. }
  35491. m.id = &node.ID
  35492. }
  35493. }
  35494. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35495. // executed in a transaction (ent.Tx), a transactional client is returned.
  35496. func (m UsageStatisticHourMutation) Client() *Client {
  35497. client := &Client{config: m.config}
  35498. client.init()
  35499. return client
  35500. }
  35501. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35502. // it returns an error otherwise.
  35503. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  35504. if _, ok := m.driver.(*txDriver); !ok {
  35505. return nil, errors.New("ent: mutation is not running in a transaction")
  35506. }
  35507. tx := &Tx{config: m.config}
  35508. tx.init()
  35509. return tx, nil
  35510. }
  35511. // SetID sets the value of the id field. Note that this
  35512. // operation is only accepted on creation of UsageStatisticHour entities.
  35513. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  35514. m.id = &id
  35515. }
  35516. // ID returns the ID value in the mutation. Note that the ID is only available
  35517. // if it was provided to the builder or after it was returned from the database.
  35518. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  35519. if m.id == nil {
  35520. return
  35521. }
  35522. return *m.id, true
  35523. }
  35524. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35525. // That means, if the mutation is applied within a transaction with an isolation level such
  35526. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35527. // or updated by the mutation.
  35528. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  35529. switch {
  35530. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35531. id, exists := m.ID()
  35532. if exists {
  35533. return []uint64{id}, nil
  35534. }
  35535. fallthrough
  35536. case m.op.Is(OpUpdate | OpDelete):
  35537. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  35538. default:
  35539. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35540. }
  35541. }
  35542. // SetCreatedAt sets the "created_at" field.
  35543. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  35544. m.created_at = &t
  35545. }
  35546. // CreatedAt returns the value of the "created_at" field in the mutation.
  35547. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  35548. v := m.created_at
  35549. if v == nil {
  35550. return
  35551. }
  35552. return *v, true
  35553. }
  35554. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  35555. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35557. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35558. if !m.op.Is(OpUpdateOne) {
  35559. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35560. }
  35561. if m.id == nil || m.oldValue == nil {
  35562. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35563. }
  35564. oldValue, err := m.oldValue(ctx)
  35565. if err != nil {
  35566. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35567. }
  35568. return oldValue.CreatedAt, nil
  35569. }
  35570. // ResetCreatedAt resets all changes to the "created_at" field.
  35571. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  35572. m.created_at = nil
  35573. }
  35574. // SetUpdatedAt sets the "updated_at" field.
  35575. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  35576. m.updated_at = &t
  35577. }
  35578. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35579. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  35580. v := m.updated_at
  35581. if v == nil {
  35582. return
  35583. }
  35584. return *v, true
  35585. }
  35586. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  35587. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35589. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35590. if !m.op.Is(OpUpdateOne) {
  35591. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35592. }
  35593. if m.id == nil || m.oldValue == nil {
  35594. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35595. }
  35596. oldValue, err := m.oldValue(ctx)
  35597. if err != nil {
  35598. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35599. }
  35600. return oldValue.UpdatedAt, nil
  35601. }
  35602. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35603. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  35604. m.updated_at = nil
  35605. }
  35606. // SetStatus sets the "status" field.
  35607. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  35608. m.status = &u
  35609. m.addstatus = nil
  35610. }
  35611. // Status returns the value of the "status" field in the mutation.
  35612. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  35613. v := m.status
  35614. if v == nil {
  35615. return
  35616. }
  35617. return *v, true
  35618. }
  35619. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  35620. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35622. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35623. if !m.op.Is(OpUpdateOne) {
  35624. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35625. }
  35626. if m.id == nil || m.oldValue == nil {
  35627. return v, errors.New("OldStatus requires an ID field in the mutation")
  35628. }
  35629. oldValue, err := m.oldValue(ctx)
  35630. if err != nil {
  35631. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35632. }
  35633. return oldValue.Status, nil
  35634. }
  35635. // AddStatus adds u to the "status" field.
  35636. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  35637. if m.addstatus != nil {
  35638. *m.addstatus += u
  35639. } else {
  35640. m.addstatus = &u
  35641. }
  35642. }
  35643. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35644. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  35645. v := m.addstatus
  35646. if v == nil {
  35647. return
  35648. }
  35649. return *v, true
  35650. }
  35651. // ClearStatus clears the value of the "status" field.
  35652. func (m *UsageStatisticHourMutation) ClearStatus() {
  35653. m.status = nil
  35654. m.addstatus = nil
  35655. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  35656. }
  35657. // StatusCleared returns if the "status" field was cleared in this mutation.
  35658. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  35659. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  35660. return ok
  35661. }
  35662. // ResetStatus resets all changes to the "status" field.
  35663. func (m *UsageStatisticHourMutation) ResetStatus() {
  35664. m.status = nil
  35665. m.addstatus = nil
  35666. delete(m.clearedFields, usagestatistichour.FieldStatus)
  35667. }
  35668. // SetDeletedAt sets the "deleted_at" field.
  35669. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  35670. m.deleted_at = &t
  35671. }
  35672. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35673. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  35674. v := m.deleted_at
  35675. if v == nil {
  35676. return
  35677. }
  35678. return *v, true
  35679. }
  35680. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  35681. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35683. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35684. if !m.op.Is(OpUpdateOne) {
  35685. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35686. }
  35687. if m.id == nil || m.oldValue == nil {
  35688. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35689. }
  35690. oldValue, err := m.oldValue(ctx)
  35691. if err != nil {
  35692. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35693. }
  35694. return oldValue.DeletedAt, nil
  35695. }
  35696. // ClearDeletedAt clears the value of the "deleted_at" field.
  35697. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  35698. m.deleted_at = nil
  35699. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  35700. }
  35701. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35702. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  35703. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  35704. return ok
  35705. }
  35706. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35707. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  35708. m.deleted_at = nil
  35709. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  35710. }
  35711. // SetAddtime sets the "addtime" field.
  35712. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  35713. m.addtime = &u
  35714. m.addaddtime = nil
  35715. }
  35716. // Addtime returns the value of the "addtime" field in the mutation.
  35717. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  35718. v := m.addtime
  35719. if v == nil {
  35720. return
  35721. }
  35722. return *v, true
  35723. }
  35724. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  35725. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35727. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  35728. if !m.op.Is(OpUpdateOne) {
  35729. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  35730. }
  35731. if m.id == nil || m.oldValue == nil {
  35732. return v, errors.New("OldAddtime requires an ID field in the mutation")
  35733. }
  35734. oldValue, err := m.oldValue(ctx)
  35735. if err != nil {
  35736. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  35737. }
  35738. return oldValue.Addtime, nil
  35739. }
  35740. // AddAddtime adds u to the "addtime" field.
  35741. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  35742. if m.addaddtime != nil {
  35743. *m.addaddtime += u
  35744. } else {
  35745. m.addaddtime = &u
  35746. }
  35747. }
  35748. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  35749. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  35750. v := m.addaddtime
  35751. if v == nil {
  35752. return
  35753. }
  35754. return *v, true
  35755. }
  35756. // ResetAddtime resets all changes to the "addtime" field.
  35757. func (m *UsageStatisticHourMutation) ResetAddtime() {
  35758. m.addtime = nil
  35759. m.addaddtime = nil
  35760. }
  35761. // SetType sets the "type" field.
  35762. func (m *UsageStatisticHourMutation) SetType(i int) {
  35763. m._type = &i
  35764. m.add_type = nil
  35765. }
  35766. // GetType returns the value of the "type" field in the mutation.
  35767. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  35768. v := m._type
  35769. if v == nil {
  35770. return
  35771. }
  35772. return *v, true
  35773. }
  35774. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  35775. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35777. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  35778. if !m.op.Is(OpUpdateOne) {
  35779. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35780. }
  35781. if m.id == nil || m.oldValue == nil {
  35782. return v, errors.New("OldType requires an ID field in the mutation")
  35783. }
  35784. oldValue, err := m.oldValue(ctx)
  35785. if err != nil {
  35786. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35787. }
  35788. return oldValue.Type, nil
  35789. }
  35790. // AddType adds i to the "type" field.
  35791. func (m *UsageStatisticHourMutation) AddType(i int) {
  35792. if m.add_type != nil {
  35793. *m.add_type += i
  35794. } else {
  35795. m.add_type = &i
  35796. }
  35797. }
  35798. // AddedType returns the value that was added to the "type" field in this mutation.
  35799. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  35800. v := m.add_type
  35801. if v == nil {
  35802. return
  35803. }
  35804. return *v, true
  35805. }
  35806. // ResetType resets all changes to the "type" field.
  35807. func (m *UsageStatisticHourMutation) ResetType() {
  35808. m._type = nil
  35809. m.add_type = nil
  35810. }
  35811. // SetBotID sets the "bot_id" field.
  35812. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  35813. m.bot_id = &s
  35814. }
  35815. // BotID returns the value of the "bot_id" field in the mutation.
  35816. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  35817. v := m.bot_id
  35818. if v == nil {
  35819. return
  35820. }
  35821. return *v, true
  35822. }
  35823. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  35824. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35826. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  35827. if !m.op.Is(OpUpdateOne) {
  35828. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35829. }
  35830. if m.id == nil || m.oldValue == nil {
  35831. return v, errors.New("OldBotID requires an ID field in the mutation")
  35832. }
  35833. oldValue, err := m.oldValue(ctx)
  35834. if err != nil {
  35835. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35836. }
  35837. return oldValue.BotID, nil
  35838. }
  35839. // ClearBotID clears the value of the "bot_id" field.
  35840. func (m *UsageStatisticHourMutation) ClearBotID() {
  35841. m.bot_id = nil
  35842. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  35843. }
  35844. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  35845. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  35846. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  35847. return ok
  35848. }
  35849. // ResetBotID resets all changes to the "bot_id" field.
  35850. func (m *UsageStatisticHourMutation) ResetBotID() {
  35851. m.bot_id = nil
  35852. delete(m.clearedFields, usagestatistichour.FieldBotID)
  35853. }
  35854. // SetOrganizationID sets the "organization_id" field.
  35855. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  35856. m.organization_id = &u
  35857. m.addorganization_id = nil
  35858. }
  35859. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35860. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  35861. v := m.organization_id
  35862. if v == nil {
  35863. return
  35864. }
  35865. return *v, true
  35866. }
  35867. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  35868. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35870. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35871. if !m.op.Is(OpUpdateOne) {
  35872. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35873. }
  35874. if m.id == nil || m.oldValue == nil {
  35875. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35876. }
  35877. oldValue, err := m.oldValue(ctx)
  35878. if err != nil {
  35879. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35880. }
  35881. return oldValue.OrganizationID, nil
  35882. }
  35883. // AddOrganizationID adds u to the "organization_id" field.
  35884. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  35885. if m.addorganization_id != nil {
  35886. *m.addorganization_id += u
  35887. } else {
  35888. m.addorganization_id = &u
  35889. }
  35890. }
  35891. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35892. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  35893. v := m.addorganization_id
  35894. if v == nil {
  35895. return
  35896. }
  35897. return *v, true
  35898. }
  35899. // ClearOrganizationID clears the value of the "organization_id" field.
  35900. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  35901. m.organization_id = nil
  35902. m.addorganization_id = nil
  35903. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  35904. }
  35905. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35906. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  35907. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  35908. return ok
  35909. }
  35910. // ResetOrganizationID resets all changes to the "organization_id" field.
  35911. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  35912. m.organization_id = nil
  35913. m.addorganization_id = nil
  35914. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  35915. }
  35916. // SetAiResponse sets the "ai_response" field.
  35917. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  35918. m.ai_response = &u
  35919. m.addai_response = nil
  35920. }
  35921. // AiResponse returns the value of the "ai_response" field in the mutation.
  35922. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  35923. v := m.ai_response
  35924. if v == nil {
  35925. return
  35926. }
  35927. return *v, true
  35928. }
  35929. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  35930. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35932. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35933. if !m.op.Is(OpUpdateOne) {
  35934. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35935. }
  35936. if m.id == nil || m.oldValue == nil {
  35937. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35938. }
  35939. oldValue, err := m.oldValue(ctx)
  35940. if err != nil {
  35941. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35942. }
  35943. return oldValue.AiResponse, nil
  35944. }
  35945. // AddAiResponse adds u to the "ai_response" field.
  35946. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  35947. if m.addai_response != nil {
  35948. *m.addai_response += u
  35949. } else {
  35950. m.addai_response = &u
  35951. }
  35952. }
  35953. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35954. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  35955. v := m.addai_response
  35956. if v == nil {
  35957. return
  35958. }
  35959. return *v, true
  35960. }
  35961. // ResetAiResponse resets all changes to the "ai_response" field.
  35962. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  35963. m.ai_response = nil
  35964. m.addai_response = nil
  35965. }
  35966. // SetSopRun sets the "sop_run" field.
  35967. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  35968. m.sop_run = &u
  35969. m.addsop_run = nil
  35970. }
  35971. // SopRun returns the value of the "sop_run" field in the mutation.
  35972. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  35973. v := m.sop_run
  35974. if v == nil {
  35975. return
  35976. }
  35977. return *v, true
  35978. }
  35979. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  35980. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  35981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35982. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35983. if !m.op.Is(OpUpdateOne) {
  35984. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35985. }
  35986. if m.id == nil || m.oldValue == nil {
  35987. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35988. }
  35989. oldValue, err := m.oldValue(ctx)
  35990. if err != nil {
  35991. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35992. }
  35993. return oldValue.SopRun, nil
  35994. }
  35995. // AddSopRun adds u to the "sop_run" field.
  35996. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  35997. if m.addsop_run != nil {
  35998. *m.addsop_run += u
  35999. } else {
  36000. m.addsop_run = &u
  36001. }
  36002. }
  36003. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36004. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  36005. v := m.addsop_run
  36006. if v == nil {
  36007. return
  36008. }
  36009. return *v, true
  36010. }
  36011. // ResetSopRun resets all changes to the "sop_run" field.
  36012. func (m *UsageStatisticHourMutation) ResetSopRun() {
  36013. m.sop_run = nil
  36014. m.addsop_run = nil
  36015. }
  36016. // SetTotalFriend sets the "total_friend" field.
  36017. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  36018. m.total_friend = &u
  36019. m.addtotal_friend = nil
  36020. }
  36021. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36022. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  36023. v := m.total_friend
  36024. if v == nil {
  36025. return
  36026. }
  36027. return *v, true
  36028. }
  36029. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  36030. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36032. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36033. if !m.op.Is(OpUpdateOne) {
  36034. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36035. }
  36036. if m.id == nil || m.oldValue == nil {
  36037. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36038. }
  36039. oldValue, err := m.oldValue(ctx)
  36040. if err != nil {
  36041. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36042. }
  36043. return oldValue.TotalFriend, nil
  36044. }
  36045. // AddTotalFriend adds u to the "total_friend" field.
  36046. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  36047. if m.addtotal_friend != nil {
  36048. *m.addtotal_friend += u
  36049. } else {
  36050. m.addtotal_friend = &u
  36051. }
  36052. }
  36053. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36054. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  36055. v := m.addtotal_friend
  36056. if v == nil {
  36057. return
  36058. }
  36059. return *v, true
  36060. }
  36061. // ResetTotalFriend resets all changes to the "total_friend" field.
  36062. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  36063. m.total_friend = nil
  36064. m.addtotal_friend = nil
  36065. }
  36066. // SetTotalGroup sets the "total_group" field.
  36067. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  36068. m.total_group = &u
  36069. m.addtotal_group = nil
  36070. }
  36071. // TotalGroup returns the value of the "total_group" field in the mutation.
  36072. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  36073. v := m.total_group
  36074. if v == nil {
  36075. return
  36076. }
  36077. return *v, true
  36078. }
  36079. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  36080. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36082. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36083. if !m.op.Is(OpUpdateOne) {
  36084. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36085. }
  36086. if m.id == nil || m.oldValue == nil {
  36087. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36088. }
  36089. oldValue, err := m.oldValue(ctx)
  36090. if err != nil {
  36091. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36092. }
  36093. return oldValue.TotalGroup, nil
  36094. }
  36095. // AddTotalGroup adds u to the "total_group" field.
  36096. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  36097. if m.addtotal_group != nil {
  36098. *m.addtotal_group += u
  36099. } else {
  36100. m.addtotal_group = &u
  36101. }
  36102. }
  36103. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36104. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  36105. v := m.addtotal_group
  36106. if v == nil {
  36107. return
  36108. }
  36109. return *v, true
  36110. }
  36111. // ResetTotalGroup resets all changes to the "total_group" field.
  36112. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  36113. m.total_group = nil
  36114. m.addtotal_group = nil
  36115. }
  36116. // SetAccountBalance sets the "account_balance" field.
  36117. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  36118. m.account_balance = &u
  36119. m.addaccount_balance = nil
  36120. }
  36121. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36122. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  36123. v := m.account_balance
  36124. if v == nil {
  36125. return
  36126. }
  36127. return *v, true
  36128. }
  36129. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  36130. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36132. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36133. if !m.op.Is(OpUpdateOne) {
  36134. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36135. }
  36136. if m.id == nil || m.oldValue == nil {
  36137. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36138. }
  36139. oldValue, err := m.oldValue(ctx)
  36140. if err != nil {
  36141. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36142. }
  36143. return oldValue.AccountBalance, nil
  36144. }
  36145. // AddAccountBalance adds u to the "account_balance" field.
  36146. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  36147. if m.addaccount_balance != nil {
  36148. *m.addaccount_balance += u
  36149. } else {
  36150. m.addaccount_balance = &u
  36151. }
  36152. }
  36153. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36154. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  36155. v := m.addaccount_balance
  36156. if v == nil {
  36157. return
  36158. }
  36159. return *v, true
  36160. }
  36161. // ResetAccountBalance resets all changes to the "account_balance" field.
  36162. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  36163. m.account_balance = nil
  36164. m.addaccount_balance = nil
  36165. }
  36166. // SetConsumeToken sets the "consume_token" field.
  36167. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  36168. m.consume_token = &u
  36169. m.addconsume_token = nil
  36170. }
  36171. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36172. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  36173. v := m.consume_token
  36174. if v == nil {
  36175. return
  36176. }
  36177. return *v, true
  36178. }
  36179. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  36180. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36182. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36183. if !m.op.Is(OpUpdateOne) {
  36184. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36185. }
  36186. if m.id == nil || m.oldValue == nil {
  36187. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36188. }
  36189. oldValue, err := m.oldValue(ctx)
  36190. if err != nil {
  36191. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36192. }
  36193. return oldValue.ConsumeToken, nil
  36194. }
  36195. // AddConsumeToken adds u to the "consume_token" field.
  36196. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  36197. if m.addconsume_token != nil {
  36198. *m.addconsume_token += u
  36199. } else {
  36200. m.addconsume_token = &u
  36201. }
  36202. }
  36203. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36204. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  36205. v := m.addconsume_token
  36206. if v == nil {
  36207. return
  36208. }
  36209. return *v, true
  36210. }
  36211. // ResetConsumeToken resets all changes to the "consume_token" field.
  36212. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  36213. m.consume_token = nil
  36214. m.addconsume_token = nil
  36215. }
  36216. // SetActiveUser sets the "active_user" field.
  36217. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  36218. m.active_user = &u
  36219. m.addactive_user = nil
  36220. }
  36221. // ActiveUser returns the value of the "active_user" field in the mutation.
  36222. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  36223. v := m.active_user
  36224. if v == nil {
  36225. return
  36226. }
  36227. return *v, true
  36228. }
  36229. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  36230. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36232. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36233. if !m.op.Is(OpUpdateOne) {
  36234. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36235. }
  36236. if m.id == nil || m.oldValue == nil {
  36237. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36238. }
  36239. oldValue, err := m.oldValue(ctx)
  36240. if err != nil {
  36241. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36242. }
  36243. return oldValue.ActiveUser, nil
  36244. }
  36245. // AddActiveUser adds u to the "active_user" field.
  36246. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  36247. if m.addactive_user != nil {
  36248. *m.addactive_user += u
  36249. } else {
  36250. m.addactive_user = &u
  36251. }
  36252. }
  36253. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36254. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  36255. v := m.addactive_user
  36256. if v == nil {
  36257. return
  36258. }
  36259. return *v, true
  36260. }
  36261. // ResetActiveUser resets all changes to the "active_user" field.
  36262. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  36263. m.active_user = nil
  36264. m.addactive_user = nil
  36265. }
  36266. // SetNewUser sets the "new_user" field.
  36267. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  36268. m.new_user = &i
  36269. m.addnew_user = nil
  36270. }
  36271. // NewUser returns the value of the "new_user" field in the mutation.
  36272. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  36273. v := m.new_user
  36274. if v == nil {
  36275. return
  36276. }
  36277. return *v, true
  36278. }
  36279. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  36280. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36282. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36283. if !m.op.Is(OpUpdateOne) {
  36284. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36285. }
  36286. if m.id == nil || m.oldValue == nil {
  36287. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36288. }
  36289. oldValue, err := m.oldValue(ctx)
  36290. if err != nil {
  36291. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36292. }
  36293. return oldValue.NewUser, nil
  36294. }
  36295. // AddNewUser adds i to the "new_user" field.
  36296. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  36297. if m.addnew_user != nil {
  36298. *m.addnew_user += i
  36299. } else {
  36300. m.addnew_user = &i
  36301. }
  36302. }
  36303. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36304. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  36305. v := m.addnew_user
  36306. if v == nil {
  36307. return
  36308. }
  36309. return *v, true
  36310. }
  36311. // ResetNewUser resets all changes to the "new_user" field.
  36312. func (m *UsageStatisticHourMutation) ResetNewUser() {
  36313. m.new_user = nil
  36314. m.addnew_user = nil
  36315. }
  36316. // SetLabelDist sets the "label_dist" field.
  36317. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36318. m.label_dist = &ctd
  36319. m.appendlabel_dist = nil
  36320. }
  36321. // LabelDist returns the value of the "label_dist" field in the mutation.
  36322. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36323. v := m.label_dist
  36324. if v == nil {
  36325. return
  36326. }
  36327. return *v, true
  36328. }
  36329. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  36330. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  36331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36332. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36333. if !m.op.Is(OpUpdateOne) {
  36334. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36335. }
  36336. if m.id == nil || m.oldValue == nil {
  36337. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36338. }
  36339. oldValue, err := m.oldValue(ctx)
  36340. if err != nil {
  36341. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36342. }
  36343. return oldValue.LabelDist, nil
  36344. }
  36345. // AppendLabelDist adds ctd to the "label_dist" field.
  36346. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36347. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36348. }
  36349. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36350. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36351. if len(m.appendlabel_dist) == 0 {
  36352. return nil, false
  36353. }
  36354. return m.appendlabel_dist, true
  36355. }
  36356. // ResetLabelDist resets all changes to the "label_dist" field.
  36357. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  36358. m.label_dist = nil
  36359. m.appendlabel_dist = nil
  36360. }
  36361. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  36362. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  36363. m.predicates = append(m.predicates, ps...)
  36364. }
  36365. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  36366. // users can use type-assertion to append predicates that do not depend on any generated package.
  36367. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  36368. p := make([]predicate.UsageStatisticHour, len(ps))
  36369. for i := range ps {
  36370. p[i] = ps[i]
  36371. }
  36372. m.Where(p...)
  36373. }
  36374. // Op returns the operation name.
  36375. func (m *UsageStatisticHourMutation) Op() Op {
  36376. return m.op
  36377. }
  36378. // SetOp allows setting the mutation operation.
  36379. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  36380. m.op = op
  36381. }
  36382. // Type returns the node type of this mutation (UsageStatisticHour).
  36383. func (m *UsageStatisticHourMutation) Type() string {
  36384. return m.typ
  36385. }
  36386. // Fields returns all fields that were changed during this mutation. Note that in
  36387. // order to get all numeric fields that were incremented/decremented, call
  36388. // AddedFields().
  36389. func (m *UsageStatisticHourMutation) Fields() []string {
  36390. fields := make([]string, 0, 17)
  36391. if m.created_at != nil {
  36392. fields = append(fields, usagestatistichour.FieldCreatedAt)
  36393. }
  36394. if m.updated_at != nil {
  36395. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  36396. }
  36397. if m.status != nil {
  36398. fields = append(fields, usagestatistichour.FieldStatus)
  36399. }
  36400. if m.deleted_at != nil {
  36401. fields = append(fields, usagestatistichour.FieldDeletedAt)
  36402. }
  36403. if m.addtime != nil {
  36404. fields = append(fields, usagestatistichour.FieldAddtime)
  36405. }
  36406. if m._type != nil {
  36407. fields = append(fields, usagestatistichour.FieldType)
  36408. }
  36409. if m.bot_id != nil {
  36410. fields = append(fields, usagestatistichour.FieldBotID)
  36411. }
  36412. if m.organization_id != nil {
  36413. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36414. }
  36415. if m.ai_response != nil {
  36416. fields = append(fields, usagestatistichour.FieldAiResponse)
  36417. }
  36418. if m.sop_run != nil {
  36419. fields = append(fields, usagestatistichour.FieldSopRun)
  36420. }
  36421. if m.total_friend != nil {
  36422. fields = append(fields, usagestatistichour.FieldTotalFriend)
  36423. }
  36424. if m.total_group != nil {
  36425. fields = append(fields, usagestatistichour.FieldTotalGroup)
  36426. }
  36427. if m.account_balance != nil {
  36428. fields = append(fields, usagestatistichour.FieldAccountBalance)
  36429. }
  36430. if m.consume_token != nil {
  36431. fields = append(fields, usagestatistichour.FieldConsumeToken)
  36432. }
  36433. if m.active_user != nil {
  36434. fields = append(fields, usagestatistichour.FieldActiveUser)
  36435. }
  36436. if m.new_user != nil {
  36437. fields = append(fields, usagestatistichour.FieldNewUser)
  36438. }
  36439. if m.label_dist != nil {
  36440. fields = append(fields, usagestatistichour.FieldLabelDist)
  36441. }
  36442. return fields
  36443. }
  36444. // Field returns the value of a field with the given name. The second boolean
  36445. // return value indicates that this field was not set, or was not defined in the
  36446. // schema.
  36447. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  36448. switch name {
  36449. case usagestatistichour.FieldCreatedAt:
  36450. return m.CreatedAt()
  36451. case usagestatistichour.FieldUpdatedAt:
  36452. return m.UpdatedAt()
  36453. case usagestatistichour.FieldStatus:
  36454. return m.Status()
  36455. case usagestatistichour.FieldDeletedAt:
  36456. return m.DeletedAt()
  36457. case usagestatistichour.FieldAddtime:
  36458. return m.Addtime()
  36459. case usagestatistichour.FieldType:
  36460. return m.GetType()
  36461. case usagestatistichour.FieldBotID:
  36462. return m.BotID()
  36463. case usagestatistichour.FieldOrganizationID:
  36464. return m.OrganizationID()
  36465. case usagestatistichour.FieldAiResponse:
  36466. return m.AiResponse()
  36467. case usagestatistichour.FieldSopRun:
  36468. return m.SopRun()
  36469. case usagestatistichour.FieldTotalFriend:
  36470. return m.TotalFriend()
  36471. case usagestatistichour.FieldTotalGroup:
  36472. return m.TotalGroup()
  36473. case usagestatistichour.FieldAccountBalance:
  36474. return m.AccountBalance()
  36475. case usagestatistichour.FieldConsumeToken:
  36476. return m.ConsumeToken()
  36477. case usagestatistichour.FieldActiveUser:
  36478. return m.ActiveUser()
  36479. case usagestatistichour.FieldNewUser:
  36480. return m.NewUser()
  36481. case usagestatistichour.FieldLabelDist:
  36482. return m.LabelDist()
  36483. }
  36484. return nil, false
  36485. }
  36486. // OldField returns the old value of the field from the database. An error is
  36487. // returned if the mutation operation is not UpdateOne, or the query to the
  36488. // database failed.
  36489. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36490. switch name {
  36491. case usagestatistichour.FieldCreatedAt:
  36492. return m.OldCreatedAt(ctx)
  36493. case usagestatistichour.FieldUpdatedAt:
  36494. return m.OldUpdatedAt(ctx)
  36495. case usagestatistichour.FieldStatus:
  36496. return m.OldStatus(ctx)
  36497. case usagestatistichour.FieldDeletedAt:
  36498. return m.OldDeletedAt(ctx)
  36499. case usagestatistichour.FieldAddtime:
  36500. return m.OldAddtime(ctx)
  36501. case usagestatistichour.FieldType:
  36502. return m.OldType(ctx)
  36503. case usagestatistichour.FieldBotID:
  36504. return m.OldBotID(ctx)
  36505. case usagestatistichour.FieldOrganizationID:
  36506. return m.OldOrganizationID(ctx)
  36507. case usagestatistichour.FieldAiResponse:
  36508. return m.OldAiResponse(ctx)
  36509. case usagestatistichour.FieldSopRun:
  36510. return m.OldSopRun(ctx)
  36511. case usagestatistichour.FieldTotalFriend:
  36512. return m.OldTotalFriend(ctx)
  36513. case usagestatistichour.FieldTotalGroup:
  36514. return m.OldTotalGroup(ctx)
  36515. case usagestatistichour.FieldAccountBalance:
  36516. return m.OldAccountBalance(ctx)
  36517. case usagestatistichour.FieldConsumeToken:
  36518. return m.OldConsumeToken(ctx)
  36519. case usagestatistichour.FieldActiveUser:
  36520. return m.OldActiveUser(ctx)
  36521. case usagestatistichour.FieldNewUser:
  36522. return m.OldNewUser(ctx)
  36523. case usagestatistichour.FieldLabelDist:
  36524. return m.OldLabelDist(ctx)
  36525. }
  36526. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36527. }
  36528. // SetField sets the value of a field with the given name. It returns an error if
  36529. // the field is not defined in the schema, or if the type mismatched the field
  36530. // type.
  36531. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  36532. switch name {
  36533. case usagestatistichour.FieldCreatedAt:
  36534. v, ok := value.(time.Time)
  36535. if !ok {
  36536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36537. }
  36538. m.SetCreatedAt(v)
  36539. return nil
  36540. case usagestatistichour.FieldUpdatedAt:
  36541. v, ok := value.(time.Time)
  36542. if !ok {
  36543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36544. }
  36545. m.SetUpdatedAt(v)
  36546. return nil
  36547. case usagestatistichour.FieldStatus:
  36548. v, ok := value.(uint8)
  36549. if !ok {
  36550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36551. }
  36552. m.SetStatus(v)
  36553. return nil
  36554. case usagestatistichour.FieldDeletedAt:
  36555. v, ok := value.(time.Time)
  36556. if !ok {
  36557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36558. }
  36559. m.SetDeletedAt(v)
  36560. return nil
  36561. case usagestatistichour.FieldAddtime:
  36562. v, ok := value.(uint64)
  36563. if !ok {
  36564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36565. }
  36566. m.SetAddtime(v)
  36567. return nil
  36568. case usagestatistichour.FieldType:
  36569. v, ok := value.(int)
  36570. if !ok {
  36571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36572. }
  36573. m.SetType(v)
  36574. return nil
  36575. case usagestatistichour.FieldBotID:
  36576. v, ok := value.(string)
  36577. if !ok {
  36578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36579. }
  36580. m.SetBotID(v)
  36581. return nil
  36582. case usagestatistichour.FieldOrganizationID:
  36583. v, ok := value.(uint64)
  36584. if !ok {
  36585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36586. }
  36587. m.SetOrganizationID(v)
  36588. return nil
  36589. case usagestatistichour.FieldAiResponse:
  36590. v, ok := value.(uint64)
  36591. if !ok {
  36592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36593. }
  36594. m.SetAiResponse(v)
  36595. return nil
  36596. case usagestatistichour.FieldSopRun:
  36597. v, ok := value.(uint64)
  36598. if !ok {
  36599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36600. }
  36601. m.SetSopRun(v)
  36602. return nil
  36603. case usagestatistichour.FieldTotalFriend:
  36604. v, ok := value.(uint64)
  36605. if !ok {
  36606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36607. }
  36608. m.SetTotalFriend(v)
  36609. return nil
  36610. case usagestatistichour.FieldTotalGroup:
  36611. v, ok := value.(uint64)
  36612. if !ok {
  36613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36614. }
  36615. m.SetTotalGroup(v)
  36616. return nil
  36617. case usagestatistichour.FieldAccountBalance:
  36618. v, ok := value.(uint64)
  36619. if !ok {
  36620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36621. }
  36622. m.SetAccountBalance(v)
  36623. return nil
  36624. case usagestatistichour.FieldConsumeToken:
  36625. v, ok := value.(uint64)
  36626. if !ok {
  36627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36628. }
  36629. m.SetConsumeToken(v)
  36630. return nil
  36631. case usagestatistichour.FieldActiveUser:
  36632. v, ok := value.(uint64)
  36633. if !ok {
  36634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36635. }
  36636. m.SetActiveUser(v)
  36637. return nil
  36638. case usagestatistichour.FieldNewUser:
  36639. v, ok := value.(int64)
  36640. if !ok {
  36641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36642. }
  36643. m.SetNewUser(v)
  36644. return nil
  36645. case usagestatistichour.FieldLabelDist:
  36646. v, ok := value.([]custom_types.LabelDist)
  36647. if !ok {
  36648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36649. }
  36650. m.SetLabelDist(v)
  36651. return nil
  36652. }
  36653. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36654. }
  36655. // AddedFields returns all numeric fields that were incremented/decremented during
  36656. // this mutation.
  36657. func (m *UsageStatisticHourMutation) AddedFields() []string {
  36658. var fields []string
  36659. if m.addstatus != nil {
  36660. fields = append(fields, usagestatistichour.FieldStatus)
  36661. }
  36662. if m.addaddtime != nil {
  36663. fields = append(fields, usagestatistichour.FieldAddtime)
  36664. }
  36665. if m.add_type != nil {
  36666. fields = append(fields, usagestatistichour.FieldType)
  36667. }
  36668. if m.addorganization_id != nil {
  36669. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36670. }
  36671. if m.addai_response != nil {
  36672. fields = append(fields, usagestatistichour.FieldAiResponse)
  36673. }
  36674. if m.addsop_run != nil {
  36675. fields = append(fields, usagestatistichour.FieldSopRun)
  36676. }
  36677. if m.addtotal_friend != nil {
  36678. fields = append(fields, usagestatistichour.FieldTotalFriend)
  36679. }
  36680. if m.addtotal_group != nil {
  36681. fields = append(fields, usagestatistichour.FieldTotalGroup)
  36682. }
  36683. if m.addaccount_balance != nil {
  36684. fields = append(fields, usagestatistichour.FieldAccountBalance)
  36685. }
  36686. if m.addconsume_token != nil {
  36687. fields = append(fields, usagestatistichour.FieldConsumeToken)
  36688. }
  36689. if m.addactive_user != nil {
  36690. fields = append(fields, usagestatistichour.FieldActiveUser)
  36691. }
  36692. if m.addnew_user != nil {
  36693. fields = append(fields, usagestatistichour.FieldNewUser)
  36694. }
  36695. return fields
  36696. }
  36697. // AddedField returns the numeric value that was incremented/decremented on a field
  36698. // with the given name. The second boolean return value indicates that this field
  36699. // was not set, or was not defined in the schema.
  36700. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  36701. switch name {
  36702. case usagestatistichour.FieldStatus:
  36703. return m.AddedStatus()
  36704. case usagestatistichour.FieldAddtime:
  36705. return m.AddedAddtime()
  36706. case usagestatistichour.FieldType:
  36707. return m.AddedType()
  36708. case usagestatistichour.FieldOrganizationID:
  36709. return m.AddedOrganizationID()
  36710. case usagestatistichour.FieldAiResponse:
  36711. return m.AddedAiResponse()
  36712. case usagestatistichour.FieldSopRun:
  36713. return m.AddedSopRun()
  36714. case usagestatistichour.FieldTotalFriend:
  36715. return m.AddedTotalFriend()
  36716. case usagestatistichour.FieldTotalGroup:
  36717. return m.AddedTotalGroup()
  36718. case usagestatistichour.FieldAccountBalance:
  36719. return m.AddedAccountBalance()
  36720. case usagestatistichour.FieldConsumeToken:
  36721. return m.AddedConsumeToken()
  36722. case usagestatistichour.FieldActiveUser:
  36723. return m.AddedActiveUser()
  36724. case usagestatistichour.FieldNewUser:
  36725. return m.AddedNewUser()
  36726. }
  36727. return nil, false
  36728. }
  36729. // AddField adds the value to the field with the given name. It returns an error if
  36730. // the field is not defined in the schema, or if the type mismatched the field
  36731. // type.
  36732. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  36733. switch name {
  36734. case usagestatistichour.FieldStatus:
  36735. v, ok := value.(int8)
  36736. if !ok {
  36737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36738. }
  36739. m.AddStatus(v)
  36740. return nil
  36741. case usagestatistichour.FieldAddtime:
  36742. v, ok := value.(int64)
  36743. if !ok {
  36744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36745. }
  36746. m.AddAddtime(v)
  36747. return nil
  36748. case usagestatistichour.FieldType:
  36749. v, ok := value.(int)
  36750. if !ok {
  36751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36752. }
  36753. m.AddType(v)
  36754. return nil
  36755. case usagestatistichour.FieldOrganizationID:
  36756. v, ok := value.(int64)
  36757. if !ok {
  36758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36759. }
  36760. m.AddOrganizationID(v)
  36761. return nil
  36762. case usagestatistichour.FieldAiResponse:
  36763. v, ok := value.(int64)
  36764. if !ok {
  36765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36766. }
  36767. m.AddAiResponse(v)
  36768. return nil
  36769. case usagestatistichour.FieldSopRun:
  36770. v, ok := value.(int64)
  36771. if !ok {
  36772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36773. }
  36774. m.AddSopRun(v)
  36775. return nil
  36776. case usagestatistichour.FieldTotalFriend:
  36777. v, ok := value.(int64)
  36778. if !ok {
  36779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36780. }
  36781. m.AddTotalFriend(v)
  36782. return nil
  36783. case usagestatistichour.FieldTotalGroup:
  36784. v, ok := value.(int64)
  36785. if !ok {
  36786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36787. }
  36788. m.AddTotalGroup(v)
  36789. return nil
  36790. case usagestatistichour.FieldAccountBalance:
  36791. v, ok := value.(int64)
  36792. if !ok {
  36793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36794. }
  36795. m.AddAccountBalance(v)
  36796. return nil
  36797. case usagestatistichour.FieldConsumeToken:
  36798. v, ok := value.(int64)
  36799. if !ok {
  36800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36801. }
  36802. m.AddConsumeToken(v)
  36803. return nil
  36804. case usagestatistichour.FieldActiveUser:
  36805. v, ok := value.(int64)
  36806. if !ok {
  36807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36808. }
  36809. m.AddActiveUser(v)
  36810. return nil
  36811. case usagestatistichour.FieldNewUser:
  36812. v, ok := value.(int64)
  36813. if !ok {
  36814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36815. }
  36816. m.AddNewUser(v)
  36817. return nil
  36818. }
  36819. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  36820. }
  36821. // ClearedFields returns all nullable fields that were cleared during this
  36822. // mutation.
  36823. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  36824. var fields []string
  36825. if m.FieldCleared(usagestatistichour.FieldStatus) {
  36826. fields = append(fields, usagestatistichour.FieldStatus)
  36827. }
  36828. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  36829. fields = append(fields, usagestatistichour.FieldDeletedAt)
  36830. }
  36831. if m.FieldCleared(usagestatistichour.FieldBotID) {
  36832. fields = append(fields, usagestatistichour.FieldBotID)
  36833. }
  36834. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  36835. fields = append(fields, usagestatistichour.FieldOrganizationID)
  36836. }
  36837. return fields
  36838. }
  36839. // FieldCleared returns a boolean indicating if a field with the given name was
  36840. // cleared in this mutation.
  36841. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  36842. _, ok := m.clearedFields[name]
  36843. return ok
  36844. }
  36845. // ClearField clears the value of the field with the given name. It returns an
  36846. // error if the field is not defined in the schema.
  36847. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  36848. switch name {
  36849. case usagestatistichour.FieldStatus:
  36850. m.ClearStatus()
  36851. return nil
  36852. case usagestatistichour.FieldDeletedAt:
  36853. m.ClearDeletedAt()
  36854. return nil
  36855. case usagestatistichour.FieldBotID:
  36856. m.ClearBotID()
  36857. return nil
  36858. case usagestatistichour.FieldOrganizationID:
  36859. m.ClearOrganizationID()
  36860. return nil
  36861. }
  36862. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  36863. }
  36864. // ResetField resets all changes in the mutation for the field with the given name.
  36865. // It returns an error if the field is not defined in the schema.
  36866. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  36867. switch name {
  36868. case usagestatistichour.FieldCreatedAt:
  36869. m.ResetCreatedAt()
  36870. return nil
  36871. case usagestatistichour.FieldUpdatedAt:
  36872. m.ResetUpdatedAt()
  36873. return nil
  36874. case usagestatistichour.FieldStatus:
  36875. m.ResetStatus()
  36876. return nil
  36877. case usagestatistichour.FieldDeletedAt:
  36878. m.ResetDeletedAt()
  36879. return nil
  36880. case usagestatistichour.FieldAddtime:
  36881. m.ResetAddtime()
  36882. return nil
  36883. case usagestatistichour.FieldType:
  36884. m.ResetType()
  36885. return nil
  36886. case usagestatistichour.FieldBotID:
  36887. m.ResetBotID()
  36888. return nil
  36889. case usagestatistichour.FieldOrganizationID:
  36890. m.ResetOrganizationID()
  36891. return nil
  36892. case usagestatistichour.FieldAiResponse:
  36893. m.ResetAiResponse()
  36894. return nil
  36895. case usagestatistichour.FieldSopRun:
  36896. m.ResetSopRun()
  36897. return nil
  36898. case usagestatistichour.FieldTotalFriend:
  36899. m.ResetTotalFriend()
  36900. return nil
  36901. case usagestatistichour.FieldTotalGroup:
  36902. m.ResetTotalGroup()
  36903. return nil
  36904. case usagestatistichour.FieldAccountBalance:
  36905. m.ResetAccountBalance()
  36906. return nil
  36907. case usagestatistichour.FieldConsumeToken:
  36908. m.ResetConsumeToken()
  36909. return nil
  36910. case usagestatistichour.FieldActiveUser:
  36911. m.ResetActiveUser()
  36912. return nil
  36913. case usagestatistichour.FieldNewUser:
  36914. m.ResetNewUser()
  36915. return nil
  36916. case usagestatistichour.FieldLabelDist:
  36917. m.ResetLabelDist()
  36918. return nil
  36919. }
  36920. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  36921. }
  36922. // AddedEdges returns all edge names that were set/added in this mutation.
  36923. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  36924. edges := make([]string, 0, 0)
  36925. return edges
  36926. }
  36927. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36928. // name in this mutation.
  36929. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  36930. return nil
  36931. }
  36932. // RemovedEdges returns all edge names that were removed in this mutation.
  36933. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  36934. edges := make([]string, 0, 0)
  36935. return edges
  36936. }
  36937. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36938. // the given name in this mutation.
  36939. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  36940. return nil
  36941. }
  36942. // ClearedEdges returns all edge names that were cleared in this mutation.
  36943. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  36944. edges := make([]string, 0, 0)
  36945. return edges
  36946. }
  36947. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36948. // was cleared in this mutation.
  36949. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  36950. return false
  36951. }
  36952. // ClearEdge clears the value of the edge with the given name. It returns an error
  36953. // if that edge is not defined in the schema.
  36954. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  36955. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  36956. }
  36957. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36958. // It returns an error if the edge is not defined in the schema.
  36959. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  36960. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  36961. }
  36962. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  36963. type UsageStatisticMonthMutation struct {
  36964. config
  36965. op Op
  36966. typ string
  36967. id *uint64
  36968. created_at *time.Time
  36969. updated_at *time.Time
  36970. status *uint8
  36971. addstatus *int8
  36972. deleted_at *time.Time
  36973. addtime *uint64
  36974. addaddtime *int64
  36975. _type *int
  36976. add_type *int
  36977. bot_id *string
  36978. organization_id *uint64
  36979. addorganization_id *int64
  36980. ai_response *uint64
  36981. addai_response *int64
  36982. sop_run *uint64
  36983. addsop_run *int64
  36984. total_friend *uint64
  36985. addtotal_friend *int64
  36986. total_group *uint64
  36987. addtotal_group *int64
  36988. account_balance *uint64
  36989. addaccount_balance *int64
  36990. consume_token *uint64
  36991. addconsume_token *int64
  36992. active_user *uint64
  36993. addactive_user *int64
  36994. new_user *int64
  36995. addnew_user *int64
  36996. label_dist *[]custom_types.LabelDist
  36997. appendlabel_dist []custom_types.LabelDist
  36998. clearedFields map[string]struct{}
  36999. done bool
  37000. oldValue func(context.Context) (*UsageStatisticMonth, error)
  37001. predicates []predicate.UsageStatisticMonth
  37002. }
  37003. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  37004. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  37005. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  37006. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  37007. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  37008. m := &UsageStatisticMonthMutation{
  37009. config: c,
  37010. op: op,
  37011. typ: TypeUsageStatisticMonth,
  37012. clearedFields: make(map[string]struct{}),
  37013. }
  37014. for _, opt := range opts {
  37015. opt(m)
  37016. }
  37017. return m
  37018. }
  37019. // withUsageStatisticMonthID sets the ID field of the mutation.
  37020. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  37021. return func(m *UsageStatisticMonthMutation) {
  37022. var (
  37023. err error
  37024. once sync.Once
  37025. value *UsageStatisticMonth
  37026. )
  37027. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  37028. once.Do(func() {
  37029. if m.done {
  37030. err = errors.New("querying old values post mutation is not allowed")
  37031. } else {
  37032. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  37033. }
  37034. })
  37035. return value, err
  37036. }
  37037. m.id = &id
  37038. }
  37039. }
  37040. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  37041. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  37042. return func(m *UsageStatisticMonthMutation) {
  37043. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  37044. return node, nil
  37045. }
  37046. m.id = &node.ID
  37047. }
  37048. }
  37049. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37050. // executed in a transaction (ent.Tx), a transactional client is returned.
  37051. func (m UsageStatisticMonthMutation) Client() *Client {
  37052. client := &Client{config: m.config}
  37053. client.init()
  37054. return client
  37055. }
  37056. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37057. // it returns an error otherwise.
  37058. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  37059. if _, ok := m.driver.(*txDriver); !ok {
  37060. return nil, errors.New("ent: mutation is not running in a transaction")
  37061. }
  37062. tx := &Tx{config: m.config}
  37063. tx.init()
  37064. return tx, nil
  37065. }
  37066. // SetID sets the value of the id field. Note that this
  37067. // operation is only accepted on creation of UsageStatisticMonth entities.
  37068. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  37069. m.id = &id
  37070. }
  37071. // ID returns the ID value in the mutation. Note that the ID is only available
  37072. // if it was provided to the builder or after it was returned from the database.
  37073. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  37074. if m.id == nil {
  37075. return
  37076. }
  37077. return *m.id, true
  37078. }
  37079. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37080. // That means, if the mutation is applied within a transaction with an isolation level such
  37081. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37082. // or updated by the mutation.
  37083. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  37084. switch {
  37085. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37086. id, exists := m.ID()
  37087. if exists {
  37088. return []uint64{id}, nil
  37089. }
  37090. fallthrough
  37091. case m.op.Is(OpUpdate | OpDelete):
  37092. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  37093. default:
  37094. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37095. }
  37096. }
  37097. // SetCreatedAt sets the "created_at" field.
  37098. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  37099. m.created_at = &t
  37100. }
  37101. // CreatedAt returns the value of the "created_at" field in the mutation.
  37102. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  37103. v := m.created_at
  37104. if v == nil {
  37105. return
  37106. }
  37107. return *v, true
  37108. }
  37109. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  37110. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37112. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37113. if !m.op.Is(OpUpdateOne) {
  37114. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37115. }
  37116. if m.id == nil || m.oldValue == nil {
  37117. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37118. }
  37119. oldValue, err := m.oldValue(ctx)
  37120. if err != nil {
  37121. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37122. }
  37123. return oldValue.CreatedAt, nil
  37124. }
  37125. // ResetCreatedAt resets all changes to the "created_at" field.
  37126. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  37127. m.created_at = nil
  37128. }
  37129. // SetUpdatedAt sets the "updated_at" field.
  37130. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  37131. m.updated_at = &t
  37132. }
  37133. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37134. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  37135. v := m.updated_at
  37136. if v == nil {
  37137. return
  37138. }
  37139. return *v, true
  37140. }
  37141. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  37142. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37144. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37145. if !m.op.Is(OpUpdateOne) {
  37146. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37147. }
  37148. if m.id == nil || m.oldValue == nil {
  37149. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37150. }
  37151. oldValue, err := m.oldValue(ctx)
  37152. if err != nil {
  37153. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37154. }
  37155. return oldValue.UpdatedAt, nil
  37156. }
  37157. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37158. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  37159. m.updated_at = nil
  37160. }
  37161. // SetStatus sets the "status" field.
  37162. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  37163. m.status = &u
  37164. m.addstatus = nil
  37165. }
  37166. // Status returns the value of the "status" field in the mutation.
  37167. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  37168. v := m.status
  37169. if v == nil {
  37170. return
  37171. }
  37172. return *v, true
  37173. }
  37174. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  37175. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37177. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37178. if !m.op.Is(OpUpdateOne) {
  37179. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37180. }
  37181. if m.id == nil || m.oldValue == nil {
  37182. return v, errors.New("OldStatus requires an ID field in the mutation")
  37183. }
  37184. oldValue, err := m.oldValue(ctx)
  37185. if err != nil {
  37186. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37187. }
  37188. return oldValue.Status, nil
  37189. }
  37190. // AddStatus adds u to the "status" field.
  37191. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  37192. if m.addstatus != nil {
  37193. *m.addstatus += u
  37194. } else {
  37195. m.addstatus = &u
  37196. }
  37197. }
  37198. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37199. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  37200. v := m.addstatus
  37201. if v == nil {
  37202. return
  37203. }
  37204. return *v, true
  37205. }
  37206. // ClearStatus clears the value of the "status" field.
  37207. func (m *UsageStatisticMonthMutation) ClearStatus() {
  37208. m.status = nil
  37209. m.addstatus = nil
  37210. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  37211. }
  37212. // StatusCleared returns if the "status" field was cleared in this mutation.
  37213. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  37214. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  37215. return ok
  37216. }
  37217. // ResetStatus resets all changes to the "status" field.
  37218. func (m *UsageStatisticMonthMutation) ResetStatus() {
  37219. m.status = nil
  37220. m.addstatus = nil
  37221. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  37222. }
  37223. // SetDeletedAt sets the "deleted_at" field.
  37224. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  37225. m.deleted_at = &t
  37226. }
  37227. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37228. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  37229. v := m.deleted_at
  37230. if v == nil {
  37231. return
  37232. }
  37233. return *v, true
  37234. }
  37235. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  37236. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37238. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37239. if !m.op.Is(OpUpdateOne) {
  37240. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37241. }
  37242. if m.id == nil || m.oldValue == nil {
  37243. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37244. }
  37245. oldValue, err := m.oldValue(ctx)
  37246. if err != nil {
  37247. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37248. }
  37249. return oldValue.DeletedAt, nil
  37250. }
  37251. // ClearDeletedAt clears the value of the "deleted_at" field.
  37252. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  37253. m.deleted_at = nil
  37254. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  37255. }
  37256. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37257. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  37258. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  37259. return ok
  37260. }
  37261. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37262. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  37263. m.deleted_at = nil
  37264. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  37265. }
  37266. // SetAddtime sets the "addtime" field.
  37267. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  37268. m.addtime = &u
  37269. m.addaddtime = nil
  37270. }
  37271. // Addtime returns the value of the "addtime" field in the mutation.
  37272. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  37273. v := m.addtime
  37274. if v == nil {
  37275. return
  37276. }
  37277. return *v, true
  37278. }
  37279. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  37280. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37282. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  37283. if !m.op.Is(OpUpdateOne) {
  37284. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  37285. }
  37286. if m.id == nil || m.oldValue == nil {
  37287. return v, errors.New("OldAddtime requires an ID field in the mutation")
  37288. }
  37289. oldValue, err := m.oldValue(ctx)
  37290. if err != nil {
  37291. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  37292. }
  37293. return oldValue.Addtime, nil
  37294. }
  37295. // AddAddtime adds u to the "addtime" field.
  37296. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  37297. if m.addaddtime != nil {
  37298. *m.addaddtime += u
  37299. } else {
  37300. m.addaddtime = &u
  37301. }
  37302. }
  37303. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  37304. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  37305. v := m.addaddtime
  37306. if v == nil {
  37307. return
  37308. }
  37309. return *v, true
  37310. }
  37311. // ResetAddtime resets all changes to the "addtime" field.
  37312. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  37313. m.addtime = nil
  37314. m.addaddtime = nil
  37315. }
  37316. // SetType sets the "type" field.
  37317. func (m *UsageStatisticMonthMutation) SetType(i int) {
  37318. m._type = &i
  37319. m.add_type = nil
  37320. }
  37321. // GetType returns the value of the "type" field in the mutation.
  37322. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  37323. v := m._type
  37324. if v == nil {
  37325. return
  37326. }
  37327. return *v, true
  37328. }
  37329. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  37330. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37332. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  37333. if !m.op.Is(OpUpdateOne) {
  37334. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37335. }
  37336. if m.id == nil || m.oldValue == nil {
  37337. return v, errors.New("OldType requires an ID field in the mutation")
  37338. }
  37339. oldValue, err := m.oldValue(ctx)
  37340. if err != nil {
  37341. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37342. }
  37343. return oldValue.Type, nil
  37344. }
  37345. // AddType adds i to the "type" field.
  37346. func (m *UsageStatisticMonthMutation) AddType(i int) {
  37347. if m.add_type != nil {
  37348. *m.add_type += i
  37349. } else {
  37350. m.add_type = &i
  37351. }
  37352. }
  37353. // AddedType returns the value that was added to the "type" field in this mutation.
  37354. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  37355. v := m.add_type
  37356. if v == nil {
  37357. return
  37358. }
  37359. return *v, true
  37360. }
  37361. // ResetType resets all changes to the "type" field.
  37362. func (m *UsageStatisticMonthMutation) ResetType() {
  37363. m._type = nil
  37364. m.add_type = nil
  37365. }
  37366. // SetBotID sets the "bot_id" field.
  37367. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  37368. m.bot_id = &s
  37369. }
  37370. // BotID returns the value of the "bot_id" field in the mutation.
  37371. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  37372. v := m.bot_id
  37373. if v == nil {
  37374. return
  37375. }
  37376. return *v, true
  37377. }
  37378. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  37379. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37381. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  37382. if !m.op.Is(OpUpdateOne) {
  37383. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37384. }
  37385. if m.id == nil || m.oldValue == nil {
  37386. return v, errors.New("OldBotID requires an ID field in the mutation")
  37387. }
  37388. oldValue, err := m.oldValue(ctx)
  37389. if err != nil {
  37390. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37391. }
  37392. return oldValue.BotID, nil
  37393. }
  37394. // ClearBotID clears the value of the "bot_id" field.
  37395. func (m *UsageStatisticMonthMutation) ClearBotID() {
  37396. m.bot_id = nil
  37397. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  37398. }
  37399. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  37400. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  37401. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  37402. return ok
  37403. }
  37404. // ResetBotID resets all changes to the "bot_id" field.
  37405. func (m *UsageStatisticMonthMutation) ResetBotID() {
  37406. m.bot_id = nil
  37407. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  37408. }
  37409. // SetOrganizationID sets the "organization_id" field.
  37410. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  37411. m.organization_id = &u
  37412. m.addorganization_id = nil
  37413. }
  37414. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37415. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  37416. v := m.organization_id
  37417. if v == nil {
  37418. return
  37419. }
  37420. return *v, true
  37421. }
  37422. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  37423. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37425. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37426. if !m.op.Is(OpUpdateOne) {
  37427. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37428. }
  37429. if m.id == nil || m.oldValue == nil {
  37430. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37431. }
  37432. oldValue, err := m.oldValue(ctx)
  37433. if err != nil {
  37434. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37435. }
  37436. return oldValue.OrganizationID, nil
  37437. }
  37438. // AddOrganizationID adds u to the "organization_id" field.
  37439. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  37440. if m.addorganization_id != nil {
  37441. *m.addorganization_id += u
  37442. } else {
  37443. m.addorganization_id = &u
  37444. }
  37445. }
  37446. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37447. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  37448. v := m.addorganization_id
  37449. if v == nil {
  37450. return
  37451. }
  37452. return *v, true
  37453. }
  37454. // ClearOrganizationID clears the value of the "organization_id" field.
  37455. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  37456. m.organization_id = nil
  37457. m.addorganization_id = nil
  37458. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  37459. }
  37460. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37461. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  37462. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  37463. return ok
  37464. }
  37465. // ResetOrganizationID resets all changes to the "organization_id" field.
  37466. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  37467. m.organization_id = nil
  37468. m.addorganization_id = nil
  37469. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  37470. }
  37471. // SetAiResponse sets the "ai_response" field.
  37472. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  37473. m.ai_response = &u
  37474. m.addai_response = nil
  37475. }
  37476. // AiResponse returns the value of the "ai_response" field in the mutation.
  37477. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  37478. v := m.ai_response
  37479. if v == nil {
  37480. return
  37481. }
  37482. return *v, true
  37483. }
  37484. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  37485. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37487. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  37488. if !m.op.Is(OpUpdateOne) {
  37489. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  37490. }
  37491. if m.id == nil || m.oldValue == nil {
  37492. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  37493. }
  37494. oldValue, err := m.oldValue(ctx)
  37495. if err != nil {
  37496. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  37497. }
  37498. return oldValue.AiResponse, nil
  37499. }
  37500. // AddAiResponse adds u to the "ai_response" field.
  37501. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  37502. if m.addai_response != nil {
  37503. *m.addai_response += u
  37504. } else {
  37505. m.addai_response = &u
  37506. }
  37507. }
  37508. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  37509. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  37510. v := m.addai_response
  37511. if v == nil {
  37512. return
  37513. }
  37514. return *v, true
  37515. }
  37516. // ResetAiResponse resets all changes to the "ai_response" field.
  37517. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  37518. m.ai_response = nil
  37519. m.addai_response = nil
  37520. }
  37521. // SetSopRun sets the "sop_run" field.
  37522. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  37523. m.sop_run = &u
  37524. m.addsop_run = nil
  37525. }
  37526. // SopRun returns the value of the "sop_run" field in the mutation.
  37527. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  37528. v := m.sop_run
  37529. if v == nil {
  37530. return
  37531. }
  37532. return *v, true
  37533. }
  37534. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  37535. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37537. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  37538. if !m.op.Is(OpUpdateOne) {
  37539. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  37540. }
  37541. if m.id == nil || m.oldValue == nil {
  37542. return v, errors.New("OldSopRun requires an ID field in the mutation")
  37543. }
  37544. oldValue, err := m.oldValue(ctx)
  37545. if err != nil {
  37546. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  37547. }
  37548. return oldValue.SopRun, nil
  37549. }
  37550. // AddSopRun adds u to the "sop_run" field.
  37551. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  37552. if m.addsop_run != nil {
  37553. *m.addsop_run += u
  37554. } else {
  37555. m.addsop_run = &u
  37556. }
  37557. }
  37558. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  37559. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  37560. v := m.addsop_run
  37561. if v == nil {
  37562. return
  37563. }
  37564. return *v, true
  37565. }
  37566. // ResetSopRun resets all changes to the "sop_run" field.
  37567. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  37568. m.sop_run = nil
  37569. m.addsop_run = nil
  37570. }
  37571. // SetTotalFriend sets the "total_friend" field.
  37572. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  37573. m.total_friend = &u
  37574. m.addtotal_friend = nil
  37575. }
  37576. // TotalFriend returns the value of the "total_friend" field in the mutation.
  37577. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  37578. v := m.total_friend
  37579. if v == nil {
  37580. return
  37581. }
  37582. return *v, true
  37583. }
  37584. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  37585. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37587. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  37588. if !m.op.Is(OpUpdateOne) {
  37589. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  37590. }
  37591. if m.id == nil || m.oldValue == nil {
  37592. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  37593. }
  37594. oldValue, err := m.oldValue(ctx)
  37595. if err != nil {
  37596. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  37597. }
  37598. return oldValue.TotalFriend, nil
  37599. }
  37600. // AddTotalFriend adds u to the "total_friend" field.
  37601. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  37602. if m.addtotal_friend != nil {
  37603. *m.addtotal_friend += u
  37604. } else {
  37605. m.addtotal_friend = &u
  37606. }
  37607. }
  37608. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  37609. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  37610. v := m.addtotal_friend
  37611. if v == nil {
  37612. return
  37613. }
  37614. return *v, true
  37615. }
  37616. // ResetTotalFriend resets all changes to the "total_friend" field.
  37617. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  37618. m.total_friend = nil
  37619. m.addtotal_friend = nil
  37620. }
  37621. // SetTotalGroup sets the "total_group" field.
  37622. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  37623. m.total_group = &u
  37624. m.addtotal_group = nil
  37625. }
  37626. // TotalGroup returns the value of the "total_group" field in the mutation.
  37627. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  37628. v := m.total_group
  37629. if v == nil {
  37630. return
  37631. }
  37632. return *v, true
  37633. }
  37634. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  37635. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37637. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  37638. if !m.op.Is(OpUpdateOne) {
  37639. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  37640. }
  37641. if m.id == nil || m.oldValue == nil {
  37642. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  37643. }
  37644. oldValue, err := m.oldValue(ctx)
  37645. if err != nil {
  37646. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  37647. }
  37648. return oldValue.TotalGroup, nil
  37649. }
  37650. // AddTotalGroup adds u to the "total_group" field.
  37651. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  37652. if m.addtotal_group != nil {
  37653. *m.addtotal_group += u
  37654. } else {
  37655. m.addtotal_group = &u
  37656. }
  37657. }
  37658. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  37659. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  37660. v := m.addtotal_group
  37661. if v == nil {
  37662. return
  37663. }
  37664. return *v, true
  37665. }
  37666. // ResetTotalGroup resets all changes to the "total_group" field.
  37667. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  37668. m.total_group = nil
  37669. m.addtotal_group = nil
  37670. }
  37671. // SetAccountBalance sets the "account_balance" field.
  37672. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  37673. m.account_balance = &u
  37674. m.addaccount_balance = nil
  37675. }
  37676. // AccountBalance returns the value of the "account_balance" field in the mutation.
  37677. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  37678. v := m.account_balance
  37679. if v == nil {
  37680. return
  37681. }
  37682. return *v, true
  37683. }
  37684. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  37685. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37687. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  37688. if !m.op.Is(OpUpdateOne) {
  37689. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  37690. }
  37691. if m.id == nil || m.oldValue == nil {
  37692. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  37693. }
  37694. oldValue, err := m.oldValue(ctx)
  37695. if err != nil {
  37696. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  37697. }
  37698. return oldValue.AccountBalance, nil
  37699. }
  37700. // AddAccountBalance adds u to the "account_balance" field.
  37701. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  37702. if m.addaccount_balance != nil {
  37703. *m.addaccount_balance += u
  37704. } else {
  37705. m.addaccount_balance = &u
  37706. }
  37707. }
  37708. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  37709. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  37710. v := m.addaccount_balance
  37711. if v == nil {
  37712. return
  37713. }
  37714. return *v, true
  37715. }
  37716. // ResetAccountBalance resets all changes to the "account_balance" field.
  37717. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  37718. m.account_balance = nil
  37719. m.addaccount_balance = nil
  37720. }
  37721. // SetConsumeToken sets the "consume_token" field.
  37722. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  37723. m.consume_token = &u
  37724. m.addconsume_token = nil
  37725. }
  37726. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  37727. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  37728. v := m.consume_token
  37729. if v == nil {
  37730. return
  37731. }
  37732. return *v, true
  37733. }
  37734. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  37735. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37737. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  37738. if !m.op.Is(OpUpdateOne) {
  37739. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  37740. }
  37741. if m.id == nil || m.oldValue == nil {
  37742. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  37743. }
  37744. oldValue, err := m.oldValue(ctx)
  37745. if err != nil {
  37746. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  37747. }
  37748. return oldValue.ConsumeToken, nil
  37749. }
  37750. // AddConsumeToken adds u to the "consume_token" field.
  37751. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  37752. if m.addconsume_token != nil {
  37753. *m.addconsume_token += u
  37754. } else {
  37755. m.addconsume_token = &u
  37756. }
  37757. }
  37758. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  37759. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  37760. v := m.addconsume_token
  37761. if v == nil {
  37762. return
  37763. }
  37764. return *v, true
  37765. }
  37766. // ResetConsumeToken resets all changes to the "consume_token" field.
  37767. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  37768. m.consume_token = nil
  37769. m.addconsume_token = nil
  37770. }
  37771. // SetActiveUser sets the "active_user" field.
  37772. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  37773. m.active_user = &u
  37774. m.addactive_user = nil
  37775. }
  37776. // ActiveUser returns the value of the "active_user" field in the mutation.
  37777. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  37778. v := m.active_user
  37779. if v == nil {
  37780. return
  37781. }
  37782. return *v, true
  37783. }
  37784. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  37785. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37787. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  37788. if !m.op.Is(OpUpdateOne) {
  37789. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  37790. }
  37791. if m.id == nil || m.oldValue == nil {
  37792. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  37793. }
  37794. oldValue, err := m.oldValue(ctx)
  37795. if err != nil {
  37796. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  37797. }
  37798. return oldValue.ActiveUser, nil
  37799. }
  37800. // AddActiveUser adds u to the "active_user" field.
  37801. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  37802. if m.addactive_user != nil {
  37803. *m.addactive_user += u
  37804. } else {
  37805. m.addactive_user = &u
  37806. }
  37807. }
  37808. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  37809. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  37810. v := m.addactive_user
  37811. if v == nil {
  37812. return
  37813. }
  37814. return *v, true
  37815. }
  37816. // ResetActiveUser resets all changes to the "active_user" field.
  37817. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  37818. m.active_user = nil
  37819. m.addactive_user = nil
  37820. }
  37821. // SetNewUser sets the "new_user" field.
  37822. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  37823. m.new_user = &i
  37824. m.addnew_user = nil
  37825. }
  37826. // NewUser returns the value of the "new_user" field in the mutation.
  37827. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  37828. v := m.new_user
  37829. if v == nil {
  37830. return
  37831. }
  37832. return *v, true
  37833. }
  37834. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  37835. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37837. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  37838. if !m.op.Is(OpUpdateOne) {
  37839. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  37840. }
  37841. if m.id == nil || m.oldValue == nil {
  37842. return v, errors.New("OldNewUser requires an ID field in the mutation")
  37843. }
  37844. oldValue, err := m.oldValue(ctx)
  37845. if err != nil {
  37846. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  37847. }
  37848. return oldValue.NewUser, nil
  37849. }
  37850. // AddNewUser adds i to the "new_user" field.
  37851. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  37852. if m.addnew_user != nil {
  37853. *m.addnew_user += i
  37854. } else {
  37855. m.addnew_user = &i
  37856. }
  37857. }
  37858. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  37859. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  37860. v := m.addnew_user
  37861. if v == nil {
  37862. return
  37863. }
  37864. return *v, true
  37865. }
  37866. // ResetNewUser resets all changes to the "new_user" field.
  37867. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  37868. m.new_user = nil
  37869. m.addnew_user = nil
  37870. }
  37871. // SetLabelDist sets the "label_dist" field.
  37872. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  37873. m.label_dist = &ctd
  37874. m.appendlabel_dist = nil
  37875. }
  37876. // LabelDist returns the value of the "label_dist" field in the mutation.
  37877. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  37878. v := m.label_dist
  37879. if v == nil {
  37880. return
  37881. }
  37882. return *v, true
  37883. }
  37884. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  37885. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  37886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37887. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  37888. if !m.op.Is(OpUpdateOne) {
  37889. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  37890. }
  37891. if m.id == nil || m.oldValue == nil {
  37892. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  37893. }
  37894. oldValue, err := m.oldValue(ctx)
  37895. if err != nil {
  37896. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  37897. }
  37898. return oldValue.LabelDist, nil
  37899. }
  37900. // AppendLabelDist adds ctd to the "label_dist" field.
  37901. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  37902. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  37903. }
  37904. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  37905. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  37906. if len(m.appendlabel_dist) == 0 {
  37907. return nil, false
  37908. }
  37909. return m.appendlabel_dist, true
  37910. }
  37911. // ResetLabelDist resets all changes to the "label_dist" field.
  37912. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  37913. m.label_dist = nil
  37914. m.appendlabel_dist = nil
  37915. }
  37916. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  37917. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  37918. m.predicates = append(m.predicates, ps...)
  37919. }
  37920. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  37921. // users can use type-assertion to append predicates that do not depend on any generated package.
  37922. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  37923. p := make([]predicate.UsageStatisticMonth, len(ps))
  37924. for i := range ps {
  37925. p[i] = ps[i]
  37926. }
  37927. m.Where(p...)
  37928. }
  37929. // Op returns the operation name.
  37930. func (m *UsageStatisticMonthMutation) Op() Op {
  37931. return m.op
  37932. }
  37933. // SetOp allows setting the mutation operation.
  37934. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  37935. m.op = op
  37936. }
  37937. // Type returns the node type of this mutation (UsageStatisticMonth).
  37938. func (m *UsageStatisticMonthMutation) Type() string {
  37939. return m.typ
  37940. }
  37941. // Fields returns all fields that were changed during this mutation. Note that in
  37942. // order to get all numeric fields that were incremented/decremented, call
  37943. // AddedFields().
  37944. func (m *UsageStatisticMonthMutation) Fields() []string {
  37945. fields := make([]string, 0, 17)
  37946. if m.created_at != nil {
  37947. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  37948. }
  37949. if m.updated_at != nil {
  37950. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  37951. }
  37952. if m.status != nil {
  37953. fields = append(fields, usagestatisticmonth.FieldStatus)
  37954. }
  37955. if m.deleted_at != nil {
  37956. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  37957. }
  37958. if m.addtime != nil {
  37959. fields = append(fields, usagestatisticmonth.FieldAddtime)
  37960. }
  37961. if m._type != nil {
  37962. fields = append(fields, usagestatisticmonth.FieldType)
  37963. }
  37964. if m.bot_id != nil {
  37965. fields = append(fields, usagestatisticmonth.FieldBotID)
  37966. }
  37967. if m.organization_id != nil {
  37968. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  37969. }
  37970. if m.ai_response != nil {
  37971. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  37972. }
  37973. if m.sop_run != nil {
  37974. fields = append(fields, usagestatisticmonth.FieldSopRun)
  37975. }
  37976. if m.total_friend != nil {
  37977. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  37978. }
  37979. if m.total_group != nil {
  37980. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  37981. }
  37982. if m.account_balance != nil {
  37983. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  37984. }
  37985. if m.consume_token != nil {
  37986. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  37987. }
  37988. if m.active_user != nil {
  37989. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  37990. }
  37991. if m.new_user != nil {
  37992. fields = append(fields, usagestatisticmonth.FieldNewUser)
  37993. }
  37994. if m.label_dist != nil {
  37995. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  37996. }
  37997. return fields
  37998. }
  37999. // Field returns the value of a field with the given name. The second boolean
  38000. // return value indicates that this field was not set, or was not defined in the
  38001. // schema.
  38002. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  38003. switch name {
  38004. case usagestatisticmonth.FieldCreatedAt:
  38005. return m.CreatedAt()
  38006. case usagestatisticmonth.FieldUpdatedAt:
  38007. return m.UpdatedAt()
  38008. case usagestatisticmonth.FieldStatus:
  38009. return m.Status()
  38010. case usagestatisticmonth.FieldDeletedAt:
  38011. return m.DeletedAt()
  38012. case usagestatisticmonth.FieldAddtime:
  38013. return m.Addtime()
  38014. case usagestatisticmonth.FieldType:
  38015. return m.GetType()
  38016. case usagestatisticmonth.FieldBotID:
  38017. return m.BotID()
  38018. case usagestatisticmonth.FieldOrganizationID:
  38019. return m.OrganizationID()
  38020. case usagestatisticmonth.FieldAiResponse:
  38021. return m.AiResponse()
  38022. case usagestatisticmonth.FieldSopRun:
  38023. return m.SopRun()
  38024. case usagestatisticmonth.FieldTotalFriend:
  38025. return m.TotalFriend()
  38026. case usagestatisticmonth.FieldTotalGroup:
  38027. return m.TotalGroup()
  38028. case usagestatisticmonth.FieldAccountBalance:
  38029. return m.AccountBalance()
  38030. case usagestatisticmonth.FieldConsumeToken:
  38031. return m.ConsumeToken()
  38032. case usagestatisticmonth.FieldActiveUser:
  38033. return m.ActiveUser()
  38034. case usagestatisticmonth.FieldNewUser:
  38035. return m.NewUser()
  38036. case usagestatisticmonth.FieldLabelDist:
  38037. return m.LabelDist()
  38038. }
  38039. return nil, false
  38040. }
  38041. // OldField returns the old value of the field from the database. An error is
  38042. // returned if the mutation operation is not UpdateOne, or the query to the
  38043. // database failed.
  38044. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38045. switch name {
  38046. case usagestatisticmonth.FieldCreatedAt:
  38047. return m.OldCreatedAt(ctx)
  38048. case usagestatisticmonth.FieldUpdatedAt:
  38049. return m.OldUpdatedAt(ctx)
  38050. case usagestatisticmonth.FieldStatus:
  38051. return m.OldStatus(ctx)
  38052. case usagestatisticmonth.FieldDeletedAt:
  38053. return m.OldDeletedAt(ctx)
  38054. case usagestatisticmonth.FieldAddtime:
  38055. return m.OldAddtime(ctx)
  38056. case usagestatisticmonth.FieldType:
  38057. return m.OldType(ctx)
  38058. case usagestatisticmonth.FieldBotID:
  38059. return m.OldBotID(ctx)
  38060. case usagestatisticmonth.FieldOrganizationID:
  38061. return m.OldOrganizationID(ctx)
  38062. case usagestatisticmonth.FieldAiResponse:
  38063. return m.OldAiResponse(ctx)
  38064. case usagestatisticmonth.FieldSopRun:
  38065. return m.OldSopRun(ctx)
  38066. case usagestatisticmonth.FieldTotalFriend:
  38067. return m.OldTotalFriend(ctx)
  38068. case usagestatisticmonth.FieldTotalGroup:
  38069. return m.OldTotalGroup(ctx)
  38070. case usagestatisticmonth.FieldAccountBalance:
  38071. return m.OldAccountBalance(ctx)
  38072. case usagestatisticmonth.FieldConsumeToken:
  38073. return m.OldConsumeToken(ctx)
  38074. case usagestatisticmonth.FieldActiveUser:
  38075. return m.OldActiveUser(ctx)
  38076. case usagestatisticmonth.FieldNewUser:
  38077. return m.OldNewUser(ctx)
  38078. case usagestatisticmonth.FieldLabelDist:
  38079. return m.OldLabelDist(ctx)
  38080. }
  38081. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38082. }
  38083. // SetField sets the value of a field with the given name. It returns an error if
  38084. // the field is not defined in the schema, or if the type mismatched the field
  38085. // type.
  38086. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  38087. switch name {
  38088. case usagestatisticmonth.FieldCreatedAt:
  38089. v, ok := value.(time.Time)
  38090. if !ok {
  38091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38092. }
  38093. m.SetCreatedAt(v)
  38094. return nil
  38095. case usagestatisticmonth.FieldUpdatedAt:
  38096. v, ok := value.(time.Time)
  38097. if !ok {
  38098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38099. }
  38100. m.SetUpdatedAt(v)
  38101. return nil
  38102. case usagestatisticmonth.FieldStatus:
  38103. v, ok := value.(uint8)
  38104. if !ok {
  38105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38106. }
  38107. m.SetStatus(v)
  38108. return nil
  38109. case usagestatisticmonth.FieldDeletedAt:
  38110. v, ok := value.(time.Time)
  38111. if !ok {
  38112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38113. }
  38114. m.SetDeletedAt(v)
  38115. return nil
  38116. case usagestatisticmonth.FieldAddtime:
  38117. v, ok := value.(uint64)
  38118. if !ok {
  38119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38120. }
  38121. m.SetAddtime(v)
  38122. return nil
  38123. case usagestatisticmonth.FieldType:
  38124. v, ok := value.(int)
  38125. if !ok {
  38126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38127. }
  38128. m.SetType(v)
  38129. return nil
  38130. case usagestatisticmonth.FieldBotID:
  38131. v, ok := value.(string)
  38132. if !ok {
  38133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38134. }
  38135. m.SetBotID(v)
  38136. return nil
  38137. case usagestatisticmonth.FieldOrganizationID:
  38138. v, ok := value.(uint64)
  38139. if !ok {
  38140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38141. }
  38142. m.SetOrganizationID(v)
  38143. return nil
  38144. case usagestatisticmonth.FieldAiResponse:
  38145. v, ok := value.(uint64)
  38146. if !ok {
  38147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38148. }
  38149. m.SetAiResponse(v)
  38150. return nil
  38151. case usagestatisticmonth.FieldSopRun:
  38152. v, ok := value.(uint64)
  38153. if !ok {
  38154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38155. }
  38156. m.SetSopRun(v)
  38157. return nil
  38158. case usagestatisticmonth.FieldTotalFriend:
  38159. v, ok := value.(uint64)
  38160. if !ok {
  38161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38162. }
  38163. m.SetTotalFriend(v)
  38164. return nil
  38165. case usagestatisticmonth.FieldTotalGroup:
  38166. v, ok := value.(uint64)
  38167. if !ok {
  38168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38169. }
  38170. m.SetTotalGroup(v)
  38171. return nil
  38172. case usagestatisticmonth.FieldAccountBalance:
  38173. v, ok := value.(uint64)
  38174. if !ok {
  38175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38176. }
  38177. m.SetAccountBalance(v)
  38178. return nil
  38179. case usagestatisticmonth.FieldConsumeToken:
  38180. v, ok := value.(uint64)
  38181. if !ok {
  38182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38183. }
  38184. m.SetConsumeToken(v)
  38185. return nil
  38186. case usagestatisticmonth.FieldActiveUser:
  38187. v, ok := value.(uint64)
  38188. if !ok {
  38189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38190. }
  38191. m.SetActiveUser(v)
  38192. return nil
  38193. case usagestatisticmonth.FieldNewUser:
  38194. v, ok := value.(int64)
  38195. if !ok {
  38196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38197. }
  38198. m.SetNewUser(v)
  38199. return nil
  38200. case usagestatisticmonth.FieldLabelDist:
  38201. v, ok := value.([]custom_types.LabelDist)
  38202. if !ok {
  38203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38204. }
  38205. m.SetLabelDist(v)
  38206. return nil
  38207. }
  38208. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38209. }
  38210. // AddedFields returns all numeric fields that were incremented/decremented during
  38211. // this mutation.
  38212. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  38213. var fields []string
  38214. if m.addstatus != nil {
  38215. fields = append(fields, usagestatisticmonth.FieldStatus)
  38216. }
  38217. if m.addaddtime != nil {
  38218. fields = append(fields, usagestatisticmonth.FieldAddtime)
  38219. }
  38220. if m.add_type != nil {
  38221. fields = append(fields, usagestatisticmonth.FieldType)
  38222. }
  38223. if m.addorganization_id != nil {
  38224. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  38225. }
  38226. if m.addai_response != nil {
  38227. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  38228. }
  38229. if m.addsop_run != nil {
  38230. fields = append(fields, usagestatisticmonth.FieldSopRun)
  38231. }
  38232. if m.addtotal_friend != nil {
  38233. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  38234. }
  38235. if m.addtotal_group != nil {
  38236. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  38237. }
  38238. if m.addaccount_balance != nil {
  38239. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  38240. }
  38241. if m.addconsume_token != nil {
  38242. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  38243. }
  38244. if m.addactive_user != nil {
  38245. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  38246. }
  38247. if m.addnew_user != nil {
  38248. fields = append(fields, usagestatisticmonth.FieldNewUser)
  38249. }
  38250. return fields
  38251. }
  38252. // AddedField returns the numeric value that was incremented/decremented on a field
  38253. // with the given name. The second boolean return value indicates that this field
  38254. // was not set, or was not defined in the schema.
  38255. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  38256. switch name {
  38257. case usagestatisticmonth.FieldStatus:
  38258. return m.AddedStatus()
  38259. case usagestatisticmonth.FieldAddtime:
  38260. return m.AddedAddtime()
  38261. case usagestatisticmonth.FieldType:
  38262. return m.AddedType()
  38263. case usagestatisticmonth.FieldOrganizationID:
  38264. return m.AddedOrganizationID()
  38265. case usagestatisticmonth.FieldAiResponse:
  38266. return m.AddedAiResponse()
  38267. case usagestatisticmonth.FieldSopRun:
  38268. return m.AddedSopRun()
  38269. case usagestatisticmonth.FieldTotalFriend:
  38270. return m.AddedTotalFriend()
  38271. case usagestatisticmonth.FieldTotalGroup:
  38272. return m.AddedTotalGroup()
  38273. case usagestatisticmonth.FieldAccountBalance:
  38274. return m.AddedAccountBalance()
  38275. case usagestatisticmonth.FieldConsumeToken:
  38276. return m.AddedConsumeToken()
  38277. case usagestatisticmonth.FieldActiveUser:
  38278. return m.AddedActiveUser()
  38279. case usagestatisticmonth.FieldNewUser:
  38280. return m.AddedNewUser()
  38281. }
  38282. return nil, false
  38283. }
  38284. // AddField adds the value to the field with the given name. It returns an error if
  38285. // the field is not defined in the schema, or if the type mismatched the field
  38286. // type.
  38287. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  38288. switch name {
  38289. case usagestatisticmonth.FieldStatus:
  38290. v, ok := value.(int8)
  38291. if !ok {
  38292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38293. }
  38294. m.AddStatus(v)
  38295. return nil
  38296. case usagestatisticmonth.FieldAddtime:
  38297. v, ok := value.(int64)
  38298. if !ok {
  38299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38300. }
  38301. m.AddAddtime(v)
  38302. return nil
  38303. case usagestatisticmonth.FieldType:
  38304. v, ok := value.(int)
  38305. if !ok {
  38306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38307. }
  38308. m.AddType(v)
  38309. return nil
  38310. case usagestatisticmonth.FieldOrganizationID:
  38311. v, ok := value.(int64)
  38312. if !ok {
  38313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38314. }
  38315. m.AddOrganizationID(v)
  38316. return nil
  38317. case usagestatisticmonth.FieldAiResponse:
  38318. v, ok := value.(int64)
  38319. if !ok {
  38320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38321. }
  38322. m.AddAiResponse(v)
  38323. return nil
  38324. case usagestatisticmonth.FieldSopRun:
  38325. v, ok := value.(int64)
  38326. if !ok {
  38327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38328. }
  38329. m.AddSopRun(v)
  38330. return nil
  38331. case usagestatisticmonth.FieldTotalFriend:
  38332. v, ok := value.(int64)
  38333. if !ok {
  38334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38335. }
  38336. m.AddTotalFriend(v)
  38337. return nil
  38338. case usagestatisticmonth.FieldTotalGroup:
  38339. v, ok := value.(int64)
  38340. if !ok {
  38341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38342. }
  38343. m.AddTotalGroup(v)
  38344. return nil
  38345. case usagestatisticmonth.FieldAccountBalance:
  38346. v, ok := value.(int64)
  38347. if !ok {
  38348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38349. }
  38350. m.AddAccountBalance(v)
  38351. return nil
  38352. case usagestatisticmonth.FieldConsumeToken:
  38353. v, ok := value.(int64)
  38354. if !ok {
  38355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38356. }
  38357. m.AddConsumeToken(v)
  38358. return nil
  38359. case usagestatisticmonth.FieldActiveUser:
  38360. v, ok := value.(int64)
  38361. if !ok {
  38362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38363. }
  38364. m.AddActiveUser(v)
  38365. return nil
  38366. case usagestatisticmonth.FieldNewUser:
  38367. v, ok := value.(int64)
  38368. if !ok {
  38369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38370. }
  38371. m.AddNewUser(v)
  38372. return nil
  38373. }
  38374. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  38375. }
  38376. // ClearedFields returns all nullable fields that were cleared during this
  38377. // mutation.
  38378. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  38379. var fields []string
  38380. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  38381. fields = append(fields, usagestatisticmonth.FieldStatus)
  38382. }
  38383. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  38384. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  38385. }
  38386. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  38387. fields = append(fields, usagestatisticmonth.FieldBotID)
  38388. }
  38389. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  38390. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  38391. }
  38392. return fields
  38393. }
  38394. // FieldCleared returns a boolean indicating if a field with the given name was
  38395. // cleared in this mutation.
  38396. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  38397. _, ok := m.clearedFields[name]
  38398. return ok
  38399. }
  38400. // ClearField clears the value of the field with the given name. It returns an
  38401. // error if the field is not defined in the schema.
  38402. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  38403. switch name {
  38404. case usagestatisticmonth.FieldStatus:
  38405. m.ClearStatus()
  38406. return nil
  38407. case usagestatisticmonth.FieldDeletedAt:
  38408. m.ClearDeletedAt()
  38409. return nil
  38410. case usagestatisticmonth.FieldBotID:
  38411. m.ClearBotID()
  38412. return nil
  38413. case usagestatisticmonth.FieldOrganizationID:
  38414. m.ClearOrganizationID()
  38415. return nil
  38416. }
  38417. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  38418. }
  38419. // ResetField resets all changes in the mutation for the field with the given name.
  38420. // It returns an error if the field is not defined in the schema.
  38421. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  38422. switch name {
  38423. case usagestatisticmonth.FieldCreatedAt:
  38424. m.ResetCreatedAt()
  38425. return nil
  38426. case usagestatisticmonth.FieldUpdatedAt:
  38427. m.ResetUpdatedAt()
  38428. return nil
  38429. case usagestatisticmonth.FieldStatus:
  38430. m.ResetStatus()
  38431. return nil
  38432. case usagestatisticmonth.FieldDeletedAt:
  38433. m.ResetDeletedAt()
  38434. return nil
  38435. case usagestatisticmonth.FieldAddtime:
  38436. m.ResetAddtime()
  38437. return nil
  38438. case usagestatisticmonth.FieldType:
  38439. m.ResetType()
  38440. return nil
  38441. case usagestatisticmonth.FieldBotID:
  38442. m.ResetBotID()
  38443. return nil
  38444. case usagestatisticmonth.FieldOrganizationID:
  38445. m.ResetOrganizationID()
  38446. return nil
  38447. case usagestatisticmonth.FieldAiResponse:
  38448. m.ResetAiResponse()
  38449. return nil
  38450. case usagestatisticmonth.FieldSopRun:
  38451. m.ResetSopRun()
  38452. return nil
  38453. case usagestatisticmonth.FieldTotalFriend:
  38454. m.ResetTotalFriend()
  38455. return nil
  38456. case usagestatisticmonth.FieldTotalGroup:
  38457. m.ResetTotalGroup()
  38458. return nil
  38459. case usagestatisticmonth.FieldAccountBalance:
  38460. m.ResetAccountBalance()
  38461. return nil
  38462. case usagestatisticmonth.FieldConsumeToken:
  38463. m.ResetConsumeToken()
  38464. return nil
  38465. case usagestatisticmonth.FieldActiveUser:
  38466. m.ResetActiveUser()
  38467. return nil
  38468. case usagestatisticmonth.FieldNewUser:
  38469. m.ResetNewUser()
  38470. return nil
  38471. case usagestatisticmonth.FieldLabelDist:
  38472. m.ResetLabelDist()
  38473. return nil
  38474. }
  38475. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  38476. }
  38477. // AddedEdges returns all edge names that were set/added in this mutation.
  38478. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  38479. edges := make([]string, 0, 0)
  38480. return edges
  38481. }
  38482. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38483. // name in this mutation.
  38484. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  38485. return nil
  38486. }
  38487. // RemovedEdges returns all edge names that were removed in this mutation.
  38488. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  38489. edges := make([]string, 0, 0)
  38490. return edges
  38491. }
  38492. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38493. // the given name in this mutation.
  38494. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  38495. return nil
  38496. }
  38497. // ClearedEdges returns all edge names that were cleared in this mutation.
  38498. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  38499. edges := make([]string, 0, 0)
  38500. return edges
  38501. }
  38502. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38503. // was cleared in this mutation.
  38504. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  38505. return false
  38506. }
  38507. // ClearEdge clears the value of the edge with the given name. It returns an error
  38508. // if that edge is not defined in the schema.
  38509. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  38510. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  38511. }
  38512. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38513. // It returns an error if the edge is not defined in the schema.
  38514. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  38515. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  38516. }
  38517. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  38518. type UsageTotalMutation struct {
  38519. config
  38520. op Op
  38521. typ string
  38522. id *uint64
  38523. created_at *time.Time
  38524. updated_at *time.Time
  38525. status *uint8
  38526. addstatus *int8
  38527. _type *int
  38528. add_type *int
  38529. bot_id *string
  38530. total_tokens *uint64
  38531. addtotal_tokens *int64
  38532. start_index *uint64
  38533. addstart_index *int64
  38534. end_index *uint64
  38535. addend_index *int64
  38536. organization_id *uint64
  38537. addorganization_id *int64
  38538. clearedFields map[string]struct{}
  38539. done bool
  38540. oldValue func(context.Context) (*UsageTotal, error)
  38541. predicates []predicate.UsageTotal
  38542. }
  38543. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  38544. // usagetotalOption allows management of the mutation configuration using functional options.
  38545. type usagetotalOption func(*UsageTotalMutation)
  38546. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  38547. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  38548. m := &UsageTotalMutation{
  38549. config: c,
  38550. op: op,
  38551. typ: TypeUsageTotal,
  38552. clearedFields: make(map[string]struct{}),
  38553. }
  38554. for _, opt := range opts {
  38555. opt(m)
  38556. }
  38557. return m
  38558. }
  38559. // withUsageTotalID sets the ID field of the mutation.
  38560. func withUsageTotalID(id uint64) usagetotalOption {
  38561. return func(m *UsageTotalMutation) {
  38562. var (
  38563. err error
  38564. once sync.Once
  38565. value *UsageTotal
  38566. )
  38567. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  38568. once.Do(func() {
  38569. if m.done {
  38570. err = errors.New("querying old values post mutation is not allowed")
  38571. } else {
  38572. value, err = m.Client().UsageTotal.Get(ctx, id)
  38573. }
  38574. })
  38575. return value, err
  38576. }
  38577. m.id = &id
  38578. }
  38579. }
  38580. // withUsageTotal sets the old UsageTotal of the mutation.
  38581. func withUsageTotal(node *UsageTotal) usagetotalOption {
  38582. return func(m *UsageTotalMutation) {
  38583. m.oldValue = func(context.Context) (*UsageTotal, error) {
  38584. return node, nil
  38585. }
  38586. m.id = &node.ID
  38587. }
  38588. }
  38589. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38590. // executed in a transaction (ent.Tx), a transactional client is returned.
  38591. func (m UsageTotalMutation) Client() *Client {
  38592. client := &Client{config: m.config}
  38593. client.init()
  38594. return client
  38595. }
  38596. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38597. // it returns an error otherwise.
  38598. func (m UsageTotalMutation) Tx() (*Tx, error) {
  38599. if _, ok := m.driver.(*txDriver); !ok {
  38600. return nil, errors.New("ent: mutation is not running in a transaction")
  38601. }
  38602. tx := &Tx{config: m.config}
  38603. tx.init()
  38604. return tx, nil
  38605. }
  38606. // SetID sets the value of the id field. Note that this
  38607. // operation is only accepted on creation of UsageTotal entities.
  38608. func (m *UsageTotalMutation) SetID(id uint64) {
  38609. m.id = &id
  38610. }
  38611. // ID returns the ID value in the mutation. Note that the ID is only available
  38612. // if it was provided to the builder or after it was returned from the database.
  38613. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  38614. if m.id == nil {
  38615. return
  38616. }
  38617. return *m.id, true
  38618. }
  38619. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38620. // That means, if the mutation is applied within a transaction with an isolation level such
  38621. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38622. // or updated by the mutation.
  38623. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  38624. switch {
  38625. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38626. id, exists := m.ID()
  38627. if exists {
  38628. return []uint64{id}, nil
  38629. }
  38630. fallthrough
  38631. case m.op.Is(OpUpdate | OpDelete):
  38632. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  38633. default:
  38634. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38635. }
  38636. }
  38637. // SetCreatedAt sets the "created_at" field.
  38638. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  38639. m.created_at = &t
  38640. }
  38641. // CreatedAt returns the value of the "created_at" field in the mutation.
  38642. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  38643. v := m.created_at
  38644. if v == nil {
  38645. return
  38646. }
  38647. return *v, true
  38648. }
  38649. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  38650. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38652. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38653. if !m.op.Is(OpUpdateOne) {
  38654. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38655. }
  38656. if m.id == nil || m.oldValue == nil {
  38657. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38658. }
  38659. oldValue, err := m.oldValue(ctx)
  38660. if err != nil {
  38661. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38662. }
  38663. return oldValue.CreatedAt, nil
  38664. }
  38665. // ResetCreatedAt resets all changes to the "created_at" field.
  38666. func (m *UsageTotalMutation) ResetCreatedAt() {
  38667. m.created_at = nil
  38668. }
  38669. // SetUpdatedAt sets the "updated_at" field.
  38670. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  38671. m.updated_at = &t
  38672. }
  38673. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38674. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  38675. v := m.updated_at
  38676. if v == nil {
  38677. return
  38678. }
  38679. return *v, true
  38680. }
  38681. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  38682. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38684. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38685. if !m.op.Is(OpUpdateOne) {
  38686. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38687. }
  38688. if m.id == nil || m.oldValue == nil {
  38689. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38690. }
  38691. oldValue, err := m.oldValue(ctx)
  38692. if err != nil {
  38693. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38694. }
  38695. return oldValue.UpdatedAt, nil
  38696. }
  38697. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38698. func (m *UsageTotalMutation) ResetUpdatedAt() {
  38699. m.updated_at = nil
  38700. }
  38701. // SetStatus sets the "status" field.
  38702. func (m *UsageTotalMutation) SetStatus(u uint8) {
  38703. m.status = &u
  38704. m.addstatus = nil
  38705. }
  38706. // Status returns the value of the "status" field in the mutation.
  38707. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  38708. v := m.status
  38709. if v == nil {
  38710. return
  38711. }
  38712. return *v, true
  38713. }
  38714. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  38715. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38717. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38718. if !m.op.Is(OpUpdateOne) {
  38719. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38720. }
  38721. if m.id == nil || m.oldValue == nil {
  38722. return v, errors.New("OldStatus requires an ID field in the mutation")
  38723. }
  38724. oldValue, err := m.oldValue(ctx)
  38725. if err != nil {
  38726. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38727. }
  38728. return oldValue.Status, nil
  38729. }
  38730. // AddStatus adds u to the "status" field.
  38731. func (m *UsageTotalMutation) AddStatus(u int8) {
  38732. if m.addstatus != nil {
  38733. *m.addstatus += u
  38734. } else {
  38735. m.addstatus = &u
  38736. }
  38737. }
  38738. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38739. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  38740. v := m.addstatus
  38741. if v == nil {
  38742. return
  38743. }
  38744. return *v, true
  38745. }
  38746. // ClearStatus clears the value of the "status" field.
  38747. func (m *UsageTotalMutation) ClearStatus() {
  38748. m.status = nil
  38749. m.addstatus = nil
  38750. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  38751. }
  38752. // StatusCleared returns if the "status" field was cleared in this mutation.
  38753. func (m *UsageTotalMutation) StatusCleared() bool {
  38754. _, ok := m.clearedFields[usagetotal.FieldStatus]
  38755. return ok
  38756. }
  38757. // ResetStatus resets all changes to the "status" field.
  38758. func (m *UsageTotalMutation) ResetStatus() {
  38759. m.status = nil
  38760. m.addstatus = nil
  38761. delete(m.clearedFields, usagetotal.FieldStatus)
  38762. }
  38763. // SetType sets the "type" field.
  38764. func (m *UsageTotalMutation) SetType(i int) {
  38765. m._type = &i
  38766. m.add_type = nil
  38767. }
  38768. // GetType returns the value of the "type" field in the mutation.
  38769. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  38770. v := m._type
  38771. if v == nil {
  38772. return
  38773. }
  38774. return *v, true
  38775. }
  38776. // OldType returns the old "type" field's value of the UsageTotal entity.
  38777. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38779. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  38780. if !m.op.Is(OpUpdateOne) {
  38781. return v, errors.New("OldType is only allowed on UpdateOne operations")
  38782. }
  38783. if m.id == nil || m.oldValue == nil {
  38784. return v, errors.New("OldType requires an ID field in the mutation")
  38785. }
  38786. oldValue, err := m.oldValue(ctx)
  38787. if err != nil {
  38788. return v, fmt.Errorf("querying old value for OldType: %w", err)
  38789. }
  38790. return oldValue.Type, nil
  38791. }
  38792. // AddType adds i to the "type" field.
  38793. func (m *UsageTotalMutation) AddType(i int) {
  38794. if m.add_type != nil {
  38795. *m.add_type += i
  38796. } else {
  38797. m.add_type = &i
  38798. }
  38799. }
  38800. // AddedType returns the value that was added to the "type" field in this mutation.
  38801. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  38802. v := m.add_type
  38803. if v == nil {
  38804. return
  38805. }
  38806. return *v, true
  38807. }
  38808. // ClearType clears the value of the "type" field.
  38809. func (m *UsageTotalMutation) ClearType() {
  38810. m._type = nil
  38811. m.add_type = nil
  38812. m.clearedFields[usagetotal.FieldType] = struct{}{}
  38813. }
  38814. // TypeCleared returns if the "type" field was cleared in this mutation.
  38815. func (m *UsageTotalMutation) TypeCleared() bool {
  38816. _, ok := m.clearedFields[usagetotal.FieldType]
  38817. return ok
  38818. }
  38819. // ResetType resets all changes to the "type" field.
  38820. func (m *UsageTotalMutation) ResetType() {
  38821. m._type = nil
  38822. m.add_type = nil
  38823. delete(m.clearedFields, usagetotal.FieldType)
  38824. }
  38825. // SetBotID sets the "bot_id" field.
  38826. func (m *UsageTotalMutation) SetBotID(s string) {
  38827. m.bot_id = &s
  38828. }
  38829. // BotID returns the value of the "bot_id" field in the mutation.
  38830. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  38831. v := m.bot_id
  38832. if v == nil {
  38833. return
  38834. }
  38835. return *v, true
  38836. }
  38837. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  38838. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38840. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  38841. if !m.op.Is(OpUpdateOne) {
  38842. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  38843. }
  38844. if m.id == nil || m.oldValue == nil {
  38845. return v, errors.New("OldBotID requires an ID field in the mutation")
  38846. }
  38847. oldValue, err := m.oldValue(ctx)
  38848. if err != nil {
  38849. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  38850. }
  38851. return oldValue.BotID, nil
  38852. }
  38853. // ResetBotID resets all changes to the "bot_id" field.
  38854. func (m *UsageTotalMutation) ResetBotID() {
  38855. m.bot_id = nil
  38856. }
  38857. // SetTotalTokens sets the "total_tokens" field.
  38858. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  38859. m.total_tokens = &u
  38860. m.addtotal_tokens = nil
  38861. }
  38862. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  38863. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  38864. v := m.total_tokens
  38865. if v == nil {
  38866. return
  38867. }
  38868. return *v, true
  38869. }
  38870. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  38871. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38873. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  38874. if !m.op.Is(OpUpdateOne) {
  38875. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  38876. }
  38877. if m.id == nil || m.oldValue == nil {
  38878. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  38879. }
  38880. oldValue, err := m.oldValue(ctx)
  38881. if err != nil {
  38882. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  38883. }
  38884. return oldValue.TotalTokens, nil
  38885. }
  38886. // AddTotalTokens adds u to the "total_tokens" field.
  38887. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  38888. if m.addtotal_tokens != nil {
  38889. *m.addtotal_tokens += u
  38890. } else {
  38891. m.addtotal_tokens = &u
  38892. }
  38893. }
  38894. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  38895. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  38896. v := m.addtotal_tokens
  38897. if v == nil {
  38898. return
  38899. }
  38900. return *v, true
  38901. }
  38902. // ClearTotalTokens clears the value of the "total_tokens" field.
  38903. func (m *UsageTotalMutation) ClearTotalTokens() {
  38904. m.total_tokens = nil
  38905. m.addtotal_tokens = nil
  38906. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  38907. }
  38908. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  38909. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  38910. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  38911. return ok
  38912. }
  38913. // ResetTotalTokens resets all changes to the "total_tokens" field.
  38914. func (m *UsageTotalMutation) ResetTotalTokens() {
  38915. m.total_tokens = nil
  38916. m.addtotal_tokens = nil
  38917. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  38918. }
  38919. // SetStartIndex sets the "start_index" field.
  38920. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  38921. m.start_index = &u
  38922. m.addstart_index = nil
  38923. }
  38924. // StartIndex returns the value of the "start_index" field in the mutation.
  38925. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  38926. v := m.start_index
  38927. if v == nil {
  38928. return
  38929. }
  38930. return *v, true
  38931. }
  38932. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  38933. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38935. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  38936. if !m.op.Is(OpUpdateOne) {
  38937. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  38938. }
  38939. if m.id == nil || m.oldValue == nil {
  38940. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  38941. }
  38942. oldValue, err := m.oldValue(ctx)
  38943. if err != nil {
  38944. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  38945. }
  38946. return oldValue.StartIndex, nil
  38947. }
  38948. // AddStartIndex adds u to the "start_index" field.
  38949. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  38950. if m.addstart_index != nil {
  38951. *m.addstart_index += u
  38952. } else {
  38953. m.addstart_index = &u
  38954. }
  38955. }
  38956. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  38957. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  38958. v := m.addstart_index
  38959. if v == nil {
  38960. return
  38961. }
  38962. return *v, true
  38963. }
  38964. // ClearStartIndex clears the value of the "start_index" field.
  38965. func (m *UsageTotalMutation) ClearStartIndex() {
  38966. m.start_index = nil
  38967. m.addstart_index = nil
  38968. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  38969. }
  38970. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  38971. func (m *UsageTotalMutation) StartIndexCleared() bool {
  38972. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  38973. return ok
  38974. }
  38975. // ResetStartIndex resets all changes to the "start_index" field.
  38976. func (m *UsageTotalMutation) ResetStartIndex() {
  38977. m.start_index = nil
  38978. m.addstart_index = nil
  38979. delete(m.clearedFields, usagetotal.FieldStartIndex)
  38980. }
  38981. // SetEndIndex sets the "end_index" field.
  38982. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  38983. m.end_index = &u
  38984. m.addend_index = nil
  38985. }
  38986. // EndIndex returns the value of the "end_index" field in the mutation.
  38987. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  38988. v := m.end_index
  38989. if v == nil {
  38990. return
  38991. }
  38992. return *v, true
  38993. }
  38994. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  38995. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  38996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38997. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  38998. if !m.op.Is(OpUpdateOne) {
  38999. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  39000. }
  39001. if m.id == nil || m.oldValue == nil {
  39002. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  39003. }
  39004. oldValue, err := m.oldValue(ctx)
  39005. if err != nil {
  39006. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  39007. }
  39008. return oldValue.EndIndex, nil
  39009. }
  39010. // AddEndIndex adds u to the "end_index" field.
  39011. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  39012. if m.addend_index != nil {
  39013. *m.addend_index += u
  39014. } else {
  39015. m.addend_index = &u
  39016. }
  39017. }
  39018. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  39019. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  39020. v := m.addend_index
  39021. if v == nil {
  39022. return
  39023. }
  39024. return *v, true
  39025. }
  39026. // ClearEndIndex clears the value of the "end_index" field.
  39027. func (m *UsageTotalMutation) ClearEndIndex() {
  39028. m.end_index = nil
  39029. m.addend_index = nil
  39030. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  39031. }
  39032. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  39033. func (m *UsageTotalMutation) EndIndexCleared() bool {
  39034. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  39035. return ok
  39036. }
  39037. // ResetEndIndex resets all changes to the "end_index" field.
  39038. func (m *UsageTotalMutation) ResetEndIndex() {
  39039. m.end_index = nil
  39040. m.addend_index = nil
  39041. delete(m.clearedFields, usagetotal.FieldEndIndex)
  39042. }
  39043. // SetOrganizationID sets the "organization_id" field.
  39044. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  39045. m.organization_id = &u
  39046. m.addorganization_id = nil
  39047. }
  39048. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39049. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  39050. v := m.organization_id
  39051. if v == nil {
  39052. return
  39053. }
  39054. return *v, true
  39055. }
  39056. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  39057. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  39058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39059. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39060. if !m.op.Is(OpUpdateOne) {
  39061. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39062. }
  39063. if m.id == nil || m.oldValue == nil {
  39064. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39065. }
  39066. oldValue, err := m.oldValue(ctx)
  39067. if err != nil {
  39068. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39069. }
  39070. return oldValue.OrganizationID, nil
  39071. }
  39072. // AddOrganizationID adds u to the "organization_id" field.
  39073. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  39074. if m.addorganization_id != nil {
  39075. *m.addorganization_id += u
  39076. } else {
  39077. m.addorganization_id = &u
  39078. }
  39079. }
  39080. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39081. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  39082. v := m.addorganization_id
  39083. if v == nil {
  39084. return
  39085. }
  39086. return *v, true
  39087. }
  39088. // ClearOrganizationID clears the value of the "organization_id" field.
  39089. func (m *UsageTotalMutation) ClearOrganizationID() {
  39090. m.organization_id = nil
  39091. m.addorganization_id = nil
  39092. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  39093. }
  39094. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39095. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  39096. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  39097. return ok
  39098. }
  39099. // ResetOrganizationID resets all changes to the "organization_id" field.
  39100. func (m *UsageTotalMutation) ResetOrganizationID() {
  39101. m.organization_id = nil
  39102. m.addorganization_id = nil
  39103. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  39104. }
  39105. // Where appends a list predicates to the UsageTotalMutation builder.
  39106. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  39107. m.predicates = append(m.predicates, ps...)
  39108. }
  39109. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  39110. // users can use type-assertion to append predicates that do not depend on any generated package.
  39111. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  39112. p := make([]predicate.UsageTotal, len(ps))
  39113. for i := range ps {
  39114. p[i] = ps[i]
  39115. }
  39116. m.Where(p...)
  39117. }
  39118. // Op returns the operation name.
  39119. func (m *UsageTotalMutation) Op() Op {
  39120. return m.op
  39121. }
  39122. // SetOp allows setting the mutation operation.
  39123. func (m *UsageTotalMutation) SetOp(op Op) {
  39124. m.op = op
  39125. }
  39126. // Type returns the node type of this mutation (UsageTotal).
  39127. func (m *UsageTotalMutation) Type() string {
  39128. return m.typ
  39129. }
  39130. // Fields returns all fields that were changed during this mutation. Note that in
  39131. // order to get all numeric fields that were incremented/decremented, call
  39132. // AddedFields().
  39133. func (m *UsageTotalMutation) Fields() []string {
  39134. fields := make([]string, 0, 9)
  39135. if m.created_at != nil {
  39136. fields = append(fields, usagetotal.FieldCreatedAt)
  39137. }
  39138. if m.updated_at != nil {
  39139. fields = append(fields, usagetotal.FieldUpdatedAt)
  39140. }
  39141. if m.status != nil {
  39142. fields = append(fields, usagetotal.FieldStatus)
  39143. }
  39144. if m._type != nil {
  39145. fields = append(fields, usagetotal.FieldType)
  39146. }
  39147. if m.bot_id != nil {
  39148. fields = append(fields, usagetotal.FieldBotID)
  39149. }
  39150. if m.total_tokens != nil {
  39151. fields = append(fields, usagetotal.FieldTotalTokens)
  39152. }
  39153. if m.start_index != nil {
  39154. fields = append(fields, usagetotal.FieldStartIndex)
  39155. }
  39156. if m.end_index != nil {
  39157. fields = append(fields, usagetotal.FieldEndIndex)
  39158. }
  39159. if m.organization_id != nil {
  39160. fields = append(fields, usagetotal.FieldOrganizationID)
  39161. }
  39162. return fields
  39163. }
  39164. // Field returns the value of a field with the given name. The second boolean
  39165. // return value indicates that this field was not set, or was not defined in the
  39166. // schema.
  39167. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  39168. switch name {
  39169. case usagetotal.FieldCreatedAt:
  39170. return m.CreatedAt()
  39171. case usagetotal.FieldUpdatedAt:
  39172. return m.UpdatedAt()
  39173. case usagetotal.FieldStatus:
  39174. return m.Status()
  39175. case usagetotal.FieldType:
  39176. return m.GetType()
  39177. case usagetotal.FieldBotID:
  39178. return m.BotID()
  39179. case usagetotal.FieldTotalTokens:
  39180. return m.TotalTokens()
  39181. case usagetotal.FieldStartIndex:
  39182. return m.StartIndex()
  39183. case usagetotal.FieldEndIndex:
  39184. return m.EndIndex()
  39185. case usagetotal.FieldOrganizationID:
  39186. return m.OrganizationID()
  39187. }
  39188. return nil, false
  39189. }
  39190. // OldField returns the old value of the field from the database. An error is
  39191. // returned if the mutation operation is not UpdateOne, or the query to the
  39192. // database failed.
  39193. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39194. switch name {
  39195. case usagetotal.FieldCreatedAt:
  39196. return m.OldCreatedAt(ctx)
  39197. case usagetotal.FieldUpdatedAt:
  39198. return m.OldUpdatedAt(ctx)
  39199. case usagetotal.FieldStatus:
  39200. return m.OldStatus(ctx)
  39201. case usagetotal.FieldType:
  39202. return m.OldType(ctx)
  39203. case usagetotal.FieldBotID:
  39204. return m.OldBotID(ctx)
  39205. case usagetotal.FieldTotalTokens:
  39206. return m.OldTotalTokens(ctx)
  39207. case usagetotal.FieldStartIndex:
  39208. return m.OldStartIndex(ctx)
  39209. case usagetotal.FieldEndIndex:
  39210. return m.OldEndIndex(ctx)
  39211. case usagetotal.FieldOrganizationID:
  39212. return m.OldOrganizationID(ctx)
  39213. }
  39214. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  39215. }
  39216. // SetField sets the value of a field with the given name. It returns an error if
  39217. // the field is not defined in the schema, or if the type mismatched the field
  39218. // type.
  39219. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  39220. switch name {
  39221. case usagetotal.FieldCreatedAt:
  39222. v, ok := value.(time.Time)
  39223. if !ok {
  39224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39225. }
  39226. m.SetCreatedAt(v)
  39227. return nil
  39228. case usagetotal.FieldUpdatedAt:
  39229. v, ok := value.(time.Time)
  39230. if !ok {
  39231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39232. }
  39233. m.SetUpdatedAt(v)
  39234. return nil
  39235. case usagetotal.FieldStatus:
  39236. v, ok := value.(uint8)
  39237. if !ok {
  39238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39239. }
  39240. m.SetStatus(v)
  39241. return nil
  39242. case usagetotal.FieldType:
  39243. v, ok := value.(int)
  39244. if !ok {
  39245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39246. }
  39247. m.SetType(v)
  39248. return nil
  39249. case usagetotal.FieldBotID:
  39250. v, ok := value.(string)
  39251. if !ok {
  39252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39253. }
  39254. m.SetBotID(v)
  39255. return nil
  39256. case usagetotal.FieldTotalTokens:
  39257. v, ok := value.(uint64)
  39258. if !ok {
  39259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39260. }
  39261. m.SetTotalTokens(v)
  39262. return nil
  39263. case usagetotal.FieldStartIndex:
  39264. v, ok := value.(uint64)
  39265. if !ok {
  39266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39267. }
  39268. m.SetStartIndex(v)
  39269. return nil
  39270. case usagetotal.FieldEndIndex:
  39271. v, ok := value.(uint64)
  39272. if !ok {
  39273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39274. }
  39275. m.SetEndIndex(v)
  39276. return nil
  39277. case usagetotal.FieldOrganizationID:
  39278. v, ok := value.(uint64)
  39279. if !ok {
  39280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39281. }
  39282. m.SetOrganizationID(v)
  39283. return nil
  39284. }
  39285. return fmt.Errorf("unknown UsageTotal field %s", name)
  39286. }
  39287. // AddedFields returns all numeric fields that were incremented/decremented during
  39288. // this mutation.
  39289. func (m *UsageTotalMutation) AddedFields() []string {
  39290. var fields []string
  39291. if m.addstatus != nil {
  39292. fields = append(fields, usagetotal.FieldStatus)
  39293. }
  39294. if m.add_type != nil {
  39295. fields = append(fields, usagetotal.FieldType)
  39296. }
  39297. if m.addtotal_tokens != nil {
  39298. fields = append(fields, usagetotal.FieldTotalTokens)
  39299. }
  39300. if m.addstart_index != nil {
  39301. fields = append(fields, usagetotal.FieldStartIndex)
  39302. }
  39303. if m.addend_index != nil {
  39304. fields = append(fields, usagetotal.FieldEndIndex)
  39305. }
  39306. if m.addorganization_id != nil {
  39307. fields = append(fields, usagetotal.FieldOrganizationID)
  39308. }
  39309. return fields
  39310. }
  39311. // AddedField returns the numeric value that was incremented/decremented on a field
  39312. // with the given name. The second boolean return value indicates that this field
  39313. // was not set, or was not defined in the schema.
  39314. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  39315. switch name {
  39316. case usagetotal.FieldStatus:
  39317. return m.AddedStatus()
  39318. case usagetotal.FieldType:
  39319. return m.AddedType()
  39320. case usagetotal.FieldTotalTokens:
  39321. return m.AddedTotalTokens()
  39322. case usagetotal.FieldStartIndex:
  39323. return m.AddedStartIndex()
  39324. case usagetotal.FieldEndIndex:
  39325. return m.AddedEndIndex()
  39326. case usagetotal.FieldOrganizationID:
  39327. return m.AddedOrganizationID()
  39328. }
  39329. return nil, false
  39330. }
  39331. // AddField adds the value to the field with the given name. It returns an error if
  39332. // the field is not defined in the schema, or if the type mismatched the field
  39333. // type.
  39334. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  39335. switch name {
  39336. case usagetotal.FieldStatus:
  39337. v, ok := value.(int8)
  39338. if !ok {
  39339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39340. }
  39341. m.AddStatus(v)
  39342. return nil
  39343. case usagetotal.FieldType:
  39344. v, ok := value.(int)
  39345. if !ok {
  39346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39347. }
  39348. m.AddType(v)
  39349. return nil
  39350. case usagetotal.FieldTotalTokens:
  39351. v, ok := value.(int64)
  39352. if !ok {
  39353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39354. }
  39355. m.AddTotalTokens(v)
  39356. return nil
  39357. case usagetotal.FieldStartIndex:
  39358. v, ok := value.(int64)
  39359. if !ok {
  39360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39361. }
  39362. m.AddStartIndex(v)
  39363. return nil
  39364. case usagetotal.FieldEndIndex:
  39365. v, ok := value.(int64)
  39366. if !ok {
  39367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39368. }
  39369. m.AddEndIndex(v)
  39370. return nil
  39371. case usagetotal.FieldOrganizationID:
  39372. v, ok := value.(int64)
  39373. if !ok {
  39374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39375. }
  39376. m.AddOrganizationID(v)
  39377. return nil
  39378. }
  39379. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  39380. }
  39381. // ClearedFields returns all nullable fields that were cleared during this
  39382. // mutation.
  39383. func (m *UsageTotalMutation) ClearedFields() []string {
  39384. var fields []string
  39385. if m.FieldCleared(usagetotal.FieldStatus) {
  39386. fields = append(fields, usagetotal.FieldStatus)
  39387. }
  39388. if m.FieldCleared(usagetotal.FieldType) {
  39389. fields = append(fields, usagetotal.FieldType)
  39390. }
  39391. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  39392. fields = append(fields, usagetotal.FieldTotalTokens)
  39393. }
  39394. if m.FieldCleared(usagetotal.FieldStartIndex) {
  39395. fields = append(fields, usagetotal.FieldStartIndex)
  39396. }
  39397. if m.FieldCleared(usagetotal.FieldEndIndex) {
  39398. fields = append(fields, usagetotal.FieldEndIndex)
  39399. }
  39400. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  39401. fields = append(fields, usagetotal.FieldOrganizationID)
  39402. }
  39403. return fields
  39404. }
  39405. // FieldCleared returns a boolean indicating if a field with the given name was
  39406. // cleared in this mutation.
  39407. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  39408. _, ok := m.clearedFields[name]
  39409. return ok
  39410. }
  39411. // ClearField clears the value of the field with the given name. It returns an
  39412. // error if the field is not defined in the schema.
  39413. func (m *UsageTotalMutation) ClearField(name string) error {
  39414. switch name {
  39415. case usagetotal.FieldStatus:
  39416. m.ClearStatus()
  39417. return nil
  39418. case usagetotal.FieldType:
  39419. m.ClearType()
  39420. return nil
  39421. case usagetotal.FieldTotalTokens:
  39422. m.ClearTotalTokens()
  39423. return nil
  39424. case usagetotal.FieldStartIndex:
  39425. m.ClearStartIndex()
  39426. return nil
  39427. case usagetotal.FieldEndIndex:
  39428. m.ClearEndIndex()
  39429. return nil
  39430. case usagetotal.FieldOrganizationID:
  39431. m.ClearOrganizationID()
  39432. return nil
  39433. }
  39434. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  39435. }
  39436. // ResetField resets all changes in the mutation for the field with the given name.
  39437. // It returns an error if the field is not defined in the schema.
  39438. func (m *UsageTotalMutation) ResetField(name string) error {
  39439. switch name {
  39440. case usagetotal.FieldCreatedAt:
  39441. m.ResetCreatedAt()
  39442. return nil
  39443. case usagetotal.FieldUpdatedAt:
  39444. m.ResetUpdatedAt()
  39445. return nil
  39446. case usagetotal.FieldStatus:
  39447. m.ResetStatus()
  39448. return nil
  39449. case usagetotal.FieldType:
  39450. m.ResetType()
  39451. return nil
  39452. case usagetotal.FieldBotID:
  39453. m.ResetBotID()
  39454. return nil
  39455. case usagetotal.FieldTotalTokens:
  39456. m.ResetTotalTokens()
  39457. return nil
  39458. case usagetotal.FieldStartIndex:
  39459. m.ResetStartIndex()
  39460. return nil
  39461. case usagetotal.FieldEndIndex:
  39462. m.ResetEndIndex()
  39463. return nil
  39464. case usagetotal.FieldOrganizationID:
  39465. m.ResetOrganizationID()
  39466. return nil
  39467. }
  39468. return fmt.Errorf("unknown UsageTotal field %s", name)
  39469. }
  39470. // AddedEdges returns all edge names that were set/added in this mutation.
  39471. func (m *UsageTotalMutation) AddedEdges() []string {
  39472. edges := make([]string, 0, 0)
  39473. return edges
  39474. }
  39475. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39476. // name in this mutation.
  39477. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  39478. return nil
  39479. }
  39480. // RemovedEdges returns all edge names that were removed in this mutation.
  39481. func (m *UsageTotalMutation) RemovedEdges() []string {
  39482. edges := make([]string, 0, 0)
  39483. return edges
  39484. }
  39485. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39486. // the given name in this mutation.
  39487. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  39488. return nil
  39489. }
  39490. // ClearedEdges returns all edge names that were cleared in this mutation.
  39491. func (m *UsageTotalMutation) ClearedEdges() []string {
  39492. edges := make([]string, 0, 0)
  39493. return edges
  39494. }
  39495. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39496. // was cleared in this mutation.
  39497. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  39498. return false
  39499. }
  39500. // ClearEdge clears the value of the edge with the given name. It returns an error
  39501. // if that edge is not defined in the schema.
  39502. func (m *UsageTotalMutation) ClearEdge(name string) error {
  39503. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  39504. }
  39505. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39506. // It returns an error if the edge is not defined in the schema.
  39507. func (m *UsageTotalMutation) ResetEdge(name string) error {
  39508. return fmt.Errorf("unknown UsageTotal edge %s", name)
  39509. }
  39510. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  39511. type WhatsappMutation struct {
  39512. config
  39513. op Op
  39514. typ string
  39515. id *uint64
  39516. created_at *time.Time
  39517. updated_at *time.Time
  39518. status *uint8
  39519. addstatus *int8
  39520. deleted_at *time.Time
  39521. wa_id *string
  39522. wa_name *string
  39523. callback *string
  39524. account *string
  39525. cc *string
  39526. phone *string
  39527. cc_phone *string
  39528. phone_name *string
  39529. phone_status *int8
  39530. addphone_status *int8
  39531. organization_id *uint64
  39532. addorganization_id *int64
  39533. api_base *string
  39534. api_key *string
  39535. allow_list *[]string
  39536. appendallow_list []string
  39537. group_allow_list *[]string
  39538. appendgroup_allow_list []string
  39539. block_list *[]string
  39540. appendblock_list []string
  39541. group_block_list *[]string
  39542. appendgroup_block_list []string
  39543. clearedFields map[string]struct{}
  39544. agent *uint64
  39545. clearedagent bool
  39546. done bool
  39547. oldValue func(context.Context) (*Whatsapp, error)
  39548. predicates []predicate.Whatsapp
  39549. }
  39550. var _ ent.Mutation = (*WhatsappMutation)(nil)
  39551. // whatsappOption allows management of the mutation configuration using functional options.
  39552. type whatsappOption func(*WhatsappMutation)
  39553. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  39554. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  39555. m := &WhatsappMutation{
  39556. config: c,
  39557. op: op,
  39558. typ: TypeWhatsapp,
  39559. clearedFields: make(map[string]struct{}),
  39560. }
  39561. for _, opt := range opts {
  39562. opt(m)
  39563. }
  39564. return m
  39565. }
  39566. // withWhatsappID sets the ID field of the mutation.
  39567. func withWhatsappID(id uint64) whatsappOption {
  39568. return func(m *WhatsappMutation) {
  39569. var (
  39570. err error
  39571. once sync.Once
  39572. value *Whatsapp
  39573. )
  39574. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  39575. once.Do(func() {
  39576. if m.done {
  39577. err = errors.New("querying old values post mutation is not allowed")
  39578. } else {
  39579. value, err = m.Client().Whatsapp.Get(ctx, id)
  39580. }
  39581. })
  39582. return value, err
  39583. }
  39584. m.id = &id
  39585. }
  39586. }
  39587. // withWhatsapp sets the old Whatsapp of the mutation.
  39588. func withWhatsapp(node *Whatsapp) whatsappOption {
  39589. return func(m *WhatsappMutation) {
  39590. m.oldValue = func(context.Context) (*Whatsapp, error) {
  39591. return node, nil
  39592. }
  39593. m.id = &node.ID
  39594. }
  39595. }
  39596. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39597. // executed in a transaction (ent.Tx), a transactional client is returned.
  39598. func (m WhatsappMutation) Client() *Client {
  39599. client := &Client{config: m.config}
  39600. client.init()
  39601. return client
  39602. }
  39603. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39604. // it returns an error otherwise.
  39605. func (m WhatsappMutation) Tx() (*Tx, error) {
  39606. if _, ok := m.driver.(*txDriver); !ok {
  39607. return nil, errors.New("ent: mutation is not running in a transaction")
  39608. }
  39609. tx := &Tx{config: m.config}
  39610. tx.init()
  39611. return tx, nil
  39612. }
  39613. // SetID sets the value of the id field. Note that this
  39614. // operation is only accepted on creation of Whatsapp entities.
  39615. func (m *WhatsappMutation) SetID(id uint64) {
  39616. m.id = &id
  39617. }
  39618. // ID returns the ID value in the mutation. Note that the ID is only available
  39619. // if it was provided to the builder or after it was returned from the database.
  39620. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  39621. if m.id == nil {
  39622. return
  39623. }
  39624. return *m.id, true
  39625. }
  39626. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39627. // That means, if the mutation is applied within a transaction with an isolation level such
  39628. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39629. // or updated by the mutation.
  39630. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  39631. switch {
  39632. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39633. id, exists := m.ID()
  39634. if exists {
  39635. return []uint64{id}, nil
  39636. }
  39637. fallthrough
  39638. case m.op.Is(OpUpdate | OpDelete):
  39639. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  39640. default:
  39641. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39642. }
  39643. }
  39644. // SetCreatedAt sets the "created_at" field.
  39645. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  39646. m.created_at = &t
  39647. }
  39648. // CreatedAt returns the value of the "created_at" field in the mutation.
  39649. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  39650. v := m.created_at
  39651. if v == nil {
  39652. return
  39653. }
  39654. return *v, true
  39655. }
  39656. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  39657. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39658. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39659. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39660. if !m.op.Is(OpUpdateOne) {
  39661. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39662. }
  39663. if m.id == nil || m.oldValue == nil {
  39664. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39665. }
  39666. oldValue, err := m.oldValue(ctx)
  39667. if err != nil {
  39668. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39669. }
  39670. return oldValue.CreatedAt, nil
  39671. }
  39672. // ResetCreatedAt resets all changes to the "created_at" field.
  39673. func (m *WhatsappMutation) ResetCreatedAt() {
  39674. m.created_at = nil
  39675. }
  39676. // SetUpdatedAt sets the "updated_at" field.
  39677. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  39678. m.updated_at = &t
  39679. }
  39680. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39681. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  39682. v := m.updated_at
  39683. if v == nil {
  39684. return
  39685. }
  39686. return *v, true
  39687. }
  39688. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  39689. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39691. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39692. if !m.op.Is(OpUpdateOne) {
  39693. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39694. }
  39695. if m.id == nil || m.oldValue == nil {
  39696. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39697. }
  39698. oldValue, err := m.oldValue(ctx)
  39699. if err != nil {
  39700. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39701. }
  39702. return oldValue.UpdatedAt, nil
  39703. }
  39704. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39705. func (m *WhatsappMutation) ResetUpdatedAt() {
  39706. m.updated_at = nil
  39707. }
  39708. // SetStatus sets the "status" field.
  39709. func (m *WhatsappMutation) SetStatus(u uint8) {
  39710. m.status = &u
  39711. m.addstatus = nil
  39712. }
  39713. // Status returns the value of the "status" field in the mutation.
  39714. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  39715. v := m.status
  39716. if v == nil {
  39717. return
  39718. }
  39719. return *v, true
  39720. }
  39721. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  39722. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39724. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39725. if !m.op.Is(OpUpdateOne) {
  39726. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39727. }
  39728. if m.id == nil || m.oldValue == nil {
  39729. return v, errors.New("OldStatus requires an ID field in the mutation")
  39730. }
  39731. oldValue, err := m.oldValue(ctx)
  39732. if err != nil {
  39733. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39734. }
  39735. return oldValue.Status, nil
  39736. }
  39737. // AddStatus adds u to the "status" field.
  39738. func (m *WhatsappMutation) AddStatus(u int8) {
  39739. if m.addstatus != nil {
  39740. *m.addstatus += u
  39741. } else {
  39742. m.addstatus = &u
  39743. }
  39744. }
  39745. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39746. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  39747. v := m.addstatus
  39748. if v == nil {
  39749. return
  39750. }
  39751. return *v, true
  39752. }
  39753. // ClearStatus clears the value of the "status" field.
  39754. func (m *WhatsappMutation) ClearStatus() {
  39755. m.status = nil
  39756. m.addstatus = nil
  39757. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  39758. }
  39759. // StatusCleared returns if the "status" field was cleared in this mutation.
  39760. func (m *WhatsappMutation) StatusCleared() bool {
  39761. _, ok := m.clearedFields[whatsapp.FieldStatus]
  39762. return ok
  39763. }
  39764. // ResetStatus resets all changes to the "status" field.
  39765. func (m *WhatsappMutation) ResetStatus() {
  39766. m.status = nil
  39767. m.addstatus = nil
  39768. delete(m.clearedFields, whatsapp.FieldStatus)
  39769. }
  39770. // SetDeletedAt sets the "deleted_at" field.
  39771. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  39772. m.deleted_at = &t
  39773. }
  39774. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39775. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  39776. v := m.deleted_at
  39777. if v == nil {
  39778. return
  39779. }
  39780. return *v, true
  39781. }
  39782. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  39783. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39785. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39786. if !m.op.Is(OpUpdateOne) {
  39787. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39788. }
  39789. if m.id == nil || m.oldValue == nil {
  39790. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39791. }
  39792. oldValue, err := m.oldValue(ctx)
  39793. if err != nil {
  39794. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39795. }
  39796. return oldValue.DeletedAt, nil
  39797. }
  39798. // ClearDeletedAt clears the value of the "deleted_at" field.
  39799. func (m *WhatsappMutation) ClearDeletedAt() {
  39800. m.deleted_at = nil
  39801. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  39802. }
  39803. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39804. func (m *WhatsappMutation) DeletedAtCleared() bool {
  39805. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  39806. return ok
  39807. }
  39808. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39809. func (m *WhatsappMutation) ResetDeletedAt() {
  39810. m.deleted_at = nil
  39811. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  39812. }
  39813. // SetWaID sets the "wa_id" field.
  39814. func (m *WhatsappMutation) SetWaID(s string) {
  39815. m.wa_id = &s
  39816. }
  39817. // WaID returns the value of the "wa_id" field in the mutation.
  39818. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  39819. v := m.wa_id
  39820. if v == nil {
  39821. return
  39822. }
  39823. return *v, true
  39824. }
  39825. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  39826. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39828. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  39829. if !m.op.Is(OpUpdateOne) {
  39830. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39831. }
  39832. if m.id == nil || m.oldValue == nil {
  39833. return v, errors.New("OldWaID requires an ID field in the mutation")
  39834. }
  39835. oldValue, err := m.oldValue(ctx)
  39836. if err != nil {
  39837. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  39838. }
  39839. return oldValue.WaID, nil
  39840. }
  39841. // ClearWaID clears the value of the "wa_id" field.
  39842. func (m *WhatsappMutation) ClearWaID() {
  39843. m.wa_id = nil
  39844. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  39845. }
  39846. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  39847. func (m *WhatsappMutation) WaIDCleared() bool {
  39848. _, ok := m.clearedFields[whatsapp.FieldWaID]
  39849. return ok
  39850. }
  39851. // ResetWaID resets all changes to the "wa_id" field.
  39852. func (m *WhatsappMutation) ResetWaID() {
  39853. m.wa_id = nil
  39854. delete(m.clearedFields, whatsapp.FieldWaID)
  39855. }
  39856. // SetWaName sets the "wa_name" field.
  39857. func (m *WhatsappMutation) SetWaName(s string) {
  39858. m.wa_name = &s
  39859. }
  39860. // WaName returns the value of the "wa_name" field in the mutation.
  39861. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  39862. v := m.wa_name
  39863. if v == nil {
  39864. return
  39865. }
  39866. return *v, true
  39867. }
  39868. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  39869. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39871. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  39872. if !m.op.Is(OpUpdateOne) {
  39873. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  39874. }
  39875. if m.id == nil || m.oldValue == nil {
  39876. return v, errors.New("OldWaName requires an ID field in the mutation")
  39877. }
  39878. oldValue, err := m.oldValue(ctx)
  39879. if err != nil {
  39880. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  39881. }
  39882. return oldValue.WaName, nil
  39883. }
  39884. // ClearWaName clears the value of the "wa_name" field.
  39885. func (m *WhatsappMutation) ClearWaName() {
  39886. m.wa_name = nil
  39887. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  39888. }
  39889. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  39890. func (m *WhatsappMutation) WaNameCleared() bool {
  39891. _, ok := m.clearedFields[whatsapp.FieldWaName]
  39892. return ok
  39893. }
  39894. // ResetWaName resets all changes to the "wa_name" field.
  39895. func (m *WhatsappMutation) ResetWaName() {
  39896. m.wa_name = nil
  39897. delete(m.clearedFields, whatsapp.FieldWaName)
  39898. }
  39899. // SetCallback sets the "callback" field.
  39900. func (m *WhatsappMutation) SetCallback(s string) {
  39901. m.callback = &s
  39902. }
  39903. // Callback returns the value of the "callback" field in the mutation.
  39904. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  39905. v := m.callback
  39906. if v == nil {
  39907. return
  39908. }
  39909. return *v, true
  39910. }
  39911. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  39912. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39914. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  39915. if !m.op.Is(OpUpdateOne) {
  39916. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  39917. }
  39918. if m.id == nil || m.oldValue == nil {
  39919. return v, errors.New("OldCallback requires an ID field in the mutation")
  39920. }
  39921. oldValue, err := m.oldValue(ctx)
  39922. if err != nil {
  39923. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  39924. }
  39925. return oldValue.Callback, nil
  39926. }
  39927. // ClearCallback clears the value of the "callback" field.
  39928. func (m *WhatsappMutation) ClearCallback() {
  39929. m.callback = nil
  39930. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  39931. }
  39932. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  39933. func (m *WhatsappMutation) CallbackCleared() bool {
  39934. _, ok := m.clearedFields[whatsapp.FieldCallback]
  39935. return ok
  39936. }
  39937. // ResetCallback resets all changes to the "callback" field.
  39938. func (m *WhatsappMutation) ResetCallback() {
  39939. m.callback = nil
  39940. delete(m.clearedFields, whatsapp.FieldCallback)
  39941. }
  39942. // SetAgentID sets the "agent_id" field.
  39943. func (m *WhatsappMutation) SetAgentID(u uint64) {
  39944. m.agent = &u
  39945. }
  39946. // AgentID returns the value of the "agent_id" field in the mutation.
  39947. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  39948. v := m.agent
  39949. if v == nil {
  39950. return
  39951. }
  39952. return *v, true
  39953. }
  39954. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  39955. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39957. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  39958. if !m.op.Is(OpUpdateOne) {
  39959. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  39960. }
  39961. if m.id == nil || m.oldValue == nil {
  39962. return v, errors.New("OldAgentID requires an ID field in the mutation")
  39963. }
  39964. oldValue, err := m.oldValue(ctx)
  39965. if err != nil {
  39966. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  39967. }
  39968. return oldValue.AgentID, nil
  39969. }
  39970. // ResetAgentID resets all changes to the "agent_id" field.
  39971. func (m *WhatsappMutation) ResetAgentID() {
  39972. m.agent = nil
  39973. }
  39974. // SetAccount sets the "account" field.
  39975. func (m *WhatsappMutation) SetAccount(s string) {
  39976. m.account = &s
  39977. }
  39978. // Account returns the value of the "account" field in the mutation.
  39979. func (m *WhatsappMutation) Account() (r string, exists bool) {
  39980. v := m.account
  39981. if v == nil {
  39982. return
  39983. }
  39984. return *v, true
  39985. }
  39986. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  39987. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  39988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39989. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  39990. if !m.op.Is(OpUpdateOne) {
  39991. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  39992. }
  39993. if m.id == nil || m.oldValue == nil {
  39994. return v, errors.New("OldAccount requires an ID field in the mutation")
  39995. }
  39996. oldValue, err := m.oldValue(ctx)
  39997. if err != nil {
  39998. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  39999. }
  40000. return oldValue.Account, nil
  40001. }
  40002. // ClearAccount clears the value of the "account" field.
  40003. func (m *WhatsappMutation) ClearAccount() {
  40004. m.account = nil
  40005. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  40006. }
  40007. // AccountCleared returns if the "account" field was cleared in this mutation.
  40008. func (m *WhatsappMutation) AccountCleared() bool {
  40009. _, ok := m.clearedFields[whatsapp.FieldAccount]
  40010. return ok
  40011. }
  40012. // ResetAccount resets all changes to the "account" field.
  40013. func (m *WhatsappMutation) ResetAccount() {
  40014. m.account = nil
  40015. delete(m.clearedFields, whatsapp.FieldAccount)
  40016. }
  40017. // SetCc sets the "cc" field.
  40018. func (m *WhatsappMutation) SetCc(s string) {
  40019. m.cc = &s
  40020. }
  40021. // Cc returns the value of the "cc" field in the mutation.
  40022. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  40023. v := m.cc
  40024. if v == nil {
  40025. return
  40026. }
  40027. return *v, true
  40028. }
  40029. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  40030. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40032. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  40033. if !m.op.Is(OpUpdateOne) {
  40034. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  40035. }
  40036. if m.id == nil || m.oldValue == nil {
  40037. return v, errors.New("OldCc requires an ID field in the mutation")
  40038. }
  40039. oldValue, err := m.oldValue(ctx)
  40040. if err != nil {
  40041. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  40042. }
  40043. return oldValue.Cc, nil
  40044. }
  40045. // ResetCc resets all changes to the "cc" field.
  40046. func (m *WhatsappMutation) ResetCc() {
  40047. m.cc = nil
  40048. }
  40049. // SetPhone sets the "phone" field.
  40050. func (m *WhatsappMutation) SetPhone(s string) {
  40051. m.phone = &s
  40052. }
  40053. // Phone returns the value of the "phone" field in the mutation.
  40054. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  40055. v := m.phone
  40056. if v == nil {
  40057. return
  40058. }
  40059. return *v, true
  40060. }
  40061. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  40062. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40064. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  40065. if !m.op.Is(OpUpdateOne) {
  40066. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40067. }
  40068. if m.id == nil || m.oldValue == nil {
  40069. return v, errors.New("OldPhone requires an ID field in the mutation")
  40070. }
  40071. oldValue, err := m.oldValue(ctx)
  40072. if err != nil {
  40073. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40074. }
  40075. return oldValue.Phone, nil
  40076. }
  40077. // ResetPhone resets all changes to the "phone" field.
  40078. func (m *WhatsappMutation) ResetPhone() {
  40079. m.phone = nil
  40080. }
  40081. // SetCcPhone sets the "cc_phone" field.
  40082. func (m *WhatsappMutation) SetCcPhone(s string) {
  40083. m.cc_phone = &s
  40084. }
  40085. // CcPhone returns the value of the "cc_phone" field in the mutation.
  40086. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  40087. v := m.cc_phone
  40088. if v == nil {
  40089. return
  40090. }
  40091. return *v, true
  40092. }
  40093. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  40094. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40096. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  40097. if !m.op.Is(OpUpdateOne) {
  40098. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  40099. }
  40100. if m.id == nil || m.oldValue == nil {
  40101. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  40102. }
  40103. oldValue, err := m.oldValue(ctx)
  40104. if err != nil {
  40105. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  40106. }
  40107. return oldValue.CcPhone, nil
  40108. }
  40109. // ResetCcPhone resets all changes to the "cc_phone" field.
  40110. func (m *WhatsappMutation) ResetCcPhone() {
  40111. m.cc_phone = nil
  40112. }
  40113. // SetPhoneName sets the "phone_name" field.
  40114. func (m *WhatsappMutation) SetPhoneName(s string) {
  40115. m.phone_name = &s
  40116. }
  40117. // PhoneName returns the value of the "phone_name" field in the mutation.
  40118. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  40119. v := m.phone_name
  40120. if v == nil {
  40121. return
  40122. }
  40123. return *v, true
  40124. }
  40125. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  40126. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40128. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  40129. if !m.op.Is(OpUpdateOne) {
  40130. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  40131. }
  40132. if m.id == nil || m.oldValue == nil {
  40133. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  40134. }
  40135. oldValue, err := m.oldValue(ctx)
  40136. if err != nil {
  40137. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  40138. }
  40139. return oldValue.PhoneName, nil
  40140. }
  40141. // ResetPhoneName resets all changes to the "phone_name" field.
  40142. func (m *WhatsappMutation) ResetPhoneName() {
  40143. m.phone_name = nil
  40144. }
  40145. // SetPhoneStatus sets the "phone_status" field.
  40146. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  40147. m.phone_status = &i
  40148. m.addphone_status = nil
  40149. }
  40150. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  40151. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  40152. v := m.phone_status
  40153. if v == nil {
  40154. return
  40155. }
  40156. return *v, true
  40157. }
  40158. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  40159. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40161. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  40162. if !m.op.Is(OpUpdateOne) {
  40163. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  40164. }
  40165. if m.id == nil || m.oldValue == nil {
  40166. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  40167. }
  40168. oldValue, err := m.oldValue(ctx)
  40169. if err != nil {
  40170. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  40171. }
  40172. return oldValue.PhoneStatus, nil
  40173. }
  40174. // AddPhoneStatus adds i to the "phone_status" field.
  40175. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  40176. if m.addphone_status != nil {
  40177. *m.addphone_status += i
  40178. } else {
  40179. m.addphone_status = &i
  40180. }
  40181. }
  40182. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  40183. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  40184. v := m.addphone_status
  40185. if v == nil {
  40186. return
  40187. }
  40188. return *v, true
  40189. }
  40190. // ResetPhoneStatus resets all changes to the "phone_status" field.
  40191. func (m *WhatsappMutation) ResetPhoneStatus() {
  40192. m.phone_status = nil
  40193. m.addphone_status = nil
  40194. }
  40195. // SetOrganizationID sets the "organization_id" field.
  40196. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  40197. m.organization_id = &u
  40198. m.addorganization_id = nil
  40199. }
  40200. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40201. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  40202. v := m.organization_id
  40203. if v == nil {
  40204. return
  40205. }
  40206. return *v, true
  40207. }
  40208. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  40209. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40211. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40212. if !m.op.Is(OpUpdateOne) {
  40213. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40214. }
  40215. if m.id == nil || m.oldValue == nil {
  40216. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40217. }
  40218. oldValue, err := m.oldValue(ctx)
  40219. if err != nil {
  40220. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40221. }
  40222. return oldValue.OrganizationID, nil
  40223. }
  40224. // AddOrganizationID adds u to the "organization_id" field.
  40225. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  40226. if m.addorganization_id != nil {
  40227. *m.addorganization_id += u
  40228. } else {
  40229. m.addorganization_id = &u
  40230. }
  40231. }
  40232. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40233. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  40234. v := m.addorganization_id
  40235. if v == nil {
  40236. return
  40237. }
  40238. return *v, true
  40239. }
  40240. // ClearOrganizationID clears the value of the "organization_id" field.
  40241. func (m *WhatsappMutation) ClearOrganizationID() {
  40242. m.organization_id = nil
  40243. m.addorganization_id = nil
  40244. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  40245. }
  40246. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  40247. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  40248. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  40249. return ok
  40250. }
  40251. // ResetOrganizationID resets all changes to the "organization_id" field.
  40252. func (m *WhatsappMutation) ResetOrganizationID() {
  40253. m.organization_id = nil
  40254. m.addorganization_id = nil
  40255. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  40256. }
  40257. // SetAPIBase sets the "api_base" field.
  40258. func (m *WhatsappMutation) SetAPIBase(s string) {
  40259. m.api_base = &s
  40260. }
  40261. // APIBase returns the value of the "api_base" field in the mutation.
  40262. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  40263. v := m.api_base
  40264. if v == nil {
  40265. return
  40266. }
  40267. return *v, true
  40268. }
  40269. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  40270. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40272. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  40273. if !m.op.Is(OpUpdateOne) {
  40274. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  40275. }
  40276. if m.id == nil || m.oldValue == nil {
  40277. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  40278. }
  40279. oldValue, err := m.oldValue(ctx)
  40280. if err != nil {
  40281. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  40282. }
  40283. return oldValue.APIBase, nil
  40284. }
  40285. // ClearAPIBase clears the value of the "api_base" field.
  40286. func (m *WhatsappMutation) ClearAPIBase() {
  40287. m.api_base = nil
  40288. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  40289. }
  40290. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  40291. func (m *WhatsappMutation) APIBaseCleared() bool {
  40292. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  40293. return ok
  40294. }
  40295. // ResetAPIBase resets all changes to the "api_base" field.
  40296. func (m *WhatsappMutation) ResetAPIBase() {
  40297. m.api_base = nil
  40298. delete(m.clearedFields, whatsapp.FieldAPIBase)
  40299. }
  40300. // SetAPIKey sets the "api_key" field.
  40301. func (m *WhatsappMutation) SetAPIKey(s string) {
  40302. m.api_key = &s
  40303. }
  40304. // APIKey returns the value of the "api_key" field in the mutation.
  40305. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  40306. v := m.api_key
  40307. if v == nil {
  40308. return
  40309. }
  40310. return *v, true
  40311. }
  40312. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  40313. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40315. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  40316. if !m.op.Is(OpUpdateOne) {
  40317. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  40318. }
  40319. if m.id == nil || m.oldValue == nil {
  40320. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  40321. }
  40322. oldValue, err := m.oldValue(ctx)
  40323. if err != nil {
  40324. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  40325. }
  40326. return oldValue.APIKey, nil
  40327. }
  40328. // ClearAPIKey clears the value of the "api_key" field.
  40329. func (m *WhatsappMutation) ClearAPIKey() {
  40330. m.api_key = nil
  40331. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  40332. }
  40333. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  40334. func (m *WhatsappMutation) APIKeyCleared() bool {
  40335. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  40336. return ok
  40337. }
  40338. // ResetAPIKey resets all changes to the "api_key" field.
  40339. func (m *WhatsappMutation) ResetAPIKey() {
  40340. m.api_key = nil
  40341. delete(m.clearedFields, whatsapp.FieldAPIKey)
  40342. }
  40343. // SetAllowList sets the "allow_list" field.
  40344. func (m *WhatsappMutation) SetAllowList(s []string) {
  40345. m.allow_list = &s
  40346. m.appendallow_list = nil
  40347. }
  40348. // AllowList returns the value of the "allow_list" field in the mutation.
  40349. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  40350. v := m.allow_list
  40351. if v == nil {
  40352. return
  40353. }
  40354. return *v, true
  40355. }
  40356. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  40357. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40359. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  40360. if !m.op.Is(OpUpdateOne) {
  40361. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  40362. }
  40363. if m.id == nil || m.oldValue == nil {
  40364. return v, errors.New("OldAllowList requires an ID field in the mutation")
  40365. }
  40366. oldValue, err := m.oldValue(ctx)
  40367. if err != nil {
  40368. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  40369. }
  40370. return oldValue.AllowList, nil
  40371. }
  40372. // AppendAllowList adds s to the "allow_list" field.
  40373. func (m *WhatsappMutation) AppendAllowList(s []string) {
  40374. m.appendallow_list = append(m.appendallow_list, s...)
  40375. }
  40376. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  40377. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  40378. if len(m.appendallow_list) == 0 {
  40379. return nil, false
  40380. }
  40381. return m.appendallow_list, true
  40382. }
  40383. // ClearAllowList clears the value of the "allow_list" field.
  40384. func (m *WhatsappMutation) ClearAllowList() {
  40385. m.allow_list = nil
  40386. m.appendallow_list = nil
  40387. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  40388. }
  40389. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  40390. func (m *WhatsappMutation) AllowListCleared() bool {
  40391. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  40392. return ok
  40393. }
  40394. // ResetAllowList resets all changes to the "allow_list" field.
  40395. func (m *WhatsappMutation) ResetAllowList() {
  40396. m.allow_list = nil
  40397. m.appendallow_list = nil
  40398. delete(m.clearedFields, whatsapp.FieldAllowList)
  40399. }
  40400. // SetGroupAllowList sets the "group_allow_list" field.
  40401. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  40402. m.group_allow_list = &s
  40403. m.appendgroup_allow_list = nil
  40404. }
  40405. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  40406. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  40407. v := m.group_allow_list
  40408. if v == nil {
  40409. return
  40410. }
  40411. return *v, true
  40412. }
  40413. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  40414. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40416. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  40417. if !m.op.Is(OpUpdateOne) {
  40418. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  40419. }
  40420. if m.id == nil || m.oldValue == nil {
  40421. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  40422. }
  40423. oldValue, err := m.oldValue(ctx)
  40424. if err != nil {
  40425. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  40426. }
  40427. return oldValue.GroupAllowList, nil
  40428. }
  40429. // AppendGroupAllowList adds s to the "group_allow_list" field.
  40430. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  40431. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  40432. }
  40433. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  40434. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  40435. if len(m.appendgroup_allow_list) == 0 {
  40436. return nil, false
  40437. }
  40438. return m.appendgroup_allow_list, true
  40439. }
  40440. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  40441. func (m *WhatsappMutation) ClearGroupAllowList() {
  40442. m.group_allow_list = nil
  40443. m.appendgroup_allow_list = nil
  40444. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  40445. }
  40446. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  40447. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  40448. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  40449. return ok
  40450. }
  40451. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  40452. func (m *WhatsappMutation) ResetGroupAllowList() {
  40453. m.group_allow_list = nil
  40454. m.appendgroup_allow_list = nil
  40455. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  40456. }
  40457. // SetBlockList sets the "block_list" field.
  40458. func (m *WhatsappMutation) SetBlockList(s []string) {
  40459. m.block_list = &s
  40460. m.appendblock_list = nil
  40461. }
  40462. // BlockList returns the value of the "block_list" field in the mutation.
  40463. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  40464. v := m.block_list
  40465. if v == nil {
  40466. return
  40467. }
  40468. return *v, true
  40469. }
  40470. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  40471. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40473. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  40474. if !m.op.Is(OpUpdateOne) {
  40475. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  40476. }
  40477. if m.id == nil || m.oldValue == nil {
  40478. return v, errors.New("OldBlockList requires an ID field in the mutation")
  40479. }
  40480. oldValue, err := m.oldValue(ctx)
  40481. if err != nil {
  40482. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  40483. }
  40484. return oldValue.BlockList, nil
  40485. }
  40486. // AppendBlockList adds s to the "block_list" field.
  40487. func (m *WhatsappMutation) AppendBlockList(s []string) {
  40488. m.appendblock_list = append(m.appendblock_list, s...)
  40489. }
  40490. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  40491. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  40492. if len(m.appendblock_list) == 0 {
  40493. return nil, false
  40494. }
  40495. return m.appendblock_list, true
  40496. }
  40497. // ClearBlockList clears the value of the "block_list" field.
  40498. func (m *WhatsappMutation) ClearBlockList() {
  40499. m.block_list = nil
  40500. m.appendblock_list = nil
  40501. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  40502. }
  40503. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  40504. func (m *WhatsappMutation) BlockListCleared() bool {
  40505. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  40506. return ok
  40507. }
  40508. // ResetBlockList resets all changes to the "block_list" field.
  40509. func (m *WhatsappMutation) ResetBlockList() {
  40510. m.block_list = nil
  40511. m.appendblock_list = nil
  40512. delete(m.clearedFields, whatsapp.FieldBlockList)
  40513. }
  40514. // SetGroupBlockList sets the "group_block_list" field.
  40515. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  40516. m.group_block_list = &s
  40517. m.appendgroup_block_list = nil
  40518. }
  40519. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  40520. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  40521. v := m.group_block_list
  40522. if v == nil {
  40523. return
  40524. }
  40525. return *v, true
  40526. }
  40527. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  40528. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  40529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40530. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  40531. if !m.op.Is(OpUpdateOne) {
  40532. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  40533. }
  40534. if m.id == nil || m.oldValue == nil {
  40535. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  40536. }
  40537. oldValue, err := m.oldValue(ctx)
  40538. if err != nil {
  40539. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  40540. }
  40541. return oldValue.GroupBlockList, nil
  40542. }
  40543. // AppendGroupBlockList adds s to the "group_block_list" field.
  40544. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  40545. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  40546. }
  40547. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  40548. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  40549. if len(m.appendgroup_block_list) == 0 {
  40550. return nil, false
  40551. }
  40552. return m.appendgroup_block_list, true
  40553. }
  40554. // ClearGroupBlockList clears the value of the "group_block_list" field.
  40555. func (m *WhatsappMutation) ClearGroupBlockList() {
  40556. m.group_block_list = nil
  40557. m.appendgroup_block_list = nil
  40558. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  40559. }
  40560. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  40561. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  40562. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  40563. return ok
  40564. }
  40565. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  40566. func (m *WhatsappMutation) ResetGroupBlockList() {
  40567. m.group_block_list = nil
  40568. m.appendgroup_block_list = nil
  40569. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  40570. }
  40571. // ClearAgent clears the "agent" edge to the Agent entity.
  40572. func (m *WhatsappMutation) ClearAgent() {
  40573. m.clearedagent = true
  40574. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  40575. }
  40576. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  40577. func (m *WhatsappMutation) AgentCleared() bool {
  40578. return m.clearedagent
  40579. }
  40580. // AgentIDs returns the "agent" edge IDs in the mutation.
  40581. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40582. // AgentID instead. It exists only for internal usage by the builders.
  40583. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  40584. if id := m.agent; id != nil {
  40585. ids = append(ids, *id)
  40586. }
  40587. return
  40588. }
  40589. // ResetAgent resets all changes to the "agent" edge.
  40590. func (m *WhatsappMutation) ResetAgent() {
  40591. m.agent = nil
  40592. m.clearedagent = false
  40593. }
  40594. // Where appends a list predicates to the WhatsappMutation builder.
  40595. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  40596. m.predicates = append(m.predicates, ps...)
  40597. }
  40598. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  40599. // users can use type-assertion to append predicates that do not depend on any generated package.
  40600. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  40601. p := make([]predicate.Whatsapp, len(ps))
  40602. for i := range ps {
  40603. p[i] = ps[i]
  40604. }
  40605. m.Where(p...)
  40606. }
  40607. // Op returns the operation name.
  40608. func (m *WhatsappMutation) Op() Op {
  40609. return m.op
  40610. }
  40611. // SetOp allows setting the mutation operation.
  40612. func (m *WhatsappMutation) SetOp(op Op) {
  40613. m.op = op
  40614. }
  40615. // Type returns the node type of this mutation (Whatsapp).
  40616. func (m *WhatsappMutation) Type() string {
  40617. return m.typ
  40618. }
  40619. // Fields returns all fields that were changed during this mutation. Note that in
  40620. // order to get all numeric fields that were incremented/decremented, call
  40621. // AddedFields().
  40622. func (m *WhatsappMutation) Fields() []string {
  40623. fields := make([]string, 0, 21)
  40624. if m.created_at != nil {
  40625. fields = append(fields, whatsapp.FieldCreatedAt)
  40626. }
  40627. if m.updated_at != nil {
  40628. fields = append(fields, whatsapp.FieldUpdatedAt)
  40629. }
  40630. if m.status != nil {
  40631. fields = append(fields, whatsapp.FieldStatus)
  40632. }
  40633. if m.deleted_at != nil {
  40634. fields = append(fields, whatsapp.FieldDeletedAt)
  40635. }
  40636. if m.wa_id != nil {
  40637. fields = append(fields, whatsapp.FieldWaID)
  40638. }
  40639. if m.wa_name != nil {
  40640. fields = append(fields, whatsapp.FieldWaName)
  40641. }
  40642. if m.callback != nil {
  40643. fields = append(fields, whatsapp.FieldCallback)
  40644. }
  40645. if m.agent != nil {
  40646. fields = append(fields, whatsapp.FieldAgentID)
  40647. }
  40648. if m.account != nil {
  40649. fields = append(fields, whatsapp.FieldAccount)
  40650. }
  40651. if m.cc != nil {
  40652. fields = append(fields, whatsapp.FieldCc)
  40653. }
  40654. if m.phone != nil {
  40655. fields = append(fields, whatsapp.FieldPhone)
  40656. }
  40657. if m.cc_phone != nil {
  40658. fields = append(fields, whatsapp.FieldCcPhone)
  40659. }
  40660. if m.phone_name != nil {
  40661. fields = append(fields, whatsapp.FieldPhoneName)
  40662. }
  40663. if m.phone_status != nil {
  40664. fields = append(fields, whatsapp.FieldPhoneStatus)
  40665. }
  40666. if m.organization_id != nil {
  40667. fields = append(fields, whatsapp.FieldOrganizationID)
  40668. }
  40669. if m.api_base != nil {
  40670. fields = append(fields, whatsapp.FieldAPIBase)
  40671. }
  40672. if m.api_key != nil {
  40673. fields = append(fields, whatsapp.FieldAPIKey)
  40674. }
  40675. if m.allow_list != nil {
  40676. fields = append(fields, whatsapp.FieldAllowList)
  40677. }
  40678. if m.group_allow_list != nil {
  40679. fields = append(fields, whatsapp.FieldGroupAllowList)
  40680. }
  40681. if m.block_list != nil {
  40682. fields = append(fields, whatsapp.FieldBlockList)
  40683. }
  40684. if m.group_block_list != nil {
  40685. fields = append(fields, whatsapp.FieldGroupBlockList)
  40686. }
  40687. return fields
  40688. }
  40689. // Field returns the value of a field with the given name. The second boolean
  40690. // return value indicates that this field was not set, or was not defined in the
  40691. // schema.
  40692. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  40693. switch name {
  40694. case whatsapp.FieldCreatedAt:
  40695. return m.CreatedAt()
  40696. case whatsapp.FieldUpdatedAt:
  40697. return m.UpdatedAt()
  40698. case whatsapp.FieldStatus:
  40699. return m.Status()
  40700. case whatsapp.FieldDeletedAt:
  40701. return m.DeletedAt()
  40702. case whatsapp.FieldWaID:
  40703. return m.WaID()
  40704. case whatsapp.FieldWaName:
  40705. return m.WaName()
  40706. case whatsapp.FieldCallback:
  40707. return m.Callback()
  40708. case whatsapp.FieldAgentID:
  40709. return m.AgentID()
  40710. case whatsapp.FieldAccount:
  40711. return m.Account()
  40712. case whatsapp.FieldCc:
  40713. return m.Cc()
  40714. case whatsapp.FieldPhone:
  40715. return m.Phone()
  40716. case whatsapp.FieldCcPhone:
  40717. return m.CcPhone()
  40718. case whatsapp.FieldPhoneName:
  40719. return m.PhoneName()
  40720. case whatsapp.FieldPhoneStatus:
  40721. return m.PhoneStatus()
  40722. case whatsapp.FieldOrganizationID:
  40723. return m.OrganizationID()
  40724. case whatsapp.FieldAPIBase:
  40725. return m.APIBase()
  40726. case whatsapp.FieldAPIKey:
  40727. return m.APIKey()
  40728. case whatsapp.FieldAllowList:
  40729. return m.AllowList()
  40730. case whatsapp.FieldGroupAllowList:
  40731. return m.GroupAllowList()
  40732. case whatsapp.FieldBlockList:
  40733. return m.BlockList()
  40734. case whatsapp.FieldGroupBlockList:
  40735. return m.GroupBlockList()
  40736. }
  40737. return nil, false
  40738. }
  40739. // OldField returns the old value of the field from the database. An error is
  40740. // returned if the mutation operation is not UpdateOne, or the query to the
  40741. // database failed.
  40742. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40743. switch name {
  40744. case whatsapp.FieldCreatedAt:
  40745. return m.OldCreatedAt(ctx)
  40746. case whatsapp.FieldUpdatedAt:
  40747. return m.OldUpdatedAt(ctx)
  40748. case whatsapp.FieldStatus:
  40749. return m.OldStatus(ctx)
  40750. case whatsapp.FieldDeletedAt:
  40751. return m.OldDeletedAt(ctx)
  40752. case whatsapp.FieldWaID:
  40753. return m.OldWaID(ctx)
  40754. case whatsapp.FieldWaName:
  40755. return m.OldWaName(ctx)
  40756. case whatsapp.FieldCallback:
  40757. return m.OldCallback(ctx)
  40758. case whatsapp.FieldAgentID:
  40759. return m.OldAgentID(ctx)
  40760. case whatsapp.FieldAccount:
  40761. return m.OldAccount(ctx)
  40762. case whatsapp.FieldCc:
  40763. return m.OldCc(ctx)
  40764. case whatsapp.FieldPhone:
  40765. return m.OldPhone(ctx)
  40766. case whatsapp.FieldCcPhone:
  40767. return m.OldCcPhone(ctx)
  40768. case whatsapp.FieldPhoneName:
  40769. return m.OldPhoneName(ctx)
  40770. case whatsapp.FieldPhoneStatus:
  40771. return m.OldPhoneStatus(ctx)
  40772. case whatsapp.FieldOrganizationID:
  40773. return m.OldOrganizationID(ctx)
  40774. case whatsapp.FieldAPIBase:
  40775. return m.OldAPIBase(ctx)
  40776. case whatsapp.FieldAPIKey:
  40777. return m.OldAPIKey(ctx)
  40778. case whatsapp.FieldAllowList:
  40779. return m.OldAllowList(ctx)
  40780. case whatsapp.FieldGroupAllowList:
  40781. return m.OldGroupAllowList(ctx)
  40782. case whatsapp.FieldBlockList:
  40783. return m.OldBlockList(ctx)
  40784. case whatsapp.FieldGroupBlockList:
  40785. return m.OldGroupBlockList(ctx)
  40786. }
  40787. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  40788. }
  40789. // SetField sets the value of a field with the given name. It returns an error if
  40790. // the field is not defined in the schema, or if the type mismatched the field
  40791. // type.
  40792. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  40793. switch name {
  40794. case whatsapp.FieldCreatedAt:
  40795. v, ok := value.(time.Time)
  40796. if !ok {
  40797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40798. }
  40799. m.SetCreatedAt(v)
  40800. return nil
  40801. case whatsapp.FieldUpdatedAt:
  40802. v, ok := value.(time.Time)
  40803. if !ok {
  40804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40805. }
  40806. m.SetUpdatedAt(v)
  40807. return nil
  40808. case whatsapp.FieldStatus:
  40809. v, ok := value.(uint8)
  40810. if !ok {
  40811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40812. }
  40813. m.SetStatus(v)
  40814. return nil
  40815. case whatsapp.FieldDeletedAt:
  40816. v, ok := value.(time.Time)
  40817. if !ok {
  40818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40819. }
  40820. m.SetDeletedAt(v)
  40821. return nil
  40822. case whatsapp.FieldWaID:
  40823. v, ok := value.(string)
  40824. if !ok {
  40825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40826. }
  40827. m.SetWaID(v)
  40828. return nil
  40829. case whatsapp.FieldWaName:
  40830. v, ok := value.(string)
  40831. if !ok {
  40832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40833. }
  40834. m.SetWaName(v)
  40835. return nil
  40836. case whatsapp.FieldCallback:
  40837. v, ok := value.(string)
  40838. if !ok {
  40839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40840. }
  40841. m.SetCallback(v)
  40842. return nil
  40843. case whatsapp.FieldAgentID:
  40844. v, ok := value.(uint64)
  40845. if !ok {
  40846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40847. }
  40848. m.SetAgentID(v)
  40849. return nil
  40850. case whatsapp.FieldAccount:
  40851. v, ok := value.(string)
  40852. if !ok {
  40853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40854. }
  40855. m.SetAccount(v)
  40856. return nil
  40857. case whatsapp.FieldCc:
  40858. v, ok := value.(string)
  40859. if !ok {
  40860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40861. }
  40862. m.SetCc(v)
  40863. return nil
  40864. case whatsapp.FieldPhone:
  40865. v, ok := value.(string)
  40866. if !ok {
  40867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40868. }
  40869. m.SetPhone(v)
  40870. return nil
  40871. case whatsapp.FieldCcPhone:
  40872. v, ok := value.(string)
  40873. if !ok {
  40874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40875. }
  40876. m.SetCcPhone(v)
  40877. return nil
  40878. case whatsapp.FieldPhoneName:
  40879. v, ok := value.(string)
  40880. if !ok {
  40881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40882. }
  40883. m.SetPhoneName(v)
  40884. return nil
  40885. case whatsapp.FieldPhoneStatus:
  40886. v, ok := value.(int8)
  40887. if !ok {
  40888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40889. }
  40890. m.SetPhoneStatus(v)
  40891. return nil
  40892. case whatsapp.FieldOrganizationID:
  40893. v, ok := value.(uint64)
  40894. if !ok {
  40895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40896. }
  40897. m.SetOrganizationID(v)
  40898. return nil
  40899. case whatsapp.FieldAPIBase:
  40900. v, ok := value.(string)
  40901. if !ok {
  40902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40903. }
  40904. m.SetAPIBase(v)
  40905. return nil
  40906. case whatsapp.FieldAPIKey:
  40907. v, ok := value.(string)
  40908. if !ok {
  40909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40910. }
  40911. m.SetAPIKey(v)
  40912. return nil
  40913. case whatsapp.FieldAllowList:
  40914. v, ok := value.([]string)
  40915. if !ok {
  40916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40917. }
  40918. m.SetAllowList(v)
  40919. return nil
  40920. case whatsapp.FieldGroupAllowList:
  40921. v, ok := value.([]string)
  40922. if !ok {
  40923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40924. }
  40925. m.SetGroupAllowList(v)
  40926. return nil
  40927. case whatsapp.FieldBlockList:
  40928. v, ok := value.([]string)
  40929. if !ok {
  40930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40931. }
  40932. m.SetBlockList(v)
  40933. return nil
  40934. case whatsapp.FieldGroupBlockList:
  40935. v, ok := value.([]string)
  40936. if !ok {
  40937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40938. }
  40939. m.SetGroupBlockList(v)
  40940. return nil
  40941. }
  40942. return fmt.Errorf("unknown Whatsapp field %s", name)
  40943. }
  40944. // AddedFields returns all numeric fields that were incremented/decremented during
  40945. // this mutation.
  40946. func (m *WhatsappMutation) AddedFields() []string {
  40947. var fields []string
  40948. if m.addstatus != nil {
  40949. fields = append(fields, whatsapp.FieldStatus)
  40950. }
  40951. if m.addphone_status != nil {
  40952. fields = append(fields, whatsapp.FieldPhoneStatus)
  40953. }
  40954. if m.addorganization_id != nil {
  40955. fields = append(fields, whatsapp.FieldOrganizationID)
  40956. }
  40957. return fields
  40958. }
  40959. // AddedField returns the numeric value that was incremented/decremented on a field
  40960. // with the given name. The second boolean return value indicates that this field
  40961. // was not set, or was not defined in the schema.
  40962. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  40963. switch name {
  40964. case whatsapp.FieldStatus:
  40965. return m.AddedStatus()
  40966. case whatsapp.FieldPhoneStatus:
  40967. return m.AddedPhoneStatus()
  40968. case whatsapp.FieldOrganizationID:
  40969. return m.AddedOrganizationID()
  40970. }
  40971. return nil, false
  40972. }
  40973. // AddField adds the value to the field with the given name. It returns an error if
  40974. // the field is not defined in the schema, or if the type mismatched the field
  40975. // type.
  40976. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  40977. switch name {
  40978. case whatsapp.FieldStatus:
  40979. v, ok := value.(int8)
  40980. if !ok {
  40981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40982. }
  40983. m.AddStatus(v)
  40984. return nil
  40985. case whatsapp.FieldPhoneStatus:
  40986. v, ok := value.(int8)
  40987. if !ok {
  40988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40989. }
  40990. m.AddPhoneStatus(v)
  40991. return nil
  40992. case whatsapp.FieldOrganizationID:
  40993. v, ok := value.(int64)
  40994. if !ok {
  40995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40996. }
  40997. m.AddOrganizationID(v)
  40998. return nil
  40999. }
  41000. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  41001. }
  41002. // ClearedFields returns all nullable fields that were cleared during this
  41003. // mutation.
  41004. func (m *WhatsappMutation) ClearedFields() []string {
  41005. var fields []string
  41006. if m.FieldCleared(whatsapp.FieldStatus) {
  41007. fields = append(fields, whatsapp.FieldStatus)
  41008. }
  41009. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  41010. fields = append(fields, whatsapp.FieldDeletedAt)
  41011. }
  41012. if m.FieldCleared(whatsapp.FieldWaID) {
  41013. fields = append(fields, whatsapp.FieldWaID)
  41014. }
  41015. if m.FieldCleared(whatsapp.FieldWaName) {
  41016. fields = append(fields, whatsapp.FieldWaName)
  41017. }
  41018. if m.FieldCleared(whatsapp.FieldCallback) {
  41019. fields = append(fields, whatsapp.FieldCallback)
  41020. }
  41021. if m.FieldCleared(whatsapp.FieldAccount) {
  41022. fields = append(fields, whatsapp.FieldAccount)
  41023. }
  41024. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  41025. fields = append(fields, whatsapp.FieldOrganizationID)
  41026. }
  41027. if m.FieldCleared(whatsapp.FieldAPIBase) {
  41028. fields = append(fields, whatsapp.FieldAPIBase)
  41029. }
  41030. if m.FieldCleared(whatsapp.FieldAPIKey) {
  41031. fields = append(fields, whatsapp.FieldAPIKey)
  41032. }
  41033. if m.FieldCleared(whatsapp.FieldAllowList) {
  41034. fields = append(fields, whatsapp.FieldAllowList)
  41035. }
  41036. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  41037. fields = append(fields, whatsapp.FieldGroupAllowList)
  41038. }
  41039. if m.FieldCleared(whatsapp.FieldBlockList) {
  41040. fields = append(fields, whatsapp.FieldBlockList)
  41041. }
  41042. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  41043. fields = append(fields, whatsapp.FieldGroupBlockList)
  41044. }
  41045. return fields
  41046. }
  41047. // FieldCleared returns a boolean indicating if a field with the given name was
  41048. // cleared in this mutation.
  41049. func (m *WhatsappMutation) FieldCleared(name string) bool {
  41050. _, ok := m.clearedFields[name]
  41051. return ok
  41052. }
  41053. // ClearField clears the value of the field with the given name. It returns an
  41054. // error if the field is not defined in the schema.
  41055. func (m *WhatsappMutation) ClearField(name string) error {
  41056. switch name {
  41057. case whatsapp.FieldStatus:
  41058. m.ClearStatus()
  41059. return nil
  41060. case whatsapp.FieldDeletedAt:
  41061. m.ClearDeletedAt()
  41062. return nil
  41063. case whatsapp.FieldWaID:
  41064. m.ClearWaID()
  41065. return nil
  41066. case whatsapp.FieldWaName:
  41067. m.ClearWaName()
  41068. return nil
  41069. case whatsapp.FieldCallback:
  41070. m.ClearCallback()
  41071. return nil
  41072. case whatsapp.FieldAccount:
  41073. m.ClearAccount()
  41074. return nil
  41075. case whatsapp.FieldOrganizationID:
  41076. m.ClearOrganizationID()
  41077. return nil
  41078. case whatsapp.FieldAPIBase:
  41079. m.ClearAPIBase()
  41080. return nil
  41081. case whatsapp.FieldAPIKey:
  41082. m.ClearAPIKey()
  41083. return nil
  41084. case whatsapp.FieldAllowList:
  41085. m.ClearAllowList()
  41086. return nil
  41087. case whatsapp.FieldGroupAllowList:
  41088. m.ClearGroupAllowList()
  41089. return nil
  41090. case whatsapp.FieldBlockList:
  41091. m.ClearBlockList()
  41092. return nil
  41093. case whatsapp.FieldGroupBlockList:
  41094. m.ClearGroupBlockList()
  41095. return nil
  41096. }
  41097. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  41098. }
  41099. // ResetField resets all changes in the mutation for the field with the given name.
  41100. // It returns an error if the field is not defined in the schema.
  41101. func (m *WhatsappMutation) ResetField(name string) error {
  41102. switch name {
  41103. case whatsapp.FieldCreatedAt:
  41104. m.ResetCreatedAt()
  41105. return nil
  41106. case whatsapp.FieldUpdatedAt:
  41107. m.ResetUpdatedAt()
  41108. return nil
  41109. case whatsapp.FieldStatus:
  41110. m.ResetStatus()
  41111. return nil
  41112. case whatsapp.FieldDeletedAt:
  41113. m.ResetDeletedAt()
  41114. return nil
  41115. case whatsapp.FieldWaID:
  41116. m.ResetWaID()
  41117. return nil
  41118. case whatsapp.FieldWaName:
  41119. m.ResetWaName()
  41120. return nil
  41121. case whatsapp.FieldCallback:
  41122. m.ResetCallback()
  41123. return nil
  41124. case whatsapp.FieldAgentID:
  41125. m.ResetAgentID()
  41126. return nil
  41127. case whatsapp.FieldAccount:
  41128. m.ResetAccount()
  41129. return nil
  41130. case whatsapp.FieldCc:
  41131. m.ResetCc()
  41132. return nil
  41133. case whatsapp.FieldPhone:
  41134. m.ResetPhone()
  41135. return nil
  41136. case whatsapp.FieldCcPhone:
  41137. m.ResetCcPhone()
  41138. return nil
  41139. case whatsapp.FieldPhoneName:
  41140. m.ResetPhoneName()
  41141. return nil
  41142. case whatsapp.FieldPhoneStatus:
  41143. m.ResetPhoneStatus()
  41144. return nil
  41145. case whatsapp.FieldOrganizationID:
  41146. m.ResetOrganizationID()
  41147. return nil
  41148. case whatsapp.FieldAPIBase:
  41149. m.ResetAPIBase()
  41150. return nil
  41151. case whatsapp.FieldAPIKey:
  41152. m.ResetAPIKey()
  41153. return nil
  41154. case whatsapp.FieldAllowList:
  41155. m.ResetAllowList()
  41156. return nil
  41157. case whatsapp.FieldGroupAllowList:
  41158. m.ResetGroupAllowList()
  41159. return nil
  41160. case whatsapp.FieldBlockList:
  41161. m.ResetBlockList()
  41162. return nil
  41163. case whatsapp.FieldGroupBlockList:
  41164. m.ResetGroupBlockList()
  41165. return nil
  41166. }
  41167. return fmt.Errorf("unknown Whatsapp field %s", name)
  41168. }
  41169. // AddedEdges returns all edge names that were set/added in this mutation.
  41170. func (m *WhatsappMutation) AddedEdges() []string {
  41171. edges := make([]string, 0, 1)
  41172. if m.agent != nil {
  41173. edges = append(edges, whatsapp.EdgeAgent)
  41174. }
  41175. return edges
  41176. }
  41177. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41178. // name in this mutation.
  41179. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  41180. switch name {
  41181. case whatsapp.EdgeAgent:
  41182. if id := m.agent; id != nil {
  41183. return []ent.Value{*id}
  41184. }
  41185. }
  41186. return nil
  41187. }
  41188. // RemovedEdges returns all edge names that were removed in this mutation.
  41189. func (m *WhatsappMutation) RemovedEdges() []string {
  41190. edges := make([]string, 0, 1)
  41191. return edges
  41192. }
  41193. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41194. // the given name in this mutation.
  41195. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  41196. return nil
  41197. }
  41198. // ClearedEdges returns all edge names that were cleared in this mutation.
  41199. func (m *WhatsappMutation) ClearedEdges() []string {
  41200. edges := make([]string, 0, 1)
  41201. if m.clearedagent {
  41202. edges = append(edges, whatsapp.EdgeAgent)
  41203. }
  41204. return edges
  41205. }
  41206. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41207. // was cleared in this mutation.
  41208. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  41209. switch name {
  41210. case whatsapp.EdgeAgent:
  41211. return m.clearedagent
  41212. }
  41213. return false
  41214. }
  41215. // ClearEdge clears the value of the edge with the given name. It returns an error
  41216. // if that edge is not defined in the schema.
  41217. func (m *WhatsappMutation) ClearEdge(name string) error {
  41218. switch name {
  41219. case whatsapp.EdgeAgent:
  41220. m.ClearAgent()
  41221. return nil
  41222. }
  41223. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  41224. }
  41225. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41226. // It returns an error if the edge is not defined in the schema.
  41227. func (m *WhatsappMutation) ResetEdge(name string) error {
  41228. switch name {
  41229. case whatsapp.EdgeAgent:
  41230. m.ResetAgent()
  41231. return nil
  41232. }
  41233. return fmt.Errorf("unknown Whatsapp edge %s", name)
  41234. }
  41235. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  41236. type WhatsappChannelMutation struct {
  41237. config
  41238. op Op
  41239. typ string
  41240. id *uint64
  41241. created_at *time.Time
  41242. updated_at *time.Time
  41243. status *uint8
  41244. addstatus *int8
  41245. deleted_at *time.Time
  41246. ak *string
  41247. sk *string
  41248. wa_id *string
  41249. wa_name *string
  41250. waba_id *uint64
  41251. addwaba_id *int64
  41252. business_id *uint64
  41253. addbusiness_id *int64
  41254. organization_id *uint64
  41255. addorganization_id *int64
  41256. verify_account *string
  41257. clearedFields map[string]struct{}
  41258. done bool
  41259. oldValue func(context.Context) (*WhatsappChannel, error)
  41260. predicates []predicate.WhatsappChannel
  41261. }
  41262. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  41263. // whatsappchannelOption allows management of the mutation configuration using functional options.
  41264. type whatsappchannelOption func(*WhatsappChannelMutation)
  41265. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  41266. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  41267. m := &WhatsappChannelMutation{
  41268. config: c,
  41269. op: op,
  41270. typ: TypeWhatsappChannel,
  41271. clearedFields: make(map[string]struct{}),
  41272. }
  41273. for _, opt := range opts {
  41274. opt(m)
  41275. }
  41276. return m
  41277. }
  41278. // withWhatsappChannelID sets the ID field of the mutation.
  41279. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  41280. return func(m *WhatsappChannelMutation) {
  41281. var (
  41282. err error
  41283. once sync.Once
  41284. value *WhatsappChannel
  41285. )
  41286. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  41287. once.Do(func() {
  41288. if m.done {
  41289. err = errors.New("querying old values post mutation is not allowed")
  41290. } else {
  41291. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  41292. }
  41293. })
  41294. return value, err
  41295. }
  41296. m.id = &id
  41297. }
  41298. }
  41299. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  41300. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  41301. return func(m *WhatsappChannelMutation) {
  41302. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  41303. return node, nil
  41304. }
  41305. m.id = &node.ID
  41306. }
  41307. }
  41308. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41309. // executed in a transaction (ent.Tx), a transactional client is returned.
  41310. func (m WhatsappChannelMutation) Client() *Client {
  41311. client := &Client{config: m.config}
  41312. client.init()
  41313. return client
  41314. }
  41315. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41316. // it returns an error otherwise.
  41317. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  41318. if _, ok := m.driver.(*txDriver); !ok {
  41319. return nil, errors.New("ent: mutation is not running in a transaction")
  41320. }
  41321. tx := &Tx{config: m.config}
  41322. tx.init()
  41323. return tx, nil
  41324. }
  41325. // SetID sets the value of the id field. Note that this
  41326. // operation is only accepted on creation of WhatsappChannel entities.
  41327. func (m *WhatsappChannelMutation) SetID(id uint64) {
  41328. m.id = &id
  41329. }
  41330. // ID returns the ID value in the mutation. Note that the ID is only available
  41331. // if it was provided to the builder or after it was returned from the database.
  41332. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  41333. if m.id == nil {
  41334. return
  41335. }
  41336. return *m.id, true
  41337. }
  41338. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41339. // That means, if the mutation is applied within a transaction with an isolation level such
  41340. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41341. // or updated by the mutation.
  41342. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  41343. switch {
  41344. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41345. id, exists := m.ID()
  41346. if exists {
  41347. return []uint64{id}, nil
  41348. }
  41349. fallthrough
  41350. case m.op.Is(OpUpdate | OpDelete):
  41351. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  41352. default:
  41353. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41354. }
  41355. }
  41356. // SetCreatedAt sets the "created_at" field.
  41357. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  41358. m.created_at = &t
  41359. }
  41360. // CreatedAt returns the value of the "created_at" field in the mutation.
  41361. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  41362. v := m.created_at
  41363. if v == nil {
  41364. return
  41365. }
  41366. return *v, true
  41367. }
  41368. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  41369. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41371. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41372. if !m.op.Is(OpUpdateOne) {
  41373. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41374. }
  41375. if m.id == nil || m.oldValue == nil {
  41376. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41377. }
  41378. oldValue, err := m.oldValue(ctx)
  41379. if err != nil {
  41380. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41381. }
  41382. return oldValue.CreatedAt, nil
  41383. }
  41384. // ResetCreatedAt resets all changes to the "created_at" field.
  41385. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  41386. m.created_at = nil
  41387. }
  41388. // SetUpdatedAt sets the "updated_at" field.
  41389. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  41390. m.updated_at = &t
  41391. }
  41392. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41393. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  41394. v := m.updated_at
  41395. if v == nil {
  41396. return
  41397. }
  41398. return *v, true
  41399. }
  41400. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  41401. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41403. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41404. if !m.op.Is(OpUpdateOne) {
  41405. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41406. }
  41407. if m.id == nil || m.oldValue == nil {
  41408. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41409. }
  41410. oldValue, err := m.oldValue(ctx)
  41411. if err != nil {
  41412. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41413. }
  41414. return oldValue.UpdatedAt, nil
  41415. }
  41416. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41417. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  41418. m.updated_at = nil
  41419. }
  41420. // SetStatus sets the "status" field.
  41421. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  41422. m.status = &u
  41423. m.addstatus = nil
  41424. }
  41425. // Status returns the value of the "status" field in the mutation.
  41426. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  41427. v := m.status
  41428. if v == nil {
  41429. return
  41430. }
  41431. return *v, true
  41432. }
  41433. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  41434. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41436. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41437. if !m.op.Is(OpUpdateOne) {
  41438. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41439. }
  41440. if m.id == nil || m.oldValue == nil {
  41441. return v, errors.New("OldStatus requires an ID field in the mutation")
  41442. }
  41443. oldValue, err := m.oldValue(ctx)
  41444. if err != nil {
  41445. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41446. }
  41447. return oldValue.Status, nil
  41448. }
  41449. // AddStatus adds u to the "status" field.
  41450. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  41451. if m.addstatus != nil {
  41452. *m.addstatus += u
  41453. } else {
  41454. m.addstatus = &u
  41455. }
  41456. }
  41457. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41458. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  41459. v := m.addstatus
  41460. if v == nil {
  41461. return
  41462. }
  41463. return *v, true
  41464. }
  41465. // ClearStatus clears the value of the "status" field.
  41466. func (m *WhatsappChannelMutation) ClearStatus() {
  41467. m.status = nil
  41468. m.addstatus = nil
  41469. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  41470. }
  41471. // StatusCleared returns if the "status" field was cleared in this mutation.
  41472. func (m *WhatsappChannelMutation) StatusCleared() bool {
  41473. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  41474. return ok
  41475. }
  41476. // ResetStatus resets all changes to the "status" field.
  41477. func (m *WhatsappChannelMutation) ResetStatus() {
  41478. m.status = nil
  41479. m.addstatus = nil
  41480. delete(m.clearedFields, whatsappchannel.FieldStatus)
  41481. }
  41482. // SetDeletedAt sets the "deleted_at" field.
  41483. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  41484. m.deleted_at = &t
  41485. }
  41486. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41487. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  41488. v := m.deleted_at
  41489. if v == nil {
  41490. return
  41491. }
  41492. return *v, true
  41493. }
  41494. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  41495. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41497. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41498. if !m.op.Is(OpUpdateOne) {
  41499. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41500. }
  41501. if m.id == nil || m.oldValue == nil {
  41502. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41503. }
  41504. oldValue, err := m.oldValue(ctx)
  41505. if err != nil {
  41506. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41507. }
  41508. return oldValue.DeletedAt, nil
  41509. }
  41510. // ClearDeletedAt clears the value of the "deleted_at" field.
  41511. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  41512. m.deleted_at = nil
  41513. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  41514. }
  41515. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41516. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  41517. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  41518. return ok
  41519. }
  41520. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41521. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  41522. m.deleted_at = nil
  41523. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  41524. }
  41525. // SetAk sets the "ak" field.
  41526. func (m *WhatsappChannelMutation) SetAk(s string) {
  41527. m.ak = &s
  41528. }
  41529. // Ak returns the value of the "ak" field in the mutation.
  41530. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  41531. v := m.ak
  41532. if v == nil {
  41533. return
  41534. }
  41535. return *v, true
  41536. }
  41537. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  41538. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41540. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  41541. if !m.op.Is(OpUpdateOne) {
  41542. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  41543. }
  41544. if m.id == nil || m.oldValue == nil {
  41545. return v, errors.New("OldAk requires an ID field in the mutation")
  41546. }
  41547. oldValue, err := m.oldValue(ctx)
  41548. if err != nil {
  41549. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  41550. }
  41551. return oldValue.Ak, nil
  41552. }
  41553. // ClearAk clears the value of the "ak" field.
  41554. func (m *WhatsappChannelMutation) ClearAk() {
  41555. m.ak = nil
  41556. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  41557. }
  41558. // AkCleared returns if the "ak" field was cleared in this mutation.
  41559. func (m *WhatsappChannelMutation) AkCleared() bool {
  41560. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  41561. return ok
  41562. }
  41563. // ResetAk resets all changes to the "ak" field.
  41564. func (m *WhatsappChannelMutation) ResetAk() {
  41565. m.ak = nil
  41566. delete(m.clearedFields, whatsappchannel.FieldAk)
  41567. }
  41568. // SetSk sets the "sk" field.
  41569. func (m *WhatsappChannelMutation) SetSk(s string) {
  41570. m.sk = &s
  41571. }
  41572. // Sk returns the value of the "sk" field in the mutation.
  41573. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  41574. v := m.sk
  41575. if v == nil {
  41576. return
  41577. }
  41578. return *v, true
  41579. }
  41580. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  41581. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41583. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  41584. if !m.op.Is(OpUpdateOne) {
  41585. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  41586. }
  41587. if m.id == nil || m.oldValue == nil {
  41588. return v, errors.New("OldSk requires an ID field in the mutation")
  41589. }
  41590. oldValue, err := m.oldValue(ctx)
  41591. if err != nil {
  41592. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  41593. }
  41594. return oldValue.Sk, nil
  41595. }
  41596. // ResetSk resets all changes to the "sk" field.
  41597. func (m *WhatsappChannelMutation) ResetSk() {
  41598. m.sk = nil
  41599. }
  41600. // SetWaID sets the "wa_id" field.
  41601. func (m *WhatsappChannelMutation) SetWaID(s string) {
  41602. m.wa_id = &s
  41603. }
  41604. // WaID returns the value of the "wa_id" field in the mutation.
  41605. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  41606. v := m.wa_id
  41607. if v == nil {
  41608. return
  41609. }
  41610. return *v, true
  41611. }
  41612. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  41613. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41615. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  41616. if !m.op.Is(OpUpdateOne) {
  41617. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  41618. }
  41619. if m.id == nil || m.oldValue == nil {
  41620. return v, errors.New("OldWaID requires an ID field in the mutation")
  41621. }
  41622. oldValue, err := m.oldValue(ctx)
  41623. if err != nil {
  41624. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  41625. }
  41626. return oldValue.WaID, nil
  41627. }
  41628. // ClearWaID clears the value of the "wa_id" field.
  41629. func (m *WhatsappChannelMutation) ClearWaID() {
  41630. m.wa_id = nil
  41631. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  41632. }
  41633. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  41634. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  41635. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  41636. return ok
  41637. }
  41638. // ResetWaID resets all changes to the "wa_id" field.
  41639. func (m *WhatsappChannelMutation) ResetWaID() {
  41640. m.wa_id = nil
  41641. delete(m.clearedFields, whatsappchannel.FieldWaID)
  41642. }
  41643. // SetWaName sets the "wa_name" field.
  41644. func (m *WhatsappChannelMutation) SetWaName(s string) {
  41645. m.wa_name = &s
  41646. }
  41647. // WaName returns the value of the "wa_name" field in the mutation.
  41648. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  41649. v := m.wa_name
  41650. if v == nil {
  41651. return
  41652. }
  41653. return *v, true
  41654. }
  41655. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  41656. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41657. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41658. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  41659. if !m.op.Is(OpUpdateOne) {
  41660. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  41661. }
  41662. if m.id == nil || m.oldValue == nil {
  41663. return v, errors.New("OldWaName requires an ID field in the mutation")
  41664. }
  41665. oldValue, err := m.oldValue(ctx)
  41666. if err != nil {
  41667. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  41668. }
  41669. return oldValue.WaName, nil
  41670. }
  41671. // ClearWaName clears the value of the "wa_name" field.
  41672. func (m *WhatsappChannelMutation) ClearWaName() {
  41673. m.wa_name = nil
  41674. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  41675. }
  41676. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  41677. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  41678. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  41679. return ok
  41680. }
  41681. // ResetWaName resets all changes to the "wa_name" field.
  41682. func (m *WhatsappChannelMutation) ResetWaName() {
  41683. m.wa_name = nil
  41684. delete(m.clearedFields, whatsappchannel.FieldWaName)
  41685. }
  41686. // SetWabaID sets the "waba_id" field.
  41687. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  41688. m.waba_id = &u
  41689. m.addwaba_id = nil
  41690. }
  41691. // WabaID returns the value of the "waba_id" field in the mutation.
  41692. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  41693. v := m.waba_id
  41694. if v == nil {
  41695. return
  41696. }
  41697. return *v, true
  41698. }
  41699. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  41700. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41702. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  41703. if !m.op.Is(OpUpdateOne) {
  41704. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  41705. }
  41706. if m.id == nil || m.oldValue == nil {
  41707. return v, errors.New("OldWabaID requires an ID field in the mutation")
  41708. }
  41709. oldValue, err := m.oldValue(ctx)
  41710. if err != nil {
  41711. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  41712. }
  41713. return oldValue.WabaID, nil
  41714. }
  41715. // AddWabaID adds u to the "waba_id" field.
  41716. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  41717. if m.addwaba_id != nil {
  41718. *m.addwaba_id += u
  41719. } else {
  41720. m.addwaba_id = &u
  41721. }
  41722. }
  41723. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  41724. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  41725. v := m.addwaba_id
  41726. if v == nil {
  41727. return
  41728. }
  41729. return *v, true
  41730. }
  41731. // ResetWabaID resets all changes to the "waba_id" field.
  41732. func (m *WhatsappChannelMutation) ResetWabaID() {
  41733. m.waba_id = nil
  41734. m.addwaba_id = nil
  41735. }
  41736. // SetBusinessID sets the "business_id" field.
  41737. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  41738. m.business_id = &u
  41739. m.addbusiness_id = nil
  41740. }
  41741. // BusinessID returns the value of the "business_id" field in the mutation.
  41742. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  41743. v := m.business_id
  41744. if v == nil {
  41745. return
  41746. }
  41747. return *v, true
  41748. }
  41749. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  41750. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41752. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  41753. if !m.op.Is(OpUpdateOne) {
  41754. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  41755. }
  41756. if m.id == nil || m.oldValue == nil {
  41757. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  41758. }
  41759. oldValue, err := m.oldValue(ctx)
  41760. if err != nil {
  41761. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  41762. }
  41763. return oldValue.BusinessID, nil
  41764. }
  41765. // AddBusinessID adds u to the "business_id" field.
  41766. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  41767. if m.addbusiness_id != nil {
  41768. *m.addbusiness_id += u
  41769. } else {
  41770. m.addbusiness_id = &u
  41771. }
  41772. }
  41773. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  41774. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  41775. v := m.addbusiness_id
  41776. if v == nil {
  41777. return
  41778. }
  41779. return *v, true
  41780. }
  41781. // ResetBusinessID resets all changes to the "business_id" field.
  41782. func (m *WhatsappChannelMutation) ResetBusinessID() {
  41783. m.business_id = nil
  41784. m.addbusiness_id = nil
  41785. }
  41786. // SetOrganizationID sets the "organization_id" field.
  41787. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  41788. m.organization_id = &u
  41789. m.addorganization_id = nil
  41790. }
  41791. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41792. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  41793. v := m.organization_id
  41794. if v == nil {
  41795. return
  41796. }
  41797. return *v, true
  41798. }
  41799. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  41800. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41802. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41803. if !m.op.Is(OpUpdateOne) {
  41804. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41805. }
  41806. if m.id == nil || m.oldValue == nil {
  41807. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41808. }
  41809. oldValue, err := m.oldValue(ctx)
  41810. if err != nil {
  41811. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41812. }
  41813. return oldValue.OrganizationID, nil
  41814. }
  41815. // AddOrganizationID adds u to the "organization_id" field.
  41816. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  41817. if m.addorganization_id != nil {
  41818. *m.addorganization_id += u
  41819. } else {
  41820. m.addorganization_id = &u
  41821. }
  41822. }
  41823. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41824. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  41825. v := m.addorganization_id
  41826. if v == nil {
  41827. return
  41828. }
  41829. return *v, true
  41830. }
  41831. // ClearOrganizationID clears the value of the "organization_id" field.
  41832. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  41833. m.organization_id = nil
  41834. m.addorganization_id = nil
  41835. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  41836. }
  41837. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41838. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  41839. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  41840. return ok
  41841. }
  41842. // ResetOrganizationID resets all changes to the "organization_id" field.
  41843. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  41844. m.organization_id = nil
  41845. m.addorganization_id = nil
  41846. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  41847. }
  41848. // SetVerifyAccount sets the "verify_account" field.
  41849. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  41850. m.verify_account = &s
  41851. }
  41852. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  41853. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  41854. v := m.verify_account
  41855. if v == nil {
  41856. return
  41857. }
  41858. return *v, true
  41859. }
  41860. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  41861. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  41862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41863. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  41864. if !m.op.Is(OpUpdateOne) {
  41865. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  41866. }
  41867. if m.id == nil || m.oldValue == nil {
  41868. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  41869. }
  41870. oldValue, err := m.oldValue(ctx)
  41871. if err != nil {
  41872. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  41873. }
  41874. return oldValue.VerifyAccount, nil
  41875. }
  41876. // ResetVerifyAccount resets all changes to the "verify_account" field.
  41877. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  41878. m.verify_account = nil
  41879. }
  41880. // Where appends a list predicates to the WhatsappChannelMutation builder.
  41881. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  41882. m.predicates = append(m.predicates, ps...)
  41883. }
  41884. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  41885. // users can use type-assertion to append predicates that do not depend on any generated package.
  41886. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  41887. p := make([]predicate.WhatsappChannel, len(ps))
  41888. for i := range ps {
  41889. p[i] = ps[i]
  41890. }
  41891. m.Where(p...)
  41892. }
  41893. // Op returns the operation name.
  41894. func (m *WhatsappChannelMutation) Op() Op {
  41895. return m.op
  41896. }
  41897. // SetOp allows setting the mutation operation.
  41898. func (m *WhatsappChannelMutation) SetOp(op Op) {
  41899. m.op = op
  41900. }
  41901. // Type returns the node type of this mutation (WhatsappChannel).
  41902. func (m *WhatsappChannelMutation) Type() string {
  41903. return m.typ
  41904. }
  41905. // Fields returns all fields that were changed during this mutation. Note that in
  41906. // order to get all numeric fields that were incremented/decremented, call
  41907. // AddedFields().
  41908. func (m *WhatsappChannelMutation) Fields() []string {
  41909. fields := make([]string, 0, 12)
  41910. if m.created_at != nil {
  41911. fields = append(fields, whatsappchannel.FieldCreatedAt)
  41912. }
  41913. if m.updated_at != nil {
  41914. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  41915. }
  41916. if m.status != nil {
  41917. fields = append(fields, whatsappchannel.FieldStatus)
  41918. }
  41919. if m.deleted_at != nil {
  41920. fields = append(fields, whatsappchannel.FieldDeletedAt)
  41921. }
  41922. if m.ak != nil {
  41923. fields = append(fields, whatsappchannel.FieldAk)
  41924. }
  41925. if m.sk != nil {
  41926. fields = append(fields, whatsappchannel.FieldSk)
  41927. }
  41928. if m.wa_id != nil {
  41929. fields = append(fields, whatsappchannel.FieldWaID)
  41930. }
  41931. if m.wa_name != nil {
  41932. fields = append(fields, whatsappchannel.FieldWaName)
  41933. }
  41934. if m.waba_id != nil {
  41935. fields = append(fields, whatsappchannel.FieldWabaID)
  41936. }
  41937. if m.business_id != nil {
  41938. fields = append(fields, whatsappchannel.FieldBusinessID)
  41939. }
  41940. if m.organization_id != nil {
  41941. fields = append(fields, whatsappchannel.FieldOrganizationID)
  41942. }
  41943. if m.verify_account != nil {
  41944. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  41945. }
  41946. return fields
  41947. }
  41948. // Field returns the value of a field with the given name. The second boolean
  41949. // return value indicates that this field was not set, or was not defined in the
  41950. // schema.
  41951. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  41952. switch name {
  41953. case whatsappchannel.FieldCreatedAt:
  41954. return m.CreatedAt()
  41955. case whatsappchannel.FieldUpdatedAt:
  41956. return m.UpdatedAt()
  41957. case whatsappchannel.FieldStatus:
  41958. return m.Status()
  41959. case whatsappchannel.FieldDeletedAt:
  41960. return m.DeletedAt()
  41961. case whatsappchannel.FieldAk:
  41962. return m.Ak()
  41963. case whatsappchannel.FieldSk:
  41964. return m.Sk()
  41965. case whatsappchannel.FieldWaID:
  41966. return m.WaID()
  41967. case whatsappchannel.FieldWaName:
  41968. return m.WaName()
  41969. case whatsappchannel.FieldWabaID:
  41970. return m.WabaID()
  41971. case whatsappchannel.FieldBusinessID:
  41972. return m.BusinessID()
  41973. case whatsappchannel.FieldOrganizationID:
  41974. return m.OrganizationID()
  41975. case whatsappchannel.FieldVerifyAccount:
  41976. return m.VerifyAccount()
  41977. }
  41978. return nil, false
  41979. }
  41980. // OldField returns the old value of the field from the database. An error is
  41981. // returned if the mutation operation is not UpdateOne, or the query to the
  41982. // database failed.
  41983. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41984. switch name {
  41985. case whatsappchannel.FieldCreatedAt:
  41986. return m.OldCreatedAt(ctx)
  41987. case whatsappchannel.FieldUpdatedAt:
  41988. return m.OldUpdatedAt(ctx)
  41989. case whatsappchannel.FieldStatus:
  41990. return m.OldStatus(ctx)
  41991. case whatsappchannel.FieldDeletedAt:
  41992. return m.OldDeletedAt(ctx)
  41993. case whatsappchannel.FieldAk:
  41994. return m.OldAk(ctx)
  41995. case whatsappchannel.FieldSk:
  41996. return m.OldSk(ctx)
  41997. case whatsappchannel.FieldWaID:
  41998. return m.OldWaID(ctx)
  41999. case whatsappchannel.FieldWaName:
  42000. return m.OldWaName(ctx)
  42001. case whatsappchannel.FieldWabaID:
  42002. return m.OldWabaID(ctx)
  42003. case whatsappchannel.FieldBusinessID:
  42004. return m.OldBusinessID(ctx)
  42005. case whatsappchannel.FieldOrganizationID:
  42006. return m.OldOrganizationID(ctx)
  42007. case whatsappchannel.FieldVerifyAccount:
  42008. return m.OldVerifyAccount(ctx)
  42009. }
  42010. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  42011. }
  42012. // SetField sets the value of a field with the given name. It returns an error if
  42013. // the field is not defined in the schema, or if the type mismatched the field
  42014. // type.
  42015. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  42016. switch name {
  42017. case whatsappchannel.FieldCreatedAt:
  42018. v, ok := value.(time.Time)
  42019. if !ok {
  42020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42021. }
  42022. m.SetCreatedAt(v)
  42023. return nil
  42024. case whatsappchannel.FieldUpdatedAt:
  42025. v, ok := value.(time.Time)
  42026. if !ok {
  42027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42028. }
  42029. m.SetUpdatedAt(v)
  42030. return nil
  42031. case whatsappchannel.FieldStatus:
  42032. v, ok := value.(uint8)
  42033. if !ok {
  42034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42035. }
  42036. m.SetStatus(v)
  42037. return nil
  42038. case whatsappchannel.FieldDeletedAt:
  42039. v, ok := value.(time.Time)
  42040. if !ok {
  42041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42042. }
  42043. m.SetDeletedAt(v)
  42044. return nil
  42045. case whatsappchannel.FieldAk:
  42046. v, ok := value.(string)
  42047. if !ok {
  42048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42049. }
  42050. m.SetAk(v)
  42051. return nil
  42052. case whatsappchannel.FieldSk:
  42053. v, ok := value.(string)
  42054. if !ok {
  42055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42056. }
  42057. m.SetSk(v)
  42058. return nil
  42059. case whatsappchannel.FieldWaID:
  42060. v, ok := value.(string)
  42061. if !ok {
  42062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42063. }
  42064. m.SetWaID(v)
  42065. return nil
  42066. case whatsappchannel.FieldWaName:
  42067. v, ok := value.(string)
  42068. if !ok {
  42069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42070. }
  42071. m.SetWaName(v)
  42072. return nil
  42073. case whatsappchannel.FieldWabaID:
  42074. v, ok := value.(uint64)
  42075. if !ok {
  42076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42077. }
  42078. m.SetWabaID(v)
  42079. return nil
  42080. case whatsappchannel.FieldBusinessID:
  42081. v, ok := value.(uint64)
  42082. if !ok {
  42083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42084. }
  42085. m.SetBusinessID(v)
  42086. return nil
  42087. case whatsappchannel.FieldOrganizationID:
  42088. v, ok := value.(uint64)
  42089. if !ok {
  42090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42091. }
  42092. m.SetOrganizationID(v)
  42093. return nil
  42094. case whatsappchannel.FieldVerifyAccount:
  42095. v, ok := value.(string)
  42096. if !ok {
  42097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42098. }
  42099. m.SetVerifyAccount(v)
  42100. return nil
  42101. }
  42102. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  42103. }
  42104. // AddedFields returns all numeric fields that were incremented/decremented during
  42105. // this mutation.
  42106. func (m *WhatsappChannelMutation) AddedFields() []string {
  42107. var fields []string
  42108. if m.addstatus != nil {
  42109. fields = append(fields, whatsappchannel.FieldStatus)
  42110. }
  42111. if m.addwaba_id != nil {
  42112. fields = append(fields, whatsappchannel.FieldWabaID)
  42113. }
  42114. if m.addbusiness_id != nil {
  42115. fields = append(fields, whatsappchannel.FieldBusinessID)
  42116. }
  42117. if m.addorganization_id != nil {
  42118. fields = append(fields, whatsappchannel.FieldOrganizationID)
  42119. }
  42120. return fields
  42121. }
  42122. // AddedField returns the numeric value that was incremented/decremented on a field
  42123. // with the given name. The second boolean return value indicates that this field
  42124. // was not set, or was not defined in the schema.
  42125. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  42126. switch name {
  42127. case whatsappchannel.FieldStatus:
  42128. return m.AddedStatus()
  42129. case whatsappchannel.FieldWabaID:
  42130. return m.AddedWabaID()
  42131. case whatsappchannel.FieldBusinessID:
  42132. return m.AddedBusinessID()
  42133. case whatsappchannel.FieldOrganizationID:
  42134. return m.AddedOrganizationID()
  42135. }
  42136. return nil, false
  42137. }
  42138. // AddField adds the value to the field with the given name. It returns an error if
  42139. // the field is not defined in the schema, or if the type mismatched the field
  42140. // type.
  42141. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  42142. switch name {
  42143. case whatsappchannel.FieldStatus:
  42144. v, ok := value.(int8)
  42145. if !ok {
  42146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42147. }
  42148. m.AddStatus(v)
  42149. return nil
  42150. case whatsappchannel.FieldWabaID:
  42151. v, ok := value.(int64)
  42152. if !ok {
  42153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42154. }
  42155. m.AddWabaID(v)
  42156. return nil
  42157. case whatsappchannel.FieldBusinessID:
  42158. v, ok := value.(int64)
  42159. if !ok {
  42160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42161. }
  42162. m.AddBusinessID(v)
  42163. return nil
  42164. case whatsappchannel.FieldOrganizationID:
  42165. v, ok := value.(int64)
  42166. if !ok {
  42167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42168. }
  42169. m.AddOrganizationID(v)
  42170. return nil
  42171. }
  42172. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  42173. }
  42174. // ClearedFields returns all nullable fields that were cleared during this
  42175. // mutation.
  42176. func (m *WhatsappChannelMutation) ClearedFields() []string {
  42177. var fields []string
  42178. if m.FieldCleared(whatsappchannel.FieldStatus) {
  42179. fields = append(fields, whatsappchannel.FieldStatus)
  42180. }
  42181. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  42182. fields = append(fields, whatsappchannel.FieldDeletedAt)
  42183. }
  42184. if m.FieldCleared(whatsappchannel.FieldAk) {
  42185. fields = append(fields, whatsappchannel.FieldAk)
  42186. }
  42187. if m.FieldCleared(whatsappchannel.FieldWaID) {
  42188. fields = append(fields, whatsappchannel.FieldWaID)
  42189. }
  42190. if m.FieldCleared(whatsappchannel.FieldWaName) {
  42191. fields = append(fields, whatsappchannel.FieldWaName)
  42192. }
  42193. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  42194. fields = append(fields, whatsappchannel.FieldOrganizationID)
  42195. }
  42196. return fields
  42197. }
  42198. // FieldCleared returns a boolean indicating if a field with the given name was
  42199. // cleared in this mutation.
  42200. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  42201. _, ok := m.clearedFields[name]
  42202. return ok
  42203. }
  42204. // ClearField clears the value of the field with the given name. It returns an
  42205. // error if the field is not defined in the schema.
  42206. func (m *WhatsappChannelMutation) ClearField(name string) error {
  42207. switch name {
  42208. case whatsappchannel.FieldStatus:
  42209. m.ClearStatus()
  42210. return nil
  42211. case whatsappchannel.FieldDeletedAt:
  42212. m.ClearDeletedAt()
  42213. return nil
  42214. case whatsappchannel.FieldAk:
  42215. m.ClearAk()
  42216. return nil
  42217. case whatsappchannel.FieldWaID:
  42218. m.ClearWaID()
  42219. return nil
  42220. case whatsappchannel.FieldWaName:
  42221. m.ClearWaName()
  42222. return nil
  42223. case whatsappchannel.FieldOrganizationID:
  42224. m.ClearOrganizationID()
  42225. return nil
  42226. }
  42227. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  42228. }
  42229. // ResetField resets all changes in the mutation for the field with the given name.
  42230. // It returns an error if the field is not defined in the schema.
  42231. func (m *WhatsappChannelMutation) ResetField(name string) error {
  42232. switch name {
  42233. case whatsappchannel.FieldCreatedAt:
  42234. m.ResetCreatedAt()
  42235. return nil
  42236. case whatsappchannel.FieldUpdatedAt:
  42237. m.ResetUpdatedAt()
  42238. return nil
  42239. case whatsappchannel.FieldStatus:
  42240. m.ResetStatus()
  42241. return nil
  42242. case whatsappchannel.FieldDeletedAt:
  42243. m.ResetDeletedAt()
  42244. return nil
  42245. case whatsappchannel.FieldAk:
  42246. m.ResetAk()
  42247. return nil
  42248. case whatsappchannel.FieldSk:
  42249. m.ResetSk()
  42250. return nil
  42251. case whatsappchannel.FieldWaID:
  42252. m.ResetWaID()
  42253. return nil
  42254. case whatsappchannel.FieldWaName:
  42255. m.ResetWaName()
  42256. return nil
  42257. case whatsappchannel.FieldWabaID:
  42258. m.ResetWabaID()
  42259. return nil
  42260. case whatsappchannel.FieldBusinessID:
  42261. m.ResetBusinessID()
  42262. return nil
  42263. case whatsappchannel.FieldOrganizationID:
  42264. m.ResetOrganizationID()
  42265. return nil
  42266. case whatsappchannel.FieldVerifyAccount:
  42267. m.ResetVerifyAccount()
  42268. return nil
  42269. }
  42270. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  42271. }
  42272. // AddedEdges returns all edge names that were set/added in this mutation.
  42273. func (m *WhatsappChannelMutation) AddedEdges() []string {
  42274. edges := make([]string, 0, 0)
  42275. return edges
  42276. }
  42277. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42278. // name in this mutation.
  42279. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  42280. return nil
  42281. }
  42282. // RemovedEdges returns all edge names that were removed in this mutation.
  42283. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  42284. edges := make([]string, 0, 0)
  42285. return edges
  42286. }
  42287. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42288. // the given name in this mutation.
  42289. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  42290. return nil
  42291. }
  42292. // ClearedEdges returns all edge names that were cleared in this mutation.
  42293. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  42294. edges := make([]string, 0, 0)
  42295. return edges
  42296. }
  42297. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42298. // was cleared in this mutation.
  42299. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  42300. return false
  42301. }
  42302. // ClearEdge clears the value of the edge with the given name. It returns an error
  42303. // if that edge is not defined in the schema.
  42304. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  42305. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  42306. }
  42307. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42308. // It returns an error if the edge is not defined in the schema.
  42309. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  42310. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  42311. }
  42312. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  42313. type WorkExperienceMutation struct {
  42314. config
  42315. op Op
  42316. typ string
  42317. id *uint64
  42318. created_at *time.Time
  42319. updated_at *time.Time
  42320. deleted_at *time.Time
  42321. start_date *time.Time
  42322. end_date *time.Time
  42323. company *string
  42324. experience *string
  42325. organization_id *uint64
  42326. addorganization_id *int64
  42327. clearedFields map[string]struct{}
  42328. employee *uint64
  42329. clearedemployee bool
  42330. done bool
  42331. oldValue func(context.Context) (*WorkExperience, error)
  42332. predicates []predicate.WorkExperience
  42333. }
  42334. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  42335. // workexperienceOption allows management of the mutation configuration using functional options.
  42336. type workexperienceOption func(*WorkExperienceMutation)
  42337. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  42338. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  42339. m := &WorkExperienceMutation{
  42340. config: c,
  42341. op: op,
  42342. typ: TypeWorkExperience,
  42343. clearedFields: make(map[string]struct{}),
  42344. }
  42345. for _, opt := range opts {
  42346. opt(m)
  42347. }
  42348. return m
  42349. }
  42350. // withWorkExperienceID sets the ID field of the mutation.
  42351. func withWorkExperienceID(id uint64) workexperienceOption {
  42352. return func(m *WorkExperienceMutation) {
  42353. var (
  42354. err error
  42355. once sync.Once
  42356. value *WorkExperience
  42357. )
  42358. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  42359. once.Do(func() {
  42360. if m.done {
  42361. err = errors.New("querying old values post mutation is not allowed")
  42362. } else {
  42363. value, err = m.Client().WorkExperience.Get(ctx, id)
  42364. }
  42365. })
  42366. return value, err
  42367. }
  42368. m.id = &id
  42369. }
  42370. }
  42371. // withWorkExperience sets the old WorkExperience of the mutation.
  42372. func withWorkExperience(node *WorkExperience) workexperienceOption {
  42373. return func(m *WorkExperienceMutation) {
  42374. m.oldValue = func(context.Context) (*WorkExperience, error) {
  42375. return node, nil
  42376. }
  42377. m.id = &node.ID
  42378. }
  42379. }
  42380. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42381. // executed in a transaction (ent.Tx), a transactional client is returned.
  42382. func (m WorkExperienceMutation) Client() *Client {
  42383. client := &Client{config: m.config}
  42384. client.init()
  42385. return client
  42386. }
  42387. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42388. // it returns an error otherwise.
  42389. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  42390. if _, ok := m.driver.(*txDriver); !ok {
  42391. return nil, errors.New("ent: mutation is not running in a transaction")
  42392. }
  42393. tx := &Tx{config: m.config}
  42394. tx.init()
  42395. return tx, nil
  42396. }
  42397. // SetID sets the value of the id field. Note that this
  42398. // operation is only accepted on creation of WorkExperience entities.
  42399. func (m *WorkExperienceMutation) SetID(id uint64) {
  42400. m.id = &id
  42401. }
  42402. // ID returns the ID value in the mutation. Note that the ID is only available
  42403. // if it was provided to the builder or after it was returned from the database.
  42404. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  42405. if m.id == nil {
  42406. return
  42407. }
  42408. return *m.id, true
  42409. }
  42410. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42411. // That means, if the mutation is applied within a transaction with an isolation level such
  42412. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42413. // or updated by the mutation.
  42414. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  42415. switch {
  42416. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42417. id, exists := m.ID()
  42418. if exists {
  42419. return []uint64{id}, nil
  42420. }
  42421. fallthrough
  42422. case m.op.Is(OpUpdate | OpDelete):
  42423. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  42424. default:
  42425. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42426. }
  42427. }
  42428. // SetCreatedAt sets the "created_at" field.
  42429. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  42430. m.created_at = &t
  42431. }
  42432. // CreatedAt returns the value of the "created_at" field in the mutation.
  42433. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  42434. v := m.created_at
  42435. if v == nil {
  42436. return
  42437. }
  42438. return *v, true
  42439. }
  42440. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  42441. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42443. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42444. if !m.op.Is(OpUpdateOne) {
  42445. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42446. }
  42447. if m.id == nil || m.oldValue == nil {
  42448. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42449. }
  42450. oldValue, err := m.oldValue(ctx)
  42451. if err != nil {
  42452. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42453. }
  42454. return oldValue.CreatedAt, nil
  42455. }
  42456. // ResetCreatedAt resets all changes to the "created_at" field.
  42457. func (m *WorkExperienceMutation) ResetCreatedAt() {
  42458. m.created_at = nil
  42459. }
  42460. // SetUpdatedAt sets the "updated_at" field.
  42461. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  42462. m.updated_at = &t
  42463. }
  42464. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42465. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  42466. v := m.updated_at
  42467. if v == nil {
  42468. return
  42469. }
  42470. return *v, true
  42471. }
  42472. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  42473. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42475. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42476. if !m.op.Is(OpUpdateOne) {
  42477. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42478. }
  42479. if m.id == nil || m.oldValue == nil {
  42480. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42481. }
  42482. oldValue, err := m.oldValue(ctx)
  42483. if err != nil {
  42484. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42485. }
  42486. return oldValue.UpdatedAt, nil
  42487. }
  42488. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42489. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  42490. m.updated_at = nil
  42491. }
  42492. // SetDeletedAt sets the "deleted_at" field.
  42493. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  42494. m.deleted_at = &t
  42495. }
  42496. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42497. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  42498. v := m.deleted_at
  42499. if v == nil {
  42500. return
  42501. }
  42502. return *v, true
  42503. }
  42504. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  42505. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42507. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42508. if !m.op.Is(OpUpdateOne) {
  42509. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42510. }
  42511. if m.id == nil || m.oldValue == nil {
  42512. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42513. }
  42514. oldValue, err := m.oldValue(ctx)
  42515. if err != nil {
  42516. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42517. }
  42518. return oldValue.DeletedAt, nil
  42519. }
  42520. // ClearDeletedAt clears the value of the "deleted_at" field.
  42521. func (m *WorkExperienceMutation) ClearDeletedAt() {
  42522. m.deleted_at = nil
  42523. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  42524. }
  42525. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42526. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  42527. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  42528. return ok
  42529. }
  42530. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42531. func (m *WorkExperienceMutation) ResetDeletedAt() {
  42532. m.deleted_at = nil
  42533. delete(m.clearedFields, workexperience.FieldDeletedAt)
  42534. }
  42535. // SetEmployeeID sets the "employee_id" field.
  42536. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  42537. m.employee = &u
  42538. }
  42539. // EmployeeID returns the value of the "employee_id" field in the mutation.
  42540. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  42541. v := m.employee
  42542. if v == nil {
  42543. return
  42544. }
  42545. return *v, true
  42546. }
  42547. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  42548. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42550. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  42551. if !m.op.Is(OpUpdateOne) {
  42552. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  42553. }
  42554. if m.id == nil || m.oldValue == nil {
  42555. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  42556. }
  42557. oldValue, err := m.oldValue(ctx)
  42558. if err != nil {
  42559. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  42560. }
  42561. return oldValue.EmployeeID, nil
  42562. }
  42563. // ResetEmployeeID resets all changes to the "employee_id" field.
  42564. func (m *WorkExperienceMutation) ResetEmployeeID() {
  42565. m.employee = nil
  42566. }
  42567. // SetStartDate sets the "start_date" field.
  42568. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  42569. m.start_date = &t
  42570. }
  42571. // StartDate returns the value of the "start_date" field in the mutation.
  42572. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  42573. v := m.start_date
  42574. if v == nil {
  42575. return
  42576. }
  42577. return *v, true
  42578. }
  42579. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  42580. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42582. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  42583. if !m.op.Is(OpUpdateOne) {
  42584. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  42585. }
  42586. if m.id == nil || m.oldValue == nil {
  42587. return v, errors.New("OldStartDate requires an ID field in the mutation")
  42588. }
  42589. oldValue, err := m.oldValue(ctx)
  42590. if err != nil {
  42591. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  42592. }
  42593. return oldValue.StartDate, nil
  42594. }
  42595. // ResetStartDate resets all changes to the "start_date" field.
  42596. func (m *WorkExperienceMutation) ResetStartDate() {
  42597. m.start_date = nil
  42598. }
  42599. // SetEndDate sets the "end_date" field.
  42600. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  42601. m.end_date = &t
  42602. }
  42603. // EndDate returns the value of the "end_date" field in the mutation.
  42604. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  42605. v := m.end_date
  42606. if v == nil {
  42607. return
  42608. }
  42609. return *v, true
  42610. }
  42611. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  42612. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42614. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  42615. if !m.op.Is(OpUpdateOne) {
  42616. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  42617. }
  42618. if m.id == nil || m.oldValue == nil {
  42619. return v, errors.New("OldEndDate requires an ID field in the mutation")
  42620. }
  42621. oldValue, err := m.oldValue(ctx)
  42622. if err != nil {
  42623. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  42624. }
  42625. return oldValue.EndDate, nil
  42626. }
  42627. // ResetEndDate resets all changes to the "end_date" field.
  42628. func (m *WorkExperienceMutation) ResetEndDate() {
  42629. m.end_date = nil
  42630. }
  42631. // SetCompany sets the "company" field.
  42632. func (m *WorkExperienceMutation) SetCompany(s string) {
  42633. m.company = &s
  42634. }
  42635. // Company returns the value of the "company" field in the mutation.
  42636. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  42637. v := m.company
  42638. if v == nil {
  42639. return
  42640. }
  42641. return *v, true
  42642. }
  42643. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  42644. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42646. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  42647. if !m.op.Is(OpUpdateOne) {
  42648. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  42649. }
  42650. if m.id == nil || m.oldValue == nil {
  42651. return v, errors.New("OldCompany requires an ID field in the mutation")
  42652. }
  42653. oldValue, err := m.oldValue(ctx)
  42654. if err != nil {
  42655. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  42656. }
  42657. return oldValue.Company, nil
  42658. }
  42659. // ResetCompany resets all changes to the "company" field.
  42660. func (m *WorkExperienceMutation) ResetCompany() {
  42661. m.company = nil
  42662. }
  42663. // SetExperience sets the "experience" field.
  42664. func (m *WorkExperienceMutation) SetExperience(s string) {
  42665. m.experience = &s
  42666. }
  42667. // Experience returns the value of the "experience" field in the mutation.
  42668. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  42669. v := m.experience
  42670. if v == nil {
  42671. return
  42672. }
  42673. return *v, true
  42674. }
  42675. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  42676. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42678. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  42679. if !m.op.Is(OpUpdateOne) {
  42680. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  42681. }
  42682. if m.id == nil || m.oldValue == nil {
  42683. return v, errors.New("OldExperience requires an ID field in the mutation")
  42684. }
  42685. oldValue, err := m.oldValue(ctx)
  42686. if err != nil {
  42687. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  42688. }
  42689. return oldValue.Experience, nil
  42690. }
  42691. // ResetExperience resets all changes to the "experience" field.
  42692. func (m *WorkExperienceMutation) ResetExperience() {
  42693. m.experience = nil
  42694. }
  42695. // SetOrganizationID sets the "organization_id" field.
  42696. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  42697. m.organization_id = &u
  42698. m.addorganization_id = nil
  42699. }
  42700. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42701. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  42702. v := m.organization_id
  42703. if v == nil {
  42704. return
  42705. }
  42706. return *v, true
  42707. }
  42708. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  42709. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  42710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42711. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42712. if !m.op.Is(OpUpdateOne) {
  42713. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42714. }
  42715. if m.id == nil || m.oldValue == nil {
  42716. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42717. }
  42718. oldValue, err := m.oldValue(ctx)
  42719. if err != nil {
  42720. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42721. }
  42722. return oldValue.OrganizationID, nil
  42723. }
  42724. // AddOrganizationID adds u to the "organization_id" field.
  42725. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  42726. if m.addorganization_id != nil {
  42727. *m.addorganization_id += u
  42728. } else {
  42729. m.addorganization_id = &u
  42730. }
  42731. }
  42732. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42733. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  42734. v := m.addorganization_id
  42735. if v == nil {
  42736. return
  42737. }
  42738. return *v, true
  42739. }
  42740. // ResetOrganizationID resets all changes to the "organization_id" field.
  42741. func (m *WorkExperienceMutation) ResetOrganizationID() {
  42742. m.organization_id = nil
  42743. m.addorganization_id = nil
  42744. }
  42745. // ClearEmployee clears the "employee" edge to the Employee entity.
  42746. func (m *WorkExperienceMutation) ClearEmployee() {
  42747. m.clearedemployee = true
  42748. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  42749. }
  42750. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  42751. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  42752. return m.clearedemployee
  42753. }
  42754. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  42755. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42756. // EmployeeID instead. It exists only for internal usage by the builders.
  42757. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  42758. if id := m.employee; id != nil {
  42759. ids = append(ids, *id)
  42760. }
  42761. return
  42762. }
  42763. // ResetEmployee resets all changes to the "employee" edge.
  42764. func (m *WorkExperienceMutation) ResetEmployee() {
  42765. m.employee = nil
  42766. m.clearedemployee = false
  42767. }
  42768. // Where appends a list predicates to the WorkExperienceMutation builder.
  42769. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  42770. m.predicates = append(m.predicates, ps...)
  42771. }
  42772. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  42773. // users can use type-assertion to append predicates that do not depend on any generated package.
  42774. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  42775. p := make([]predicate.WorkExperience, len(ps))
  42776. for i := range ps {
  42777. p[i] = ps[i]
  42778. }
  42779. m.Where(p...)
  42780. }
  42781. // Op returns the operation name.
  42782. func (m *WorkExperienceMutation) Op() Op {
  42783. return m.op
  42784. }
  42785. // SetOp allows setting the mutation operation.
  42786. func (m *WorkExperienceMutation) SetOp(op Op) {
  42787. m.op = op
  42788. }
  42789. // Type returns the node type of this mutation (WorkExperience).
  42790. func (m *WorkExperienceMutation) Type() string {
  42791. return m.typ
  42792. }
  42793. // Fields returns all fields that were changed during this mutation. Note that in
  42794. // order to get all numeric fields that were incremented/decremented, call
  42795. // AddedFields().
  42796. func (m *WorkExperienceMutation) Fields() []string {
  42797. fields := make([]string, 0, 9)
  42798. if m.created_at != nil {
  42799. fields = append(fields, workexperience.FieldCreatedAt)
  42800. }
  42801. if m.updated_at != nil {
  42802. fields = append(fields, workexperience.FieldUpdatedAt)
  42803. }
  42804. if m.deleted_at != nil {
  42805. fields = append(fields, workexperience.FieldDeletedAt)
  42806. }
  42807. if m.employee != nil {
  42808. fields = append(fields, workexperience.FieldEmployeeID)
  42809. }
  42810. if m.start_date != nil {
  42811. fields = append(fields, workexperience.FieldStartDate)
  42812. }
  42813. if m.end_date != nil {
  42814. fields = append(fields, workexperience.FieldEndDate)
  42815. }
  42816. if m.company != nil {
  42817. fields = append(fields, workexperience.FieldCompany)
  42818. }
  42819. if m.experience != nil {
  42820. fields = append(fields, workexperience.FieldExperience)
  42821. }
  42822. if m.organization_id != nil {
  42823. fields = append(fields, workexperience.FieldOrganizationID)
  42824. }
  42825. return fields
  42826. }
  42827. // Field returns the value of a field with the given name. The second boolean
  42828. // return value indicates that this field was not set, or was not defined in the
  42829. // schema.
  42830. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  42831. switch name {
  42832. case workexperience.FieldCreatedAt:
  42833. return m.CreatedAt()
  42834. case workexperience.FieldUpdatedAt:
  42835. return m.UpdatedAt()
  42836. case workexperience.FieldDeletedAt:
  42837. return m.DeletedAt()
  42838. case workexperience.FieldEmployeeID:
  42839. return m.EmployeeID()
  42840. case workexperience.FieldStartDate:
  42841. return m.StartDate()
  42842. case workexperience.FieldEndDate:
  42843. return m.EndDate()
  42844. case workexperience.FieldCompany:
  42845. return m.Company()
  42846. case workexperience.FieldExperience:
  42847. return m.Experience()
  42848. case workexperience.FieldOrganizationID:
  42849. return m.OrganizationID()
  42850. }
  42851. return nil, false
  42852. }
  42853. // OldField returns the old value of the field from the database. An error is
  42854. // returned if the mutation operation is not UpdateOne, or the query to the
  42855. // database failed.
  42856. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42857. switch name {
  42858. case workexperience.FieldCreatedAt:
  42859. return m.OldCreatedAt(ctx)
  42860. case workexperience.FieldUpdatedAt:
  42861. return m.OldUpdatedAt(ctx)
  42862. case workexperience.FieldDeletedAt:
  42863. return m.OldDeletedAt(ctx)
  42864. case workexperience.FieldEmployeeID:
  42865. return m.OldEmployeeID(ctx)
  42866. case workexperience.FieldStartDate:
  42867. return m.OldStartDate(ctx)
  42868. case workexperience.FieldEndDate:
  42869. return m.OldEndDate(ctx)
  42870. case workexperience.FieldCompany:
  42871. return m.OldCompany(ctx)
  42872. case workexperience.FieldExperience:
  42873. return m.OldExperience(ctx)
  42874. case workexperience.FieldOrganizationID:
  42875. return m.OldOrganizationID(ctx)
  42876. }
  42877. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  42878. }
  42879. // SetField sets the value of a field with the given name. It returns an error if
  42880. // the field is not defined in the schema, or if the type mismatched the field
  42881. // type.
  42882. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  42883. switch name {
  42884. case workexperience.FieldCreatedAt:
  42885. v, ok := value.(time.Time)
  42886. if !ok {
  42887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42888. }
  42889. m.SetCreatedAt(v)
  42890. return nil
  42891. case workexperience.FieldUpdatedAt:
  42892. v, ok := value.(time.Time)
  42893. if !ok {
  42894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42895. }
  42896. m.SetUpdatedAt(v)
  42897. return nil
  42898. case workexperience.FieldDeletedAt:
  42899. v, ok := value.(time.Time)
  42900. if !ok {
  42901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42902. }
  42903. m.SetDeletedAt(v)
  42904. return nil
  42905. case workexperience.FieldEmployeeID:
  42906. v, ok := value.(uint64)
  42907. if !ok {
  42908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42909. }
  42910. m.SetEmployeeID(v)
  42911. return nil
  42912. case workexperience.FieldStartDate:
  42913. v, ok := value.(time.Time)
  42914. if !ok {
  42915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42916. }
  42917. m.SetStartDate(v)
  42918. return nil
  42919. case workexperience.FieldEndDate:
  42920. v, ok := value.(time.Time)
  42921. if !ok {
  42922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42923. }
  42924. m.SetEndDate(v)
  42925. return nil
  42926. case workexperience.FieldCompany:
  42927. v, ok := value.(string)
  42928. if !ok {
  42929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42930. }
  42931. m.SetCompany(v)
  42932. return nil
  42933. case workexperience.FieldExperience:
  42934. v, ok := value.(string)
  42935. if !ok {
  42936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42937. }
  42938. m.SetExperience(v)
  42939. return nil
  42940. case workexperience.FieldOrganizationID:
  42941. v, ok := value.(uint64)
  42942. if !ok {
  42943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42944. }
  42945. m.SetOrganizationID(v)
  42946. return nil
  42947. }
  42948. return fmt.Errorf("unknown WorkExperience field %s", name)
  42949. }
  42950. // AddedFields returns all numeric fields that were incremented/decremented during
  42951. // this mutation.
  42952. func (m *WorkExperienceMutation) AddedFields() []string {
  42953. var fields []string
  42954. if m.addorganization_id != nil {
  42955. fields = append(fields, workexperience.FieldOrganizationID)
  42956. }
  42957. return fields
  42958. }
  42959. // AddedField returns the numeric value that was incremented/decremented on a field
  42960. // with the given name. The second boolean return value indicates that this field
  42961. // was not set, or was not defined in the schema.
  42962. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  42963. switch name {
  42964. case workexperience.FieldOrganizationID:
  42965. return m.AddedOrganizationID()
  42966. }
  42967. return nil, false
  42968. }
  42969. // AddField adds the value to the field with the given name. It returns an error if
  42970. // the field is not defined in the schema, or if the type mismatched the field
  42971. // type.
  42972. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  42973. switch name {
  42974. case workexperience.FieldOrganizationID:
  42975. v, ok := value.(int64)
  42976. if !ok {
  42977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42978. }
  42979. m.AddOrganizationID(v)
  42980. return nil
  42981. }
  42982. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  42983. }
  42984. // ClearedFields returns all nullable fields that were cleared during this
  42985. // mutation.
  42986. func (m *WorkExperienceMutation) ClearedFields() []string {
  42987. var fields []string
  42988. if m.FieldCleared(workexperience.FieldDeletedAt) {
  42989. fields = append(fields, workexperience.FieldDeletedAt)
  42990. }
  42991. return fields
  42992. }
  42993. // FieldCleared returns a boolean indicating if a field with the given name was
  42994. // cleared in this mutation.
  42995. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  42996. _, ok := m.clearedFields[name]
  42997. return ok
  42998. }
  42999. // ClearField clears the value of the field with the given name. It returns an
  43000. // error if the field is not defined in the schema.
  43001. func (m *WorkExperienceMutation) ClearField(name string) error {
  43002. switch name {
  43003. case workexperience.FieldDeletedAt:
  43004. m.ClearDeletedAt()
  43005. return nil
  43006. }
  43007. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  43008. }
  43009. // ResetField resets all changes in the mutation for the field with the given name.
  43010. // It returns an error if the field is not defined in the schema.
  43011. func (m *WorkExperienceMutation) ResetField(name string) error {
  43012. switch name {
  43013. case workexperience.FieldCreatedAt:
  43014. m.ResetCreatedAt()
  43015. return nil
  43016. case workexperience.FieldUpdatedAt:
  43017. m.ResetUpdatedAt()
  43018. return nil
  43019. case workexperience.FieldDeletedAt:
  43020. m.ResetDeletedAt()
  43021. return nil
  43022. case workexperience.FieldEmployeeID:
  43023. m.ResetEmployeeID()
  43024. return nil
  43025. case workexperience.FieldStartDate:
  43026. m.ResetStartDate()
  43027. return nil
  43028. case workexperience.FieldEndDate:
  43029. m.ResetEndDate()
  43030. return nil
  43031. case workexperience.FieldCompany:
  43032. m.ResetCompany()
  43033. return nil
  43034. case workexperience.FieldExperience:
  43035. m.ResetExperience()
  43036. return nil
  43037. case workexperience.FieldOrganizationID:
  43038. m.ResetOrganizationID()
  43039. return nil
  43040. }
  43041. return fmt.Errorf("unknown WorkExperience field %s", name)
  43042. }
  43043. // AddedEdges returns all edge names that were set/added in this mutation.
  43044. func (m *WorkExperienceMutation) AddedEdges() []string {
  43045. edges := make([]string, 0, 1)
  43046. if m.employee != nil {
  43047. edges = append(edges, workexperience.EdgeEmployee)
  43048. }
  43049. return edges
  43050. }
  43051. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43052. // name in this mutation.
  43053. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  43054. switch name {
  43055. case workexperience.EdgeEmployee:
  43056. if id := m.employee; id != nil {
  43057. return []ent.Value{*id}
  43058. }
  43059. }
  43060. return nil
  43061. }
  43062. // RemovedEdges returns all edge names that were removed in this mutation.
  43063. func (m *WorkExperienceMutation) RemovedEdges() []string {
  43064. edges := make([]string, 0, 1)
  43065. return edges
  43066. }
  43067. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43068. // the given name in this mutation.
  43069. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  43070. return nil
  43071. }
  43072. // ClearedEdges returns all edge names that were cleared in this mutation.
  43073. func (m *WorkExperienceMutation) ClearedEdges() []string {
  43074. edges := make([]string, 0, 1)
  43075. if m.clearedemployee {
  43076. edges = append(edges, workexperience.EdgeEmployee)
  43077. }
  43078. return edges
  43079. }
  43080. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43081. // was cleared in this mutation.
  43082. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  43083. switch name {
  43084. case workexperience.EdgeEmployee:
  43085. return m.clearedemployee
  43086. }
  43087. return false
  43088. }
  43089. // ClearEdge clears the value of the edge with the given name. It returns an error
  43090. // if that edge is not defined in the schema.
  43091. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  43092. switch name {
  43093. case workexperience.EdgeEmployee:
  43094. m.ClearEmployee()
  43095. return nil
  43096. }
  43097. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  43098. }
  43099. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43100. // It returns an error if the edge is not defined in the schema.
  43101. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  43102. switch name {
  43103. case workexperience.EdgeEmployee:
  43104. m.ResetEmployee()
  43105. return nil
  43106. }
  43107. return fmt.Errorf("unknown WorkExperience edge %s", name)
  43108. }
  43109. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  43110. type WpChatroomMutation struct {
  43111. config
  43112. op Op
  43113. typ string
  43114. id *uint64
  43115. created_at *time.Time
  43116. updated_at *time.Time
  43117. status *uint8
  43118. addstatus *int8
  43119. wx_wxid *string
  43120. chatroom_id *string
  43121. nickname *string
  43122. owner *string
  43123. avatar *string
  43124. member_list *[]string
  43125. appendmember_list []string
  43126. clearedFields map[string]struct{}
  43127. done bool
  43128. oldValue func(context.Context) (*WpChatroom, error)
  43129. predicates []predicate.WpChatroom
  43130. }
  43131. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  43132. // wpchatroomOption allows management of the mutation configuration using functional options.
  43133. type wpchatroomOption func(*WpChatroomMutation)
  43134. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  43135. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  43136. m := &WpChatroomMutation{
  43137. config: c,
  43138. op: op,
  43139. typ: TypeWpChatroom,
  43140. clearedFields: make(map[string]struct{}),
  43141. }
  43142. for _, opt := range opts {
  43143. opt(m)
  43144. }
  43145. return m
  43146. }
  43147. // withWpChatroomID sets the ID field of the mutation.
  43148. func withWpChatroomID(id uint64) wpchatroomOption {
  43149. return func(m *WpChatroomMutation) {
  43150. var (
  43151. err error
  43152. once sync.Once
  43153. value *WpChatroom
  43154. )
  43155. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  43156. once.Do(func() {
  43157. if m.done {
  43158. err = errors.New("querying old values post mutation is not allowed")
  43159. } else {
  43160. value, err = m.Client().WpChatroom.Get(ctx, id)
  43161. }
  43162. })
  43163. return value, err
  43164. }
  43165. m.id = &id
  43166. }
  43167. }
  43168. // withWpChatroom sets the old WpChatroom of the mutation.
  43169. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  43170. return func(m *WpChatroomMutation) {
  43171. m.oldValue = func(context.Context) (*WpChatroom, error) {
  43172. return node, nil
  43173. }
  43174. m.id = &node.ID
  43175. }
  43176. }
  43177. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43178. // executed in a transaction (ent.Tx), a transactional client is returned.
  43179. func (m WpChatroomMutation) Client() *Client {
  43180. client := &Client{config: m.config}
  43181. client.init()
  43182. return client
  43183. }
  43184. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43185. // it returns an error otherwise.
  43186. func (m WpChatroomMutation) Tx() (*Tx, error) {
  43187. if _, ok := m.driver.(*txDriver); !ok {
  43188. return nil, errors.New("ent: mutation is not running in a transaction")
  43189. }
  43190. tx := &Tx{config: m.config}
  43191. tx.init()
  43192. return tx, nil
  43193. }
  43194. // SetID sets the value of the id field. Note that this
  43195. // operation is only accepted on creation of WpChatroom entities.
  43196. func (m *WpChatroomMutation) SetID(id uint64) {
  43197. m.id = &id
  43198. }
  43199. // ID returns the ID value in the mutation. Note that the ID is only available
  43200. // if it was provided to the builder or after it was returned from the database.
  43201. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  43202. if m.id == nil {
  43203. return
  43204. }
  43205. return *m.id, true
  43206. }
  43207. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43208. // That means, if the mutation is applied within a transaction with an isolation level such
  43209. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43210. // or updated by the mutation.
  43211. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  43212. switch {
  43213. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43214. id, exists := m.ID()
  43215. if exists {
  43216. return []uint64{id}, nil
  43217. }
  43218. fallthrough
  43219. case m.op.Is(OpUpdate | OpDelete):
  43220. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  43221. default:
  43222. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43223. }
  43224. }
  43225. // SetCreatedAt sets the "created_at" field.
  43226. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  43227. m.created_at = &t
  43228. }
  43229. // CreatedAt returns the value of the "created_at" field in the mutation.
  43230. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  43231. v := m.created_at
  43232. if v == nil {
  43233. return
  43234. }
  43235. return *v, true
  43236. }
  43237. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  43238. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43240. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43241. if !m.op.Is(OpUpdateOne) {
  43242. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43243. }
  43244. if m.id == nil || m.oldValue == nil {
  43245. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43246. }
  43247. oldValue, err := m.oldValue(ctx)
  43248. if err != nil {
  43249. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43250. }
  43251. return oldValue.CreatedAt, nil
  43252. }
  43253. // ResetCreatedAt resets all changes to the "created_at" field.
  43254. func (m *WpChatroomMutation) ResetCreatedAt() {
  43255. m.created_at = nil
  43256. }
  43257. // SetUpdatedAt sets the "updated_at" field.
  43258. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  43259. m.updated_at = &t
  43260. }
  43261. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43262. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  43263. v := m.updated_at
  43264. if v == nil {
  43265. return
  43266. }
  43267. return *v, true
  43268. }
  43269. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  43270. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43272. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43273. if !m.op.Is(OpUpdateOne) {
  43274. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43275. }
  43276. if m.id == nil || m.oldValue == nil {
  43277. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43278. }
  43279. oldValue, err := m.oldValue(ctx)
  43280. if err != nil {
  43281. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43282. }
  43283. return oldValue.UpdatedAt, nil
  43284. }
  43285. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43286. func (m *WpChatroomMutation) ResetUpdatedAt() {
  43287. m.updated_at = nil
  43288. }
  43289. // SetStatus sets the "status" field.
  43290. func (m *WpChatroomMutation) SetStatus(u uint8) {
  43291. m.status = &u
  43292. m.addstatus = nil
  43293. }
  43294. // Status returns the value of the "status" field in the mutation.
  43295. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  43296. v := m.status
  43297. if v == nil {
  43298. return
  43299. }
  43300. return *v, true
  43301. }
  43302. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  43303. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43305. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43306. if !m.op.Is(OpUpdateOne) {
  43307. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43308. }
  43309. if m.id == nil || m.oldValue == nil {
  43310. return v, errors.New("OldStatus requires an ID field in the mutation")
  43311. }
  43312. oldValue, err := m.oldValue(ctx)
  43313. if err != nil {
  43314. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43315. }
  43316. return oldValue.Status, nil
  43317. }
  43318. // AddStatus adds u to the "status" field.
  43319. func (m *WpChatroomMutation) AddStatus(u int8) {
  43320. if m.addstatus != nil {
  43321. *m.addstatus += u
  43322. } else {
  43323. m.addstatus = &u
  43324. }
  43325. }
  43326. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43327. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  43328. v := m.addstatus
  43329. if v == nil {
  43330. return
  43331. }
  43332. return *v, true
  43333. }
  43334. // ClearStatus clears the value of the "status" field.
  43335. func (m *WpChatroomMutation) ClearStatus() {
  43336. m.status = nil
  43337. m.addstatus = nil
  43338. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  43339. }
  43340. // StatusCleared returns if the "status" field was cleared in this mutation.
  43341. func (m *WpChatroomMutation) StatusCleared() bool {
  43342. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  43343. return ok
  43344. }
  43345. // ResetStatus resets all changes to the "status" field.
  43346. func (m *WpChatroomMutation) ResetStatus() {
  43347. m.status = nil
  43348. m.addstatus = nil
  43349. delete(m.clearedFields, wpchatroom.FieldStatus)
  43350. }
  43351. // SetWxWxid sets the "wx_wxid" field.
  43352. func (m *WpChatroomMutation) SetWxWxid(s string) {
  43353. m.wx_wxid = &s
  43354. }
  43355. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  43356. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  43357. v := m.wx_wxid
  43358. if v == nil {
  43359. return
  43360. }
  43361. return *v, true
  43362. }
  43363. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  43364. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43366. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  43367. if !m.op.Is(OpUpdateOne) {
  43368. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  43369. }
  43370. if m.id == nil || m.oldValue == nil {
  43371. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  43372. }
  43373. oldValue, err := m.oldValue(ctx)
  43374. if err != nil {
  43375. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  43376. }
  43377. return oldValue.WxWxid, nil
  43378. }
  43379. // ResetWxWxid resets all changes to the "wx_wxid" field.
  43380. func (m *WpChatroomMutation) ResetWxWxid() {
  43381. m.wx_wxid = nil
  43382. }
  43383. // SetChatroomID sets the "chatroom_id" field.
  43384. func (m *WpChatroomMutation) SetChatroomID(s string) {
  43385. m.chatroom_id = &s
  43386. }
  43387. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  43388. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  43389. v := m.chatroom_id
  43390. if v == nil {
  43391. return
  43392. }
  43393. return *v, true
  43394. }
  43395. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  43396. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43398. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  43399. if !m.op.Is(OpUpdateOne) {
  43400. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  43401. }
  43402. if m.id == nil || m.oldValue == nil {
  43403. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  43404. }
  43405. oldValue, err := m.oldValue(ctx)
  43406. if err != nil {
  43407. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  43408. }
  43409. return oldValue.ChatroomID, nil
  43410. }
  43411. // ResetChatroomID resets all changes to the "chatroom_id" field.
  43412. func (m *WpChatroomMutation) ResetChatroomID() {
  43413. m.chatroom_id = nil
  43414. }
  43415. // SetNickname sets the "nickname" field.
  43416. func (m *WpChatroomMutation) SetNickname(s string) {
  43417. m.nickname = &s
  43418. }
  43419. // Nickname returns the value of the "nickname" field in the mutation.
  43420. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  43421. v := m.nickname
  43422. if v == nil {
  43423. return
  43424. }
  43425. return *v, true
  43426. }
  43427. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  43428. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43430. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  43431. if !m.op.Is(OpUpdateOne) {
  43432. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  43433. }
  43434. if m.id == nil || m.oldValue == nil {
  43435. return v, errors.New("OldNickname requires an ID field in the mutation")
  43436. }
  43437. oldValue, err := m.oldValue(ctx)
  43438. if err != nil {
  43439. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  43440. }
  43441. return oldValue.Nickname, nil
  43442. }
  43443. // ResetNickname resets all changes to the "nickname" field.
  43444. func (m *WpChatroomMutation) ResetNickname() {
  43445. m.nickname = nil
  43446. }
  43447. // SetOwner sets the "owner" field.
  43448. func (m *WpChatroomMutation) SetOwner(s string) {
  43449. m.owner = &s
  43450. }
  43451. // Owner returns the value of the "owner" field in the mutation.
  43452. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  43453. v := m.owner
  43454. if v == nil {
  43455. return
  43456. }
  43457. return *v, true
  43458. }
  43459. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  43460. // If the WpChatroom 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 *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  43463. if !m.op.Is(OpUpdateOne) {
  43464. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  43465. }
  43466. if m.id == nil || m.oldValue == nil {
  43467. return v, errors.New("OldOwner 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 OldOwner: %w", err)
  43472. }
  43473. return oldValue.Owner, nil
  43474. }
  43475. // ResetOwner resets all changes to the "owner" field.
  43476. func (m *WpChatroomMutation) ResetOwner() {
  43477. m.owner = nil
  43478. }
  43479. // SetAvatar sets the "avatar" field.
  43480. func (m *WpChatroomMutation) SetAvatar(s string) {
  43481. m.avatar = &s
  43482. }
  43483. // Avatar returns the value of the "avatar" field in the mutation.
  43484. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  43485. v := m.avatar
  43486. if v == nil {
  43487. return
  43488. }
  43489. return *v, true
  43490. }
  43491. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  43492. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43494. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43495. if !m.op.Is(OpUpdateOne) {
  43496. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43497. }
  43498. if m.id == nil || m.oldValue == nil {
  43499. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43500. }
  43501. oldValue, err := m.oldValue(ctx)
  43502. if err != nil {
  43503. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43504. }
  43505. return oldValue.Avatar, nil
  43506. }
  43507. // ResetAvatar resets all changes to the "avatar" field.
  43508. func (m *WpChatroomMutation) ResetAvatar() {
  43509. m.avatar = nil
  43510. }
  43511. // SetMemberList sets the "member_list" field.
  43512. func (m *WpChatroomMutation) SetMemberList(s []string) {
  43513. m.member_list = &s
  43514. m.appendmember_list = nil
  43515. }
  43516. // MemberList returns the value of the "member_list" field in the mutation.
  43517. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  43518. v := m.member_list
  43519. if v == nil {
  43520. return
  43521. }
  43522. return *v, true
  43523. }
  43524. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  43525. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  43526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43527. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  43528. if !m.op.Is(OpUpdateOne) {
  43529. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  43530. }
  43531. if m.id == nil || m.oldValue == nil {
  43532. return v, errors.New("OldMemberList requires an ID field in the mutation")
  43533. }
  43534. oldValue, err := m.oldValue(ctx)
  43535. if err != nil {
  43536. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  43537. }
  43538. return oldValue.MemberList, nil
  43539. }
  43540. // AppendMemberList adds s to the "member_list" field.
  43541. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  43542. m.appendmember_list = append(m.appendmember_list, s...)
  43543. }
  43544. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  43545. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  43546. if len(m.appendmember_list) == 0 {
  43547. return nil, false
  43548. }
  43549. return m.appendmember_list, true
  43550. }
  43551. // ResetMemberList resets all changes to the "member_list" field.
  43552. func (m *WpChatroomMutation) ResetMemberList() {
  43553. m.member_list = nil
  43554. m.appendmember_list = nil
  43555. }
  43556. // Where appends a list predicates to the WpChatroomMutation builder.
  43557. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  43558. m.predicates = append(m.predicates, ps...)
  43559. }
  43560. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  43561. // users can use type-assertion to append predicates that do not depend on any generated package.
  43562. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  43563. p := make([]predicate.WpChatroom, len(ps))
  43564. for i := range ps {
  43565. p[i] = ps[i]
  43566. }
  43567. m.Where(p...)
  43568. }
  43569. // Op returns the operation name.
  43570. func (m *WpChatroomMutation) Op() Op {
  43571. return m.op
  43572. }
  43573. // SetOp allows setting the mutation operation.
  43574. func (m *WpChatroomMutation) SetOp(op Op) {
  43575. m.op = op
  43576. }
  43577. // Type returns the node type of this mutation (WpChatroom).
  43578. func (m *WpChatroomMutation) Type() string {
  43579. return m.typ
  43580. }
  43581. // Fields returns all fields that were changed during this mutation. Note that in
  43582. // order to get all numeric fields that were incremented/decremented, call
  43583. // AddedFields().
  43584. func (m *WpChatroomMutation) Fields() []string {
  43585. fields := make([]string, 0, 9)
  43586. if m.created_at != nil {
  43587. fields = append(fields, wpchatroom.FieldCreatedAt)
  43588. }
  43589. if m.updated_at != nil {
  43590. fields = append(fields, wpchatroom.FieldUpdatedAt)
  43591. }
  43592. if m.status != nil {
  43593. fields = append(fields, wpchatroom.FieldStatus)
  43594. }
  43595. if m.wx_wxid != nil {
  43596. fields = append(fields, wpchatroom.FieldWxWxid)
  43597. }
  43598. if m.chatroom_id != nil {
  43599. fields = append(fields, wpchatroom.FieldChatroomID)
  43600. }
  43601. if m.nickname != nil {
  43602. fields = append(fields, wpchatroom.FieldNickname)
  43603. }
  43604. if m.owner != nil {
  43605. fields = append(fields, wpchatroom.FieldOwner)
  43606. }
  43607. if m.avatar != nil {
  43608. fields = append(fields, wpchatroom.FieldAvatar)
  43609. }
  43610. if m.member_list != nil {
  43611. fields = append(fields, wpchatroom.FieldMemberList)
  43612. }
  43613. return fields
  43614. }
  43615. // Field returns the value of a field with the given name. The second boolean
  43616. // return value indicates that this field was not set, or was not defined in the
  43617. // schema.
  43618. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  43619. switch name {
  43620. case wpchatroom.FieldCreatedAt:
  43621. return m.CreatedAt()
  43622. case wpchatroom.FieldUpdatedAt:
  43623. return m.UpdatedAt()
  43624. case wpchatroom.FieldStatus:
  43625. return m.Status()
  43626. case wpchatroom.FieldWxWxid:
  43627. return m.WxWxid()
  43628. case wpchatroom.FieldChatroomID:
  43629. return m.ChatroomID()
  43630. case wpchatroom.FieldNickname:
  43631. return m.Nickname()
  43632. case wpchatroom.FieldOwner:
  43633. return m.Owner()
  43634. case wpchatroom.FieldAvatar:
  43635. return m.Avatar()
  43636. case wpchatroom.FieldMemberList:
  43637. return m.MemberList()
  43638. }
  43639. return nil, false
  43640. }
  43641. // OldField returns the old value of the field from the database. An error is
  43642. // returned if the mutation operation is not UpdateOne, or the query to the
  43643. // database failed.
  43644. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43645. switch name {
  43646. case wpchatroom.FieldCreatedAt:
  43647. return m.OldCreatedAt(ctx)
  43648. case wpchatroom.FieldUpdatedAt:
  43649. return m.OldUpdatedAt(ctx)
  43650. case wpchatroom.FieldStatus:
  43651. return m.OldStatus(ctx)
  43652. case wpchatroom.FieldWxWxid:
  43653. return m.OldWxWxid(ctx)
  43654. case wpchatroom.FieldChatroomID:
  43655. return m.OldChatroomID(ctx)
  43656. case wpchatroom.FieldNickname:
  43657. return m.OldNickname(ctx)
  43658. case wpchatroom.FieldOwner:
  43659. return m.OldOwner(ctx)
  43660. case wpchatroom.FieldAvatar:
  43661. return m.OldAvatar(ctx)
  43662. case wpchatroom.FieldMemberList:
  43663. return m.OldMemberList(ctx)
  43664. }
  43665. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  43666. }
  43667. // SetField sets the value of a field with the given name. It returns an error if
  43668. // the field is not defined in the schema, or if the type mismatched the field
  43669. // type.
  43670. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  43671. switch name {
  43672. case wpchatroom.FieldCreatedAt:
  43673. v, ok := value.(time.Time)
  43674. if !ok {
  43675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43676. }
  43677. m.SetCreatedAt(v)
  43678. return nil
  43679. case wpchatroom.FieldUpdatedAt:
  43680. v, ok := value.(time.Time)
  43681. if !ok {
  43682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43683. }
  43684. m.SetUpdatedAt(v)
  43685. return nil
  43686. case wpchatroom.FieldStatus:
  43687. v, ok := value.(uint8)
  43688. if !ok {
  43689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43690. }
  43691. m.SetStatus(v)
  43692. return nil
  43693. case wpchatroom.FieldWxWxid:
  43694. v, ok := value.(string)
  43695. if !ok {
  43696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43697. }
  43698. m.SetWxWxid(v)
  43699. return nil
  43700. case wpchatroom.FieldChatroomID:
  43701. v, ok := value.(string)
  43702. if !ok {
  43703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43704. }
  43705. m.SetChatroomID(v)
  43706. return nil
  43707. case wpchatroom.FieldNickname:
  43708. v, ok := value.(string)
  43709. if !ok {
  43710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43711. }
  43712. m.SetNickname(v)
  43713. return nil
  43714. case wpchatroom.FieldOwner:
  43715. v, ok := value.(string)
  43716. if !ok {
  43717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43718. }
  43719. m.SetOwner(v)
  43720. return nil
  43721. case wpchatroom.FieldAvatar:
  43722. v, ok := value.(string)
  43723. if !ok {
  43724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43725. }
  43726. m.SetAvatar(v)
  43727. return nil
  43728. case wpchatroom.FieldMemberList:
  43729. v, ok := value.([]string)
  43730. if !ok {
  43731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43732. }
  43733. m.SetMemberList(v)
  43734. return nil
  43735. }
  43736. return fmt.Errorf("unknown WpChatroom field %s", name)
  43737. }
  43738. // AddedFields returns all numeric fields that were incremented/decremented during
  43739. // this mutation.
  43740. func (m *WpChatroomMutation) AddedFields() []string {
  43741. var fields []string
  43742. if m.addstatus != nil {
  43743. fields = append(fields, wpchatroom.FieldStatus)
  43744. }
  43745. return fields
  43746. }
  43747. // AddedField returns the numeric value that was incremented/decremented on a field
  43748. // with the given name. The second boolean return value indicates that this field
  43749. // was not set, or was not defined in the schema.
  43750. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  43751. switch name {
  43752. case wpchatroom.FieldStatus:
  43753. return m.AddedStatus()
  43754. }
  43755. return nil, false
  43756. }
  43757. // AddField adds the value to the field with the given name. It returns an error if
  43758. // the field is not defined in the schema, or if the type mismatched the field
  43759. // type.
  43760. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  43761. switch name {
  43762. case wpchatroom.FieldStatus:
  43763. v, ok := value.(int8)
  43764. if !ok {
  43765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43766. }
  43767. m.AddStatus(v)
  43768. return nil
  43769. }
  43770. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  43771. }
  43772. // ClearedFields returns all nullable fields that were cleared during this
  43773. // mutation.
  43774. func (m *WpChatroomMutation) ClearedFields() []string {
  43775. var fields []string
  43776. if m.FieldCleared(wpchatroom.FieldStatus) {
  43777. fields = append(fields, wpchatroom.FieldStatus)
  43778. }
  43779. return fields
  43780. }
  43781. // FieldCleared returns a boolean indicating if a field with the given name was
  43782. // cleared in this mutation.
  43783. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  43784. _, ok := m.clearedFields[name]
  43785. return ok
  43786. }
  43787. // ClearField clears the value of the field with the given name. It returns an
  43788. // error if the field is not defined in the schema.
  43789. func (m *WpChatroomMutation) ClearField(name string) error {
  43790. switch name {
  43791. case wpchatroom.FieldStatus:
  43792. m.ClearStatus()
  43793. return nil
  43794. }
  43795. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  43796. }
  43797. // ResetField resets all changes in the mutation for the field with the given name.
  43798. // It returns an error if the field is not defined in the schema.
  43799. func (m *WpChatroomMutation) ResetField(name string) error {
  43800. switch name {
  43801. case wpchatroom.FieldCreatedAt:
  43802. m.ResetCreatedAt()
  43803. return nil
  43804. case wpchatroom.FieldUpdatedAt:
  43805. m.ResetUpdatedAt()
  43806. return nil
  43807. case wpchatroom.FieldStatus:
  43808. m.ResetStatus()
  43809. return nil
  43810. case wpchatroom.FieldWxWxid:
  43811. m.ResetWxWxid()
  43812. return nil
  43813. case wpchatroom.FieldChatroomID:
  43814. m.ResetChatroomID()
  43815. return nil
  43816. case wpchatroom.FieldNickname:
  43817. m.ResetNickname()
  43818. return nil
  43819. case wpchatroom.FieldOwner:
  43820. m.ResetOwner()
  43821. return nil
  43822. case wpchatroom.FieldAvatar:
  43823. m.ResetAvatar()
  43824. return nil
  43825. case wpchatroom.FieldMemberList:
  43826. m.ResetMemberList()
  43827. return nil
  43828. }
  43829. return fmt.Errorf("unknown WpChatroom field %s", name)
  43830. }
  43831. // AddedEdges returns all edge names that were set/added in this mutation.
  43832. func (m *WpChatroomMutation) AddedEdges() []string {
  43833. edges := make([]string, 0, 0)
  43834. return edges
  43835. }
  43836. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43837. // name in this mutation.
  43838. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  43839. return nil
  43840. }
  43841. // RemovedEdges returns all edge names that were removed in this mutation.
  43842. func (m *WpChatroomMutation) RemovedEdges() []string {
  43843. edges := make([]string, 0, 0)
  43844. return edges
  43845. }
  43846. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43847. // the given name in this mutation.
  43848. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  43849. return nil
  43850. }
  43851. // ClearedEdges returns all edge names that were cleared in this mutation.
  43852. func (m *WpChatroomMutation) ClearedEdges() []string {
  43853. edges := make([]string, 0, 0)
  43854. return edges
  43855. }
  43856. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43857. // was cleared in this mutation.
  43858. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  43859. return false
  43860. }
  43861. // ClearEdge clears the value of the edge with the given name. It returns an error
  43862. // if that edge is not defined in the schema.
  43863. func (m *WpChatroomMutation) ClearEdge(name string) error {
  43864. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  43865. }
  43866. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43867. // It returns an error if the edge is not defined in the schema.
  43868. func (m *WpChatroomMutation) ResetEdge(name string) error {
  43869. return fmt.Errorf("unknown WpChatroom edge %s", name)
  43870. }
  43871. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  43872. type WpChatroomMemberMutation struct {
  43873. config
  43874. op Op
  43875. typ string
  43876. id *uint64
  43877. created_at *time.Time
  43878. updated_at *time.Time
  43879. status *uint8
  43880. addstatus *int8
  43881. wx_wxid *string
  43882. wxid *string
  43883. nickname *string
  43884. avatar *string
  43885. clearedFields map[string]struct{}
  43886. done bool
  43887. oldValue func(context.Context) (*WpChatroomMember, error)
  43888. predicates []predicate.WpChatroomMember
  43889. }
  43890. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  43891. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  43892. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  43893. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  43894. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  43895. m := &WpChatroomMemberMutation{
  43896. config: c,
  43897. op: op,
  43898. typ: TypeWpChatroomMember,
  43899. clearedFields: make(map[string]struct{}),
  43900. }
  43901. for _, opt := range opts {
  43902. opt(m)
  43903. }
  43904. return m
  43905. }
  43906. // withWpChatroomMemberID sets the ID field of the mutation.
  43907. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  43908. return func(m *WpChatroomMemberMutation) {
  43909. var (
  43910. err error
  43911. once sync.Once
  43912. value *WpChatroomMember
  43913. )
  43914. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  43915. once.Do(func() {
  43916. if m.done {
  43917. err = errors.New("querying old values post mutation is not allowed")
  43918. } else {
  43919. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  43920. }
  43921. })
  43922. return value, err
  43923. }
  43924. m.id = &id
  43925. }
  43926. }
  43927. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  43928. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  43929. return func(m *WpChatroomMemberMutation) {
  43930. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  43931. return node, nil
  43932. }
  43933. m.id = &node.ID
  43934. }
  43935. }
  43936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43937. // executed in a transaction (ent.Tx), a transactional client is returned.
  43938. func (m WpChatroomMemberMutation) Client() *Client {
  43939. client := &Client{config: m.config}
  43940. client.init()
  43941. return client
  43942. }
  43943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43944. // it returns an error otherwise.
  43945. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  43946. if _, ok := m.driver.(*txDriver); !ok {
  43947. return nil, errors.New("ent: mutation is not running in a transaction")
  43948. }
  43949. tx := &Tx{config: m.config}
  43950. tx.init()
  43951. return tx, nil
  43952. }
  43953. // SetID sets the value of the id field. Note that this
  43954. // operation is only accepted on creation of WpChatroomMember entities.
  43955. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  43956. m.id = &id
  43957. }
  43958. // ID returns the ID value in the mutation. Note that the ID is only available
  43959. // if it was provided to the builder or after it was returned from the database.
  43960. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  43961. if m.id == nil {
  43962. return
  43963. }
  43964. return *m.id, true
  43965. }
  43966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43967. // That means, if the mutation is applied within a transaction with an isolation level such
  43968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43969. // or updated by the mutation.
  43970. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  43971. switch {
  43972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43973. id, exists := m.ID()
  43974. if exists {
  43975. return []uint64{id}, nil
  43976. }
  43977. fallthrough
  43978. case m.op.Is(OpUpdate | OpDelete):
  43979. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  43980. default:
  43981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43982. }
  43983. }
  43984. // SetCreatedAt sets the "created_at" field.
  43985. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  43986. m.created_at = &t
  43987. }
  43988. // CreatedAt returns the value of the "created_at" field in the mutation.
  43989. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  43990. v := m.created_at
  43991. if v == nil {
  43992. return
  43993. }
  43994. return *v, true
  43995. }
  43996. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  43997. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  43998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43999. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44000. if !m.op.Is(OpUpdateOne) {
  44001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44002. }
  44003. if m.id == nil || m.oldValue == nil {
  44004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44005. }
  44006. oldValue, err := m.oldValue(ctx)
  44007. if err != nil {
  44008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44009. }
  44010. return oldValue.CreatedAt, nil
  44011. }
  44012. // ResetCreatedAt resets all changes to the "created_at" field.
  44013. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  44014. m.created_at = nil
  44015. }
  44016. // SetUpdatedAt sets the "updated_at" field.
  44017. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  44018. m.updated_at = &t
  44019. }
  44020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44021. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  44022. v := m.updated_at
  44023. if v == nil {
  44024. return
  44025. }
  44026. return *v, true
  44027. }
  44028. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  44029. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44031. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44032. if !m.op.Is(OpUpdateOne) {
  44033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44034. }
  44035. if m.id == nil || m.oldValue == nil {
  44036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44037. }
  44038. oldValue, err := m.oldValue(ctx)
  44039. if err != nil {
  44040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44041. }
  44042. return oldValue.UpdatedAt, nil
  44043. }
  44044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44045. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  44046. m.updated_at = nil
  44047. }
  44048. // SetStatus sets the "status" field.
  44049. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  44050. m.status = &u
  44051. m.addstatus = nil
  44052. }
  44053. // Status returns the value of the "status" field in the mutation.
  44054. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  44055. v := m.status
  44056. if v == nil {
  44057. return
  44058. }
  44059. return *v, true
  44060. }
  44061. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  44062. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44064. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44065. if !m.op.Is(OpUpdateOne) {
  44066. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44067. }
  44068. if m.id == nil || m.oldValue == nil {
  44069. return v, errors.New("OldStatus requires an ID field in the mutation")
  44070. }
  44071. oldValue, err := m.oldValue(ctx)
  44072. if err != nil {
  44073. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44074. }
  44075. return oldValue.Status, nil
  44076. }
  44077. // AddStatus adds u to the "status" field.
  44078. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  44079. if m.addstatus != nil {
  44080. *m.addstatus += u
  44081. } else {
  44082. m.addstatus = &u
  44083. }
  44084. }
  44085. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44086. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  44087. v := m.addstatus
  44088. if v == nil {
  44089. return
  44090. }
  44091. return *v, true
  44092. }
  44093. // ClearStatus clears the value of the "status" field.
  44094. func (m *WpChatroomMemberMutation) ClearStatus() {
  44095. m.status = nil
  44096. m.addstatus = nil
  44097. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  44098. }
  44099. // StatusCleared returns if the "status" field was cleared in this mutation.
  44100. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  44101. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  44102. return ok
  44103. }
  44104. // ResetStatus resets all changes to the "status" field.
  44105. func (m *WpChatroomMemberMutation) ResetStatus() {
  44106. m.status = nil
  44107. m.addstatus = nil
  44108. delete(m.clearedFields, wpchatroommember.FieldStatus)
  44109. }
  44110. // SetWxWxid sets the "wx_wxid" field.
  44111. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  44112. m.wx_wxid = &s
  44113. }
  44114. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  44115. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  44116. v := m.wx_wxid
  44117. if v == nil {
  44118. return
  44119. }
  44120. return *v, true
  44121. }
  44122. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  44123. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44125. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  44126. if !m.op.Is(OpUpdateOne) {
  44127. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  44128. }
  44129. if m.id == nil || m.oldValue == nil {
  44130. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  44131. }
  44132. oldValue, err := m.oldValue(ctx)
  44133. if err != nil {
  44134. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  44135. }
  44136. return oldValue.WxWxid, nil
  44137. }
  44138. // ResetWxWxid resets all changes to the "wx_wxid" field.
  44139. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  44140. m.wx_wxid = nil
  44141. }
  44142. // SetWxid sets the "wxid" field.
  44143. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  44144. m.wxid = &s
  44145. }
  44146. // Wxid returns the value of the "wxid" field in the mutation.
  44147. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  44148. v := m.wxid
  44149. if v == nil {
  44150. return
  44151. }
  44152. return *v, true
  44153. }
  44154. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  44155. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  44156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44157. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  44158. if !m.op.Is(OpUpdateOne) {
  44159. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44160. }
  44161. if m.id == nil || m.oldValue == nil {
  44162. return v, errors.New("OldWxid requires an ID field in the mutation")
  44163. }
  44164. oldValue, err := m.oldValue(ctx)
  44165. if err != nil {
  44166. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44167. }
  44168. return oldValue.Wxid, nil
  44169. }
  44170. // ResetWxid resets all changes to the "wxid" field.
  44171. func (m *WpChatroomMemberMutation) ResetWxid() {
  44172. m.wxid = nil
  44173. }
  44174. // SetNickname sets the "nickname" field.
  44175. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  44176. m.nickname = &s
  44177. }
  44178. // Nickname returns the value of the "nickname" field in the mutation.
  44179. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  44180. v := m.nickname
  44181. if v == nil {
  44182. return
  44183. }
  44184. return *v, true
  44185. }
  44186. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  44187. // If the WpChatroomMember 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 *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  44190. if !m.op.Is(OpUpdateOne) {
  44191. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44192. }
  44193. if m.id == nil || m.oldValue == nil {
  44194. return v, errors.New("OldNickname 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 OldNickname: %w", err)
  44199. }
  44200. return oldValue.Nickname, nil
  44201. }
  44202. // ResetNickname resets all changes to the "nickname" field.
  44203. func (m *WpChatroomMemberMutation) ResetNickname() {
  44204. m.nickname = nil
  44205. }
  44206. // SetAvatar sets the "avatar" field.
  44207. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  44208. m.avatar = &s
  44209. }
  44210. // Avatar returns the value of the "avatar" field in the mutation.
  44211. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  44212. v := m.avatar
  44213. if v == nil {
  44214. return
  44215. }
  44216. return *v, true
  44217. }
  44218. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  44219. // If the WpChatroomMember 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 *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44222. if !m.op.Is(OpUpdateOne) {
  44223. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44224. }
  44225. if m.id == nil || m.oldValue == nil {
  44226. return v, errors.New("OldAvatar 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 OldAvatar: %w", err)
  44231. }
  44232. return oldValue.Avatar, nil
  44233. }
  44234. // ResetAvatar resets all changes to the "avatar" field.
  44235. func (m *WpChatroomMemberMutation) ResetAvatar() {
  44236. m.avatar = nil
  44237. }
  44238. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  44239. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  44240. m.predicates = append(m.predicates, ps...)
  44241. }
  44242. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  44243. // users can use type-assertion to append predicates that do not depend on any generated package.
  44244. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  44245. p := make([]predicate.WpChatroomMember, len(ps))
  44246. for i := range ps {
  44247. p[i] = ps[i]
  44248. }
  44249. m.Where(p...)
  44250. }
  44251. // Op returns the operation name.
  44252. func (m *WpChatroomMemberMutation) Op() Op {
  44253. return m.op
  44254. }
  44255. // SetOp allows setting the mutation operation.
  44256. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  44257. m.op = op
  44258. }
  44259. // Type returns the node type of this mutation (WpChatroomMember).
  44260. func (m *WpChatroomMemberMutation) Type() string {
  44261. return m.typ
  44262. }
  44263. // Fields returns all fields that were changed during this mutation. Note that in
  44264. // order to get all numeric fields that were incremented/decremented, call
  44265. // AddedFields().
  44266. func (m *WpChatroomMemberMutation) Fields() []string {
  44267. fields := make([]string, 0, 7)
  44268. if m.created_at != nil {
  44269. fields = append(fields, wpchatroommember.FieldCreatedAt)
  44270. }
  44271. if m.updated_at != nil {
  44272. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  44273. }
  44274. if m.status != nil {
  44275. fields = append(fields, wpchatroommember.FieldStatus)
  44276. }
  44277. if m.wx_wxid != nil {
  44278. fields = append(fields, wpchatroommember.FieldWxWxid)
  44279. }
  44280. if m.wxid != nil {
  44281. fields = append(fields, wpchatroommember.FieldWxid)
  44282. }
  44283. if m.nickname != nil {
  44284. fields = append(fields, wpchatroommember.FieldNickname)
  44285. }
  44286. if m.avatar != nil {
  44287. fields = append(fields, wpchatroommember.FieldAvatar)
  44288. }
  44289. return fields
  44290. }
  44291. // Field returns the value of a field with the given name. The second boolean
  44292. // return value indicates that this field was not set, or was not defined in the
  44293. // schema.
  44294. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  44295. switch name {
  44296. case wpchatroommember.FieldCreatedAt:
  44297. return m.CreatedAt()
  44298. case wpchatroommember.FieldUpdatedAt:
  44299. return m.UpdatedAt()
  44300. case wpchatroommember.FieldStatus:
  44301. return m.Status()
  44302. case wpchatroommember.FieldWxWxid:
  44303. return m.WxWxid()
  44304. case wpchatroommember.FieldWxid:
  44305. return m.Wxid()
  44306. case wpchatroommember.FieldNickname:
  44307. return m.Nickname()
  44308. case wpchatroommember.FieldAvatar:
  44309. return m.Avatar()
  44310. }
  44311. return nil, false
  44312. }
  44313. // OldField returns the old value of the field from the database. An error is
  44314. // returned if the mutation operation is not UpdateOne, or the query to the
  44315. // database failed.
  44316. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44317. switch name {
  44318. case wpchatroommember.FieldCreatedAt:
  44319. return m.OldCreatedAt(ctx)
  44320. case wpchatroommember.FieldUpdatedAt:
  44321. return m.OldUpdatedAt(ctx)
  44322. case wpchatroommember.FieldStatus:
  44323. return m.OldStatus(ctx)
  44324. case wpchatroommember.FieldWxWxid:
  44325. return m.OldWxWxid(ctx)
  44326. case wpchatroommember.FieldWxid:
  44327. return m.OldWxid(ctx)
  44328. case wpchatroommember.FieldNickname:
  44329. return m.OldNickname(ctx)
  44330. case wpchatroommember.FieldAvatar:
  44331. return m.OldAvatar(ctx)
  44332. }
  44333. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  44334. }
  44335. // SetField sets the value of a field with the given name. It returns an error if
  44336. // the field is not defined in the schema, or if the type mismatched the field
  44337. // type.
  44338. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  44339. switch name {
  44340. case wpchatroommember.FieldCreatedAt:
  44341. v, ok := value.(time.Time)
  44342. if !ok {
  44343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44344. }
  44345. m.SetCreatedAt(v)
  44346. return nil
  44347. case wpchatroommember.FieldUpdatedAt:
  44348. v, ok := value.(time.Time)
  44349. if !ok {
  44350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44351. }
  44352. m.SetUpdatedAt(v)
  44353. return nil
  44354. case wpchatroommember.FieldStatus:
  44355. v, ok := value.(uint8)
  44356. if !ok {
  44357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44358. }
  44359. m.SetStatus(v)
  44360. return nil
  44361. case wpchatroommember.FieldWxWxid:
  44362. v, ok := value.(string)
  44363. if !ok {
  44364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44365. }
  44366. m.SetWxWxid(v)
  44367. return nil
  44368. case wpchatroommember.FieldWxid:
  44369. v, ok := value.(string)
  44370. if !ok {
  44371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44372. }
  44373. m.SetWxid(v)
  44374. return nil
  44375. case wpchatroommember.FieldNickname:
  44376. v, ok := value.(string)
  44377. if !ok {
  44378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44379. }
  44380. m.SetNickname(v)
  44381. return nil
  44382. case wpchatroommember.FieldAvatar:
  44383. v, ok := value.(string)
  44384. if !ok {
  44385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44386. }
  44387. m.SetAvatar(v)
  44388. return nil
  44389. }
  44390. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  44391. }
  44392. // AddedFields returns all numeric fields that were incremented/decremented during
  44393. // this mutation.
  44394. func (m *WpChatroomMemberMutation) AddedFields() []string {
  44395. var fields []string
  44396. if m.addstatus != nil {
  44397. fields = append(fields, wpchatroommember.FieldStatus)
  44398. }
  44399. return fields
  44400. }
  44401. // AddedField returns the numeric value that was incremented/decremented on a field
  44402. // with the given name. The second boolean return value indicates that this field
  44403. // was not set, or was not defined in the schema.
  44404. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  44405. switch name {
  44406. case wpchatroommember.FieldStatus:
  44407. return m.AddedStatus()
  44408. }
  44409. return nil, false
  44410. }
  44411. // AddField adds the value to the field with the given name. It returns an error if
  44412. // the field is not defined in the schema, or if the type mismatched the field
  44413. // type.
  44414. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  44415. switch name {
  44416. case wpchatroommember.FieldStatus:
  44417. v, ok := value.(int8)
  44418. if !ok {
  44419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44420. }
  44421. m.AddStatus(v)
  44422. return nil
  44423. }
  44424. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  44425. }
  44426. // ClearedFields returns all nullable fields that were cleared during this
  44427. // mutation.
  44428. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  44429. var fields []string
  44430. if m.FieldCleared(wpchatroommember.FieldStatus) {
  44431. fields = append(fields, wpchatroommember.FieldStatus)
  44432. }
  44433. return fields
  44434. }
  44435. // FieldCleared returns a boolean indicating if a field with the given name was
  44436. // cleared in this mutation.
  44437. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  44438. _, ok := m.clearedFields[name]
  44439. return ok
  44440. }
  44441. // ClearField clears the value of the field with the given name. It returns an
  44442. // error if the field is not defined in the schema.
  44443. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  44444. switch name {
  44445. case wpchatroommember.FieldStatus:
  44446. m.ClearStatus()
  44447. return nil
  44448. }
  44449. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  44450. }
  44451. // ResetField resets all changes in the mutation for the field with the given name.
  44452. // It returns an error if the field is not defined in the schema.
  44453. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  44454. switch name {
  44455. case wpchatroommember.FieldCreatedAt:
  44456. m.ResetCreatedAt()
  44457. return nil
  44458. case wpchatroommember.FieldUpdatedAt:
  44459. m.ResetUpdatedAt()
  44460. return nil
  44461. case wpchatroommember.FieldStatus:
  44462. m.ResetStatus()
  44463. return nil
  44464. case wpchatroommember.FieldWxWxid:
  44465. m.ResetWxWxid()
  44466. return nil
  44467. case wpchatroommember.FieldWxid:
  44468. m.ResetWxid()
  44469. return nil
  44470. case wpchatroommember.FieldNickname:
  44471. m.ResetNickname()
  44472. return nil
  44473. case wpchatroommember.FieldAvatar:
  44474. m.ResetAvatar()
  44475. return nil
  44476. }
  44477. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  44478. }
  44479. // AddedEdges returns all edge names that were set/added in this mutation.
  44480. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  44481. edges := make([]string, 0, 0)
  44482. return edges
  44483. }
  44484. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44485. // name in this mutation.
  44486. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  44487. return nil
  44488. }
  44489. // RemovedEdges returns all edge names that were removed in this mutation.
  44490. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  44491. edges := make([]string, 0, 0)
  44492. return edges
  44493. }
  44494. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44495. // the given name in this mutation.
  44496. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  44497. return nil
  44498. }
  44499. // ClearedEdges returns all edge names that were cleared in this mutation.
  44500. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  44501. edges := make([]string, 0, 0)
  44502. return edges
  44503. }
  44504. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44505. // was cleared in this mutation.
  44506. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  44507. return false
  44508. }
  44509. // ClearEdge clears the value of the edge with the given name. It returns an error
  44510. // if that edge is not defined in the schema.
  44511. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  44512. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  44513. }
  44514. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44515. // It returns an error if the edge is not defined in the schema.
  44516. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  44517. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  44518. }
  44519. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  44520. type WxMutation struct {
  44521. config
  44522. op Op
  44523. typ string
  44524. id *uint64
  44525. created_at *time.Time
  44526. updated_at *time.Time
  44527. status *uint8
  44528. addstatus *int8
  44529. deleted_at *time.Time
  44530. port *string
  44531. process_id *string
  44532. callback *string
  44533. wxid *string
  44534. account *string
  44535. nickname *string
  44536. tel *string
  44537. head_big *string
  44538. organization_id *uint64
  44539. addorganization_id *int64
  44540. api_base *string
  44541. api_key *string
  44542. allow_list *[]string
  44543. appendallow_list []string
  44544. group_allow_list *[]string
  44545. appendgroup_allow_list []string
  44546. block_list *[]string
  44547. appendblock_list []string
  44548. group_block_list *[]string
  44549. appendgroup_block_list []string
  44550. ctype *uint64
  44551. addctype *int64
  44552. clearedFields map[string]struct{}
  44553. server *uint64
  44554. clearedserver bool
  44555. agent *uint64
  44556. clearedagent bool
  44557. done bool
  44558. oldValue func(context.Context) (*Wx, error)
  44559. predicates []predicate.Wx
  44560. }
  44561. var _ ent.Mutation = (*WxMutation)(nil)
  44562. // wxOption allows management of the mutation configuration using functional options.
  44563. type wxOption func(*WxMutation)
  44564. // newWxMutation creates new mutation for the Wx entity.
  44565. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  44566. m := &WxMutation{
  44567. config: c,
  44568. op: op,
  44569. typ: TypeWx,
  44570. clearedFields: make(map[string]struct{}),
  44571. }
  44572. for _, opt := range opts {
  44573. opt(m)
  44574. }
  44575. return m
  44576. }
  44577. // withWxID sets the ID field of the mutation.
  44578. func withWxID(id uint64) wxOption {
  44579. return func(m *WxMutation) {
  44580. var (
  44581. err error
  44582. once sync.Once
  44583. value *Wx
  44584. )
  44585. m.oldValue = func(ctx context.Context) (*Wx, error) {
  44586. once.Do(func() {
  44587. if m.done {
  44588. err = errors.New("querying old values post mutation is not allowed")
  44589. } else {
  44590. value, err = m.Client().Wx.Get(ctx, id)
  44591. }
  44592. })
  44593. return value, err
  44594. }
  44595. m.id = &id
  44596. }
  44597. }
  44598. // withWx sets the old Wx of the mutation.
  44599. func withWx(node *Wx) wxOption {
  44600. return func(m *WxMutation) {
  44601. m.oldValue = func(context.Context) (*Wx, error) {
  44602. return node, nil
  44603. }
  44604. m.id = &node.ID
  44605. }
  44606. }
  44607. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44608. // executed in a transaction (ent.Tx), a transactional client is returned.
  44609. func (m WxMutation) Client() *Client {
  44610. client := &Client{config: m.config}
  44611. client.init()
  44612. return client
  44613. }
  44614. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44615. // it returns an error otherwise.
  44616. func (m WxMutation) Tx() (*Tx, error) {
  44617. if _, ok := m.driver.(*txDriver); !ok {
  44618. return nil, errors.New("ent: mutation is not running in a transaction")
  44619. }
  44620. tx := &Tx{config: m.config}
  44621. tx.init()
  44622. return tx, nil
  44623. }
  44624. // SetID sets the value of the id field. Note that this
  44625. // operation is only accepted on creation of Wx entities.
  44626. func (m *WxMutation) SetID(id uint64) {
  44627. m.id = &id
  44628. }
  44629. // ID returns the ID value in the mutation. Note that the ID is only available
  44630. // if it was provided to the builder or after it was returned from the database.
  44631. func (m *WxMutation) ID() (id uint64, exists bool) {
  44632. if m.id == nil {
  44633. return
  44634. }
  44635. return *m.id, true
  44636. }
  44637. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44638. // That means, if the mutation is applied within a transaction with an isolation level such
  44639. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44640. // or updated by the mutation.
  44641. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  44642. switch {
  44643. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44644. id, exists := m.ID()
  44645. if exists {
  44646. return []uint64{id}, nil
  44647. }
  44648. fallthrough
  44649. case m.op.Is(OpUpdate | OpDelete):
  44650. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  44651. default:
  44652. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44653. }
  44654. }
  44655. // SetCreatedAt sets the "created_at" field.
  44656. func (m *WxMutation) SetCreatedAt(t time.Time) {
  44657. m.created_at = &t
  44658. }
  44659. // CreatedAt returns the value of the "created_at" field in the mutation.
  44660. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  44661. v := m.created_at
  44662. if v == nil {
  44663. return
  44664. }
  44665. return *v, true
  44666. }
  44667. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  44668. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44670. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44671. if !m.op.Is(OpUpdateOne) {
  44672. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44673. }
  44674. if m.id == nil || m.oldValue == nil {
  44675. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44676. }
  44677. oldValue, err := m.oldValue(ctx)
  44678. if err != nil {
  44679. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44680. }
  44681. return oldValue.CreatedAt, nil
  44682. }
  44683. // ResetCreatedAt resets all changes to the "created_at" field.
  44684. func (m *WxMutation) ResetCreatedAt() {
  44685. m.created_at = nil
  44686. }
  44687. // SetUpdatedAt sets the "updated_at" field.
  44688. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  44689. m.updated_at = &t
  44690. }
  44691. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44692. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  44693. v := m.updated_at
  44694. if v == nil {
  44695. return
  44696. }
  44697. return *v, true
  44698. }
  44699. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  44700. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44702. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44703. if !m.op.Is(OpUpdateOne) {
  44704. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44705. }
  44706. if m.id == nil || m.oldValue == nil {
  44707. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44708. }
  44709. oldValue, err := m.oldValue(ctx)
  44710. if err != nil {
  44711. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44712. }
  44713. return oldValue.UpdatedAt, nil
  44714. }
  44715. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44716. func (m *WxMutation) ResetUpdatedAt() {
  44717. m.updated_at = nil
  44718. }
  44719. // SetStatus sets the "status" field.
  44720. func (m *WxMutation) SetStatus(u uint8) {
  44721. m.status = &u
  44722. m.addstatus = nil
  44723. }
  44724. // Status returns the value of the "status" field in the mutation.
  44725. func (m *WxMutation) Status() (r uint8, exists bool) {
  44726. v := m.status
  44727. if v == nil {
  44728. return
  44729. }
  44730. return *v, true
  44731. }
  44732. // OldStatus returns the old "status" field's value of the Wx entity.
  44733. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44735. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  44736. if !m.op.Is(OpUpdateOne) {
  44737. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  44738. }
  44739. if m.id == nil || m.oldValue == nil {
  44740. return v, errors.New("OldStatus requires an ID field in the mutation")
  44741. }
  44742. oldValue, err := m.oldValue(ctx)
  44743. if err != nil {
  44744. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  44745. }
  44746. return oldValue.Status, nil
  44747. }
  44748. // AddStatus adds u to the "status" field.
  44749. func (m *WxMutation) AddStatus(u int8) {
  44750. if m.addstatus != nil {
  44751. *m.addstatus += u
  44752. } else {
  44753. m.addstatus = &u
  44754. }
  44755. }
  44756. // AddedStatus returns the value that was added to the "status" field in this mutation.
  44757. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  44758. v := m.addstatus
  44759. if v == nil {
  44760. return
  44761. }
  44762. return *v, true
  44763. }
  44764. // ClearStatus clears the value of the "status" field.
  44765. func (m *WxMutation) ClearStatus() {
  44766. m.status = nil
  44767. m.addstatus = nil
  44768. m.clearedFields[wx.FieldStatus] = struct{}{}
  44769. }
  44770. // StatusCleared returns if the "status" field was cleared in this mutation.
  44771. func (m *WxMutation) StatusCleared() bool {
  44772. _, ok := m.clearedFields[wx.FieldStatus]
  44773. return ok
  44774. }
  44775. // ResetStatus resets all changes to the "status" field.
  44776. func (m *WxMutation) ResetStatus() {
  44777. m.status = nil
  44778. m.addstatus = nil
  44779. delete(m.clearedFields, wx.FieldStatus)
  44780. }
  44781. // SetDeletedAt sets the "deleted_at" field.
  44782. func (m *WxMutation) SetDeletedAt(t time.Time) {
  44783. m.deleted_at = &t
  44784. }
  44785. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44786. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  44787. v := m.deleted_at
  44788. if v == nil {
  44789. return
  44790. }
  44791. return *v, true
  44792. }
  44793. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  44794. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44796. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44797. if !m.op.Is(OpUpdateOne) {
  44798. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44799. }
  44800. if m.id == nil || m.oldValue == nil {
  44801. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44802. }
  44803. oldValue, err := m.oldValue(ctx)
  44804. if err != nil {
  44805. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44806. }
  44807. return oldValue.DeletedAt, nil
  44808. }
  44809. // ClearDeletedAt clears the value of the "deleted_at" field.
  44810. func (m *WxMutation) ClearDeletedAt() {
  44811. m.deleted_at = nil
  44812. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  44813. }
  44814. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44815. func (m *WxMutation) DeletedAtCleared() bool {
  44816. _, ok := m.clearedFields[wx.FieldDeletedAt]
  44817. return ok
  44818. }
  44819. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44820. func (m *WxMutation) ResetDeletedAt() {
  44821. m.deleted_at = nil
  44822. delete(m.clearedFields, wx.FieldDeletedAt)
  44823. }
  44824. // SetServerID sets the "server_id" field.
  44825. func (m *WxMutation) SetServerID(u uint64) {
  44826. m.server = &u
  44827. }
  44828. // ServerID returns the value of the "server_id" field in the mutation.
  44829. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  44830. v := m.server
  44831. if v == nil {
  44832. return
  44833. }
  44834. return *v, true
  44835. }
  44836. // OldServerID returns the old "server_id" field's value of the Wx entity.
  44837. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44839. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  44840. if !m.op.Is(OpUpdateOne) {
  44841. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  44842. }
  44843. if m.id == nil || m.oldValue == nil {
  44844. return v, errors.New("OldServerID requires an ID field in the mutation")
  44845. }
  44846. oldValue, err := m.oldValue(ctx)
  44847. if err != nil {
  44848. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  44849. }
  44850. return oldValue.ServerID, nil
  44851. }
  44852. // ClearServerID clears the value of the "server_id" field.
  44853. func (m *WxMutation) ClearServerID() {
  44854. m.server = nil
  44855. m.clearedFields[wx.FieldServerID] = struct{}{}
  44856. }
  44857. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  44858. func (m *WxMutation) ServerIDCleared() bool {
  44859. _, ok := m.clearedFields[wx.FieldServerID]
  44860. return ok
  44861. }
  44862. // ResetServerID resets all changes to the "server_id" field.
  44863. func (m *WxMutation) ResetServerID() {
  44864. m.server = nil
  44865. delete(m.clearedFields, wx.FieldServerID)
  44866. }
  44867. // SetPort sets the "port" field.
  44868. func (m *WxMutation) SetPort(s string) {
  44869. m.port = &s
  44870. }
  44871. // Port returns the value of the "port" field in the mutation.
  44872. func (m *WxMutation) Port() (r string, exists bool) {
  44873. v := m.port
  44874. if v == nil {
  44875. return
  44876. }
  44877. return *v, true
  44878. }
  44879. // OldPort returns the old "port" field's value of the Wx entity.
  44880. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44882. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  44883. if !m.op.Is(OpUpdateOne) {
  44884. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  44885. }
  44886. if m.id == nil || m.oldValue == nil {
  44887. return v, errors.New("OldPort requires an ID field in the mutation")
  44888. }
  44889. oldValue, err := m.oldValue(ctx)
  44890. if err != nil {
  44891. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  44892. }
  44893. return oldValue.Port, nil
  44894. }
  44895. // ResetPort resets all changes to the "port" field.
  44896. func (m *WxMutation) ResetPort() {
  44897. m.port = nil
  44898. }
  44899. // SetProcessID sets the "process_id" field.
  44900. func (m *WxMutation) SetProcessID(s string) {
  44901. m.process_id = &s
  44902. }
  44903. // ProcessID returns the value of the "process_id" field in the mutation.
  44904. func (m *WxMutation) ProcessID() (r string, exists bool) {
  44905. v := m.process_id
  44906. if v == nil {
  44907. return
  44908. }
  44909. return *v, true
  44910. }
  44911. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  44912. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44914. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  44915. if !m.op.Is(OpUpdateOne) {
  44916. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  44917. }
  44918. if m.id == nil || m.oldValue == nil {
  44919. return v, errors.New("OldProcessID requires an ID field in the mutation")
  44920. }
  44921. oldValue, err := m.oldValue(ctx)
  44922. if err != nil {
  44923. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  44924. }
  44925. return oldValue.ProcessID, nil
  44926. }
  44927. // ResetProcessID resets all changes to the "process_id" field.
  44928. func (m *WxMutation) ResetProcessID() {
  44929. m.process_id = nil
  44930. }
  44931. // SetCallback sets the "callback" field.
  44932. func (m *WxMutation) SetCallback(s string) {
  44933. m.callback = &s
  44934. }
  44935. // Callback returns the value of the "callback" field in the mutation.
  44936. func (m *WxMutation) Callback() (r string, exists bool) {
  44937. v := m.callback
  44938. if v == nil {
  44939. return
  44940. }
  44941. return *v, true
  44942. }
  44943. // OldCallback returns the old "callback" field's value of the Wx entity.
  44944. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44945. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44946. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  44947. if !m.op.Is(OpUpdateOne) {
  44948. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  44949. }
  44950. if m.id == nil || m.oldValue == nil {
  44951. return v, errors.New("OldCallback requires an ID field in the mutation")
  44952. }
  44953. oldValue, err := m.oldValue(ctx)
  44954. if err != nil {
  44955. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  44956. }
  44957. return oldValue.Callback, nil
  44958. }
  44959. // ResetCallback resets all changes to the "callback" field.
  44960. func (m *WxMutation) ResetCallback() {
  44961. m.callback = nil
  44962. }
  44963. // SetWxid sets the "wxid" field.
  44964. func (m *WxMutation) SetWxid(s string) {
  44965. m.wxid = &s
  44966. }
  44967. // Wxid returns the value of the "wxid" field in the mutation.
  44968. func (m *WxMutation) Wxid() (r string, exists bool) {
  44969. v := m.wxid
  44970. if v == nil {
  44971. return
  44972. }
  44973. return *v, true
  44974. }
  44975. // OldWxid returns the old "wxid" field's value of the Wx entity.
  44976. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  44977. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44978. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  44979. if !m.op.Is(OpUpdateOne) {
  44980. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44981. }
  44982. if m.id == nil || m.oldValue == nil {
  44983. return v, errors.New("OldWxid requires an ID field in the mutation")
  44984. }
  44985. oldValue, err := m.oldValue(ctx)
  44986. if err != nil {
  44987. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44988. }
  44989. return oldValue.Wxid, nil
  44990. }
  44991. // ResetWxid resets all changes to the "wxid" field.
  44992. func (m *WxMutation) ResetWxid() {
  44993. m.wxid = nil
  44994. }
  44995. // SetAccount sets the "account" field.
  44996. func (m *WxMutation) SetAccount(s string) {
  44997. m.account = &s
  44998. }
  44999. // Account returns the value of the "account" field in the mutation.
  45000. func (m *WxMutation) Account() (r string, exists bool) {
  45001. v := m.account
  45002. if v == nil {
  45003. return
  45004. }
  45005. return *v, true
  45006. }
  45007. // OldAccount returns the old "account" field's value of the Wx entity.
  45008. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45010. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  45011. if !m.op.Is(OpUpdateOne) {
  45012. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  45013. }
  45014. if m.id == nil || m.oldValue == nil {
  45015. return v, errors.New("OldAccount requires an ID field in the mutation")
  45016. }
  45017. oldValue, err := m.oldValue(ctx)
  45018. if err != nil {
  45019. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  45020. }
  45021. return oldValue.Account, nil
  45022. }
  45023. // ResetAccount resets all changes to the "account" field.
  45024. func (m *WxMutation) ResetAccount() {
  45025. m.account = nil
  45026. }
  45027. // SetNickname sets the "nickname" field.
  45028. func (m *WxMutation) SetNickname(s string) {
  45029. m.nickname = &s
  45030. }
  45031. // Nickname returns the value of the "nickname" field in the mutation.
  45032. func (m *WxMutation) Nickname() (r string, exists bool) {
  45033. v := m.nickname
  45034. if v == nil {
  45035. return
  45036. }
  45037. return *v, true
  45038. }
  45039. // OldNickname returns the old "nickname" field's value of the Wx entity.
  45040. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45042. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  45043. if !m.op.Is(OpUpdateOne) {
  45044. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45045. }
  45046. if m.id == nil || m.oldValue == nil {
  45047. return v, errors.New("OldNickname requires an ID field in the mutation")
  45048. }
  45049. oldValue, err := m.oldValue(ctx)
  45050. if err != nil {
  45051. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45052. }
  45053. return oldValue.Nickname, nil
  45054. }
  45055. // ResetNickname resets all changes to the "nickname" field.
  45056. func (m *WxMutation) ResetNickname() {
  45057. m.nickname = nil
  45058. }
  45059. // SetTel sets the "tel" field.
  45060. func (m *WxMutation) SetTel(s string) {
  45061. m.tel = &s
  45062. }
  45063. // Tel returns the value of the "tel" field in the mutation.
  45064. func (m *WxMutation) Tel() (r string, exists bool) {
  45065. v := m.tel
  45066. if v == nil {
  45067. return
  45068. }
  45069. return *v, true
  45070. }
  45071. // OldTel returns the old "tel" field's value of the Wx entity.
  45072. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45074. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  45075. if !m.op.Is(OpUpdateOne) {
  45076. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  45077. }
  45078. if m.id == nil || m.oldValue == nil {
  45079. return v, errors.New("OldTel requires an ID field in the mutation")
  45080. }
  45081. oldValue, err := m.oldValue(ctx)
  45082. if err != nil {
  45083. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  45084. }
  45085. return oldValue.Tel, nil
  45086. }
  45087. // ResetTel resets all changes to the "tel" field.
  45088. func (m *WxMutation) ResetTel() {
  45089. m.tel = nil
  45090. }
  45091. // SetHeadBig sets the "head_big" field.
  45092. func (m *WxMutation) SetHeadBig(s string) {
  45093. m.head_big = &s
  45094. }
  45095. // HeadBig returns the value of the "head_big" field in the mutation.
  45096. func (m *WxMutation) HeadBig() (r string, exists bool) {
  45097. v := m.head_big
  45098. if v == nil {
  45099. return
  45100. }
  45101. return *v, true
  45102. }
  45103. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  45104. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45106. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  45107. if !m.op.Is(OpUpdateOne) {
  45108. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  45109. }
  45110. if m.id == nil || m.oldValue == nil {
  45111. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  45112. }
  45113. oldValue, err := m.oldValue(ctx)
  45114. if err != nil {
  45115. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  45116. }
  45117. return oldValue.HeadBig, nil
  45118. }
  45119. // ResetHeadBig resets all changes to the "head_big" field.
  45120. func (m *WxMutation) ResetHeadBig() {
  45121. m.head_big = nil
  45122. }
  45123. // SetOrganizationID sets the "organization_id" field.
  45124. func (m *WxMutation) SetOrganizationID(u uint64) {
  45125. m.organization_id = &u
  45126. m.addorganization_id = nil
  45127. }
  45128. // OrganizationID returns the value of the "organization_id" field in the mutation.
  45129. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  45130. v := m.organization_id
  45131. if v == nil {
  45132. return
  45133. }
  45134. return *v, true
  45135. }
  45136. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  45137. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45139. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45140. if !m.op.Is(OpUpdateOne) {
  45141. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45142. }
  45143. if m.id == nil || m.oldValue == nil {
  45144. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45145. }
  45146. oldValue, err := m.oldValue(ctx)
  45147. if err != nil {
  45148. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45149. }
  45150. return oldValue.OrganizationID, nil
  45151. }
  45152. // AddOrganizationID adds u to the "organization_id" field.
  45153. func (m *WxMutation) AddOrganizationID(u int64) {
  45154. if m.addorganization_id != nil {
  45155. *m.addorganization_id += u
  45156. } else {
  45157. m.addorganization_id = &u
  45158. }
  45159. }
  45160. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45161. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  45162. v := m.addorganization_id
  45163. if v == nil {
  45164. return
  45165. }
  45166. return *v, true
  45167. }
  45168. // ClearOrganizationID clears the value of the "organization_id" field.
  45169. func (m *WxMutation) ClearOrganizationID() {
  45170. m.organization_id = nil
  45171. m.addorganization_id = nil
  45172. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  45173. }
  45174. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  45175. func (m *WxMutation) OrganizationIDCleared() bool {
  45176. _, ok := m.clearedFields[wx.FieldOrganizationID]
  45177. return ok
  45178. }
  45179. // ResetOrganizationID resets all changes to the "organization_id" field.
  45180. func (m *WxMutation) ResetOrganizationID() {
  45181. m.organization_id = nil
  45182. m.addorganization_id = nil
  45183. delete(m.clearedFields, wx.FieldOrganizationID)
  45184. }
  45185. // SetAgentID sets the "agent_id" field.
  45186. func (m *WxMutation) SetAgentID(u uint64) {
  45187. m.agent = &u
  45188. }
  45189. // AgentID returns the value of the "agent_id" field in the mutation.
  45190. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  45191. v := m.agent
  45192. if v == nil {
  45193. return
  45194. }
  45195. return *v, true
  45196. }
  45197. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  45198. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45200. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  45201. if !m.op.Is(OpUpdateOne) {
  45202. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  45203. }
  45204. if m.id == nil || m.oldValue == nil {
  45205. return v, errors.New("OldAgentID requires an ID field in the mutation")
  45206. }
  45207. oldValue, err := m.oldValue(ctx)
  45208. if err != nil {
  45209. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  45210. }
  45211. return oldValue.AgentID, nil
  45212. }
  45213. // ResetAgentID resets all changes to the "agent_id" field.
  45214. func (m *WxMutation) ResetAgentID() {
  45215. m.agent = nil
  45216. }
  45217. // SetAPIBase sets the "api_base" field.
  45218. func (m *WxMutation) SetAPIBase(s string) {
  45219. m.api_base = &s
  45220. }
  45221. // APIBase returns the value of the "api_base" field in the mutation.
  45222. func (m *WxMutation) APIBase() (r string, exists bool) {
  45223. v := m.api_base
  45224. if v == nil {
  45225. return
  45226. }
  45227. return *v, true
  45228. }
  45229. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  45230. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45232. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  45233. if !m.op.Is(OpUpdateOne) {
  45234. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  45235. }
  45236. if m.id == nil || m.oldValue == nil {
  45237. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  45238. }
  45239. oldValue, err := m.oldValue(ctx)
  45240. if err != nil {
  45241. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  45242. }
  45243. return oldValue.APIBase, nil
  45244. }
  45245. // ClearAPIBase clears the value of the "api_base" field.
  45246. func (m *WxMutation) ClearAPIBase() {
  45247. m.api_base = nil
  45248. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  45249. }
  45250. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  45251. func (m *WxMutation) APIBaseCleared() bool {
  45252. _, ok := m.clearedFields[wx.FieldAPIBase]
  45253. return ok
  45254. }
  45255. // ResetAPIBase resets all changes to the "api_base" field.
  45256. func (m *WxMutation) ResetAPIBase() {
  45257. m.api_base = nil
  45258. delete(m.clearedFields, wx.FieldAPIBase)
  45259. }
  45260. // SetAPIKey sets the "api_key" field.
  45261. func (m *WxMutation) SetAPIKey(s string) {
  45262. m.api_key = &s
  45263. }
  45264. // APIKey returns the value of the "api_key" field in the mutation.
  45265. func (m *WxMutation) APIKey() (r string, exists bool) {
  45266. v := m.api_key
  45267. if v == nil {
  45268. return
  45269. }
  45270. return *v, true
  45271. }
  45272. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  45273. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45275. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  45276. if !m.op.Is(OpUpdateOne) {
  45277. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  45278. }
  45279. if m.id == nil || m.oldValue == nil {
  45280. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  45281. }
  45282. oldValue, err := m.oldValue(ctx)
  45283. if err != nil {
  45284. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  45285. }
  45286. return oldValue.APIKey, nil
  45287. }
  45288. // ClearAPIKey clears the value of the "api_key" field.
  45289. func (m *WxMutation) ClearAPIKey() {
  45290. m.api_key = nil
  45291. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  45292. }
  45293. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  45294. func (m *WxMutation) APIKeyCleared() bool {
  45295. _, ok := m.clearedFields[wx.FieldAPIKey]
  45296. return ok
  45297. }
  45298. // ResetAPIKey resets all changes to the "api_key" field.
  45299. func (m *WxMutation) ResetAPIKey() {
  45300. m.api_key = nil
  45301. delete(m.clearedFields, wx.FieldAPIKey)
  45302. }
  45303. // SetAllowList sets the "allow_list" field.
  45304. func (m *WxMutation) SetAllowList(s []string) {
  45305. m.allow_list = &s
  45306. m.appendallow_list = nil
  45307. }
  45308. // AllowList returns the value of the "allow_list" field in the mutation.
  45309. func (m *WxMutation) AllowList() (r []string, exists bool) {
  45310. v := m.allow_list
  45311. if v == nil {
  45312. return
  45313. }
  45314. return *v, true
  45315. }
  45316. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  45317. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45319. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  45320. if !m.op.Is(OpUpdateOne) {
  45321. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  45322. }
  45323. if m.id == nil || m.oldValue == nil {
  45324. return v, errors.New("OldAllowList requires an ID field in the mutation")
  45325. }
  45326. oldValue, err := m.oldValue(ctx)
  45327. if err != nil {
  45328. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  45329. }
  45330. return oldValue.AllowList, nil
  45331. }
  45332. // AppendAllowList adds s to the "allow_list" field.
  45333. func (m *WxMutation) AppendAllowList(s []string) {
  45334. m.appendallow_list = append(m.appendallow_list, s...)
  45335. }
  45336. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  45337. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  45338. if len(m.appendallow_list) == 0 {
  45339. return nil, false
  45340. }
  45341. return m.appendallow_list, true
  45342. }
  45343. // ResetAllowList resets all changes to the "allow_list" field.
  45344. func (m *WxMutation) ResetAllowList() {
  45345. m.allow_list = nil
  45346. m.appendallow_list = nil
  45347. }
  45348. // SetGroupAllowList sets the "group_allow_list" field.
  45349. func (m *WxMutation) SetGroupAllowList(s []string) {
  45350. m.group_allow_list = &s
  45351. m.appendgroup_allow_list = nil
  45352. }
  45353. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  45354. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  45355. v := m.group_allow_list
  45356. if v == nil {
  45357. return
  45358. }
  45359. return *v, true
  45360. }
  45361. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  45362. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45364. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  45365. if !m.op.Is(OpUpdateOne) {
  45366. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  45367. }
  45368. if m.id == nil || m.oldValue == nil {
  45369. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  45370. }
  45371. oldValue, err := m.oldValue(ctx)
  45372. if err != nil {
  45373. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  45374. }
  45375. return oldValue.GroupAllowList, nil
  45376. }
  45377. // AppendGroupAllowList adds s to the "group_allow_list" field.
  45378. func (m *WxMutation) AppendGroupAllowList(s []string) {
  45379. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  45380. }
  45381. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  45382. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  45383. if len(m.appendgroup_allow_list) == 0 {
  45384. return nil, false
  45385. }
  45386. return m.appendgroup_allow_list, true
  45387. }
  45388. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  45389. func (m *WxMutation) ResetGroupAllowList() {
  45390. m.group_allow_list = nil
  45391. m.appendgroup_allow_list = nil
  45392. }
  45393. // SetBlockList sets the "block_list" field.
  45394. func (m *WxMutation) SetBlockList(s []string) {
  45395. m.block_list = &s
  45396. m.appendblock_list = nil
  45397. }
  45398. // BlockList returns the value of the "block_list" field in the mutation.
  45399. func (m *WxMutation) BlockList() (r []string, exists bool) {
  45400. v := m.block_list
  45401. if v == nil {
  45402. return
  45403. }
  45404. return *v, true
  45405. }
  45406. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  45407. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45409. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  45410. if !m.op.Is(OpUpdateOne) {
  45411. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  45412. }
  45413. if m.id == nil || m.oldValue == nil {
  45414. return v, errors.New("OldBlockList requires an ID field in the mutation")
  45415. }
  45416. oldValue, err := m.oldValue(ctx)
  45417. if err != nil {
  45418. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  45419. }
  45420. return oldValue.BlockList, nil
  45421. }
  45422. // AppendBlockList adds s to the "block_list" field.
  45423. func (m *WxMutation) AppendBlockList(s []string) {
  45424. m.appendblock_list = append(m.appendblock_list, s...)
  45425. }
  45426. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  45427. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  45428. if len(m.appendblock_list) == 0 {
  45429. return nil, false
  45430. }
  45431. return m.appendblock_list, true
  45432. }
  45433. // ResetBlockList resets all changes to the "block_list" field.
  45434. func (m *WxMutation) ResetBlockList() {
  45435. m.block_list = nil
  45436. m.appendblock_list = nil
  45437. }
  45438. // SetGroupBlockList sets the "group_block_list" field.
  45439. func (m *WxMutation) SetGroupBlockList(s []string) {
  45440. m.group_block_list = &s
  45441. m.appendgroup_block_list = nil
  45442. }
  45443. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  45444. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  45445. v := m.group_block_list
  45446. if v == nil {
  45447. return
  45448. }
  45449. return *v, true
  45450. }
  45451. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  45452. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45454. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  45455. if !m.op.Is(OpUpdateOne) {
  45456. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  45457. }
  45458. if m.id == nil || m.oldValue == nil {
  45459. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  45460. }
  45461. oldValue, err := m.oldValue(ctx)
  45462. if err != nil {
  45463. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  45464. }
  45465. return oldValue.GroupBlockList, nil
  45466. }
  45467. // AppendGroupBlockList adds s to the "group_block_list" field.
  45468. func (m *WxMutation) AppendGroupBlockList(s []string) {
  45469. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  45470. }
  45471. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  45472. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  45473. if len(m.appendgroup_block_list) == 0 {
  45474. return nil, false
  45475. }
  45476. return m.appendgroup_block_list, true
  45477. }
  45478. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  45479. func (m *WxMutation) ResetGroupBlockList() {
  45480. m.group_block_list = nil
  45481. m.appendgroup_block_list = nil
  45482. }
  45483. // SetCtype sets the "ctype" field.
  45484. func (m *WxMutation) SetCtype(u uint64) {
  45485. m.ctype = &u
  45486. m.addctype = nil
  45487. }
  45488. // Ctype returns the value of the "ctype" field in the mutation.
  45489. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  45490. v := m.ctype
  45491. if v == nil {
  45492. return
  45493. }
  45494. return *v, true
  45495. }
  45496. // OldCtype returns the old "ctype" field's value of the Wx entity.
  45497. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  45498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45499. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  45500. if !m.op.Is(OpUpdateOne) {
  45501. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  45502. }
  45503. if m.id == nil || m.oldValue == nil {
  45504. return v, errors.New("OldCtype requires an ID field in the mutation")
  45505. }
  45506. oldValue, err := m.oldValue(ctx)
  45507. if err != nil {
  45508. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  45509. }
  45510. return oldValue.Ctype, nil
  45511. }
  45512. // AddCtype adds u to the "ctype" field.
  45513. func (m *WxMutation) AddCtype(u int64) {
  45514. if m.addctype != nil {
  45515. *m.addctype += u
  45516. } else {
  45517. m.addctype = &u
  45518. }
  45519. }
  45520. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  45521. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  45522. v := m.addctype
  45523. if v == nil {
  45524. return
  45525. }
  45526. return *v, true
  45527. }
  45528. // ClearCtype clears the value of the "ctype" field.
  45529. func (m *WxMutation) ClearCtype() {
  45530. m.ctype = nil
  45531. m.addctype = nil
  45532. m.clearedFields[wx.FieldCtype] = struct{}{}
  45533. }
  45534. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  45535. func (m *WxMutation) CtypeCleared() bool {
  45536. _, ok := m.clearedFields[wx.FieldCtype]
  45537. return ok
  45538. }
  45539. // ResetCtype resets all changes to the "ctype" field.
  45540. func (m *WxMutation) ResetCtype() {
  45541. m.ctype = nil
  45542. m.addctype = nil
  45543. delete(m.clearedFields, wx.FieldCtype)
  45544. }
  45545. // ClearServer clears the "server" edge to the Server entity.
  45546. func (m *WxMutation) ClearServer() {
  45547. m.clearedserver = true
  45548. m.clearedFields[wx.FieldServerID] = struct{}{}
  45549. }
  45550. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  45551. func (m *WxMutation) ServerCleared() bool {
  45552. return m.ServerIDCleared() || m.clearedserver
  45553. }
  45554. // ServerIDs returns the "server" edge IDs in the mutation.
  45555. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45556. // ServerID instead. It exists only for internal usage by the builders.
  45557. func (m *WxMutation) ServerIDs() (ids []uint64) {
  45558. if id := m.server; id != nil {
  45559. ids = append(ids, *id)
  45560. }
  45561. return
  45562. }
  45563. // ResetServer resets all changes to the "server" edge.
  45564. func (m *WxMutation) ResetServer() {
  45565. m.server = nil
  45566. m.clearedserver = false
  45567. }
  45568. // ClearAgent clears the "agent" edge to the Agent entity.
  45569. func (m *WxMutation) ClearAgent() {
  45570. m.clearedagent = true
  45571. m.clearedFields[wx.FieldAgentID] = struct{}{}
  45572. }
  45573. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  45574. func (m *WxMutation) AgentCleared() bool {
  45575. return m.clearedagent
  45576. }
  45577. // AgentIDs returns the "agent" edge IDs in the mutation.
  45578. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45579. // AgentID instead. It exists only for internal usage by the builders.
  45580. func (m *WxMutation) AgentIDs() (ids []uint64) {
  45581. if id := m.agent; id != nil {
  45582. ids = append(ids, *id)
  45583. }
  45584. return
  45585. }
  45586. // ResetAgent resets all changes to the "agent" edge.
  45587. func (m *WxMutation) ResetAgent() {
  45588. m.agent = nil
  45589. m.clearedagent = false
  45590. }
  45591. // Where appends a list predicates to the WxMutation builder.
  45592. func (m *WxMutation) Where(ps ...predicate.Wx) {
  45593. m.predicates = append(m.predicates, ps...)
  45594. }
  45595. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  45596. // users can use type-assertion to append predicates that do not depend on any generated package.
  45597. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  45598. p := make([]predicate.Wx, len(ps))
  45599. for i := range ps {
  45600. p[i] = ps[i]
  45601. }
  45602. m.Where(p...)
  45603. }
  45604. // Op returns the operation name.
  45605. func (m *WxMutation) Op() Op {
  45606. return m.op
  45607. }
  45608. // SetOp allows setting the mutation operation.
  45609. func (m *WxMutation) SetOp(op Op) {
  45610. m.op = op
  45611. }
  45612. // Type returns the node type of this mutation (Wx).
  45613. func (m *WxMutation) Type() string {
  45614. return m.typ
  45615. }
  45616. // Fields returns all fields that were changed during this mutation. Note that in
  45617. // order to get all numeric fields that were incremented/decremented, call
  45618. // AddedFields().
  45619. func (m *WxMutation) Fields() []string {
  45620. fields := make([]string, 0, 22)
  45621. if m.created_at != nil {
  45622. fields = append(fields, wx.FieldCreatedAt)
  45623. }
  45624. if m.updated_at != nil {
  45625. fields = append(fields, wx.FieldUpdatedAt)
  45626. }
  45627. if m.status != nil {
  45628. fields = append(fields, wx.FieldStatus)
  45629. }
  45630. if m.deleted_at != nil {
  45631. fields = append(fields, wx.FieldDeletedAt)
  45632. }
  45633. if m.server != nil {
  45634. fields = append(fields, wx.FieldServerID)
  45635. }
  45636. if m.port != nil {
  45637. fields = append(fields, wx.FieldPort)
  45638. }
  45639. if m.process_id != nil {
  45640. fields = append(fields, wx.FieldProcessID)
  45641. }
  45642. if m.callback != nil {
  45643. fields = append(fields, wx.FieldCallback)
  45644. }
  45645. if m.wxid != nil {
  45646. fields = append(fields, wx.FieldWxid)
  45647. }
  45648. if m.account != nil {
  45649. fields = append(fields, wx.FieldAccount)
  45650. }
  45651. if m.nickname != nil {
  45652. fields = append(fields, wx.FieldNickname)
  45653. }
  45654. if m.tel != nil {
  45655. fields = append(fields, wx.FieldTel)
  45656. }
  45657. if m.head_big != nil {
  45658. fields = append(fields, wx.FieldHeadBig)
  45659. }
  45660. if m.organization_id != nil {
  45661. fields = append(fields, wx.FieldOrganizationID)
  45662. }
  45663. if m.agent != nil {
  45664. fields = append(fields, wx.FieldAgentID)
  45665. }
  45666. if m.api_base != nil {
  45667. fields = append(fields, wx.FieldAPIBase)
  45668. }
  45669. if m.api_key != nil {
  45670. fields = append(fields, wx.FieldAPIKey)
  45671. }
  45672. if m.allow_list != nil {
  45673. fields = append(fields, wx.FieldAllowList)
  45674. }
  45675. if m.group_allow_list != nil {
  45676. fields = append(fields, wx.FieldGroupAllowList)
  45677. }
  45678. if m.block_list != nil {
  45679. fields = append(fields, wx.FieldBlockList)
  45680. }
  45681. if m.group_block_list != nil {
  45682. fields = append(fields, wx.FieldGroupBlockList)
  45683. }
  45684. if m.ctype != nil {
  45685. fields = append(fields, wx.FieldCtype)
  45686. }
  45687. return fields
  45688. }
  45689. // Field returns the value of a field with the given name. The second boolean
  45690. // return value indicates that this field was not set, or was not defined in the
  45691. // schema.
  45692. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  45693. switch name {
  45694. case wx.FieldCreatedAt:
  45695. return m.CreatedAt()
  45696. case wx.FieldUpdatedAt:
  45697. return m.UpdatedAt()
  45698. case wx.FieldStatus:
  45699. return m.Status()
  45700. case wx.FieldDeletedAt:
  45701. return m.DeletedAt()
  45702. case wx.FieldServerID:
  45703. return m.ServerID()
  45704. case wx.FieldPort:
  45705. return m.Port()
  45706. case wx.FieldProcessID:
  45707. return m.ProcessID()
  45708. case wx.FieldCallback:
  45709. return m.Callback()
  45710. case wx.FieldWxid:
  45711. return m.Wxid()
  45712. case wx.FieldAccount:
  45713. return m.Account()
  45714. case wx.FieldNickname:
  45715. return m.Nickname()
  45716. case wx.FieldTel:
  45717. return m.Tel()
  45718. case wx.FieldHeadBig:
  45719. return m.HeadBig()
  45720. case wx.FieldOrganizationID:
  45721. return m.OrganizationID()
  45722. case wx.FieldAgentID:
  45723. return m.AgentID()
  45724. case wx.FieldAPIBase:
  45725. return m.APIBase()
  45726. case wx.FieldAPIKey:
  45727. return m.APIKey()
  45728. case wx.FieldAllowList:
  45729. return m.AllowList()
  45730. case wx.FieldGroupAllowList:
  45731. return m.GroupAllowList()
  45732. case wx.FieldBlockList:
  45733. return m.BlockList()
  45734. case wx.FieldGroupBlockList:
  45735. return m.GroupBlockList()
  45736. case wx.FieldCtype:
  45737. return m.Ctype()
  45738. }
  45739. return nil, false
  45740. }
  45741. // OldField returns the old value of the field from the database. An error is
  45742. // returned if the mutation operation is not UpdateOne, or the query to the
  45743. // database failed.
  45744. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45745. switch name {
  45746. case wx.FieldCreatedAt:
  45747. return m.OldCreatedAt(ctx)
  45748. case wx.FieldUpdatedAt:
  45749. return m.OldUpdatedAt(ctx)
  45750. case wx.FieldStatus:
  45751. return m.OldStatus(ctx)
  45752. case wx.FieldDeletedAt:
  45753. return m.OldDeletedAt(ctx)
  45754. case wx.FieldServerID:
  45755. return m.OldServerID(ctx)
  45756. case wx.FieldPort:
  45757. return m.OldPort(ctx)
  45758. case wx.FieldProcessID:
  45759. return m.OldProcessID(ctx)
  45760. case wx.FieldCallback:
  45761. return m.OldCallback(ctx)
  45762. case wx.FieldWxid:
  45763. return m.OldWxid(ctx)
  45764. case wx.FieldAccount:
  45765. return m.OldAccount(ctx)
  45766. case wx.FieldNickname:
  45767. return m.OldNickname(ctx)
  45768. case wx.FieldTel:
  45769. return m.OldTel(ctx)
  45770. case wx.FieldHeadBig:
  45771. return m.OldHeadBig(ctx)
  45772. case wx.FieldOrganizationID:
  45773. return m.OldOrganizationID(ctx)
  45774. case wx.FieldAgentID:
  45775. return m.OldAgentID(ctx)
  45776. case wx.FieldAPIBase:
  45777. return m.OldAPIBase(ctx)
  45778. case wx.FieldAPIKey:
  45779. return m.OldAPIKey(ctx)
  45780. case wx.FieldAllowList:
  45781. return m.OldAllowList(ctx)
  45782. case wx.FieldGroupAllowList:
  45783. return m.OldGroupAllowList(ctx)
  45784. case wx.FieldBlockList:
  45785. return m.OldBlockList(ctx)
  45786. case wx.FieldGroupBlockList:
  45787. return m.OldGroupBlockList(ctx)
  45788. case wx.FieldCtype:
  45789. return m.OldCtype(ctx)
  45790. }
  45791. return nil, fmt.Errorf("unknown Wx field %s", name)
  45792. }
  45793. // SetField sets the value of a field with the given name. It returns an error if
  45794. // the field is not defined in the schema, or if the type mismatched the field
  45795. // type.
  45796. func (m *WxMutation) SetField(name string, value ent.Value) error {
  45797. switch name {
  45798. case wx.FieldCreatedAt:
  45799. v, ok := value.(time.Time)
  45800. if !ok {
  45801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45802. }
  45803. m.SetCreatedAt(v)
  45804. return nil
  45805. case wx.FieldUpdatedAt:
  45806. v, ok := value.(time.Time)
  45807. if !ok {
  45808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45809. }
  45810. m.SetUpdatedAt(v)
  45811. return nil
  45812. case wx.FieldStatus:
  45813. v, ok := value.(uint8)
  45814. if !ok {
  45815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45816. }
  45817. m.SetStatus(v)
  45818. return nil
  45819. case wx.FieldDeletedAt:
  45820. v, ok := value.(time.Time)
  45821. if !ok {
  45822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45823. }
  45824. m.SetDeletedAt(v)
  45825. return nil
  45826. case wx.FieldServerID:
  45827. v, ok := value.(uint64)
  45828. if !ok {
  45829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45830. }
  45831. m.SetServerID(v)
  45832. return nil
  45833. case wx.FieldPort:
  45834. v, ok := value.(string)
  45835. if !ok {
  45836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45837. }
  45838. m.SetPort(v)
  45839. return nil
  45840. case wx.FieldProcessID:
  45841. v, ok := value.(string)
  45842. if !ok {
  45843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45844. }
  45845. m.SetProcessID(v)
  45846. return nil
  45847. case wx.FieldCallback:
  45848. v, ok := value.(string)
  45849. if !ok {
  45850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45851. }
  45852. m.SetCallback(v)
  45853. return nil
  45854. case wx.FieldWxid:
  45855. v, ok := value.(string)
  45856. if !ok {
  45857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45858. }
  45859. m.SetWxid(v)
  45860. return nil
  45861. case wx.FieldAccount:
  45862. v, ok := value.(string)
  45863. if !ok {
  45864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45865. }
  45866. m.SetAccount(v)
  45867. return nil
  45868. case wx.FieldNickname:
  45869. v, ok := value.(string)
  45870. if !ok {
  45871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45872. }
  45873. m.SetNickname(v)
  45874. return nil
  45875. case wx.FieldTel:
  45876. v, ok := value.(string)
  45877. if !ok {
  45878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45879. }
  45880. m.SetTel(v)
  45881. return nil
  45882. case wx.FieldHeadBig:
  45883. v, ok := value.(string)
  45884. if !ok {
  45885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45886. }
  45887. m.SetHeadBig(v)
  45888. return nil
  45889. case wx.FieldOrganizationID:
  45890. v, ok := value.(uint64)
  45891. if !ok {
  45892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45893. }
  45894. m.SetOrganizationID(v)
  45895. return nil
  45896. case wx.FieldAgentID:
  45897. v, ok := value.(uint64)
  45898. if !ok {
  45899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45900. }
  45901. m.SetAgentID(v)
  45902. return nil
  45903. case wx.FieldAPIBase:
  45904. v, ok := value.(string)
  45905. if !ok {
  45906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45907. }
  45908. m.SetAPIBase(v)
  45909. return nil
  45910. case wx.FieldAPIKey:
  45911. v, ok := value.(string)
  45912. if !ok {
  45913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45914. }
  45915. m.SetAPIKey(v)
  45916. return nil
  45917. case wx.FieldAllowList:
  45918. v, ok := value.([]string)
  45919. if !ok {
  45920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45921. }
  45922. m.SetAllowList(v)
  45923. return nil
  45924. case wx.FieldGroupAllowList:
  45925. v, ok := value.([]string)
  45926. if !ok {
  45927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45928. }
  45929. m.SetGroupAllowList(v)
  45930. return nil
  45931. case wx.FieldBlockList:
  45932. v, ok := value.([]string)
  45933. if !ok {
  45934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45935. }
  45936. m.SetBlockList(v)
  45937. return nil
  45938. case wx.FieldGroupBlockList:
  45939. v, ok := value.([]string)
  45940. if !ok {
  45941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45942. }
  45943. m.SetGroupBlockList(v)
  45944. return nil
  45945. case wx.FieldCtype:
  45946. v, ok := value.(uint64)
  45947. if !ok {
  45948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45949. }
  45950. m.SetCtype(v)
  45951. return nil
  45952. }
  45953. return fmt.Errorf("unknown Wx field %s", name)
  45954. }
  45955. // AddedFields returns all numeric fields that were incremented/decremented during
  45956. // this mutation.
  45957. func (m *WxMutation) AddedFields() []string {
  45958. var fields []string
  45959. if m.addstatus != nil {
  45960. fields = append(fields, wx.FieldStatus)
  45961. }
  45962. if m.addorganization_id != nil {
  45963. fields = append(fields, wx.FieldOrganizationID)
  45964. }
  45965. if m.addctype != nil {
  45966. fields = append(fields, wx.FieldCtype)
  45967. }
  45968. return fields
  45969. }
  45970. // AddedField returns the numeric value that was incremented/decremented on a field
  45971. // with the given name. The second boolean return value indicates that this field
  45972. // was not set, or was not defined in the schema.
  45973. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  45974. switch name {
  45975. case wx.FieldStatus:
  45976. return m.AddedStatus()
  45977. case wx.FieldOrganizationID:
  45978. return m.AddedOrganizationID()
  45979. case wx.FieldCtype:
  45980. return m.AddedCtype()
  45981. }
  45982. return nil, false
  45983. }
  45984. // AddField adds the value to the field with the given name. It returns an error if
  45985. // the field is not defined in the schema, or if the type mismatched the field
  45986. // type.
  45987. func (m *WxMutation) AddField(name string, value ent.Value) error {
  45988. switch name {
  45989. case wx.FieldStatus:
  45990. v, ok := value.(int8)
  45991. if !ok {
  45992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45993. }
  45994. m.AddStatus(v)
  45995. return nil
  45996. case wx.FieldOrganizationID:
  45997. v, ok := value.(int64)
  45998. if !ok {
  45999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46000. }
  46001. m.AddOrganizationID(v)
  46002. return nil
  46003. case wx.FieldCtype:
  46004. v, ok := value.(int64)
  46005. if !ok {
  46006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46007. }
  46008. m.AddCtype(v)
  46009. return nil
  46010. }
  46011. return fmt.Errorf("unknown Wx numeric field %s", name)
  46012. }
  46013. // ClearedFields returns all nullable fields that were cleared during this
  46014. // mutation.
  46015. func (m *WxMutation) ClearedFields() []string {
  46016. var fields []string
  46017. if m.FieldCleared(wx.FieldStatus) {
  46018. fields = append(fields, wx.FieldStatus)
  46019. }
  46020. if m.FieldCleared(wx.FieldDeletedAt) {
  46021. fields = append(fields, wx.FieldDeletedAt)
  46022. }
  46023. if m.FieldCleared(wx.FieldServerID) {
  46024. fields = append(fields, wx.FieldServerID)
  46025. }
  46026. if m.FieldCleared(wx.FieldOrganizationID) {
  46027. fields = append(fields, wx.FieldOrganizationID)
  46028. }
  46029. if m.FieldCleared(wx.FieldAPIBase) {
  46030. fields = append(fields, wx.FieldAPIBase)
  46031. }
  46032. if m.FieldCleared(wx.FieldAPIKey) {
  46033. fields = append(fields, wx.FieldAPIKey)
  46034. }
  46035. if m.FieldCleared(wx.FieldCtype) {
  46036. fields = append(fields, wx.FieldCtype)
  46037. }
  46038. return fields
  46039. }
  46040. // FieldCleared returns a boolean indicating if a field with the given name was
  46041. // cleared in this mutation.
  46042. func (m *WxMutation) FieldCleared(name string) bool {
  46043. _, ok := m.clearedFields[name]
  46044. return ok
  46045. }
  46046. // ClearField clears the value of the field with the given name. It returns an
  46047. // error if the field is not defined in the schema.
  46048. func (m *WxMutation) ClearField(name string) error {
  46049. switch name {
  46050. case wx.FieldStatus:
  46051. m.ClearStatus()
  46052. return nil
  46053. case wx.FieldDeletedAt:
  46054. m.ClearDeletedAt()
  46055. return nil
  46056. case wx.FieldServerID:
  46057. m.ClearServerID()
  46058. return nil
  46059. case wx.FieldOrganizationID:
  46060. m.ClearOrganizationID()
  46061. return nil
  46062. case wx.FieldAPIBase:
  46063. m.ClearAPIBase()
  46064. return nil
  46065. case wx.FieldAPIKey:
  46066. m.ClearAPIKey()
  46067. return nil
  46068. case wx.FieldCtype:
  46069. m.ClearCtype()
  46070. return nil
  46071. }
  46072. return fmt.Errorf("unknown Wx nullable field %s", name)
  46073. }
  46074. // ResetField resets all changes in the mutation for the field with the given name.
  46075. // It returns an error if the field is not defined in the schema.
  46076. func (m *WxMutation) ResetField(name string) error {
  46077. switch name {
  46078. case wx.FieldCreatedAt:
  46079. m.ResetCreatedAt()
  46080. return nil
  46081. case wx.FieldUpdatedAt:
  46082. m.ResetUpdatedAt()
  46083. return nil
  46084. case wx.FieldStatus:
  46085. m.ResetStatus()
  46086. return nil
  46087. case wx.FieldDeletedAt:
  46088. m.ResetDeletedAt()
  46089. return nil
  46090. case wx.FieldServerID:
  46091. m.ResetServerID()
  46092. return nil
  46093. case wx.FieldPort:
  46094. m.ResetPort()
  46095. return nil
  46096. case wx.FieldProcessID:
  46097. m.ResetProcessID()
  46098. return nil
  46099. case wx.FieldCallback:
  46100. m.ResetCallback()
  46101. return nil
  46102. case wx.FieldWxid:
  46103. m.ResetWxid()
  46104. return nil
  46105. case wx.FieldAccount:
  46106. m.ResetAccount()
  46107. return nil
  46108. case wx.FieldNickname:
  46109. m.ResetNickname()
  46110. return nil
  46111. case wx.FieldTel:
  46112. m.ResetTel()
  46113. return nil
  46114. case wx.FieldHeadBig:
  46115. m.ResetHeadBig()
  46116. return nil
  46117. case wx.FieldOrganizationID:
  46118. m.ResetOrganizationID()
  46119. return nil
  46120. case wx.FieldAgentID:
  46121. m.ResetAgentID()
  46122. return nil
  46123. case wx.FieldAPIBase:
  46124. m.ResetAPIBase()
  46125. return nil
  46126. case wx.FieldAPIKey:
  46127. m.ResetAPIKey()
  46128. return nil
  46129. case wx.FieldAllowList:
  46130. m.ResetAllowList()
  46131. return nil
  46132. case wx.FieldGroupAllowList:
  46133. m.ResetGroupAllowList()
  46134. return nil
  46135. case wx.FieldBlockList:
  46136. m.ResetBlockList()
  46137. return nil
  46138. case wx.FieldGroupBlockList:
  46139. m.ResetGroupBlockList()
  46140. return nil
  46141. case wx.FieldCtype:
  46142. m.ResetCtype()
  46143. return nil
  46144. }
  46145. return fmt.Errorf("unknown Wx field %s", name)
  46146. }
  46147. // AddedEdges returns all edge names that were set/added in this mutation.
  46148. func (m *WxMutation) AddedEdges() []string {
  46149. edges := make([]string, 0, 2)
  46150. if m.server != nil {
  46151. edges = append(edges, wx.EdgeServer)
  46152. }
  46153. if m.agent != nil {
  46154. edges = append(edges, wx.EdgeAgent)
  46155. }
  46156. return edges
  46157. }
  46158. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46159. // name in this mutation.
  46160. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  46161. switch name {
  46162. case wx.EdgeServer:
  46163. if id := m.server; id != nil {
  46164. return []ent.Value{*id}
  46165. }
  46166. case wx.EdgeAgent:
  46167. if id := m.agent; id != nil {
  46168. return []ent.Value{*id}
  46169. }
  46170. }
  46171. return nil
  46172. }
  46173. // RemovedEdges returns all edge names that were removed in this mutation.
  46174. func (m *WxMutation) RemovedEdges() []string {
  46175. edges := make([]string, 0, 2)
  46176. return edges
  46177. }
  46178. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46179. // the given name in this mutation.
  46180. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  46181. return nil
  46182. }
  46183. // ClearedEdges returns all edge names that were cleared in this mutation.
  46184. func (m *WxMutation) ClearedEdges() []string {
  46185. edges := make([]string, 0, 2)
  46186. if m.clearedserver {
  46187. edges = append(edges, wx.EdgeServer)
  46188. }
  46189. if m.clearedagent {
  46190. edges = append(edges, wx.EdgeAgent)
  46191. }
  46192. return edges
  46193. }
  46194. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46195. // was cleared in this mutation.
  46196. func (m *WxMutation) EdgeCleared(name string) bool {
  46197. switch name {
  46198. case wx.EdgeServer:
  46199. return m.clearedserver
  46200. case wx.EdgeAgent:
  46201. return m.clearedagent
  46202. }
  46203. return false
  46204. }
  46205. // ClearEdge clears the value of the edge with the given name. It returns an error
  46206. // if that edge is not defined in the schema.
  46207. func (m *WxMutation) ClearEdge(name string) error {
  46208. switch name {
  46209. case wx.EdgeServer:
  46210. m.ClearServer()
  46211. return nil
  46212. case wx.EdgeAgent:
  46213. m.ClearAgent()
  46214. return nil
  46215. }
  46216. return fmt.Errorf("unknown Wx unique edge %s", name)
  46217. }
  46218. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46219. // It returns an error if the edge is not defined in the schema.
  46220. func (m *WxMutation) ResetEdge(name string) error {
  46221. switch name {
  46222. case wx.EdgeServer:
  46223. m.ResetServer()
  46224. return nil
  46225. case wx.EdgeAgent:
  46226. m.ResetAgent()
  46227. return nil
  46228. }
  46229. return fmt.Errorf("unknown Wx edge %s", name)
  46230. }
  46231. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  46232. type WxCardMutation struct {
  46233. config
  46234. op Op
  46235. typ string
  46236. id *uint64
  46237. created_at *time.Time
  46238. updated_at *time.Time
  46239. deleted_at *time.Time
  46240. user_id *uint64
  46241. adduser_id *int64
  46242. wx_user_id *uint64
  46243. addwx_user_id *int64
  46244. avatar *string
  46245. logo *string
  46246. name *string
  46247. company *string
  46248. address *string
  46249. phone *string
  46250. official_account *string
  46251. wechat_account *string
  46252. email *string
  46253. api_base *string
  46254. api_key *string
  46255. ai_info *string
  46256. intro *string
  46257. clearedFields map[string]struct{}
  46258. done bool
  46259. oldValue func(context.Context) (*WxCard, error)
  46260. predicates []predicate.WxCard
  46261. }
  46262. var _ ent.Mutation = (*WxCardMutation)(nil)
  46263. // wxcardOption allows management of the mutation configuration using functional options.
  46264. type wxcardOption func(*WxCardMutation)
  46265. // newWxCardMutation creates new mutation for the WxCard entity.
  46266. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  46267. m := &WxCardMutation{
  46268. config: c,
  46269. op: op,
  46270. typ: TypeWxCard,
  46271. clearedFields: make(map[string]struct{}),
  46272. }
  46273. for _, opt := range opts {
  46274. opt(m)
  46275. }
  46276. return m
  46277. }
  46278. // withWxCardID sets the ID field of the mutation.
  46279. func withWxCardID(id uint64) wxcardOption {
  46280. return func(m *WxCardMutation) {
  46281. var (
  46282. err error
  46283. once sync.Once
  46284. value *WxCard
  46285. )
  46286. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  46287. once.Do(func() {
  46288. if m.done {
  46289. err = errors.New("querying old values post mutation is not allowed")
  46290. } else {
  46291. value, err = m.Client().WxCard.Get(ctx, id)
  46292. }
  46293. })
  46294. return value, err
  46295. }
  46296. m.id = &id
  46297. }
  46298. }
  46299. // withWxCard sets the old WxCard of the mutation.
  46300. func withWxCard(node *WxCard) wxcardOption {
  46301. return func(m *WxCardMutation) {
  46302. m.oldValue = func(context.Context) (*WxCard, error) {
  46303. return node, nil
  46304. }
  46305. m.id = &node.ID
  46306. }
  46307. }
  46308. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46309. // executed in a transaction (ent.Tx), a transactional client is returned.
  46310. func (m WxCardMutation) Client() *Client {
  46311. client := &Client{config: m.config}
  46312. client.init()
  46313. return client
  46314. }
  46315. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46316. // it returns an error otherwise.
  46317. func (m WxCardMutation) Tx() (*Tx, error) {
  46318. if _, ok := m.driver.(*txDriver); !ok {
  46319. return nil, errors.New("ent: mutation is not running in a transaction")
  46320. }
  46321. tx := &Tx{config: m.config}
  46322. tx.init()
  46323. return tx, nil
  46324. }
  46325. // SetID sets the value of the id field. Note that this
  46326. // operation is only accepted on creation of WxCard entities.
  46327. func (m *WxCardMutation) SetID(id uint64) {
  46328. m.id = &id
  46329. }
  46330. // ID returns the ID value in the mutation. Note that the ID is only available
  46331. // if it was provided to the builder or after it was returned from the database.
  46332. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  46333. if m.id == nil {
  46334. return
  46335. }
  46336. return *m.id, true
  46337. }
  46338. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46339. // That means, if the mutation is applied within a transaction with an isolation level such
  46340. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46341. // or updated by the mutation.
  46342. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  46343. switch {
  46344. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46345. id, exists := m.ID()
  46346. if exists {
  46347. return []uint64{id}, nil
  46348. }
  46349. fallthrough
  46350. case m.op.Is(OpUpdate | OpDelete):
  46351. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  46352. default:
  46353. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46354. }
  46355. }
  46356. // SetCreatedAt sets the "created_at" field.
  46357. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  46358. m.created_at = &t
  46359. }
  46360. // CreatedAt returns the value of the "created_at" field in the mutation.
  46361. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  46362. v := m.created_at
  46363. if v == nil {
  46364. return
  46365. }
  46366. return *v, true
  46367. }
  46368. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  46369. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46371. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46372. if !m.op.Is(OpUpdateOne) {
  46373. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46374. }
  46375. if m.id == nil || m.oldValue == nil {
  46376. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46377. }
  46378. oldValue, err := m.oldValue(ctx)
  46379. if err != nil {
  46380. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46381. }
  46382. return oldValue.CreatedAt, nil
  46383. }
  46384. // ResetCreatedAt resets all changes to the "created_at" field.
  46385. func (m *WxCardMutation) ResetCreatedAt() {
  46386. m.created_at = nil
  46387. }
  46388. // SetUpdatedAt sets the "updated_at" field.
  46389. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  46390. m.updated_at = &t
  46391. }
  46392. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46393. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  46394. v := m.updated_at
  46395. if v == nil {
  46396. return
  46397. }
  46398. return *v, true
  46399. }
  46400. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  46401. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46403. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46404. if !m.op.Is(OpUpdateOne) {
  46405. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46406. }
  46407. if m.id == nil || m.oldValue == nil {
  46408. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46409. }
  46410. oldValue, err := m.oldValue(ctx)
  46411. if err != nil {
  46412. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46413. }
  46414. return oldValue.UpdatedAt, nil
  46415. }
  46416. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46417. func (m *WxCardMutation) ResetUpdatedAt() {
  46418. m.updated_at = nil
  46419. }
  46420. // SetDeletedAt sets the "deleted_at" field.
  46421. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  46422. m.deleted_at = &t
  46423. }
  46424. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46425. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  46426. v := m.deleted_at
  46427. if v == nil {
  46428. return
  46429. }
  46430. return *v, true
  46431. }
  46432. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  46433. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46435. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46436. if !m.op.Is(OpUpdateOne) {
  46437. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46438. }
  46439. if m.id == nil || m.oldValue == nil {
  46440. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46441. }
  46442. oldValue, err := m.oldValue(ctx)
  46443. if err != nil {
  46444. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46445. }
  46446. return oldValue.DeletedAt, nil
  46447. }
  46448. // ClearDeletedAt clears the value of the "deleted_at" field.
  46449. func (m *WxCardMutation) ClearDeletedAt() {
  46450. m.deleted_at = nil
  46451. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  46452. }
  46453. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46454. func (m *WxCardMutation) DeletedAtCleared() bool {
  46455. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  46456. return ok
  46457. }
  46458. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46459. func (m *WxCardMutation) ResetDeletedAt() {
  46460. m.deleted_at = nil
  46461. delete(m.clearedFields, wxcard.FieldDeletedAt)
  46462. }
  46463. // SetUserID sets the "user_id" field.
  46464. func (m *WxCardMutation) SetUserID(u uint64) {
  46465. m.user_id = &u
  46466. m.adduser_id = nil
  46467. }
  46468. // UserID returns the value of the "user_id" field in the mutation.
  46469. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  46470. v := m.user_id
  46471. if v == nil {
  46472. return
  46473. }
  46474. return *v, true
  46475. }
  46476. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  46477. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46479. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  46480. if !m.op.Is(OpUpdateOne) {
  46481. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  46482. }
  46483. if m.id == nil || m.oldValue == nil {
  46484. return v, errors.New("OldUserID requires an ID field in the mutation")
  46485. }
  46486. oldValue, err := m.oldValue(ctx)
  46487. if err != nil {
  46488. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  46489. }
  46490. return oldValue.UserID, nil
  46491. }
  46492. // AddUserID adds u to the "user_id" field.
  46493. func (m *WxCardMutation) AddUserID(u int64) {
  46494. if m.adduser_id != nil {
  46495. *m.adduser_id += u
  46496. } else {
  46497. m.adduser_id = &u
  46498. }
  46499. }
  46500. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  46501. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  46502. v := m.adduser_id
  46503. if v == nil {
  46504. return
  46505. }
  46506. return *v, true
  46507. }
  46508. // ClearUserID clears the value of the "user_id" field.
  46509. func (m *WxCardMutation) ClearUserID() {
  46510. m.user_id = nil
  46511. m.adduser_id = nil
  46512. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  46513. }
  46514. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  46515. func (m *WxCardMutation) UserIDCleared() bool {
  46516. _, ok := m.clearedFields[wxcard.FieldUserID]
  46517. return ok
  46518. }
  46519. // ResetUserID resets all changes to the "user_id" field.
  46520. func (m *WxCardMutation) ResetUserID() {
  46521. m.user_id = nil
  46522. m.adduser_id = nil
  46523. delete(m.clearedFields, wxcard.FieldUserID)
  46524. }
  46525. // SetWxUserID sets the "wx_user_id" field.
  46526. func (m *WxCardMutation) SetWxUserID(u uint64) {
  46527. m.wx_user_id = &u
  46528. m.addwx_user_id = nil
  46529. }
  46530. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  46531. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  46532. v := m.wx_user_id
  46533. if v == nil {
  46534. return
  46535. }
  46536. return *v, true
  46537. }
  46538. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  46539. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46541. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  46542. if !m.op.Is(OpUpdateOne) {
  46543. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  46544. }
  46545. if m.id == nil || m.oldValue == nil {
  46546. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  46547. }
  46548. oldValue, err := m.oldValue(ctx)
  46549. if err != nil {
  46550. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  46551. }
  46552. return oldValue.WxUserID, nil
  46553. }
  46554. // AddWxUserID adds u to the "wx_user_id" field.
  46555. func (m *WxCardMutation) AddWxUserID(u int64) {
  46556. if m.addwx_user_id != nil {
  46557. *m.addwx_user_id += u
  46558. } else {
  46559. m.addwx_user_id = &u
  46560. }
  46561. }
  46562. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  46563. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  46564. v := m.addwx_user_id
  46565. if v == nil {
  46566. return
  46567. }
  46568. return *v, true
  46569. }
  46570. // ClearWxUserID clears the value of the "wx_user_id" field.
  46571. func (m *WxCardMutation) ClearWxUserID() {
  46572. m.wx_user_id = nil
  46573. m.addwx_user_id = nil
  46574. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  46575. }
  46576. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  46577. func (m *WxCardMutation) WxUserIDCleared() bool {
  46578. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  46579. return ok
  46580. }
  46581. // ResetWxUserID resets all changes to the "wx_user_id" field.
  46582. func (m *WxCardMutation) ResetWxUserID() {
  46583. m.wx_user_id = nil
  46584. m.addwx_user_id = nil
  46585. delete(m.clearedFields, wxcard.FieldWxUserID)
  46586. }
  46587. // SetAvatar sets the "avatar" field.
  46588. func (m *WxCardMutation) SetAvatar(s string) {
  46589. m.avatar = &s
  46590. }
  46591. // Avatar returns the value of the "avatar" field in the mutation.
  46592. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  46593. v := m.avatar
  46594. if v == nil {
  46595. return
  46596. }
  46597. return *v, true
  46598. }
  46599. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  46600. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46602. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46603. if !m.op.Is(OpUpdateOne) {
  46604. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46605. }
  46606. if m.id == nil || m.oldValue == nil {
  46607. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46608. }
  46609. oldValue, err := m.oldValue(ctx)
  46610. if err != nil {
  46611. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46612. }
  46613. return oldValue.Avatar, nil
  46614. }
  46615. // ResetAvatar resets all changes to the "avatar" field.
  46616. func (m *WxCardMutation) ResetAvatar() {
  46617. m.avatar = nil
  46618. }
  46619. // SetLogo sets the "logo" field.
  46620. func (m *WxCardMutation) SetLogo(s string) {
  46621. m.logo = &s
  46622. }
  46623. // Logo returns the value of the "logo" field in the mutation.
  46624. func (m *WxCardMutation) Logo() (r string, exists bool) {
  46625. v := m.logo
  46626. if v == nil {
  46627. return
  46628. }
  46629. return *v, true
  46630. }
  46631. // OldLogo returns the old "logo" field's value of the WxCard entity.
  46632. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46634. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  46635. if !m.op.Is(OpUpdateOne) {
  46636. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  46637. }
  46638. if m.id == nil || m.oldValue == nil {
  46639. return v, errors.New("OldLogo requires an ID field in the mutation")
  46640. }
  46641. oldValue, err := m.oldValue(ctx)
  46642. if err != nil {
  46643. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  46644. }
  46645. return oldValue.Logo, nil
  46646. }
  46647. // ResetLogo resets all changes to the "logo" field.
  46648. func (m *WxCardMutation) ResetLogo() {
  46649. m.logo = nil
  46650. }
  46651. // SetName sets the "name" field.
  46652. func (m *WxCardMutation) SetName(s string) {
  46653. m.name = &s
  46654. }
  46655. // Name returns the value of the "name" field in the mutation.
  46656. func (m *WxCardMutation) Name() (r string, exists bool) {
  46657. v := m.name
  46658. if v == nil {
  46659. return
  46660. }
  46661. return *v, true
  46662. }
  46663. // OldName returns the old "name" field's value of the WxCard entity.
  46664. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46666. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  46667. if !m.op.Is(OpUpdateOne) {
  46668. return v, errors.New("OldName is only allowed on UpdateOne operations")
  46669. }
  46670. if m.id == nil || m.oldValue == nil {
  46671. return v, errors.New("OldName requires an ID field in the mutation")
  46672. }
  46673. oldValue, err := m.oldValue(ctx)
  46674. if err != nil {
  46675. return v, fmt.Errorf("querying old value for OldName: %w", err)
  46676. }
  46677. return oldValue.Name, nil
  46678. }
  46679. // ResetName resets all changes to the "name" field.
  46680. func (m *WxCardMutation) ResetName() {
  46681. m.name = nil
  46682. }
  46683. // SetCompany sets the "company" field.
  46684. func (m *WxCardMutation) SetCompany(s string) {
  46685. m.company = &s
  46686. }
  46687. // Company returns the value of the "company" field in the mutation.
  46688. func (m *WxCardMutation) Company() (r string, exists bool) {
  46689. v := m.company
  46690. if v == nil {
  46691. return
  46692. }
  46693. return *v, true
  46694. }
  46695. // OldCompany returns the old "company" field's value of the WxCard entity.
  46696. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46698. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  46699. if !m.op.Is(OpUpdateOne) {
  46700. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  46701. }
  46702. if m.id == nil || m.oldValue == nil {
  46703. return v, errors.New("OldCompany requires an ID field in the mutation")
  46704. }
  46705. oldValue, err := m.oldValue(ctx)
  46706. if err != nil {
  46707. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  46708. }
  46709. return oldValue.Company, nil
  46710. }
  46711. // ResetCompany resets all changes to the "company" field.
  46712. func (m *WxCardMutation) ResetCompany() {
  46713. m.company = nil
  46714. }
  46715. // SetAddress sets the "address" field.
  46716. func (m *WxCardMutation) SetAddress(s string) {
  46717. m.address = &s
  46718. }
  46719. // Address returns the value of the "address" field in the mutation.
  46720. func (m *WxCardMutation) Address() (r string, exists bool) {
  46721. v := m.address
  46722. if v == nil {
  46723. return
  46724. }
  46725. return *v, true
  46726. }
  46727. // OldAddress returns the old "address" field's value of the WxCard entity.
  46728. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46730. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  46731. if !m.op.Is(OpUpdateOne) {
  46732. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  46733. }
  46734. if m.id == nil || m.oldValue == nil {
  46735. return v, errors.New("OldAddress requires an ID field in the mutation")
  46736. }
  46737. oldValue, err := m.oldValue(ctx)
  46738. if err != nil {
  46739. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  46740. }
  46741. return oldValue.Address, nil
  46742. }
  46743. // ResetAddress resets all changes to the "address" field.
  46744. func (m *WxCardMutation) ResetAddress() {
  46745. m.address = nil
  46746. }
  46747. // SetPhone sets the "phone" field.
  46748. func (m *WxCardMutation) SetPhone(s string) {
  46749. m.phone = &s
  46750. }
  46751. // Phone returns the value of the "phone" field in the mutation.
  46752. func (m *WxCardMutation) Phone() (r string, exists bool) {
  46753. v := m.phone
  46754. if v == nil {
  46755. return
  46756. }
  46757. return *v, true
  46758. }
  46759. // OldPhone returns the old "phone" field's value of the WxCard entity.
  46760. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46761. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46762. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  46763. if !m.op.Is(OpUpdateOne) {
  46764. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  46765. }
  46766. if m.id == nil || m.oldValue == nil {
  46767. return v, errors.New("OldPhone requires an ID field in the mutation")
  46768. }
  46769. oldValue, err := m.oldValue(ctx)
  46770. if err != nil {
  46771. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  46772. }
  46773. return oldValue.Phone, nil
  46774. }
  46775. // ResetPhone resets all changes to the "phone" field.
  46776. func (m *WxCardMutation) ResetPhone() {
  46777. m.phone = nil
  46778. }
  46779. // SetOfficialAccount sets the "official_account" field.
  46780. func (m *WxCardMutation) SetOfficialAccount(s string) {
  46781. m.official_account = &s
  46782. }
  46783. // OfficialAccount returns the value of the "official_account" field in the mutation.
  46784. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  46785. v := m.official_account
  46786. if v == nil {
  46787. return
  46788. }
  46789. return *v, true
  46790. }
  46791. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  46792. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46794. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  46795. if !m.op.Is(OpUpdateOne) {
  46796. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  46797. }
  46798. if m.id == nil || m.oldValue == nil {
  46799. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  46800. }
  46801. oldValue, err := m.oldValue(ctx)
  46802. if err != nil {
  46803. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  46804. }
  46805. return oldValue.OfficialAccount, nil
  46806. }
  46807. // ResetOfficialAccount resets all changes to the "official_account" field.
  46808. func (m *WxCardMutation) ResetOfficialAccount() {
  46809. m.official_account = nil
  46810. }
  46811. // SetWechatAccount sets the "wechat_account" field.
  46812. func (m *WxCardMutation) SetWechatAccount(s string) {
  46813. m.wechat_account = &s
  46814. }
  46815. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  46816. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  46817. v := m.wechat_account
  46818. if v == nil {
  46819. return
  46820. }
  46821. return *v, true
  46822. }
  46823. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  46824. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46826. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  46827. if !m.op.Is(OpUpdateOne) {
  46828. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  46829. }
  46830. if m.id == nil || m.oldValue == nil {
  46831. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  46832. }
  46833. oldValue, err := m.oldValue(ctx)
  46834. if err != nil {
  46835. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  46836. }
  46837. return oldValue.WechatAccount, nil
  46838. }
  46839. // ResetWechatAccount resets all changes to the "wechat_account" field.
  46840. func (m *WxCardMutation) ResetWechatAccount() {
  46841. m.wechat_account = nil
  46842. }
  46843. // SetEmail sets the "email" field.
  46844. func (m *WxCardMutation) SetEmail(s string) {
  46845. m.email = &s
  46846. }
  46847. // Email returns the value of the "email" field in the mutation.
  46848. func (m *WxCardMutation) Email() (r string, exists bool) {
  46849. v := m.email
  46850. if v == nil {
  46851. return
  46852. }
  46853. return *v, true
  46854. }
  46855. // OldEmail returns the old "email" field's value of the WxCard entity.
  46856. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46858. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  46859. if !m.op.Is(OpUpdateOne) {
  46860. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  46861. }
  46862. if m.id == nil || m.oldValue == nil {
  46863. return v, errors.New("OldEmail requires an ID field in the mutation")
  46864. }
  46865. oldValue, err := m.oldValue(ctx)
  46866. if err != nil {
  46867. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  46868. }
  46869. return oldValue.Email, nil
  46870. }
  46871. // ClearEmail clears the value of the "email" field.
  46872. func (m *WxCardMutation) ClearEmail() {
  46873. m.email = nil
  46874. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  46875. }
  46876. // EmailCleared returns if the "email" field was cleared in this mutation.
  46877. func (m *WxCardMutation) EmailCleared() bool {
  46878. _, ok := m.clearedFields[wxcard.FieldEmail]
  46879. return ok
  46880. }
  46881. // ResetEmail resets all changes to the "email" field.
  46882. func (m *WxCardMutation) ResetEmail() {
  46883. m.email = nil
  46884. delete(m.clearedFields, wxcard.FieldEmail)
  46885. }
  46886. // SetAPIBase sets the "api_base" field.
  46887. func (m *WxCardMutation) SetAPIBase(s string) {
  46888. m.api_base = &s
  46889. }
  46890. // APIBase returns the value of the "api_base" field in the mutation.
  46891. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  46892. v := m.api_base
  46893. if v == nil {
  46894. return
  46895. }
  46896. return *v, true
  46897. }
  46898. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  46899. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46901. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  46902. if !m.op.Is(OpUpdateOne) {
  46903. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  46904. }
  46905. if m.id == nil || m.oldValue == nil {
  46906. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  46907. }
  46908. oldValue, err := m.oldValue(ctx)
  46909. if err != nil {
  46910. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  46911. }
  46912. return oldValue.APIBase, nil
  46913. }
  46914. // ClearAPIBase clears the value of the "api_base" field.
  46915. func (m *WxCardMutation) ClearAPIBase() {
  46916. m.api_base = nil
  46917. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  46918. }
  46919. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  46920. func (m *WxCardMutation) APIBaseCleared() bool {
  46921. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  46922. return ok
  46923. }
  46924. // ResetAPIBase resets all changes to the "api_base" field.
  46925. func (m *WxCardMutation) ResetAPIBase() {
  46926. m.api_base = nil
  46927. delete(m.clearedFields, wxcard.FieldAPIBase)
  46928. }
  46929. // SetAPIKey sets the "api_key" field.
  46930. func (m *WxCardMutation) SetAPIKey(s string) {
  46931. m.api_key = &s
  46932. }
  46933. // APIKey returns the value of the "api_key" field in the mutation.
  46934. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  46935. v := m.api_key
  46936. if v == nil {
  46937. return
  46938. }
  46939. return *v, true
  46940. }
  46941. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  46942. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46944. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  46945. if !m.op.Is(OpUpdateOne) {
  46946. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  46947. }
  46948. if m.id == nil || m.oldValue == nil {
  46949. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  46950. }
  46951. oldValue, err := m.oldValue(ctx)
  46952. if err != nil {
  46953. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  46954. }
  46955. return oldValue.APIKey, nil
  46956. }
  46957. // ClearAPIKey clears the value of the "api_key" field.
  46958. func (m *WxCardMutation) ClearAPIKey() {
  46959. m.api_key = nil
  46960. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  46961. }
  46962. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  46963. func (m *WxCardMutation) APIKeyCleared() bool {
  46964. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  46965. return ok
  46966. }
  46967. // ResetAPIKey resets all changes to the "api_key" field.
  46968. func (m *WxCardMutation) ResetAPIKey() {
  46969. m.api_key = nil
  46970. delete(m.clearedFields, wxcard.FieldAPIKey)
  46971. }
  46972. // SetAiInfo sets the "ai_info" field.
  46973. func (m *WxCardMutation) SetAiInfo(s string) {
  46974. m.ai_info = &s
  46975. }
  46976. // AiInfo returns the value of the "ai_info" field in the mutation.
  46977. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  46978. v := m.ai_info
  46979. if v == nil {
  46980. return
  46981. }
  46982. return *v, true
  46983. }
  46984. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  46985. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  46986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46987. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  46988. if !m.op.Is(OpUpdateOne) {
  46989. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  46990. }
  46991. if m.id == nil || m.oldValue == nil {
  46992. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  46993. }
  46994. oldValue, err := m.oldValue(ctx)
  46995. if err != nil {
  46996. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  46997. }
  46998. return oldValue.AiInfo, nil
  46999. }
  47000. // ClearAiInfo clears the value of the "ai_info" field.
  47001. func (m *WxCardMutation) ClearAiInfo() {
  47002. m.ai_info = nil
  47003. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  47004. }
  47005. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  47006. func (m *WxCardMutation) AiInfoCleared() bool {
  47007. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  47008. return ok
  47009. }
  47010. // ResetAiInfo resets all changes to the "ai_info" field.
  47011. func (m *WxCardMutation) ResetAiInfo() {
  47012. m.ai_info = nil
  47013. delete(m.clearedFields, wxcard.FieldAiInfo)
  47014. }
  47015. // SetIntro sets the "intro" field.
  47016. func (m *WxCardMutation) SetIntro(s string) {
  47017. m.intro = &s
  47018. }
  47019. // Intro returns the value of the "intro" field in the mutation.
  47020. func (m *WxCardMutation) Intro() (r string, exists bool) {
  47021. v := m.intro
  47022. if v == nil {
  47023. return
  47024. }
  47025. return *v, true
  47026. }
  47027. // OldIntro returns the old "intro" field's value of the WxCard entity.
  47028. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  47029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47030. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  47031. if !m.op.Is(OpUpdateOne) {
  47032. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  47033. }
  47034. if m.id == nil || m.oldValue == nil {
  47035. return v, errors.New("OldIntro requires an ID field in the mutation")
  47036. }
  47037. oldValue, err := m.oldValue(ctx)
  47038. if err != nil {
  47039. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  47040. }
  47041. return oldValue.Intro, nil
  47042. }
  47043. // ClearIntro clears the value of the "intro" field.
  47044. func (m *WxCardMutation) ClearIntro() {
  47045. m.intro = nil
  47046. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  47047. }
  47048. // IntroCleared returns if the "intro" field was cleared in this mutation.
  47049. func (m *WxCardMutation) IntroCleared() bool {
  47050. _, ok := m.clearedFields[wxcard.FieldIntro]
  47051. return ok
  47052. }
  47053. // ResetIntro resets all changes to the "intro" field.
  47054. func (m *WxCardMutation) ResetIntro() {
  47055. m.intro = nil
  47056. delete(m.clearedFields, wxcard.FieldIntro)
  47057. }
  47058. // Where appends a list predicates to the WxCardMutation builder.
  47059. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  47060. m.predicates = append(m.predicates, ps...)
  47061. }
  47062. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  47063. // users can use type-assertion to append predicates that do not depend on any generated package.
  47064. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  47065. p := make([]predicate.WxCard, len(ps))
  47066. for i := range ps {
  47067. p[i] = ps[i]
  47068. }
  47069. m.Where(p...)
  47070. }
  47071. // Op returns the operation name.
  47072. func (m *WxCardMutation) Op() Op {
  47073. return m.op
  47074. }
  47075. // SetOp allows setting the mutation operation.
  47076. func (m *WxCardMutation) SetOp(op Op) {
  47077. m.op = op
  47078. }
  47079. // Type returns the node type of this mutation (WxCard).
  47080. func (m *WxCardMutation) Type() string {
  47081. return m.typ
  47082. }
  47083. // Fields returns all fields that were changed during this mutation. Note that in
  47084. // order to get all numeric fields that were incremented/decremented, call
  47085. // AddedFields().
  47086. func (m *WxCardMutation) Fields() []string {
  47087. fields := make([]string, 0, 18)
  47088. if m.created_at != nil {
  47089. fields = append(fields, wxcard.FieldCreatedAt)
  47090. }
  47091. if m.updated_at != nil {
  47092. fields = append(fields, wxcard.FieldUpdatedAt)
  47093. }
  47094. if m.deleted_at != nil {
  47095. fields = append(fields, wxcard.FieldDeletedAt)
  47096. }
  47097. if m.user_id != nil {
  47098. fields = append(fields, wxcard.FieldUserID)
  47099. }
  47100. if m.wx_user_id != nil {
  47101. fields = append(fields, wxcard.FieldWxUserID)
  47102. }
  47103. if m.avatar != nil {
  47104. fields = append(fields, wxcard.FieldAvatar)
  47105. }
  47106. if m.logo != nil {
  47107. fields = append(fields, wxcard.FieldLogo)
  47108. }
  47109. if m.name != nil {
  47110. fields = append(fields, wxcard.FieldName)
  47111. }
  47112. if m.company != nil {
  47113. fields = append(fields, wxcard.FieldCompany)
  47114. }
  47115. if m.address != nil {
  47116. fields = append(fields, wxcard.FieldAddress)
  47117. }
  47118. if m.phone != nil {
  47119. fields = append(fields, wxcard.FieldPhone)
  47120. }
  47121. if m.official_account != nil {
  47122. fields = append(fields, wxcard.FieldOfficialAccount)
  47123. }
  47124. if m.wechat_account != nil {
  47125. fields = append(fields, wxcard.FieldWechatAccount)
  47126. }
  47127. if m.email != nil {
  47128. fields = append(fields, wxcard.FieldEmail)
  47129. }
  47130. if m.api_base != nil {
  47131. fields = append(fields, wxcard.FieldAPIBase)
  47132. }
  47133. if m.api_key != nil {
  47134. fields = append(fields, wxcard.FieldAPIKey)
  47135. }
  47136. if m.ai_info != nil {
  47137. fields = append(fields, wxcard.FieldAiInfo)
  47138. }
  47139. if m.intro != nil {
  47140. fields = append(fields, wxcard.FieldIntro)
  47141. }
  47142. return fields
  47143. }
  47144. // Field returns the value of a field with the given name. The second boolean
  47145. // return value indicates that this field was not set, or was not defined in the
  47146. // schema.
  47147. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  47148. switch name {
  47149. case wxcard.FieldCreatedAt:
  47150. return m.CreatedAt()
  47151. case wxcard.FieldUpdatedAt:
  47152. return m.UpdatedAt()
  47153. case wxcard.FieldDeletedAt:
  47154. return m.DeletedAt()
  47155. case wxcard.FieldUserID:
  47156. return m.UserID()
  47157. case wxcard.FieldWxUserID:
  47158. return m.WxUserID()
  47159. case wxcard.FieldAvatar:
  47160. return m.Avatar()
  47161. case wxcard.FieldLogo:
  47162. return m.Logo()
  47163. case wxcard.FieldName:
  47164. return m.Name()
  47165. case wxcard.FieldCompany:
  47166. return m.Company()
  47167. case wxcard.FieldAddress:
  47168. return m.Address()
  47169. case wxcard.FieldPhone:
  47170. return m.Phone()
  47171. case wxcard.FieldOfficialAccount:
  47172. return m.OfficialAccount()
  47173. case wxcard.FieldWechatAccount:
  47174. return m.WechatAccount()
  47175. case wxcard.FieldEmail:
  47176. return m.Email()
  47177. case wxcard.FieldAPIBase:
  47178. return m.APIBase()
  47179. case wxcard.FieldAPIKey:
  47180. return m.APIKey()
  47181. case wxcard.FieldAiInfo:
  47182. return m.AiInfo()
  47183. case wxcard.FieldIntro:
  47184. return m.Intro()
  47185. }
  47186. return nil, false
  47187. }
  47188. // OldField returns the old value of the field from the database. An error is
  47189. // returned if the mutation operation is not UpdateOne, or the query to the
  47190. // database failed.
  47191. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  47192. switch name {
  47193. case wxcard.FieldCreatedAt:
  47194. return m.OldCreatedAt(ctx)
  47195. case wxcard.FieldUpdatedAt:
  47196. return m.OldUpdatedAt(ctx)
  47197. case wxcard.FieldDeletedAt:
  47198. return m.OldDeletedAt(ctx)
  47199. case wxcard.FieldUserID:
  47200. return m.OldUserID(ctx)
  47201. case wxcard.FieldWxUserID:
  47202. return m.OldWxUserID(ctx)
  47203. case wxcard.FieldAvatar:
  47204. return m.OldAvatar(ctx)
  47205. case wxcard.FieldLogo:
  47206. return m.OldLogo(ctx)
  47207. case wxcard.FieldName:
  47208. return m.OldName(ctx)
  47209. case wxcard.FieldCompany:
  47210. return m.OldCompany(ctx)
  47211. case wxcard.FieldAddress:
  47212. return m.OldAddress(ctx)
  47213. case wxcard.FieldPhone:
  47214. return m.OldPhone(ctx)
  47215. case wxcard.FieldOfficialAccount:
  47216. return m.OldOfficialAccount(ctx)
  47217. case wxcard.FieldWechatAccount:
  47218. return m.OldWechatAccount(ctx)
  47219. case wxcard.FieldEmail:
  47220. return m.OldEmail(ctx)
  47221. case wxcard.FieldAPIBase:
  47222. return m.OldAPIBase(ctx)
  47223. case wxcard.FieldAPIKey:
  47224. return m.OldAPIKey(ctx)
  47225. case wxcard.FieldAiInfo:
  47226. return m.OldAiInfo(ctx)
  47227. case wxcard.FieldIntro:
  47228. return m.OldIntro(ctx)
  47229. }
  47230. return nil, fmt.Errorf("unknown WxCard field %s", name)
  47231. }
  47232. // SetField sets the value of a field with the given name. It returns an error if
  47233. // the field is not defined in the schema, or if the type mismatched the field
  47234. // type.
  47235. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  47236. switch name {
  47237. case wxcard.FieldCreatedAt:
  47238. v, ok := value.(time.Time)
  47239. if !ok {
  47240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47241. }
  47242. m.SetCreatedAt(v)
  47243. return nil
  47244. case wxcard.FieldUpdatedAt:
  47245. v, ok := value.(time.Time)
  47246. if !ok {
  47247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47248. }
  47249. m.SetUpdatedAt(v)
  47250. return nil
  47251. case wxcard.FieldDeletedAt:
  47252. v, ok := value.(time.Time)
  47253. if !ok {
  47254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47255. }
  47256. m.SetDeletedAt(v)
  47257. return nil
  47258. case wxcard.FieldUserID:
  47259. v, ok := value.(uint64)
  47260. if !ok {
  47261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47262. }
  47263. m.SetUserID(v)
  47264. return nil
  47265. case wxcard.FieldWxUserID:
  47266. v, ok := value.(uint64)
  47267. if !ok {
  47268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47269. }
  47270. m.SetWxUserID(v)
  47271. return nil
  47272. case wxcard.FieldAvatar:
  47273. v, ok := value.(string)
  47274. if !ok {
  47275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47276. }
  47277. m.SetAvatar(v)
  47278. return nil
  47279. case wxcard.FieldLogo:
  47280. v, ok := value.(string)
  47281. if !ok {
  47282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47283. }
  47284. m.SetLogo(v)
  47285. return nil
  47286. case wxcard.FieldName:
  47287. v, ok := value.(string)
  47288. if !ok {
  47289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47290. }
  47291. m.SetName(v)
  47292. return nil
  47293. case wxcard.FieldCompany:
  47294. v, ok := value.(string)
  47295. if !ok {
  47296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47297. }
  47298. m.SetCompany(v)
  47299. return nil
  47300. case wxcard.FieldAddress:
  47301. v, ok := value.(string)
  47302. if !ok {
  47303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47304. }
  47305. m.SetAddress(v)
  47306. return nil
  47307. case wxcard.FieldPhone:
  47308. v, ok := value.(string)
  47309. if !ok {
  47310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47311. }
  47312. m.SetPhone(v)
  47313. return nil
  47314. case wxcard.FieldOfficialAccount:
  47315. v, ok := value.(string)
  47316. if !ok {
  47317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47318. }
  47319. m.SetOfficialAccount(v)
  47320. return nil
  47321. case wxcard.FieldWechatAccount:
  47322. v, ok := value.(string)
  47323. if !ok {
  47324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47325. }
  47326. m.SetWechatAccount(v)
  47327. return nil
  47328. case wxcard.FieldEmail:
  47329. v, ok := value.(string)
  47330. if !ok {
  47331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47332. }
  47333. m.SetEmail(v)
  47334. return nil
  47335. case wxcard.FieldAPIBase:
  47336. v, ok := value.(string)
  47337. if !ok {
  47338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47339. }
  47340. m.SetAPIBase(v)
  47341. return nil
  47342. case wxcard.FieldAPIKey:
  47343. v, ok := value.(string)
  47344. if !ok {
  47345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47346. }
  47347. m.SetAPIKey(v)
  47348. return nil
  47349. case wxcard.FieldAiInfo:
  47350. v, ok := value.(string)
  47351. if !ok {
  47352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47353. }
  47354. m.SetAiInfo(v)
  47355. return nil
  47356. case wxcard.FieldIntro:
  47357. v, ok := value.(string)
  47358. if !ok {
  47359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47360. }
  47361. m.SetIntro(v)
  47362. return nil
  47363. }
  47364. return fmt.Errorf("unknown WxCard field %s", name)
  47365. }
  47366. // AddedFields returns all numeric fields that were incremented/decremented during
  47367. // this mutation.
  47368. func (m *WxCardMutation) AddedFields() []string {
  47369. var fields []string
  47370. if m.adduser_id != nil {
  47371. fields = append(fields, wxcard.FieldUserID)
  47372. }
  47373. if m.addwx_user_id != nil {
  47374. fields = append(fields, wxcard.FieldWxUserID)
  47375. }
  47376. return fields
  47377. }
  47378. // AddedField returns the numeric value that was incremented/decremented on a field
  47379. // with the given name. The second boolean return value indicates that this field
  47380. // was not set, or was not defined in the schema.
  47381. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  47382. switch name {
  47383. case wxcard.FieldUserID:
  47384. return m.AddedUserID()
  47385. case wxcard.FieldWxUserID:
  47386. return m.AddedWxUserID()
  47387. }
  47388. return nil, false
  47389. }
  47390. // AddField adds the value to the field with the given name. It returns an error if
  47391. // the field is not defined in the schema, or if the type mismatched the field
  47392. // type.
  47393. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  47394. switch name {
  47395. case wxcard.FieldUserID:
  47396. v, ok := value.(int64)
  47397. if !ok {
  47398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47399. }
  47400. m.AddUserID(v)
  47401. return nil
  47402. case wxcard.FieldWxUserID:
  47403. v, ok := value.(int64)
  47404. if !ok {
  47405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  47406. }
  47407. m.AddWxUserID(v)
  47408. return nil
  47409. }
  47410. return fmt.Errorf("unknown WxCard numeric field %s", name)
  47411. }
  47412. // ClearedFields returns all nullable fields that were cleared during this
  47413. // mutation.
  47414. func (m *WxCardMutation) ClearedFields() []string {
  47415. var fields []string
  47416. if m.FieldCleared(wxcard.FieldDeletedAt) {
  47417. fields = append(fields, wxcard.FieldDeletedAt)
  47418. }
  47419. if m.FieldCleared(wxcard.FieldUserID) {
  47420. fields = append(fields, wxcard.FieldUserID)
  47421. }
  47422. if m.FieldCleared(wxcard.FieldWxUserID) {
  47423. fields = append(fields, wxcard.FieldWxUserID)
  47424. }
  47425. if m.FieldCleared(wxcard.FieldEmail) {
  47426. fields = append(fields, wxcard.FieldEmail)
  47427. }
  47428. if m.FieldCleared(wxcard.FieldAPIBase) {
  47429. fields = append(fields, wxcard.FieldAPIBase)
  47430. }
  47431. if m.FieldCleared(wxcard.FieldAPIKey) {
  47432. fields = append(fields, wxcard.FieldAPIKey)
  47433. }
  47434. if m.FieldCleared(wxcard.FieldAiInfo) {
  47435. fields = append(fields, wxcard.FieldAiInfo)
  47436. }
  47437. if m.FieldCleared(wxcard.FieldIntro) {
  47438. fields = append(fields, wxcard.FieldIntro)
  47439. }
  47440. return fields
  47441. }
  47442. // FieldCleared returns a boolean indicating if a field with the given name was
  47443. // cleared in this mutation.
  47444. func (m *WxCardMutation) FieldCleared(name string) bool {
  47445. _, ok := m.clearedFields[name]
  47446. return ok
  47447. }
  47448. // ClearField clears the value of the field with the given name. It returns an
  47449. // error if the field is not defined in the schema.
  47450. func (m *WxCardMutation) ClearField(name string) error {
  47451. switch name {
  47452. case wxcard.FieldDeletedAt:
  47453. m.ClearDeletedAt()
  47454. return nil
  47455. case wxcard.FieldUserID:
  47456. m.ClearUserID()
  47457. return nil
  47458. case wxcard.FieldWxUserID:
  47459. m.ClearWxUserID()
  47460. return nil
  47461. case wxcard.FieldEmail:
  47462. m.ClearEmail()
  47463. return nil
  47464. case wxcard.FieldAPIBase:
  47465. m.ClearAPIBase()
  47466. return nil
  47467. case wxcard.FieldAPIKey:
  47468. m.ClearAPIKey()
  47469. return nil
  47470. case wxcard.FieldAiInfo:
  47471. m.ClearAiInfo()
  47472. return nil
  47473. case wxcard.FieldIntro:
  47474. m.ClearIntro()
  47475. return nil
  47476. }
  47477. return fmt.Errorf("unknown WxCard nullable field %s", name)
  47478. }
  47479. // ResetField resets all changes in the mutation for the field with the given name.
  47480. // It returns an error if the field is not defined in the schema.
  47481. func (m *WxCardMutation) ResetField(name string) error {
  47482. switch name {
  47483. case wxcard.FieldCreatedAt:
  47484. m.ResetCreatedAt()
  47485. return nil
  47486. case wxcard.FieldUpdatedAt:
  47487. m.ResetUpdatedAt()
  47488. return nil
  47489. case wxcard.FieldDeletedAt:
  47490. m.ResetDeletedAt()
  47491. return nil
  47492. case wxcard.FieldUserID:
  47493. m.ResetUserID()
  47494. return nil
  47495. case wxcard.FieldWxUserID:
  47496. m.ResetWxUserID()
  47497. return nil
  47498. case wxcard.FieldAvatar:
  47499. m.ResetAvatar()
  47500. return nil
  47501. case wxcard.FieldLogo:
  47502. m.ResetLogo()
  47503. return nil
  47504. case wxcard.FieldName:
  47505. m.ResetName()
  47506. return nil
  47507. case wxcard.FieldCompany:
  47508. m.ResetCompany()
  47509. return nil
  47510. case wxcard.FieldAddress:
  47511. m.ResetAddress()
  47512. return nil
  47513. case wxcard.FieldPhone:
  47514. m.ResetPhone()
  47515. return nil
  47516. case wxcard.FieldOfficialAccount:
  47517. m.ResetOfficialAccount()
  47518. return nil
  47519. case wxcard.FieldWechatAccount:
  47520. m.ResetWechatAccount()
  47521. return nil
  47522. case wxcard.FieldEmail:
  47523. m.ResetEmail()
  47524. return nil
  47525. case wxcard.FieldAPIBase:
  47526. m.ResetAPIBase()
  47527. return nil
  47528. case wxcard.FieldAPIKey:
  47529. m.ResetAPIKey()
  47530. return nil
  47531. case wxcard.FieldAiInfo:
  47532. m.ResetAiInfo()
  47533. return nil
  47534. case wxcard.FieldIntro:
  47535. m.ResetIntro()
  47536. return nil
  47537. }
  47538. return fmt.Errorf("unknown WxCard field %s", name)
  47539. }
  47540. // AddedEdges returns all edge names that were set/added in this mutation.
  47541. func (m *WxCardMutation) AddedEdges() []string {
  47542. edges := make([]string, 0, 0)
  47543. return edges
  47544. }
  47545. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  47546. // name in this mutation.
  47547. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  47548. return nil
  47549. }
  47550. // RemovedEdges returns all edge names that were removed in this mutation.
  47551. func (m *WxCardMutation) RemovedEdges() []string {
  47552. edges := make([]string, 0, 0)
  47553. return edges
  47554. }
  47555. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  47556. // the given name in this mutation.
  47557. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  47558. return nil
  47559. }
  47560. // ClearedEdges returns all edge names that were cleared in this mutation.
  47561. func (m *WxCardMutation) ClearedEdges() []string {
  47562. edges := make([]string, 0, 0)
  47563. return edges
  47564. }
  47565. // EdgeCleared returns a boolean which indicates if the edge with the given name
  47566. // was cleared in this mutation.
  47567. func (m *WxCardMutation) EdgeCleared(name string) bool {
  47568. return false
  47569. }
  47570. // ClearEdge clears the value of the edge with the given name. It returns an error
  47571. // if that edge is not defined in the schema.
  47572. func (m *WxCardMutation) ClearEdge(name string) error {
  47573. return fmt.Errorf("unknown WxCard unique edge %s", name)
  47574. }
  47575. // ResetEdge resets all changes to the edge with the given name in this mutation.
  47576. // It returns an error if the edge is not defined in the schema.
  47577. func (m *WxCardMutation) ResetEdge(name string) error {
  47578. return fmt.Errorf("unknown WxCard edge %s", name)
  47579. }
  47580. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  47581. type WxCardUserMutation struct {
  47582. config
  47583. op Op
  47584. typ string
  47585. id *uint64
  47586. created_at *time.Time
  47587. updated_at *time.Time
  47588. deleted_at *time.Time
  47589. wxid *string
  47590. account *string
  47591. avatar *string
  47592. nickname *string
  47593. remark *string
  47594. phone *string
  47595. open_id *string
  47596. union_id *string
  47597. session_key *string
  47598. is_vip *int
  47599. addis_vip *int
  47600. clearedFields map[string]struct{}
  47601. done bool
  47602. oldValue func(context.Context) (*WxCardUser, error)
  47603. predicates []predicate.WxCardUser
  47604. }
  47605. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  47606. // wxcarduserOption allows management of the mutation configuration using functional options.
  47607. type wxcarduserOption func(*WxCardUserMutation)
  47608. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  47609. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  47610. m := &WxCardUserMutation{
  47611. config: c,
  47612. op: op,
  47613. typ: TypeWxCardUser,
  47614. clearedFields: make(map[string]struct{}),
  47615. }
  47616. for _, opt := range opts {
  47617. opt(m)
  47618. }
  47619. return m
  47620. }
  47621. // withWxCardUserID sets the ID field of the mutation.
  47622. func withWxCardUserID(id uint64) wxcarduserOption {
  47623. return func(m *WxCardUserMutation) {
  47624. var (
  47625. err error
  47626. once sync.Once
  47627. value *WxCardUser
  47628. )
  47629. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  47630. once.Do(func() {
  47631. if m.done {
  47632. err = errors.New("querying old values post mutation is not allowed")
  47633. } else {
  47634. value, err = m.Client().WxCardUser.Get(ctx, id)
  47635. }
  47636. })
  47637. return value, err
  47638. }
  47639. m.id = &id
  47640. }
  47641. }
  47642. // withWxCardUser sets the old WxCardUser of the mutation.
  47643. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  47644. return func(m *WxCardUserMutation) {
  47645. m.oldValue = func(context.Context) (*WxCardUser, error) {
  47646. return node, nil
  47647. }
  47648. m.id = &node.ID
  47649. }
  47650. }
  47651. // Client returns a new `ent.Client` from the mutation. If the mutation was
  47652. // executed in a transaction (ent.Tx), a transactional client is returned.
  47653. func (m WxCardUserMutation) Client() *Client {
  47654. client := &Client{config: m.config}
  47655. client.init()
  47656. return client
  47657. }
  47658. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  47659. // it returns an error otherwise.
  47660. func (m WxCardUserMutation) Tx() (*Tx, error) {
  47661. if _, ok := m.driver.(*txDriver); !ok {
  47662. return nil, errors.New("ent: mutation is not running in a transaction")
  47663. }
  47664. tx := &Tx{config: m.config}
  47665. tx.init()
  47666. return tx, nil
  47667. }
  47668. // SetID sets the value of the id field. Note that this
  47669. // operation is only accepted on creation of WxCardUser entities.
  47670. func (m *WxCardUserMutation) SetID(id uint64) {
  47671. m.id = &id
  47672. }
  47673. // ID returns the ID value in the mutation. Note that the ID is only available
  47674. // if it was provided to the builder or after it was returned from the database.
  47675. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  47676. if m.id == nil {
  47677. return
  47678. }
  47679. return *m.id, true
  47680. }
  47681. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  47682. // That means, if the mutation is applied within a transaction with an isolation level such
  47683. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  47684. // or updated by the mutation.
  47685. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  47686. switch {
  47687. case m.op.Is(OpUpdateOne | OpDeleteOne):
  47688. id, exists := m.ID()
  47689. if exists {
  47690. return []uint64{id}, nil
  47691. }
  47692. fallthrough
  47693. case m.op.Is(OpUpdate | OpDelete):
  47694. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  47695. default:
  47696. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47697. }
  47698. }
  47699. // SetCreatedAt sets the "created_at" field.
  47700. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  47701. m.created_at = &t
  47702. }
  47703. // CreatedAt returns the value of the "created_at" field in the mutation.
  47704. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  47705. v := m.created_at
  47706. if v == nil {
  47707. return
  47708. }
  47709. return *v, true
  47710. }
  47711. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  47712. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47714. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47715. if !m.op.Is(OpUpdateOne) {
  47716. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47717. }
  47718. if m.id == nil || m.oldValue == nil {
  47719. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47720. }
  47721. oldValue, err := m.oldValue(ctx)
  47722. if err != nil {
  47723. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47724. }
  47725. return oldValue.CreatedAt, nil
  47726. }
  47727. // ResetCreatedAt resets all changes to the "created_at" field.
  47728. func (m *WxCardUserMutation) ResetCreatedAt() {
  47729. m.created_at = nil
  47730. }
  47731. // SetUpdatedAt sets the "updated_at" field.
  47732. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  47733. m.updated_at = &t
  47734. }
  47735. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47736. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  47737. v := m.updated_at
  47738. if v == nil {
  47739. return
  47740. }
  47741. return *v, true
  47742. }
  47743. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  47744. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47746. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47747. if !m.op.Is(OpUpdateOne) {
  47748. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47749. }
  47750. if m.id == nil || m.oldValue == nil {
  47751. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47752. }
  47753. oldValue, err := m.oldValue(ctx)
  47754. if err != nil {
  47755. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47756. }
  47757. return oldValue.UpdatedAt, nil
  47758. }
  47759. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47760. func (m *WxCardUserMutation) ResetUpdatedAt() {
  47761. m.updated_at = nil
  47762. }
  47763. // SetDeletedAt sets the "deleted_at" field.
  47764. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  47765. m.deleted_at = &t
  47766. }
  47767. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47768. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  47769. v := m.deleted_at
  47770. if v == nil {
  47771. return
  47772. }
  47773. return *v, true
  47774. }
  47775. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  47776. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47778. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47779. if !m.op.Is(OpUpdateOne) {
  47780. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47781. }
  47782. if m.id == nil || m.oldValue == nil {
  47783. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47784. }
  47785. oldValue, err := m.oldValue(ctx)
  47786. if err != nil {
  47787. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47788. }
  47789. return oldValue.DeletedAt, nil
  47790. }
  47791. // ClearDeletedAt clears the value of the "deleted_at" field.
  47792. func (m *WxCardUserMutation) ClearDeletedAt() {
  47793. m.deleted_at = nil
  47794. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  47795. }
  47796. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47797. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  47798. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  47799. return ok
  47800. }
  47801. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47802. func (m *WxCardUserMutation) ResetDeletedAt() {
  47803. m.deleted_at = nil
  47804. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  47805. }
  47806. // SetWxid sets the "wxid" field.
  47807. func (m *WxCardUserMutation) SetWxid(s string) {
  47808. m.wxid = &s
  47809. }
  47810. // Wxid returns the value of the "wxid" field in the mutation.
  47811. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  47812. v := m.wxid
  47813. if v == nil {
  47814. return
  47815. }
  47816. return *v, true
  47817. }
  47818. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  47819. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47821. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  47822. if !m.op.Is(OpUpdateOne) {
  47823. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47824. }
  47825. if m.id == nil || m.oldValue == nil {
  47826. return v, errors.New("OldWxid requires an ID field in the mutation")
  47827. }
  47828. oldValue, err := m.oldValue(ctx)
  47829. if err != nil {
  47830. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47831. }
  47832. return oldValue.Wxid, nil
  47833. }
  47834. // ResetWxid resets all changes to the "wxid" field.
  47835. func (m *WxCardUserMutation) ResetWxid() {
  47836. m.wxid = nil
  47837. }
  47838. // SetAccount sets the "account" field.
  47839. func (m *WxCardUserMutation) SetAccount(s string) {
  47840. m.account = &s
  47841. }
  47842. // Account returns the value of the "account" field in the mutation.
  47843. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  47844. v := m.account
  47845. if v == nil {
  47846. return
  47847. }
  47848. return *v, true
  47849. }
  47850. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  47851. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47853. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  47854. if !m.op.Is(OpUpdateOne) {
  47855. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  47856. }
  47857. if m.id == nil || m.oldValue == nil {
  47858. return v, errors.New("OldAccount requires an ID field in the mutation")
  47859. }
  47860. oldValue, err := m.oldValue(ctx)
  47861. if err != nil {
  47862. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  47863. }
  47864. return oldValue.Account, nil
  47865. }
  47866. // ResetAccount resets all changes to the "account" field.
  47867. func (m *WxCardUserMutation) ResetAccount() {
  47868. m.account = nil
  47869. }
  47870. // SetAvatar sets the "avatar" field.
  47871. func (m *WxCardUserMutation) SetAvatar(s string) {
  47872. m.avatar = &s
  47873. }
  47874. // Avatar returns the value of the "avatar" field in the mutation.
  47875. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  47876. v := m.avatar
  47877. if v == nil {
  47878. return
  47879. }
  47880. return *v, true
  47881. }
  47882. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  47883. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47884. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47885. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  47886. if !m.op.Is(OpUpdateOne) {
  47887. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  47888. }
  47889. if m.id == nil || m.oldValue == nil {
  47890. return v, errors.New("OldAvatar requires an ID field in the mutation")
  47891. }
  47892. oldValue, err := m.oldValue(ctx)
  47893. if err != nil {
  47894. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  47895. }
  47896. return oldValue.Avatar, nil
  47897. }
  47898. // ResetAvatar resets all changes to the "avatar" field.
  47899. func (m *WxCardUserMutation) ResetAvatar() {
  47900. m.avatar = nil
  47901. }
  47902. // SetNickname sets the "nickname" field.
  47903. func (m *WxCardUserMutation) SetNickname(s string) {
  47904. m.nickname = &s
  47905. }
  47906. // Nickname returns the value of the "nickname" field in the mutation.
  47907. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  47908. v := m.nickname
  47909. if v == nil {
  47910. return
  47911. }
  47912. return *v, true
  47913. }
  47914. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  47915. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47917. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  47918. if !m.op.Is(OpUpdateOne) {
  47919. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  47920. }
  47921. if m.id == nil || m.oldValue == nil {
  47922. return v, errors.New("OldNickname requires an ID field in the mutation")
  47923. }
  47924. oldValue, err := m.oldValue(ctx)
  47925. if err != nil {
  47926. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  47927. }
  47928. return oldValue.Nickname, nil
  47929. }
  47930. // ResetNickname resets all changes to the "nickname" field.
  47931. func (m *WxCardUserMutation) ResetNickname() {
  47932. m.nickname = nil
  47933. }
  47934. // SetRemark sets the "remark" field.
  47935. func (m *WxCardUserMutation) SetRemark(s string) {
  47936. m.remark = &s
  47937. }
  47938. // Remark returns the value of the "remark" field in the mutation.
  47939. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  47940. v := m.remark
  47941. if v == nil {
  47942. return
  47943. }
  47944. return *v, true
  47945. }
  47946. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  47947. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47949. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  47950. if !m.op.Is(OpUpdateOne) {
  47951. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  47952. }
  47953. if m.id == nil || m.oldValue == nil {
  47954. return v, errors.New("OldRemark requires an ID field in the mutation")
  47955. }
  47956. oldValue, err := m.oldValue(ctx)
  47957. if err != nil {
  47958. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  47959. }
  47960. return oldValue.Remark, nil
  47961. }
  47962. // ResetRemark resets all changes to the "remark" field.
  47963. func (m *WxCardUserMutation) ResetRemark() {
  47964. m.remark = nil
  47965. }
  47966. // SetPhone sets the "phone" field.
  47967. func (m *WxCardUserMutation) SetPhone(s string) {
  47968. m.phone = &s
  47969. }
  47970. // Phone returns the value of the "phone" field in the mutation.
  47971. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  47972. v := m.phone
  47973. if v == nil {
  47974. return
  47975. }
  47976. return *v, true
  47977. }
  47978. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  47979. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  47980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47981. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  47982. if !m.op.Is(OpUpdateOne) {
  47983. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  47984. }
  47985. if m.id == nil || m.oldValue == nil {
  47986. return v, errors.New("OldPhone requires an ID field in the mutation")
  47987. }
  47988. oldValue, err := m.oldValue(ctx)
  47989. if err != nil {
  47990. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  47991. }
  47992. return oldValue.Phone, nil
  47993. }
  47994. // ResetPhone resets all changes to the "phone" field.
  47995. func (m *WxCardUserMutation) ResetPhone() {
  47996. m.phone = nil
  47997. }
  47998. // SetOpenID sets the "open_id" field.
  47999. func (m *WxCardUserMutation) SetOpenID(s string) {
  48000. m.open_id = &s
  48001. }
  48002. // OpenID returns the value of the "open_id" field in the mutation.
  48003. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  48004. v := m.open_id
  48005. if v == nil {
  48006. return
  48007. }
  48008. return *v, true
  48009. }
  48010. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  48011. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48013. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  48014. if !m.op.Is(OpUpdateOne) {
  48015. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  48016. }
  48017. if m.id == nil || m.oldValue == nil {
  48018. return v, errors.New("OldOpenID requires an ID field in the mutation")
  48019. }
  48020. oldValue, err := m.oldValue(ctx)
  48021. if err != nil {
  48022. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  48023. }
  48024. return oldValue.OpenID, nil
  48025. }
  48026. // ResetOpenID resets all changes to the "open_id" field.
  48027. func (m *WxCardUserMutation) ResetOpenID() {
  48028. m.open_id = nil
  48029. }
  48030. // SetUnionID sets the "union_id" field.
  48031. func (m *WxCardUserMutation) SetUnionID(s string) {
  48032. m.union_id = &s
  48033. }
  48034. // UnionID returns the value of the "union_id" field in the mutation.
  48035. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  48036. v := m.union_id
  48037. if v == nil {
  48038. return
  48039. }
  48040. return *v, true
  48041. }
  48042. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  48043. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48045. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  48046. if !m.op.Is(OpUpdateOne) {
  48047. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  48048. }
  48049. if m.id == nil || m.oldValue == nil {
  48050. return v, errors.New("OldUnionID requires an ID field in the mutation")
  48051. }
  48052. oldValue, err := m.oldValue(ctx)
  48053. if err != nil {
  48054. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  48055. }
  48056. return oldValue.UnionID, nil
  48057. }
  48058. // ResetUnionID resets all changes to the "union_id" field.
  48059. func (m *WxCardUserMutation) ResetUnionID() {
  48060. m.union_id = nil
  48061. }
  48062. // SetSessionKey sets the "session_key" field.
  48063. func (m *WxCardUserMutation) SetSessionKey(s string) {
  48064. m.session_key = &s
  48065. }
  48066. // SessionKey returns the value of the "session_key" field in the mutation.
  48067. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  48068. v := m.session_key
  48069. if v == nil {
  48070. return
  48071. }
  48072. return *v, true
  48073. }
  48074. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  48075. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48077. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  48078. if !m.op.Is(OpUpdateOne) {
  48079. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  48080. }
  48081. if m.id == nil || m.oldValue == nil {
  48082. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  48083. }
  48084. oldValue, err := m.oldValue(ctx)
  48085. if err != nil {
  48086. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  48087. }
  48088. return oldValue.SessionKey, nil
  48089. }
  48090. // ResetSessionKey resets all changes to the "session_key" field.
  48091. func (m *WxCardUserMutation) ResetSessionKey() {
  48092. m.session_key = nil
  48093. }
  48094. // SetIsVip sets the "is_vip" field.
  48095. func (m *WxCardUserMutation) SetIsVip(i int) {
  48096. m.is_vip = &i
  48097. m.addis_vip = nil
  48098. }
  48099. // IsVip returns the value of the "is_vip" field in the mutation.
  48100. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  48101. v := m.is_vip
  48102. if v == nil {
  48103. return
  48104. }
  48105. return *v, true
  48106. }
  48107. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  48108. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  48109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48110. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  48111. if !m.op.Is(OpUpdateOne) {
  48112. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  48113. }
  48114. if m.id == nil || m.oldValue == nil {
  48115. return v, errors.New("OldIsVip requires an ID field in the mutation")
  48116. }
  48117. oldValue, err := m.oldValue(ctx)
  48118. if err != nil {
  48119. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  48120. }
  48121. return oldValue.IsVip, nil
  48122. }
  48123. // AddIsVip adds i to the "is_vip" field.
  48124. func (m *WxCardUserMutation) AddIsVip(i int) {
  48125. if m.addis_vip != nil {
  48126. *m.addis_vip += i
  48127. } else {
  48128. m.addis_vip = &i
  48129. }
  48130. }
  48131. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  48132. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  48133. v := m.addis_vip
  48134. if v == nil {
  48135. return
  48136. }
  48137. return *v, true
  48138. }
  48139. // ResetIsVip resets all changes to the "is_vip" field.
  48140. func (m *WxCardUserMutation) ResetIsVip() {
  48141. m.is_vip = nil
  48142. m.addis_vip = nil
  48143. }
  48144. // Where appends a list predicates to the WxCardUserMutation builder.
  48145. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  48146. m.predicates = append(m.predicates, ps...)
  48147. }
  48148. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  48149. // users can use type-assertion to append predicates that do not depend on any generated package.
  48150. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  48151. p := make([]predicate.WxCardUser, len(ps))
  48152. for i := range ps {
  48153. p[i] = ps[i]
  48154. }
  48155. m.Where(p...)
  48156. }
  48157. // Op returns the operation name.
  48158. func (m *WxCardUserMutation) Op() Op {
  48159. return m.op
  48160. }
  48161. // SetOp allows setting the mutation operation.
  48162. func (m *WxCardUserMutation) SetOp(op Op) {
  48163. m.op = op
  48164. }
  48165. // Type returns the node type of this mutation (WxCardUser).
  48166. func (m *WxCardUserMutation) Type() string {
  48167. return m.typ
  48168. }
  48169. // Fields returns all fields that were changed during this mutation. Note that in
  48170. // order to get all numeric fields that were incremented/decremented, call
  48171. // AddedFields().
  48172. func (m *WxCardUserMutation) Fields() []string {
  48173. fields := make([]string, 0, 13)
  48174. if m.created_at != nil {
  48175. fields = append(fields, wxcarduser.FieldCreatedAt)
  48176. }
  48177. if m.updated_at != nil {
  48178. fields = append(fields, wxcarduser.FieldUpdatedAt)
  48179. }
  48180. if m.deleted_at != nil {
  48181. fields = append(fields, wxcarduser.FieldDeletedAt)
  48182. }
  48183. if m.wxid != nil {
  48184. fields = append(fields, wxcarduser.FieldWxid)
  48185. }
  48186. if m.account != nil {
  48187. fields = append(fields, wxcarduser.FieldAccount)
  48188. }
  48189. if m.avatar != nil {
  48190. fields = append(fields, wxcarduser.FieldAvatar)
  48191. }
  48192. if m.nickname != nil {
  48193. fields = append(fields, wxcarduser.FieldNickname)
  48194. }
  48195. if m.remark != nil {
  48196. fields = append(fields, wxcarduser.FieldRemark)
  48197. }
  48198. if m.phone != nil {
  48199. fields = append(fields, wxcarduser.FieldPhone)
  48200. }
  48201. if m.open_id != nil {
  48202. fields = append(fields, wxcarduser.FieldOpenID)
  48203. }
  48204. if m.union_id != nil {
  48205. fields = append(fields, wxcarduser.FieldUnionID)
  48206. }
  48207. if m.session_key != nil {
  48208. fields = append(fields, wxcarduser.FieldSessionKey)
  48209. }
  48210. if m.is_vip != nil {
  48211. fields = append(fields, wxcarduser.FieldIsVip)
  48212. }
  48213. return fields
  48214. }
  48215. // Field returns the value of a field with the given name. The second boolean
  48216. // return value indicates that this field was not set, or was not defined in the
  48217. // schema.
  48218. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  48219. switch name {
  48220. case wxcarduser.FieldCreatedAt:
  48221. return m.CreatedAt()
  48222. case wxcarduser.FieldUpdatedAt:
  48223. return m.UpdatedAt()
  48224. case wxcarduser.FieldDeletedAt:
  48225. return m.DeletedAt()
  48226. case wxcarduser.FieldWxid:
  48227. return m.Wxid()
  48228. case wxcarduser.FieldAccount:
  48229. return m.Account()
  48230. case wxcarduser.FieldAvatar:
  48231. return m.Avatar()
  48232. case wxcarduser.FieldNickname:
  48233. return m.Nickname()
  48234. case wxcarduser.FieldRemark:
  48235. return m.Remark()
  48236. case wxcarduser.FieldPhone:
  48237. return m.Phone()
  48238. case wxcarduser.FieldOpenID:
  48239. return m.OpenID()
  48240. case wxcarduser.FieldUnionID:
  48241. return m.UnionID()
  48242. case wxcarduser.FieldSessionKey:
  48243. return m.SessionKey()
  48244. case wxcarduser.FieldIsVip:
  48245. return m.IsVip()
  48246. }
  48247. return nil, false
  48248. }
  48249. // OldField returns the old value of the field from the database. An error is
  48250. // returned if the mutation operation is not UpdateOne, or the query to the
  48251. // database failed.
  48252. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48253. switch name {
  48254. case wxcarduser.FieldCreatedAt:
  48255. return m.OldCreatedAt(ctx)
  48256. case wxcarduser.FieldUpdatedAt:
  48257. return m.OldUpdatedAt(ctx)
  48258. case wxcarduser.FieldDeletedAt:
  48259. return m.OldDeletedAt(ctx)
  48260. case wxcarduser.FieldWxid:
  48261. return m.OldWxid(ctx)
  48262. case wxcarduser.FieldAccount:
  48263. return m.OldAccount(ctx)
  48264. case wxcarduser.FieldAvatar:
  48265. return m.OldAvatar(ctx)
  48266. case wxcarduser.FieldNickname:
  48267. return m.OldNickname(ctx)
  48268. case wxcarduser.FieldRemark:
  48269. return m.OldRemark(ctx)
  48270. case wxcarduser.FieldPhone:
  48271. return m.OldPhone(ctx)
  48272. case wxcarduser.FieldOpenID:
  48273. return m.OldOpenID(ctx)
  48274. case wxcarduser.FieldUnionID:
  48275. return m.OldUnionID(ctx)
  48276. case wxcarduser.FieldSessionKey:
  48277. return m.OldSessionKey(ctx)
  48278. case wxcarduser.FieldIsVip:
  48279. return m.OldIsVip(ctx)
  48280. }
  48281. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  48282. }
  48283. // SetField sets the value of a field with the given name. It returns an error if
  48284. // the field is not defined in the schema, or if the type mismatched the field
  48285. // type.
  48286. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  48287. switch name {
  48288. case wxcarduser.FieldCreatedAt:
  48289. v, ok := value.(time.Time)
  48290. if !ok {
  48291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48292. }
  48293. m.SetCreatedAt(v)
  48294. return nil
  48295. case wxcarduser.FieldUpdatedAt:
  48296. v, ok := value.(time.Time)
  48297. if !ok {
  48298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48299. }
  48300. m.SetUpdatedAt(v)
  48301. return nil
  48302. case wxcarduser.FieldDeletedAt:
  48303. v, ok := value.(time.Time)
  48304. if !ok {
  48305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48306. }
  48307. m.SetDeletedAt(v)
  48308. return nil
  48309. case wxcarduser.FieldWxid:
  48310. v, ok := value.(string)
  48311. if !ok {
  48312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48313. }
  48314. m.SetWxid(v)
  48315. return nil
  48316. case wxcarduser.FieldAccount:
  48317. v, ok := value.(string)
  48318. if !ok {
  48319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48320. }
  48321. m.SetAccount(v)
  48322. return nil
  48323. case wxcarduser.FieldAvatar:
  48324. v, ok := value.(string)
  48325. if !ok {
  48326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48327. }
  48328. m.SetAvatar(v)
  48329. return nil
  48330. case wxcarduser.FieldNickname:
  48331. v, ok := value.(string)
  48332. if !ok {
  48333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48334. }
  48335. m.SetNickname(v)
  48336. return nil
  48337. case wxcarduser.FieldRemark:
  48338. v, ok := value.(string)
  48339. if !ok {
  48340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48341. }
  48342. m.SetRemark(v)
  48343. return nil
  48344. case wxcarduser.FieldPhone:
  48345. v, ok := value.(string)
  48346. if !ok {
  48347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48348. }
  48349. m.SetPhone(v)
  48350. return nil
  48351. case wxcarduser.FieldOpenID:
  48352. v, ok := value.(string)
  48353. if !ok {
  48354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48355. }
  48356. m.SetOpenID(v)
  48357. return nil
  48358. case wxcarduser.FieldUnionID:
  48359. v, ok := value.(string)
  48360. if !ok {
  48361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48362. }
  48363. m.SetUnionID(v)
  48364. return nil
  48365. case wxcarduser.FieldSessionKey:
  48366. v, ok := value.(string)
  48367. if !ok {
  48368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48369. }
  48370. m.SetSessionKey(v)
  48371. return nil
  48372. case wxcarduser.FieldIsVip:
  48373. v, ok := value.(int)
  48374. if !ok {
  48375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48376. }
  48377. m.SetIsVip(v)
  48378. return nil
  48379. }
  48380. return fmt.Errorf("unknown WxCardUser field %s", name)
  48381. }
  48382. // AddedFields returns all numeric fields that were incremented/decremented during
  48383. // this mutation.
  48384. func (m *WxCardUserMutation) AddedFields() []string {
  48385. var fields []string
  48386. if m.addis_vip != nil {
  48387. fields = append(fields, wxcarduser.FieldIsVip)
  48388. }
  48389. return fields
  48390. }
  48391. // AddedField returns the numeric value that was incremented/decremented on a field
  48392. // with the given name. The second boolean return value indicates that this field
  48393. // was not set, or was not defined in the schema.
  48394. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  48395. switch name {
  48396. case wxcarduser.FieldIsVip:
  48397. return m.AddedIsVip()
  48398. }
  48399. return nil, false
  48400. }
  48401. // AddField adds the value to the field with the given name. It returns an error if
  48402. // the field is not defined in the schema, or if the type mismatched the field
  48403. // type.
  48404. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  48405. switch name {
  48406. case wxcarduser.FieldIsVip:
  48407. v, ok := value.(int)
  48408. if !ok {
  48409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48410. }
  48411. m.AddIsVip(v)
  48412. return nil
  48413. }
  48414. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  48415. }
  48416. // ClearedFields returns all nullable fields that were cleared during this
  48417. // mutation.
  48418. func (m *WxCardUserMutation) ClearedFields() []string {
  48419. var fields []string
  48420. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  48421. fields = append(fields, wxcarduser.FieldDeletedAt)
  48422. }
  48423. return fields
  48424. }
  48425. // FieldCleared returns a boolean indicating if a field with the given name was
  48426. // cleared in this mutation.
  48427. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  48428. _, ok := m.clearedFields[name]
  48429. return ok
  48430. }
  48431. // ClearField clears the value of the field with the given name. It returns an
  48432. // error if the field is not defined in the schema.
  48433. func (m *WxCardUserMutation) ClearField(name string) error {
  48434. switch name {
  48435. case wxcarduser.FieldDeletedAt:
  48436. m.ClearDeletedAt()
  48437. return nil
  48438. }
  48439. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  48440. }
  48441. // ResetField resets all changes in the mutation for the field with the given name.
  48442. // It returns an error if the field is not defined in the schema.
  48443. func (m *WxCardUserMutation) ResetField(name string) error {
  48444. switch name {
  48445. case wxcarduser.FieldCreatedAt:
  48446. m.ResetCreatedAt()
  48447. return nil
  48448. case wxcarduser.FieldUpdatedAt:
  48449. m.ResetUpdatedAt()
  48450. return nil
  48451. case wxcarduser.FieldDeletedAt:
  48452. m.ResetDeletedAt()
  48453. return nil
  48454. case wxcarduser.FieldWxid:
  48455. m.ResetWxid()
  48456. return nil
  48457. case wxcarduser.FieldAccount:
  48458. m.ResetAccount()
  48459. return nil
  48460. case wxcarduser.FieldAvatar:
  48461. m.ResetAvatar()
  48462. return nil
  48463. case wxcarduser.FieldNickname:
  48464. m.ResetNickname()
  48465. return nil
  48466. case wxcarduser.FieldRemark:
  48467. m.ResetRemark()
  48468. return nil
  48469. case wxcarduser.FieldPhone:
  48470. m.ResetPhone()
  48471. return nil
  48472. case wxcarduser.FieldOpenID:
  48473. m.ResetOpenID()
  48474. return nil
  48475. case wxcarduser.FieldUnionID:
  48476. m.ResetUnionID()
  48477. return nil
  48478. case wxcarduser.FieldSessionKey:
  48479. m.ResetSessionKey()
  48480. return nil
  48481. case wxcarduser.FieldIsVip:
  48482. m.ResetIsVip()
  48483. return nil
  48484. }
  48485. return fmt.Errorf("unknown WxCardUser field %s", name)
  48486. }
  48487. // AddedEdges returns all edge names that were set/added in this mutation.
  48488. func (m *WxCardUserMutation) AddedEdges() []string {
  48489. edges := make([]string, 0, 0)
  48490. return edges
  48491. }
  48492. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48493. // name in this mutation.
  48494. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  48495. return nil
  48496. }
  48497. // RemovedEdges returns all edge names that were removed in this mutation.
  48498. func (m *WxCardUserMutation) RemovedEdges() []string {
  48499. edges := make([]string, 0, 0)
  48500. return edges
  48501. }
  48502. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48503. // the given name in this mutation.
  48504. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  48505. return nil
  48506. }
  48507. // ClearedEdges returns all edge names that were cleared in this mutation.
  48508. func (m *WxCardUserMutation) ClearedEdges() []string {
  48509. edges := make([]string, 0, 0)
  48510. return edges
  48511. }
  48512. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48513. // was cleared in this mutation.
  48514. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  48515. return false
  48516. }
  48517. // ClearEdge clears the value of the edge with the given name. It returns an error
  48518. // if that edge is not defined in the schema.
  48519. func (m *WxCardUserMutation) ClearEdge(name string) error {
  48520. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  48521. }
  48522. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48523. // It returns an error if the edge is not defined in the schema.
  48524. func (m *WxCardUserMutation) ResetEdge(name string) error {
  48525. return fmt.Errorf("unknown WxCardUser edge %s", name)
  48526. }
  48527. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  48528. type WxCardVisitMutation struct {
  48529. config
  48530. op Op
  48531. typ string
  48532. id *uint64
  48533. created_at *time.Time
  48534. updated_at *time.Time
  48535. deleted_at *time.Time
  48536. user_id *uint64
  48537. adduser_id *int64
  48538. bot_id *uint64
  48539. addbot_id *int64
  48540. bot_type *uint8
  48541. addbot_type *int8
  48542. clearedFields map[string]struct{}
  48543. done bool
  48544. oldValue func(context.Context) (*WxCardVisit, error)
  48545. predicates []predicate.WxCardVisit
  48546. }
  48547. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  48548. // wxcardvisitOption allows management of the mutation configuration using functional options.
  48549. type wxcardvisitOption func(*WxCardVisitMutation)
  48550. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  48551. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  48552. m := &WxCardVisitMutation{
  48553. config: c,
  48554. op: op,
  48555. typ: TypeWxCardVisit,
  48556. clearedFields: make(map[string]struct{}),
  48557. }
  48558. for _, opt := range opts {
  48559. opt(m)
  48560. }
  48561. return m
  48562. }
  48563. // withWxCardVisitID sets the ID field of the mutation.
  48564. func withWxCardVisitID(id uint64) wxcardvisitOption {
  48565. return func(m *WxCardVisitMutation) {
  48566. var (
  48567. err error
  48568. once sync.Once
  48569. value *WxCardVisit
  48570. )
  48571. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  48572. once.Do(func() {
  48573. if m.done {
  48574. err = errors.New("querying old values post mutation is not allowed")
  48575. } else {
  48576. value, err = m.Client().WxCardVisit.Get(ctx, id)
  48577. }
  48578. })
  48579. return value, err
  48580. }
  48581. m.id = &id
  48582. }
  48583. }
  48584. // withWxCardVisit sets the old WxCardVisit of the mutation.
  48585. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  48586. return func(m *WxCardVisitMutation) {
  48587. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  48588. return node, nil
  48589. }
  48590. m.id = &node.ID
  48591. }
  48592. }
  48593. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48594. // executed in a transaction (ent.Tx), a transactional client is returned.
  48595. func (m WxCardVisitMutation) Client() *Client {
  48596. client := &Client{config: m.config}
  48597. client.init()
  48598. return client
  48599. }
  48600. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48601. // it returns an error otherwise.
  48602. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  48603. if _, ok := m.driver.(*txDriver); !ok {
  48604. return nil, errors.New("ent: mutation is not running in a transaction")
  48605. }
  48606. tx := &Tx{config: m.config}
  48607. tx.init()
  48608. return tx, nil
  48609. }
  48610. // SetID sets the value of the id field. Note that this
  48611. // operation is only accepted on creation of WxCardVisit entities.
  48612. func (m *WxCardVisitMutation) SetID(id uint64) {
  48613. m.id = &id
  48614. }
  48615. // ID returns the ID value in the mutation. Note that the ID is only available
  48616. // if it was provided to the builder or after it was returned from the database.
  48617. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  48618. if m.id == nil {
  48619. return
  48620. }
  48621. return *m.id, true
  48622. }
  48623. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48624. // That means, if the mutation is applied within a transaction with an isolation level such
  48625. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48626. // or updated by the mutation.
  48627. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  48628. switch {
  48629. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48630. id, exists := m.ID()
  48631. if exists {
  48632. return []uint64{id}, nil
  48633. }
  48634. fallthrough
  48635. case m.op.Is(OpUpdate | OpDelete):
  48636. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  48637. default:
  48638. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48639. }
  48640. }
  48641. // SetCreatedAt sets the "created_at" field.
  48642. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  48643. m.created_at = &t
  48644. }
  48645. // CreatedAt returns the value of the "created_at" field in the mutation.
  48646. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  48647. v := m.created_at
  48648. if v == nil {
  48649. return
  48650. }
  48651. return *v, true
  48652. }
  48653. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  48654. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48656. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48657. if !m.op.Is(OpUpdateOne) {
  48658. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48659. }
  48660. if m.id == nil || m.oldValue == nil {
  48661. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48662. }
  48663. oldValue, err := m.oldValue(ctx)
  48664. if err != nil {
  48665. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48666. }
  48667. return oldValue.CreatedAt, nil
  48668. }
  48669. // ResetCreatedAt resets all changes to the "created_at" field.
  48670. func (m *WxCardVisitMutation) ResetCreatedAt() {
  48671. m.created_at = nil
  48672. }
  48673. // SetUpdatedAt sets the "updated_at" field.
  48674. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  48675. m.updated_at = &t
  48676. }
  48677. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48678. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  48679. v := m.updated_at
  48680. if v == nil {
  48681. return
  48682. }
  48683. return *v, true
  48684. }
  48685. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  48686. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48688. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48689. if !m.op.Is(OpUpdateOne) {
  48690. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48691. }
  48692. if m.id == nil || m.oldValue == nil {
  48693. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48694. }
  48695. oldValue, err := m.oldValue(ctx)
  48696. if err != nil {
  48697. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48698. }
  48699. return oldValue.UpdatedAt, nil
  48700. }
  48701. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48702. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  48703. m.updated_at = nil
  48704. }
  48705. // SetDeletedAt sets the "deleted_at" field.
  48706. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  48707. m.deleted_at = &t
  48708. }
  48709. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48710. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  48711. v := m.deleted_at
  48712. if v == nil {
  48713. return
  48714. }
  48715. return *v, true
  48716. }
  48717. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  48718. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48720. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48721. if !m.op.Is(OpUpdateOne) {
  48722. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48723. }
  48724. if m.id == nil || m.oldValue == nil {
  48725. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48726. }
  48727. oldValue, err := m.oldValue(ctx)
  48728. if err != nil {
  48729. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48730. }
  48731. return oldValue.DeletedAt, nil
  48732. }
  48733. // ClearDeletedAt clears the value of the "deleted_at" field.
  48734. func (m *WxCardVisitMutation) ClearDeletedAt() {
  48735. m.deleted_at = nil
  48736. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  48737. }
  48738. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48739. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  48740. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  48741. return ok
  48742. }
  48743. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48744. func (m *WxCardVisitMutation) ResetDeletedAt() {
  48745. m.deleted_at = nil
  48746. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  48747. }
  48748. // SetUserID sets the "user_id" field.
  48749. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  48750. m.user_id = &u
  48751. m.adduser_id = nil
  48752. }
  48753. // UserID returns the value of the "user_id" field in the mutation.
  48754. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  48755. v := m.user_id
  48756. if v == nil {
  48757. return
  48758. }
  48759. return *v, true
  48760. }
  48761. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  48762. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48764. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48765. if !m.op.Is(OpUpdateOne) {
  48766. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48767. }
  48768. if m.id == nil || m.oldValue == nil {
  48769. return v, errors.New("OldUserID requires an ID field in the mutation")
  48770. }
  48771. oldValue, err := m.oldValue(ctx)
  48772. if err != nil {
  48773. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48774. }
  48775. return oldValue.UserID, nil
  48776. }
  48777. // AddUserID adds u to the "user_id" field.
  48778. func (m *WxCardVisitMutation) AddUserID(u int64) {
  48779. if m.adduser_id != nil {
  48780. *m.adduser_id += u
  48781. } else {
  48782. m.adduser_id = &u
  48783. }
  48784. }
  48785. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48786. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  48787. v := m.adduser_id
  48788. if v == nil {
  48789. return
  48790. }
  48791. return *v, true
  48792. }
  48793. // ClearUserID clears the value of the "user_id" field.
  48794. func (m *WxCardVisitMutation) ClearUserID() {
  48795. m.user_id = nil
  48796. m.adduser_id = nil
  48797. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  48798. }
  48799. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48800. func (m *WxCardVisitMutation) UserIDCleared() bool {
  48801. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  48802. return ok
  48803. }
  48804. // ResetUserID resets all changes to the "user_id" field.
  48805. func (m *WxCardVisitMutation) ResetUserID() {
  48806. m.user_id = nil
  48807. m.adduser_id = nil
  48808. delete(m.clearedFields, wxcardvisit.FieldUserID)
  48809. }
  48810. // SetBotID sets the "bot_id" field.
  48811. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  48812. m.bot_id = &u
  48813. m.addbot_id = nil
  48814. }
  48815. // BotID returns the value of the "bot_id" field in the mutation.
  48816. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  48817. v := m.bot_id
  48818. if v == nil {
  48819. return
  48820. }
  48821. return *v, true
  48822. }
  48823. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  48824. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48826. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  48827. if !m.op.Is(OpUpdateOne) {
  48828. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  48829. }
  48830. if m.id == nil || m.oldValue == nil {
  48831. return v, errors.New("OldBotID requires an ID field in the mutation")
  48832. }
  48833. oldValue, err := m.oldValue(ctx)
  48834. if err != nil {
  48835. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  48836. }
  48837. return oldValue.BotID, nil
  48838. }
  48839. // AddBotID adds u to the "bot_id" field.
  48840. func (m *WxCardVisitMutation) AddBotID(u int64) {
  48841. if m.addbot_id != nil {
  48842. *m.addbot_id += u
  48843. } else {
  48844. m.addbot_id = &u
  48845. }
  48846. }
  48847. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  48848. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  48849. v := m.addbot_id
  48850. if v == nil {
  48851. return
  48852. }
  48853. return *v, true
  48854. }
  48855. // ResetBotID resets all changes to the "bot_id" field.
  48856. func (m *WxCardVisitMutation) ResetBotID() {
  48857. m.bot_id = nil
  48858. m.addbot_id = nil
  48859. }
  48860. // SetBotType sets the "bot_type" field.
  48861. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  48862. m.bot_type = &u
  48863. m.addbot_type = nil
  48864. }
  48865. // BotType returns the value of the "bot_type" field in the mutation.
  48866. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  48867. v := m.bot_type
  48868. if v == nil {
  48869. return
  48870. }
  48871. return *v, true
  48872. }
  48873. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  48874. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  48875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48876. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  48877. if !m.op.Is(OpUpdateOne) {
  48878. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  48879. }
  48880. if m.id == nil || m.oldValue == nil {
  48881. return v, errors.New("OldBotType requires an ID field in the mutation")
  48882. }
  48883. oldValue, err := m.oldValue(ctx)
  48884. if err != nil {
  48885. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  48886. }
  48887. return oldValue.BotType, nil
  48888. }
  48889. // AddBotType adds u to the "bot_type" field.
  48890. func (m *WxCardVisitMutation) AddBotType(u int8) {
  48891. if m.addbot_type != nil {
  48892. *m.addbot_type += u
  48893. } else {
  48894. m.addbot_type = &u
  48895. }
  48896. }
  48897. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  48898. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  48899. v := m.addbot_type
  48900. if v == nil {
  48901. return
  48902. }
  48903. return *v, true
  48904. }
  48905. // ResetBotType resets all changes to the "bot_type" field.
  48906. func (m *WxCardVisitMutation) ResetBotType() {
  48907. m.bot_type = nil
  48908. m.addbot_type = nil
  48909. }
  48910. // Where appends a list predicates to the WxCardVisitMutation builder.
  48911. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  48912. m.predicates = append(m.predicates, ps...)
  48913. }
  48914. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  48915. // users can use type-assertion to append predicates that do not depend on any generated package.
  48916. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  48917. p := make([]predicate.WxCardVisit, len(ps))
  48918. for i := range ps {
  48919. p[i] = ps[i]
  48920. }
  48921. m.Where(p...)
  48922. }
  48923. // Op returns the operation name.
  48924. func (m *WxCardVisitMutation) Op() Op {
  48925. return m.op
  48926. }
  48927. // SetOp allows setting the mutation operation.
  48928. func (m *WxCardVisitMutation) SetOp(op Op) {
  48929. m.op = op
  48930. }
  48931. // Type returns the node type of this mutation (WxCardVisit).
  48932. func (m *WxCardVisitMutation) Type() string {
  48933. return m.typ
  48934. }
  48935. // Fields returns all fields that were changed during this mutation. Note that in
  48936. // order to get all numeric fields that were incremented/decremented, call
  48937. // AddedFields().
  48938. func (m *WxCardVisitMutation) Fields() []string {
  48939. fields := make([]string, 0, 6)
  48940. if m.created_at != nil {
  48941. fields = append(fields, wxcardvisit.FieldCreatedAt)
  48942. }
  48943. if m.updated_at != nil {
  48944. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  48945. }
  48946. if m.deleted_at != nil {
  48947. fields = append(fields, wxcardvisit.FieldDeletedAt)
  48948. }
  48949. if m.user_id != nil {
  48950. fields = append(fields, wxcardvisit.FieldUserID)
  48951. }
  48952. if m.bot_id != nil {
  48953. fields = append(fields, wxcardvisit.FieldBotID)
  48954. }
  48955. if m.bot_type != nil {
  48956. fields = append(fields, wxcardvisit.FieldBotType)
  48957. }
  48958. return fields
  48959. }
  48960. // Field returns the value of a field with the given name. The second boolean
  48961. // return value indicates that this field was not set, or was not defined in the
  48962. // schema.
  48963. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  48964. switch name {
  48965. case wxcardvisit.FieldCreatedAt:
  48966. return m.CreatedAt()
  48967. case wxcardvisit.FieldUpdatedAt:
  48968. return m.UpdatedAt()
  48969. case wxcardvisit.FieldDeletedAt:
  48970. return m.DeletedAt()
  48971. case wxcardvisit.FieldUserID:
  48972. return m.UserID()
  48973. case wxcardvisit.FieldBotID:
  48974. return m.BotID()
  48975. case wxcardvisit.FieldBotType:
  48976. return m.BotType()
  48977. }
  48978. return nil, false
  48979. }
  48980. // OldField returns the old value of the field from the database. An error is
  48981. // returned if the mutation operation is not UpdateOne, or the query to the
  48982. // database failed.
  48983. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48984. switch name {
  48985. case wxcardvisit.FieldCreatedAt:
  48986. return m.OldCreatedAt(ctx)
  48987. case wxcardvisit.FieldUpdatedAt:
  48988. return m.OldUpdatedAt(ctx)
  48989. case wxcardvisit.FieldDeletedAt:
  48990. return m.OldDeletedAt(ctx)
  48991. case wxcardvisit.FieldUserID:
  48992. return m.OldUserID(ctx)
  48993. case wxcardvisit.FieldBotID:
  48994. return m.OldBotID(ctx)
  48995. case wxcardvisit.FieldBotType:
  48996. return m.OldBotType(ctx)
  48997. }
  48998. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  48999. }
  49000. // SetField sets the value of a field with the given name. It returns an error if
  49001. // the field is not defined in the schema, or if the type mismatched the field
  49002. // type.
  49003. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  49004. switch name {
  49005. case wxcardvisit.FieldCreatedAt:
  49006. v, ok := value.(time.Time)
  49007. if !ok {
  49008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49009. }
  49010. m.SetCreatedAt(v)
  49011. return nil
  49012. case wxcardvisit.FieldUpdatedAt:
  49013. v, ok := value.(time.Time)
  49014. if !ok {
  49015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49016. }
  49017. m.SetUpdatedAt(v)
  49018. return nil
  49019. case wxcardvisit.FieldDeletedAt:
  49020. v, ok := value.(time.Time)
  49021. if !ok {
  49022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49023. }
  49024. m.SetDeletedAt(v)
  49025. return nil
  49026. case wxcardvisit.FieldUserID:
  49027. v, ok := value.(uint64)
  49028. if !ok {
  49029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49030. }
  49031. m.SetUserID(v)
  49032. return nil
  49033. case wxcardvisit.FieldBotID:
  49034. v, ok := value.(uint64)
  49035. if !ok {
  49036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49037. }
  49038. m.SetBotID(v)
  49039. return nil
  49040. case wxcardvisit.FieldBotType:
  49041. v, ok := value.(uint8)
  49042. if !ok {
  49043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49044. }
  49045. m.SetBotType(v)
  49046. return nil
  49047. }
  49048. return fmt.Errorf("unknown WxCardVisit field %s", name)
  49049. }
  49050. // AddedFields returns all numeric fields that were incremented/decremented during
  49051. // this mutation.
  49052. func (m *WxCardVisitMutation) AddedFields() []string {
  49053. var fields []string
  49054. if m.adduser_id != nil {
  49055. fields = append(fields, wxcardvisit.FieldUserID)
  49056. }
  49057. if m.addbot_id != nil {
  49058. fields = append(fields, wxcardvisit.FieldBotID)
  49059. }
  49060. if m.addbot_type != nil {
  49061. fields = append(fields, wxcardvisit.FieldBotType)
  49062. }
  49063. return fields
  49064. }
  49065. // AddedField returns the numeric value that was incremented/decremented on a field
  49066. // with the given name. The second boolean return value indicates that this field
  49067. // was not set, or was not defined in the schema.
  49068. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  49069. switch name {
  49070. case wxcardvisit.FieldUserID:
  49071. return m.AddedUserID()
  49072. case wxcardvisit.FieldBotID:
  49073. return m.AddedBotID()
  49074. case wxcardvisit.FieldBotType:
  49075. return m.AddedBotType()
  49076. }
  49077. return nil, false
  49078. }
  49079. // AddField adds the value to the field with the given name. It returns an error if
  49080. // the field is not defined in the schema, or if the type mismatched the field
  49081. // type.
  49082. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  49083. switch name {
  49084. case wxcardvisit.FieldUserID:
  49085. v, ok := value.(int64)
  49086. if !ok {
  49087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49088. }
  49089. m.AddUserID(v)
  49090. return nil
  49091. case wxcardvisit.FieldBotID:
  49092. v, ok := value.(int64)
  49093. if !ok {
  49094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49095. }
  49096. m.AddBotID(v)
  49097. return nil
  49098. case wxcardvisit.FieldBotType:
  49099. v, ok := value.(int8)
  49100. if !ok {
  49101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49102. }
  49103. m.AddBotType(v)
  49104. return nil
  49105. }
  49106. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  49107. }
  49108. // ClearedFields returns all nullable fields that were cleared during this
  49109. // mutation.
  49110. func (m *WxCardVisitMutation) ClearedFields() []string {
  49111. var fields []string
  49112. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  49113. fields = append(fields, wxcardvisit.FieldDeletedAt)
  49114. }
  49115. if m.FieldCleared(wxcardvisit.FieldUserID) {
  49116. fields = append(fields, wxcardvisit.FieldUserID)
  49117. }
  49118. return fields
  49119. }
  49120. // FieldCleared returns a boolean indicating if a field with the given name was
  49121. // cleared in this mutation.
  49122. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  49123. _, ok := m.clearedFields[name]
  49124. return ok
  49125. }
  49126. // ClearField clears the value of the field with the given name. It returns an
  49127. // error if the field is not defined in the schema.
  49128. func (m *WxCardVisitMutation) ClearField(name string) error {
  49129. switch name {
  49130. case wxcardvisit.FieldDeletedAt:
  49131. m.ClearDeletedAt()
  49132. return nil
  49133. case wxcardvisit.FieldUserID:
  49134. m.ClearUserID()
  49135. return nil
  49136. }
  49137. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  49138. }
  49139. // ResetField resets all changes in the mutation for the field with the given name.
  49140. // It returns an error if the field is not defined in the schema.
  49141. func (m *WxCardVisitMutation) ResetField(name string) error {
  49142. switch name {
  49143. case wxcardvisit.FieldCreatedAt:
  49144. m.ResetCreatedAt()
  49145. return nil
  49146. case wxcardvisit.FieldUpdatedAt:
  49147. m.ResetUpdatedAt()
  49148. return nil
  49149. case wxcardvisit.FieldDeletedAt:
  49150. m.ResetDeletedAt()
  49151. return nil
  49152. case wxcardvisit.FieldUserID:
  49153. m.ResetUserID()
  49154. return nil
  49155. case wxcardvisit.FieldBotID:
  49156. m.ResetBotID()
  49157. return nil
  49158. case wxcardvisit.FieldBotType:
  49159. m.ResetBotType()
  49160. return nil
  49161. }
  49162. return fmt.Errorf("unknown WxCardVisit field %s", name)
  49163. }
  49164. // AddedEdges returns all edge names that were set/added in this mutation.
  49165. func (m *WxCardVisitMutation) AddedEdges() []string {
  49166. edges := make([]string, 0, 0)
  49167. return edges
  49168. }
  49169. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49170. // name in this mutation.
  49171. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  49172. return nil
  49173. }
  49174. // RemovedEdges returns all edge names that were removed in this mutation.
  49175. func (m *WxCardVisitMutation) RemovedEdges() []string {
  49176. edges := make([]string, 0, 0)
  49177. return edges
  49178. }
  49179. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49180. // the given name in this mutation.
  49181. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  49182. return nil
  49183. }
  49184. // ClearedEdges returns all edge names that were cleared in this mutation.
  49185. func (m *WxCardVisitMutation) ClearedEdges() []string {
  49186. edges := make([]string, 0, 0)
  49187. return edges
  49188. }
  49189. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49190. // was cleared in this mutation.
  49191. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  49192. return false
  49193. }
  49194. // ClearEdge clears the value of the edge with the given name. It returns an error
  49195. // if that edge is not defined in the schema.
  49196. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  49197. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  49198. }
  49199. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49200. // It returns an error if the edge is not defined in the schema.
  49201. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  49202. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  49203. }
  49204. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  49205. type XunjiMutation struct {
  49206. config
  49207. op Op
  49208. typ string
  49209. id *uint64
  49210. created_at *time.Time
  49211. updated_at *time.Time
  49212. status *uint8
  49213. addstatus *int8
  49214. deleted_at *time.Time
  49215. app_key *string
  49216. app_secret *string
  49217. token *string
  49218. encoding_key *string
  49219. organization_id *uint64
  49220. addorganization_id *int64
  49221. clearedFields map[string]struct{}
  49222. done bool
  49223. oldValue func(context.Context) (*Xunji, error)
  49224. predicates []predicate.Xunji
  49225. }
  49226. var _ ent.Mutation = (*XunjiMutation)(nil)
  49227. // xunjiOption allows management of the mutation configuration using functional options.
  49228. type xunjiOption func(*XunjiMutation)
  49229. // newXunjiMutation creates new mutation for the Xunji entity.
  49230. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  49231. m := &XunjiMutation{
  49232. config: c,
  49233. op: op,
  49234. typ: TypeXunji,
  49235. clearedFields: make(map[string]struct{}),
  49236. }
  49237. for _, opt := range opts {
  49238. opt(m)
  49239. }
  49240. return m
  49241. }
  49242. // withXunjiID sets the ID field of the mutation.
  49243. func withXunjiID(id uint64) xunjiOption {
  49244. return func(m *XunjiMutation) {
  49245. var (
  49246. err error
  49247. once sync.Once
  49248. value *Xunji
  49249. )
  49250. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  49251. once.Do(func() {
  49252. if m.done {
  49253. err = errors.New("querying old values post mutation is not allowed")
  49254. } else {
  49255. value, err = m.Client().Xunji.Get(ctx, id)
  49256. }
  49257. })
  49258. return value, err
  49259. }
  49260. m.id = &id
  49261. }
  49262. }
  49263. // withXunji sets the old Xunji of the mutation.
  49264. func withXunji(node *Xunji) xunjiOption {
  49265. return func(m *XunjiMutation) {
  49266. m.oldValue = func(context.Context) (*Xunji, error) {
  49267. return node, nil
  49268. }
  49269. m.id = &node.ID
  49270. }
  49271. }
  49272. // Client returns a new `ent.Client` from the mutation. If the mutation was
  49273. // executed in a transaction (ent.Tx), a transactional client is returned.
  49274. func (m XunjiMutation) Client() *Client {
  49275. client := &Client{config: m.config}
  49276. client.init()
  49277. return client
  49278. }
  49279. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  49280. // it returns an error otherwise.
  49281. func (m XunjiMutation) Tx() (*Tx, error) {
  49282. if _, ok := m.driver.(*txDriver); !ok {
  49283. return nil, errors.New("ent: mutation is not running in a transaction")
  49284. }
  49285. tx := &Tx{config: m.config}
  49286. tx.init()
  49287. return tx, nil
  49288. }
  49289. // SetID sets the value of the id field. Note that this
  49290. // operation is only accepted on creation of Xunji entities.
  49291. func (m *XunjiMutation) SetID(id uint64) {
  49292. m.id = &id
  49293. }
  49294. // ID returns the ID value in the mutation. Note that the ID is only available
  49295. // if it was provided to the builder or after it was returned from the database.
  49296. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  49297. if m.id == nil {
  49298. return
  49299. }
  49300. return *m.id, true
  49301. }
  49302. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  49303. // That means, if the mutation is applied within a transaction with an isolation level such
  49304. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  49305. // or updated by the mutation.
  49306. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  49307. switch {
  49308. case m.op.Is(OpUpdateOne | OpDeleteOne):
  49309. id, exists := m.ID()
  49310. if exists {
  49311. return []uint64{id}, nil
  49312. }
  49313. fallthrough
  49314. case m.op.Is(OpUpdate | OpDelete):
  49315. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  49316. default:
  49317. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  49318. }
  49319. }
  49320. // SetCreatedAt sets the "created_at" field.
  49321. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  49322. m.created_at = &t
  49323. }
  49324. // CreatedAt returns the value of the "created_at" field in the mutation.
  49325. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  49326. v := m.created_at
  49327. if v == nil {
  49328. return
  49329. }
  49330. return *v, true
  49331. }
  49332. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  49333. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49335. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  49336. if !m.op.Is(OpUpdateOne) {
  49337. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  49338. }
  49339. if m.id == nil || m.oldValue == nil {
  49340. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  49341. }
  49342. oldValue, err := m.oldValue(ctx)
  49343. if err != nil {
  49344. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  49345. }
  49346. return oldValue.CreatedAt, nil
  49347. }
  49348. // ResetCreatedAt resets all changes to the "created_at" field.
  49349. func (m *XunjiMutation) ResetCreatedAt() {
  49350. m.created_at = nil
  49351. }
  49352. // SetUpdatedAt sets the "updated_at" field.
  49353. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  49354. m.updated_at = &t
  49355. }
  49356. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  49357. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  49358. v := m.updated_at
  49359. if v == nil {
  49360. return
  49361. }
  49362. return *v, true
  49363. }
  49364. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  49365. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49367. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  49368. if !m.op.Is(OpUpdateOne) {
  49369. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  49370. }
  49371. if m.id == nil || m.oldValue == nil {
  49372. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  49373. }
  49374. oldValue, err := m.oldValue(ctx)
  49375. if err != nil {
  49376. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  49377. }
  49378. return oldValue.UpdatedAt, nil
  49379. }
  49380. // ResetUpdatedAt resets all changes to the "updated_at" field.
  49381. func (m *XunjiMutation) ResetUpdatedAt() {
  49382. m.updated_at = nil
  49383. }
  49384. // SetStatus sets the "status" field.
  49385. func (m *XunjiMutation) SetStatus(u uint8) {
  49386. m.status = &u
  49387. m.addstatus = nil
  49388. }
  49389. // Status returns the value of the "status" field in the mutation.
  49390. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  49391. v := m.status
  49392. if v == nil {
  49393. return
  49394. }
  49395. return *v, true
  49396. }
  49397. // OldStatus returns the old "status" field's value of the Xunji entity.
  49398. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49400. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  49401. if !m.op.Is(OpUpdateOne) {
  49402. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  49403. }
  49404. if m.id == nil || m.oldValue == nil {
  49405. return v, errors.New("OldStatus requires an ID field in the mutation")
  49406. }
  49407. oldValue, err := m.oldValue(ctx)
  49408. if err != nil {
  49409. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  49410. }
  49411. return oldValue.Status, nil
  49412. }
  49413. // AddStatus adds u to the "status" field.
  49414. func (m *XunjiMutation) AddStatus(u int8) {
  49415. if m.addstatus != nil {
  49416. *m.addstatus += u
  49417. } else {
  49418. m.addstatus = &u
  49419. }
  49420. }
  49421. // AddedStatus returns the value that was added to the "status" field in this mutation.
  49422. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  49423. v := m.addstatus
  49424. if v == nil {
  49425. return
  49426. }
  49427. return *v, true
  49428. }
  49429. // ClearStatus clears the value of the "status" field.
  49430. func (m *XunjiMutation) ClearStatus() {
  49431. m.status = nil
  49432. m.addstatus = nil
  49433. m.clearedFields[xunji.FieldStatus] = struct{}{}
  49434. }
  49435. // StatusCleared returns if the "status" field was cleared in this mutation.
  49436. func (m *XunjiMutation) StatusCleared() bool {
  49437. _, ok := m.clearedFields[xunji.FieldStatus]
  49438. return ok
  49439. }
  49440. // ResetStatus resets all changes to the "status" field.
  49441. func (m *XunjiMutation) ResetStatus() {
  49442. m.status = nil
  49443. m.addstatus = nil
  49444. delete(m.clearedFields, xunji.FieldStatus)
  49445. }
  49446. // SetDeletedAt sets the "deleted_at" field.
  49447. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  49448. m.deleted_at = &t
  49449. }
  49450. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  49451. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  49452. v := m.deleted_at
  49453. if v == nil {
  49454. return
  49455. }
  49456. return *v, true
  49457. }
  49458. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  49459. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49461. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  49462. if !m.op.Is(OpUpdateOne) {
  49463. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  49464. }
  49465. if m.id == nil || m.oldValue == nil {
  49466. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  49467. }
  49468. oldValue, err := m.oldValue(ctx)
  49469. if err != nil {
  49470. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  49471. }
  49472. return oldValue.DeletedAt, nil
  49473. }
  49474. // ClearDeletedAt clears the value of the "deleted_at" field.
  49475. func (m *XunjiMutation) ClearDeletedAt() {
  49476. m.deleted_at = nil
  49477. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  49478. }
  49479. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  49480. func (m *XunjiMutation) DeletedAtCleared() bool {
  49481. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  49482. return ok
  49483. }
  49484. // ResetDeletedAt resets all changes to the "deleted_at" field.
  49485. func (m *XunjiMutation) ResetDeletedAt() {
  49486. m.deleted_at = nil
  49487. delete(m.clearedFields, xunji.FieldDeletedAt)
  49488. }
  49489. // SetAppKey sets the "app_key" field.
  49490. func (m *XunjiMutation) SetAppKey(s string) {
  49491. m.app_key = &s
  49492. }
  49493. // AppKey returns the value of the "app_key" field in the mutation.
  49494. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  49495. v := m.app_key
  49496. if v == nil {
  49497. return
  49498. }
  49499. return *v, true
  49500. }
  49501. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  49502. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49504. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  49505. if !m.op.Is(OpUpdateOne) {
  49506. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  49507. }
  49508. if m.id == nil || m.oldValue == nil {
  49509. return v, errors.New("OldAppKey requires an ID field in the mutation")
  49510. }
  49511. oldValue, err := m.oldValue(ctx)
  49512. if err != nil {
  49513. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  49514. }
  49515. return oldValue.AppKey, nil
  49516. }
  49517. // ClearAppKey clears the value of the "app_key" field.
  49518. func (m *XunjiMutation) ClearAppKey() {
  49519. m.app_key = nil
  49520. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  49521. }
  49522. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  49523. func (m *XunjiMutation) AppKeyCleared() bool {
  49524. _, ok := m.clearedFields[xunji.FieldAppKey]
  49525. return ok
  49526. }
  49527. // ResetAppKey resets all changes to the "app_key" field.
  49528. func (m *XunjiMutation) ResetAppKey() {
  49529. m.app_key = nil
  49530. delete(m.clearedFields, xunji.FieldAppKey)
  49531. }
  49532. // SetAppSecret sets the "app_secret" field.
  49533. func (m *XunjiMutation) SetAppSecret(s string) {
  49534. m.app_secret = &s
  49535. }
  49536. // AppSecret returns the value of the "app_secret" field in the mutation.
  49537. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  49538. v := m.app_secret
  49539. if v == nil {
  49540. return
  49541. }
  49542. return *v, true
  49543. }
  49544. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  49545. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49547. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  49548. if !m.op.Is(OpUpdateOne) {
  49549. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  49550. }
  49551. if m.id == nil || m.oldValue == nil {
  49552. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  49553. }
  49554. oldValue, err := m.oldValue(ctx)
  49555. if err != nil {
  49556. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  49557. }
  49558. return oldValue.AppSecret, nil
  49559. }
  49560. // ClearAppSecret clears the value of the "app_secret" field.
  49561. func (m *XunjiMutation) ClearAppSecret() {
  49562. m.app_secret = nil
  49563. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  49564. }
  49565. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  49566. func (m *XunjiMutation) AppSecretCleared() bool {
  49567. _, ok := m.clearedFields[xunji.FieldAppSecret]
  49568. return ok
  49569. }
  49570. // ResetAppSecret resets all changes to the "app_secret" field.
  49571. func (m *XunjiMutation) ResetAppSecret() {
  49572. m.app_secret = nil
  49573. delete(m.clearedFields, xunji.FieldAppSecret)
  49574. }
  49575. // SetToken sets the "token" field.
  49576. func (m *XunjiMutation) SetToken(s string) {
  49577. m.token = &s
  49578. }
  49579. // Token returns the value of the "token" field in the mutation.
  49580. func (m *XunjiMutation) Token() (r string, exists bool) {
  49581. v := m.token
  49582. if v == nil {
  49583. return
  49584. }
  49585. return *v, true
  49586. }
  49587. // OldToken returns the old "token" field's value of the Xunji entity.
  49588. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49590. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  49591. if !m.op.Is(OpUpdateOne) {
  49592. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  49593. }
  49594. if m.id == nil || m.oldValue == nil {
  49595. return v, errors.New("OldToken requires an ID field in the mutation")
  49596. }
  49597. oldValue, err := m.oldValue(ctx)
  49598. if err != nil {
  49599. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  49600. }
  49601. return oldValue.Token, nil
  49602. }
  49603. // ClearToken clears the value of the "token" field.
  49604. func (m *XunjiMutation) ClearToken() {
  49605. m.token = nil
  49606. m.clearedFields[xunji.FieldToken] = struct{}{}
  49607. }
  49608. // TokenCleared returns if the "token" field was cleared in this mutation.
  49609. func (m *XunjiMutation) TokenCleared() bool {
  49610. _, ok := m.clearedFields[xunji.FieldToken]
  49611. return ok
  49612. }
  49613. // ResetToken resets all changes to the "token" field.
  49614. func (m *XunjiMutation) ResetToken() {
  49615. m.token = nil
  49616. delete(m.clearedFields, xunji.FieldToken)
  49617. }
  49618. // SetEncodingKey sets the "encoding_key" field.
  49619. func (m *XunjiMutation) SetEncodingKey(s string) {
  49620. m.encoding_key = &s
  49621. }
  49622. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  49623. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  49624. v := m.encoding_key
  49625. if v == nil {
  49626. return
  49627. }
  49628. return *v, true
  49629. }
  49630. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  49631. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49633. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  49634. if !m.op.Is(OpUpdateOne) {
  49635. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  49636. }
  49637. if m.id == nil || m.oldValue == nil {
  49638. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  49639. }
  49640. oldValue, err := m.oldValue(ctx)
  49641. if err != nil {
  49642. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  49643. }
  49644. return oldValue.EncodingKey, nil
  49645. }
  49646. // ClearEncodingKey clears the value of the "encoding_key" field.
  49647. func (m *XunjiMutation) ClearEncodingKey() {
  49648. m.encoding_key = nil
  49649. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  49650. }
  49651. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  49652. func (m *XunjiMutation) EncodingKeyCleared() bool {
  49653. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  49654. return ok
  49655. }
  49656. // ResetEncodingKey resets all changes to the "encoding_key" field.
  49657. func (m *XunjiMutation) ResetEncodingKey() {
  49658. m.encoding_key = nil
  49659. delete(m.clearedFields, xunji.FieldEncodingKey)
  49660. }
  49661. // SetOrganizationID sets the "organization_id" field.
  49662. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  49663. m.organization_id = &u
  49664. m.addorganization_id = nil
  49665. }
  49666. // OrganizationID returns the value of the "organization_id" field in the mutation.
  49667. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  49668. v := m.organization_id
  49669. if v == nil {
  49670. return
  49671. }
  49672. return *v, true
  49673. }
  49674. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  49675. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  49676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49677. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  49678. if !m.op.Is(OpUpdateOne) {
  49679. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  49680. }
  49681. if m.id == nil || m.oldValue == nil {
  49682. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  49683. }
  49684. oldValue, err := m.oldValue(ctx)
  49685. if err != nil {
  49686. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  49687. }
  49688. return oldValue.OrganizationID, nil
  49689. }
  49690. // AddOrganizationID adds u to the "organization_id" field.
  49691. func (m *XunjiMutation) AddOrganizationID(u int64) {
  49692. if m.addorganization_id != nil {
  49693. *m.addorganization_id += u
  49694. } else {
  49695. m.addorganization_id = &u
  49696. }
  49697. }
  49698. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  49699. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  49700. v := m.addorganization_id
  49701. if v == nil {
  49702. return
  49703. }
  49704. return *v, true
  49705. }
  49706. // ResetOrganizationID resets all changes to the "organization_id" field.
  49707. func (m *XunjiMutation) ResetOrganizationID() {
  49708. m.organization_id = nil
  49709. m.addorganization_id = nil
  49710. }
  49711. // Where appends a list predicates to the XunjiMutation builder.
  49712. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  49713. m.predicates = append(m.predicates, ps...)
  49714. }
  49715. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  49716. // users can use type-assertion to append predicates that do not depend on any generated package.
  49717. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  49718. p := make([]predicate.Xunji, len(ps))
  49719. for i := range ps {
  49720. p[i] = ps[i]
  49721. }
  49722. m.Where(p...)
  49723. }
  49724. // Op returns the operation name.
  49725. func (m *XunjiMutation) Op() Op {
  49726. return m.op
  49727. }
  49728. // SetOp allows setting the mutation operation.
  49729. func (m *XunjiMutation) SetOp(op Op) {
  49730. m.op = op
  49731. }
  49732. // Type returns the node type of this mutation (Xunji).
  49733. func (m *XunjiMutation) Type() string {
  49734. return m.typ
  49735. }
  49736. // Fields returns all fields that were changed during this mutation. Note that in
  49737. // order to get all numeric fields that were incremented/decremented, call
  49738. // AddedFields().
  49739. func (m *XunjiMutation) Fields() []string {
  49740. fields := make([]string, 0, 9)
  49741. if m.created_at != nil {
  49742. fields = append(fields, xunji.FieldCreatedAt)
  49743. }
  49744. if m.updated_at != nil {
  49745. fields = append(fields, xunji.FieldUpdatedAt)
  49746. }
  49747. if m.status != nil {
  49748. fields = append(fields, xunji.FieldStatus)
  49749. }
  49750. if m.deleted_at != nil {
  49751. fields = append(fields, xunji.FieldDeletedAt)
  49752. }
  49753. if m.app_key != nil {
  49754. fields = append(fields, xunji.FieldAppKey)
  49755. }
  49756. if m.app_secret != nil {
  49757. fields = append(fields, xunji.FieldAppSecret)
  49758. }
  49759. if m.token != nil {
  49760. fields = append(fields, xunji.FieldToken)
  49761. }
  49762. if m.encoding_key != nil {
  49763. fields = append(fields, xunji.FieldEncodingKey)
  49764. }
  49765. if m.organization_id != nil {
  49766. fields = append(fields, xunji.FieldOrganizationID)
  49767. }
  49768. return fields
  49769. }
  49770. // Field returns the value of a field with the given name. The second boolean
  49771. // return value indicates that this field was not set, or was not defined in the
  49772. // schema.
  49773. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  49774. switch name {
  49775. case xunji.FieldCreatedAt:
  49776. return m.CreatedAt()
  49777. case xunji.FieldUpdatedAt:
  49778. return m.UpdatedAt()
  49779. case xunji.FieldStatus:
  49780. return m.Status()
  49781. case xunji.FieldDeletedAt:
  49782. return m.DeletedAt()
  49783. case xunji.FieldAppKey:
  49784. return m.AppKey()
  49785. case xunji.FieldAppSecret:
  49786. return m.AppSecret()
  49787. case xunji.FieldToken:
  49788. return m.Token()
  49789. case xunji.FieldEncodingKey:
  49790. return m.EncodingKey()
  49791. case xunji.FieldOrganizationID:
  49792. return m.OrganizationID()
  49793. }
  49794. return nil, false
  49795. }
  49796. // OldField returns the old value of the field from the database. An error is
  49797. // returned if the mutation operation is not UpdateOne, or the query to the
  49798. // database failed.
  49799. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49800. switch name {
  49801. case xunji.FieldCreatedAt:
  49802. return m.OldCreatedAt(ctx)
  49803. case xunji.FieldUpdatedAt:
  49804. return m.OldUpdatedAt(ctx)
  49805. case xunji.FieldStatus:
  49806. return m.OldStatus(ctx)
  49807. case xunji.FieldDeletedAt:
  49808. return m.OldDeletedAt(ctx)
  49809. case xunji.FieldAppKey:
  49810. return m.OldAppKey(ctx)
  49811. case xunji.FieldAppSecret:
  49812. return m.OldAppSecret(ctx)
  49813. case xunji.FieldToken:
  49814. return m.OldToken(ctx)
  49815. case xunji.FieldEncodingKey:
  49816. return m.OldEncodingKey(ctx)
  49817. case xunji.FieldOrganizationID:
  49818. return m.OldOrganizationID(ctx)
  49819. }
  49820. return nil, fmt.Errorf("unknown Xunji field %s", name)
  49821. }
  49822. // SetField sets the value of a field with the given name. It returns an error if
  49823. // the field is not defined in the schema, or if the type mismatched the field
  49824. // type.
  49825. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  49826. switch name {
  49827. case xunji.FieldCreatedAt:
  49828. v, ok := value.(time.Time)
  49829. if !ok {
  49830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49831. }
  49832. m.SetCreatedAt(v)
  49833. return nil
  49834. case xunji.FieldUpdatedAt:
  49835. v, ok := value.(time.Time)
  49836. if !ok {
  49837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49838. }
  49839. m.SetUpdatedAt(v)
  49840. return nil
  49841. case xunji.FieldStatus:
  49842. v, ok := value.(uint8)
  49843. if !ok {
  49844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49845. }
  49846. m.SetStatus(v)
  49847. return nil
  49848. case xunji.FieldDeletedAt:
  49849. v, ok := value.(time.Time)
  49850. if !ok {
  49851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49852. }
  49853. m.SetDeletedAt(v)
  49854. return nil
  49855. case xunji.FieldAppKey:
  49856. v, ok := value.(string)
  49857. if !ok {
  49858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49859. }
  49860. m.SetAppKey(v)
  49861. return nil
  49862. case xunji.FieldAppSecret:
  49863. v, ok := value.(string)
  49864. if !ok {
  49865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49866. }
  49867. m.SetAppSecret(v)
  49868. return nil
  49869. case xunji.FieldToken:
  49870. v, ok := value.(string)
  49871. if !ok {
  49872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49873. }
  49874. m.SetToken(v)
  49875. return nil
  49876. case xunji.FieldEncodingKey:
  49877. v, ok := value.(string)
  49878. if !ok {
  49879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49880. }
  49881. m.SetEncodingKey(v)
  49882. return nil
  49883. case xunji.FieldOrganizationID:
  49884. v, ok := value.(uint64)
  49885. if !ok {
  49886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49887. }
  49888. m.SetOrganizationID(v)
  49889. return nil
  49890. }
  49891. return fmt.Errorf("unknown Xunji field %s", name)
  49892. }
  49893. // AddedFields returns all numeric fields that were incremented/decremented during
  49894. // this mutation.
  49895. func (m *XunjiMutation) AddedFields() []string {
  49896. var fields []string
  49897. if m.addstatus != nil {
  49898. fields = append(fields, xunji.FieldStatus)
  49899. }
  49900. if m.addorganization_id != nil {
  49901. fields = append(fields, xunji.FieldOrganizationID)
  49902. }
  49903. return fields
  49904. }
  49905. // AddedField returns the numeric value that was incremented/decremented on a field
  49906. // with the given name. The second boolean return value indicates that this field
  49907. // was not set, or was not defined in the schema.
  49908. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  49909. switch name {
  49910. case xunji.FieldStatus:
  49911. return m.AddedStatus()
  49912. case xunji.FieldOrganizationID:
  49913. return m.AddedOrganizationID()
  49914. }
  49915. return nil, false
  49916. }
  49917. // AddField adds the value to the field with the given name. It returns an error if
  49918. // the field is not defined in the schema, or if the type mismatched the field
  49919. // type.
  49920. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  49921. switch name {
  49922. case xunji.FieldStatus:
  49923. v, ok := value.(int8)
  49924. if !ok {
  49925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49926. }
  49927. m.AddStatus(v)
  49928. return nil
  49929. case xunji.FieldOrganizationID:
  49930. v, ok := value.(int64)
  49931. if !ok {
  49932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49933. }
  49934. m.AddOrganizationID(v)
  49935. return nil
  49936. }
  49937. return fmt.Errorf("unknown Xunji numeric field %s", name)
  49938. }
  49939. // ClearedFields returns all nullable fields that were cleared during this
  49940. // mutation.
  49941. func (m *XunjiMutation) ClearedFields() []string {
  49942. var fields []string
  49943. if m.FieldCleared(xunji.FieldStatus) {
  49944. fields = append(fields, xunji.FieldStatus)
  49945. }
  49946. if m.FieldCleared(xunji.FieldDeletedAt) {
  49947. fields = append(fields, xunji.FieldDeletedAt)
  49948. }
  49949. if m.FieldCleared(xunji.FieldAppKey) {
  49950. fields = append(fields, xunji.FieldAppKey)
  49951. }
  49952. if m.FieldCleared(xunji.FieldAppSecret) {
  49953. fields = append(fields, xunji.FieldAppSecret)
  49954. }
  49955. if m.FieldCleared(xunji.FieldToken) {
  49956. fields = append(fields, xunji.FieldToken)
  49957. }
  49958. if m.FieldCleared(xunji.FieldEncodingKey) {
  49959. fields = append(fields, xunji.FieldEncodingKey)
  49960. }
  49961. return fields
  49962. }
  49963. // FieldCleared returns a boolean indicating if a field with the given name was
  49964. // cleared in this mutation.
  49965. func (m *XunjiMutation) FieldCleared(name string) bool {
  49966. _, ok := m.clearedFields[name]
  49967. return ok
  49968. }
  49969. // ClearField clears the value of the field with the given name. It returns an
  49970. // error if the field is not defined in the schema.
  49971. func (m *XunjiMutation) ClearField(name string) error {
  49972. switch name {
  49973. case xunji.FieldStatus:
  49974. m.ClearStatus()
  49975. return nil
  49976. case xunji.FieldDeletedAt:
  49977. m.ClearDeletedAt()
  49978. return nil
  49979. case xunji.FieldAppKey:
  49980. m.ClearAppKey()
  49981. return nil
  49982. case xunji.FieldAppSecret:
  49983. m.ClearAppSecret()
  49984. return nil
  49985. case xunji.FieldToken:
  49986. m.ClearToken()
  49987. return nil
  49988. case xunji.FieldEncodingKey:
  49989. m.ClearEncodingKey()
  49990. return nil
  49991. }
  49992. return fmt.Errorf("unknown Xunji nullable field %s", name)
  49993. }
  49994. // ResetField resets all changes in the mutation for the field with the given name.
  49995. // It returns an error if the field is not defined in the schema.
  49996. func (m *XunjiMutation) ResetField(name string) error {
  49997. switch name {
  49998. case xunji.FieldCreatedAt:
  49999. m.ResetCreatedAt()
  50000. return nil
  50001. case xunji.FieldUpdatedAt:
  50002. m.ResetUpdatedAt()
  50003. return nil
  50004. case xunji.FieldStatus:
  50005. m.ResetStatus()
  50006. return nil
  50007. case xunji.FieldDeletedAt:
  50008. m.ResetDeletedAt()
  50009. return nil
  50010. case xunji.FieldAppKey:
  50011. m.ResetAppKey()
  50012. return nil
  50013. case xunji.FieldAppSecret:
  50014. m.ResetAppSecret()
  50015. return nil
  50016. case xunji.FieldToken:
  50017. m.ResetToken()
  50018. return nil
  50019. case xunji.FieldEncodingKey:
  50020. m.ResetEncodingKey()
  50021. return nil
  50022. case xunji.FieldOrganizationID:
  50023. m.ResetOrganizationID()
  50024. return nil
  50025. }
  50026. return fmt.Errorf("unknown Xunji field %s", name)
  50027. }
  50028. // AddedEdges returns all edge names that were set/added in this mutation.
  50029. func (m *XunjiMutation) AddedEdges() []string {
  50030. edges := make([]string, 0, 0)
  50031. return edges
  50032. }
  50033. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50034. // name in this mutation.
  50035. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  50036. return nil
  50037. }
  50038. // RemovedEdges returns all edge names that were removed in this mutation.
  50039. func (m *XunjiMutation) RemovedEdges() []string {
  50040. edges := make([]string, 0, 0)
  50041. return edges
  50042. }
  50043. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50044. // the given name in this mutation.
  50045. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  50046. return nil
  50047. }
  50048. // ClearedEdges returns all edge names that were cleared in this mutation.
  50049. func (m *XunjiMutation) ClearedEdges() []string {
  50050. edges := make([]string, 0, 0)
  50051. return edges
  50052. }
  50053. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50054. // was cleared in this mutation.
  50055. func (m *XunjiMutation) EdgeCleared(name string) bool {
  50056. return false
  50057. }
  50058. // ClearEdge clears the value of the edge with the given name. It returns an error
  50059. // if that edge is not defined in the schema.
  50060. func (m *XunjiMutation) ClearEdge(name string) error {
  50061. return fmt.Errorf("unknown Xunji unique edge %s", name)
  50062. }
  50063. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50064. // It returns an error if the edge is not defined in the schema.
  50065. func (m *XunjiMutation) ResetEdge(name string) error {
  50066. return fmt.Errorf("unknown Xunji edge %s", name)
  50067. }
  50068. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  50069. type XunjiServiceMutation struct {
  50070. config
  50071. op Op
  50072. typ string
  50073. id *uint64
  50074. created_at *time.Time
  50075. updated_at *time.Time
  50076. status *uint8
  50077. addstatus *int8
  50078. deleted_at *time.Time
  50079. xunji_id *uint64
  50080. addxunji_id *int64
  50081. organization_id *uint64
  50082. addorganization_id *int64
  50083. wxid *string
  50084. api_base *string
  50085. api_key *string
  50086. clearedFields map[string]struct{}
  50087. agent *uint64
  50088. clearedagent bool
  50089. done bool
  50090. oldValue func(context.Context) (*XunjiService, error)
  50091. predicates []predicate.XunjiService
  50092. }
  50093. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  50094. // xunjiserviceOption allows management of the mutation configuration using functional options.
  50095. type xunjiserviceOption func(*XunjiServiceMutation)
  50096. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  50097. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  50098. m := &XunjiServiceMutation{
  50099. config: c,
  50100. op: op,
  50101. typ: TypeXunjiService,
  50102. clearedFields: make(map[string]struct{}),
  50103. }
  50104. for _, opt := range opts {
  50105. opt(m)
  50106. }
  50107. return m
  50108. }
  50109. // withXunjiServiceID sets the ID field of the mutation.
  50110. func withXunjiServiceID(id uint64) xunjiserviceOption {
  50111. return func(m *XunjiServiceMutation) {
  50112. var (
  50113. err error
  50114. once sync.Once
  50115. value *XunjiService
  50116. )
  50117. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  50118. once.Do(func() {
  50119. if m.done {
  50120. err = errors.New("querying old values post mutation is not allowed")
  50121. } else {
  50122. value, err = m.Client().XunjiService.Get(ctx, id)
  50123. }
  50124. })
  50125. return value, err
  50126. }
  50127. m.id = &id
  50128. }
  50129. }
  50130. // withXunjiService sets the old XunjiService of the mutation.
  50131. func withXunjiService(node *XunjiService) xunjiserviceOption {
  50132. return func(m *XunjiServiceMutation) {
  50133. m.oldValue = func(context.Context) (*XunjiService, error) {
  50134. return node, nil
  50135. }
  50136. m.id = &node.ID
  50137. }
  50138. }
  50139. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50140. // executed in a transaction (ent.Tx), a transactional client is returned.
  50141. func (m XunjiServiceMutation) Client() *Client {
  50142. client := &Client{config: m.config}
  50143. client.init()
  50144. return client
  50145. }
  50146. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50147. // it returns an error otherwise.
  50148. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  50149. if _, ok := m.driver.(*txDriver); !ok {
  50150. return nil, errors.New("ent: mutation is not running in a transaction")
  50151. }
  50152. tx := &Tx{config: m.config}
  50153. tx.init()
  50154. return tx, nil
  50155. }
  50156. // SetID sets the value of the id field. Note that this
  50157. // operation is only accepted on creation of XunjiService entities.
  50158. func (m *XunjiServiceMutation) SetID(id uint64) {
  50159. m.id = &id
  50160. }
  50161. // ID returns the ID value in the mutation. Note that the ID is only available
  50162. // if it was provided to the builder or after it was returned from the database.
  50163. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  50164. if m.id == nil {
  50165. return
  50166. }
  50167. return *m.id, true
  50168. }
  50169. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50170. // That means, if the mutation is applied within a transaction with an isolation level such
  50171. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50172. // or updated by the mutation.
  50173. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  50174. switch {
  50175. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50176. id, exists := m.ID()
  50177. if exists {
  50178. return []uint64{id}, nil
  50179. }
  50180. fallthrough
  50181. case m.op.Is(OpUpdate | OpDelete):
  50182. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  50183. default:
  50184. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50185. }
  50186. }
  50187. // SetCreatedAt sets the "created_at" field.
  50188. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  50189. m.created_at = &t
  50190. }
  50191. // CreatedAt returns the value of the "created_at" field in the mutation.
  50192. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  50193. v := m.created_at
  50194. if v == nil {
  50195. return
  50196. }
  50197. return *v, true
  50198. }
  50199. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  50200. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50202. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50203. if !m.op.Is(OpUpdateOne) {
  50204. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50205. }
  50206. if m.id == nil || m.oldValue == nil {
  50207. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50208. }
  50209. oldValue, err := m.oldValue(ctx)
  50210. if err != nil {
  50211. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50212. }
  50213. return oldValue.CreatedAt, nil
  50214. }
  50215. // ResetCreatedAt resets all changes to the "created_at" field.
  50216. func (m *XunjiServiceMutation) ResetCreatedAt() {
  50217. m.created_at = nil
  50218. }
  50219. // SetUpdatedAt sets the "updated_at" field.
  50220. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  50221. m.updated_at = &t
  50222. }
  50223. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50224. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  50225. v := m.updated_at
  50226. if v == nil {
  50227. return
  50228. }
  50229. return *v, true
  50230. }
  50231. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  50232. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50234. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50235. if !m.op.Is(OpUpdateOne) {
  50236. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50237. }
  50238. if m.id == nil || m.oldValue == nil {
  50239. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50240. }
  50241. oldValue, err := m.oldValue(ctx)
  50242. if err != nil {
  50243. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50244. }
  50245. return oldValue.UpdatedAt, nil
  50246. }
  50247. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50248. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  50249. m.updated_at = nil
  50250. }
  50251. // SetStatus sets the "status" field.
  50252. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  50253. m.status = &u
  50254. m.addstatus = nil
  50255. }
  50256. // Status returns the value of the "status" field in the mutation.
  50257. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  50258. v := m.status
  50259. if v == nil {
  50260. return
  50261. }
  50262. return *v, true
  50263. }
  50264. // OldStatus returns the old "status" field's value of the XunjiService entity.
  50265. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50267. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  50268. if !m.op.Is(OpUpdateOne) {
  50269. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  50270. }
  50271. if m.id == nil || m.oldValue == nil {
  50272. return v, errors.New("OldStatus requires an ID field in the mutation")
  50273. }
  50274. oldValue, err := m.oldValue(ctx)
  50275. if err != nil {
  50276. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  50277. }
  50278. return oldValue.Status, nil
  50279. }
  50280. // AddStatus adds u to the "status" field.
  50281. func (m *XunjiServiceMutation) AddStatus(u int8) {
  50282. if m.addstatus != nil {
  50283. *m.addstatus += u
  50284. } else {
  50285. m.addstatus = &u
  50286. }
  50287. }
  50288. // AddedStatus returns the value that was added to the "status" field in this mutation.
  50289. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  50290. v := m.addstatus
  50291. if v == nil {
  50292. return
  50293. }
  50294. return *v, true
  50295. }
  50296. // ClearStatus clears the value of the "status" field.
  50297. func (m *XunjiServiceMutation) ClearStatus() {
  50298. m.status = nil
  50299. m.addstatus = nil
  50300. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  50301. }
  50302. // StatusCleared returns if the "status" field was cleared in this mutation.
  50303. func (m *XunjiServiceMutation) StatusCleared() bool {
  50304. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  50305. return ok
  50306. }
  50307. // ResetStatus resets all changes to the "status" field.
  50308. func (m *XunjiServiceMutation) ResetStatus() {
  50309. m.status = nil
  50310. m.addstatus = nil
  50311. delete(m.clearedFields, xunjiservice.FieldStatus)
  50312. }
  50313. // SetDeletedAt sets the "deleted_at" field.
  50314. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  50315. m.deleted_at = &t
  50316. }
  50317. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50318. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  50319. v := m.deleted_at
  50320. if v == nil {
  50321. return
  50322. }
  50323. return *v, true
  50324. }
  50325. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  50326. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50328. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50329. if !m.op.Is(OpUpdateOne) {
  50330. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50331. }
  50332. if m.id == nil || m.oldValue == nil {
  50333. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50334. }
  50335. oldValue, err := m.oldValue(ctx)
  50336. if err != nil {
  50337. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50338. }
  50339. return oldValue.DeletedAt, nil
  50340. }
  50341. // ClearDeletedAt clears the value of the "deleted_at" field.
  50342. func (m *XunjiServiceMutation) ClearDeletedAt() {
  50343. m.deleted_at = nil
  50344. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  50345. }
  50346. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50347. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  50348. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  50349. return ok
  50350. }
  50351. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50352. func (m *XunjiServiceMutation) ResetDeletedAt() {
  50353. m.deleted_at = nil
  50354. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  50355. }
  50356. // SetXunjiID sets the "xunji_id" field.
  50357. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  50358. m.xunji_id = &u
  50359. m.addxunji_id = nil
  50360. }
  50361. // XunjiID returns the value of the "xunji_id" field in the mutation.
  50362. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  50363. v := m.xunji_id
  50364. if v == nil {
  50365. return
  50366. }
  50367. return *v, true
  50368. }
  50369. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  50370. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50372. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  50373. if !m.op.Is(OpUpdateOne) {
  50374. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  50375. }
  50376. if m.id == nil || m.oldValue == nil {
  50377. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  50378. }
  50379. oldValue, err := m.oldValue(ctx)
  50380. if err != nil {
  50381. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  50382. }
  50383. return oldValue.XunjiID, nil
  50384. }
  50385. // AddXunjiID adds u to the "xunji_id" field.
  50386. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  50387. if m.addxunji_id != nil {
  50388. *m.addxunji_id += u
  50389. } else {
  50390. m.addxunji_id = &u
  50391. }
  50392. }
  50393. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  50394. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  50395. v := m.addxunji_id
  50396. if v == nil {
  50397. return
  50398. }
  50399. return *v, true
  50400. }
  50401. // ResetXunjiID resets all changes to the "xunji_id" field.
  50402. func (m *XunjiServiceMutation) ResetXunjiID() {
  50403. m.xunji_id = nil
  50404. m.addxunji_id = nil
  50405. }
  50406. // SetAgentID sets the "agent_id" field.
  50407. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  50408. m.agent = &u
  50409. }
  50410. // AgentID returns the value of the "agent_id" field in the mutation.
  50411. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  50412. v := m.agent
  50413. if v == nil {
  50414. return
  50415. }
  50416. return *v, true
  50417. }
  50418. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  50419. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50421. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  50422. if !m.op.Is(OpUpdateOne) {
  50423. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  50424. }
  50425. if m.id == nil || m.oldValue == nil {
  50426. return v, errors.New("OldAgentID requires an ID field in the mutation")
  50427. }
  50428. oldValue, err := m.oldValue(ctx)
  50429. if err != nil {
  50430. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  50431. }
  50432. return oldValue.AgentID, nil
  50433. }
  50434. // ResetAgentID resets all changes to the "agent_id" field.
  50435. func (m *XunjiServiceMutation) ResetAgentID() {
  50436. m.agent = nil
  50437. }
  50438. // SetOrganizationID sets the "organization_id" field.
  50439. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  50440. m.organization_id = &u
  50441. m.addorganization_id = nil
  50442. }
  50443. // OrganizationID returns the value of the "organization_id" field in the mutation.
  50444. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  50445. v := m.organization_id
  50446. if v == nil {
  50447. return
  50448. }
  50449. return *v, true
  50450. }
  50451. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  50452. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50454. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  50455. if !m.op.Is(OpUpdateOne) {
  50456. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  50457. }
  50458. if m.id == nil || m.oldValue == nil {
  50459. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  50460. }
  50461. oldValue, err := m.oldValue(ctx)
  50462. if err != nil {
  50463. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  50464. }
  50465. return oldValue.OrganizationID, nil
  50466. }
  50467. // AddOrganizationID adds u to the "organization_id" field.
  50468. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  50469. if m.addorganization_id != nil {
  50470. *m.addorganization_id += u
  50471. } else {
  50472. m.addorganization_id = &u
  50473. }
  50474. }
  50475. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  50476. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  50477. v := m.addorganization_id
  50478. if v == nil {
  50479. return
  50480. }
  50481. return *v, true
  50482. }
  50483. // ResetOrganizationID resets all changes to the "organization_id" field.
  50484. func (m *XunjiServiceMutation) ResetOrganizationID() {
  50485. m.organization_id = nil
  50486. m.addorganization_id = nil
  50487. }
  50488. // SetWxid sets the "wxid" field.
  50489. func (m *XunjiServiceMutation) SetWxid(s string) {
  50490. m.wxid = &s
  50491. }
  50492. // Wxid returns the value of the "wxid" field in the mutation.
  50493. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  50494. v := m.wxid
  50495. if v == nil {
  50496. return
  50497. }
  50498. return *v, true
  50499. }
  50500. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  50501. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50503. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  50504. if !m.op.Is(OpUpdateOne) {
  50505. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  50506. }
  50507. if m.id == nil || m.oldValue == nil {
  50508. return v, errors.New("OldWxid requires an ID field in the mutation")
  50509. }
  50510. oldValue, err := m.oldValue(ctx)
  50511. if err != nil {
  50512. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  50513. }
  50514. return oldValue.Wxid, nil
  50515. }
  50516. // ResetWxid resets all changes to the "wxid" field.
  50517. func (m *XunjiServiceMutation) ResetWxid() {
  50518. m.wxid = nil
  50519. }
  50520. // SetAPIBase sets the "api_base" field.
  50521. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  50522. m.api_base = &s
  50523. }
  50524. // APIBase returns the value of the "api_base" field in the mutation.
  50525. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  50526. v := m.api_base
  50527. if v == nil {
  50528. return
  50529. }
  50530. return *v, true
  50531. }
  50532. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  50533. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50535. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  50536. if !m.op.Is(OpUpdateOne) {
  50537. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  50538. }
  50539. if m.id == nil || m.oldValue == nil {
  50540. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  50541. }
  50542. oldValue, err := m.oldValue(ctx)
  50543. if err != nil {
  50544. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  50545. }
  50546. return oldValue.APIBase, nil
  50547. }
  50548. // ClearAPIBase clears the value of the "api_base" field.
  50549. func (m *XunjiServiceMutation) ClearAPIBase() {
  50550. m.api_base = nil
  50551. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  50552. }
  50553. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  50554. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  50555. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  50556. return ok
  50557. }
  50558. // ResetAPIBase resets all changes to the "api_base" field.
  50559. func (m *XunjiServiceMutation) ResetAPIBase() {
  50560. m.api_base = nil
  50561. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  50562. }
  50563. // SetAPIKey sets the "api_key" field.
  50564. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  50565. m.api_key = &s
  50566. }
  50567. // APIKey returns the value of the "api_key" field in the mutation.
  50568. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  50569. v := m.api_key
  50570. if v == nil {
  50571. return
  50572. }
  50573. return *v, true
  50574. }
  50575. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  50576. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  50577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50578. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  50579. if !m.op.Is(OpUpdateOne) {
  50580. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  50581. }
  50582. if m.id == nil || m.oldValue == nil {
  50583. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  50584. }
  50585. oldValue, err := m.oldValue(ctx)
  50586. if err != nil {
  50587. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  50588. }
  50589. return oldValue.APIKey, nil
  50590. }
  50591. // ClearAPIKey clears the value of the "api_key" field.
  50592. func (m *XunjiServiceMutation) ClearAPIKey() {
  50593. m.api_key = nil
  50594. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  50595. }
  50596. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  50597. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  50598. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  50599. return ok
  50600. }
  50601. // ResetAPIKey resets all changes to the "api_key" field.
  50602. func (m *XunjiServiceMutation) ResetAPIKey() {
  50603. m.api_key = nil
  50604. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  50605. }
  50606. // ClearAgent clears the "agent" edge to the Agent entity.
  50607. func (m *XunjiServiceMutation) ClearAgent() {
  50608. m.clearedagent = true
  50609. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  50610. }
  50611. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  50612. func (m *XunjiServiceMutation) AgentCleared() bool {
  50613. return m.clearedagent
  50614. }
  50615. // AgentIDs returns the "agent" edge IDs in the mutation.
  50616. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  50617. // AgentID instead. It exists only for internal usage by the builders.
  50618. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  50619. if id := m.agent; id != nil {
  50620. ids = append(ids, *id)
  50621. }
  50622. return
  50623. }
  50624. // ResetAgent resets all changes to the "agent" edge.
  50625. func (m *XunjiServiceMutation) ResetAgent() {
  50626. m.agent = nil
  50627. m.clearedagent = false
  50628. }
  50629. // Where appends a list predicates to the XunjiServiceMutation builder.
  50630. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  50631. m.predicates = append(m.predicates, ps...)
  50632. }
  50633. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  50634. // users can use type-assertion to append predicates that do not depend on any generated package.
  50635. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  50636. p := make([]predicate.XunjiService, len(ps))
  50637. for i := range ps {
  50638. p[i] = ps[i]
  50639. }
  50640. m.Where(p...)
  50641. }
  50642. // Op returns the operation name.
  50643. func (m *XunjiServiceMutation) Op() Op {
  50644. return m.op
  50645. }
  50646. // SetOp allows setting the mutation operation.
  50647. func (m *XunjiServiceMutation) SetOp(op Op) {
  50648. m.op = op
  50649. }
  50650. // Type returns the node type of this mutation (XunjiService).
  50651. func (m *XunjiServiceMutation) Type() string {
  50652. return m.typ
  50653. }
  50654. // Fields returns all fields that were changed during this mutation. Note that in
  50655. // order to get all numeric fields that were incremented/decremented, call
  50656. // AddedFields().
  50657. func (m *XunjiServiceMutation) Fields() []string {
  50658. fields := make([]string, 0, 10)
  50659. if m.created_at != nil {
  50660. fields = append(fields, xunjiservice.FieldCreatedAt)
  50661. }
  50662. if m.updated_at != nil {
  50663. fields = append(fields, xunjiservice.FieldUpdatedAt)
  50664. }
  50665. if m.status != nil {
  50666. fields = append(fields, xunjiservice.FieldStatus)
  50667. }
  50668. if m.deleted_at != nil {
  50669. fields = append(fields, xunjiservice.FieldDeletedAt)
  50670. }
  50671. if m.xunji_id != nil {
  50672. fields = append(fields, xunjiservice.FieldXunjiID)
  50673. }
  50674. if m.agent != nil {
  50675. fields = append(fields, xunjiservice.FieldAgentID)
  50676. }
  50677. if m.organization_id != nil {
  50678. fields = append(fields, xunjiservice.FieldOrganizationID)
  50679. }
  50680. if m.wxid != nil {
  50681. fields = append(fields, xunjiservice.FieldWxid)
  50682. }
  50683. if m.api_base != nil {
  50684. fields = append(fields, xunjiservice.FieldAPIBase)
  50685. }
  50686. if m.api_key != nil {
  50687. fields = append(fields, xunjiservice.FieldAPIKey)
  50688. }
  50689. return fields
  50690. }
  50691. // Field returns the value of a field with the given name. The second boolean
  50692. // return value indicates that this field was not set, or was not defined in the
  50693. // schema.
  50694. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  50695. switch name {
  50696. case xunjiservice.FieldCreatedAt:
  50697. return m.CreatedAt()
  50698. case xunjiservice.FieldUpdatedAt:
  50699. return m.UpdatedAt()
  50700. case xunjiservice.FieldStatus:
  50701. return m.Status()
  50702. case xunjiservice.FieldDeletedAt:
  50703. return m.DeletedAt()
  50704. case xunjiservice.FieldXunjiID:
  50705. return m.XunjiID()
  50706. case xunjiservice.FieldAgentID:
  50707. return m.AgentID()
  50708. case xunjiservice.FieldOrganizationID:
  50709. return m.OrganizationID()
  50710. case xunjiservice.FieldWxid:
  50711. return m.Wxid()
  50712. case xunjiservice.FieldAPIBase:
  50713. return m.APIBase()
  50714. case xunjiservice.FieldAPIKey:
  50715. return m.APIKey()
  50716. }
  50717. return nil, false
  50718. }
  50719. // OldField returns the old value of the field from the database. An error is
  50720. // returned if the mutation operation is not UpdateOne, or the query to the
  50721. // database failed.
  50722. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50723. switch name {
  50724. case xunjiservice.FieldCreatedAt:
  50725. return m.OldCreatedAt(ctx)
  50726. case xunjiservice.FieldUpdatedAt:
  50727. return m.OldUpdatedAt(ctx)
  50728. case xunjiservice.FieldStatus:
  50729. return m.OldStatus(ctx)
  50730. case xunjiservice.FieldDeletedAt:
  50731. return m.OldDeletedAt(ctx)
  50732. case xunjiservice.FieldXunjiID:
  50733. return m.OldXunjiID(ctx)
  50734. case xunjiservice.FieldAgentID:
  50735. return m.OldAgentID(ctx)
  50736. case xunjiservice.FieldOrganizationID:
  50737. return m.OldOrganizationID(ctx)
  50738. case xunjiservice.FieldWxid:
  50739. return m.OldWxid(ctx)
  50740. case xunjiservice.FieldAPIBase:
  50741. return m.OldAPIBase(ctx)
  50742. case xunjiservice.FieldAPIKey:
  50743. return m.OldAPIKey(ctx)
  50744. }
  50745. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  50746. }
  50747. // SetField sets the value of a field with the given name. It returns an error if
  50748. // the field is not defined in the schema, or if the type mismatched the field
  50749. // type.
  50750. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  50751. switch name {
  50752. case xunjiservice.FieldCreatedAt:
  50753. v, ok := value.(time.Time)
  50754. if !ok {
  50755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50756. }
  50757. m.SetCreatedAt(v)
  50758. return nil
  50759. case xunjiservice.FieldUpdatedAt:
  50760. v, ok := value.(time.Time)
  50761. if !ok {
  50762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50763. }
  50764. m.SetUpdatedAt(v)
  50765. return nil
  50766. case xunjiservice.FieldStatus:
  50767. v, ok := value.(uint8)
  50768. if !ok {
  50769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50770. }
  50771. m.SetStatus(v)
  50772. return nil
  50773. case xunjiservice.FieldDeletedAt:
  50774. v, ok := value.(time.Time)
  50775. if !ok {
  50776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50777. }
  50778. m.SetDeletedAt(v)
  50779. return nil
  50780. case xunjiservice.FieldXunjiID:
  50781. v, ok := value.(uint64)
  50782. if !ok {
  50783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50784. }
  50785. m.SetXunjiID(v)
  50786. return nil
  50787. case xunjiservice.FieldAgentID:
  50788. v, ok := value.(uint64)
  50789. if !ok {
  50790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50791. }
  50792. m.SetAgentID(v)
  50793. return nil
  50794. case xunjiservice.FieldOrganizationID:
  50795. v, ok := value.(uint64)
  50796. if !ok {
  50797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50798. }
  50799. m.SetOrganizationID(v)
  50800. return nil
  50801. case xunjiservice.FieldWxid:
  50802. v, ok := value.(string)
  50803. if !ok {
  50804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50805. }
  50806. m.SetWxid(v)
  50807. return nil
  50808. case xunjiservice.FieldAPIBase:
  50809. v, ok := value.(string)
  50810. if !ok {
  50811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50812. }
  50813. m.SetAPIBase(v)
  50814. return nil
  50815. case xunjiservice.FieldAPIKey:
  50816. v, ok := value.(string)
  50817. if !ok {
  50818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50819. }
  50820. m.SetAPIKey(v)
  50821. return nil
  50822. }
  50823. return fmt.Errorf("unknown XunjiService field %s", name)
  50824. }
  50825. // AddedFields returns all numeric fields that were incremented/decremented during
  50826. // this mutation.
  50827. func (m *XunjiServiceMutation) AddedFields() []string {
  50828. var fields []string
  50829. if m.addstatus != nil {
  50830. fields = append(fields, xunjiservice.FieldStatus)
  50831. }
  50832. if m.addxunji_id != nil {
  50833. fields = append(fields, xunjiservice.FieldXunjiID)
  50834. }
  50835. if m.addorganization_id != nil {
  50836. fields = append(fields, xunjiservice.FieldOrganizationID)
  50837. }
  50838. return fields
  50839. }
  50840. // AddedField returns the numeric value that was incremented/decremented on a field
  50841. // with the given name. The second boolean return value indicates that this field
  50842. // was not set, or was not defined in the schema.
  50843. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  50844. switch name {
  50845. case xunjiservice.FieldStatus:
  50846. return m.AddedStatus()
  50847. case xunjiservice.FieldXunjiID:
  50848. return m.AddedXunjiID()
  50849. case xunjiservice.FieldOrganizationID:
  50850. return m.AddedOrganizationID()
  50851. }
  50852. return nil, false
  50853. }
  50854. // AddField adds the value to the field with the given name. It returns an error if
  50855. // the field is not defined in the schema, or if the type mismatched the field
  50856. // type.
  50857. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  50858. switch name {
  50859. case xunjiservice.FieldStatus:
  50860. v, ok := value.(int8)
  50861. if !ok {
  50862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50863. }
  50864. m.AddStatus(v)
  50865. return nil
  50866. case xunjiservice.FieldXunjiID:
  50867. v, ok := value.(int64)
  50868. if !ok {
  50869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50870. }
  50871. m.AddXunjiID(v)
  50872. return nil
  50873. case xunjiservice.FieldOrganizationID:
  50874. v, ok := value.(int64)
  50875. if !ok {
  50876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50877. }
  50878. m.AddOrganizationID(v)
  50879. return nil
  50880. }
  50881. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  50882. }
  50883. // ClearedFields returns all nullable fields that were cleared during this
  50884. // mutation.
  50885. func (m *XunjiServiceMutation) ClearedFields() []string {
  50886. var fields []string
  50887. if m.FieldCleared(xunjiservice.FieldStatus) {
  50888. fields = append(fields, xunjiservice.FieldStatus)
  50889. }
  50890. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  50891. fields = append(fields, xunjiservice.FieldDeletedAt)
  50892. }
  50893. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  50894. fields = append(fields, xunjiservice.FieldAPIBase)
  50895. }
  50896. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  50897. fields = append(fields, xunjiservice.FieldAPIKey)
  50898. }
  50899. return fields
  50900. }
  50901. // FieldCleared returns a boolean indicating if a field with the given name was
  50902. // cleared in this mutation.
  50903. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  50904. _, ok := m.clearedFields[name]
  50905. return ok
  50906. }
  50907. // ClearField clears the value of the field with the given name. It returns an
  50908. // error if the field is not defined in the schema.
  50909. func (m *XunjiServiceMutation) ClearField(name string) error {
  50910. switch name {
  50911. case xunjiservice.FieldStatus:
  50912. m.ClearStatus()
  50913. return nil
  50914. case xunjiservice.FieldDeletedAt:
  50915. m.ClearDeletedAt()
  50916. return nil
  50917. case xunjiservice.FieldAPIBase:
  50918. m.ClearAPIBase()
  50919. return nil
  50920. case xunjiservice.FieldAPIKey:
  50921. m.ClearAPIKey()
  50922. return nil
  50923. }
  50924. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  50925. }
  50926. // ResetField resets all changes in the mutation for the field with the given name.
  50927. // It returns an error if the field is not defined in the schema.
  50928. func (m *XunjiServiceMutation) ResetField(name string) error {
  50929. switch name {
  50930. case xunjiservice.FieldCreatedAt:
  50931. m.ResetCreatedAt()
  50932. return nil
  50933. case xunjiservice.FieldUpdatedAt:
  50934. m.ResetUpdatedAt()
  50935. return nil
  50936. case xunjiservice.FieldStatus:
  50937. m.ResetStatus()
  50938. return nil
  50939. case xunjiservice.FieldDeletedAt:
  50940. m.ResetDeletedAt()
  50941. return nil
  50942. case xunjiservice.FieldXunjiID:
  50943. m.ResetXunjiID()
  50944. return nil
  50945. case xunjiservice.FieldAgentID:
  50946. m.ResetAgentID()
  50947. return nil
  50948. case xunjiservice.FieldOrganizationID:
  50949. m.ResetOrganizationID()
  50950. return nil
  50951. case xunjiservice.FieldWxid:
  50952. m.ResetWxid()
  50953. return nil
  50954. case xunjiservice.FieldAPIBase:
  50955. m.ResetAPIBase()
  50956. return nil
  50957. case xunjiservice.FieldAPIKey:
  50958. m.ResetAPIKey()
  50959. return nil
  50960. }
  50961. return fmt.Errorf("unknown XunjiService field %s", name)
  50962. }
  50963. // AddedEdges returns all edge names that were set/added in this mutation.
  50964. func (m *XunjiServiceMutation) AddedEdges() []string {
  50965. edges := make([]string, 0, 1)
  50966. if m.agent != nil {
  50967. edges = append(edges, xunjiservice.EdgeAgent)
  50968. }
  50969. return edges
  50970. }
  50971. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50972. // name in this mutation.
  50973. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  50974. switch name {
  50975. case xunjiservice.EdgeAgent:
  50976. if id := m.agent; id != nil {
  50977. return []ent.Value{*id}
  50978. }
  50979. }
  50980. return nil
  50981. }
  50982. // RemovedEdges returns all edge names that were removed in this mutation.
  50983. func (m *XunjiServiceMutation) RemovedEdges() []string {
  50984. edges := make([]string, 0, 1)
  50985. return edges
  50986. }
  50987. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50988. // the given name in this mutation.
  50989. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  50990. return nil
  50991. }
  50992. // ClearedEdges returns all edge names that were cleared in this mutation.
  50993. func (m *XunjiServiceMutation) ClearedEdges() []string {
  50994. edges := make([]string, 0, 1)
  50995. if m.clearedagent {
  50996. edges = append(edges, xunjiservice.EdgeAgent)
  50997. }
  50998. return edges
  50999. }
  51000. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51001. // was cleared in this mutation.
  51002. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  51003. switch name {
  51004. case xunjiservice.EdgeAgent:
  51005. return m.clearedagent
  51006. }
  51007. return false
  51008. }
  51009. // ClearEdge clears the value of the edge with the given name. It returns an error
  51010. // if that edge is not defined in the schema.
  51011. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  51012. switch name {
  51013. case xunjiservice.EdgeAgent:
  51014. m.ClearAgent()
  51015. return nil
  51016. }
  51017. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  51018. }
  51019. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51020. // It returns an error if the edge is not defined in the schema.
  51021. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  51022. switch name {
  51023. case xunjiservice.EdgeAgent:
  51024. m.ResetAgent()
  51025. return nil
  51026. }
  51027. return fmt.Errorf("unknown XunjiService edge %s", name)
  51028. }