mutation.go 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/contact"
  19. "wechat-api/ent/creditbalance"
  20. "wechat-api/ent/creditusage"
  21. "wechat-api/ent/custom_types"
  22. "wechat-api/ent/employee"
  23. "wechat-api/ent/employeeconfig"
  24. "wechat-api/ent/label"
  25. "wechat-api/ent/labelrelationship"
  26. "wechat-api/ent/labeltagging"
  27. "wechat-api/ent/message"
  28. "wechat-api/ent/messagerecords"
  29. "wechat-api/ent/msg"
  30. "wechat-api/ent/payrecharge"
  31. "wechat-api/ent/predicate"
  32. "wechat-api/ent/server"
  33. "wechat-api/ent/sopnode"
  34. "wechat-api/ent/sopstage"
  35. "wechat-api/ent/soptask"
  36. "wechat-api/ent/token"
  37. "wechat-api/ent/tutorial"
  38. "wechat-api/ent/usagedetail"
  39. "wechat-api/ent/usagestatisticday"
  40. "wechat-api/ent/usagestatistichour"
  41. "wechat-api/ent/usagestatisticmonth"
  42. "wechat-api/ent/usagetotal"
  43. "wechat-api/ent/whatsapp"
  44. "wechat-api/ent/whatsappchannel"
  45. "wechat-api/ent/workexperience"
  46. "wechat-api/ent/wpchatroom"
  47. "wechat-api/ent/wpchatroommember"
  48. "wechat-api/ent/wx"
  49. "wechat-api/ent/wxcard"
  50. "wechat-api/ent/wxcarduser"
  51. "wechat-api/ent/wxcardvisit"
  52. "entgo.io/ent"
  53. "entgo.io/ent/dialect/sql"
  54. )
  55. const (
  56. // Operation types.
  57. OpCreate = ent.OpCreate
  58. OpDelete = ent.OpDelete
  59. OpDeleteOne = ent.OpDeleteOne
  60. OpUpdate = ent.OpUpdate
  61. OpUpdateOne = ent.OpUpdateOne
  62. // Node types.
  63. TypeAgent = "Agent"
  64. TypeAgentBase = "AgentBase"
  65. TypeAliyunAvatar = "AliyunAvatar"
  66. TypeAllocAgent = "AllocAgent"
  67. TypeApiKey = "ApiKey"
  68. TypeBatchMsg = "BatchMsg"
  69. TypeCategory = "Category"
  70. TypeChatRecords = "ChatRecords"
  71. TypeChatSession = "ChatSession"
  72. TypeContact = "Contact"
  73. TypeCreditBalance = "CreditBalance"
  74. TypeCreditUsage = "CreditUsage"
  75. TypeEmployee = "Employee"
  76. TypeEmployeeConfig = "EmployeeConfig"
  77. TypeLabel = "Label"
  78. TypeLabelRelationship = "LabelRelationship"
  79. TypeLabelTagging = "LabelTagging"
  80. TypeMessage = "Message"
  81. TypeMessageRecords = "MessageRecords"
  82. TypeMsg = "Msg"
  83. TypePayRecharge = "PayRecharge"
  84. TypeServer = "Server"
  85. TypeSopNode = "SopNode"
  86. TypeSopStage = "SopStage"
  87. TypeSopTask = "SopTask"
  88. TypeToken = "Token"
  89. TypeTutorial = "Tutorial"
  90. TypeUsageDetail = "UsageDetail"
  91. TypeUsageStatisticDay = "UsageStatisticDay"
  92. TypeUsageStatisticHour = "UsageStatisticHour"
  93. TypeUsageStatisticMonth = "UsageStatisticMonth"
  94. TypeUsageTotal = "UsageTotal"
  95. TypeWhatsapp = "Whatsapp"
  96. TypeWhatsappChannel = "WhatsappChannel"
  97. TypeWorkExperience = "WorkExperience"
  98. TypeWpChatroom = "WpChatroom"
  99. TypeWpChatroomMember = "WpChatroomMember"
  100. TypeWx = "Wx"
  101. TypeWxCard = "WxCard"
  102. TypeWxCardUser = "WxCardUser"
  103. TypeWxCardVisit = "WxCardVisit"
  104. )
  105. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  106. type AgentMutation struct {
  107. config
  108. op Op
  109. typ string
  110. id *uint64
  111. created_at *time.Time
  112. updated_at *time.Time
  113. deleted_at *time.Time
  114. name *string
  115. role *string
  116. status *int
  117. addstatus *int
  118. background *string
  119. examples *string
  120. organization_id *uint64
  121. addorganization_id *int64
  122. dataset_id *string
  123. collection_id *string
  124. model *string
  125. api_base *string
  126. api_key *string
  127. _type *int
  128. add_type *int
  129. clearedFields map[string]struct{}
  130. wx_agent map[uint64]struct{}
  131. removedwx_agent map[uint64]struct{}
  132. clearedwx_agent bool
  133. token_agent map[uint64]struct{}
  134. removedtoken_agent map[uint64]struct{}
  135. clearedtoken_agent bool
  136. wa_agent map[uint64]struct{}
  137. removedwa_agent map[uint64]struct{}
  138. clearedwa_agent bool
  139. key_agent map[uint64]struct{}
  140. removedkey_agent map[uint64]struct{}
  141. clearedkey_agent bool
  142. done bool
  143. oldValue func(context.Context) (*Agent, error)
  144. predicates []predicate.Agent
  145. }
  146. var _ ent.Mutation = (*AgentMutation)(nil)
  147. // agentOption allows management of the mutation configuration using functional options.
  148. type agentOption func(*AgentMutation)
  149. // newAgentMutation creates new mutation for the Agent entity.
  150. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  151. m := &AgentMutation{
  152. config: c,
  153. op: op,
  154. typ: TypeAgent,
  155. clearedFields: make(map[string]struct{}),
  156. }
  157. for _, opt := range opts {
  158. opt(m)
  159. }
  160. return m
  161. }
  162. // withAgentID sets the ID field of the mutation.
  163. func withAgentID(id uint64) agentOption {
  164. return func(m *AgentMutation) {
  165. var (
  166. err error
  167. once sync.Once
  168. value *Agent
  169. )
  170. m.oldValue = func(ctx context.Context) (*Agent, error) {
  171. once.Do(func() {
  172. if m.done {
  173. err = errors.New("querying old values post mutation is not allowed")
  174. } else {
  175. value, err = m.Client().Agent.Get(ctx, id)
  176. }
  177. })
  178. return value, err
  179. }
  180. m.id = &id
  181. }
  182. }
  183. // withAgent sets the old Agent of the mutation.
  184. func withAgent(node *Agent) agentOption {
  185. return func(m *AgentMutation) {
  186. m.oldValue = func(context.Context) (*Agent, error) {
  187. return node, nil
  188. }
  189. m.id = &node.ID
  190. }
  191. }
  192. // Client returns a new `ent.Client` from the mutation. If the mutation was
  193. // executed in a transaction (ent.Tx), a transactional client is returned.
  194. func (m AgentMutation) Client() *Client {
  195. client := &Client{config: m.config}
  196. client.init()
  197. return client
  198. }
  199. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  200. // it returns an error otherwise.
  201. func (m AgentMutation) Tx() (*Tx, error) {
  202. if _, ok := m.driver.(*txDriver); !ok {
  203. return nil, errors.New("ent: mutation is not running in a transaction")
  204. }
  205. tx := &Tx{config: m.config}
  206. tx.init()
  207. return tx, nil
  208. }
  209. // SetID sets the value of the id field. Note that this
  210. // operation is only accepted on creation of Agent entities.
  211. func (m *AgentMutation) SetID(id uint64) {
  212. m.id = &id
  213. }
  214. // ID returns the ID value in the mutation. Note that the ID is only available
  215. // if it was provided to the builder or after it was returned from the database.
  216. func (m *AgentMutation) ID() (id uint64, exists bool) {
  217. if m.id == nil {
  218. return
  219. }
  220. return *m.id, true
  221. }
  222. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  223. // That means, if the mutation is applied within a transaction with an isolation level such
  224. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  225. // or updated by the mutation.
  226. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  227. switch {
  228. case m.op.Is(OpUpdateOne | OpDeleteOne):
  229. id, exists := m.ID()
  230. if exists {
  231. return []uint64{id}, nil
  232. }
  233. fallthrough
  234. case m.op.Is(OpUpdate | OpDelete):
  235. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  236. default:
  237. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  238. }
  239. }
  240. // SetCreatedAt sets the "created_at" field.
  241. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  242. m.created_at = &t
  243. }
  244. // CreatedAt returns the value of the "created_at" field in the mutation.
  245. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  246. v := m.created_at
  247. if v == nil {
  248. return
  249. }
  250. return *v, true
  251. }
  252. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  253. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  255. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  256. if !m.op.Is(OpUpdateOne) {
  257. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  258. }
  259. if m.id == nil || m.oldValue == nil {
  260. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  261. }
  262. oldValue, err := m.oldValue(ctx)
  263. if err != nil {
  264. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  265. }
  266. return oldValue.CreatedAt, nil
  267. }
  268. // ResetCreatedAt resets all changes to the "created_at" field.
  269. func (m *AgentMutation) ResetCreatedAt() {
  270. m.created_at = nil
  271. }
  272. // SetUpdatedAt sets the "updated_at" field.
  273. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  274. m.updated_at = &t
  275. }
  276. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  277. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  278. v := m.updated_at
  279. if v == nil {
  280. return
  281. }
  282. return *v, true
  283. }
  284. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  285. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  287. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  288. if !m.op.Is(OpUpdateOne) {
  289. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  290. }
  291. if m.id == nil || m.oldValue == nil {
  292. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  293. }
  294. oldValue, err := m.oldValue(ctx)
  295. if err != nil {
  296. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  297. }
  298. return oldValue.UpdatedAt, nil
  299. }
  300. // ResetUpdatedAt resets all changes to the "updated_at" field.
  301. func (m *AgentMutation) ResetUpdatedAt() {
  302. m.updated_at = nil
  303. }
  304. // SetDeletedAt sets the "deleted_at" field.
  305. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  306. m.deleted_at = &t
  307. }
  308. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  309. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  310. v := m.deleted_at
  311. if v == nil {
  312. return
  313. }
  314. return *v, true
  315. }
  316. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  317. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  319. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  320. if !m.op.Is(OpUpdateOne) {
  321. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  322. }
  323. if m.id == nil || m.oldValue == nil {
  324. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  325. }
  326. oldValue, err := m.oldValue(ctx)
  327. if err != nil {
  328. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  329. }
  330. return oldValue.DeletedAt, nil
  331. }
  332. // ClearDeletedAt clears the value of the "deleted_at" field.
  333. func (m *AgentMutation) ClearDeletedAt() {
  334. m.deleted_at = nil
  335. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  336. }
  337. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  338. func (m *AgentMutation) DeletedAtCleared() bool {
  339. _, ok := m.clearedFields[agent.FieldDeletedAt]
  340. return ok
  341. }
  342. // ResetDeletedAt resets all changes to the "deleted_at" field.
  343. func (m *AgentMutation) ResetDeletedAt() {
  344. m.deleted_at = nil
  345. delete(m.clearedFields, agent.FieldDeletedAt)
  346. }
  347. // SetName sets the "name" field.
  348. func (m *AgentMutation) SetName(s string) {
  349. m.name = &s
  350. }
  351. // Name returns the value of the "name" field in the mutation.
  352. func (m *AgentMutation) Name() (r string, exists bool) {
  353. v := m.name
  354. if v == nil {
  355. return
  356. }
  357. return *v, true
  358. }
  359. // OldName returns the old "name" field's value of the Agent entity.
  360. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  362. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  363. if !m.op.Is(OpUpdateOne) {
  364. return v, errors.New("OldName is only allowed on UpdateOne operations")
  365. }
  366. if m.id == nil || m.oldValue == nil {
  367. return v, errors.New("OldName requires an ID field in the mutation")
  368. }
  369. oldValue, err := m.oldValue(ctx)
  370. if err != nil {
  371. return v, fmt.Errorf("querying old value for OldName: %w", err)
  372. }
  373. return oldValue.Name, nil
  374. }
  375. // ResetName resets all changes to the "name" field.
  376. func (m *AgentMutation) ResetName() {
  377. m.name = nil
  378. }
  379. // SetRole sets the "role" field.
  380. func (m *AgentMutation) SetRole(s string) {
  381. m.role = &s
  382. }
  383. // Role returns the value of the "role" field in the mutation.
  384. func (m *AgentMutation) Role() (r string, exists bool) {
  385. v := m.role
  386. if v == nil {
  387. return
  388. }
  389. return *v, true
  390. }
  391. // OldRole returns the old "role" field's value of the Agent entity.
  392. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  394. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  395. if !m.op.Is(OpUpdateOne) {
  396. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  397. }
  398. if m.id == nil || m.oldValue == nil {
  399. return v, errors.New("OldRole requires an ID field in the mutation")
  400. }
  401. oldValue, err := m.oldValue(ctx)
  402. if err != nil {
  403. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  404. }
  405. return oldValue.Role, nil
  406. }
  407. // ClearRole clears the value of the "role" field.
  408. func (m *AgentMutation) ClearRole() {
  409. m.role = nil
  410. m.clearedFields[agent.FieldRole] = struct{}{}
  411. }
  412. // RoleCleared returns if the "role" field was cleared in this mutation.
  413. func (m *AgentMutation) RoleCleared() bool {
  414. _, ok := m.clearedFields[agent.FieldRole]
  415. return ok
  416. }
  417. // ResetRole resets all changes to the "role" field.
  418. func (m *AgentMutation) ResetRole() {
  419. m.role = nil
  420. delete(m.clearedFields, agent.FieldRole)
  421. }
  422. // SetStatus sets the "status" field.
  423. func (m *AgentMutation) SetStatus(i int) {
  424. m.status = &i
  425. m.addstatus = nil
  426. }
  427. // Status returns the value of the "status" field in the mutation.
  428. func (m *AgentMutation) Status() (r int, exists bool) {
  429. v := m.status
  430. if v == nil {
  431. return
  432. }
  433. return *v, true
  434. }
  435. // OldStatus returns the old "status" field's value of the Agent entity.
  436. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  438. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  439. if !m.op.Is(OpUpdateOne) {
  440. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  441. }
  442. if m.id == nil || m.oldValue == nil {
  443. return v, errors.New("OldStatus requires an ID field in the mutation")
  444. }
  445. oldValue, err := m.oldValue(ctx)
  446. if err != nil {
  447. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  448. }
  449. return oldValue.Status, nil
  450. }
  451. // AddStatus adds i to the "status" field.
  452. func (m *AgentMutation) AddStatus(i int) {
  453. if m.addstatus != nil {
  454. *m.addstatus += i
  455. } else {
  456. m.addstatus = &i
  457. }
  458. }
  459. // AddedStatus returns the value that was added to the "status" field in this mutation.
  460. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  461. v := m.addstatus
  462. if v == nil {
  463. return
  464. }
  465. return *v, true
  466. }
  467. // ClearStatus clears the value of the "status" field.
  468. func (m *AgentMutation) ClearStatus() {
  469. m.status = nil
  470. m.addstatus = nil
  471. m.clearedFields[agent.FieldStatus] = struct{}{}
  472. }
  473. // StatusCleared returns if the "status" field was cleared in this mutation.
  474. func (m *AgentMutation) StatusCleared() bool {
  475. _, ok := m.clearedFields[agent.FieldStatus]
  476. return ok
  477. }
  478. // ResetStatus resets all changes to the "status" field.
  479. func (m *AgentMutation) ResetStatus() {
  480. m.status = nil
  481. m.addstatus = nil
  482. delete(m.clearedFields, agent.FieldStatus)
  483. }
  484. // SetBackground sets the "background" field.
  485. func (m *AgentMutation) SetBackground(s string) {
  486. m.background = &s
  487. }
  488. // Background returns the value of the "background" field in the mutation.
  489. func (m *AgentMutation) Background() (r string, exists bool) {
  490. v := m.background
  491. if v == nil {
  492. return
  493. }
  494. return *v, true
  495. }
  496. // OldBackground returns the old "background" field's value of the Agent entity.
  497. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  499. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  500. if !m.op.Is(OpUpdateOne) {
  501. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  502. }
  503. if m.id == nil || m.oldValue == nil {
  504. return v, errors.New("OldBackground requires an ID field in the mutation")
  505. }
  506. oldValue, err := m.oldValue(ctx)
  507. if err != nil {
  508. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  509. }
  510. return oldValue.Background, nil
  511. }
  512. // ClearBackground clears the value of the "background" field.
  513. func (m *AgentMutation) ClearBackground() {
  514. m.background = nil
  515. m.clearedFields[agent.FieldBackground] = struct{}{}
  516. }
  517. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  518. func (m *AgentMutation) BackgroundCleared() bool {
  519. _, ok := m.clearedFields[agent.FieldBackground]
  520. return ok
  521. }
  522. // ResetBackground resets all changes to the "background" field.
  523. func (m *AgentMutation) ResetBackground() {
  524. m.background = nil
  525. delete(m.clearedFields, agent.FieldBackground)
  526. }
  527. // SetExamples sets the "examples" field.
  528. func (m *AgentMutation) SetExamples(s string) {
  529. m.examples = &s
  530. }
  531. // Examples returns the value of the "examples" field in the mutation.
  532. func (m *AgentMutation) Examples() (r string, exists bool) {
  533. v := m.examples
  534. if v == nil {
  535. return
  536. }
  537. return *v, true
  538. }
  539. // OldExamples returns the old "examples" field's value of the Agent entity.
  540. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  542. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  543. if !m.op.Is(OpUpdateOne) {
  544. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  545. }
  546. if m.id == nil || m.oldValue == nil {
  547. return v, errors.New("OldExamples requires an ID field in the mutation")
  548. }
  549. oldValue, err := m.oldValue(ctx)
  550. if err != nil {
  551. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  552. }
  553. return oldValue.Examples, nil
  554. }
  555. // ClearExamples clears the value of the "examples" field.
  556. func (m *AgentMutation) ClearExamples() {
  557. m.examples = nil
  558. m.clearedFields[agent.FieldExamples] = struct{}{}
  559. }
  560. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  561. func (m *AgentMutation) ExamplesCleared() bool {
  562. _, ok := m.clearedFields[agent.FieldExamples]
  563. return ok
  564. }
  565. // ResetExamples resets all changes to the "examples" field.
  566. func (m *AgentMutation) ResetExamples() {
  567. m.examples = nil
  568. delete(m.clearedFields, agent.FieldExamples)
  569. }
  570. // SetOrganizationID sets the "organization_id" field.
  571. func (m *AgentMutation) SetOrganizationID(u uint64) {
  572. m.organization_id = &u
  573. m.addorganization_id = nil
  574. }
  575. // OrganizationID returns the value of the "organization_id" field in the mutation.
  576. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  577. v := m.organization_id
  578. if v == nil {
  579. return
  580. }
  581. return *v, true
  582. }
  583. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  584. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  586. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  587. if !m.op.Is(OpUpdateOne) {
  588. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  589. }
  590. if m.id == nil || m.oldValue == nil {
  591. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  592. }
  593. oldValue, err := m.oldValue(ctx)
  594. if err != nil {
  595. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  596. }
  597. return oldValue.OrganizationID, nil
  598. }
  599. // AddOrganizationID adds u to the "organization_id" field.
  600. func (m *AgentMutation) AddOrganizationID(u int64) {
  601. if m.addorganization_id != nil {
  602. *m.addorganization_id += u
  603. } else {
  604. m.addorganization_id = &u
  605. }
  606. }
  607. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  608. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  609. v := m.addorganization_id
  610. if v == nil {
  611. return
  612. }
  613. return *v, true
  614. }
  615. // ResetOrganizationID resets all changes to the "organization_id" field.
  616. func (m *AgentMutation) ResetOrganizationID() {
  617. m.organization_id = nil
  618. m.addorganization_id = nil
  619. }
  620. // SetDatasetID sets the "dataset_id" field.
  621. func (m *AgentMutation) SetDatasetID(s string) {
  622. m.dataset_id = &s
  623. }
  624. // DatasetID returns the value of the "dataset_id" field in the mutation.
  625. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  626. v := m.dataset_id
  627. if v == nil {
  628. return
  629. }
  630. return *v, true
  631. }
  632. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  633. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  635. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  636. if !m.op.Is(OpUpdateOne) {
  637. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  638. }
  639. if m.id == nil || m.oldValue == nil {
  640. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  641. }
  642. oldValue, err := m.oldValue(ctx)
  643. if err != nil {
  644. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  645. }
  646. return oldValue.DatasetID, nil
  647. }
  648. // ResetDatasetID resets all changes to the "dataset_id" field.
  649. func (m *AgentMutation) ResetDatasetID() {
  650. m.dataset_id = nil
  651. }
  652. // SetCollectionID sets the "collection_id" field.
  653. func (m *AgentMutation) SetCollectionID(s string) {
  654. m.collection_id = &s
  655. }
  656. // CollectionID returns the value of the "collection_id" field in the mutation.
  657. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  658. v := m.collection_id
  659. if v == nil {
  660. return
  661. }
  662. return *v, true
  663. }
  664. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  665. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  667. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  668. if !m.op.Is(OpUpdateOne) {
  669. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  670. }
  671. if m.id == nil || m.oldValue == nil {
  672. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  673. }
  674. oldValue, err := m.oldValue(ctx)
  675. if err != nil {
  676. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  677. }
  678. return oldValue.CollectionID, nil
  679. }
  680. // ResetCollectionID resets all changes to the "collection_id" field.
  681. func (m *AgentMutation) ResetCollectionID() {
  682. m.collection_id = nil
  683. }
  684. // SetModel sets the "model" field.
  685. func (m *AgentMutation) SetModel(s string) {
  686. m.model = &s
  687. }
  688. // Model returns the value of the "model" field in the mutation.
  689. func (m *AgentMutation) Model() (r string, exists bool) {
  690. v := m.model
  691. if v == nil {
  692. return
  693. }
  694. return *v, true
  695. }
  696. // OldModel returns the old "model" field's value of the Agent entity.
  697. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  699. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  700. if !m.op.Is(OpUpdateOne) {
  701. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  702. }
  703. if m.id == nil || m.oldValue == nil {
  704. return v, errors.New("OldModel requires an ID field in the mutation")
  705. }
  706. oldValue, err := m.oldValue(ctx)
  707. if err != nil {
  708. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  709. }
  710. return oldValue.Model, nil
  711. }
  712. // ClearModel clears the value of the "model" field.
  713. func (m *AgentMutation) ClearModel() {
  714. m.model = nil
  715. m.clearedFields[agent.FieldModel] = struct{}{}
  716. }
  717. // ModelCleared returns if the "model" field was cleared in this mutation.
  718. func (m *AgentMutation) ModelCleared() bool {
  719. _, ok := m.clearedFields[agent.FieldModel]
  720. return ok
  721. }
  722. // ResetModel resets all changes to the "model" field.
  723. func (m *AgentMutation) ResetModel() {
  724. m.model = nil
  725. delete(m.clearedFields, agent.FieldModel)
  726. }
  727. // SetAPIBase sets the "api_base" field.
  728. func (m *AgentMutation) SetAPIBase(s string) {
  729. m.api_base = &s
  730. }
  731. // APIBase returns the value of the "api_base" field in the mutation.
  732. func (m *AgentMutation) APIBase() (r string, exists bool) {
  733. v := m.api_base
  734. if v == nil {
  735. return
  736. }
  737. return *v, true
  738. }
  739. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  740. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  742. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  743. if !m.op.Is(OpUpdateOne) {
  744. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  745. }
  746. if m.id == nil || m.oldValue == nil {
  747. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  748. }
  749. oldValue, err := m.oldValue(ctx)
  750. if err != nil {
  751. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  752. }
  753. return oldValue.APIBase, nil
  754. }
  755. // ClearAPIBase clears the value of the "api_base" field.
  756. func (m *AgentMutation) ClearAPIBase() {
  757. m.api_base = nil
  758. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  759. }
  760. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  761. func (m *AgentMutation) APIBaseCleared() bool {
  762. _, ok := m.clearedFields[agent.FieldAPIBase]
  763. return ok
  764. }
  765. // ResetAPIBase resets all changes to the "api_base" field.
  766. func (m *AgentMutation) ResetAPIBase() {
  767. m.api_base = nil
  768. delete(m.clearedFields, agent.FieldAPIBase)
  769. }
  770. // SetAPIKey sets the "api_key" field.
  771. func (m *AgentMutation) SetAPIKey(s string) {
  772. m.api_key = &s
  773. }
  774. // APIKey returns the value of the "api_key" field in the mutation.
  775. func (m *AgentMutation) APIKey() (r string, exists bool) {
  776. v := m.api_key
  777. if v == nil {
  778. return
  779. }
  780. return *v, true
  781. }
  782. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  783. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  785. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  786. if !m.op.Is(OpUpdateOne) {
  787. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  788. }
  789. if m.id == nil || m.oldValue == nil {
  790. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  791. }
  792. oldValue, err := m.oldValue(ctx)
  793. if err != nil {
  794. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  795. }
  796. return oldValue.APIKey, nil
  797. }
  798. // ClearAPIKey clears the value of the "api_key" field.
  799. func (m *AgentMutation) ClearAPIKey() {
  800. m.api_key = nil
  801. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  802. }
  803. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  804. func (m *AgentMutation) APIKeyCleared() bool {
  805. _, ok := m.clearedFields[agent.FieldAPIKey]
  806. return ok
  807. }
  808. // ResetAPIKey resets all changes to the "api_key" field.
  809. func (m *AgentMutation) ResetAPIKey() {
  810. m.api_key = nil
  811. delete(m.clearedFields, agent.FieldAPIKey)
  812. }
  813. // SetType sets the "type" field.
  814. func (m *AgentMutation) SetType(i int) {
  815. m._type = &i
  816. m.add_type = nil
  817. }
  818. // GetType returns the value of the "type" field in the mutation.
  819. func (m *AgentMutation) GetType() (r int, exists bool) {
  820. v := m._type
  821. if v == nil {
  822. return
  823. }
  824. return *v, true
  825. }
  826. // OldType returns the old "type" field's value of the Agent entity.
  827. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  829. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  830. if !m.op.Is(OpUpdateOne) {
  831. return v, errors.New("OldType is only allowed on UpdateOne operations")
  832. }
  833. if m.id == nil || m.oldValue == nil {
  834. return v, errors.New("OldType requires an ID field in the mutation")
  835. }
  836. oldValue, err := m.oldValue(ctx)
  837. if err != nil {
  838. return v, fmt.Errorf("querying old value for OldType: %w", err)
  839. }
  840. return oldValue.Type, nil
  841. }
  842. // AddType adds i to the "type" field.
  843. func (m *AgentMutation) AddType(i int) {
  844. if m.add_type != nil {
  845. *m.add_type += i
  846. } else {
  847. m.add_type = &i
  848. }
  849. }
  850. // AddedType returns the value that was added to the "type" field in this mutation.
  851. func (m *AgentMutation) AddedType() (r int, exists bool) {
  852. v := m.add_type
  853. if v == nil {
  854. return
  855. }
  856. return *v, true
  857. }
  858. // ClearType clears the value of the "type" field.
  859. func (m *AgentMutation) ClearType() {
  860. m._type = nil
  861. m.add_type = nil
  862. m.clearedFields[agent.FieldType] = struct{}{}
  863. }
  864. // TypeCleared returns if the "type" field was cleared in this mutation.
  865. func (m *AgentMutation) TypeCleared() bool {
  866. _, ok := m.clearedFields[agent.FieldType]
  867. return ok
  868. }
  869. // ResetType resets all changes to the "type" field.
  870. func (m *AgentMutation) ResetType() {
  871. m._type = nil
  872. m.add_type = nil
  873. delete(m.clearedFields, agent.FieldType)
  874. }
  875. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  876. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  877. if m.wx_agent == nil {
  878. m.wx_agent = make(map[uint64]struct{})
  879. }
  880. for i := range ids {
  881. m.wx_agent[ids[i]] = struct{}{}
  882. }
  883. }
  884. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  885. func (m *AgentMutation) ClearWxAgent() {
  886. m.clearedwx_agent = true
  887. }
  888. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  889. func (m *AgentMutation) WxAgentCleared() bool {
  890. return m.clearedwx_agent
  891. }
  892. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  893. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  894. if m.removedwx_agent == nil {
  895. m.removedwx_agent = make(map[uint64]struct{})
  896. }
  897. for i := range ids {
  898. delete(m.wx_agent, ids[i])
  899. m.removedwx_agent[ids[i]] = struct{}{}
  900. }
  901. }
  902. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  903. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  904. for id := range m.removedwx_agent {
  905. ids = append(ids, id)
  906. }
  907. return
  908. }
  909. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  910. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  911. for id := range m.wx_agent {
  912. ids = append(ids, id)
  913. }
  914. return
  915. }
  916. // ResetWxAgent resets all changes to the "wx_agent" edge.
  917. func (m *AgentMutation) ResetWxAgent() {
  918. m.wx_agent = nil
  919. m.clearedwx_agent = false
  920. m.removedwx_agent = nil
  921. }
  922. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  923. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  924. if m.token_agent == nil {
  925. m.token_agent = make(map[uint64]struct{})
  926. }
  927. for i := range ids {
  928. m.token_agent[ids[i]] = struct{}{}
  929. }
  930. }
  931. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  932. func (m *AgentMutation) ClearTokenAgent() {
  933. m.clearedtoken_agent = true
  934. }
  935. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  936. func (m *AgentMutation) TokenAgentCleared() bool {
  937. return m.clearedtoken_agent
  938. }
  939. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  940. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  941. if m.removedtoken_agent == nil {
  942. m.removedtoken_agent = make(map[uint64]struct{})
  943. }
  944. for i := range ids {
  945. delete(m.token_agent, ids[i])
  946. m.removedtoken_agent[ids[i]] = struct{}{}
  947. }
  948. }
  949. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  950. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  951. for id := range m.removedtoken_agent {
  952. ids = append(ids, id)
  953. }
  954. return
  955. }
  956. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  957. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  958. for id := range m.token_agent {
  959. ids = append(ids, id)
  960. }
  961. return
  962. }
  963. // ResetTokenAgent resets all changes to the "token_agent" edge.
  964. func (m *AgentMutation) ResetTokenAgent() {
  965. m.token_agent = nil
  966. m.clearedtoken_agent = false
  967. m.removedtoken_agent = nil
  968. }
  969. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  970. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  971. if m.wa_agent == nil {
  972. m.wa_agent = make(map[uint64]struct{})
  973. }
  974. for i := range ids {
  975. m.wa_agent[ids[i]] = struct{}{}
  976. }
  977. }
  978. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  979. func (m *AgentMutation) ClearWaAgent() {
  980. m.clearedwa_agent = true
  981. }
  982. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  983. func (m *AgentMutation) WaAgentCleared() bool {
  984. return m.clearedwa_agent
  985. }
  986. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  987. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  988. if m.removedwa_agent == nil {
  989. m.removedwa_agent = make(map[uint64]struct{})
  990. }
  991. for i := range ids {
  992. delete(m.wa_agent, ids[i])
  993. m.removedwa_agent[ids[i]] = struct{}{}
  994. }
  995. }
  996. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  997. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  998. for id := range m.removedwa_agent {
  999. ids = append(ids, id)
  1000. }
  1001. return
  1002. }
  1003. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  1004. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  1005. for id := range m.wa_agent {
  1006. ids = append(ids, id)
  1007. }
  1008. return
  1009. }
  1010. // ResetWaAgent resets all changes to the "wa_agent" edge.
  1011. func (m *AgentMutation) ResetWaAgent() {
  1012. m.wa_agent = nil
  1013. m.clearedwa_agent = false
  1014. m.removedwa_agent = nil
  1015. }
  1016. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  1017. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  1018. if m.key_agent == nil {
  1019. m.key_agent = make(map[uint64]struct{})
  1020. }
  1021. for i := range ids {
  1022. m.key_agent[ids[i]] = struct{}{}
  1023. }
  1024. }
  1025. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  1026. func (m *AgentMutation) ClearKeyAgent() {
  1027. m.clearedkey_agent = true
  1028. }
  1029. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  1030. func (m *AgentMutation) KeyAgentCleared() bool {
  1031. return m.clearedkey_agent
  1032. }
  1033. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  1034. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  1035. if m.removedkey_agent == nil {
  1036. m.removedkey_agent = make(map[uint64]struct{})
  1037. }
  1038. for i := range ids {
  1039. delete(m.key_agent, ids[i])
  1040. m.removedkey_agent[ids[i]] = struct{}{}
  1041. }
  1042. }
  1043. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  1044. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  1045. for id := range m.removedkey_agent {
  1046. ids = append(ids, id)
  1047. }
  1048. return
  1049. }
  1050. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  1051. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  1052. for id := range m.key_agent {
  1053. ids = append(ids, id)
  1054. }
  1055. return
  1056. }
  1057. // ResetKeyAgent resets all changes to the "key_agent" edge.
  1058. func (m *AgentMutation) ResetKeyAgent() {
  1059. m.key_agent = nil
  1060. m.clearedkey_agent = false
  1061. m.removedkey_agent = nil
  1062. }
  1063. // Where appends a list predicates to the AgentMutation builder.
  1064. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  1065. m.predicates = append(m.predicates, ps...)
  1066. }
  1067. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  1068. // users can use type-assertion to append predicates that do not depend on any generated package.
  1069. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  1070. p := make([]predicate.Agent, len(ps))
  1071. for i := range ps {
  1072. p[i] = ps[i]
  1073. }
  1074. m.Where(p...)
  1075. }
  1076. // Op returns the operation name.
  1077. func (m *AgentMutation) Op() Op {
  1078. return m.op
  1079. }
  1080. // SetOp allows setting the mutation operation.
  1081. func (m *AgentMutation) SetOp(op Op) {
  1082. m.op = op
  1083. }
  1084. // Type returns the node type of this mutation (Agent).
  1085. func (m *AgentMutation) Type() string {
  1086. return m.typ
  1087. }
  1088. // Fields returns all fields that were changed during this mutation. Note that in
  1089. // order to get all numeric fields that were incremented/decremented, call
  1090. // AddedFields().
  1091. func (m *AgentMutation) Fields() []string {
  1092. fields := make([]string, 0, 15)
  1093. if m.created_at != nil {
  1094. fields = append(fields, agent.FieldCreatedAt)
  1095. }
  1096. if m.updated_at != nil {
  1097. fields = append(fields, agent.FieldUpdatedAt)
  1098. }
  1099. if m.deleted_at != nil {
  1100. fields = append(fields, agent.FieldDeletedAt)
  1101. }
  1102. if m.name != nil {
  1103. fields = append(fields, agent.FieldName)
  1104. }
  1105. if m.role != nil {
  1106. fields = append(fields, agent.FieldRole)
  1107. }
  1108. if m.status != nil {
  1109. fields = append(fields, agent.FieldStatus)
  1110. }
  1111. if m.background != nil {
  1112. fields = append(fields, agent.FieldBackground)
  1113. }
  1114. if m.examples != nil {
  1115. fields = append(fields, agent.FieldExamples)
  1116. }
  1117. if m.organization_id != nil {
  1118. fields = append(fields, agent.FieldOrganizationID)
  1119. }
  1120. if m.dataset_id != nil {
  1121. fields = append(fields, agent.FieldDatasetID)
  1122. }
  1123. if m.collection_id != nil {
  1124. fields = append(fields, agent.FieldCollectionID)
  1125. }
  1126. if m.model != nil {
  1127. fields = append(fields, agent.FieldModel)
  1128. }
  1129. if m.api_base != nil {
  1130. fields = append(fields, agent.FieldAPIBase)
  1131. }
  1132. if m.api_key != nil {
  1133. fields = append(fields, agent.FieldAPIKey)
  1134. }
  1135. if m._type != nil {
  1136. fields = append(fields, agent.FieldType)
  1137. }
  1138. return fields
  1139. }
  1140. // Field returns the value of a field with the given name. The second boolean
  1141. // return value indicates that this field was not set, or was not defined in the
  1142. // schema.
  1143. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  1144. switch name {
  1145. case agent.FieldCreatedAt:
  1146. return m.CreatedAt()
  1147. case agent.FieldUpdatedAt:
  1148. return m.UpdatedAt()
  1149. case agent.FieldDeletedAt:
  1150. return m.DeletedAt()
  1151. case agent.FieldName:
  1152. return m.Name()
  1153. case agent.FieldRole:
  1154. return m.Role()
  1155. case agent.FieldStatus:
  1156. return m.Status()
  1157. case agent.FieldBackground:
  1158. return m.Background()
  1159. case agent.FieldExamples:
  1160. return m.Examples()
  1161. case agent.FieldOrganizationID:
  1162. return m.OrganizationID()
  1163. case agent.FieldDatasetID:
  1164. return m.DatasetID()
  1165. case agent.FieldCollectionID:
  1166. return m.CollectionID()
  1167. case agent.FieldModel:
  1168. return m.Model()
  1169. case agent.FieldAPIBase:
  1170. return m.APIBase()
  1171. case agent.FieldAPIKey:
  1172. return m.APIKey()
  1173. case agent.FieldType:
  1174. return m.GetType()
  1175. }
  1176. return nil, false
  1177. }
  1178. // OldField returns the old value of the field from the database. An error is
  1179. // returned if the mutation operation is not UpdateOne, or the query to the
  1180. // database failed.
  1181. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1182. switch name {
  1183. case agent.FieldCreatedAt:
  1184. return m.OldCreatedAt(ctx)
  1185. case agent.FieldUpdatedAt:
  1186. return m.OldUpdatedAt(ctx)
  1187. case agent.FieldDeletedAt:
  1188. return m.OldDeletedAt(ctx)
  1189. case agent.FieldName:
  1190. return m.OldName(ctx)
  1191. case agent.FieldRole:
  1192. return m.OldRole(ctx)
  1193. case agent.FieldStatus:
  1194. return m.OldStatus(ctx)
  1195. case agent.FieldBackground:
  1196. return m.OldBackground(ctx)
  1197. case agent.FieldExamples:
  1198. return m.OldExamples(ctx)
  1199. case agent.FieldOrganizationID:
  1200. return m.OldOrganizationID(ctx)
  1201. case agent.FieldDatasetID:
  1202. return m.OldDatasetID(ctx)
  1203. case agent.FieldCollectionID:
  1204. return m.OldCollectionID(ctx)
  1205. case agent.FieldModel:
  1206. return m.OldModel(ctx)
  1207. case agent.FieldAPIBase:
  1208. return m.OldAPIBase(ctx)
  1209. case agent.FieldAPIKey:
  1210. return m.OldAPIKey(ctx)
  1211. case agent.FieldType:
  1212. return m.OldType(ctx)
  1213. }
  1214. return nil, fmt.Errorf("unknown Agent field %s", name)
  1215. }
  1216. // SetField sets the value of a field with the given name. It returns an error if
  1217. // the field is not defined in the schema, or if the type mismatched the field
  1218. // type.
  1219. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  1220. switch name {
  1221. case agent.FieldCreatedAt:
  1222. v, ok := value.(time.Time)
  1223. if !ok {
  1224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1225. }
  1226. m.SetCreatedAt(v)
  1227. return nil
  1228. case agent.FieldUpdatedAt:
  1229. v, ok := value.(time.Time)
  1230. if !ok {
  1231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1232. }
  1233. m.SetUpdatedAt(v)
  1234. return nil
  1235. case agent.FieldDeletedAt:
  1236. v, ok := value.(time.Time)
  1237. if !ok {
  1238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1239. }
  1240. m.SetDeletedAt(v)
  1241. return nil
  1242. case agent.FieldName:
  1243. v, ok := value.(string)
  1244. if !ok {
  1245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1246. }
  1247. m.SetName(v)
  1248. return nil
  1249. case agent.FieldRole:
  1250. v, ok := value.(string)
  1251. if !ok {
  1252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1253. }
  1254. m.SetRole(v)
  1255. return nil
  1256. case agent.FieldStatus:
  1257. v, ok := value.(int)
  1258. if !ok {
  1259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1260. }
  1261. m.SetStatus(v)
  1262. return nil
  1263. case agent.FieldBackground:
  1264. v, ok := value.(string)
  1265. if !ok {
  1266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1267. }
  1268. m.SetBackground(v)
  1269. return nil
  1270. case agent.FieldExamples:
  1271. v, ok := value.(string)
  1272. if !ok {
  1273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1274. }
  1275. m.SetExamples(v)
  1276. return nil
  1277. case agent.FieldOrganizationID:
  1278. v, ok := value.(uint64)
  1279. if !ok {
  1280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1281. }
  1282. m.SetOrganizationID(v)
  1283. return nil
  1284. case agent.FieldDatasetID:
  1285. v, ok := value.(string)
  1286. if !ok {
  1287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1288. }
  1289. m.SetDatasetID(v)
  1290. return nil
  1291. case agent.FieldCollectionID:
  1292. v, ok := value.(string)
  1293. if !ok {
  1294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1295. }
  1296. m.SetCollectionID(v)
  1297. return nil
  1298. case agent.FieldModel:
  1299. v, ok := value.(string)
  1300. if !ok {
  1301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1302. }
  1303. m.SetModel(v)
  1304. return nil
  1305. case agent.FieldAPIBase:
  1306. v, ok := value.(string)
  1307. if !ok {
  1308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1309. }
  1310. m.SetAPIBase(v)
  1311. return nil
  1312. case agent.FieldAPIKey:
  1313. v, ok := value.(string)
  1314. if !ok {
  1315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1316. }
  1317. m.SetAPIKey(v)
  1318. return nil
  1319. case agent.FieldType:
  1320. v, ok := value.(int)
  1321. if !ok {
  1322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1323. }
  1324. m.SetType(v)
  1325. return nil
  1326. }
  1327. return fmt.Errorf("unknown Agent field %s", name)
  1328. }
  1329. // AddedFields returns all numeric fields that were incremented/decremented during
  1330. // this mutation.
  1331. func (m *AgentMutation) AddedFields() []string {
  1332. var fields []string
  1333. if m.addstatus != nil {
  1334. fields = append(fields, agent.FieldStatus)
  1335. }
  1336. if m.addorganization_id != nil {
  1337. fields = append(fields, agent.FieldOrganizationID)
  1338. }
  1339. if m.add_type != nil {
  1340. fields = append(fields, agent.FieldType)
  1341. }
  1342. return fields
  1343. }
  1344. // AddedField returns the numeric value that was incremented/decremented on a field
  1345. // with the given name. The second boolean return value indicates that this field
  1346. // was not set, or was not defined in the schema.
  1347. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1348. switch name {
  1349. case agent.FieldStatus:
  1350. return m.AddedStatus()
  1351. case agent.FieldOrganizationID:
  1352. return m.AddedOrganizationID()
  1353. case agent.FieldType:
  1354. return m.AddedType()
  1355. }
  1356. return nil, false
  1357. }
  1358. // AddField adds the value to the field with the given name. It returns an error if
  1359. // the field is not defined in the schema, or if the type mismatched the field
  1360. // type.
  1361. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1362. switch name {
  1363. case agent.FieldStatus:
  1364. v, ok := value.(int)
  1365. if !ok {
  1366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1367. }
  1368. m.AddStatus(v)
  1369. return nil
  1370. case agent.FieldOrganizationID:
  1371. v, ok := value.(int64)
  1372. if !ok {
  1373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1374. }
  1375. m.AddOrganizationID(v)
  1376. return nil
  1377. case agent.FieldType:
  1378. v, ok := value.(int)
  1379. if !ok {
  1380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1381. }
  1382. m.AddType(v)
  1383. return nil
  1384. }
  1385. return fmt.Errorf("unknown Agent numeric field %s", name)
  1386. }
  1387. // ClearedFields returns all nullable fields that were cleared during this
  1388. // mutation.
  1389. func (m *AgentMutation) ClearedFields() []string {
  1390. var fields []string
  1391. if m.FieldCleared(agent.FieldDeletedAt) {
  1392. fields = append(fields, agent.FieldDeletedAt)
  1393. }
  1394. if m.FieldCleared(agent.FieldRole) {
  1395. fields = append(fields, agent.FieldRole)
  1396. }
  1397. if m.FieldCleared(agent.FieldStatus) {
  1398. fields = append(fields, agent.FieldStatus)
  1399. }
  1400. if m.FieldCleared(agent.FieldBackground) {
  1401. fields = append(fields, agent.FieldBackground)
  1402. }
  1403. if m.FieldCleared(agent.FieldExamples) {
  1404. fields = append(fields, agent.FieldExamples)
  1405. }
  1406. if m.FieldCleared(agent.FieldModel) {
  1407. fields = append(fields, agent.FieldModel)
  1408. }
  1409. if m.FieldCleared(agent.FieldAPIBase) {
  1410. fields = append(fields, agent.FieldAPIBase)
  1411. }
  1412. if m.FieldCleared(agent.FieldAPIKey) {
  1413. fields = append(fields, agent.FieldAPIKey)
  1414. }
  1415. if m.FieldCleared(agent.FieldType) {
  1416. fields = append(fields, agent.FieldType)
  1417. }
  1418. return fields
  1419. }
  1420. // FieldCleared returns a boolean indicating if a field with the given name was
  1421. // cleared in this mutation.
  1422. func (m *AgentMutation) FieldCleared(name string) bool {
  1423. _, ok := m.clearedFields[name]
  1424. return ok
  1425. }
  1426. // ClearField clears the value of the field with the given name. It returns an
  1427. // error if the field is not defined in the schema.
  1428. func (m *AgentMutation) ClearField(name string) error {
  1429. switch name {
  1430. case agent.FieldDeletedAt:
  1431. m.ClearDeletedAt()
  1432. return nil
  1433. case agent.FieldRole:
  1434. m.ClearRole()
  1435. return nil
  1436. case agent.FieldStatus:
  1437. m.ClearStatus()
  1438. return nil
  1439. case agent.FieldBackground:
  1440. m.ClearBackground()
  1441. return nil
  1442. case agent.FieldExamples:
  1443. m.ClearExamples()
  1444. return nil
  1445. case agent.FieldModel:
  1446. m.ClearModel()
  1447. return nil
  1448. case agent.FieldAPIBase:
  1449. m.ClearAPIBase()
  1450. return nil
  1451. case agent.FieldAPIKey:
  1452. m.ClearAPIKey()
  1453. return nil
  1454. case agent.FieldType:
  1455. m.ClearType()
  1456. return nil
  1457. }
  1458. return fmt.Errorf("unknown Agent nullable field %s", name)
  1459. }
  1460. // ResetField resets all changes in the mutation for the field with the given name.
  1461. // It returns an error if the field is not defined in the schema.
  1462. func (m *AgentMutation) ResetField(name string) error {
  1463. switch name {
  1464. case agent.FieldCreatedAt:
  1465. m.ResetCreatedAt()
  1466. return nil
  1467. case agent.FieldUpdatedAt:
  1468. m.ResetUpdatedAt()
  1469. return nil
  1470. case agent.FieldDeletedAt:
  1471. m.ResetDeletedAt()
  1472. return nil
  1473. case agent.FieldName:
  1474. m.ResetName()
  1475. return nil
  1476. case agent.FieldRole:
  1477. m.ResetRole()
  1478. return nil
  1479. case agent.FieldStatus:
  1480. m.ResetStatus()
  1481. return nil
  1482. case agent.FieldBackground:
  1483. m.ResetBackground()
  1484. return nil
  1485. case agent.FieldExamples:
  1486. m.ResetExamples()
  1487. return nil
  1488. case agent.FieldOrganizationID:
  1489. m.ResetOrganizationID()
  1490. return nil
  1491. case agent.FieldDatasetID:
  1492. m.ResetDatasetID()
  1493. return nil
  1494. case agent.FieldCollectionID:
  1495. m.ResetCollectionID()
  1496. return nil
  1497. case agent.FieldModel:
  1498. m.ResetModel()
  1499. return nil
  1500. case agent.FieldAPIBase:
  1501. m.ResetAPIBase()
  1502. return nil
  1503. case agent.FieldAPIKey:
  1504. m.ResetAPIKey()
  1505. return nil
  1506. case agent.FieldType:
  1507. m.ResetType()
  1508. return nil
  1509. }
  1510. return fmt.Errorf("unknown Agent field %s", name)
  1511. }
  1512. // AddedEdges returns all edge names that were set/added in this mutation.
  1513. func (m *AgentMutation) AddedEdges() []string {
  1514. edges := make([]string, 0, 4)
  1515. if m.wx_agent != nil {
  1516. edges = append(edges, agent.EdgeWxAgent)
  1517. }
  1518. if m.token_agent != nil {
  1519. edges = append(edges, agent.EdgeTokenAgent)
  1520. }
  1521. if m.wa_agent != nil {
  1522. edges = append(edges, agent.EdgeWaAgent)
  1523. }
  1524. if m.key_agent != nil {
  1525. edges = append(edges, agent.EdgeKeyAgent)
  1526. }
  1527. return edges
  1528. }
  1529. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1530. // name in this mutation.
  1531. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1532. switch name {
  1533. case agent.EdgeWxAgent:
  1534. ids := make([]ent.Value, 0, len(m.wx_agent))
  1535. for id := range m.wx_agent {
  1536. ids = append(ids, id)
  1537. }
  1538. return ids
  1539. case agent.EdgeTokenAgent:
  1540. ids := make([]ent.Value, 0, len(m.token_agent))
  1541. for id := range m.token_agent {
  1542. ids = append(ids, id)
  1543. }
  1544. return ids
  1545. case agent.EdgeWaAgent:
  1546. ids := make([]ent.Value, 0, len(m.wa_agent))
  1547. for id := range m.wa_agent {
  1548. ids = append(ids, id)
  1549. }
  1550. return ids
  1551. case agent.EdgeKeyAgent:
  1552. ids := make([]ent.Value, 0, len(m.key_agent))
  1553. for id := range m.key_agent {
  1554. ids = append(ids, id)
  1555. }
  1556. return ids
  1557. }
  1558. return nil
  1559. }
  1560. // RemovedEdges returns all edge names that were removed in this mutation.
  1561. func (m *AgentMutation) RemovedEdges() []string {
  1562. edges := make([]string, 0, 4)
  1563. if m.removedwx_agent != nil {
  1564. edges = append(edges, agent.EdgeWxAgent)
  1565. }
  1566. if m.removedtoken_agent != nil {
  1567. edges = append(edges, agent.EdgeTokenAgent)
  1568. }
  1569. if m.removedwa_agent != nil {
  1570. edges = append(edges, agent.EdgeWaAgent)
  1571. }
  1572. if m.removedkey_agent != nil {
  1573. edges = append(edges, agent.EdgeKeyAgent)
  1574. }
  1575. return edges
  1576. }
  1577. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1578. // the given name in this mutation.
  1579. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1580. switch name {
  1581. case agent.EdgeWxAgent:
  1582. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1583. for id := range m.removedwx_agent {
  1584. ids = append(ids, id)
  1585. }
  1586. return ids
  1587. case agent.EdgeTokenAgent:
  1588. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1589. for id := range m.removedtoken_agent {
  1590. ids = append(ids, id)
  1591. }
  1592. return ids
  1593. case agent.EdgeWaAgent:
  1594. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1595. for id := range m.removedwa_agent {
  1596. ids = append(ids, id)
  1597. }
  1598. return ids
  1599. case agent.EdgeKeyAgent:
  1600. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1601. for id := range m.removedkey_agent {
  1602. ids = append(ids, id)
  1603. }
  1604. return ids
  1605. }
  1606. return nil
  1607. }
  1608. // ClearedEdges returns all edge names that were cleared in this mutation.
  1609. func (m *AgentMutation) ClearedEdges() []string {
  1610. edges := make([]string, 0, 4)
  1611. if m.clearedwx_agent {
  1612. edges = append(edges, agent.EdgeWxAgent)
  1613. }
  1614. if m.clearedtoken_agent {
  1615. edges = append(edges, agent.EdgeTokenAgent)
  1616. }
  1617. if m.clearedwa_agent {
  1618. edges = append(edges, agent.EdgeWaAgent)
  1619. }
  1620. if m.clearedkey_agent {
  1621. edges = append(edges, agent.EdgeKeyAgent)
  1622. }
  1623. return edges
  1624. }
  1625. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1626. // was cleared in this mutation.
  1627. func (m *AgentMutation) EdgeCleared(name string) bool {
  1628. switch name {
  1629. case agent.EdgeWxAgent:
  1630. return m.clearedwx_agent
  1631. case agent.EdgeTokenAgent:
  1632. return m.clearedtoken_agent
  1633. case agent.EdgeWaAgent:
  1634. return m.clearedwa_agent
  1635. case agent.EdgeKeyAgent:
  1636. return m.clearedkey_agent
  1637. }
  1638. return false
  1639. }
  1640. // ClearEdge clears the value of the edge with the given name. It returns an error
  1641. // if that edge is not defined in the schema.
  1642. func (m *AgentMutation) ClearEdge(name string) error {
  1643. switch name {
  1644. }
  1645. return fmt.Errorf("unknown Agent unique edge %s", name)
  1646. }
  1647. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1648. // It returns an error if the edge is not defined in the schema.
  1649. func (m *AgentMutation) ResetEdge(name string) error {
  1650. switch name {
  1651. case agent.EdgeWxAgent:
  1652. m.ResetWxAgent()
  1653. return nil
  1654. case agent.EdgeTokenAgent:
  1655. m.ResetTokenAgent()
  1656. return nil
  1657. case agent.EdgeWaAgent:
  1658. m.ResetWaAgent()
  1659. return nil
  1660. case agent.EdgeKeyAgent:
  1661. m.ResetKeyAgent()
  1662. return nil
  1663. }
  1664. return fmt.Errorf("unknown Agent edge %s", name)
  1665. }
  1666. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1667. type AgentBaseMutation struct {
  1668. config
  1669. op Op
  1670. typ string
  1671. id *string
  1672. q *string
  1673. a *string
  1674. chunk_index *uint64
  1675. addchunk_index *int64
  1676. indexes *[]string
  1677. appendindexes []string
  1678. dataset_id *string
  1679. collection_id *string
  1680. source_name *string
  1681. can_write *[]bool
  1682. appendcan_write []bool
  1683. is_owner *[]bool
  1684. appendis_owner []bool
  1685. clearedFields map[string]struct{}
  1686. wx_agent map[uint64]struct{}
  1687. removedwx_agent map[uint64]struct{}
  1688. clearedwx_agent bool
  1689. done bool
  1690. oldValue func(context.Context) (*AgentBase, error)
  1691. predicates []predicate.AgentBase
  1692. }
  1693. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1694. // agentbaseOption allows management of the mutation configuration using functional options.
  1695. type agentbaseOption func(*AgentBaseMutation)
  1696. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1697. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1698. m := &AgentBaseMutation{
  1699. config: c,
  1700. op: op,
  1701. typ: TypeAgentBase,
  1702. clearedFields: make(map[string]struct{}),
  1703. }
  1704. for _, opt := range opts {
  1705. opt(m)
  1706. }
  1707. return m
  1708. }
  1709. // withAgentBaseID sets the ID field of the mutation.
  1710. func withAgentBaseID(id string) agentbaseOption {
  1711. return func(m *AgentBaseMutation) {
  1712. var (
  1713. err error
  1714. once sync.Once
  1715. value *AgentBase
  1716. )
  1717. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1718. once.Do(func() {
  1719. if m.done {
  1720. err = errors.New("querying old values post mutation is not allowed")
  1721. } else {
  1722. value, err = m.Client().AgentBase.Get(ctx, id)
  1723. }
  1724. })
  1725. return value, err
  1726. }
  1727. m.id = &id
  1728. }
  1729. }
  1730. // withAgentBase sets the old AgentBase of the mutation.
  1731. func withAgentBase(node *AgentBase) agentbaseOption {
  1732. return func(m *AgentBaseMutation) {
  1733. m.oldValue = func(context.Context) (*AgentBase, error) {
  1734. return node, nil
  1735. }
  1736. m.id = &node.ID
  1737. }
  1738. }
  1739. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1740. // executed in a transaction (ent.Tx), a transactional client is returned.
  1741. func (m AgentBaseMutation) Client() *Client {
  1742. client := &Client{config: m.config}
  1743. client.init()
  1744. return client
  1745. }
  1746. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1747. // it returns an error otherwise.
  1748. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1749. if _, ok := m.driver.(*txDriver); !ok {
  1750. return nil, errors.New("ent: mutation is not running in a transaction")
  1751. }
  1752. tx := &Tx{config: m.config}
  1753. tx.init()
  1754. return tx, nil
  1755. }
  1756. // SetID sets the value of the id field. Note that this
  1757. // operation is only accepted on creation of AgentBase entities.
  1758. func (m *AgentBaseMutation) SetID(id string) {
  1759. m.id = &id
  1760. }
  1761. // ID returns the ID value in the mutation. Note that the ID is only available
  1762. // if it was provided to the builder or after it was returned from the database.
  1763. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1764. if m.id == nil {
  1765. return
  1766. }
  1767. return *m.id, true
  1768. }
  1769. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1770. // That means, if the mutation is applied within a transaction with an isolation level such
  1771. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1772. // or updated by the mutation.
  1773. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1774. switch {
  1775. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1776. id, exists := m.ID()
  1777. if exists {
  1778. return []string{id}, nil
  1779. }
  1780. fallthrough
  1781. case m.op.Is(OpUpdate | OpDelete):
  1782. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1783. default:
  1784. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1785. }
  1786. }
  1787. // SetQ sets the "q" field.
  1788. func (m *AgentBaseMutation) SetQ(s string) {
  1789. m.q = &s
  1790. }
  1791. // Q returns the value of the "q" field in the mutation.
  1792. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1793. v := m.q
  1794. if v == nil {
  1795. return
  1796. }
  1797. return *v, true
  1798. }
  1799. // OldQ returns the old "q" field's value of the AgentBase entity.
  1800. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1802. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1803. if !m.op.Is(OpUpdateOne) {
  1804. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1805. }
  1806. if m.id == nil || m.oldValue == nil {
  1807. return v, errors.New("OldQ requires an ID field in the mutation")
  1808. }
  1809. oldValue, err := m.oldValue(ctx)
  1810. if err != nil {
  1811. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1812. }
  1813. return oldValue.Q, nil
  1814. }
  1815. // ClearQ clears the value of the "q" field.
  1816. func (m *AgentBaseMutation) ClearQ() {
  1817. m.q = nil
  1818. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1819. }
  1820. // QCleared returns if the "q" field was cleared in this mutation.
  1821. func (m *AgentBaseMutation) QCleared() bool {
  1822. _, ok := m.clearedFields[agentbase.FieldQ]
  1823. return ok
  1824. }
  1825. // ResetQ resets all changes to the "q" field.
  1826. func (m *AgentBaseMutation) ResetQ() {
  1827. m.q = nil
  1828. delete(m.clearedFields, agentbase.FieldQ)
  1829. }
  1830. // SetA sets the "a" field.
  1831. func (m *AgentBaseMutation) SetA(s string) {
  1832. m.a = &s
  1833. }
  1834. // A returns the value of the "a" field in the mutation.
  1835. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1836. v := m.a
  1837. if v == nil {
  1838. return
  1839. }
  1840. return *v, true
  1841. }
  1842. // OldA returns the old "a" field's value of the AgentBase entity.
  1843. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1845. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1846. if !m.op.Is(OpUpdateOne) {
  1847. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1848. }
  1849. if m.id == nil || m.oldValue == nil {
  1850. return v, errors.New("OldA requires an ID field in the mutation")
  1851. }
  1852. oldValue, err := m.oldValue(ctx)
  1853. if err != nil {
  1854. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1855. }
  1856. return oldValue.A, nil
  1857. }
  1858. // ClearA clears the value of the "a" field.
  1859. func (m *AgentBaseMutation) ClearA() {
  1860. m.a = nil
  1861. m.clearedFields[agentbase.FieldA] = struct{}{}
  1862. }
  1863. // ACleared returns if the "a" field was cleared in this mutation.
  1864. func (m *AgentBaseMutation) ACleared() bool {
  1865. _, ok := m.clearedFields[agentbase.FieldA]
  1866. return ok
  1867. }
  1868. // ResetA resets all changes to the "a" field.
  1869. func (m *AgentBaseMutation) ResetA() {
  1870. m.a = nil
  1871. delete(m.clearedFields, agentbase.FieldA)
  1872. }
  1873. // SetChunkIndex sets the "chunk_index" field.
  1874. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1875. m.chunk_index = &u
  1876. m.addchunk_index = nil
  1877. }
  1878. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1879. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1880. v := m.chunk_index
  1881. if v == nil {
  1882. return
  1883. }
  1884. return *v, true
  1885. }
  1886. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1887. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1889. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1890. if !m.op.Is(OpUpdateOne) {
  1891. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1892. }
  1893. if m.id == nil || m.oldValue == nil {
  1894. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1895. }
  1896. oldValue, err := m.oldValue(ctx)
  1897. if err != nil {
  1898. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1899. }
  1900. return oldValue.ChunkIndex, nil
  1901. }
  1902. // AddChunkIndex adds u to the "chunk_index" field.
  1903. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1904. if m.addchunk_index != nil {
  1905. *m.addchunk_index += u
  1906. } else {
  1907. m.addchunk_index = &u
  1908. }
  1909. }
  1910. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1911. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1912. v := m.addchunk_index
  1913. if v == nil {
  1914. return
  1915. }
  1916. return *v, true
  1917. }
  1918. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1919. func (m *AgentBaseMutation) ResetChunkIndex() {
  1920. m.chunk_index = nil
  1921. m.addchunk_index = nil
  1922. }
  1923. // SetIndexes sets the "indexes" field.
  1924. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1925. m.indexes = &s
  1926. m.appendindexes = nil
  1927. }
  1928. // Indexes returns the value of the "indexes" field in the mutation.
  1929. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1930. v := m.indexes
  1931. if v == nil {
  1932. return
  1933. }
  1934. return *v, true
  1935. }
  1936. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1937. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1939. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1940. if !m.op.Is(OpUpdateOne) {
  1941. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1942. }
  1943. if m.id == nil || m.oldValue == nil {
  1944. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1945. }
  1946. oldValue, err := m.oldValue(ctx)
  1947. if err != nil {
  1948. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1949. }
  1950. return oldValue.Indexes, nil
  1951. }
  1952. // AppendIndexes adds s to the "indexes" field.
  1953. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1954. m.appendindexes = append(m.appendindexes, s...)
  1955. }
  1956. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1957. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1958. if len(m.appendindexes) == 0 {
  1959. return nil, false
  1960. }
  1961. return m.appendindexes, true
  1962. }
  1963. // ClearIndexes clears the value of the "indexes" field.
  1964. func (m *AgentBaseMutation) ClearIndexes() {
  1965. m.indexes = nil
  1966. m.appendindexes = nil
  1967. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1968. }
  1969. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1970. func (m *AgentBaseMutation) IndexesCleared() bool {
  1971. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1972. return ok
  1973. }
  1974. // ResetIndexes resets all changes to the "indexes" field.
  1975. func (m *AgentBaseMutation) ResetIndexes() {
  1976. m.indexes = nil
  1977. m.appendindexes = nil
  1978. delete(m.clearedFields, agentbase.FieldIndexes)
  1979. }
  1980. // SetDatasetID sets the "dataset_id" field.
  1981. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1982. m.dataset_id = &s
  1983. }
  1984. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1985. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1986. v := m.dataset_id
  1987. if v == nil {
  1988. return
  1989. }
  1990. return *v, true
  1991. }
  1992. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1993. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1995. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1996. if !m.op.Is(OpUpdateOne) {
  1997. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1998. }
  1999. if m.id == nil || m.oldValue == nil {
  2000. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  2001. }
  2002. oldValue, err := m.oldValue(ctx)
  2003. if err != nil {
  2004. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  2005. }
  2006. return oldValue.DatasetID, nil
  2007. }
  2008. // ClearDatasetID clears the value of the "dataset_id" field.
  2009. func (m *AgentBaseMutation) ClearDatasetID() {
  2010. m.dataset_id = nil
  2011. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  2012. }
  2013. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  2014. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  2015. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  2016. return ok
  2017. }
  2018. // ResetDatasetID resets all changes to the "dataset_id" field.
  2019. func (m *AgentBaseMutation) ResetDatasetID() {
  2020. m.dataset_id = nil
  2021. delete(m.clearedFields, agentbase.FieldDatasetID)
  2022. }
  2023. // SetCollectionID sets the "collection_id" field.
  2024. func (m *AgentBaseMutation) SetCollectionID(s string) {
  2025. m.collection_id = &s
  2026. }
  2027. // CollectionID returns the value of the "collection_id" field in the mutation.
  2028. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  2029. v := m.collection_id
  2030. if v == nil {
  2031. return
  2032. }
  2033. return *v, true
  2034. }
  2035. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  2036. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2038. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  2039. if !m.op.Is(OpUpdateOne) {
  2040. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  2041. }
  2042. if m.id == nil || m.oldValue == nil {
  2043. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  2044. }
  2045. oldValue, err := m.oldValue(ctx)
  2046. if err != nil {
  2047. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  2048. }
  2049. return oldValue.CollectionID, nil
  2050. }
  2051. // ClearCollectionID clears the value of the "collection_id" field.
  2052. func (m *AgentBaseMutation) ClearCollectionID() {
  2053. m.collection_id = nil
  2054. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  2055. }
  2056. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  2057. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  2058. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  2059. return ok
  2060. }
  2061. // ResetCollectionID resets all changes to the "collection_id" field.
  2062. func (m *AgentBaseMutation) ResetCollectionID() {
  2063. m.collection_id = nil
  2064. delete(m.clearedFields, agentbase.FieldCollectionID)
  2065. }
  2066. // SetSourceName sets the "source_name" field.
  2067. func (m *AgentBaseMutation) SetSourceName(s string) {
  2068. m.source_name = &s
  2069. }
  2070. // SourceName returns the value of the "source_name" field in the mutation.
  2071. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  2072. v := m.source_name
  2073. if v == nil {
  2074. return
  2075. }
  2076. return *v, true
  2077. }
  2078. // OldSourceName returns the old "source_name" 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) OldSourceName(ctx context.Context) (v string, err error) {
  2082. if !m.op.Is(OpUpdateOne) {
  2083. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  2084. }
  2085. if m.id == nil || m.oldValue == nil {
  2086. return v, errors.New("OldSourceName 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 OldSourceName: %w", err)
  2091. }
  2092. return oldValue.SourceName, nil
  2093. }
  2094. // ClearSourceName clears the value of the "source_name" field.
  2095. func (m *AgentBaseMutation) ClearSourceName() {
  2096. m.source_name = nil
  2097. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  2098. }
  2099. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  2100. func (m *AgentBaseMutation) SourceNameCleared() bool {
  2101. _, ok := m.clearedFields[agentbase.FieldSourceName]
  2102. return ok
  2103. }
  2104. // ResetSourceName resets all changes to the "source_name" field.
  2105. func (m *AgentBaseMutation) ResetSourceName() {
  2106. m.source_name = nil
  2107. delete(m.clearedFields, agentbase.FieldSourceName)
  2108. }
  2109. // SetCanWrite sets the "can_write" field.
  2110. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  2111. m.can_write = &b
  2112. m.appendcan_write = nil
  2113. }
  2114. // CanWrite returns the value of the "can_write" field in the mutation.
  2115. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  2116. v := m.can_write
  2117. if v == nil {
  2118. return
  2119. }
  2120. return *v, true
  2121. }
  2122. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  2123. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2125. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  2126. if !m.op.Is(OpUpdateOne) {
  2127. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  2128. }
  2129. if m.id == nil || m.oldValue == nil {
  2130. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  2131. }
  2132. oldValue, err := m.oldValue(ctx)
  2133. if err != nil {
  2134. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  2135. }
  2136. return oldValue.CanWrite, nil
  2137. }
  2138. // AppendCanWrite adds b to the "can_write" field.
  2139. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  2140. m.appendcan_write = append(m.appendcan_write, b...)
  2141. }
  2142. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  2143. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  2144. if len(m.appendcan_write) == 0 {
  2145. return nil, false
  2146. }
  2147. return m.appendcan_write, true
  2148. }
  2149. // ClearCanWrite clears the value of the "can_write" field.
  2150. func (m *AgentBaseMutation) ClearCanWrite() {
  2151. m.can_write = nil
  2152. m.appendcan_write = nil
  2153. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  2154. }
  2155. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  2156. func (m *AgentBaseMutation) CanWriteCleared() bool {
  2157. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  2158. return ok
  2159. }
  2160. // ResetCanWrite resets all changes to the "can_write" field.
  2161. func (m *AgentBaseMutation) ResetCanWrite() {
  2162. m.can_write = nil
  2163. m.appendcan_write = nil
  2164. delete(m.clearedFields, agentbase.FieldCanWrite)
  2165. }
  2166. // SetIsOwner sets the "is_owner" field.
  2167. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  2168. m.is_owner = &b
  2169. m.appendis_owner = nil
  2170. }
  2171. // IsOwner returns the value of the "is_owner" field in the mutation.
  2172. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  2173. v := m.is_owner
  2174. if v == nil {
  2175. return
  2176. }
  2177. return *v, true
  2178. }
  2179. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  2180. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  2181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2182. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  2183. if !m.op.Is(OpUpdateOne) {
  2184. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  2185. }
  2186. if m.id == nil || m.oldValue == nil {
  2187. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  2188. }
  2189. oldValue, err := m.oldValue(ctx)
  2190. if err != nil {
  2191. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  2192. }
  2193. return oldValue.IsOwner, nil
  2194. }
  2195. // AppendIsOwner adds b to the "is_owner" field.
  2196. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  2197. m.appendis_owner = append(m.appendis_owner, b...)
  2198. }
  2199. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  2200. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  2201. if len(m.appendis_owner) == 0 {
  2202. return nil, false
  2203. }
  2204. return m.appendis_owner, true
  2205. }
  2206. // ClearIsOwner clears the value of the "is_owner" field.
  2207. func (m *AgentBaseMutation) ClearIsOwner() {
  2208. m.is_owner = nil
  2209. m.appendis_owner = nil
  2210. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  2211. }
  2212. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  2213. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  2214. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  2215. return ok
  2216. }
  2217. // ResetIsOwner resets all changes to the "is_owner" field.
  2218. func (m *AgentBaseMutation) ResetIsOwner() {
  2219. m.is_owner = nil
  2220. m.appendis_owner = nil
  2221. delete(m.clearedFields, agentbase.FieldIsOwner)
  2222. }
  2223. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2224. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  2225. if m.wx_agent == nil {
  2226. m.wx_agent = make(map[uint64]struct{})
  2227. }
  2228. for i := range ids {
  2229. m.wx_agent[ids[i]] = struct{}{}
  2230. }
  2231. }
  2232. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2233. func (m *AgentBaseMutation) ClearWxAgent() {
  2234. m.clearedwx_agent = true
  2235. }
  2236. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2237. func (m *AgentBaseMutation) WxAgentCleared() bool {
  2238. return m.clearedwx_agent
  2239. }
  2240. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2241. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  2242. if m.removedwx_agent == nil {
  2243. m.removedwx_agent = make(map[uint64]struct{})
  2244. }
  2245. for i := range ids {
  2246. delete(m.wx_agent, ids[i])
  2247. m.removedwx_agent[ids[i]] = struct{}{}
  2248. }
  2249. }
  2250. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2251. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  2252. for id := range m.removedwx_agent {
  2253. ids = append(ids, id)
  2254. }
  2255. return
  2256. }
  2257. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2258. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  2259. for id := range m.wx_agent {
  2260. ids = append(ids, id)
  2261. }
  2262. return
  2263. }
  2264. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2265. func (m *AgentBaseMutation) ResetWxAgent() {
  2266. m.wx_agent = nil
  2267. m.clearedwx_agent = false
  2268. m.removedwx_agent = nil
  2269. }
  2270. // Where appends a list predicates to the AgentBaseMutation builder.
  2271. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  2272. m.predicates = append(m.predicates, ps...)
  2273. }
  2274. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  2275. // users can use type-assertion to append predicates that do not depend on any generated package.
  2276. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  2277. p := make([]predicate.AgentBase, len(ps))
  2278. for i := range ps {
  2279. p[i] = ps[i]
  2280. }
  2281. m.Where(p...)
  2282. }
  2283. // Op returns the operation name.
  2284. func (m *AgentBaseMutation) Op() Op {
  2285. return m.op
  2286. }
  2287. // SetOp allows setting the mutation operation.
  2288. func (m *AgentBaseMutation) SetOp(op Op) {
  2289. m.op = op
  2290. }
  2291. // Type returns the node type of this mutation (AgentBase).
  2292. func (m *AgentBaseMutation) Type() string {
  2293. return m.typ
  2294. }
  2295. // Fields returns all fields that were changed during this mutation. Note that in
  2296. // order to get all numeric fields that were incremented/decremented, call
  2297. // AddedFields().
  2298. func (m *AgentBaseMutation) Fields() []string {
  2299. fields := make([]string, 0, 9)
  2300. if m.q != nil {
  2301. fields = append(fields, agentbase.FieldQ)
  2302. }
  2303. if m.a != nil {
  2304. fields = append(fields, agentbase.FieldA)
  2305. }
  2306. if m.chunk_index != nil {
  2307. fields = append(fields, agentbase.FieldChunkIndex)
  2308. }
  2309. if m.indexes != nil {
  2310. fields = append(fields, agentbase.FieldIndexes)
  2311. }
  2312. if m.dataset_id != nil {
  2313. fields = append(fields, agentbase.FieldDatasetID)
  2314. }
  2315. if m.collection_id != nil {
  2316. fields = append(fields, agentbase.FieldCollectionID)
  2317. }
  2318. if m.source_name != nil {
  2319. fields = append(fields, agentbase.FieldSourceName)
  2320. }
  2321. if m.can_write != nil {
  2322. fields = append(fields, agentbase.FieldCanWrite)
  2323. }
  2324. if m.is_owner != nil {
  2325. fields = append(fields, agentbase.FieldIsOwner)
  2326. }
  2327. return fields
  2328. }
  2329. // Field returns the value of a field with the given name. The second boolean
  2330. // return value indicates that this field was not set, or was not defined in the
  2331. // schema.
  2332. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2333. switch name {
  2334. case agentbase.FieldQ:
  2335. return m.Q()
  2336. case agentbase.FieldA:
  2337. return m.A()
  2338. case agentbase.FieldChunkIndex:
  2339. return m.ChunkIndex()
  2340. case agentbase.FieldIndexes:
  2341. return m.Indexes()
  2342. case agentbase.FieldDatasetID:
  2343. return m.DatasetID()
  2344. case agentbase.FieldCollectionID:
  2345. return m.CollectionID()
  2346. case agentbase.FieldSourceName:
  2347. return m.SourceName()
  2348. case agentbase.FieldCanWrite:
  2349. return m.CanWrite()
  2350. case agentbase.FieldIsOwner:
  2351. return m.IsOwner()
  2352. }
  2353. return nil, false
  2354. }
  2355. // OldField returns the old value of the field from the database. An error is
  2356. // returned if the mutation operation is not UpdateOne, or the query to the
  2357. // database failed.
  2358. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2359. switch name {
  2360. case agentbase.FieldQ:
  2361. return m.OldQ(ctx)
  2362. case agentbase.FieldA:
  2363. return m.OldA(ctx)
  2364. case agentbase.FieldChunkIndex:
  2365. return m.OldChunkIndex(ctx)
  2366. case agentbase.FieldIndexes:
  2367. return m.OldIndexes(ctx)
  2368. case agentbase.FieldDatasetID:
  2369. return m.OldDatasetID(ctx)
  2370. case agentbase.FieldCollectionID:
  2371. return m.OldCollectionID(ctx)
  2372. case agentbase.FieldSourceName:
  2373. return m.OldSourceName(ctx)
  2374. case agentbase.FieldCanWrite:
  2375. return m.OldCanWrite(ctx)
  2376. case agentbase.FieldIsOwner:
  2377. return m.OldIsOwner(ctx)
  2378. }
  2379. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2380. }
  2381. // SetField sets the value of a field with the given name. It returns an error if
  2382. // the field is not defined in the schema, or if the type mismatched the field
  2383. // type.
  2384. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2385. switch name {
  2386. case agentbase.FieldQ:
  2387. v, ok := value.(string)
  2388. if !ok {
  2389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2390. }
  2391. m.SetQ(v)
  2392. return nil
  2393. case agentbase.FieldA:
  2394. v, ok := value.(string)
  2395. if !ok {
  2396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2397. }
  2398. m.SetA(v)
  2399. return nil
  2400. case agentbase.FieldChunkIndex:
  2401. v, ok := value.(uint64)
  2402. if !ok {
  2403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2404. }
  2405. m.SetChunkIndex(v)
  2406. return nil
  2407. case agentbase.FieldIndexes:
  2408. v, ok := value.([]string)
  2409. if !ok {
  2410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2411. }
  2412. m.SetIndexes(v)
  2413. return nil
  2414. case agentbase.FieldDatasetID:
  2415. v, ok := value.(string)
  2416. if !ok {
  2417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2418. }
  2419. m.SetDatasetID(v)
  2420. return nil
  2421. case agentbase.FieldCollectionID:
  2422. v, ok := value.(string)
  2423. if !ok {
  2424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2425. }
  2426. m.SetCollectionID(v)
  2427. return nil
  2428. case agentbase.FieldSourceName:
  2429. v, ok := value.(string)
  2430. if !ok {
  2431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2432. }
  2433. m.SetSourceName(v)
  2434. return nil
  2435. case agentbase.FieldCanWrite:
  2436. v, ok := value.([]bool)
  2437. if !ok {
  2438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2439. }
  2440. m.SetCanWrite(v)
  2441. return nil
  2442. case agentbase.FieldIsOwner:
  2443. v, ok := value.([]bool)
  2444. if !ok {
  2445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2446. }
  2447. m.SetIsOwner(v)
  2448. return nil
  2449. }
  2450. return fmt.Errorf("unknown AgentBase field %s", name)
  2451. }
  2452. // AddedFields returns all numeric fields that were incremented/decremented during
  2453. // this mutation.
  2454. func (m *AgentBaseMutation) AddedFields() []string {
  2455. var fields []string
  2456. if m.addchunk_index != nil {
  2457. fields = append(fields, agentbase.FieldChunkIndex)
  2458. }
  2459. return fields
  2460. }
  2461. // AddedField returns the numeric value that was incremented/decremented on a field
  2462. // with the given name. The second boolean return value indicates that this field
  2463. // was not set, or was not defined in the schema.
  2464. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2465. switch name {
  2466. case agentbase.FieldChunkIndex:
  2467. return m.AddedChunkIndex()
  2468. }
  2469. return nil, false
  2470. }
  2471. // AddField adds the value to the field with the given name. It returns an error if
  2472. // the field is not defined in the schema, or if the type mismatched the field
  2473. // type.
  2474. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2475. switch name {
  2476. case agentbase.FieldChunkIndex:
  2477. v, ok := value.(int64)
  2478. if !ok {
  2479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2480. }
  2481. m.AddChunkIndex(v)
  2482. return nil
  2483. }
  2484. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2485. }
  2486. // ClearedFields returns all nullable fields that were cleared during this
  2487. // mutation.
  2488. func (m *AgentBaseMutation) ClearedFields() []string {
  2489. var fields []string
  2490. if m.FieldCleared(agentbase.FieldQ) {
  2491. fields = append(fields, agentbase.FieldQ)
  2492. }
  2493. if m.FieldCleared(agentbase.FieldA) {
  2494. fields = append(fields, agentbase.FieldA)
  2495. }
  2496. if m.FieldCleared(agentbase.FieldIndexes) {
  2497. fields = append(fields, agentbase.FieldIndexes)
  2498. }
  2499. if m.FieldCleared(agentbase.FieldDatasetID) {
  2500. fields = append(fields, agentbase.FieldDatasetID)
  2501. }
  2502. if m.FieldCleared(agentbase.FieldCollectionID) {
  2503. fields = append(fields, agentbase.FieldCollectionID)
  2504. }
  2505. if m.FieldCleared(agentbase.FieldSourceName) {
  2506. fields = append(fields, agentbase.FieldSourceName)
  2507. }
  2508. if m.FieldCleared(agentbase.FieldCanWrite) {
  2509. fields = append(fields, agentbase.FieldCanWrite)
  2510. }
  2511. if m.FieldCleared(agentbase.FieldIsOwner) {
  2512. fields = append(fields, agentbase.FieldIsOwner)
  2513. }
  2514. return fields
  2515. }
  2516. // FieldCleared returns a boolean indicating if a field with the given name was
  2517. // cleared in this mutation.
  2518. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2519. _, ok := m.clearedFields[name]
  2520. return ok
  2521. }
  2522. // ClearField clears the value of the field with the given name. It returns an
  2523. // error if the field is not defined in the schema.
  2524. func (m *AgentBaseMutation) ClearField(name string) error {
  2525. switch name {
  2526. case agentbase.FieldQ:
  2527. m.ClearQ()
  2528. return nil
  2529. case agentbase.FieldA:
  2530. m.ClearA()
  2531. return nil
  2532. case agentbase.FieldIndexes:
  2533. m.ClearIndexes()
  2534. return nil
  2535. case agentbase.FieldDatasetID:
  2536. m.ClearDatasetID()
  2537. return nil
  2538. case agentbase.FieldCollectionID:
  2539. m.ClearCollectionID()
  2540. return nil
  2541. case agentbase.FieldSourceName:
  2542. m.ClearSourceName()
  2543. return nil
  2544. case agentbase.FieldCanWrite:
  2545. m.ClearCanWrite()
  2546. return nil
  2547. case agentbase.FieldIsOwner:
  2548. m.ClearIsOwner()
  2549. return nil
  2550. }
  2551. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2552. }
  2553. // ResetField resets all changes in the mutation for the field with the given name.
  2554. // It returns an error if the field is not defined in the schema.
  2555. func (m *AgentBaseMutation) ResetField(name string) error {
  2556. switch name {
  2557. case agentbase.FieldQ:
  2558. m.ResetQ()
  2559. return nil
  2560. case agentbase.FieldA:
  2561. m.ResetA()
  2562. return nil
  2563. case agentbase.FieldChunkIndex:
  2564. m.ResetChunkIndex()
  2565. return nil
  2566. case agentbase.FieldIndexes:
  2567. m.ResetIndexes()
  2568. return nil
  2569. case agentbase.FieldDatasetID:
  2570. m.ResetDatasetID()
  2571. return nil
  2572. case agentbase.FieldCollectionID:
  2573. m.ResetCollectionID()
  2574. return nil
  2575. case agentbase.FieldSourceName:
  2576. m.ResetSourceName()
  2577. return nil
  2578. case agentbase.FieldCanWrite:
  2579. m.ResetCanWrite()
  2580. return nil
  2581. case agentbase.FieldIsOwner:
  2582. m.ResetIsOwner()
  2583. return nil
  2584. }
  2585. return fmt.Errorf("unknown AgentBase field %s", name)
  2586. }
  2587. // AddedEdges returns all edge names that were set/added in this mutation.
  2588. func (m *AgentBaseMutation) AddedEdges() []string {
  2589. edges := make([]string, 0, 1)
  2590. if m.wx_agent != nil {
  2591. edges = append(edges, agentbase.EdgeWxAgent)
  2592. }
  2593. return edges
  2594. }
  2595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2596. // name in this mutation.
  2597. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2598. switch name {
  2599. case agentbase.EdgeWxAgent:
  2600. ids := make([]ent.Value, 0, len(m.wx_agent))
  2601. for id := range m.wx_agent {
  2602. ids = append(ids, id)
  2603. }
  2604. return ids
  2605. }
  2606. return nil
  2607. }
  2608. // RemovedEdges returns all edge names that were removed in this mutation.
  2609. func (m *AgentBaseMutation) RemovedEdges() []string {
  2610. edges := make([]string, 0, 1)
  2611. if m.removedwx_agent != nil {
  2612. edges = append(edges, agentbase.EdgeWxAgent)
  2613. }
  2614. return edges
  2615. }
  2616. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2617. // the given name in this mutation.
  2618. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2619. switch name {
  2620. case agentbase.EdgeWxAgent:
  2621. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2622. for id := range m.removedwx_agent {
  2623. ids = append(ids, id)
  2624. }
  2625. return ids
  2626. }
  2627. return nil
  2628. }
  2629. // ClearedEdges returns all edge names that were cleared in this mutation.
  2630. func (m *AgentBaseMutation) ClearedEdges() []string {
  2631. edges := make([]string, 0, 1)
  2632. if m.clearedwx_agent {
  2633. edges = append(edges, agentbase.EdgeWxAgent)
  2634. }
  2635. return edges
  2636. }
  2637. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2638. // was cleared in this mutation.
  2639. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2640. switch name {
  2641. case agentbase.EdgeWxAgent:
  2642. return m.clearedwx_agent
  2643. }
  2644. return false
  2645. }
  2646. // ClearEdge clears the value of the edge with the given name. It returns an error
  2647. // if that edge is not defined in the schema.
  2648. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2649. switch name {
  2650. }
  2651. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2652. }
  2653. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2654. // It returns an error if the edge is not defined in the schema.
  2655. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2656. switch name {
  2657. case agentbase.EdgeWxAgent:
  2658. m.ResetWxAgent()
  2659. return nil
  2660. }
  2661. return fmt.Errorf("unknown AgentBase edge %s", name)
  2662. }
  2663. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2664. type AliyunAvatarMutation struct {
  2665. config
  2666. op Op
  2667. typ string
  2668. id *uint64
  2669. created_at *time.Time
  2670. updated_at *time.Time
  2671. deleted_at *time.Time
  2672. user_id *uint64
  2673. adduser_id *int64
  2674. biz_id *string
  2675. access_key_id *string
  2676. access_key_secret *string
  2677. app_id *string
  2678. tenant_id *uint64
  2679. addtenant_id *int64
  2680. response *string
  2681. token *string
  2682. session_id *string
  2683. clearedFields map[string]struct{}
  2684. done bool
  2685. oldValue func(context.Context) (*AliyunAvatar, error)
  2686. predicates []predicate.AliyunAvatar
  2687. }
  2688. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2689. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2690. type aliyunavatarOption func(*AliyunAvatarMutation)
  2691. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2692. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2693. m := &AliyunAvatarMutation{
  2694. config: c,
  2695. op: op,
  2696. typ: TypeAliyunAvatar,
  2697. clearedFields: make(map[string]struct{}),
  2698. }
  2699. for _, opt := range opts {
  2700. opt(m)
  2701. }
  2702. return m
  2703. }
  2704. // withAliyunAvatarID sets the ID field of the mutation.
  2705. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2706. return func(m *AliyunAvatarMutation) {
  2707. var (
  2708. err error
  2709. once sync.Once
  2710. value *AliyunAvatar
  2711. )
  2712. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2713. once.Do(func() {
  2714. if m.done {
  2715. err = errors.New("querying old values post mutation is not allowed")
  2716. } else {
  2717. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2718. }
  2719. })
  2720. return value, err
  2721. }
  2722. m.id = &id
  2723. }
  2724. }
  2725. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2726. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2727. return func(m *AliyunAvatarMutation) {
  2728. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2729. return node, nil
  2730. }
  2731. m.id = &node.ID
  2732. }
  2733. }
  2734. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2735. // executed in a transaction (ent.Tx), a transactional client is returned.
  2736. func (m AliyunAvatarMutation) Client() *Client {
  2737. client := &Client{config: m.config}
  2738. client.init()
  2739. return client
  2740. }
  2741. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2742. // it returns an error otherwise.
  2743. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2744. if _, ok := m.driver.(*txDriver); !ok {
  2745. return nil, errors.New("ent: mutation is not running in a transaction")
  2746. }
  2747. tx := &Tx{config: m.config}
  2748. tx.init()
  2749. return tx, nil
  2750. }
  2751. // SetID sets the value of the id field. Note that this
  2752. // operation is only accepted on creation of AliyunAvatar entities.
  2753. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2754. m.id = &id
  2755. }
  2756. // ID returns the ID value in the mutation. Note that the ID is only available
  2757. // if it was provided to the builder or after it was returned from the database.
  2758. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2759. if m.id == nil {
  2760. return
  2761. }
  2762. return *m.id, true
  2763. }
  2764. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2765. // That means, if the mutation is applied within a transaction with an isolation level such
  2766. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2767. // or updated by the mutation.
  2768. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2769. switch {
  2770. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2771. id, exists := m.ID()
  2772. if exists {
  2773. return []uint64{id}, nil
  2774. }
  2775. fallthrough
  2776. case m.op.Is(OpUpdate | OpDelete):
  2777. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2778. default:
  2779. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2780. }
  2781. }
  2782. // SetCreatedAt sets the "created_at" field.
  2783. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2784. m.created_at = &t
  2785. }
  2786. // CreatedAt returns the value of the "created_at" field in the mutation.
  2787. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2788. v := m.created_at
  2789. if v == nil {
  2790. return
  2791. }
  2792. return *v, true
  2793. }
  2794. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2795. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2797. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2798. if !m.op.Is(OpUpdateOne) {
  2799. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2800. }
  2801. if m.id == nil || m.oldValue == nil {
  2802. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2803. }
  2804. oldValue, err := m.oldValue(ctx)
  2805. if err != nil {
  2806. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2807. }
  2808. return oldValue.CreatedAt, nil
  2809. }
  2810. // ResetCreatedAt resets all changes to the "created_at" field.
  2811. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2812. m.created_at = nil
  2813. }
  2814. // SetUpdatedAt sets the "updated_at" field.
  2815. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2816. m.updated_at = &t
  2817. }
  2818. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2819. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2820. v := m.updated_at
  2821. if v == nil {
  2822. return
  2823. }
  2824. return *v, true
  2825. }
  2826. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2827. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2829. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2830. if !m.op.Is(OpUpdateOne) {
  2831. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2832. }
  2833. if m.id == nil || m.oldValue == nil {
  2834. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2835. }
  2836. oldValue, err := m.oldValue(ctx)
  2837. if err != nil {
  2838. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2839. }
  2840. return oldValue.UpdatedAt, nil
  2841. }
  2842. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2843. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2844. m.updated_at = nil
  2845. }
  2846. // SetDeletedAt sets the "deleted_at" field.
  2847. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2848. m.deleted_at = &t
  2849. }
  2850. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2851. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2852. v := m.deleted_at
  2853. if v == nil {
  2854. return
  2855. }
  2856. return *v, true
  2857. }
  2858. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2859. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2861. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2862. if !m.op.Is(OpUpdateOne) {
  2863. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2864. }
  2865. if m.id == nil || m.oldValue == nil {
  2866. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2867. }
  2868. oldValue, err := m.oldValue(ctx)
  2869. if err != nil {
  2870. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2871. }
  2872. return oldValue.DeletedAt, nil
  2873. }
  2874. // ClearDeletedAt clears the value of the "deleted_at" field.
  2875. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2876. m.deleted_at = nil
  2877. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2878. }
  2879. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2880. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2881. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2882. return ok
  2883. }
  2884. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2885. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2886. m.deleted_at = nil
  2887. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2888. }
  2889. // SetUserID sets the "user_id" field.
  2890. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2891. m.user_id = &u
  2892. m.adduser_id = nil
  2893. }
  2894. // UserID returns the value of the "user_id" field in the mutation.
  2895. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2896. v := m.user_id
  2897. if v == nil {
  2898. return
  2899. }
  2900. return *v, true
  2901. }
  2902. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2903. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2905. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2906. if !m.op.Is(OpUpdateOne) {
  2907. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2908. }
  2909. if m.id == nil || m.oldValue == nil {
  2910. return v, errors.New("OldUserID requires an ID field in the mutation")
  2911. }
  2912. oldValue, err := m.oldValue(ctx)
  2913. if err != nil {
  2914. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2915. }
  2916. return oldValue.UserID, nil
  2917. }
  2918. // AddUserID adds u to the "user_id" field.
  2919. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2920. if m.adduser_id != nil {
  2921. *m.adduser_id += u
  2922. } else {
  2923. m.adduser_id = &u
  2924. }
  2925. }
  2926. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2927. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2928. v := m.adduser_id
  2929. if v == nil {
  2930. return
  2931. }
  2932. return *v, true
  2933. }
  2934. // ResetUserID resets all changes to the "user_id" field.
  2935. func (m *AliyunAvatarMutation) ResetUserID() {
  2936. m.user_id = nil
  2937. m.adduser_id = nil
  2938. }
  2939. // SetBizID sets the "biz_id" field.
  2940. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2941. m.biz_id = &s
  2942. }
  2943. // BizID returns the value of the "biz_id" field in the mutation.
  2944. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2945. v := m.biz_id
  2946. if v == nil {
  2947. return
  2948. }
  2949. return *v, true
  2950. }
  2951. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2952. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2954. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2955. if !m.op.Is(OpUpdateOne) {
  2956. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2957. }
  2958. if m.id == nil || m.oldValue == nil {
  2959. return v, errors.New("OldBizID requires an ID field in the mutation")
  2960. }
  2961. oldValue, err := m.oldValue(ctx)
  2962. if err != nil {
  2963. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2964. }
  2965. return oldValue.BizID, nil
  2966. }
  2967. // ResetBizID resets all changes to the "biz_id" field.
  2968. func (m *AliyunAvatarMutation) ResetBizID() {
  2969. m.biz_id = nil
  2970. }
  2971. // SetAccessKeyID sets the "access_key_id" field.
  2972. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2973. m.access_key_id = &s
  2974. }
  2975. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2976. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2977. v := m.access_key_id
  2978. if v == nil {
  2979. return
  2980. }
  2981. return *v, true
  2982. }
  2983. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2984. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2986. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2987. if !m.op.Is(OpUpdateOne) {
  2988. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2989. }
  2990. if m.id == nil || m.oldValue == nil {
  2991. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2992. }
  2993. oldValue, err := m.oldValue(ctx)
  2994. if err != nil {
  2995. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2996. }
  2997. return oldValue.AccessKeyID, nil
  2998. }
  2999. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  3000. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  3001. m.access_key_id = nil
  3002. }
  3003. // SetAccessKeySecret sets the "access_key_secret" field.
  3004. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  3005. m.access_key_secret = &s
  3006. }
  3007. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  3008. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  3009. v := m.access_key_secret
  3010. if v == nil {
  3011. return
  3012. }
  3013. return *v, true
  3014. }
  3015. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  3016. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3018. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  3019. if !m.op.Is(OpUpdateOne) {
  3020. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  3021. }
  3022. if m.id == nil || m.oldValue == nil {
  3023. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  3024. }
  3025. oldValue, err := m.oldValue(ctx)
  3026. if err != nil {
  3027. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  3028. }
  3029. return oldValue.AccessKeySecret, nil
  3030. }
  3031. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  3032. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  3033. m.access_key_secret = nil
  3034. }
  3035. // SetAppID sets the "app_id" field.
  3036. func (m *AliyunAvatarMutation) SetAppID(s string) {
  3037. m.app_id = &s
  3038. }
  3039. // AppID returns the value of the "app_id" field in the mutation.
  3040. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  3041. v := m.app_id
  3042. if v == nil {
  3043. return
  3044. }
  3045. return *v, true
  3046. }
  3047. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  3048. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3050. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  3051. if !m.op.Is(OpUpdateOne) {
  3052. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  3053. }
  3054. if m.id == nil || m.oldValue == nil {
  3055. return v, errors.New("OldAppID requires an ID field in the mutation")
  3056. }
  3057. oldValue, err := m.oldValue(ctx)
  3058. if err != nil {
  3059. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  3060. }
  3061. return oldValue.AppID, nil
  3062. }
  3063. // ClearAppID clears the value of the "app_id" field.
  3064. func (m *AliyunAvatarMutation) ClearAppID() {
  3065. m.app_id = nil
  3066. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  3067. }
  3068. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  3069. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  3070. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  3071. return ok
  3072. }
  3073. // ResetAppID resets all changes to the "app_id" field.
  3074. func (m *AliyunAvatarMutation) ResetAppID() {
  3075. m.app_id = nil
  3076. delete(m.clearedFields, aliyunavatar.FieldAppID)
  3077. }
  3078. // SetTenantID sets the "tenant_id" field.
  3079. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  3080. m.tenant_id = &u
  3081. m.addtenant_id = nil
  3082. }
  3083. // TenantID returns the value of the "tenant_id" field in the mutation.
  3084. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  3085. v := m.tenant_id
  3086. if v == nil {
  3087. return
  3088. }
  3089. return *v, true
  3090. }
  3091. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  3092. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3094. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  3095. if !m.op.Is(OpUpdateOne) {
  3096. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  3097. }
  3098. if m.id == nil || m.oldValue == nil {
  3099. return v, errors.New("OldTenantID requires an ID field in the mutation")
  3100. }
  3101. oldValue, err := m.oldValue(ctx)
  3102. if err != nil {
  3103. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  3104. }
  3105. return oldValue.TenantID, nil
  3106. }
  3107. // AddTenantID adds u to the "tenant_id" field.
  3108. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  3109. if m.addtenant_id != nil {
  3110. *m.addtenant_id += u
  3111. } else {
  3112. m.addtenant_id = &u
  3113. }
  3114. }
  3115. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  3116. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  3117. v := m.addtenant_id
  3118. if v == nil {
  3119. return
  3120. }
  3121. return *v, true
  3122. }
  3123. // ResetTenantID resets all changes to the "tenant_id" field.
  3124. func (m *AliyunAvatarMutation) ResetTenantID() {
  3125. m.tenant_id = nil
  3126. m.addtenant_id = nil
  3127. }
  3128. // SetResponse sets the "response" field.
  3129. func (m *AliyunAvatarMutation) SetResponse(s string) {
  3130. m.response = &s
  3131. }
  3132. // Response returns the value of the "response" field in the mutation.
  3133. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  3134. v := m.response
  3135. if v == nil {
  3136. return
  3137. }
  3138. return *v, true
  3139. }
  3140. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  3141. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3143. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  3144. if !m.op.Is(OpUpdateOne) {
  3145. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  3146. }
  3147. if m.id == nil || m.oldValue == nil {
  3148. return v, errors.New("OldResponse requires an ID field in the mutation")
  3149. }
  3150. oldValue, err := m.oldValue(ctx)
  3151. if err != nil {
  3152. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  3153. }
  3154. return oldValue.Response, nil
  3155. }
  3156. // ResetResponse resets all changes to the "response" field.
  3157. func (m *AliyunAvatarMutation) ResetResponse() {
  3158. m.response = nil
  3159. }
  3160. // SetToken sets the "token" field.
  3161. func (m *AliyunAvatarMutation) SetToken(s string) {
  3162. m.token = &s
  3163. }
  3164. // Token returns the value of the "token" field in the mutation.
  3165. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  3166. v := m.token
  3167. if v == nil {
  3168. return
  3169. }
  3170. return *v, true
  3171. }
  3172. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  3173. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3174. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3175. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  3176. if !m.op.Is(OpUpdateOne) {
  3177. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  3178. }
  3179. if m.id == nil || m.oldValue == nil {
  3180. return v, errors.New("OldToken requires an ID field in the mutation")
  3181. }
  3182. oldValue, err := m.oldValue(ctx)
  3183. if err != nil {
  3184. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  3185. }
  3186. return oldValue.Token, nil
  3187. }
  3188. // ResetToken resets all changes to the "token" field.
  3189. func (m *AliyunAvatarMutation) ResetToken() {
  3190. m.token = nil
  3191. }
  3192. // SetSessionID sets the "session_id" field.
  3193. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  3194. m.session_id = &s
  3195. }
  3196. // SessionID returns the value of the "session_id" field in the mutation.
  3197. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  3198. v := m.session_id
  3199. if v == nil {
  3200. return
  3201. }
  3202. return *v, true
  3203. }
  3204. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  3205. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  3206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3207. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  3208. if !m.op.Is(OpUpdateOne) {
  3209. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  3210. }
  3211. if m.id == nil || m.oldValue == nil {
  3212. return v, errors.New("OldSessionID requires an ID field in the mutation")
  3213. }
  3214. oldValue, err := m.oldValue(ctx)
  3215. if err != nil {
  3216. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  3217. }
  3218. return oldValue.SessionID, nil
  3219. }
  3220. // ResetSessionID resets all changes to the "session_id" field.
  3221. func (m *AliyunAvatarMutation) ResetSessionID() {
  3222. m.session_id = nil
  3223. }
  3224. // Where appends a list predicates to the AliyunAvatarMutation builder.
  3225. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  3226. m.predicates = append(m.predicates, ps...)
  3227. }
  3228. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  3229. // users can use type-assertion to append predicates that do not depend on any generated package.
  3230. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  3231. p := make([]predicate.AliyunAvatar, len(ps))
  3232. for i := range ps {
  3233. p[i] = ps[i]
  3234. }
  3235. m.Where(p...)
  3236. }
  3237. // Op returns the operation name.
  3238. func (m *AliyunAvatarMutation) Op() Op {
  3239. return m.op
  3240. }
  3241. // SetOp allows setting the mutation operation.
  3242. func (m *AliyunAvatarMutation) SetOp(op Op) {
  3243. m.op = op
  3244. }
  3245. // Type returns the node type of this mutation (AliyunAvatar).
  3246. func (m *AliyunAvatarMutation) Type() string {
  3247. return m.typ
  3248. }
  3249. // Fields returns all fields that were changed during this mutation. Note that in
  3250. // order to get all numeric fields that were incremented/decremented, call
  3251. // AddedFields().
  3252. func (m *AliyunAvatarMutation) Fields() []string {
  3253. fields := make([]string, 0, 12)
  3254. if m.created_at != nil {
  3255. fields = append(fields, aliyunavatar.FieldCreatedAt)
  3256. }
  3257. if m.updated_at != nil {
  3258. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  3259. }
  3260. if m.deleted_at != nil {
  3261. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3262. }
  3263. if m.user_id != nil {
  3264. fields = append(fields, aliyunavatar.FieldUserID)
  3265. }
  3266. if m.biz_id != nil {
  3267. fields = append(fields, aliyunavatar.FieldBizID)
  3268. }
  3269. if m.access_key_id != nil {
  3270. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  3271. }
  3272. if m.access_key_secret != nil {
  3273. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  3274. }
  3275. if m.app_id != nil {
  3276. fields = append(fields, aliyunavatar.FieldAppID)
  3277. }
  3278. if m.tenant_id != nil {
  3279. fields = append(fields, aliyunavatar.FieldTenantID)
  3280. }
  3281. if m.response != nil {
  3282. fields = append(fields, aliyunavatar.FieldResponse)
  3283. }
  3284. if m.token != nil {
  3285. fields = append(fields, aliyunavatar.FieldToken)
  3286. }
  3287. if m.session_id != nil {
  3288. fields = append(fields, aliyunavatar.FieldSessionID)
  3289. }
  3290. return fields
  3291. }
  3292. // Field returns the value of a field with the given name. The second boolean
  3293. // return value indicates that this field was not set, or was not defined in the
  3294. // schema.
  3295. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  3296. switch name {
  3297. case aliyunavatar.FieldCreatedAt:
  3298. return m.CreatedAt()
  3299. case aliyunavatar.FieldUpdatedAt:
  3300. return m.UpdatedAt()
  3301. case aliyunavatar.FieldDeletedAt:
  3302. return m.DeletedAt()
  3303. case aliyunavatar.FieldUserID:
  3304. return m.UserID()
  3305. case aliyunavatar.FieldBizID:
  3306. return m.BizID()
  3307. case aliyunavatar.FieldAccessKeyID:
  3308. return m.AccessKeyID()
  3309. case aliyunavatar.FieldAccessKeySecret:
  3310. return m.AccessKeySecret()
  3311. case aliyunavatar.FieldAppID:
  3312. return m.AppID()
  3313. case aliyunavatar.FieldTenantID:
  3314. return m.TenantID()
  3315. case aliyunavatar.FieldResponse:
  3316. return m.Response()
  3317. case aliyunavatar.FieldToken:
  3318. return m.Token()
  3319. case aliyunavatar.FieldSessionID:
  3320. return m.SessionID()
  3321. }
  3322. return nil, false
  3323. }
  3324. // OldField returns the old value of the field from the database. An error is
  3325. // returned if the mutation operation is not UpdateOne, or the query to the
  3326. // database failed.
  3327. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3328. switch name {
  3329. case aliyunavatar.FieldCreatedAt:
  3330. return m.OldCreatedAt(ctx)
  3331. case aliyunavatar.FieldUpdatedAt:
  3332. return m.OldUpdatedAt(ctx)
  3333. case aliyunavatar.FieldDeletedAt:
  3334. return m.OldDeletedAt(ctx)
  3335. case aliyunavatar.FieldUserID:
  3336. return m.OldUserID(ctx)
  3337. case aliyunavatar.FieldBizID:
  3338. return m.OldBizID(ctx)
  3339. case aliyunavatar.FieldAccessKeyID:
  3340. return m.OldAccessKeyID(ctx)
  3341. case aliyunavatar.FieldAccessKeySecret:
  3342. return m.OldAccessKeySecret(ctx)
  3343. case aliyunavatar.FieldAppID:
  3344. return m.OldAppID(ctx)
  3345. case aliyunavatar.FieldTenantID:
  3346. return m.OldTenantID(ctx)
  3347. case aliyunavatar.FieldResponse:
  3348. return m.OldResponse(ctx)
  3349. case aliyunavatar.FieldToken:
  3350. return m.OldToken(ctx)
  3351. case aliyunavatar.FieldSessionID:
  3352. return m.OldSessionID(ctx)
  3353. }
  3354. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3355. }
  3356. // SetField sets the value of a field with the given name. It returns an error if
  3357. // the field is not defined in the schema, or if the type mismatched the field
  3358. // type.
  3359. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3360. switch name {
  3361. case aliyunavatar.FieldCreatedAt:
  3362. v, ok := value.(time.Time)
  3363. if !ok {
  3364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3365. }
  3366. m.SetCreatedAt(v)
  3367. return nil
  3368. case aliyunavatar.FieldUpdatedAt:
  3369. v, ok := value.(time.Time)
  3370. if !ok {
  3371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3372. }
  3373. m.SetUpdatedAt(v)
  3374. return nil
  3375. case aliyunavatar.FieldDeletedAt:
  3376. v, ok := value.(time.Time)
  3377. if !ok {
  3378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3379. }
  3380. m.SetDeletedAt(v)
  3381. return nil
  3382. case aliyunavatar.FieldUserID:
  3383. v, ok := value.(uint64)
  3384. if !ok {
  3385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3386. }
  3387. m.SetUserID(v)
  3388. return nil
  3389. case aliyunavatar.FieldBizID:
  3390. v, ok := value.(string)
  3391. if !ok {
  3392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3393. }
  3394. m.SetBizID(v)
  3395. return nil
  3396. case aliyunavatar.FieldAccessKeyID:
  3397. v, ok := value.(string)
  3398. if !ok {
  3399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3400. }
  3401. m.SetAccessKeyID(v)
  3402. return nil
  3403. case aliyunavatar.FieldAccessKeySecret:
  3404. v, ok := value.(string)
  3405. if !ok {
  3406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3407. }
  3408. m.SetAccessKeySecret(v)
  3409. return nil
  3410. case aliyunavatar.FieldAppID:
  3411. v, ok := value.(string)
  3412. if !ok {
  3413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3414. }
  3415. m.SetAppID(v)
  3416. return nil
  3417. case aliyunavatar.FieldTenantID:
  3418. v, ok := value.(uint64)
  3419. if !ok {
  3420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3421. }
  3422. m.SetTenantID(v)
  3423. return nil
  3424. case aliyunavatar.FieldResponse:
  3425. v, ok := value.(string)
  3426. if !ok {
  3427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3428. }
  3429. m.SetResponse(v)
  3430. return nil
  3431. case aliyunavatar.FieldToken:
  3432. v, ok := value.(string)
  3433. if !ok {
  3434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3435. }
  3436. m.SetToken(v)
  3437. return nil
  3438. case aliyunavatar.FieldSessionID:
  3439. v, ok := value.(string)
  3440. if !ok {
  3441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3442. }
  3443. m.SetSessionID(v)
  3444. return nil
  3445. }
  3446. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3447. }
  3448. // AddedFields returns all numeric fields that were incremented/decremented during
  3449. // this mutation.
  3450. func (m *AliyunAvatarMutation) AddedFields() []string {
  3451. var fields []string
  3452. if m.adduser_id != nil {
  3453. fields = append(fields, aliyunavatar.FieldUserID)
  3454. }
  3455. if m.addtenant_id != nil {
  3456. fields = append(fields, aliyunavatar.FieldTenantID)
  3457. }
  3458. return fields
  3459. }
  3460. // AddedField returns the numeric value that was incremented/decremented on a field
  3461. // with the given name. The second boolean return value indicates that this field
  3462. // was not set, or was not defined in the schema.
  3463. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3464. switch name {
  3465. case aliyunavatar.FieldUserID:
  3466. return m.AddedUserID()
  3467. case aliyunavatar.FieldTenantID:
  3468. return m.AddedTenantID()
  3469. }
  3470. return nil, false
  3471. }
  3472. // AddField adds the value to the field with the given name. It returns an error if
  3473. // the field is not defined in the schema, or if the type mismatched the field
  3474. // type.
  3475. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3476. switch name {
  3477. case aliyunavatar.FieldUserID:
  3478. v, ok := value.(int64)
  3479. if !ok {
  3480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3481. }
  3482. m.AddUserID(v)
  3483. return nil
  3484. case aliyunavatar.FieldTenantID:
  3485. v, ok := value.(int64)
  3486. if !ok {
  3487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3488. }
  3489. m.AddTenantID(v)
  3490. return nil
  3491. }
  3492. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3493. }
  3494. // ClearedFields returns all nullable fields that were cleared during this
  3495. // mutation.
  3496. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3497. var fields []string
  3498. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3499. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3500. }
  3501. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3502. fields = append(fields, aliyunavatar.FieldAppID)
  3503. }
  3504. return fields
  3505. }
  3506. // FieldCleared returns a boolean indicating if a field with the given name was
  3507. // cleared in this mutation.
  3508. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3509. _, ok := m.clearedFields[name]
  3510. return ok
  3511. }
  3512. // ClearField clears the value of the field with the given name. It returns an
  3513. // error if the field is not defined in the schema.
  3514. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3515. switch name {
  3516. case aliyunavatar.FieldDeletedAt:
  3517. m.ClearDeletedAt()
  3518. return nil
  3519. case aliyunavatar.FieldAppID:
  3520. m.ClearAppID()
  3521. return nil
  3522. }
  3523. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3524. }
  3525. // ResetField resets all changes in the mutation for the field with the given name.
  3526. // It returns an error if the field is not defined in the schema.
  3527. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3528. switch name {
  3529. case aliyunavatar.FieldCreatedAt:
  3530. m.ResetCreatedAt()
  3531. return nil
  3532. case aliyunavatar.FieldUpdatedAt:
  3533. m.ResetUpdatedAt()
  3534. return nil
  3535. case aliyunavatar.FieldDeletedAt:
  3536. m.ResetDeletedAt()
  3537. return nil
  3538. case aliyunavatar.FieldUserID:
  3539. m.ResetUserID()
  3540. return nil
  3541. case aliyunavatar.FieldBizID:
  3542. m.ResetBizID()
  3543. return nil
  3544. case aliyunavatar.FieldAccessKeyID:
  3545. m.ResetAccessKeyID()
  3546. return nil
  3547. case aliyunavatar.FieldAccessKeySecret:
  3548. m.ResetAccessKeySecret()
  3549. return nil
  3550. case aliyunavatar.FieldAppID:
  3551. m.ResetAppID()
  3552. return nil
  3553. case aliyunavatar.FieldTenantID:
  3554. m.ResetTenantID()
  3555. return nil
  3556. case aliyunavatar.FieldResponse:
  3557. m.ResetResponse()
  3558. return nil
  3559. case aliyunavatar.FieldToken:
  3560. m.ResetToken()
  3561. return nil
  3562. case aliyunavatar.FieldSessionID:
  3563. m.ResetSessionID()
  3564. return nil
  3565. }
  3566. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3567. }
  3568. // AddedEdges returns all edge names that were set/added in this mutation.
  3569. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3570. edges := make([]string, 0, 0)
  3571. return edges
  3572. }
  3573. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3574. // name in this mutation.
  3575. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3576. return nil
  3577. }
  3578. // RemovedEdges returns all edge names that were removed in this mutation.
  3579. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3580. edges := make([]string, 0, 0)
  3581. return edges
  3582. }
  3583. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3584. // the given name in this mutation.
  3585. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3586. return nil
  3587. }
  3588. // ClearedEdges returns all edge names that were cleared in this mutation.
  3589. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3590. edges := make([]string, 0, 0)
  3591. return edges
  3592. }
  3593. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3594. // was cleared in this mutation.
  3595. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3596. return false
  3597. }
  3598. // ClearEdge clears the value of the edge with the given name. It returns an error
  3599. // if that edge is not defined in the schema.
  3600. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3601. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3602. }
  3603. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3604. // It returns an error if the edge is not defined in the schema.
  3605. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3606. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3607. }
  3608. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3609. type AllocAgentMutation struct {
  3610. config
  3611. op Op
  3612. typ string
  3613. id *uint64
  3614. created_at *time.Time
  3615. updated_at *time.Time
  3616. deleted_at *time.Time
  3617. user_id *string
  3618. organization_id *uint64
  3619. addorganization_id *int64
  3620. agents *[]uint64
  3621. appendagents []uint64
  3622. status *int
  3623. addstatus *int
  3624. clearedFields map[string]struct{}
  3625. done bool
  3626. oldValue func(context.Context) (*AllocAgent, error)
  3627. predicates []predicate.AllocAgent
  3628. }
  3629. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3630. // allocagentOption allows management of the mutation configuration using functional options.
  3631. type allocagentOption func(*AllocAgentMutation)
  3632. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3633. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3634. m := &AllocAgentMutation{
  3635. config: c,
  3636. op: op,
  3637. typ: TypeAllocAgent,
  3638. clearedFields: make(map[string]struct{}),
  3639. }
  3640. for _, opt := range opts {
  3641. opt(m)
  3642. }
  3643. return m
  3644. }
  3645. // withAllocAgentID sets the ID field of the mutation.
  3646. func withAllocAgentID(id uint64) allocagentOption {
  3647. return func(m *AllocAgentMutation) {
  3648. var (
  3649. err error
  3650. once sync.Once
  3651. value *AllocAgent
  3652. )
  3653. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3654. once.Do(func() {
  3655. if m.done {
  3656. err = errors.New("querying old values post mutation is not allowed")
  3657. } else {
  3658. value, err = m.Client().AllocAgent.Get(ctx, id)
  3659. }
  3660. })
  3661. return value, err
  3662. }
  3663. m.id = &id
  3664. }
  3665. }
  3666. // withAllocAgent sets the old AllocAgent of the mutation.
  3667. func withAllocAgent(node *AllocAgent) allocagentOption {
  3668. return func(m *AllocAgentMutation) {
  3669. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3670. return node, nil
  3671. }
  3672. m.id = &node.ID
  3673. }
  3674. }
  3675. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3676. // executed in a transaction (ent.Tx), a transactional client is returned.
  3677. func (m AllocAgentMutation) Client() *Client {
  3678. client := &Client{config: m.config}
  3679. client.init()
  3680. return client
  3681. }
  3682. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3683. // it returns an error otherwise.
  3684. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3685. if _, ok := m.driver.(*txDriver); !ok {
  3686. return nil, errors.New("ent: mutation is not running in a transaction")
  3687. }
  3688. tx := &Tx{config: m.config}
  3689. tx.init()
  3690. return tx, nil
  3691. }
  3692. // SetID sets the value of the id field. Note that this
  3693. // operation is only accepted on creation of AllocAgent entities.
  3694. func (m *AllocAgentMutation) SetID(id uint64) {
  3695. m.id = &id
  3696. }
  3697. // ID returns the ID value in the mutation. Note that the ID is only available
  3698. // if it was provided to the builder or after it was returned from the database.
  3699. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3700. if m.id == nil {
  3701. return
  3702. }
  3703. return *m.id, true
  3704. }
  3705. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3706. // That means, if the mutation is applied within a transaction with an isolation level such
  3707. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3708. // or updated by the mutation.
  3709. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3710. switch {
  3711. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3712. id, exists := m.ID()
  3713. if exists {
  3714. return []uint64{id}, nil
  3715. }
  3716. fallthrough
  3717. case m.op.Is(OpUpdate | OpDelete):
  3718. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3719. default:
  3720. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3721. }
  3722. }
  3723. // SetCreatedAt sets the "created_at" field.
  3724. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3725. m.created_at = &t
  3726. }
  3727. // CreatedAt returns the value of the "created_at" field in the mutation.
  3728. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3729. v := m.created_at
  3730. if v == nil {
  3731. return
  3732. }
  3733. return *v, true
  3734. }
  3735. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3736. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3738. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3739. if !m.op.Is(OpUpdateOne) {
  3740. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3741. }
  3742. if m.id == nil || m.oldValue == nil {
  3743. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3744. }
  3745. oldValue, err := m.oldValue(ctx)
  3746. if err != nil {
  3747. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3748. }
  3749. return oldValue.CreatedAt, nil
  3750. }
  3751. // ResetCreatedAt resets all changes to the "created_at" field.
  3752. func (m *AllocAgentMutation) ResetCreatedAt() {
  3753. m.created_at = nil
  3754. }
  3755. // SetUpdatedAt sets the "updated_at" field.
  3756. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3757. m.updated_at = &t
  3758. }
  3759. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3760. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3761. v := m.updated_at
  3762. if v == nil {
  3763. return
  3764. }
  3765. return *v, true
  3766. }
  3767. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3768. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3770. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3771. if !m.op.Is(OpUpdateOne) {
  3772. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3773. }
  3774. if m.id == nil || m.oldValue == nil {
  3775. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3776. }
  3777. oldValue, err := m.oldValue(ctx)
  3778. if err != nil {
  3779. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3780. }
  3781. return oldValue.UpdatedAt, nil
  3782. }
  3783. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3784. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3785. m.updated_at = nil
  3786. }
  3787. // SetDeletedAt sets the "deleted_at" field.
  3788. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3789. m.deleted_at = &t
  3790. }
  3791. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3792. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3793. v := m.deleted_at
  3794. if v == nil {
  3795. return
  3796. }
  3797. return *v, true
  3798. }
  3799. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3800. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3802. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3803. if !m.op.Is(OpUpdateOne) {
  3804. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3805. }
  3806. if m.id == nil || m.oldValue == nil {
  3807. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3808. }
  3809. oldValue, err := m.oldValue(ctx)
  3810. if err != nil {
  3811. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3812. }
  3813. return oldValue.DeletedAt, nil
  3814. }
  3815. // ClearDeletedAt clears the value of the "deleted_at" field.
  3816. func (m *AllocAgentMutation) ClearDeletedAt() {
  3817. m.deleted_at = nil
  3818. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3819. }
  3820. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3821. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3822. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3823. return ok
  3824. }
  3825. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3826. func (m *AllocAgentMutation) ResetDeletedAt() {
  3827. m.deleted_at = nil
  3828. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3829. }
  3830. // SetUserID sets the "user_id" field.
  3831. func (m *AllocAgentMutation) SetUserID(s string) {
  3832. m.user_id = &s
  3833. }
  3834. // UserID returns the value of the "user_id" field in the mutation.
  3835. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3836. v := m.user_id
  3837. if v == nil {
  3838. return
  3839. }
  3840. return *v, true
  3841. }
  3842. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3843. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3845. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3846. if !m.op.Is(OpUpdateOne) {
  3847. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3848. }
  3849. if m.id == nil || m.oldValue == nil {
  3850. return v, errors.New("OldUserID requires an ID field in the mutation")
  3851. }
  3852. oldValue, err := m.oldValue(ctx)
  3853. if err != nil {
  3854. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3855. }
  3856. return oldValue.UserID, nil
  3857. }
  3858. // ClearUserID clears the value of the "user_id" field.
  3859. func (m *AllocAgentMutation) ClearUserID() {
  3860. m.user_id = nil
  3861. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3862. }
  3863. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3864. func (m *AllocAgentMutation) UserIDCleared() bool {
  3865. _, ok := m.clearedFields[allocagent.FieldUserID]
  3866. return ok
  3867. }
  3868. // ResetUserID resets all changes to the "user_id" field.
  3869. func (m *AllocAgentMutation) ResetUserID() {
  3870. m.user_id = nil
  3871. delete(m.clearedFields, allocagent.FieldUserID)
  3872. }
  3873. // SetOrganizationID sets the "organization_id" field.
  3874. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3875. m.organization_id = &u
  3876. m.addorganization_id = nil
  3877. }
  3878. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3879. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3880. v := m.organization_id
  3881. if v == nil {
  3882. return
  3883. }
  3884. return *v, true
  3885. }
  3886. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3887. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3889. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3890. if !m.op.Is(OpUpdateOne) {
  3891. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3892. }
  3893. if m.id == nil || m.oldValue == nil {
  3894. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3895. }
  3896. oldValue, err := m.oldValue(ctx)
  3897. if err != nil {
  3898. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3899. }
  3900. return oldValue.OrganizationID, nil
  3901. }
  3902. // AddOrganizationID adds u to the "organization_id" field.
  3903. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3904. if m.addorganization_id != nil {
  3905. *m.addorganization_id += u
  3906. } else {
  3907. m.addorganization_id = &u
  3908. }
  3909. }
  3910. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3911. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3912. v := m.addorganization_id
  3913. if v == nil {
  3914. return
  3915. }
  3916. return *v, true
  3917. }
  3918. // ClearOrganizationID clears the value of the "organization_id" field.
  3919. func (m *AllocAgentMutation) ClearOrganizationID() {
  3920. m.organization_id = nil
  3921. m.addorganization_id = nil
  3922. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3923. }
  3924. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3925. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3926. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3927. return ok
  3928. }
  3929. // ResetOrganizationID resets all changes to the "organization_id" field.
  3930. func (m *AllocAgentMutation) ResetOrganizationID() {
  3931. m.organization_id = nil
  3932. m.addorganization_id = nil
  3933. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3934. }
  3935. // SetAgents sets the "agents" field.
  3936. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3937. m.agents = &u
  3938. m.appendagents = nil
  3939. }
  3940. // Agents returns the value of the "agents" field in the mutation.
  3941. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3942. v := m.agents
  3943. if v == nil {
  3944. return
  3945. }
  3946. return *v, true
  3947. }
  3948. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3949. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3951. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3952. if !m.op.Is(OpUpdateOne) {
  3953. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3954. }
  3955. if m.id == nil || m.oldValue == nil {
  3956. return v, errors.New("OldAgents requires an ID field in the mutation")
  3957. }
  3958. oldValue, err := m.oldValue(ctx)
  3959. if err != nil {
  3960. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3961. }
  3962. return oldValue.Agents, nil
  3963. }
  3964. // AppendAgents adds u to the "agents" field.
  3965. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3966. m.appendagents = append(m.appendagents, u...)
  3967. }
  3968. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3969. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3970. if len(m.appendagents) == 0 {
  3971. return nil, false
  3972. }
  3973. return m.appendagents, true
  3974. }
  3975. // ResetAgents resets all changes to the "agents" field.
  3976. func (m *AllocAgentMutation) ResetAgents() {
  3977. m.agents = nil
  3978. m.appendagents = nil
  3979. }
  3980. // SetStatus sets the "status" field.
  3981. func (m *AllocAgentMutation) SetStatus(i int) {
  3982. m.status = &i
  3983. m.addstatus = nil
  3984. }
  3985. // Status returns the value of the "status" field in the mutation.
  3986. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3987. v := m.status
  3988. if v == nil {
  3989. return
  3990. }
  3991. return *v, true
  3992. }
  3993. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3994. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3996. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3997. if !m.op.Is(OpUpdateOne) {
  3998. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3999. }
  4000. if m.id == nil || m.oldValue == nil {
  4001. return v, errors.New("OldStatus requires an ID field in the mutation")
  4002. }
  4003. oldValue, err := m.oldValue(ctx)
  4004. if err != nil {
  4005. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4006. }
  4007. return oldValue.Status, nil
  4008. }
  4009. // AddStatus adds i to the "status" field.
  4010. func (m *AllocAgentMutation) AddStatus(i int) {
  4011. if m.addstatus != nil {
  4012. *m.addstatus += i
  4013. } else {
  4014. m.addstatus = &i
  4015. }
  4016. }
  4017. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4018. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  4019. v := m.addstatus
  4020. if v == nil {
  4021. return
  4022. }
  4023. return *v, true
  4024. }
  4025. // ClearStatus clears the value of the "status" field.
  4026. func (m *AllocAgentMutation) ClearStatus() {
  4027. m.status = nil
  4028. m.addstatus = nil
  4029. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  4030. }
  4031. // StatusCleared returns if the "status" field was cleared in this mutation.
  4032. func (m *AllocAgentMutation) StatusCleared() bool {
  4033. _, ok := m.clearedFields[allocagent.FieldStatus]
  4034. return ok
  4035. }
  4036. // ResetStatus resets all changes to the "status" field.
  4037. func (m *AllocAgentMutation) ResetStatus() {
  4038. m.status = nil
  4039. m.addstatus = nil
  4040. delete(m.clearedFields, allocagent.FieldStatus)
  4041. }
  4042. // Where appends a list predicates to the AllocAgentMutation builder.
  4043. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  4044. m.predicates = append(m.predicates, ps...)
  4045. }
  4046. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  4047. // users can use type-assertion to append predicates that do not depend on any generated package.
  4048. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  4049. p := make([]predicate.AllocAgent, len(ps))
  4050. for i := range ps {
  4051. p[i] = ps[i]
  4052. }
  4053. m.Where(p...)
  4054. }
  4055. // Op returns the operation name.
  4056. func (m *AllocAgentMutation) Op() Op {
  4057. return m.op
  4058. }
  4059. // SetOp allows setting the mutation operation.
  4060. func (m *AllocAgentMutation) SetOp(op Op) {
  4061. m.op = op
  4062. }
  4063. // Type returns the node type of this mutation (AllocAgent).
  4064. func (m *AllocAgentMutation) Type() string {
  4065. return m.typ
  4066. }
  4067. // Fields returns all fields that were changed during this mutation. Note that in
  4068. // order to get all numeric fields that were incremented/decremented, call
  4069. // AddedFields().
  4070. func (m *AllocAgentMutation) Fields() []string {
  4071. fields := make([]string, 0, 7)
  4072. if m.created_at != nil {
  4073. fields = append(fields, allocagent.FieldCreatedAt)
  4074. }
  4075. if m.updated_at != nil {
  4076. fields = append(fields, allocagent.FieldUpdatedAt)
  4077. }
  4078. if m.deleted_at != nil {
  4079. fields = append(fields, allocagent.FieldDeletedAt)
  4080. }
  4081. if m.user_id != nil {
  4082. fields = append(fields, allocagent.FieldUserID)
  4083. }
  4084. if m.organization_id != nil {
  4085. fields = append(fields, allocagent.FieldOrganizationID)
  4086. }
  4087. if m.agents != nil {
  4088. fields = append(fields, allocagent.FieldAgents)
  4089. }
  4090. if m.status != nil {
  4091. fields = append(fields, allocagent.FieldStatus)
  4092. }
  4093. return fields
  4094. }
  4095. // Field returns the value of a field with the given name. The second boolean
  4096. // return value indicates that this field was not set, or was not defined in the
  4097. // schema.
  4098. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  4099. switch name {
  4100. case allocagent.FieldCreatedAt:
  4101. return m.CreatedAt()
  4102. case allocagent.FieldUpdatedAt:
  4103. return m.UpdatedAt()
  4104. case allocagent.FieldDeletedAt:
  4105. return m.DeletedAt()
  4106. case allocagent.FieldUserID:
  4107. return m.UserID()
  4108. case allocagent.FieldOrganizationID:
  4109. return m.OrganizationID()
  4110. case allocagent.FieldAgents:
  4111. return m.Agents()
  4112. case allocagent.FieldStatus:
  4113. return m.Status()
  4114. }
  4115. return nil, false
  4116. }
  4117. // OldField returns the old value of the field from the database. An error is
  4118. // returned if the mutation operation is not UpdateOne, or the query to the
  4119. // database failed.
  4120. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4121. switch name {
  4122. case allocagent.FieldCreatedAt:
  4123. return m.OldCreatedAt(ctx)
  4124. case allocagent.FieldUpdatedAt:
  4125. return m.OldUpdatedAt(ctx)
  4126. case allocagent.FieldDeletedAt:
  4127. return m.OldDeletedAt(ctx)
  4128. case allocagent.FieldUserID:
  4129. return m.OldUserID(ctx)
  4130. case allocagent.FieldOrganizationID:
  4131. return m.OldOrganizationID(ctx)
  4132. case allocagent.FieldAgents:
  4133. return m.OldAgents(ctx)
  4134. case allocagent.FieldStatus:
  4135. return m.OldStatus(ctx)
  4136. }
  4137. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  4138. }
  4139. // SetField sets the value of a field with the given name. It returns an error if
  4140. // the field is not defined in the schema, or if the type mismatched the field
  4141. // type.
  4142. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  4143. switch name {
  4144. case allocagent.FieldCreatedAt:
  4145. v, ok := value.(time.Time)
  4146. if !ok {
  4147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4148. }
  4149. m.SetCreatedAt(v)
  4150. return nil
  4151. case allocagent.FieldUpdatedAt:
  4152. v, ok := value.(time.Time)
  4153. if !ok {
  4154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4155. }
  4156. m.SetUpdatedAt(v)
  4157. return nil
  4158. case allocagent.FieldDeletedAt:
  4159. v, ok := value.(time.Time)
  4160. if !ok {
  4161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4162. }
  4163. m.SetDeletedAt(v)
  4164. return nil
  4165. case allocagent.FieldUserID:
  4166. v, ok := value.(string)
  4167. if !ok {
  4168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4169. }
  4170. m.SetUserID(v)
  4171. return nil
  4172. case allocagent.FieldOrganizationID:
  4173. v, ok := value.(uint64)
  4174. if !ok {
  4175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4176. }
  4177. m.SetOrganizationID(v)
  4178. return nil
  4179. case allocagent.FieldAgents:
  4180. v, ok := value.([]uint64)
  4181. if !ok {
  4182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4183. }
  4184. m.SetAgents(v)
  4185. return nil
  4186. case allocagent.FieldStatus:
  4187. v, ok := value.(int)
  4188. if !ok {
  4189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4190. }
  4191. m.SetStatus(v)
  4192. return nil
  4193. }
  4194. return fmt.Errorf("unknown AllocAgent field %s", name)
  4195. }
  4196. // AddedFields returns all numeric fields that were incremented/decremented during
  4197. // this mutation.
  4198. func (m *AllocAgentMutation) AddedFields() []string {
  4199. var fields []string
  4200. if m.addorganization_id != nil {
  4201. fields = append(fields, allocagent.FieldOrganizationID)
  4202. }
  4203. if m.addstatus != nil {
  4204. fields = append(fields, allocagent.FieldStatus)
  4205. }
  4206. return fields
  4207. }
  4208. // AddedField returns the numeric value that was incremented/decremented on a field
  4209. // with the given name. The second boolean return value indicates that this field
  4210. // was not set, or was not defined in the schema.
  4211. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  4212. switch name {
  4213. case allocagent.FieldOrganizationID:
  4214. return m.AddedOrganizationID()
  4215. case allocagent.FieldStatus:
  4216. return m.AddedStatus()
  4217. }
  4218. return nil, false
  4219. }
  4220. // AddField adds the value to the field with the given name. It returns an error if
  4221. // the field is not defined in the schema, or if the type mismatched the field
  4222. // type.
  4223. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  4224. switch name {
  4225. case allocagent.FieldOrganizationID:
  4226. v, ok := value.(int64)
  4227. if !ok {
  4228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4229. }
  4230. m.AddOrganizationID(v)
  4231. return nil
  4232. case allocagent.FieldStatus:
  4233. v, ok := value.(int)
  4234. if !ok {
  4235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4236. }
  4237. m.AddStatus(v)
  4238. return nil
  4239. }
  4240. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  4241. }
  4242. // ClearedFields returns all nullable fields that were cleared during this
  4243. // mutation.
  4244. func (m *AllocAgentMutation) ClearedFields() []string {
  4245. var fields []string
  4246. if m.FieldCleared(allocagent.FieldDeletedAt) {
  4247. fields = append(fields, allocagent.FieldDeletedAt)
  4248. }
  4249. if m.FieldCleared(allocagent.FieldUserID) {
  4250. fields = append(fields, allocagent.FieldUserID)
  4251. }
  4252. if m.FieldCleared(allocagent.FieldOrganizationID) {
  4253. fields = append(fields, allocagent.FieldOrganizationID)
  4254. }
  4255. if m.FieldCleared(allocagent.FieldStatus) {
  4256. fields = append(fields, allocagent.FieldStatus)
  4257. }
  4258. return fields
  4259. }
  4260. // FieldCleared returns a boolean indicating if a field with the given name was
  4261. // cleared in this mutation.
  4262. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  4263. _, ok := m.clearedFields[name]
  4264. return ok
  4265. }
  4266. // ClearField clears the value of the field with the given name. It returns an
  4267. // error if the field is not defined in the schema.
  4268. func (m *AllocAgentMutation) ClearField(name string) error {
  4269. switch name {
  4270. case allocagent.FieldDeletedAt:
  4271. m.ClearDeletedAt()
  4272. return nil
  4273. case allocagent.FieldUserID:
  4274. m.ClearUserID()
  4275. return nil
  4276. case allocagent.FieldOrganizationID:
  4277. m.ClearOrganizationID()
  4278. return nil
  4279. case allocagent.FieldStatus:
  4280. m.ClearStatus()
  4281. return nil
  4282. }
  4283. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  4284. }
  4285. // ResetField resets all changes in the mutation for the field with the given name.
  4286. // It returns an error if the field is not defined in the schema.
  4287. func (m *AllocAgentMutation) ResetField(name string) error {
  4288. switch name {
  4289. case allocagent.FieldCreatedAt:
  4290. m.ResetCreatedAt()
  4291. return nil
  4292. case allocagent.FieldUpdatedAt:
  4293. m.ResetUpdatedAt()
  4294. return nil
  4295. case allocagent.FieldDeletedAt:
  4296. m.ResetDeletedAt()
  4297. return nil
  4298. case allocagent.FieldUserID:
  4299. m.ResetUserID()
  4300. return nil
  4301. case allocagent.FieldOrganizationID:
  4302. m.ResetOrganizationID()
  4303. return nil
  4304. case allocagent.FieldAgents:
  4305. m.ResetAgents()
  4306. return nil
  4307. case allocagent.FieldStatus:
  4308. m.ResetStatus()
  4309. return nil
  4310. }
  4311. return fmt.Errorf("unknown AllocAgent field %s", name)
  4312. }
  4313. // AddedEdges returns all edge names that were set/added in this mutation.
  4314. func (m *AllocAgentMutation) AddedEdges() []string {
  4315. edges := make([]string, 0, 0)
  4316. return edges
  4317. }
  4318. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4319. // name in this mutation.
  4320. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4321. return nil
  4322. }
  4323. // RemovedEdges returns all edge names that were removed in this mutation.
  4324. func (m *AllocAgentMutation) RemovedEdges() []string {
  4325. edges := make([]string, 0, 0)
  4326. return edges
  4327. }
  4328. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4329. // the given name in this mutation.
  4330. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4331. return nil
  4332. }
  4333. // ClearedEdges returns all edge names that were cleared in this mutation.
  4334. func (m *AllocAgentMutation) ClearedEdges() []string {
  4335. edges := make([]string, 0, 0)
  4336. return edges
  4337. }
  4338. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4339. // was cleared in this mutation.
  4340. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4341. return false
  4342. }
  4343. // ClearEdge clears the value of the edge with the given name. It returns an error
  4344. // if that edge is not defined in the schema.
  4345. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4346. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4347. }
  4348. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4349. // It returns an error if the edge is not defined in the schema.
  4350. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4351. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4352. }
  4353. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4354. type ApiKeyMutation struct {
  4355. config
  4356. op Op
  4357. typ string
  4358. id *uint64
  4359. created_at *time.Time
  4360. updated_at *time.Time
  4361. deleted_at *time.Time
  4362. title *string
  4363. key *string
  4364. organization_id *uint64
  4365. addorganization_id *int64
  4366. custom_agent_base *string
  4367. custom_agent_key *string
  4368. openai_base *string
  4369. openai_key *string
  4370. clearedFields map[string]struct{}
  4371. agent *uint64
  4372. clearedagent bool
  4373. done bool
  4374. oldValue func(context.Context) (*ApiKey, error)
  4375. predicates []predicate.ApiKey
  4376. }
  4377. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4378. // apikeyOption allows management of the mutation configuration using functional options.
  4379. type apikeyOption func(*ApiKeyMutation)
  4380. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4381. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4382. m := &ApiKeyMutation{
  4383. config: c,
  4384. op: op,
  4385. typ: TypeApiKey,
  4386. clearedFields: make(map[string]struct{}),
  4387. }
  4388. for _, opt := range opts {
  4389. opt(m)
  4390. }
  4391. return m
  4392. }
  4393. // withApiKeyID sets the ID field of the mutation.
  4394. func withApiKeyID(id uint64) apikeyOption {
  4395. return func(m *ApiKeyMutation) {
  4396. var (
  4397. err error
  4398. once sync.Once
  4399. value *ApiKey
  4400. )
  4401. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4402. once.Do(func() {
  4403. if m.done {
  4404. err = errors.New("querying old values post mutation is not allowed")
  4405. } else {
  4406. value, err = m.Client().ApiKey.Get(ctx, id)
  4407. }
  4408. })
  4409. return value, err
  4410. }
  4411. m.id = &id
  4412. }
  4413. }
  4414. // withApiKey sets the old ApiKey of the mutation.
  4415. func withApiKey(node *ApiKey) apikeyOption {
  4416. return func(m *ApiKeyMutation) {
  4417. m.oldValue = func(context.Context) (*ApiKey, error) {
  4418. return node, nil
  4419. }
  4420. m.id = &node.ID
  4421. }
  4422. }
  4423. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4424. // executed in a transaction (ent.Tx), a transactional client is returned.
  4425. func (m ApiKeyMutation) Client() *Client {
  4426. client := &Client{config: m.config}
  4427. client.init()
  4428. return client
  4429. }
  4430. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4431. // it returns an error otherwise.
  4432. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4433. if _, ok := m.driver.(*txDriver); !ok {
  4434. return nil, errors.New("ent: mutation is not running in a transaction")
  4435. }
  4436. tx := &Tx{config: m.config}
  4437. tx.init()
  4438. return tx, nil
  4439. }
  4440. // SetID sets the value of the id field. Note that this
  4441. // operation is only accepted on creation of ApiKey entities.
  4442. func (m *ApiKeyMutation) SetID(id uint64) {
  4443. m.id = &id
  4444. }
  4445. // ID returns the ID value in the mutation. Note that the ID is only available
  4446. // if it was provided to the builder or after it was returned from the database.
  4447. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4448. if m.id == nil {
  4449. return
  4450. }
  4451. return *m.id, true
  4452. }
  4453. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4454. // That means, if the mutation is applied within a transaction with an isolation level such
  4455. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4456. // or updated by the mutation.
  4457. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4458. switch {
  4459. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4460. id, exists := m.ID()
  4461. if exists {
  4462. return []uint64{id}, nil
  4463. }
  4464. fallthrough
  4465. case m.op.Is(OpUpdate | OpDelete):
  4466. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4467. default:
  4468. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4469. }
  4470. }
  4471. // SetCreatedAt sets the "created_at" field.
  4472. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4473. m.created_at = &t
  4474. }
  4475. // CreatedAt returns the value of the "created_at" field in the mutation.
  4476. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4477. v := m.created_at
  4478. if v == nil {
  4479. return
  4480. }
  4481. return *v, true
  4482. }
  4483. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4484. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4486. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4487. if !m.op.Is(OpUpdateOne) {
  4488. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4489. }
  4490. if m.id == nil || m.oldValue == nil {
  4491. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4492. }
  4493. oldValue, err := m.oldValue(ctx)
  4494. if err != nil {
  4495. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4496. }
  4497. return oldValue.CreatedAt, nil
  4498. }
  4499. // ResetCreatedAt resets all changes to the "created_at" field.
  4500. func (m *ApiKeyMutation) ResetCreatedAt() {
  4501. m.created_at = nil
  4502. }
  4503. // SetUpdatedAt sets the "updated_at" field.
  4504. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4505. m.updated_at = &t
  4506. }
  4507. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4508. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4509. v := m.updated_at
  4510. if v == nil {
  4511. return
  4512. }
  4513. return *v, true
  4514. }
  4515. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4516. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4518. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4519. if !m.op.Is(OpUpdateOne) {
  4520. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4521. }
  4522. if m.id == nil || m.oldValue == nil {
  4523. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4524. }
  4525. oldValue, err := m.oldValue(ctx)
  4526. if err != nil {
  4527. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4528. }
  4529. return oldValue.UpdatedAt, nil
  4530. }
  4531. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4532. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4533. m.updated_at = nil
  4534. }
  4535. // SetDeletedAt sets the "deleted_at" field.
  4536. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4537. m.deleted_at = &t
  4538. }
  4539. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4540. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4541. v := m.deleted_at
  4542. if v == nil {
  4543. return
  4544. }
  4545. return *v, true
  4546. }
  4547. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4548. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4550. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4551. if !m.op.Is(OpUpdateOne) {
  4552. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4553. }
  4554. if m.id == nil || m.oldValue == nil {
  4555. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4556. }
  4557. oldValue, err := m.oldValue(ctx)
  4558. if err != nil {
  4559. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4560. }
  4561. return oldValue.DeletedAt, nil
  4562. }
  4563. // ClearDeletedAt clears the value of the "deleted_at" field.
  4564. func (m *ApiKeyMutation) ClearDeletedAt() {
  4565. m.deleted_at = nil
  4566. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4567. }
  4568. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4569. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4570. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4571. return ok
  4572. }
  4573. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4574. func (m *ApiKeyMutation) ResetDeletedAt() {
  4575. m.deleted_at = nil
  4576. delete(m.clearedFields, apikey.FieldDeletedAt)
  4577. }
  4578. // SetTitle sets the "title" field.
  4579. func (m *ApiKeyMutation) SetTitle(s string) {
  4580. m.title = &s
  4581. }
  4582. // Title returns the value of the "title" field in the mutation.
  4583. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4584. v := m.title
  4585. if v == nil {
  4586. return
  4587. }
  4588. return *v, true
  4589. }
  4590. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4591. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4593. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4594. if !m.op.Is(OpUpdateOne) {
  4595. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4596. }
  4597. if m.id == nil || m.oldValue == nil {
  4598. return v, errors.New("OldTitle requires an ID field in the mutation")
  4599. }
  4600. oldValue, err := m.oldValue(ctx)
  4601. if err != nil {
  4602. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4603. }
  4604. return oldValue.Title, nil
  4605. }
  4606. // ClearTitle clears the value of the "title" field.
  4607. func (m *ApiKeyMutation) ClearTitle() {
  4608. m.title = nil
  4609. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4610. }
  4611. // TitleCleared returns if the "title" field was cleared in this mutation.
  4612. func (m *ApiKeyMutation) TitleCleared() bool {
  4613. _, ok := m.clearedFields[apikey.FieldTitle]
  4614. return ok
  4615. }
  4616. // ResetTitle resets all changes to the "title" field.
  4617. func (m *ApiKeyMutation) ResetTitle() {
  4618. m.title = nil
  4619. delete(m.clearedFields, apikey.FieldTitle)
  4620. }
  4621. // SetKey sets the "key" field.
  4622. func (m *ApiKeyMutation) SetKey(s string) {
  4623. m.key = &s
  4624. }
  4625. // Key returns the value of the "key" field in the mutation.
  4626. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4627. v := m.key
  4628. if v == nil {
  4629. return
  4630. }
  4631. return *v, true
  4632. }
  4633. // OldKey returns the old "key" 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) OldKey(ctx context.Context) (v string, err error) {
  4637. if !m.op.Is(OpUpdateOne) {
  4638. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4639. }
  4640. if m.id == nil || m.oldValue == nil {
  4641. return v, errors.New("OldKey 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 OldKey: %w", err)
  4646. }
  4647. return oldValue.Key, nil
  4648. }
  4649. // ClearKey clears the value of the "key" field.
  4650. func (m *ApiKeyMutation) ClearKey() {
  4651. m.key = nil
  4652. m.clearedFields[apikey.FieldKey] = struct{}{}
  4653. }
  4654. // KeyCleared returns if the "key" field was cleared in this mutation.
  4655. func (m *ApiKeyMutation) KeyCleared() bool {
  4656. _, ok := m.clearedFields[apikey.FieldKey]
  4657. return ok
  4658. }
  4659. // ResetKey resets all changes to the "key" field.
  4660. func (m *ApiKeyMutation) ResetKey() {
  4661. m.key = nil
  4662. delete(m.clearedFields, apikey.FieldKey)
  4663. }
  4664. // SetOrganizationID sets the "organization_id" field.
  4665. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4666. m.organization_id = &u
  4667. m.addorganization_id = nil
  4668. }
  4669. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4670. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4671. v := m.organization_id
  4672. if v == nil {
  4673. return
  4674. }
  4675. return *v, true
  4676. }
  4677. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4678. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4680. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4681. if !m.op.Is(OpUpdateOne) {
  4682. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4683. }
  4684. if m.id == nil || m.oldValue == nil {
  4685. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4686. }
  4687. oldValue, err := m.oldValue(ctx)
  4688. if err != nil {
  4689. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4690. }
  4691. return oldValue.OrganizationID, nil
  4692. }
  4693. // AddOrganizationID adds u to the "organization_id" field.
  4694. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4695. if m.addorganization_id != nil {
  4696. *m.addorganization_id += u
  4697. } else {
  4698. m.addorganization_id = &u
  4699. }
  4700. }
  4701. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4702. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4703. v := m.addorganization_id
  4704. if v == nil {
  4705. return
  4706. }
  4707. return *v, true
  4708. }
  4709. // ResetOrganizationID resets all changes to the "organization_id" field.
  4710. func (m *ApiKeyMutation) ResetOrganizationID() {
  4711. m.organization_id = nil
  4712. m.addorganization_id = nil
  4713. }
  4714. // SetAgentID sets the "agent_id" field.
  4715. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4716. m.agent = &u
  4717. }
  4718. // AgentID returns the value of the "agent_id" field in the mutation.
  4719. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4720. v := m.agent
  4721. if v == nil {
  4722. return
  4723. }
  4724. return *v, true
  4725. }
  4726. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4727. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4729. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4730. if !m.op.Is(OpUpdateOne) {
  4731. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4732. }
  4733. if m.id == nil || m.oldValue == nil {
  4734. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4735. }
  4736. oldValue, err := m.oldValue(ctx)
  4737. if err != nil {
  4738. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4739. }
  4740. return oldValue.AgentID, nil
  4741. }
  4742. // ResetAgentID resets all changes to the "agent_id" field.
  4743. func (m *ApiKeyMutation) ResetAgentID() {
  4744. m.agent = nil
  4745. }
  4746. // SetCustomAgentBase sets the "custom_agent_base" field.
  4747. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4748. m.custom_agent_base = &s
  4749. }
  4750. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4751. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4752. v := m.custom_agent_base
  4753. if v == nil {
  4754. return
  4755. }
  4756. return *v, true
  4757. }
  4758. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4759. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4761. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4762. if !m.op.Is(OpUpdateOne) {
  4763. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4764. }
  4765. if m.id == nil || m.oldValue == nil {
  4766. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4767. }
  4768. oldValue, err := m.oldValue(ctx)
  4769. if err != nil {
  4770. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4771. }
  4772. return oldValue.CustomAgentBase, nil
  4773. }
  4774. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4775. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4776. m.custom_agent_base = nil
  4777. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4778. }
  4779. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4780. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4781. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4782. return ok
  4783. }
  4784. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4785. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4786. m.custom_agent_base = nil
  4787. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4788. }
  4789. // SetCustomAgentKey sets the "custom_agent_key" field.
  4790. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4791. m.custom_agent_key = &s
  4792. }
  4793. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4794. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4795. v := m.custom_agent_key
  4796. if v == nil {
  4797. return
  4798. }
  4799. return *v, true
  4800. }
  4801. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4802. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4804. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4805. if !m.op.Is(OpUpdateOne) {
  4806. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4807. }
  4808. if m.id == nil || m.oldValue == nil {
  4809. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4810. }
  4811. oldValue, err := m.oldValue(ctx)
  4812. if err != nil {
  4813. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4814. }
  4815. return oldValue.CustomAgentKey, nil
  4816. }
  4817. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4818. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4819. m.custom_agent_key = nil
  4820. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4821. }
  4822. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4823. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4824. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4825. return ok
  4826. }
  4827. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4828. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4829. m.custom_agent_key = nil
  4830. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4831. }
  4832. // SetOpenaiBase sets the "openai_base" field.
  4833. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4834. m.openai_base = &s
  4835. }
  4836. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4837. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4838. v := m.openai_base
  4839. if v == nil {
  4840. return
  4841. }
  4842. return *v, true
  4843. }
  4844. // OldOpenaiBase returns the old "openai_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) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4848. if !m.op.Is(OpUpdateOne) {
  4849. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4850. }
  4851. if m.id == nil || m.oldValue == nil {
  4852. return v, errors.New("OldOpenaiBase 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 OldOpenaiBase: %w", err)
  4857. }
  4858. return oldValue.OpenaiBase, nil
  4859. }
  4860. // ClearOpenaiBase clears the value of the "openai_base" field.
  4861. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4862. m.openai_base = nil
  4863. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4864. }
  4865. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4866. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4867. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4868. return ok
  4869. }
  4870. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4871. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4872. m.openai_base = nil
  4873. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4874. }
  4875. // SetOpenaiKey sets the "openai_key" field.
  4876. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4877. m.openai_key = &s
  4878. }
  4879. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4880. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4881. v := m.openai_key
  4882. if v == nil {
  4883. return
  4884. }
  4885. return *v, true
  4886. }
  4887. // OldOpenaiKey returns the old "openai_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) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4891. if !m.op.Is(OpUpdateOne) {
  4892. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4893. }
  4894. if m.id == nil || m.oldValue == nil {
  4895. return v, errors.New("OldOpenaiKey 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 OldOpenaiKey: %w", err)
  4900. }
  4901. return oldValue.OpenaiKey, nil
  4902. }
  4903. // ClearOpenaiKey clears the value of the "openai_key" field.
  4904. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4905. m.openai_key = nil
  4906. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4907. }
  4908. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4909. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4910. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4911. return ok
  4912. }
  4913. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4914. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4915. m.openai_key = nil
  4916. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4917. }
  4918. // ClearAgent clears the "agent" edge to the Agent entity.
  4919. func (m *ApiKeyMutation) ClearAgent() {
  4920. m.clearedagent = true
  4921. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4922. }
  4923. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4924. func (m *ApiKeyMutation) AgentCleared() bool {
  4925. return m.clearedagent
  4926. }
  4927. // AgentIDs returns the "agent" edge IDs in the mutation.
  4928. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4929. // AgentID instead. It exists only for internal usage by the builders.
  4930. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4931. if id := m.agent; id != nil {
  4932. ids = append(ids, *id)
  4933. }
  4934. return
  4935. }
  4936. // ResetAgent resets all changes to the "agent" edge.
  4937. func (m *ApiKeyMutation) ResetAgent() {
  4938. m.agent = nil
  4939. m.clearedagent = false
  4940. }
  4941. // Where appends a list predicates to the ApiKeyMutation builder.
  4942. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4943. m.predicates = append(m.predicates, ps...)
  4944. }
  4945. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4946. // users can use type-assertion to append predicates that do not depend on any generated package.
  4947. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4948. p := make([]predicate.ApiKey, len(ps))
  4949. for i := range ps {
  4950. p[i] = ps[i]
  4951. }
  4952. m.Where(p...)
  4953. }
  4954. // Op returns the operation name.
  4955. func (m *ApiKeyMutation) Op() Op {
  4956. return m.op
  4957. }
  4958. // SetOp allows setting the mutation operation.
  4959. func (m *ApiKeyMutation) SetOp(op Op) {
  4960. m.op = op
  4961. }
  4962. // Type returns the node type of this mutation (ApiKey).
  4963. func (m *ApiKeyMutation) Type() string {
  4964. return m.typ
  4965. }
  4966. // Fields returns all fields that were changed during this mutation. Note that in
  4967. // order to get all numeric fields that were incremented/decremented, call
  4968. // AddedFields().
  4969. func (m *ApiKeyMutation) Fields() []string {
  4970. fields := make([]string, 0, 11)
  4971. if m.created_at != nil {
  4972. fields = append(fields, apikey.FieldCreatedAt)
  4973. }
  4974. if m.updated_at != nil {
  4975. fields = append(fields, apikey.FieldUpdatedAt)
  4976. }
  4977. if m.deleted_at != nil {
  4978. fields = append(fields, apikey.FieldDeletedAt)
  4979. }
  4980. if m.title != nil {
  4981. fields = append(fields, apikey.FieldTitle)
  4982. }
  4983. if m.key != nil {
  4984. fields = append(fields, apikey.FieldKey)
  4985. }
  4986. if m.organization_id != nil {
  4987. fields = append(fields, apikey.FieldOrganizationID)
  4988. }
  4989. if m.agent != nil {
  4990. fields = append(fields, apikey.FieldAgentID)
  4991. }
  4992. if m.custom_agent_base != nil {
  4993. fields = append(fields, apikey.FieldCustomAgentBase)
  4994. }
  4995. if m.custom_agent_key != nil {
  4996. fields = append(fields, apikey.FieldCustomAgentKey)
  4997. }
  4998. if m.openai_base != nil {
  4999. fields = append(fields, apikey.FieldOpenaiBase)
  5000. }
  5001. if m.openai_key != nil {
  5002. fields = append(fields, apikey.FieldOpenaiKey)
  5003. }
  5004. return fields
  5005. }
  5006. // Field returns the value of a field with the given name. The second boolean
  5007. // return value indicates that this field was not set, or was not defined in the
  5008. // schema.
  5009. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  5010. switch name {
  5011. case apikey.FieldCreatedAt:
  5012. return m.CreatedAt()
  5013. case apikey.FieldUpdatedAt:
  5014. return m.UpdatedAt()
  5015. case apikey.FieldDeletedAt:
  5016. return m.DeletedAt()
  5017. case apikey.FieldTitle:
  5018. return m.Title()
  5019. case apikey.FieldKey:
  5020. return m.Key()
  5021. case apikey.FieldOrganizationID:
  5022. return m.OrganizationID()
  5023. case apikey.FieldAgentID:
  5024. return m.AgentID()
  5025. case apikey.FieldCustomAgentBase:
  5026. return m.CustomAgentBase()
  5027. case apikey.FieldCustomAgentKey:
  5028. return m.CustomAgentKey()
  5029. case apikey.FieldOpenaiBase:
  5030. return m.OpenaiBase()
  5031. case apikey.FieldOpenaiKey:
  5032. return m.OpenaiKey()
  5033. }
  5034. return nil, false
  5035. }
  5036. // OldField returns the old value of the field from the database. An error is
  5037. // returned if the mutation operation is not UpdateOne, or the query to the
  5038. // database failed.
  5039. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5040. switch name {
  5041. case apikey.FieldCreatedAt:
  5042. return m.OldCreatedAt(ctx)
  5043. case apikey.FieldUpdatedAt:
  5044. return m.OldUpdatedAt(ctx)
  5045. case apikey.FieldDeletedAt:
  5046. return m.OldDeletedAt(ctx)
  5047. case apikey.FieldTitle:
  5048. return m.OldTitle(ctx)
  5049. case apikey.FieldKey:
  5050. return m.OldKey(ctx)
  5051. case apikey.FieldOrganizationID:
  5052. return m.OldOrganizationID(ctx)
  5053. case apikey.FieldAgentID:
  5054. return m.OldAgentID(ctx)
  5055. case apikey.FieldCustomAgentBase:
  5056. return m.OldCustomAgentBase(ctx)
  5057. case apikey.FieldCustomAgentKey:
  5058. return m.OldCustomAgentKey(ctx)
  5059. case apikey.FieldOpenaiBase:
  5060. return m.OldOpenaiBase(ctx)
  5061. case apikey.FieldOpenaiKey:
  5062. return m.OldOpenaiKey(ctx)
  5063. }
  5064. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  5065. }
  5066. // SetField sets the value of a field with the given name. It returns an error if
  5067. // the field is not defined in the schema, or if the type mismatched the field
  5068. // type.
  5069. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  5070. switch name {
  5071. case apikey.FieldCreatedAt:
  5072. v, ok := value.(time.Time)
  5073. if !ok {
  5074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5075. }
  5076. m.SetCreatedAt(v)
  5077. return nil
  5078. case apikey.FieldUpdatedAt:
  5079. v, ok := value.(time.Time)
  5080. if !ok {
  5081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5082. }
  5083. m.SetUpdatedAt(v)
  5084. return nil
  5085. case apikey.FieldDeletedAt:
  5086. v, ok := value.(time.Time)
  5087. if !ok {
  5088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5089. }
  5090. m.SetDeletedAt(v)
  5091. return nil
  5092. case apikey.FieldTitle:
  5093. v, ok := value.(string)
  5094. if !ok {
  5095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5096. }
  5097. m.SetTitle(v)
  5098. return nil
  5099. case apikey.FieldKey:
  5100. v, ok := value.(string)
  5101. if !ok {
  5102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5103. }
  5104. m.SetKey(v)
  5105. return nil
  5106. case apikey.FieldOrganizationID:
  5107. v, ok := value.(uint64)
  5108. if !ok {
  5109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5110. }
  5111. m.SetOrganizationID(v)
  5112. return nil
  5113. case apikey.FieldAgentID:
  5114. v, ok := value.(uint64)
  5115. if !ok {
  5116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5117. }
  5118. m.SetAgentID(v)
  5119. return nil
  5120. case apikey.FieldCustomAgentBase:
  5121. v, ok := value.(string)
  5122. if !ok {
  5123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5124. }
  5125. m.SetCustomAgentBase(v)
  5126. return nil
  5127. case apikey.FieldCustomAgentKey:
  5128. v, ok := value.(string)
  5129. if !ok {
  5130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5131. }
  5132. m.SetCustomAgentKey(v)
  5133. return nil
  5134. case apikey.FieldOpenaiBase:
  5135. v, ok := value.(string)
  5136. if !ok {
  5137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5138. }
  5139. m.SetOpenaiBase(v)
  5140. return nil
  5141. case apikey.FieldOpenaiKey:
  5142. v, ok := value.(string)
  5143. if !ok {
  5144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5145. }
  5146. m.SetOpenaiKey(v)
  5147. return nil
  5148. }
  5149. return fmt.Errorf("unknown ApiKey field %s", name)
  5150. }
  5151. // AddedFields returns all numeric fields that were incremented/decremented during
  5152. // this mutation.
  5153. func (m *ApiKeyMutation) AddedFields() []string {
  5154. var fields []string
  5155. if m.addorganization_id != nil {
  5156. fields = append(fields, apikey.FieldOrganizationID)
  5157. }
  5158. return fields
  5159. }
  5160. // AddedField returns the numeric value that was incremented/decremented on a field
  5161. // with the given name. The second boolean return value indicates that this field
  5162. // was not set, or was not defined in the schema.
  5163. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  5164. switch name {
  5165. case apikey.FieldOrganizationID:
  5166. return m.AddedOrganizationID()
  5167. }
  5168. return nil, false
  5169. }
  5170. // AddField adds the value to the field with the given name. It returns an error if
  5171. // the field is not defined in the schema, or if the type mismatched the field
  5172. // type.
  5173. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  5174. switch name {
  5175. case apikey.FieldOrganizationID:
  5176. v, ok := value.(int64)
  5177. if !ok {
  5178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5179. }
  5180. m.AddOrganizationID(v)
  5181. return nil
  5182. }
  5183. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  5184. }
  5185. // ClearedFields returns all nullable fields that were cleared during this
  5186. // mutation.
  5187. func (m *ApiKeyMutation) ClearedFields() []string {
  5188. var fields []string
  5189. if m.FieldCleared(apikey.FieldDeletedAt) {
  5190. fields = append(fields, apikey.FieldDeletedAt)
  5191. }
  5192. if m.FieldCleared(apikey.FieldTitle) {
  5193. fields = append(fields, apikey.FieldTitle)
  5194. }
  5195. if m.FieldCleared(apikey.FieldKey) {
  5196. fields = append(fields, apikey.FieldKey)
  5197. }
  5198. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  5199. fields = append(fields, apikey.FieldCustomAgentBase)
  5200. }
  5201. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  5202. fields = append(fields, apikey.FieldCustomAgentKey)
  5203. }
  5204. if m.FieldCleared(apikey.FieldOpenaiBase) {
  5205. fields = append(fields, apikey.FieldOpenaiBase)
  5206. }
  5207. if m.FieldCleared(apikey.FieldOpenaiKey) {
  5208. fields = append(fields, apikey.FieldOpenaiKey)
  5209. }
  5210. return fields
  5211. }
  5212. // FieldCleared returns a boolean indicating if a field with the given name was
  5213. // cleared in this mutation.
  5214. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  5215. _, ok := m.clearedFields[name]
  5216. return ok
  5217. }
  5218. // ClearField clears the value of the field with the given name. It returns an
  5219. // error if the field is not defined in the schema.
  5220. func (m *ApiKeyMutation) ClearField(name string) error {
  5221. switch name {
  5222. case apikey.FieldDeletedAt:
  5223. m.ClearDeletedAt()
  5224. return nil
  5225. case apikey.FieldTitle:
  5226. m.ClearTitle()
  5227. return nil
  5228. case apikey.FieldKey:
  5229. m.ClearKey()
  5230. return nil
  5231. case apikey.FieldCustomAgentBase:
  5232. m.ClearCustomAgentBase()
  5233. return nil
  5234. case apikey.FieldCustomAgentKey:
  5235. m.ClearCustomAgentKey()
  5236. return nil
  5237. case apikey.FieldOpenaiBase:
  5238. m.ClearOpenaiBase()
  5239. return nil
  5240. case apikey.FieldOpenaiKey:
  5241. m.ClearOpenaiKey()
  5242. return nil
  5243. }
  5244. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  5245. }
  5246. // ResetField resets all changes in the mutation for the field with the given name.
  5247. // It returns an error if the field is not defined in the schema.
  5248. func (m *ApiKeyMutation) ResetField(name string) error {
  5249. switch name {
  5250. case apikey.FieldCreatedAt:
  5251. m.ResetCreatedAt()
  5252. return nil
  5253. case apikey.FieldUpdatedAt:
  5254. m.ResetUpdatedAt()
  5255. return nil
  5256. case apikey.FieldDeletedAt:
  5257. m.ResetDeletedAt()
  5258. return nil
  5259. case apikey.FieldTitle:
  5260. m.ResetTitle()
  5261. return nil
  5262. case apikey.FieldKey:
  5263. m.ResetKey()
  5264. return nil
  5265. case apikey.FieldOrganizationID:
  5266. m.ResetOrganizationID()
  5267. return nil
  5268. case apikey.FieldAgentID:
  5269. m.ResetAgentID()
  5270. return nil
  5271. case apikey.FieldCustomAgentBase:
  5272. m.ResetCustomAgentBase()
  5273. return nil
  5274. case apikey.FieldCustomAgentKey:
  5275. m.ResetCustomAgentKey()
  5276. return nil
  5277. case apikey.FieldOpenaiBase:
  5278. m.ResetOpenaiBase()
  5279. return nil
  5280. case apikey.FieldOpenaiKey:
  5281. m.ResetOpenaiKey()
  5282. return nil
  5283. }
  5284. return fmt.Errorf("unknown ApiKey field %s", name)
  5285. }
  5286. // AddedEdges returns all edge names that were set/added in this mutation.
  5287. func (m *ApiKeyMutation) AddedEdges() []string {
  5288. edges := make([]string, 0, 1)
  5289. if m.agent != nil {
  5290. edges = append(edges, apikey.EdgeAgent)
  5291. }
  5292. return edges
  5293. }
  5294. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5295. // name in this mutation.
  5296. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  5297. switch name {
  5298. case apikey.EdgeAgent:
  5299. if id := m.agent; id != nil {
  5300. return []ent.Value{*id}
  5301. }
  5302. }
  5303. return nil
  5304. }
  5305. // RemovedEdges returns all edge names that were removed in this mutation.
  5306. func (m *ApiKeyMutation) RemovedEdges() []string {
  5307. edges := make([]string, 0, 1)
  5308. return edges
  5309. }
  5310. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5311. // the given name in this mutation.
  5312. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  5313. return nil
  5314. }
  5315. // ClearedEdges returns all edge names that were cleared in this mutation.
  5316. func (m *ApiKeyMutation) ClearedEdges() []string {
  5317. edges := make([]string, 0, 1)
  5318. if m.clearedagent {
  5319. edges = append(edges, apikey.EdgeAgent)
  5320. }
  5321. return edges
  5322. }
  5323. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5324. // was cleared in this mutation.
  5325. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5326. switch name {
  5327. case apikey.EdgeAgent:
  5328. return m.clearedagent
  5329. }
  5330. return false
  5331. }
  5332. // ClearEdge clears the value of the edge with the given name. It returns an error
  5333. // if that edge is not defined in the schema.
  5334. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5335. switch name {
  5336. case apikey.EdgeAgent:
  5337. m.ClearAgent()
  5338. return nil
  5339. }
  5340. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5341. }
  5342. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5343. // It returns an error if the edge is not defined in the schema.
  5344. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5345. switch name {
  5346. case apikey.EdgeAgent:
  5347. m.ResetAgent()
  5348. return nil
  5349. }
  5350. return fmt.Errorf("unknown ApiKey edge %s", name)
  5351. }
  5352. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5353. type BatchMsgMutation struct {
  5354. config
  5355. op Op
  5356. typ string
  5357. id *uint64
  5358. created_at *time.Time
  5359. updated_at *time.Time
  5360. deleted_at *time.Time
  5361. status *uint8
  5362. addstatus *int8
  5363. batch_no *string
  5364. task_name *string
  5365. fromwxid *string
  5366. msg *string
  5367. tag *string
  5368. tagids *string
  5369. total *int32
  5370. addtotal *int32
  5371. success *int32
  5372. addsuccess *int32
  5373. fail *int32
  5374. addfail *int32
  5375. start_time *time.Time
  5376. stop_time *time.Time
  5377. send_time *time.Time
  5378. _type *int32
  5379. add_type *int32
  5380. organization_id *uint64
  5381. addorganization_id *int64
  5382. ctype *uint64
  5383. addctype *int64
  5384. cc *string
  5385. phone *string
  5386. template_name *string
  5387. template_code *string
  5388. lang *string
  5389. clearedFields map[string]struct{}
  5390. done bool
  5391. oldValue func(context.Context) (*BatchMsg, error)
  5392. predicates []predicate.BatchMsg
  5393. }
  5394. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5395. // batchmsgOption allows management of the mutation configuration using functional options.
  5396. type batchmsgOption func(*BatchMsgMutation)
  5397. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5398. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5399. m := &BatchMsgMutation{
  5400. config: c,
  5401. op: op,
  5402. typ: TypeBatchMsg,
  5403. clearedFields: make(map[string]struct{}),
  5404. }
  5405. for _, opt := range opts {
  5406. opt(m)
  5407. }
  5408. return m
  5409. }
  5410. // withBatchMsgID sets the ID field of the mutation.
  5411. func withBatchMsgID(id uint64) batchmsgOption {
  5412. return func(m *BatchMsgMutation) {
  5413. var (
  5414. err error
  5415. once sync.Once
  5416. value *BatchMsg
  5417. )
  5418. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5419. once.Do(func() {
  5420. if m.done {
  5421. err = errors.New("querying old values post mutation is not allowed")
  5422. } else {
  5423. value, err = m.Client().BatchMsg.Get(ctx, id)
  5424. }
  5425. })
  5426. return value, err
  5427. }
  5428. m.id = &id
  5429. }
  5430. }
  5431. // withBatchMsg sets the old BatchMsg of the mutation.
  5432. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5433. return func(m *BatchMsgMutation) {
  5434. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5435. return node, nil
  5436. }
  5437. m.id = &node.ID
  5438. }
  5439. }
  5440. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5441. // executed in a transaction (ent.Tx), a transactional client is returned.
  5442. func (m BatchMsgMutation) Client() *Client {
  5443. client := &Client{config: m.config}
  5444. client.init()
  5445. return client
  5446. }
  5447. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5448. // it returns an error otherwise.
  5449. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5450. if _, ok := m.driver.(*txDriver); !ok {
  5451. return nil, errors.New("ent: mutation is not running in a transaction")
  5452. }
  5453. tx := &Tx{config: m.config}
  5454. tx.init()
  5455. return tx, nil
  5456. }
  5457. // SetID sets the value of the id field. Note that this
  5458. // operation is only accepted on creation of BatchMsg entities.
  5459. func (m *BatchMsgMutation) SetID(id uint64) {
  5460. m.id = &id
  5461. }
  5462. // ID returns the ID value in the mutation. Note that the ID is only available
  5463. // if it was provided to the builder or after it was returned from the database.
  5464. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5465. if m.id == nil {
  5466. return
  5467. }
  5468. return *m.id, true
  5469. }
  5470. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5471. // That means, if the mutation is applied within a transaction with an isolation level such
  5472. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5473. // or updated by the mutation.
  5474. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5475. switch {
  5476. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5477. id, exists := m.ID()
  5478. if exists {
  5479. return []uint64{id}, nil
  5480. }
  5481. fallthrough
  5482. case m.op.Is(OpUpdate | OpDelete):
  5483. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5484. default:
  5485. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5486. }
  5487. }
  5488. // SetCreatedAt sets the "created_at" field.
  5489. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5490. m.created_at = &t
  5491. }
  5492. // CreatedAt returns the value of the "created_at" field in the mutation.
  5493. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5494. v := m.created_at
  5495. if v == nil {
  5496. return
  5497. }
  5498. return *v, true
  5499. }
  5500. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5501. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5503. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5504. if !m.op.Is(OpUpdateOne) {
  5505. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5506. }
  5507. if m.id == nil || m.oldValue == nil {
  5508. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5509. }
  5510. oldValue, err := m.oldValue(ctx)
  5511. if err != nil {
  5512. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5513. }
  5514. return oldValue.CreatedAt, nil
  5515. }
  5516. // ResetCreatedAt resets all changes to the "created_at" field.
  5517. func (m *BatchMsgMutation) ResetCreatedAt() {
  5518. m.created_at = nil
  5519. }
  5520. // SetUpdatedAt sets the "updated_at" field.
  5521. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5522. m.updated_at = &t
  5523. }
  5524. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5525. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5526. v := m.updated_at
  5527. if v == nil {
  5528. return
  5529. }
  5530. return *v, true
  5531. }
  5532. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5533. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5535. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5536. if !m.op.Is(OpUpdateOne) {
  5537. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5538. }
  5539. if m.id == nil || m.oldValue == nil {
  5540. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5541. }
  5542. oldValue, err := m.oldValue(ctx)
  5543. if err != nil {
  5544. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5545. }
  5546. return oldValue.UpdatedAt, nil
  5547. }
  5548. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5549. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5550. m.updated_at = nil
  5551. }
  5552. // SetDeletedAt sets the "deleted_at" field.
  5553. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5554. m.deleted_at = &t
  5555. }
  5556. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5557. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5558. v := m.deleted_at
  5559. if v == nil {
  5560. return
  5561. }
  5562. return *v, true
  5563. }
  5564. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5565. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5567. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5568. if !m.op.Is(OpUpdateOne) {
  5569. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5570. }
  5571. if m.id == nil || m.oldValue == nil {
  5572. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5573. }
  5574. oldValue, err := m.oldValue(ctx)
  5575. if err != nil {
  5576. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5577. }
  5578. return oldValue.DeletedAt, nil
  5579. }
  5580. // ClearDeletedAt clears the value of the "deleted_at" field.
  5581. func (m *BatchMsgMutation) ClearDeletedAt() {
  5582. m.deleted_at = nil
  5583. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5584. }
  5585. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5586. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5587. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5588. return ok
  5589. }
  5590. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5591. func (m *BatchMsgMutation) ResetDeletedAt() {
  5592. m.deleted_at = nil
  5593. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5594. }
  5595. // SetStatus sets the "status" field.
  5596. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5597. m.status = &u
  5598. m.addstatus = nil
  5599. }
  5600. // Status returns the value of the "status" field in the mutation.
  5601. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5602. v := m.status
  5603. if v == nil {
  5604. return
  5605. }
  5606. return *v, true
  5607. }
  5608. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5609. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5611. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5612. if !m.op.Is(OpUpdateOne) {
  5613. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5614. }
  5615. if m.id == nil || m.oldValue == nil {
  5616. return v, errors.New("OldStatus requires an ID field in the mutation")
  5617. }
  5618. oldValue, err := m.oldValue(ctx)
  5619. if err != nil {
  5620. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5621. }
  5622. return oldValue.Status, nil
  5623. }
  5624. // AddStatus adds u to the "status" field.
  5625. func (m *BatchMsgMutation) AddStatus(u int8) {
  5626. if m.addstatus != nil {
  5627. *m.addstatus += u
  5628. } else {
  5629. m.addstatus = &u
  5630. }
  5631. }
  5632. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5633. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5634. v := m.addstatus
  5635. if v == nil {
  5636. return
  5637. }
  5638. return *v, true
  5639. }
  5640. // ClearStatus clears the value of the "status" field.
  5641. func (m *BatchMsgMutation) ClearStatus() {
  5642. m.status = nil
  5643. m.addstatus = nil
  5644. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5645. }
  5646. // StatusCleared returns if the "status" field was cleared in this mutation.
  5647. func (m *BatchMsgMutation) StatusCleared() bool {
  5648. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5649. return ok
  5650. }
  5651. // ResetStatus resets all changes to the "status" field.
  5652. func (m *BatchMsgMutation) ResetStatus() {
  5653. m.status = nil
  5654. m.addstatus = nil
  5655. delete(m.clearedFields, batchmsg.FieldStatus)
  5656. }
  5657. // SetBatchNo sets the "batch_no" field.
  5658. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5659. m.batch_no = &s
  5660. }
  5661. // BatchNo returns the value of the "batch_no" field in the mutation.
  5662. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5663. v := m.batch_no
  5664. if v == nil {
  5665. return
  5666. }
  5667. return *v, true
  5668. }
  5669. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5670. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5672. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5673. if !m.op.Is(OpUpdateOne) {
  5674. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5675. }
  5676. if m.id == nil || m.oldValue == nil {
  5677. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5678. }
  5679. oldValue, err := m.oldValue(ctx)
  5680. if err != nil {
  5681. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5682. }
  5683. return oldValue.BatchNo, nil
  5684. }
  5685. // ClearBatchNo clears the value of the "batch_no" field.
  5686. func (m *BatchMsgMutation) ClearBatchNo() {
  5687. m.batch_no = nil
  5688. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5689. }
  5690. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5691. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5692. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5693. return ok
  5694. }
  5695. // ResetBatchNo resets all changes to the "batch_no" field.
  5696. func (m *BatchMsgMutation) ResetBatchNo() {
  5697. m.batch_no = nil
  5698. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5699. }
  5700. // SetTaskName sets the "task_name" field.
  5701. func (m *BatchMsgMutation) SetTaskName(s string) {
  5702. m.task_name = &s
  5703. }
  5704. // TaskName returns the value of the "task_name" field in the mutation.
  5705. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5706. v := m.task_name
  5707. if v == nil {
  5708. return
  5709. }
  5710. return *v, true
  5711. }
  5712. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5713. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5715. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5716. if !m.op.Is(OpUpdateOne) {
  5717. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5718. }
  5719. if m.id == nil || m.oldValue == nil {
  5720. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5721. }
  5722. oldValue, err := m.oldValue(ctx)
  5723. if err != nil {
  5724. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5725. }
  5726. return oldValue.TaskName, nil
  5727. }
  5728. // ClearTaskName clears the value of the "task_name" field.
  5729. func (m *BatchMsgMutation) ClearTaskName() {
  5730. m.task_name = nil
  5731. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5732. }
  5733. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5734. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5735. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5736. return ok
  5737. }
  5738. // ResetTaskName resets all changes to the "task_name" field.
  5739. func (m *BatchMsgMutation) ResetTaskName() {
  5740. m.task_name = nil
  5741. delete(m.clearedFields, batchmsg.FieldTaskName)
  5742. }
  5743. // SetFromwxid sets the "fromwxid" field.
  5744. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5745. m.fromwxid = &s
  5746. }
  5747. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5748. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5749. v := m.fromwxid
  5750. if v == nil {
  5751. return
  5752. }
  5753. return *v, true
  5754. }
  5755. // OldFromwxid returns the old "fromwxid" 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) OldFromwxid(ctx context.Context) (v string, err error) {
  5759. if !m.op.Is(OpUpdateOne) {
  5760. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5761. }
  5762. if m.id == nil || m.oldValue == nil {
  5763. return v, errors.New("OldFromwxid 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 OldFromwxid: %w", err)
  5768. }
  5769. return oldValue.Fromwxid, nil
  5770. }
  5771. // ClearFromwxid clears the value of the "fromwxid" field.
  5772. func (m *BatchMsgMutation) ClearFromwxid() {
  5773. m.fromwxid = nil
  5774. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5775. }
  5776. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5777. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5778. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5779. return ok
  5780. }
  5781. // ResetFromwxid resets all changes to the "fromwxid" field.
  5782. func (m *BatchMsgMutation) ResetFromwxid() {
  5783. m.fromwxid = nil
  5784. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5785. }
  5786. // SetMsg sets the "msg" field.
  5787. func (m *BatchMsgMutation) SetMsg(s string) {
  5788. m.msg = &s
  5789. }
  5790. // Msg returns the value of the "msg" field in the mutation.
  5791. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5792. v := m.msg
  5793. if v == nil {
  5794. return
  5795. }
  5796. return *v, true
  5797. }
  5798. // OldMsg returns the old "msg" 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) OldMsg(ctx context.Context) (v string, err error) {
  5802. if !m.op.Is(OpUpdateOne) {
  5803. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5804. }
  5805. if m.id == nil || m.oldValue == nil {
  5806. return v, errors.New("OldMsg 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 OldMsg: %w", err)
  5811. }
  5812. return oldValue.Msg, nil
  5813. }
  5814. // ClearMsg clears the value of the "msg" field.
  5815. func (m *BatchMsgMutation) ClearMsg() {
  5816. m.msg = nil
  5817. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5818. }
  5819. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5820. func (m *BatchMsgMutation) MsgCleared() bool {
  5821. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5822. return ok
  5823. }
  5824. // ResetMsg resets all changes to the "msg" field.
  5825. func (m *BatchMsgMutation) ResetMsg() {
  5826. m.msg = nil
  5827. delete(m.clearedFields, batchmsg.FieldMsg)
  5828. }
  5829. // SetTag sets the "tag" field.
  5830. func (m *BatchMsgMutation) SetTag(s string) {
  5831. m.tag = &s
  5832. }
  5833. // Tag returns the value of the "tag" field in the mutation.
  5834. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5835. v := m.tag
  5836. if v == nil {
  5837. return
  5838. }
  5839. return *v, true
  5840. }
  5841. // OldTag returns the old "tag" 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) OldTag(ctx context.Context) (v string, err error) {
  5845. if !m.op.Is(OpUpdateOne) {
  5846. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5847. }
  5848. if m.id == nil || m.oldValue == nil {
  5849. return v, errors.New("OldTag 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 OldTag: %w", err)
  5854. }
  5855. return oldValue.Tag, nil
  5856. }
  5857. // ClearTag clears the value of the "tag" field.
  5858. func (m *BatchMsgMutation) ClearTag() {
  5859. m.tag = nil
  5860. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5861. }
  5862. // TagCleared returns if the "tag" field was cleared in this mutation.
  5863. func (m *BatchMsgMutation) TagCleared() bool {
  5864. _, ok := m.clearedFields[batchmsg.FieldTag]
  5865. return ok
  5866. }
  5867. // ResetTag resets all changes to the "tag" field.
  5868. func (m *BatchMsgMutation) ResetTag() {
  5869. m.tag = nil
  5870. delete(m.clearedFields, batchmsg.FieldTag)
  5871. }
  5872. // SetTagids sets the "tagids" field.
  5873. func (m *BatchMsgMutation) SetTagids(s string) {
  5874. m.tagids = &s
  5875. }
  5876. // Tagids returns the value of the "tagids" field in the mutation.
  5877. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5878. v := m.tagids
  5879. if v == nil {
  5880. return
  5881. }
  5882. return *v, true
  5883. }
  5884. // OldTagids returns the old "tagids" 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) OldTagids(ctx context.Context) (v string, err error) {
  5888. if !m.op.Is(OpUpdateOne) {
  5889. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5890. }
  5891. if m.id == nil || m.oldValue == nil {
  5892. return v, errors.New("OldTagids 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 OldTagids: %w", err)
  5897. }
  5898. return oldValue.Tagids, nil
  5899. }
  5900. // ClearTagids clears the value of the "tagids" field.
  5901. func (m *BatchMsgMutation) ClearTagids() {
  5902. m.tagids = nil
  5903. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5904. }
  5905. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5906. func (m *BatchMsgMutation) TagidsCleared() bool {
  5907. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5908. return ok
  5909. }
  5910. // ResetTagids resets all changes to the "tagids" field.
  5911. func (m *BatchMsgMutation) ResetTagids() {
  5912. m.tagids = nil
  5913. delete(m.clearedFields, batchmsg.FieldTagids)
  5914. }
  5915. // SetTotal sets the "total" field.
  5916. func (m *BatchMsgMutation) SetTotal(i int32) {
  5917. m.total = &i
  5918. m.addtotal = nil
  5919. }
  5920. // Total returns the value of the "total" field in the mutation.
  5921. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5922. v := m.total
  5923. if v == nil {
  5924. return
  5925. }
  5926. return *v, true
  5927. }
  5928. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5929. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5931. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5932. if !m.op.Is(OpUpdateOne) {
  5933. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5934. }
  5935. if m.id == nil || m.oldValue == nil {
  5936. return v, errors.New("OldTotal requires an ID field in the mutation")
  5937. }
  5938. oldValue, err := m.oldValue(ctx)
  5939. if err != nil {
  5940. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5941. }
  5942. return oldValue.Total, nil
  5943. }
  5944. // AddTotal adds i to the "total" field.
  5945. func (m *BatchMsgMutation) AddTotal(i int32) {
  5946. if m.addtotal != nil {
  5947. *m.addtotal += i
  5948. } else {
  5949. m.addtotal = &i
  5950. }
  5951. }
  5952. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5953. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5954. v := m.addtotal
  5955. if v == nil {
  5956. return
  5957. }
  5958. return *v, true
  5959. }
  5960. // ClearTotal clears the value of the "total" field.
  5961. func (m *BatchMsgMutation) ClearTotal() {
  5962. m.total = nil
  5963. m.addtotal = nil
  5964. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5965. }
  5966. // TotalCleared returns if the "total" field was cleared in this mutation.
  5967. func (m *BatchMsgMutation) TotalCleared() bool {
  5968. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5969. return ok
  5970. }
  5971. // ResetTotal resets all changes to the "total" field.
  5972. func (m *BatchMsgMutation) ResetTotal() {
  5973. m.total = nil
  5974. m.addtotal = nil
  5975. delete(m.clearedFields, batchmsg.FieldTotal)
  5976. }
  5977. // SetSuccess sets the "success" field.
  5978. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5979. m.success = &i
  5980. m.addsuccess = nil
  5981. }
  5982. // Success returns the value of the "success" field in the mutation.
  5983. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5984. v := m.success
  5985. if v == nil {
  5986. return
  5987. }
  5988. return *v, true
  5989. }
  5990. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5991. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5993. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5994. if !m.op.Is(OpUpdateOne) {
  5995. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5996. }
  5997. if m.id == nil || m.oldValue == nil {
  5998. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5999. }
  6000. oldValue, err := m.oldValue(ctx)
  6001. if err != nil {
  6002. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  6003. }
  6004. return oldValue.Success, nil
  6005. }
  6006. // AddSuccess adds i to the "success" field.
  6007. func (m *BatchMsgMutation) AddSuccess(i int32) {
  6008. if m.addsuccess != nil {
  6009. *m.addsuccess += i
  6010. } else {
  6011. m.addsuccess = &i
  6012. }
  6013. }
  6014. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  6015. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  6016. v := m.addsuccess
  6017. if v == nil {
  6018. return
  6019. }
  6020. return *v, true
  6021. }
  6022. // ClearSuccess clears the value of the "success" field.
  6023. func (m *BatchMsgMutation) ClearSuccess() {
  6024. m.success = nil
  6025. m.addsuccess = nil
  6026. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  6027. }
  6028. // SuccessCleared returns if the "success" field was cleared in this mutation.
  6029. func (m *BatchMsgMutation) SuccessCleared() bool {
  6030. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  6031. return ok
  6032. }
  6033. // ResetSuccess resets all changes to the "success" field.
  6034. func (m *BatchMsgMutation) ResetSuccess() {
  6035. m.success = nil
  6036. m.addsuccess = nil
  6037. delete(m.clearedFields, batchmsg.FieldSuccess)
  6038. }
  6039. // SetFail sets the "fail" field.
  6040. func (m *BatchMsgMutation) SetFail(i int32) {
  6041. m.fail = &i
  6042. m.addfail = nil
  6043. }
  6044. // Fail returns the value of the "fail" field in the mutation.
  6045. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  6046. v := m.fail
  6047. if v == nil {
  6048. return
  6049. }
  6050. return *v, true
  6051. }
  6052. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  6053. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6055. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  6056. if !m.op.Is(OpUpdateOne) {
  6057. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  6058. }
  6059. if m.id == nil || m.oldValue == nil {
  6060. return v, errors.New("OldFail requires an ID field in the mutation")
  6061. }
  6062. oldValue, err := m.oldValue(ctx)
  6063. if err != nil {
  6064. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  6065. }
  6066. return oldValue.Fail, nil
  6067. }
  6068. // AddFail adds i to the "fail" field.
  6069. func (m *BatchMsgMutation) AddFail(i int32) {
  6070. if m.addfail != nil {
  6071. *m.addfail += i
  6072. } else {
  6073. m.addfail = &i
  6074. }
  6075. }
  6076. // AddedFail returns the value that was added to the "fail" field in this mutation.
  6077. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  6078. v := m.addfail
  6079. if v == nil {
  6080. return
  6081. }
  6082. return *v, true
  6083. }
  6084. // ClearFail clears the value of the "fail" field.
  6085. func (m *BatchMsgMutation) ClearFail() {
  6086. m.fail = nil
  6087. m.addfail = nil
  6088. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  6089. }
  6090. // FailCleared returns if the "fail" field was cleared in this mutation.
  6091. func (m *BatchMsgMutation) FailCleared() bool {
  6092. _, ok := m.clearedFields[batchmsg.FieldFail]
  6093. return ok
  6094. }
  6095. // ResetFail resets all changes to the "fail" field.
  6096. func (m *BatchMsgMutation) ResetFail() {
  6097. m.fail = nil
  6098. m.addfail = nil
  6099. delete(m.clearedFields, batchmsg.FieldFail)
  6100. }
  6101. // SetStartTime sets the "start_time" field.
  6102. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  6103. m.start_time = &t
  6104. }
  6105. // StartTime returns the value of the "start_time" field in the mutation.
  6106. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  6107. v := m.start_time
  6108. if v == nil {
  6109. return
  6110. }
  6111. return *v, true
  6112. }
  6113. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  6114. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6116. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  6117. if !m.op.Is(OpUpdateOne) {
  6118. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  6119. }
  6120. if m.id == nil || m.oldValue == nil {
  6121. return v, errors.New("OldStartTime requires an ID field in the mutation")
  6122. }
  6123. oldValue, err := m.oldValue(ctx)
  6124. if err != nil {
  6125. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  6126. }
  6127. return oldValue.StartTime, nil
  6128. }
  6129. // ClearStartTime clears the value of the "start_time" field.
  6130. func (m *BatchMsgMutation) ClearStartTime() {
  6131. m.start_time = nil
  6132. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  6133. }
  6134. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  6135. func (m *BatchMsgMutation) StartTimeCleared() bool {
  6136. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  6137. return ok
  6138. }
  6139. // ResetStartTime resets all changes to the "start_time" field.
  6140. func (m *BatchMsgMutation) ResetStartTime() {
  6141. m.start_time = nil
  6142. delete(m.clearedFields, batchmsg.FieldStartTime)
  6143. }
  6144. // SetStopTime sets the "stop_time" field.
  6145. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  6146. m.stop_time = &t
  6147. }
  6148. // StopTime returns the value of the "stop_time" field in the mutation.
  6149. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  6150. v := m.stop_time
  6151. if v == nil {
  6152. return
  6153. }
  6154. return *v, true
  6155. }
  6156. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  6157. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6159. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  6160. if !m.op.Is(OpUpdateOne) {
  6161. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  6162. }
  6163. if m.id == nil || m.oldValue == nil {
  6164. return v, errors.New("OldStopTime requires an ID field in the mutation")
  6165. }
  6166. oldValue, err := m.oldValue(ctx)
  6167. if err != nil {
  6168. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  6169. }
  6170. return oldValue.StopTime, nil
  6171. }
  6172. // ClearStopTime clears the value of the "stop_time" field.
  6173. func (m *BatchMsgMutation) ClearStopTime() {
  6174. m.stop_time = nil
  6175. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  6176. }
  6177. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  6178. func (m *BatchMsgMutation) StopTimeCleared() bool {
  6179. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  6180. return ok
  6181. }
  6182. // ResetStopTime resets all changes to the "stop_time" field.
  6183. func (m *BatchMsgMutation) ResetStopTime() {
  6184. m.stop_time = nil
  6185. delete(m.clearedFields, batchmsg.FieldStopTime)
  6186. }
  6187. // SetSendTime sets the "send_time" field.
  6188. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  6189. m.send_time = &t
  6190. }
  6191. // SendTime returns the value of the "send_time" field in the mutation.
  6192. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  6193. v := m.send_time
  6194. if v == nil {
  6195. return
  6196. }
  6197. return *v, true
  6198. }
  6199. // OldSendTime returns the old "send_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) OldSendTime(ctx context.Context) (v time.Time, err error) {
  6203. if !m.op.Is(OpUpdateOne) {
  6204. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  6205. }
  6206. if m.id == nil || m.oldValue == nil {
  6207. return v, errors.New("OldSendTime 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 OldSendTime: %w", err)
  6212. }
  6213. return oldValue.SendTime, nil
  6214. }
  6215. // ClearSendTime clears the value of the "send_time" field.
  6216. func (m *BatchMsgMutation) ClearSendTime() {
  6217. m.send_time = nil
  6218. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  6219. }
  6220. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  6221. func (m *BatchMsgMutation) SendTimeCleared() bool {
  6222. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  6223. return ok
  6224. }
  6225. // ResetSendTime resets all changes to the "send_time" field.
  6226. func (m *BatchMsgMutation) ResetSendTime() {
  6227. m.send_time = nil
  6228. delete(m.clearedFields, batchmsg.FieldSendTime)
  6229. }
  6230. // SetType sets the "type" field.
  6231. func (m *BatchMsgMutation) SetType(i int32) {
  6232. m._type = &i
  6233. m.add_type = nil
  6234. }
  6235. // GetType returns the value of the "type" field in the mutation.
  6236. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  6237. v := m._type
  6238. if v == nil {
  6239. return
  6240. }
  6241. return *v, true
  6242. }
  6243. // OldType returns the old "type" field's value of the BatchMsg entity.
  6244. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6246. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  6247. if !m.op.Is(OpUpdateOne) {
  6248. return v, errors.New("OldType is only allowed on UpdateOne operations")
  6249. }
  6250. if m.id == nil || m.oldValue == nil {
  6251. return v, errors.New("OldType requires an ID field in the mutation")
  6252. }
  6253. oldValue, err := m.oldValue(ctx)
  6254. if err != nil {
  6255. return v, fmt.Errorf("querying old value for OldType: %w", err)
  6256. }
  6257. return oldValue.Type, nil
  6258. }
  6259. // AddType adds i to the "type" field.
  6260. func (m *BatchMsgMutation) AddType(i int32) {
  6261. if m.add_type != nil {
  6262. *m.add_type += i
  6263. } else {
  6264. m.add_type = &i
  6265. }
  6266. }
  6267. // AddedType returns the value that was added to the "type" field in this mutation.
  6268. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  6269. v := m.add_type
  6270. if v == nil {
  6271. return
  6272. }
  6273. return *v, true
  6274. }
  6275. // ClearType clears the value of the "type" field.
  6276. func (m *BatchMsgMutation) ClearType() {
  6277. m._type = nil
  6278. m.add_type = nil
  6279. m.clearedFields[batchmsg.FieldType] = struct{}{}
  6280. }
  6281. // TypeCleared returns if the "type" field was cleared in this mutation.
  6282. func (m *BatchMsgMutation) TypeCleared() bool {
  6283. _, ok := m.clearedFields[batchmsg.FieldType]
  6284. return ok
  6285. }
  6286. // ResetType resets all changes to the "type" field.
  6287. func (m *BatchMsgMutation) ResetType() {
  6288. m._type = nil
  6289. m.add_type = nil
  6290. delete(m.clearedFields, batchmsg.FieldType)
  6291. }
  6292. // SetOrganizationID sets the "organization_id" field.
  6293. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  6294. m.organization_id = &u
  6295. m.addorganization_id = nil
  6296. }
  6297. // OrganizationID returns the value of the "organization_id" field in the mutation.
  6298. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  6299. v := m.organization_id
  6300. if v == nil {
  6301. return
  6302. }
  6303. return *v, true
  6304. }
  6305. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  6306. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6308. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  6309. if !m.op.Is(OpUpdateOne) {
  6310. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  6311. }
  6312. if m.id == nil || m.oldValue == nil {
  6313. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  6314. }
  6315. oldValue, err := m.oldValue(ctx)
  6316. if err != nil {
  6317. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  6318. }
  6319. return oldValue.OrganizationID, nil
  6320. }
  6321. // AddOrganizationID adds u to the "organization_id" field.
  6322. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6323. if m.addorganization_id != nil {
  6324. *m.addorganization_id += u
  6325. } else {
  6326. m.addorganization_id = &u
  6327. }
  6328. }
  6329. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6330. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6331. v := m.addorganization_id
  6332. if v == nil {
  6333. return
  6334. }
  6335. return *v, true
  6336. }
  6337. // ResetOrganizationID resets all changes to the "organization_id" field.
  6338. func (m *BatchMsgMutation) ResetOrganizationID() {
  6339. m.organization_id = nil
  6340. m.addorganization_id = nil
  6341. }
  6342. // SetCtype sets the "ctype" field.
  6343. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6344. m.ctype = &u
  6345. m.addctype = nil
  6346. }
  6347. // Ctype returns the value of the "ctype" field in the mutation.
  6348. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6349. v := m.ctype
  6350. if v == nil {
  6351. return
  6352. }
  6353. return *v, true
  6354. }
  6355. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6356. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6358. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6359. if !m.op.Is(OpUpdateOne) {
  6360. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6361. }
  6362. if m.id == nil || m.oldValue == nil {
  6363. return v, errors.New("OldCtype requires an ID field in the mutation")
  6364. }
  6365. oldValue, err := m.oldValue(ctx)
  6366. if err != nil {
  6367. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6368. }
  6369. return oldValue.Ctype, nil
  6370. }
  6371. // AddCtype adds u to the "ctype" field.
  6372. func (m *BatchMsgMutation) AddCtype(u int64) {
  6373. if m.addctype != nil {
  6374. *m.addctype += u
  6375. } else {
  6376. m.addctype = &u
  6377. }
  6378. }
  6379. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6380. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6381. v := m.addctype
  6382. if v == nil {
  6383. return
  6384. }
  6385. return *v, true
  6386. }
  6387. // ResetCtype resets all changes to the "ctype" field.
  6388. func (m *BatchMsgMutation) ResetCtype() {
  6389. m.ctype = nil
  6390. m.addctype = nil
  6391. }
  6392. // SetCc sets the "cc" field.
  6393. func (m *BatchMsgMutation) SetCc(s string) {
  6394. m.cc = &s
  6395. }
  6396. // Cc returns the value of the "cc" field in the mutation.
  6397. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6398. v := m.cc
  6399. if v == nil {
  6400. return
  6401. }
  6402. return *v, true
  6403. }
  6404. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6405. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6407. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6408. if !m.op.Is(OpUpdateOne) {
  6409. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6410. }
  6411. if m.id == nil || m.oldValue == nil {
  6412. return v, errors.New("OldCc requires an ID field in the mutation")
  6413. }
  6414. oldValue, err := m.oldValue(ctx)
  6415. if err != nil {
  6416. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6417. }
  6418. return oldValue.Cc, nil
  6419. }
  6420. // ClearCc clears the value of the "cc" field.
  6421. func (m *BatchMsgMutation) ClearCc() {
  6422. m.cc = nil
  6423. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6424. }
  6425. // CcCleared returns if the "cc" field was cleared in this mutation.
  6426. func (m *BatchMsgMutation) CcCleared() bool {
  6427. _, ok := m.clearedFields[batchmsg.FieldCc]
  6428. return ok
  6429. }
  6430. // ResetCc resets all changes to the "cc" field.
  6431. func (m *BatchMsgMutation) ResetCc() {
  6432. m.cc = nil
  6433. delete(m.clearedFields, batchmsg.FieldCc)
  6434. }
  6435. // SetPhone sets the "phone" field.
  6436. func (m *BatchMsgMutation) SetPhone(s string) {
  6437. m.phone = &s
  6438. }
  6439. // Phone returns the value of the "phone" field in the mutation.
  6440. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6441. v := m.phone
  6442. if v == nil {
  6443. return
  6444. }
  6445. return *v, true
  6446. }
  6447. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6448. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6450. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6451. if !m.op.Is(OpUpdateOne) {
  6452. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6453. }
  6454. if m.id == nil || m.oldValue == nil {
  6455. return v, errors.New("OldPhone requires an ID field in the mutation")
  6456. }
  6457. oldValue, err := m.oldValue(ctx)
  6458. if err != nil {
  6459. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6460. }
  6461. return oldValue.Phone, nil
  6462. }
  6463. // ClearPhone clears the value of the "phone" field.
  6464. func (m *BatchMsgMutation) ClearPhone() {
  6465. m.phone = nil
  6466. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6467. }
  6468. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6469. func (m *BatchMsgMutation) PhoneCleared() bool {
  6470. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6471. return ok
  6472. }
  6473. // ResetPhone resets all changes to the "phone" field.
  6474. func (m *BatchMsgMutation) ResetPhone() {
  6475. m.phone = nil
  6476. delete(m.clearedFields, batchmsg.FieldPhone)
  6477. }
  6478. // SetTemplateName sets the "template_name" field.
  6479. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6480. m.template_name = &s
  6481. }
  6482. // TemplateName returns the value of the "template_name" field in the mutation.
  6483. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6484. v := m.template_name
  6485. if v == nil {
  6486. return
  6487. }
  6488. return *v, true
  6489. }
  6490. // OldTemplateName returns the old "template_name" 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) OldTemplateName(ctx context.Context) (v string, err error) {
  6494. if !m.op.Is(OpUpdateOne) {
  6495. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6496. }
  6497. if m.id == nil || m.oldValue == nil {
  6498. return v, errors.New("OldTemplateName 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 OldTemplateName: %w", err)
  6503. }
  6504. return oldValue.TemplateName, nil
  6505. }
  6506. // ClearTemplateName clears the value of the "template_name" field.
  6507. func (m *BatchMsgMutation) ClearTemplateName() {
  6508. m.template_name = nil
  6509. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6510. }
  6511. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6512. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6513. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6514. return ok
  6515. }
  6516. // ResetTemplateName resets all changes to the "template_name" field.
  6517. func (m *BatchMsgMutation) ResetTemplateName() {
  6518. m.template_name = nil
  6519. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6520. }
  6521. // SetTemplateCode sets the "template_code" field.
  6522. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6523. m.template_code = &s
  6524. }
  6525. // TemplateCode returns the value of the "template_code" field in the mutation.
  6526. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6527. v := m.template_code
  6528. if v == nil {
  6529. return
  6530. }
  6531. return *v, true
  6532. }
  6533. // OldTemplateCode returns the old "template_code" 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) OldTemplateCode(ctx context.Context) (v string, err error) {
  6537. if !m.op.Is(OpUpdateOne) {
  6538. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6539. }
  6540. if m.id == nil || m.oldValue == nil {
  6541. return v, errors.New("OldTemplateCode 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 OldTemplateCode: %w", err)
  6546. }
  6547. return oldValue.TemplateCode, nil
  6548. }
  6549. // ClearTemplateCode clears the value of the "template_code" field.
  6550. func (m *BatchMsgMutation) ClearTemplateCode() {
  6551. m.template_code = nil
  6552. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6553. }
  6554. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6555. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6556. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6557. return ok
  6558. }
  6559. // ResetTemplateCode resets all changes to the "template_code" field.
  6560. func (m *BatchMsgMutation) ResetTemplateCode() {
  6561. m.template_code = nil
  6562. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6563. }
  6564. // SetLang sets the "lang" field.
  6565. func (m *BatchMsgMutation) SetLang(s string) {
  6566. m.lang = &s
  6567. }
  6568. // Lang returns the value of the "lang" field in the mutation.
  6569. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6570. v := m.lang
  6571. if v == nil {
  6572. return
  6573. }
  6574. return *v, true
  6575. }
  6576. // OldLang returns the old "lang" 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) OldLang(ctx context.Context) (v string, err error) {
  6580. if !m.op.Is(OpUpdateOne) {
  6581. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6582. }
  6583. if m.id == nil || m.oldValue == nil {
  6584. return v, errors.New("OldLang 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 OldLang: %w", err)
  6589. }
  6590. return oldValue.Lang, nil
  6591. }
  6592. // ClearLang clears the value of the "lang" field.
  6593. func (m *BatchMsgMutation) ClearLang() {
  6594. m.lang = nil
  6595. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6596. }
  6597. // LangCleared returns if the "lang" field was cleared in this mutation.
  6598. func (m *BatchMsgMutation) LangCleared() bool {
  6599. _, ok := m.clearedFields[batchmsg.FieldLang]
  6600. return ok
  6601. }
  6602. // ResetLang resets all changes to the "lang" field.
  6603. func (m *BatchMsgMutation) ResetLang() {
  6604. m.lang = nil
  6605. delete(m.clearedFields, batchmsg.FieldLang)
  6606. }
  6607. // Where appends a list predicates to the BatchMsgMutation builder.
  6608. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6609. m.predicates = append(m.predicates, ps...)
  6610. }
  6611. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6612. // users can use type-assertion to append predicates that do not depend on any generated package.
  6613. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6614. p := make([]predicate.BatchMsg, len(ps))
  6615. for i := range ps {
  6616. p[i] = ps[i]
  6617. }
  6618. m.Where(p...)
  6619. }
  6620. // Op returns the operation name.
  6621. func (m *BatchMsgMutation) Op() Op {
  6622. return m.op
  6623. }
  6624. // SetOp allows setting the mutation operation.
  6625. func (m *BatchMsgMutation) SetOp(op Op) {
  6626. m.op = op
  6627. }
  6628. // Type returns the node type of this mutation (BatchMsg).
  6629. func (m *BatchMsgMutation) Type() string {
  6630. return m.typ
  6631. }
  6632. // Fields returns all fields that were changed during this mutation. Note that in
  6633. // order to get all numeric fields that were incremented/decremented, call
  6634. // AddedFields().
  6635. func (m *BatchMsgMutation) Fields() []string {
  6636. fields := make([]string, 0, 24)
  6637. if m.created_at != nil {
  6638. fields = append(fields, batchmsg.FieldCreatedAt)
  6639. }
  6640. if m.updated_at != nil {
  6641. fields = append(fields, batchmsg.FieldUpdatedAt)
  6642. }
  6643. if m.deleted_at != nil {
  6644. fields = append(fields, batchmsg.FieldDeletedAt)
  6645. }
  6646. if m.status != nil {
  6647. fields = append(fields, batchmsg.FieldStatus)
  6648. }
  6649. if m.batch_no != nil {
  6650. fields = append(fields, batchmsg.FieldBatchNo)
  6651. }
  6652. if m.task_name != nil {
  6653. fields = append(fields, batchmsg.FieldTaskName)
  6654. }
  6655. if m.fromwxid != nil {
  6656. fields = append(fields, batchmsg.FieldFromwxid)
  6657. }
  6658. if m.msg != nil {
  6659. fields = append(fields, batchmsg.FieldMsg)
  6660. }
  6661. if m.tag != nil {
  6662. fields = append(fields, batchmsg.FieldTag)
  6663. }
  6664. if m.tagids != nil {
  6665. fields = append(fields, batchmsg.FieldTagids)
  6666. }
  6667. if m.total != nil {
  6668. fields = append(fields, batchmsg.FieldTotal)
  6669. }
  6670. if m.success != nil {
  6671. fields = append(fields, batchmsg.FieldSuccess)
  6672. }
  6673. if m.fail != nil {
  6674. fields = append(fields, batchmsg.FieldFail)
  6675. }
  6676. if m.start_time != nil {
  6677. fields = append(fields, batchmsg.FieldStartTime)
  6678. }
  6679. if m.stop_time != nil {
  6680. fields = append(fields, batchmsg.FieldStopTime)
  6681. }
  6682. if m.send_time != nil {
  6683. fields = append(fields, batchmsg.FieldSendTime)
  6684. }
  6685. if m._type != nil {
  6686. fields = append(fields, batchmsg.FieldType)
  6687. }
  6688. if m.organization_id != nil {
  6689. fields = append(fields, batchmsg.FieldOrganizationID)
  6690. }
  6691. if m.ctype != nil {
  6692. fields = append(fields, batchmsg.FieldCtype)
  6693. }
  6694. if m.cc != nil {
  6695. fields = append(fields, batchmsg.FieldCc)
  6696. }
  6697. if m.phone != nil {
  6698. fields = append(fields, batchmsg.FieldPhone)
  6699. }
  6700. if m.template_name != nil {
  6701. fields = append(fields, batchmsg.FieldTemplateName)
  6702. }
  6703. if m.template_code != nil {
  6704. fields = append(fields, batchmsg.FieldTemplateCode)
  6705. }
  6706. if m.lang != nil {
  6707. fields = append(fields, batchmsg.FieldLang)
  6708. }
  6709. return fields
  6710. }
  6711. // Field returns the value of a field with the given name. The second boolean
  6712. // return value indicates that this field was not set, or was not defined in the
  6713. // schema.
  6714. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6715. switch name {
  6716. case batchmsg.FieldCreatedAt:
  6717. return m.CreatedAt()
  6718. case batchmsg.FieldUpdatedAt:
  6719. return m.UpdatedAt()
  6720. case batchmsg.FieldDeletedAt:
  6721. return m.DeletedAt()
  6722. case batchmsg.FieldStatus:
  6723. return m.Status()
  6724. case batchmsg.FieldBatchNo:
  6725. return m.BatchNo()
  6726. case batchmsg.FieldTaskName:
  6727. return m.TaskName()
  6728. case batchmsg.FieldFromwxid:
  6729. return m.Fromwxid()
  6730. case batchmsg.FieldMsg:
  6731. return m.Msg()
  6732. case batchmsg.FieldTag:
  6733. return m.Tag()
  6734. case batchmsg.FieldTagids:
  6735. return m.Tagids()
  6736. case batchmsg.FieldTotal:
  6737. return m.Total()
  6738. case batchmsg.FieldSuccess:
  6739. return m.Success()
  6740. case batchmsg.FieldFail:
  6741. return m.Fail()
  6742. case batchmsg.FieldStartTime:
  6743. return m.StartTime()
  6744. case batchmsg.FieldStopTime:
  6745. return m.StopTime()
  6746. case batchmsg.FieldSendTime:
  6747. return m.SendTime()
  6748. case batchmsg.FieldType:
  6749. return m.GetType()
  6750. case batchmsg.FieldOrganizationID:
  6751. return m.OrganizationID()
  6752. case batchmsg.FieldCtype:
  6753. return m.Ctype()
  6754. case batchmsg.FieldCc:
  6755. return m.Cc()
  6756. case batchmsg.FieldPhone:
  6757. return m.Phone()
  6758. case batchmsg.FieldTemplateName:
  6759. return m.TemplateName()
  6760. case batchmsg.FieldTemplateCode:
  6761. return m.TemplateCode()
  6762. case batchmsg.FieldLang:
  6763. return m.Lang()
  6764. }
  6765. return nil, false
  6766. }
  6767. // OldField returns the old value of the field from the database. An error is
  6768. // returned if the mutation operation is not UpdateOne, or the query to the
  6769. // database failed.
  6770. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6771. switch name {
  6772. case batchmsg.FieldCreatedAt:
  6773. return m.OldCreatedAt(ctx)
  6774. case batchmsg.FieldUpdatedAt:
  6775. return m.OldUpdatedAt(ctx)
  6776. case batchmsg.FieldDeletedAt:
  6777. return m.OldDeletedAt(ctx)
  6778. case batchmsg.FieldStatus:
  6779. return m.OldStatus(ctx)
  6780. case batchmsg.FieldBatchNo:
  6781. return m.OldBatchNo(ctx)
  6782. case batchmsg.FieldTaskName:
  6783. return m.OldTaskName(ctx)
  6784. case batchmsg.FieldFromwxid:
  6785. return m.OldFromwxid(ctx)
  6786. case batchmsg.FieldMsg:
  6787. return m.OldMsg(ctx)
  6788. case batchmsg.FieldTag:
  6789. return m.OldTag(ctx)
  6790. case batchmsg.FieldTagids:
  6791. return m.OldTagids(ctx)
  6792. case batchmsg.FieldTotal:
  6793. return m.OldTotal(ctx)
  6794. case batchmsg.FieldSuccess:
  6795. return m.OldSuccess(ctx)
  6796. case batchmsg.FieldFail:
  6797. return m.OldFail(ctx)
  6798. case batchmsg.FieldStartTime:
  6799. return m.OldStartTime(ctx)
  6800. case batchmsg.FieldStopTime:
  6801. return m.OldStopTime(ctx)
  6802. case batchmsg.FieldSendTime:
  6803. return m.OldSendTime(ctx)
  6804. case batchmsg.FieldType:
  6805. return m.OldType(ctx)
  6806. case batchmsg.FieldOrganizationID:
  6807. return m.OldOrganizationID(ctx)
  6808. case batchmsg.FieldCtype:
  6809. return m.OldCtype(ctx)
  6810. case batchmsg.FieldCc:
  6811. return m.OldCc(ctx)
  6812. case batchmsg.FieldPhone:
  6813. return m.OldPhone(ctx)
  6814. case batchmsg.FieldTemplateName:
  6815. return m.OldTemplateName(ctx)
  6816. case batchmsg.FieldTemplateCode:
  6817. return m.OldTemplateCode(ctx)
  6818. case batchmsg.FieldLang:
  6819. return m.OldLang(ctx)
  6820. }
  6821. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6822. }
  6823. // SetField sets the value of a field with the given name. It returns an error if
  6824. // the field is not defined in the schema, or if the type mismatched the field
  6825. // type.
  6826. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6827. switch name {
  6828. case batchmsg.FieldCreatedAt:
  6829. v, ok := value.(time.Time)
  6830. if !ok {
  6831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6832. }
  6833. m.SetCreatedAt(v)
  6834. return nil
  6835. case batchmsg.FieldUpdatedAt:
  6836. v, ok := value.(time.Time)
  6837. if !ok {
  6838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6839. }
  6840. m.SetUpdatedAt(v)
  6841. return nil
  6842. case batchmsg.FieldDeletedAt:
  6843. v, ok := value.(time.Time)
  6844. if !ok {
  6845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6846. }
  6847. m.SetDeletedAt(v)
  6848. return nil
  6849. case batchmsg.FieldStatus:
  6850. v, ok := value.(uint8)
  6851. if !ok {
  6852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6853. }
  6854. m.SetStatus(v)
  6855. return nil
  6856. case batchmsg.FieldBatchNo:
  6857. v, ok := value.(string)
  6858. if !ok {
  6859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6860. }
  6861. m.SetBatchNo(v)
  6862. return nil
  6863. case batchmsg.FieldTaskName:
  6864. v, ok := value.(string)
  6865. if !ok {
  6866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6867. }
  6868. m.SetTaskName(v)
  6869. return nil
  6870. case batchmsg.FieldFromwxid:
  6871. v, ok := value.(string)
  6872. if !ok {
  6873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6874. }
  6875. m.SetFromwxid(v)
  6876. return nil
  6877. case batchmsg.FieldMsg:
  6878. v, ok := value.(string)
  6879. if !ok {
  6880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6881. }
  6882. m.SetMsg(v)
  6883. return nil
  6884. case batchmsg.FieldTag:
  6885. v, ok := value.(string)
  6886. if !ok {
  6887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6888. }
  6889. m.SetTag(v)
  6890. return nil
  6891. case batchmsg.FieldTagids:
  6892. v, ok := value.(string)
  6893. if !ok {
  6894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6895. }
  6896. m.SetTagids(v)
  6897. return nil
  6898. case batchmsg.FieldTotal:
  6899. v, ok := value.(int32)
  6900. if !ok {
  6901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6902. }
  6903. m.SetTotal(v)
  6904. return nil
  6905. case batchmsg.FieldSuccess:
  6906. v, ok := value.(int32)
  6907. if !ok {
  6908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6909. }
  6910. m.SetSuccess(v)
  6911. return nil
  6912. case batchmsg.FieldFail:
  6913. v, ok := value.(int32)
  6914. if !ok {
  6915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6916. }
  6917. m.SetFail(v)
  6918. return nil
  6919. case batchmsg.FieldStartTime:
  6920. v, ok := value.(time.Time)
  6921. if !ok {
  6922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6923. }
  6924. m.SetStartTime(v)
  6925. return nil
  6926. case batchmsg.FieldStopTime:
  6927. v, ok := value.(time.Time)
  6928. if !ok {
  6929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6930. }
  6931. m.SetStopTime(v)
  6932. return nil
  6933. case batchmsg.FieldSendTime:
  6934. v, ok := value.(time.Time)
  6935. if !ok {
  6936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6937. }
  6938. m.SetSendTime(v)
  6939. return nil
  6940. case batchmsg.FieldType:
  6941. v, ok := value.(int32)
  6942. if !ok {
  6943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6944. }
  6945. m.SetType(v)
  6946. return nil
  6947. case batchmsg.FieldOrganizationID:
  6948. v, ok := value.(uint64)
  6949. if !ok {
  6950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6951. }
  6952. m.SetOrganizationID(v)
  6953. return nil
  6954. case batchmsg.FieldCtype:
  6955. v, ok := value.(uint64)
  6956. if !ok {
  6957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6958. }
  6959. m.SetCtype(v)
  6960. return nil
  6961. case batchmsg.FieldCc:
  6962. v, ok := value.(string)
  6963. if !ok {
  6964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6965. }
  6966. m.SetCc(v)
  6967. return nil
  6968. case batchmsg.FieldPhone:
  6969. v, ok := value.(string)
  6970. if !ok {
  6971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6972. }
  6973. m.SetPhone(v)
  6974. return nil
  6975. case batchmsg.FieldTemplateName:
  6976. v, ok := value.(string)
  6977. if !ok {
  6978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6979. }
  6980. m.SetTemplateName(v)
  6981. return nil
  6982. case batchmsg.FieldTemplateCode:
  6983. v, ok := value.(string)
  6984. if !ok {
  6985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6986. }
  6987. m.SetTemplateCode(v)
  6988. return nil
  6989. case batchmsg.FieldLang:
  6990. v, ok := value.(string)
  6991. if !ok {
  6992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6993. }
  6994. m.SetLang(v)
  6995. return nil
  6996. }
  6997. return fmt.Errorf("unknown BatchMsg field %s", name)
  6998. }
  6999. // AddedFields returns all numeric fields that were incremented/decremented during
  7000. // this mutation.
  7001. func (m *BatchMsgMutation) AddedFields() []string {
  7002. var fields []string
  7003. if m.addstatus != nil {
  7004. fields = append(fields, batchmsg.FieldStatus)
  7005. }
  7006. if m.addtotal != nil {
  7007. fields = append(fields, batchmsg.FieldTotal)
  7008. }
  7009. if m.addsuccess != nil {
  7010. fields = append(fields, batchmsg.FieldSuccess)
  7011. }
  7012. if m.addfail != nil {
  7013. fields = append(fields, batchmsg.FieldFail)
  7014. }
  7015. if m.add_type != nil {
  7016. fields = append(fields, batchmsg.FieldType)
  7017. }
  7018. if m.addorganization_id != nil {
  7019. fields = append(fields, batchmsg.FieldOrganizationID)
  7020. }
  7021. if m.addctype != nil {
  7022. fields = append(fields, batchmsg.FieldCtype)
  7023. }
  7024. return fields
  7025. }
  7026. // AddedField returns the numeric value that was incremented/decremented on a field
  7027. // with the given name. The second boolean return value indicates that this field
  7028. // was not set, or was not defined in the schema.
  7029. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  7030. switch name {
  7031. case batchmsg.FieldStatus:
  7032. return m.AddedStatus()
  7033. case batchmsg.FieldTotal:
  7034. return m.AddedTotal()
  7035. case batchmsg.FieldSuccess:
  7036. return m.AddedSuccess()
  7037. case batchmsg.FieldFail:
  7038. return m.AddedFail()
  7039. case batchmsg.FieldType:
  7040. return m.AddedType()
  7041. case batchmsg.FieldOrganizationID:
  7042. return m.AddedOrganizationID()
  7043. case batchmsg.FieldCtype:
  7044. return m.AddedCtype()
  7045. }
  7046. return nil, false
  7047. }
  7048. // AddField adds the value to the field with the given name. It returns an error if
  7049. // the field is not defined in the schema, or if the type mismatched the field
  7050. // type.
  7051. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  7052. switch name {
  7053. case batchmsg.FieldStatus:
  7054. v, ok := value.(int8)
  7055. if !ok {
  7056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7057. }
  7058. m.AddStatus(v)
  7059. return nil
  7060. case batchmsg.FieldTotal:
  7061. v, ok := value.(int32)
  7062. if !ok {
  7063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7064. }
  7065. m.AddTotal(v)
  7066. return nil
  7067. case batchmsg.FieldSuccess:
  7068. v, ok := value.(int32)
  7069. if !ok {
  7070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7071. }
  7072. m.AddSuccess(v)
  7073. return nil
  7074. case batchmsg.FieldFail:
  7075. v, ok := value.(int32)
  7076. if !ok {
  7077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7078. }
  7079. m.AddFail(v)
  7080. return nil
  7081. case batchmsg.FieldType:
  7082. v, ok := value.(int32)
  7083. if !ok {
  7084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7085. }
  7086. m.AddType(v)
  7087. return nil
  7088. case batchmsg.FieldOrganizationID:
  7089. v, ok := value.(int64)
  7090. if !ok {
  7091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7092. }
  7093. m.AddOrganizationID(v)
  7094. return nil
  7095. case batchmsg.FieldCtype:
  7096. v, ok := value.(int64)
  7097. if !ok {
  7098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7099. }
  7100. m.AddCtype(v)
  7101. return nil
  7102. }
  7103. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  7104. }
  7105. // ClearedFields returns all nullable fields that were cleared during this
  7106. // mutation.
  7107. func (m *BatchMsgMutation) ClearedFields() []string {
  7108. var fields []string
  7109. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  7110. fields = append(fields, batchmsg.FieldDeletedAt)
  7111. }
  7112. if m.FieldCleared(batchmsg.FieldStatus) {
  7113. fields = append(fields, batchmsg.FieldStatus)
  7114. }
  7115. if m.FieldCleared(batchmsg.FieldBatchNo) {
  7116. fields = append(fields, batchmsg.FieldBatchNo)
  7117. }
  7118. if m.FieldCleared(batchmsg.FieldTaskName) {
  7119. fields = append(fields, batchmsg.FieldTaskName)
  7120. }
  7121. if m.FieldCleared(batchmsg.FieldFromwxid) {
  7122. fields = append(fields, batchmsg.FieldFromwxid)
  7123. }
  7124. if m.FieldCleared(batchmsg.FieldMsg) {
  7125. fields = append(fields, batchmsg.FieldMsg)
  7126. }
  7127. if m.FieldCleared(batchmsg.FieldTag) {
  7128. fields = append(fields, batchmsg.FieldTag)
  7129. }
  7130. if m.FieldCleared(batchmsg.FieldTagids) {
  7131. fields = append(fields, batchmsg.FieldTagids)
  7132. }
  7133. if m.FieldCleared(batchmsg.FieldTotal) {
  7134. fields = append(fields, batchmsg.FieldTotal)
  7135. }
  7136. if m.FieldCleared(batchmsg.FieldSuccess) {
  7137. fields = append(fields, batchmsg.FieldSuccess)
  7138. }
  7139. if m.FieldCleared(batchmsg.FieldFail) {
  7140. fields = append(fields, batchmsg.FieldFail)
  7141. }
  7142. if m.FieldCleared(batchmsg.FieldStartTime) {
  7143. fields = append(fields, batchmsg.FieldStartTime)
  7144. }
  7145. if m.FieldCleared(batchmsg.FieldStopTime) {
  7146. fields = append(fields, batchmsg.FieldStopTime)
  7147. }
  7148. if m.FieldCleared(batchmsg.FieldSendTime) {
  7149. fields = append(fields, batchmsg.FieldSendTime)
  7150. }
  7151. if m.FieldCleared(batchmsg.FieldType) {
  7152. fields = append(fields, batchmsg.FieldType)
  7153. }
  7154. if m.FieldCleared(batchmsg.FieldCc) {
  7155. fields = append(fields, batchmsg.FieldCc)
  7156. }
  7157. if m.FieldCleared(batchmsg.FieldPhone) {
  7158. fields = append(fields, batchmsg.FieldPhone)
  7159. }
  7160. if m.FieldCleared(batchmsg.FieldTemplateName) {
  7161. fields = append(fields, batchmsg.FieldTemplateName)
  7162. }
  7163. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  7164. fields = append(fields, batchmsg.FieldTemplateCode)
  7165. }
  7166. if m.FieldCleared(batchmsg.FieldLang) {
  7167. fields = append(fields, batchmsg.FieldLang)
  7168. }
  7169. return fields
  7170. }
  7171. // FieldCleared returns a boolean indicating if a field with the given name was
  7172. // cleared in this mutation.
  7173. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  7174. _, ok := m.clearedFields[name]
  7175. return ok
  7176. }
  7177. // ClearField clears the value of the field with the given name. It returns an
  7178. // error if the field is not defined in the schema.
  7179. func (m *BatchMsgMutation) ClearField(name string) error {
  7180. switch name {
  7181. case batchmsg.FieldDeletedAt:
  7182. m.ClearDeletedAt()
  7183. return nil
  7184. case batchmsg.FieldStatus:
  7185. m.ClearStatus()
  7186. return nil
  7187. case batchmsg.FieldBatchNo:
  7188. m.ClearBatchNo()
  7189. return nil
  7190. case batchmsg.FieldTaskName:
  7191. m.ClearTaskName()
  7192. return nil
  7193. case batchmsg.FieldFromwxid:
  7194. m.ClearFromwxid()
  7195. return nil
  7196. case batchmsg.FieldMsg:
  7197. m.ClearMsg()
  7198. return nil
  7199. case batchmsg.FieldTag:
  7200. m.ClearTag()
  7201. return nil
  7202. case batchmsg.FieldTagids:
  7203. m.ClearTagids()
  7204. return nil
  7205. case batchmsg.FieldTotal:
  7206. m.ClearTotal()
  7207. return nil
  7208. case batchmsg.FieldSuccess:
  7209. m.ClearSuccess()
  7210. return nil
  7211. case batchmsg.FieldFail:
  7212. m.ClearFail()
  7213. return nil
  7214. case batchmsg.FieldStartTime:
  7215. m.ClearStartTime()
  7216. return nil
  7217. case batchmsg.FieldStopTime:
  7218. m.ClearStopTime()
  7219. return nil
  7220. case batchmsg.FieldSendTime:
  7221. m.ClearSendTime()
  7222. return nil
  7223. case batchmsg.FieldType:
  7224. m.ClearType()
  7225. return nil
  7226. case batchmsg.FieldCc:
  7227. m.ClearCc()
  7228. return nil
  7229. case batchmsg.FieldPhone:
  7230. m.ClearPhone()
  7231. return nil
  7232. case batchmsg.FieldTemplateName:
  7233. m.ClearTemplateName()
  7234. return nil
  7235. case batchmsg.FieldTemplateCode:
  7236. m.ClearTemplateCode()
  7237. return nil
  7238. case batchmsg.FieldLang:
  7239. m.ClearLang()
  7240. return nil
  7241. }
  7242. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  7243. }
  7244. // ResetField resets all changes in the mutation for the field with the given name.
  7245. // It returns an error if the field is not defined in the schema.
  7246. func (m *BatchMsgMutation) ResetField(name string) error {
  7247. switch name {
  7248. case batchmsg.FieldCreatedAt:
  7249. m.ResetCreatedAt()
  7250. return nil
  7251. case batchmsg.FieldUpdatedAt:
  7252. m.ResetUpdatedAt()
  7253. return nil
  7254. case batchmsg.FieldDeletedAt:
  7255. m.ResetDeletedAt()
  7256. return nil
  7257. case batchmsg.FieldStatus:
  7258. m.ResetStatus()
  7259. return nil
  7260. case batchmsg.FieldBatchNo:
  7261. m.ResetBatchNo()
  7262. return nil
  7263. case batchmsg.FieldTaskName:
  7264. m.ResetTaskName()
  7265. return nil
  7266. case batchmsg.FieldFromwxid:
  7267. m.ResetFromwxid()
  7268. return nil
  7269. case batchmsg.FieldMsg:
  7270. m.ResetMsg()
  7271. return nil
  7272. case batchmsg.FieldTag:
  7273. m.ResetTag()
  7274. return nil
  7275. case batchmsg.FieldTagids:
  7276. m.ResetTagids()
  7277. return nil
  7278. case batchmsg.FieldTotal:
  7279. m.ResetTotal()
  7280. return nil
  7281. case batchmsg.FieldSuccess:
  7282. m.ResetSuccess()
  7283. return nil
  7284. case batchmsg.FieldFail:
  7285. m.ResetFail()
  7286. return nil
  7287. case batchmsg.FieldStartTime:
  7288. m.ResetStartTime()
  7289. return nil
  7290. case batchmsg.FieldStopTime:
  7291. m.ResetStopTime()
  7292. return nil
  7293. case batchmsg.FieldSendTime:
  7294. m.ResetSendTime()
  7295. return nil
  7296. case batchmsg.FieldType:
  7297. m.ResetType()
  7298. return nil
  7299. case batchmsg.FieldOrganizationID:
  7300. m.ResetOrganizationID()
  7301. return nil
  7302. case batchmsg.FieldCtype:
  7303. m.ResetCtype()
  7304. return nil
  7305. case batchmsg.FieldCc:
  7306. m.ResetCc()
  7307. return nil
  7308. case batchmsg.FieldPhone:
  7309. m.ResetPhone()
  7310. return nil
  7311. case batchmsg.FieldTemplateName:
  7312. m.ResetTemplateName()
  7313. return nil
  7314. case batchmsg.FieldTemplateCode:
  7315. m.ResetTemplateCode()
  7316. return nil
  7317. case batchmsg.FieldLang:
  7318. m.ResetLang()
  7319. return nil
  7320. }
  7321. return fmt.Errorf("unknown BatchMsg field %s", name)
  7322. }
  7323. // AddedEdges returns all edge names that were set/added in this mutation.
  7324. func (m *BatchMsgMutation) AddedEdges() []string {
  7325. edges := make([]string, 0, 0)
  7326. return edges
  7327. }
  7328. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7329. // name in this mutation.
  7330. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7331. return nil
  7332. }
  7333. // RemovedEdges returns all edge names that were removed in this mutation.
  7334. func (m *BatchMsgMutation) RemovedEdges() []string {
  7335. edges := make([]string, 0, 0)
  7336. return edges
  7337. }
  7338. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7339. // the given name in this mutation.
  7340. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7341. return nil
  7342. }
  7343. // ClearedEdges returns all edge names that were cleared in this mutation.
  7344. func (m *BatchMsgMutation) ClearedEdges() []string {
  7345. edges := make([]string, 0, 0)
  7346. return edges
  7347. }
  7348. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7349. // was cleared in this mutation.
  7350. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7351. return false
  7352. }
  7353. // ClearEdge clears the value of the edge with the given name. It returns an error
  7354. // if that edge is not defined in the schema.
  7355. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7356. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7357. }
  7358. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7359. // It returns an error if the edge is not defined in the schema.
  7360. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7361. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7362. }
  7363. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7364. type CategoryMutation struct {
  7365. config
  7366. op Op
  7367. typ string
  7368. id *uint64
  7369. created_at *time.Time
  7370. updated_at *time.Time
  7371. deleted_at *time.Time
  7372. name *string
  7373. organization_id *uint64
  7374. addorganization_id *int64
  7375. clearedFields map[string]struct{}
  7376. done bool
  7377. oldValue func(context.Context) (*Category, error)
  7378. predicates []predicate.Category
  7379. }
  7380. var _ ent.Mutation = (*CategoryMutation)(nil)
  7381. // categoryOption allows management of the mutation configuration using functional options.
  7382. type categoryOption func(*CategoryMutation)
  7383. // newCategoryMutation creates new mutation for the Category entity.
  7384. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7385. m := &CategoryMutation{
  7386. config: c,
  7387. op: op,
  7388. typ: TypeCategory,
  7389. clearedFields: make(map[string]struct{}),
  7390. }
  7391. for _, opt := range opts {
  7392. opt(m)
  7393. }
  7394. return m
  7395. }
  7396. // withCategoryID sets the ID field of the mutation.
  7397. func withCategoryID(id uint64) categoryOption {
  7398. return func(m *CategoryMutation) {
  7399. var (
  7400. err error
  7401. once sync.Once
  7402. value *Category
  7403. )
  7404. m.oldValue = func(ctx context.Context) (*Category, error) {
  7405. once.Do(func() {
  7406. if m.done {
  7407. err = errors.New("querying old values post mutation is not allowed")
  7408. } else {
  7409. value, err = m.Client().Category.Get(ctx, id)
  7410. }
  7411. })
  7412. return value, err
  7413. }
  7414. m.id = &id
  7415. }
  7416. }
  7417. // withCategory sets the old Category of the mutation.
  7418. func withCategory(node *Category) categoryOption {
  7419. return func(m *CategoryMutation) {
  7420. m.oldValue = func(context.Context) (*Category, error) {
  7421. return node, nil
  7422. }
  7423. m.id = &node.ID
  7424. }
  7425. }
  7426. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7427. // executed in a transaction (ent.Tx), a transactional client is returned.
  7428. func (m CategoryMutation) Client() *Client {
  7429. client := &Client{config: m.config}
  7430. client.init()
  7431. return client
  7432. }
  7433. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7434. // it returns an error otherwise.
  7435. func (m CategoryMutation) Tx() (*Tx, error) {
  7436. if _, ok := m.driver.(*txDriver); !ok {
  7437. return nil, errors.New("ent: mutation is not running in a transaction")
  7438. }
  7439. tx := &Tx{config: m.config}
  7440. tx.init()
  7441. return tx, nil
  7442. }
  7443. // SetID sets the value of the id field. Note that this
  7444. // operation is only accepted on creation of Category entities.
  7445. func (m *CategoryMutation) SetID(id uint64) {
  7446. m.id = &id
  7447. }
  7448. // ID returns the ID value in the mutation. Note that the ID is only available
  7449. // if it was provided to the builder or after it was returned from the database.
  7450. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7451. if m.id == nil {
  7452. return
  7453. }
  7454. return *m.id, true
  7455. }
  7456. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7457. // That means, if the mutation is applied within a transaction with an isolation level such
  7458. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7459. // or updated by the mutation.
  7460. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7461. switch {
  7462. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7463. id, exists := m.ID()
  7464. if exists {
  7465. return []uint64{id}, nil
  7466. }
  7467. fallthrough
  7468. case m.op.Is(OpUpdate | OpDelete):
  7469. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7470. default:
  7471. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7472. }
  7473. }
  7474. // SetCreatedAt sets the "created_at" field.
  7475. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7476. m.created_at = &t
  7477. }
  7478. // CreatedAt returns the value of the "created_at" field in the mutation.
  7479. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7480. v := m.created_at
  7481. if v == nil {
  7482. return
  7483. }
  7484. return *v, true
  7485. }
  7486. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7487. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7489. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7490. if !m.op.Is(OpUpdateOne) {
  7491. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7492. }
  7493. if m.id == nil || m.oldValue == nil {
  7494. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7495. }
  7496. oldValue, err := m.oldValue(ctx)
  7497. if err != nil {
  7498. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7499. }
  7500. return oldValue.CreatedAt, nil
  7501. }
  7502. // ResetCreatedAt resets all changes to the "created_at" field.
  7503. func (m *CategoryMutation) ResetCreatedAt() {
  7504. m.created_at = nil
  7505. }
  7506. // SetUpdatedAt sets the "updated_at" field.
  7507. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7508. m.updated_at = &t
  7509. }
  7510. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7511. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7512. v := m.updated_at
  7513. if v == nil {
  7514. return
  7515. }
  7516. return *v, true
  7517. }
  7518. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7519. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7521. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7522. if !m.op.Is(OpUpdateOne) {
  7523. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7524. }
  7525. if m.id == nil || m.oldValue == nil {
  7526. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7527. }
  7528. oldValue, err := m.oldValue(ctx)
  7529. if err != nil {
  7530. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7531. }
  7532. return oldValue.UpdatedAt, nil
  7533. }
  7534. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7535. func (m *CategoryMutation) ResetUpdatedAt() {
  7536. m.updated_at = nil
  7537. }
  7538. // SetDeletedAt sets the "deleted_at" field.
  7539. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7540. m.deleted_at = &t
  7541. }
  7542. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7543. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7544. v := m.deleted_at
  7545. if v == nil {
  7546. return
  7547. }
  7548. return *v, true
  7549. }
  7550. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7551. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7553. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7554. if !m.op.Is(OpUpdateOne) {
  7555. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7556. }
  7557. if m.id == nil || m.oldValue == nil {
  7558. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7559. }
  7560. oldValue, err := m.oldValue(ctx)
  7561. if err != nil {
  7562. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7563. }
  7564. return oldValue.DeletedAt, nil
  7565. }
  7566. // ClearDeletedAt clears the value of the "deleted_at" field.
  7567. func (m *CategoryMutation) ClearDeletedAt() {
  7568. m.deleted_at = nil
  7569. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7570. }
  7571. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7572. func (m *CategoryMutation) DeletedAtCleared() bool {
  7573. _, ok := m.clearedFields[category.FieldDeletedAt]
  7574. return ok
  7575. }
  7576. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7577. func (m *CategoryMutation) ResetDeletedAt() {
  7578. m.deleted_at = nil
  7579. delete(m.clearedFields, category.FieldDeletedAt)
  7580. }
  7581. // SetName sets the "name" field.
  7582. func (m *CategoryMutation) SetName(s string) {
  7583. m.name = &s
  7584. }
  7585. // Name returns the value of the "name" field in the mutation.
  7586. func (m *CategoryMutation) Name() (r string, exists bool) {
  7587. v := m.name
  7588. if v == nil {
  7589. return
  7590. }
  7591. return *v, true
  7592. }
  7593. // OldName returns the old "name" field's value of the Category entity.
  7594. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7596. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7597. if !m.op.Is(OpUpdateOne) {
  7598. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7599. }
  7600. if m.id == nil || m.oldValue == nil {
  7601. return v, errors.New("OldName requires an ID field in the mutation")
  7602. }
  7603. oldValue, err := m.oldValue(ctx)
  7604. if err != nil {
  7605. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7606. }
  7607. return oldValue.Name, nil
  7608. }
  7609. // ResetName resets all changes to the "name" field.
  7610. func (m *CategoryMutation) ResetName() {
  7611. m.name = nil
  7612. }
  7613. // SetOrganizationID sets the "organization_id" field.
  7614. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7615. m.organization_id = &u
  7616. m.addorganization_id = nil
  7617. }
  7618. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7619. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7620. v := m.organization_id
  7621. if v == nil {
  7622. return
  7623. }
  7624. return *v, true
  7625. }
  7626. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7627. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7629. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7630. if !m.op.Is(OpUpdateOne) {
  7631. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7632. }
  7633. if m.id == nil || m.oldValue == nil {
  7634. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7635. }
  7636. oldValue, err := m.oldValue(ctx)
  7637. if err != nil {
  7638. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7639. }
  7640. return oldValue.OrganizationID, nil
  7641. }
  7642. // AddOrganizationID adds u to the "organization_id" field.
  7643. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7644. if m.addorganization_id != nil {
  7645. *m.addorganization_id += u
  7646. } else {
  7647. m.addorganization_id = &u
  7648. }
  7649. }
  7650. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7651. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7652. v := m.addorganization_id
  7653. if v == nil {
  7654. return
  7655. }
  7656. return *v, true
  7657. }
  7658. // ResetOrganizationID resets all changes to the "organization_id" field.
  7659. func (m *CategoryMutation) ResetOrganizationID() {
  7660. m.organization_id = nil
  7661. m.addorganization_id = nil
  7662. }
  7663. // Where appends a list predicates to the CategoryMutation builder.
  7664. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7665. m.predicates = append(m.predicates, ps...)
  7666. }
  7667. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7668. // users can use type-assertion to append predicates that do not depend on any generated package.
  7669. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7670. p := make([]predicate.Category, len(ps))
  7671. for i := range ps {
  7672. p[i] = ps[i]
  7673. }
  7674. m.Where(p...)
  7675. }
  7676. // Op returns the operation name.
  7677. func (m *CategoryMutation) Op() Op {
  7678. return m.op
  7679. }
  7680. // SetOp allows setting the mutation operation.
  7681. func (m *CategoryMutation) SetOp(op Op) {
  7682. m.op = op
  7683. }
  7684. // Type returns the node type of this mutation (Category).
  7685. func (m *CategoryMutation) Type() string {
  7686. return m.typ
  7687. }
  7688. // Fields returns all fields that were changed during this mutation. Note that in
  7689. // order to get all numeric fields that were incremented/decremented, call
  7690. // AddedFields().
  7691. func (m *CategoryMutation) Fields() []string {
  7692. fields := make([]string, 0, 5)
  7693. if m.created_at != nil {
  7694. fields = append(fields, category.FieldCreatedAt)
  7695. }
  7696. if m.updated_at != nil {
  7697. fields = append(fields, category.FieldUpdatedAt)
  7698. }
  7699. if m.deleted_at != nil {
  7700. fields = append(fields, category.FieldDeletedAt)
  7701. }
  7702. if m.name != nil {
  7703. fields = append(fields, category.FieldName)
  7704. }
  7705. if m.organization_id != nil {
  7706. fields = append(fields, category.FieldOrganizationID)
  7707. }
  7708. return fields
  7709. }
  7710. // Field returns the value of a field with the given name. The second boolean
  7711. // return value indicates that this field was not set, or was not defined in the
  7712. // schema.
  7713. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7714. switch name {
  7715. case category.FieldCreatedAt:
  7716. return m.CreatedAt()
  7717. case category.FieldUpdatedAt:
  7718. return m.UpdatedAt()
  7719. case category.FieldDeletedAt:
  7720. return m.DeletedAt()
  7721. case category.FieldName:
  7722. return m.Name()
  7723. case category.FieldOrganizationID:
  7724. return m.OrganizationID()
  7725. }
  7726. return nil, false
  7727. }
  7728. // OldField returns the old value of the field from the database. An error is
  7729. // returned if the mutation operation is not UpdateOne, or the query to the
  7730. // database failed.
  7731. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7732. switch name {
  7733. case category.FieldCreatedAt:
  7734. return m.OldCreatedAt(ctx)
  7735. case category.FieldUpdatedAt:
  7736. return m.OldUpdatedAt(ctx)
  7737. case category.FieldDeletedAt:
  7738. return m.OldDeletedAt(ctx)
  7739. case category.FieldName:
  7740. return m.OldName(ctx)
  7741. case category.FieldOrganizationID:
  7742. return m.OldOrganizationID(ctx)
  7743. }
  7744. return nil, fmt.Errorf("unknown Category field %s", name)
  7745. }
  7746. // SetField sets the value of a field with the given name. It returns an error if
  7747. // the field is not defined in the schema, or if the type mismatched the field
  7748. // type.
  7749. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7750. switch name {
  7751. case category.FieldCreatedAt:
  7752. v, ok := value.(time.Time)
  7753. if !ok {
  7754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7755. }
  7756. m.SetCreatedAt(v)
  7757. return nil
  7758. case category.FieldUpdatedAt:
  7759. v, ok := value.(time.Time)
  7760. if !ok {
  7761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7762. }
  7763. m.SetUpdatedAt(v)
  7764. return nil
  7765. case category.FieldDeletedAt:
  7766. v, ok := value.(time.Time)
  7767. if !ok {
  7768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7769. }
  7770. m.SetDeletedAt(v)
  7771. return nil
  7772. case category.FieldName:
  7773. v, ok := value.(string)
  7774. if !ok {
  7775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7776. }
  7777. m.SetName(v)
  7778. return nil
  7779. case category.FieldOrganizationID:
  7780. v, ok := value.(uint64)
  7781. if !ok {
  7782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7783. }
  7784. m.SetOrganizationID(v)
  7785. return nil
  7786. }
  7787. return fmt.Errorf("unknown Category field %s", name)
  7788. }
  7789. // AddedFields returns all numeric fields that were incremented/decremented during
  7790. // this mutation.
  7791. func (m *CategoryMutation) AddedFields() []string {
  7792. var fields []string
  7793. if m.addorganization_id != nil {
  7794. fields = append(fields, category.FieldOrganizationID)
  7795. }
  7796. return fields
  7797. }
  7798. // AddedField returns the numeric value that was incremented/decremented on a field
  7799. // with the given name. The second boolean return value indicates that this field
  7800. // was not set, or was not defined in the schema.
  7801. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7802. switch name {
  7803. case category.FieldOrganizationID:
  7804. return m.AddedOrganizationID()
  7805. }
  7806. return nil, false
  7807. }
  7808. // AddField adds the value to the field with the given name. It returns an error if
  7809. // the field is not defined in the schema, or if the type mismatched the field
  7810. // type.
  7811. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7812. switch name {
  7813. case category.FieldOrganizationID:
  7814. v, ok := value.(int64)
  7815. if !ok {
  7816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7817. }
  7818. m.AddOrganizationID(v)
  7819. return nil
  7820. }
  7821. return fmt.Errorf("unknown Category numeric field %s", name)
  7822. }
  7823. // ClearedFields returns all nullable fields that were cleared during this
  7824. // mutation.
  7825. func (m *CategoryMutation) ClearedFields() []string {
  7826. var fields []string
  7827. if m.FieldCleared(category.FieldDeletedAt) {
  7828. fields = append(fields, category.FieldDeletedAt)
  7829. }
  7830. return fields
  7831. }
  7832. // FieldCleared returns a boolean indicating if a field with the given name was
  7833. // cleared in this mutation.
  7834. func (m *CategoryMutation) FieldCleared(name string) bool {
  7835. _, ok := m.clearedFields[name]
  7836. return ok
  7837. }
  7838. // ClearField clears the value of the field with the given name. It returns an
  7839. // error if the field is not defined in the schema.
  7840. func (m *CategoryMutation) ClearField(name string) error {
  7841. switch name {
  7842. case category.FieldDeletedAt:
  7843. m.ClearDeletedAt()
  7844. return nil
  7845. }
  7846. return fmt.Errorf("unknown Category nullable field %s", name)
  7847. }
  7848. // ResetField resets all changes in the mutation for the field with the given name.
  7849. // It returns an error if the field is not defined in the schema.
  7850. func (m *CategoryMutation) ResetField(name string) error {
  7851. switch name {
  7852. case category.FieldCreatedAt:
  7853. m.ResetCreatedAt()
  7854. return nil
  7855. case category.FieldUpdatedAt:
  7856. m.ResetUpdatedAt()
  7857. return nil
  7858. case category.FieldDeletedAt:
  7859. m.ResetDeletedAt()
  7860. return nil
  7861. case category.FieldName:
  7862. m.ResetName()
  7863. return nil
  7864. case category.FieldOrganizationID:
  7865. m.ResetOrganizationID()
  7866. return nil
  7867. }
  7868. return fmt.Errorf("unknown Category field %s", name)
  7869. }
  7870. // AddedEdges returns all edge names that were set/added in this mutation.
  7871. func (m *CategoryMutation) AddedEdges() []string {
  7872. edges := make([]string, 0, 0)
  7873. return edges
  7874. }
  7875. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7876. // name in this mutation.
  7877. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7878. return nil
  7879. }
  7880. // RemovedEdges returns all edge names that were removed in this mutation.
  7881. func (m *CategoryMutation) RemovedEdges() []string {
  7882. edges := make([]string, 0, 0)
  7883. return edges
  7884. }
  7885. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7886. // the given name in this mutation.
  7887. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7888. return nil
  7889. }
  7890. // ClearedEdges returns all edge names that were cleared in this mutation.
  7891. func (m *CategoryMutation) ClearedEdges() []string {
  7892. edges := make([]string, 0, 0)
  7893. return edges
  7894. }
  7895. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7896. // was cleared in this mutation.
  7897. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7898. return false
  7899. }
  7900. // ClearEdge clears the value of the edge with the given name. It returns an error
  7901. // if that edge is not defined in the schema.
  7902. func (m *CategoryMutation) ClearEdge(name string) error {
  7903. return fmt.Errorf("unknown Category unique edge %s", name)
  7904. }
  7905. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7906. // It returns an error if the edge is not defined in the schema.
  7907. func (m *CategoryMutation) ResetEdge(name string) error {
  7908. return fmt.Errorf("unknown Category edge %s", name)
  7909. }
  7910. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7911. type ChatRecordsMutation struct {
  7912. config
  7913. op Op
  7914. typ string
  7915. id *uint64
  7916. created_at *time.Time
  7917. updated_at *time.Time
  7918. deleted_at *time.Time
  7919. content *string
  7920. content_type *uint8
  7921. addcontent_type *int8
  7922. session_id *uint64
  7923. addsession_id *int64
  7924. user_id *uint64
  7925. adduser_id *int64
  7926. bot_id *uint64
  7927. addbot_id *int64
  7928. bot_type *uint8
  7929. addbot_type *int8
  7930. clearedFields map[string]struct{}
  7931. done bool
  7932. oldValue func(context.Context) (*ChatRecords, error)
  7933. predicates []predicate.ChatRecords
  7934. }
  7935. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7936. // chatrecordsOption allows management of the mutation configuration using functional options.
  7937. type chatrecordsOption func(*ChatRecordsMutation)
  7938. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7939. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7940. m := &ChatRecordsMutation{
  7941. config: c,
  7942. op: op,
  7943. typ: TypeChatRecords,
  7944. clearedFields: make(map[string]struct{}),
  7945. }
  7946. for _, opt := range opts {
  7947. opt(m)
  7948. }
  7949. return m
  7950. }
  7951. // withChatRecordsID sets the ID field of the mutation.
  7952. func withChatRecordsID(id uint64) chatrecordsOption {
  7953. return func(m *ChatRecordsMutation) {
  7954. var (
  7955. err error
  7956. once sync.Once
  7957. value *ChatRecords
  7958. )
  7959. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7960. once.Do(func() {
  7961. if m.done {
  7962. err = errors.New("querying old values post mutation is not allowed")
  7963. } else {
  7964. value, err = m.Client().ChatRecords.Get(ctx, id)
  7965. }
  7966. })
  7967. return value, err
  7968. }
  7969. m.id = &id
  7970. }
  7971. }
  7972. // withChatRecords sets the old ChatRecords of the mutation.
  7973. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7974. return func(m *ChatRecordsMutation) {
  7975. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7976. return node, nil
  7977. }
  7978. m.id = &node.ID
  7979. }
  7980. }
  7981. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7982. // executed in a transaction (ent.Tx), a transactional client is returned.
  7983. func (m ChatRecordsMutation) Client() *Client {
  7984. client := &Client{config: m.config}
  7985. client.init()
  7986. return client
  7987. }
  7988. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7989. // it returns an error otherwise.
  7990. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7991. if _, ok := m.driver.(*txDriver); !ok {
  7992. return nil, errors.New("ent: mutation is not running in a transaction")
  7993. }
  7994. tx := &Tx{config: m.config}
  7995. tx.init()
  7996. return tx, nil
  7997. }
  7998. // SetID sets the value of the id field. Note that this
  7999. // operation is only accepted on creation of ChatRecords entities.
  8000. func (m *ChatRecordsMutation) SetID(id uint64) {
  8001. m.id = &id
  8002. }
  8003. // ID returns the ID value in the mutation. Note that the ID is only available
  8004. // if it was provided to the builder or after it was returned from the database.
  8005. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  8006. if m.id == nil {
  8007. return
  8008. }
  8009. return *m.id, true
  8010. }
  8011. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8012. // That means, if the mutation is applied within a transaction with an isolation level such
  8013. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8014. // or updated by the mutation.
  8015. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  8016. switch {
  8017. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8018. id, exists := m.ID()
  8019. if exists {
  8020. return []uint64{id}, nil
  8021. }
  8022. fallthrough
  8023. case m.op.Is(OpUpdate | OpDelete):
  8024. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  8025. default:
  8026. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8027. }
  8028. }
  8029. // SetCreatedAt sets the "created_at" field.
  8030. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  8031. m.created_at = &t
  8032. }
  8033. // CreatedAt returns the value of the "created_at" field in the mutation.
  8034. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  8035. v := m.created_at
  8036. if v == nil {
  8037. return
  8038. }
  8039. return *v, true
  8040. }
  8041. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  8042. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8044. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8045. if !m.op.Is(OpUpdateOne) {
  8046. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8047. }
  8048. if m.id == nil || m.oldValue == nil {
  8049. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8050. }
  8051. oldValue, err := m.oldValue(ctx)
  8052. if err != nil {
  8053. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8054. }
  8055. return oldValue.CreatedAt, nil
  8056. }
  8057. // ResetCreatedAt resets all changes to the "created_at" field.
  8058. func (m *ChatRecordsMutation) ResetCreatedAt() {
  8059. m.created_at = nil
  8060. }
  8061. // SetUpdatedAt sets the "updated_at" field.
  8062. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  8063. m.updated_at = &t
  8064. }
  8065. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8066. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  8067. v := m.updated_at
  8068. if v == nil {
  8069. return
  8070. }
  8071. return *v, true
  8072. }
  8073. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  8074. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8076. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8077. if !m.op.Is(OpUpdateOne) {
  8078. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8079. }
  8080. if m.id == nil || m.oldValue == nil {
  8081. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8082. }
  8083. oldValue, err := m.oldValue(ctx)
  8084. if err != nil {
  8085. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8086. }
  8087. return oldValue.UpdatedAt, nil
  8088. }
  8089. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8090. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  8091. m.updated_at = nil
  8092. }
  8093. // SetDeletedAt sets the "deleted_at" field.
  8094. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  8095. m.deleted_at = &t
  8096. }
  8097. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8098. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  8099. v := m.deleted_at
  8100. if v == nil {
  8101. return
  8102. }
  8103. return *v, true
  8104. }
  8105. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  8106. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8108. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8109. if !m.op.Is(OpUpdateOne) {
  8110. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8111. }
  8112. if m.id == nil || m.oldValue == nil {
  8113. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8114. }
  8115. oldValue, err := m.oldValue(ctx)
  8116. if err != nil {
  8117. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8118. }
  8119. return oldValue.DeletedAt, nil
  8120. }
  8121. // ClearDeletedAt clears the value of the "deleted_at" field.
  8122. func (m *ChatRecordsMutation) ClearDeletedAt() {
  8123. m.deleted_at = nil
  8124. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  8125. }
  8126. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8127. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  8128. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  8129. return ok
  8130. }
  8131. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8132. func (m *ChatRecordsMutation) ResetDeletedAt() {
  8133. m.deleted_at = nil
  8134. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  8135. }
  8136. // SetContent sets the "content" field.
  8137. func (m *ChatRecordsMutation) SetContent(s string) {
  8138. m.content = &s
  8139. }
  8140. // Content returns the value of the "content" field in the mutation.
  8141. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  8142. v := m.content
  8143. if v == nil {
  8144. return
  8145. }
  8146. return *v, true
  8147. }
  8148. // OldContent returns the old "content" field's value of the ChatRecords entity.
  8149. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8151. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  8152. if !m.op.Is(OpUpdateOne) {
  8153. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  8154. }
  8155. if m.id == nil || m.oldValue == nil {
  8156. return v, errors.New("OldContent requires an ID field in the mutation")
  8157. }
  8158. oldValue, err := m.oldValue(ctx)
  8159. if err != nil {
  8160. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  8161. }
  8162. return oldValue.Content, nil
  8163. }
  8164. // ResetContent resets all changes to the "content" field.
  8165. func (m *ChatRecordsMutation) ResetContent() {
  8166. m.content = nil
  8167. }
  8168. // SetContentType sets the "content_type" field.
  8169. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  8170. m.content_type = &u
  8171. m.addcontent_type = nil
  8172. }
  8173. // ContentType returns the value of the "content_type" field in the mutation.
  8174. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  8175. v := m.content_type
  8176. if v == nil {
  8177. return
  8178. }
  8179. return *v, true
  8180. }
  8181. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  8182. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8184. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  8185. if !m.op.Is(OpUpdateOne) {
  8186. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  8187. }
  8188. if m.id == nil || m.oldValue == nil {
  8189. return v, errors.New("OldContentType requires an ID field in the mutation")
  8190. }
  8191. oldValue, err := m.oldValue(ctx)
  8192. if err != nil {
  8193. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  8194. }
  8195. return oldValue.ContentType, nil
  8196. }
  8197. // AddContentType adds u to the "content_type" field.
  8198. func (m *ChatRecordsMutation) AddContentType(u int8) {
  8199. if m.addcontent_type != nil {
  8200. *m.addcontent_type += u
  8201. } else {
  8202. m.addcontent_type = &u
  8203. }
  8204. }
  8205. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  8206. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  8207. v := m.addcontent_type
  8208. if v == nil {
  8209. return
  8210. }
  8211. return *v, true
  8212. }
  8213. // ResetContentType resets all changes to the "content_type" field.
  8214. func (m *ChatRecordsMutation) ResetContentType() {
  8215. m.content_type = nil
  8216. m.addcontent_type = nil
  8217. }
  8218. // SetSessionID sets the "session_id" field.
  8219. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  8220. m.session_id = &u
  8221. m.addsession_id = nil
  8222. }
  8223. // SessionID returns the value of the "session_id" field in the mutation.
  8224. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  8225. v := m.session_id
  8226. if v == nil {
  8227. return
  8228. }
  8229. return *v, true
  8230. }
  8231. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  8232. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8234. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  8235. if !m.op.Is(OpUpdateOne) {
  8236. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  8237. }
  8238. if m.id == nil || m.oldValue == nil {
  8239. return v, errors.New("OldSessionID requires an ID field in the mutation")
  8240. }
  8241. oldValue, err := m.oldValue(ctx)
  8242. if err != nil {
  8243. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  8244. }
  8245. return oldValue.SessionID, nil
  8246. }
  8247. // AddSessionID adds u to the "session_id" field.
  8248. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  8249. if m.addsession_id != nil {
  8250. *m.addsession_id += u
  8251. } else {
  8252. m.addsession_id = &u
  8253. }
  8254. }
  8255. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  8256. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  8257. v := m.addsession_id
  8258. if v == nil {
  8259. return
  8260. }
  8261. return *v, true
  8262. }
  8263. // ResetSessionID resets all changes to the "session_id" field.
  8264. func (m *ChatRecordsMutation) ResetSessionID() {
  8265. m.session_id = nil
  8266. m.addsession_id = nil
  8267. }
  8268. // SetUserID sets the "user_id" field.
  8269. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  8270. m.user_id = &u
  8271. m.adduser_id = nil
  8272. }
  8273. // UserID returns the value of the "user_id" field in the mutation.
  8274. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  8275. v := m.user_id
  8276. if v == nil {
  8277. return
  8278. }
  8279. return *v, true
  8280. }
  8281. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  8282. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8284. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8285. if !m.op.Is(OpUpdateOne) {
  8286. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8287. }
  8288. if m.id == nil || m.oldValue == nil {
  8289. return v, errors.New("OldUserID requires an ID field in the mutation")
  8290. }
  8291. oldValue, err := m.oldValue(ctx)
  8292. if err != nil {
  8293. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8294. }
  8295. return oldValue.UserID, nil
  8296. }
  8297. // AddUserID adds u to the "user_id" field.
  8298. func (m *ChatRecordsMutation) AddUserID(u int64) {
  8299. if m.adduser_id != nil {
  8300. *m.adduser_id += u
  8301. } else {
  8302. m.adduser_id = &u
  8303. }
  8304. }
  8305. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8306. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  8307. v := m.adduser_id
  8308. if v == nil {
  8309. return
  8310. }
  8311. return *v, true
  8312. }
  8313. // ResetUserID resets all changes to the "user_id" field.
  8314. func (m *ChatRecordsMutation) ResetUserID() {
  8315. m.user_id = nil
  8316. m.adduser_id = nil
  8317. }
  8318. // SetBotID sets the "bot_id" field.
  8319. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8320. m.bot_id = &u
  8321. m.addbot_id = nil
  8322. }
  8323. // BotID returns the value of the "bot_id" field in the mutation.
  8324. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8325. v := m.bot_id
  8326. if v == nil {
  8327. return
  8328. }
  8329. return *v, true
  8330. }
  8331. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8332. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8334. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8335. if !m.op.Is(OpUpdateOne) {
  8336. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8337. }
  8338. if m.id == nil || m.oldValue == nil {
  8339. return v, errors.New("OldBotID requires an ID field in the mutation")
  8340. }
  8341. oldValue, err := m.oldValue(ctx)
  8342. if err != nil {
  8343. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8344. }
  8345. return oldValue.BotID, nil
  8346. }
  8347. // AddBotID adds u to the "bot_id" field.
  8348. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8349. if m.addbot_id != nil {
  8350. *m.addbot_id += u
  8351. } else {
  8352. m.addbot_id = &u
  8353. }
  8354. }
  8355. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8356. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8357. v := m.addbot_id
  8358. if v == nil {
  8359. return
  8360. }
  8361. return *v, true
  8362. }
  8363. // ResetBotID resets all changes to the "bot_id" field.
  8364. func (m *ChatRecordsMutation) ResetBotID() {
  8365. m.bot_id = nil
  8366. m.addbot_id = nil
  8367. }
  8368. // SetBotType sets the "bot_type" field.
  8369. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8370. m.bot_type = &u
  8371. m.addbot_type = nil
  8372. }
  8373. // BotType returns the value of the "bot_type" field in the mutation.
  8374. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8375. v := m.bot_type
  8376. if v == nil {
  8377. return
  8378. }
  8379. return *v, true
  8380. }
  8381. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8382. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8384. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8385. if !m.op.Is(OpUpdateOne) {
  8386. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8387. }
  8388. if m.id == nil || m.oldValue == nil {
  8389. return v, errors.New("OldBotType requires an ID field in the mutation")
  8390. }
  8391. oldValue, err := m.oldValue(ctx)
  8392. if err != nil {
  8393. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8394. }
  8395. return oldValue.BotType, nil
  8396. }
  8397. // AddBotType adds u to the "bot_type" field.
  8398. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8399. if m.addbot_type != nil {
  8400. *m.addbot_type += u
  8401. } else {
  8402. m.addbot_type = &u
  8403. }
  8404. }
  8405. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8406. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8407. v := m.addbot_type
  8408. if v == nil {
  8409. return
  8410. }
  8411. return *v, true
  8412. }
  8413. // ResetBotType resets all changes to the "bot_type" field.
  8414. func (m *ChatRecordsMutation) ResetBotType() {
  8415. m.bot_type = nil
  8416. m.addbot_type = nil
  8417. }
  8418. // Where appends a list predicates to the ChatRecordsMutation builder.
  8419. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8420. m.predicates = append(m.predicates, ps...)
  8421. }
  8422. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8423. // users can use type-assertion to append predicates that do not depend on any generated package.
  8424. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8425. p := make([]predicate.ChatRecords, len(ps))
  8426. for i := range ps {
  8427. p[i] = ps[i]
  8428. }
  8429. m.Where(p...)
  8430. }
  8431. // Op returns the operation name.
  8432. func (m *ChatRecordsMutation) Op() Op {
  8433. return m.op
  8434. }
  8435. // SetOp allows setting the mutation operation.
  8436. func (m *ChatRecordsMutation) SetOp(op Op) {
  8437. m.op = op
  8438. }
  8439. // Type returns the node type of this mutation (ChatRecords).
  8440. func (m *ChatRecordsMutation) Type() string {
  8441. return m.typ
  8442. }
  8443. // Fields returns all fields that were changed during this mutation. Note that in
  8444. // order to get all numeric fields that were incremented/decremented, call
  8445. // AddedFields().
  8446. func (m *ChatRecordsMutation) Fields() []string {
  8447. fields := make([]string, 0, 9)
  8448. if m.created_at != nil {
  8449. fields = append(fields, chatrecords.FieldCreatedAt)
  8450. }
  8451. if m.updated_at != nil {
  8452. fields = append(fields, chatrecords.FieldUpdatedAt)
  8453. }
  8454. if m.deleted_at != nil {
  8455. fields = append(fields, chatrecords.FieldDeletedAt)
  8456. }
  8457. if m.content != nil {
  8458. fields = append(fields, chatrecords.FieldContent)
  8459. }
  8460. if m.content_type != nil {
  8461. fields = append(fields, chatrecords.FieldContentType)
  8462. }
  8463. if m.session_id != nil {
  8464. fields = append(fields, chatrecords.FieldSessionID)
  8465. }
  8466. if m.user_id != nil {
  8467. fields = append(fields, chatrecords.FieldUserID)
  8468. }
  8469. if m.bot_id != nil {
  8470. fields = append(fields, chatrecords.FieldBotID)
  8471. }
  8472. if m.bot_type != nil {
  8473. fields = append(fields, chatrecords.FieldBotType)
  8474. }
  8475. return fields
  8476. }
  8477. // Field returns the value of a field with the given name. The second boolean
  8478. // return value indicates that this field was not set, or was not defined in the
  8479. // schema.
  8480. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8481. switch name {
  8482. case chatrecords.FieldCreatedAt:
  8483. return m.CreatedAt()
  8484. case chatrecords.FieldUpdatedAt:
  8485. return m.UpdatedAt()
  8486. case chatrecords.FieldDeletedAt:
  8487. return m.DeletedAt()
  8488. case chatrecords.FieldContent:
  8489. return m.Content()
  8490. case chatrecords.FieldContentType:
  8491. return m.ContentType()
  8492. case chatrecords.FieldSessionID:
  8493. return m.SessionID()
  8494. case chatrecords.FieldUserID:
  8495. return m.UserID()
  8496. case chatrecords.FieldBotID:
  8497. return m.BotID()
  8498. case chatrecords.FieldBotType:
  8499. return m.BotType()
  8500. }
  8501. return nil, false
  8502. }
  8503. // OldField returns the old value of the field from the database. An error is
  8504. // returned if the mutation operation is not UpdateOne, or the query to the
  8505. // database failed.
  8506. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8507. switch name {
  8508. case chatrecords.FieldCreatedAt:
  8509. return m.OldCreatedAt(ctx)
  8510. case chatrecords.FieldUpdatedAt:
  8511. return m.OldUpdatedAt(ctx)
  8512. case chatrecords.FieldDeletedAt:
  8513. return m.OldDeletedAt(ctx)
  8514. case chatrecords.FieldContent:
  8515. return m.OldContent(ctx)
  8516. case chatrecords.FieldContentType:
  8517. return m.OldContentType(ctx)
  8518. case chatrecords.FieldSessionID:
  8519. return m.OldSessionID(ctx)
  8520. case chatrecords.FieldUserID:
  8521. return m.OldUserID(ctx)
  8522. case chatrecords.FieldBotID:
  8523. return m.OldBotID(ctx)
  8524. case chatrecords.FieldBotType:
  8525. return m.OldBotType(ctx)
  8526. }
  8527. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8528. }
  8529. // SetField sets the value of a field with the given name. It returns an error if
  8530. // the field is not defined in the schema, or if the type mismatched the field
  8531. // type.
  8532. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8533. switch name {
  8534. case chatrecords.FieldCreatedAt:
  8535. v, ok := value.(time.Time)
  8536. if !ok {
  8537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8538. }
  8539. m.SetCreatedAt(v)
  8540. return nil
  8541. case chatrecords.FieldUpdatedAt:
  8542. v, ok := value.(time.Time)
  8543. if !ok {
  8544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8545. }
  8546. m.SetUpdatedAt(v)
  8547. return nil
  8548. case chatrecords.FieldDeletedAt:
  8549. v, ok := value.(time.Time)
  8550. if !ok {
  8551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8552. }
  8553. m.SetDeletedAt(v)
  8554. return nil
  8555. case chatrecords.FieldContent:
  8556. v, ok := value.(string)
  8557. if !ok {
  8558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8559. }
  8560. m.SetContent(v)
  8561. return nil
  8562. case chatrecords.FieldContentType:
  8563. v, ok := value.(uint8)
  8564. if !ok {
  8565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8566. }
  8567. m.SetContentType(v)
  8568. return nil
  8569. case chatrecords.FieldSessionID:
  8570. v, ok := value.(uint64)
  8571. if !ok {
  8572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8573. }
  8574. m.SetSessionID(v)
  8575. return nil
  8576. case chatrecords.FieldUserID:
  8577. v, ok := value.(uint64)
  8578. if !ok {
  8579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8580. }
  8581. m.SetUserID(v)
  8582. return nil
  8583. case chatrecords.FieldBotID:
  8584. v, ok := value.(uint64)
  8585. if !ok {
  8586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8587. }
  8588. m.SetBotID(v)
  8589. return nil
  8590. case chatrecords.FieldBotType:
  8591. v, ok := value.(uint8)
  8592. if !ok {
  8593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8594. }
  8595. m.SetBotType(v)
  8596. return nil
  8597. }
  8598. return fmt.Errorf("unknown ChatRecords field %s", name)
  8599. }
  8600. // AddedFields returns all numeric fields that were incremented/decremented during
  8601. // this mutation.
  8602. func (m *ChatRecordsMutation) AddedFields() []string {
  8603. var fields []string
  8604. if m.addcontent_type != nil {
  8605. fields = append(fields, chatrecords.FieldContentType)
  8606. }
  8607. if m.addsession_id != nil {
  8608. fields = append(fields, chatrecords.FieldSessionID)
  8609. }
  8610. if m.adduser_id != nil {
  8611. fields = append(fields, chatrecords.FieldUserID)
  8612. }
  8613. if m.addbot_id != nil {
  8614. fields = append(fields, chatrecords.FieldBotID)
  8615. }
  8616. if m.addbot_type != nil {
  8617. fields = append(fields, chatrecords.FieldBotType)
  8618. }
  8619. return fields
  8620. }
  8621. // AddedField returns the numeric value that was incremented/decremented on a field
  8622. // with the given name. The second boolean return value indicates that this field
  8623. // was not set, or was not defined in the schema.
  8624. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8625. switch name {
  8626. case chatrecords.FieldContentType:
  8627. return m.AddedContentType()
  8628. case chatrecords.FieldSessionID:
  8629. return m.AddedSessionID()
  8630. case chatrecords.FieldUserID:
  8631. return m.AddedUserID()
  8632. case chatrecords.FieldBotID:
  8633. return m.AddedBotID()
  8634. case chatrecords.FieldBotType:
  8635. return m.AddedBotType()
  8636. }
  8637. return nil, false
  8638. }
  8639. // AddField adds the value to the field with the given name. It returns an error if
  8640. // the field is not defined in the schema, or if the type mismatched the field
  8641. // type.
  8642. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8643. switch name {
  8644. case chatrecords.FieldContentType:
  8645. v, ok := value.(int8)
  8646. if !ok {
  8647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8648. }
  8649. m.AddContentType(v)
  8650. return nil
  8651. case chatrecords.FieldSessionID:
  8652. v, ok := value.(int64)
  8653. if !ok {
  8654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8655. }
  8656. m.AddSessionID(v)
  8657. return nil
  8658. case chatrecords.FieldUserID:
  8659. v, ok := value.(int64)
  8660. if !ok {
  8661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8662. }
  8663. m.AddUserID(v)
  8664. return nil
  8665. case chatrecords.FieldBotID:
  8666. v, ok := value.(int64)
  8667. if !ok {
  8668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8669. }
  8670. m.AddBotID(v)
  8671. return nil
  8672. case chatrecords.FieldBotType:
  8673. v, ok := value.(int8)
  8674. if !ok {
  8675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8676. }
  8677. m.AddBotType(v)
  8678. return nil
  8679. }
  8680. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8681. }
  8682. // ClearedFields returns all nullable fields that were cleared during this
  8683. // mutation.
  8684. func (m *ChatRecordsMutation) ClearedFields() []string {
  8685. var fields []string
  8686. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8687. fields = append(fields, chatrecords.FieldDeletedAt)
  8688. }
  8689. return fields
  8690. }
  8691. // FieldCleared returns a boolean indicating if a field with the given name was
  8692. // cleared in this mutation.
  8693. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8694. _, ok := m.clearedFields[name]
  8695. return ok
  8696. }
  8697. // ClearField clears the value of the field with the given name. It returns an
  8698. // error if the field is not defined in the schema.
  8699. func (m *ChatRecordsMutation) ClearField(name string) error {
  8700. switch name {
  8701. case chatrecords.FieldDeletedAt:
  8702. m.ClearDeletedAt()
  8703. return nil
  8704. }
  8705. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8706. }
  8707. // ResetField resets all changes in the mutation for the field with the given name.
  8708. // It returns an error if the field is not defined in the schema.
  8709. func (m *ChatRecordsMutation) ResetField(name string) error {
  8710. switch name {
  8711. case chatrecords.FieldCreatedAt:
  8712. m.ResetCreatedAt()
  8713. return nil
  8714. case chatrecords.FieldUpdatedAt:
  8715. m.ResetUpdatedAt()
  8716. return nil
  8717. case chatrecords.FieldDeletedAt:
  8718. m.ResetDeletedAt()
  8719. return nil
  8720. case chatrecords.FieldContent:
  8721. m.ResetContent()
  8722. return nil
  8723. case chatrecords.FieldContentType:
  8724. m.ResetContentType()
  8725. return nil
  8726. case chatrecords.FieldSessionID:
  8727. m.ResetSessionID()
  8728. return nil
  8729. case chatrecords.FieldUserID:
  8730. m.ResetUserID()
  8731. return nil
  8732. case chatrecords.FieldBotID:
  8733. m.ResetBotID()
  8734. return nil
  8735. case chatrecords.FieldBotType:
  8736. m.ResetBotType()
  8737. return nil
  8738. }
  8739. return fmt.Errorf("unknown ChatRecords field %s", name)
  8740. }
  8741. // AddedEdges returns all edge names that were set/added in this mutation.
  8742. func (m *ChatRecordsMutation) AddedEdges() []string {
  8743. edges := make([]string, 0, 0)
  8744. return edges
  8745. }
  8746. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8747. // name in this mutation.
  8748. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8749. return nil
  8750. }
  8751. // RemovedEdges returns all edge names that were removed in this mutation.
  8752. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8753. edges := make([]string, 0, 0)
  8754. return edges
  8755. }
  8756. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8757. // the given name in this mutation.
  8758. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8759. return nil
  8760. }
  8761. // ClearedEdges returns all edge names that were cleared in this mutation.
  8762. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8763. edges := make([]string, 0, 0)
  8764. return edges
  8765. }
  8766. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8767. // was cleared in this mutation.
  8768. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8769. return false
  8770. }
  8771. // ClearEdge clears the value of the edge with the given name. It returns an error
  8772. // if that edge is not defined in the schema.
  8773. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8774. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8775. }
  8776. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8777. // It returns an error if the edge is not defined in the schema.
  8778. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8779. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8780. }
  8781. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8782. type ChatSessionMutation struct {
  8783. config
  8784. op Op
  8785. typ string
  8786. id *uint64
  8787. created_at *time.Time
  8788. updated_at *time.Time
  8789. deleted_at *time.Time
  8790. name *string
  8791. user_id *uint64
  8792. adduser_id *int64
  8793. bot_id *uint64
  8794. addbot_id *int64
  8795. bot_type *uint8
  8796. addbot_type *int8
  8797. clearedFields map[string]struct{}
  8798. done bool
  8799. oldValue func(context.Context) (*ChatSession, error)
  8800. predicates []predicate.ChatSession
  8801. }
  8802. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8803. // chatsessionOption allows management of the mutation configuration using functional options.
  8804. type chatsessionOption func(*ChatSessionMutation)
  8805. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8806. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8807. m := &ChatSessionMutation{
  8808. config: c,
  8809. op: op,
  8810. typ: TypeChatSession,
  8811. clearedFields: make(map[string]struct{}),
  8812. }
  8813. for _, opt := range opts {
  8814. opt(m)
  8815. }
  8816. return m
  8817. }
  8818. // withChatSessionID sets the ID field of the mutation.
  8819. func withChatSessionID(id uint64) chatsessionOption {
  8820. return func(m *ChatSessionMutation) {
  8821. var (
  8822. err error
  8823. once sync.Once
  8824. value *ChatSession
  8825. )
  8826. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8827. once.Do(func() {
  8828. if m.done {
  8829. err = errors.New("querying old values post mutation is not allowed")
  8830. } else {
  8831. value, err = m.Client().ChatSession.Get(ctx, id)
  8832. }
  8833. })
  8834. return value, err
  8835. }
  8836. m.id = &id
  8837. }
  8838. }
  8839. // withChatSession sets the old ChatSession of the mutation.
  8840. func withChatSession(node *ChatSession) chatsessionOption {
  8841. return func(m *ChatSessionMutation) {
  8842. m.oldValue = func(context.Context) (*ChatSession, error) {
  8843. return node, nil
  8844. }
  8845. m.id = &node.ID
  8846. }
  8847. }
  8848. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8849. // executed in a transaction (ent.Tx), a transactional client is returned.
  8850. func (m ChatSessionMutation) Client() *Client {
  8851. client := &Client{config: m.config}
  8852. client.init()
  8853. return client
  8854. }
  8855. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8856. // it returns an error otherwise.
  8857. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8858. if _, ok := m.driver.(*txDriver); !ok {
  8859. return nil, errors.New("ent: mutation is not running in a transaction")
  8860. }
  8861. tx := &Tx{config: m.config}
  8862. tx.init()
  8863. return tx, nil
  8864. }
  8865. // SetID sets the value of the id field. Note that this
  8866. // operation is only accepted on creation of ChatSession entities.
  8867. func (m *ChatSessionMutation) SetID(id uint64) {
  8868. m.id = &id
  8869. }
  8870. // ID returns the ID value in the mutation. Note that the ID is only available
  8871. // if it was provided to the builder or after it was returned from the database.
  8872. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8873. if m.id == nil {
  8874. return
  8875. }
  8876. return *m.id, true
  8877. }
  8878. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8879. // That means, if the mutation is applied within a transaction with an isolation level such
  8880. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8881. // or updated by the mutation.
  8882. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8883. switch {
  8884. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8885. id, exists := m.ID()
  8886. if exists {
  8887. return []uint64{id}, nil
  8888. }
  8889. fallthrough
  8890. case m.op.Is(OpUpdate | OpDelete):
  8891. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8892. default:
  8893. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8894. }
  8895. }
  8896. // SetCreatedAt sets the "created_at" field.
  8897. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8898. m.created_at = &t
  8899. }
  8900. // CreatedAt returns the value of the "created_at" field in the mutation.
  8901. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8902. v := m.created_at
  8903. if v == nil {
  8904. return
  8905. }
  8906. return *v, true
  8907. }
  8908. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8909. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8911. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8912. if !m.op.Is(OpUpdateOne) {
  8913. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8914. }
  8915. if m.id == nil || m.oldValue == nil {
  8916. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8917. }
  8918. oldValue, err := m.oldValue(ctx)
  8919. if err != nil {
  8920. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8921. }
  8922. return oldValue.CreatedAt, nil
  8923. }
  8924. // ResetCreatedAt resets all changes to the "created_at" field.
  8925. func (m *ChatSessionMutation) ResetCreatedAt() {
  8926. m.created_at = nil
  8927. }
  8928. // SetUpdatedAt sets the "updated_at" field.
  8929. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8930. m.updated_at = &t
  8931. }
  8932. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8933. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8934. v := m.updated_at
  8935. if v == nil {
  8936. return
  8937. }
  8938. return *v, true
  8939. }
  8940. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8941. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8943. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8944. if !m.op.Is(OpUpdateOne) {
  8945. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8946. }
  8947. if m.id == nil || m.oldValue == nil {
  8948. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8949. }
  8950. oldValue, err := m.oldValue(ctx)
  8951. if err != nil {
  8952. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8953. }
  8954. return oldValue.UpdatedAt, nil
  8955. }
  8956. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8957. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8958. m.updated_at = nil
  8959. }
  8960. // SetDeletedAt sets the "deleted_at" field.
  8961. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8962. m.deleted_at = &t
  8963. }
  8964. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8965. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8966. v := m.deleted_at
  8967. if v == nil {
  8968. return
  8969. }
  8970. return *v, true
  8971. }
  8972. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8973. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8975. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8976. if !m.op.Is(OpUpdateOne) {
  8977. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8978. }
  8979. if m.id == nil || m.oldValue == nil {
  8980. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8981. }
  8982. oldValue, err := m.oldValue(ctx)
  8983. if err != nil {
  8984. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8985. }
  8986. return oldValue.DeletedAt, nil
  8987. }
  8988. // ClearDeletedAt clears the value of the "deleted_at" field.
  8989. func (m *ChatSessionMutation) ClearDeletedAt() {
  8990. m.deleted_at = nil
  8991. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8992. }
  8993. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8994. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8995. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8996. return ok
  8997. }
  8998. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8999. func (m *ChatSessionMutation) ResetDeletedAt() {
  9000. m.deleted_at = nil
  9001. delete(m.clearedFields, chatsession.FieldDeletedAt)
  9002. }
  9003. // SetName sets the "name" field.
  9004. func (m *ChatSessionMutation) SetName(s string) {
  9005. m.name = &s
  9006. }
  9007. // Name returns the value of the "name" field in the mutation.
  9008. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  9009. v := m.name
  9010. if v == nil {
  9011. return
  9012. }
  9013. return *v, true
  9014. }
  9015. // OldName returns the old "name" field's value of the ChatSession entity.
  9016. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9018. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  9019. if !m.op.Is(OpUpdateOne) {
  9020. return v, errors.New("OldName is only allowed on UpdateOne operations")
  9021. }
  9022. if m.id == nil || m.oldValue == nil {
  9023. return v, errors.New("OldName requires an ID field in the mutation")
  9024. }
  9025. oldValue, err := m.oldValue(ctx)
  9026. if err != nil {
  9027. return v, fmt.Errorf("querying old value for OldName: %w", err)
  9028. }
  9029. return oldValue.Name, nil
  9030. }
  9031. // ResetName resets all changes to the "name" field.
  9032. func (m *ChatSessionMutation) ResetName() {
  9033. m.name = nil
  9034. }
  9035. // SetUserID sets the "user_id" field.
  9036. func (m *ChatSessionMutation) SetUserID(u uint64) {
  9037. m.user_id = &u
  9038. m.adduser_id = nil
  9039. }
  9040. // UserID returns the value of the "user_id" field in the mutation.
  9041. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  9042. v := m.user_id
  9043. if v == nil {
  9044. return
  9045. }
  9046. return *v, true
  9047. }
  9048. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  9049. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9051. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9052. if !m.op.Is(OpUpdateOne) {
  9053. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9054. }
  9055. if m.id == nil || m.oldValue == nil {
  9056. return v, errors.New("OldUserID requires an ID field in the mutation")
  9057. }
  9058. oldValue, err := m.oldValue(ctx)
  9059. if err != nil {
  9060. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9061. }
  9062. return oldValue.UserID, nil
  9063. }
  9064. // AddUserID adds u to the "user_id" field.
  9065. func (m *ChatSessionMutation) AddUserID(u int64) {
  9066. if m.adduser_id != nil {
  9067. *m.adduser_id += u
  9068. } else {
  9069. m.adduser_id = &u
  9070. }
  9071. }
  9072. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9073. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  9074. v := m.adduser_id
  9075. if v == nil {
  9076. return
  9077. }
  9078. return *v, true
  9079. }
  9080. // ResetUserID resets all changes to the "user_id" field.
  9081. func (m *ChatSessionMutation) ResetUserID() {
  9082. m.user_id = nil
  9083. m.adduser_id = nil
  9084. }
  9085. // SetBotID sets the "bot_id" field.
  9086. func (m *ChatSessionMutation) SetBotID(u uint64) {
  9087. m.bot_id = &u
  9088. m.addbot_id = nil
  9089. }
  9090. // BotID returns the value of the "bot_id" field in the mutation.
  9091. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  9092. v := m.bot_id
  9093. if v == nil {
  9094. return
  9095. }
  9096. return *v, true
  9097. }
  9098. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  9099. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9101. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9102. if !m.op.Is(OpUpdateOne) {
  9103. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9104. }
  9105. if m.id == nil || m.oldValue == nil {
  9106. return v, errors.New("OldBotID requires an ID field in the mutation")
  9107. }
  9108. oldValue, err := m.oldValue(ctx)
  9109. if err != nil {
  9110. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  9111. }
  9112. return oldValue.BotID, nil
  9113. }
  9114. // AddBotID adds u to the "bot_id" field.
  9115. func (m *ChatSessionMutation) AddBotID(u int64) {
  9116. if m.addbot_id != nil {
  9117. *m.addbot_id += u
  9118. } else {
  9119. m.addbot_id = &u
  9120. }
  9121. }
  9122. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9123. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  9124. v := m.addbot_id
  9125. if v == nil {
  9126. return
  9127. }
  9128. return *v, true
  9129. }
  9130. // ResetBotID resets all changes to the "bot_id" field.
  9131. func (m *ChatSessionMutation) ResetBotID() {
  9132. m.bot_id = nil
  9133. m.addbot_id = nil
  9134. }
  9135. // SetBotType sets the "bot_type" field.
  9136. func (m *ChatSessionMutation) SetBotType(u uint8) {
  9137. m.bot_type = &u
  9138. m.addbot_type = nil
  9139. }
  9140. // BotType returns the value of the "bot_type" field in the mutation.
  9141. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  9142. v := m.bot_type
  9143. if v == nil {
  9144. return
  9145. }
  9146. return *v, true
  9147. }
  9148. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  9149. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  9150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9151. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9152. if !m.op.Is(OpUpdateOne) {
  9153. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9154. }
  9155. if m.id == nil || m.oldValue == nil {
  9156. return v, errors.New("OldBotType requires an ID field in the mutation")
  9157. }
  9158. oldValue, err := m.oldValue(ctx)
  9159. if err != nil {
  9160. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9161. }
  9162. return oldValue.BotType, nil
  9163. }
  9164. // AddBotType adds u to the "bot_type" field.
  9165. func (m *ChatSessionMutation) AddBotType(u int8) {
  9166. if m.addbot_type != nil {
  9167. *m.addbot_type += u
  9168. } else {
  9169. m.addbot_type = &u
  9170. }
  9171. }
  9172. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9173. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  9174. v := m.addbot_type
  9175. if v == nil {
  9176. return
  9177. }
  9178. return *v, true
  9179. }
  9180. // ResetBotType resets all changes to the "bot_type" field.
  9181. func (m *ChatSessionMutation) ResetBotType() {
  9182. m.bot_type = nil
  9183. m.addbot_type = nil
  9184. }
  9185. // Where appends a list predicates to the ChatSessionMutation builder.
  9186. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  9187. m.predicates = append(m.predicates, ps...)
  9188. }
  9189. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  9190. // users can use type-assertion to append predicates that do not depend on any generated package.
  9191. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  9192. p := make([]predicate.ChatSession, len(ps))
  9193. for i := range ps {
  9194. p[i] = ps[i]
  9195. }
  9196. m.Where(p...)
  9197. }
  9198. // Op returns the operation name.
  9199. func (m *ChatSessionMutation) Op() Op {
  9200. return m.op
  9201. }
  9202. // SetOp allows setting the mutation operation.
  9203. func (m *ChatSessionMutation) SetOp(op Op) {
  9204. m.op = op
  9205. }
  9206. // Type returns the node type of this mutation (ChatSession).
  9207. func (m *ChatSessionMutation) Type() string {
  9208. return m.typ
  9209. }
  9210. // Fields returns all fields that were changed during this mutation. Note that in
  9211. // order to get all numeric fields that were incremented/decremented, call
  9212. // AddedFields().
  9213. func (m *ChatSessionMutation) Fields() []string {
  9214. fields := make([]string, 0, 7)
  9215. if m.created_at != nil {
  9216. fields = append(fields, chatsession.FieldCreatedAt)
  9217. }
  9218. if m.updated_at != nil {
  9219. fields = append(fields, chatsession.FieldUpdatedAt)
  9220. }
  9221. if m.deleted_at != nil {
  9222. fields = append(fields, chatsession.FieldDeletedAt)
  9223. }
  9224. if m.name != nil {
  9225. fields = append(fields, chatsession.FieldName)
  9226. }
  9227. if m.user_id != nil {
  9228. fields = append(fields, chatsession.FieldUserID)
  9229. }
  9230. if m.bot_id != nil {
  9231. fields = append(fields, chatsession.FieldBotID)
  9232. }
  9233. if m.bot_type != nil {
  9234. fields = append(fields, chatsession.FieldBotType)
  9235. }
  9236. return fields
  9237. }
  9238. // Field returns the value of a field with the given name. The second boolean
  9239. // return value indicates that this field was not set, or was not defined in the
  9240. // schema.
  9241. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  9242. switch name {
  9243. case chatsession.FieldCreatedAt:
  9244. return m.CreatedAt()
  9245. case chatsession.FieldUpdatedAt:
  9246. return m.UpdatedAt()
  9247. case chatsession.FieldDeletedAt:
  9248. return m.DeletedAt()
  9249. case chatsession.FieldName:
  9250. return m.Name()
  9251. case chatsession.FieldUserID:
  9252. return m.UserID()
  9253. case chatsession.FieldBotID:
  9254. return m.BotID()
  9255. case chatsession.FieldBotType:
  9256. return m.BotType()
  9257. }
  9258. return nil, false
  9259. }
  9260. // OldField returns the old value of the field from the database. An error is
  9261. // returned if the mutation operation is not UpdateOne, or the query to the
  9262. // database failed.
  9263. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9264. switch name {
  9265. case chatsession.FieldCreatedAt:
  9266. return m.OldCreatedAt(ctx)
  9267. case chatsession.FieldUpdatedAt:
  9268. return m.OldUpdatedAt(ctx)
  9269. case chatsession.FieldDeletedAt:
  9270. return m.OldDeletedAt(ctx)
  9271. case chatsession.FieldName:
  9272. return m.OldName(ctx)
  9273. case chatsession.FieldUserID:
  9274. return m.OldUserID(ctx)
  9275. case chatsession.FieldBotID:
  9276. return m.OldBotID(ctx)
  9277. case chatsession.FieldBotType:
  9278. return m.OldBotType(ctx)
  9279. }
  9280. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  9281. }
  9282. // SetField sets the value of a field with the given name. It returns an error if
  9283. // the field is not defined in the schema, or if the type mismatched the field
  9284. // type.
  9285. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  9286. switch name {
  9287. case chatsession.FieldCreatedAt:
  9288. v, ok := value.(time.Time)
  9289. if !ok {
  9290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9291. }
  9292. m.SetCreatedAt(v)
  9293. return nil
  9294. case chatsession.FieldUpdatedAt:
  9295. v, ok := value.(time.Time)
  9296. if !ok {
  9297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9298. }
  9299. m.SetUpdatedAt(v)
  9300. return nil
  9301. case chatsession.FieldDeletedAt:
  9302. v, ok := value.(time.Time)
  9303. if !ok {
  9304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9305. }
  9306. m.SetDeletedAt(v)
  9307. return nil
  9308. case chatsession.FieldName:
  9309. v, ok := value.(string)
  9310. if !ok {
  9311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9312. }
  9313. m.SetName(v)
  9314. return nil
  9315. case chatsession.FieldUserID:
  9316. v, ok := value.(uint64)
  9317. if !ok {
  9318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9319. }
  9320. m.SetUserID(v)
  9321. return nil
  9322. case chatsession.FieldBotID:
  9323. v, ok := value.(uint64)
  9324. if !ok {
  9325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9326. }
  9327. m.SetBotID(v)
  9328. return nil
  9329. case chatsession.FieldBotType:
  9330. v, ok := value.(uint8)
  9331. if !ok {
  9332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9333. }
  9334. m.SetBotType(v)
  9335. return nil
  9336. }
  9337. return fmt.Errorf("unknown ChatSession field %s", name)
  9338. }
  9339. // AddedFields returns all numeric fields that were incremented/decremented during
  9340. // this mutation.
  9341. func (m *ChatSessionMutation) AddedFields() []string {
  9342. var fields []string
  9343. if m.adduser_id != nil {
  9344. fields = append(fields, chatsession.FieldUserID)
  9345. }
  9346. if m.addbot_id != nil {
  9347. fields = append(fields, chatsession.FieldBotID)
  9348. }
  9349. if m.addbot_type != nil {
  9350. fields = append(fields, chatsession.FieldBotType)
  9351. }
  9352. return fields
  9353. }
  9354. // AddedField returns the numeric value that was incremented/decremented on a field
  9355. // with the given name. The second boolean return value indicates that this field
  9356. // was not set, or was not defined in the schema.
  9357. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9358. switch name {
  9359. case chatsession.FieldUserID:
  9360. return m.AddedUserID()
  9361. case chatsession.FieldBotID:
  9362. return m.AddedBotID()
  9363. case chatsession.FieldBotType:
  9364. return m.AddedBotType()
  9365. }
  9366. return nil, false
  9367. }
  9368. // AddField adds the value to the 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) AddField(name string, value ent.Value) error {
  9372. switch name {
  9373. case chatsession.FieldUserID:
  9374. v, ok := value.(int64)
  9375. if !ok {
  9376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9377. }
  9378. m.AddUserID(v)
  9379. return nil
  9380. case chatsession.FieldBotID:
  9381. v, ok := value.(int64)
  9382. if !ok {
  9383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9384. }
  9385. m.AddBotID(v)
  9386. return nil
  9387. case chatsession.FieldBotType:
  9388. v, ok := value.(int8)
  9389. if !ok {
  9390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9391. }
  9392. m.AddBotType(v)
  9393. return nil
  9394. }
  9395. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9396. }
  9397. // ClearedFields returns all nullable fields that were cleared during this
  9398. // mutation.
  9399. func (m *ChatSessionMutation) ClearedFields() []string {
  9400. var fields []string
  9401. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9402. fields = append(fields, chatsession.FieldDeletedAt)
  9403. }
  9404. return fields
  9405. }
  9406. // FieldCleared returns a boolean indicating if a field with the given name was
  9407. // cleared in this mutation.
  9408. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9409. _, ok := m.clearedFields[name]
  9410. return ok
  9411. }
  9412. // ClearField clears the value of the field with the given name. It returns an
  9413. // error if the field is not defined in the schema.
  9414. func (m *ChatSessionMutation) ClearField(name string) error {
  9415. switch name {
  9416. case chatsession.FieldDeletedAt:
  9417. m.ClearDeletedAt()
  9418. return nil
  9419. }
  9420. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9421. }
  9422. // ResetField resets all changes in the mutation for the field with the given name.
  9423. // It returns an error if the field is not defined in the schema.
  9424. func (m *ChatSessionMutation) ResetField(name string) error {
  9425. switch name {
  9426. case chatsession.FieldCreatedAt:
  9427. m.ResetCreatedAt()
  9428. return nil
  9429. case chatsession.FieldUpdatedAt:
  9430. m.ResetUpdatedAt()
  9431. return nil
  9432. case chatsession.FieldDeletedAt:
  9433. m.ResetDeletedAt()
  9434. return nil
  9435. case chatsession.FieldName:
  9436. m.ResetName()
  9437. return nil
  9438. case chatsession.FieldUserID:
  9439. m.ResetUserID()
  9440. return nil
  9441. case chatsession.FieldBotID:
  9442. m.ResetBotID()
  9443. return nil
  9444. case chatsession.FieldBotType:
  9445. m.ResetBotType()
  9446. return nil
  9447. }
  9448. return fmt.Errorf("unknown ChatSession field %s", name)
  9449. }
  9450. // AddedEdges returns all edge names that were set/added in this mutation.
  9451. func (m *ChatSessionMutation) AddedEdges() []string {
  9452. edges := make([]string, 0, 0)
  9453. return edges
  9454. }
  9455. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9456. // name in this mutation.
  9457. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9458. return nil
  9459. }
  9460. // RemovedEdges returns all edge names that were removed in this mutation.
  9461. func (m *ChatSessionMutation) RemovedEdges() []string {
  9462. edges := make([]string, 0, 0)
  9463. return edges
  9464. }
  9465. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9466. // the given name in this mutation.
  9467. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9468. return nil
  9469. }
  9470. // ClearedEdges returns all edge names that were cleared in this mutation.
  9471. func (m *ChatSessionMutation) ClearedEdges() []string {
  9472. edges := make([]string, 0, 0)
  9473. return edges
  9474. }
  9475. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9476. // was cleared in this mutation.
  9477. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9478. return false
  9479. }
  9480. // ClearEdge clears the value of the edge with the given name. It returns an error
  9481. // if that edge is not defined in the schema.
  9482. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9483. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9484. }
  9485. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9486. // It returns an error if the edge is not defined in the schema.
  9487. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9488. return fmt.Errorf("unknown ChatSession edge %s", name)
  9489. }
  9490. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  9491. type ContactMutation struct {
  9492. config
  9493. op Op
  9494. typ string
  9495. id *uint64
  9496. created_at *time.Time
  9497. updated_at *time.Time
  9498. status *uint8
  9499. addstatus *int8
  9500. deleted_at *time.Time
  9501. wx_wxid *string
  9502. _type *int
  9503. add_type *int
  9504. wxid *string
  9505. account *string
  9506. nickname *string
  9507. markname *string
  9508. headimg *string
  9509. sex *int
  9510. addsex *int
  9511. starrole *string
  9512. dontseeit *int
  9513. adddontseeit *int
  9514. dontseeme *int
  9515. adddontseeme *int
  9516. lag *string
  9517. gid *string
  9518. gname *string
  9519. v3 *string
  9520. organization_id *uint64
  9521. addorganization_id *int64
  9522. ctype *uint64
  9523. addctype *int64
  9524. cage *int
  9525. addcage *int
  9526. cname *string
  9527. carea *string
  9528. cbirthday *string
  9529. cbirtharea *string
  9530. cidcard_no *string
  9531. ctitle *string
  9532. cc *string
  9533. phone *string
  9534. clearedFields map[string]struct{}
  9535. contact_relationships map[uint64]struct{}
  9536. removedcontact_relationships map[uint64]struct{}
  9537. clearedcontact_relationships bool
  9538. contact_messages map[uint64]struct{}
  9539. removedcontact_messages map[uint64]struct{}
  9540. clearedcontact_messages bool
  9541. done bool
  9542. oldValue func(context.Context) (*Contact, error)
  9543. predicates []predicate.Contact
  9544. }
  9545. var _ ent.Mutation = (*ContactMutation)(nil)
  9546. // contactOption allows management of the mutation configuration using functional options.
  9547. type contactOption func(*ContactMutation)
  9548. // newContactMutation creates new mutation for the Contact entity.
  9549. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  9550. m := &ContactMutation{
  9551. config: c,
  9552. op: op,
  9553. typ: TypeContact,
  9554. clearedFields: make(map[string]struct{}),
  9555. }
  9556. for _, opt := range opts {
  9557. opt(m)
  9558. }
  9559. return m
  9560. }
  9561. // withContactID sets the ID field of the mutation.
  9562. func withContactID(id uint64) contactOption {
  9563. return func(m *ContactMutation) {
  9564. var (
  9565. err error
  9566. once sync.Once
  9567. value *Contact
  9568. )
  9569. m.oldValue = func(ctx context.Context) (*Contact, error) {
  9570. once.Do(func() {
  9571. if m.done {
  9572. err = errors.New("querying old values post mutation is not allowed")
  9573. } else {
  9574. value, err = m.Client().Contact.Get(ctx, id)
  9575. }
  9576. })
  9577. return value, err
  9578. }
  9579. m.id = &id
  9580. }
  9581. }
  9582. // withContact sets the old Contact of the mutation.
  9583. func withContact(node *Contact) contactOption {
  9584. return func(m *ContactMutation) {
  9585. m.oldValue = func(context.Context) (*Contact, error) {
  9586. return node, nil
  9587. }
  9588. m.id = &node.ID
  9589. }
  9590. }
  9591. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9592. // executed in a transaction (ent.Tx), a transactional client is returned.
  9593. func (m ContactMutation) Client() *Client {
  9594. client := &Client{config: m.config}
  9595. client.init()
  9596. return client
  9597. }
  9598. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9599. // it returns an error otherwise.
  9600. func (m ContactMutation) Tx() (*Tx, error) {
  9601. if _, ok := m.driver.(*txDriver); !ok {
  9602. return nil, errors.New("ent: mutation is not running in a transaction")
  9603. }
  9604. tx := &Tx{config: m.config}
  9605. tx.init()
  9606. return tx, nil
  9607. }
  9608. // SetID sets the value of the id field. Note that this
  9609. // operation is only accepted on creation of Contact entities.
  9610. func (m *ContactMutation) SetID(id uint64) {
  9611. m.id = &id
  9612. }
  9613. // ID returns the ID value in the mutation. Note that the ID is only available
  9614. // if it was provided to the builder or after it was returned from the database.
  9615. func (m *ContactMutation) ID() (id uint64, exists bool) {
  9616. if m.id == nil {
  9617. return
  9618. }
  9619. return *m.id, true
  9620. }
  9621. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9622. // That means, if the mutation is applied within a transaction with an isolation level such
  9623. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9624. // or updated by the mutation.
  9625. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  9626. switch {
  9627. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9628. id, exists := m.ID()
  9629. if exists {
  9630. return []uint64{id}, nil
  9631. }
  9632. fallthrough
  9633. case m.op.Is(OpUpdate | OpDelete):
  9634. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  9635. default:
  9636. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9637. }
  9638. }
  9639. // SetCreatedAt sets the "created_at" field.
  9640. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  9641. m.created_at = &t
  9642. }
  9643. // CreatedAt returns the value of the "created_at" field in the mutation.
  9644. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  9645. v := m.created_at
  9646. if v == nil {
  9647. return
  9648. }
  9649. return *v, true
  9650. }
  9651. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  9652. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9654. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9655. if !m.op.Is(OpUpdateOne) {
  9656. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9657. }
  9658. if m.id == nil || m.oldValue == nil {
  9659. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9660. }
  9661. oldValue, err := m.oldValue(ctx)
  9662. if err != nil {
  9663. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9664. }
  9665. return oldValue.CreatedAt, nil
  9666. }
  9667. // ResetCreatedAt resets all changes to the "created_at" field.
  9668. func (m *ContactMutation) ResetCreatedAt() {
  9669. m.created_at = nil
  9670. }
  9671. // SetUpdatedAt sets the "updated_at" field.
  9672. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  9673. m.updated_at = &t
  9674. }
  9675. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9676. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  9677. v := m.updated_at
  9678. if v == nil {
  9679. return
  9680. }
  9681. return *v, true
  9682. }
  9683. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  9684. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9686. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9687. if !m.op.Is(OpUpdateOne) {
  9688. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9689. }
  9690. if m.id == nil || m.oldValue == nil {
  9691. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9692. }
  9693. oldValue, err := m.oldValue(ctx)
  9694. if err != nil {
  9695. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9696. }
  9697. return oldValue.UpdatedAt, nil
  9698. }
  9699. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9700. func (m *ContactMutation) ResetUpdatedAt() {
  9701. m.updated_at = nil
  9702. }
  9703. // SetStatus sets the "status" field.
  9704. func (m *ContactMutation) SetStatus(u uint8) {
  9705. m.status = &u
  9706. m.addstatus = nil
  9707. }
  9708. // Status returns the value of the "status" field in the mutation.
  9709. func (m *ContactMutation) Status() (r uint8, exists bool) {
  9710. v := m.status
  9711. if v == nil {
  9712. return
  9713. }
  9714. return *v, true
  9715. }
  9716. // OldStatus returns the old "status" field's value of the Contact entity.
  9717. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9719. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  9720. if !m.op.Is(OpUpdateOne) {
  9721. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9722. }
  9723. if m.id == nil || m.oldValue == nil {
  9724. return v, errors.New("OldStatus requires an ID field in the mutation")
  9725. }
  9726. oldValue, err := m.oldValue(ctx)
  9727. if err != nil {
  9728. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9729. }
  9730. return oldValue.Status, nil
  9731. }
  9732. // AddStatus adds u to the "status" field.
  9733. func (m *ContactMutation) AddStatus(u int8) {
  9734. if m.addstatus != nil {
  9735. *m.addstatus += u
  9736. } else {
  9737. m.addstatus = &u
  9738. }
  9739. }
  9740. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9741. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  9742. v := m.addstatus
  9743. if v == nil {
  9744. return
  9745. }
  9746. return *v, true
  9747. }
  9748. // ClearStatus clears the value of the "status" field.
  9749. func (m *ContactMutation) ClearStatus() {
  9750. m.status = nil
  9751. m.addstatus = nil
  9752. m.clearedFields[contact.FieldStatus] = struct{}{}
  9753. }
  9754. // StatusCleared returns if the "status" field was cleared in this mutation.
  9755. func (m *ContactMutation) StatusCleared() bool {
  9756. _, ok := m.clearedFields[contact.FieldStatus]
  9757. return ok
  9758. }
  9759. // ResetStatus resets all changes to the "status" field.
  9760. func (m *ContactMutation) ResetStatus() {
  9761. m.status = nil
  9762. m.addstatus = nil
  9763. delete(m.clearedFields, contact.FieldStatus)
  9764. }
  9765. // SetDeletedAt sets the "deleted_at" field.
  9766. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  9767. m.deleted_at = &t
  9768. }
  9769. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9770. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  9771. v := m.deleted_at
  9772. if v == nil {
  9773. return
  9774. }
  9775. return *v, true
  9776. }
  9777. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  9778. // If the Contact 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 *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9781. if !m.op.Is(OpUpdateOne) {
  9782. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9783. }
  9784. if m.id == nil || m.oldValue == nil {
  9785. return v, errors.New("OldDeletedAt 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 OldDeletedAt: %w", err)
  9790. }
  9791. return oldValue.DeletedAt, nil
  9792. }
  9793. // ClearDeletedAt clears the value of the "deleted_at" field.
  9794. func (m *ContactMutation) ClearDeletedAt() {
  9795. m.deleted_at = nil
  9796. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  9797. }
  9798. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9799. func (m *ContactMutation) DeletedAtCleared() bool {
  9800. _, ok := m.clearedFields[contact.FieldDeletedAt]
  9801. return ok
  9802. }
  9803. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9804. func (m *ContactMutation) ResetDeletedAt() {
  9805. m.deleted_at = nil
  9806. delete(m.clearedFields, contact.FieldDeletedAt)
  9807. }
  9808. // SetWxWxid sets the "wx_wxid" field.
  9809. func (m *ContactMutation) SetWxWxid(s string) {
  9810. m.wx_wxid = &s
  9811. }
  9812. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  9813. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  9814. v := m.wx_wxid
  9815. if v == nil {
  9816. return
  9817. }
  9818. return *v, true
  9819. }
  9820. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  9821. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9823. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  9824. if !m.op.Is(OpUpdateOne) {
  9825. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  9826. }
  9827. if m.id == nil || m.oldValue == nil {
  9828. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  9829. }
  9830. oldValue, err := m.oldValue(ctx)
  9831. if err != nil {
  9832. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  9833. }
  9834. return oldValue.WxWxid, nil
  9835. }
  9836. // ResetWxWxid resets all changes to the "wx_wxid" field.
  9837. func (m *ContactMutation) ResetWxWxid() {
  9838. m.wx_wxid = nil
  9839. }
  9840. // SetType sets the "type" field.
  9841. func (m *ContactMutation) SetType(i int) {
  9842. m._type = &i
  9843. m.add_type = nil
  9844. }
  9845. // GetType returns the value of the "type" field in the mutation.
  9846. func (m *ContactMutation) GetType() (r int, exists bool) {
  9847. v := m._type
  9848. if v == nil {
  9849. return
  9850. }
  9851. return *v, true
  9852. }
  9853. // OldType returns the old "type" field's value of the Contact entity.
  9854. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9856. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  9857. if !m.op.Is(OpUpdateOne) {
  9858. return v, errors.New("OldType is only allowed on UpdateOne operations")
  9859. }
  9860. if m.id == nil || m.oldValue == nil {
  9861. return v, errors.New("OldType requires an ID field in the mutation")
  9862. }
  9863. oldValue, err := m.oldValue(ctx)
  9864. if err != nil {
  9865. return v, fmt.Errorf("querying old value for OldType: %w", err)
  9866. }
  9867. return oldValue.Type, nil
  9868. }
  9869. // AddType adds i to the "type" field.
  9870. func (m *ContactMutation) AddType(i int) {
  9871. if m.add_type != nil {
  9872. *m.add_type += i
  9873. } else {
  9874. m.add_type = &i
  9875. }
  9876. }
  9877. // AddedType returns the value that was added to the "type" field in this mutation.
  9878. func (m *ContactMutation) AddedType() (r int, exists bool) {
  9879. v := m.add_type
  9880. if v == nil {
  9881. return
  9882. }
  9883. return *v, true
  9884. }
  9885. // ClearType clears the value of the "type" field.
  9886. func (m *ContactMutation) ClearType() {
  9887. m._type = nil
  9888. m.add_type = nil
  9889. m.clearedFields[contact.FieldType] = struct{}{}
  9890. }
  9891. // TypeCleared returns if the "type" field was cleared in this mutation.
  9892. func (m *ContactMutation) TypeCleared() bool {
  9893. _, ok := m.clearedFields[contact.FieldType]
  9894. return ok
  9895. }
  9896. // ResetType resets all changes to the "type" field.
  9897. func (m *ContactMutation) ResetType() {
  9898. m._type = nil
  9899. m.add_type = nil
  9900. delete(m.clearedFields, contact.FieldType)
  9901. }
  9902. // SetWxid sets the "wxid" field.
  9903. func (m *ContactMutation) SetWxid(s string) {
  9904. m.wxid = &s
  9905. }
  9906. // Wxid returns the value of the "wxid" field in the mutation.
  9907. func (m *ContactMutation) Wxid() (r string, exists bool) {
  9908. v := m.wxid
  9909. if v == nil {
  9910. return
  9911. }
  9912. return *v, true
  9913. }
  9914. // OldWxid returns the old "wxid" field's value of the Contact entity.
  9915. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9917. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  9918. if !m.op.Is(OpUpdateOne) {
  9919. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  9920. }
  9921. if m.id == nil || m.oldValue == nil {
  9922. return v, errors.New("OldWxid requires an ID field in the mutation")
  9923. }
  9924. oldValue, err := m.oldValue(ctx)
  9925. if err != nil {
  9926. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  9927. }
  9928. return oldValue.Wxid, nil
  9929. }
  9930. // ResetWxid resets all changes to the "wxid" field.
  9931. func (m *ContactMutation) ResetWxid() {
  9932. m.wxid = nil
  9933. }
  9934. // SetAccount sets the "account" field.
  9935. func (m *ContactMutation) SetAccount(s string) {
  9936. m.account = &s
  9937. }
  9938. // Account returns the value of the "account" field in the mutation.
  9939. func (m *ContactMutation) Account() (r string, exists bool) {
  9940. v := m.account
  9941. if v == nil {
  9942. return
  9943. }
  9944. return *v, true
  9945. }
  9946. // OldAccount returns the old "account" field's value of the Contact entity.
  9947. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9949. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  9950. if !m.op.Is(OpUpdateOne) {
  9951. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  9952. }
  9953. if m.id == nil || m.oldValue == nil {
  9954. return v, errors.New("OldAccount requires an ID field in the mutation")
  9955. }
  9956. oldValue, err := m.oldValue(ctx)
  9957. if err != nil {
  9958. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  9959. }
  9960. return oldValue.Account, nil
  9961. }
  9962. // ResetAccount resets all changes to the "account" field.
  9963. func (m *ContactMutation) ResetAccount() {
  9964. m.account = nil
  9965. }
  9966. // SetNickname sets the "nickname" field.
  9967. func (m *ContactMutation) SetNickname(s string) {
  9968. m.nickname = &s
  9969. }
  9970. // Nickname returns the value of the "nickname" field in the mutation.
  9971. func (m *ContactMutation) Nickname() (r string, exists bool) {
  9972. v := m.nickname
  9973. if v == nil {
  9974. return
  9975. }
  9976. return *v, true
  9977. }
  9978. // OldNickname returns the old "nickname" field's value of the Contact entity.
  9979. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  9980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9981. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  9982. if !m.op.Is(OpUpdateOne) {
  9983. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  9984. }
  9985. if m.id == nil || m.oldValue == nil {
  9986. return v, errors.New("OldNickname requires an ID field in the mutation")
  9987. }
  9988. oldValue, err := m.oldValue(ctx)
  9989. if err != nil {
  9990. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  9991. }
  9992. return oldValue.Nickname, nil
  9993. }
  9994. // ResetNickname resets all changes to the "nickname" field.
  9995. func (m *ContactMutation) ResetNickname() {
  9996. m.nickname = nil
  9997. }
  9998. // SetMarkname sets the "markname" field.
  9999. func (m *ContactMutation) SetMarkname(s string) {
  10000. m.markname = &s
  10001. }
  10002. // Markname returns the value of the "markname" field in the mutation.
  10003. func (m *ContactMutation) Markname() (r string, exists bool) {
  10004. v := m.markname
  10005. if v == nil {
  10006. return
  10007. }
  10008. return *v, true
  10009. }
  10010. // OldMarkname returns the old "markname" field's value of the Contact entity.
  10011. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10013. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  10014. if !m.op.Is(OpUpdateOne) {
  10015. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  10016. }
  10017. if m.id == nil || m.oldValue == nil {
  10018. return v, errors.New("OldMarkname requires an ID field in the mutation")
  10019. }
  10020. oldValue, err := m.oldValue(ctx)
  10021. if err != nil {
  10022. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  10023. }
  10024. return oldValue.Markname, nil
  10025. }
  10026. // ResetMarkname resets all changes to the "markname" field.
  10027. func (m *ContactMutation) ResetMarkname() {
  10028. m.markname = nil
  10029. }
  10030. // SetHeadimg sets the "headimg" field.
  10031. func (m *ContactMutation) SetHeadimg(s string) {
  10032. m.headimg = &s
  10033. }
  10034. // Headimg returns the value of the "headimg" field in the mutation.
  10035. func (m *ContactMutation) Headimg() (r string, exists bool) {
  10036. v := m.headimg
  10037. if v == nil {
  10038. return
  10039. }
  10040. return *v, true
  10041. }
  10042. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  10043. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10045. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  10046. if !m.op.Is(OpUpdateOne) {
  10047. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  10048. }
  10049. if m.id == nil || m.oldValue == nil {
  10050. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  10051. }
  10052. oldValue, err := m.oldValue(ctx)
  10053. if err != nil {
  10054. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  10055. }
  10056. return oldValue.Headimg, nil
  10057. }
  10058. // ResetHeadimg resets all changes to the "headimg" field.
  10059. func (m *ContactMutation) ResetHeadimg() {
  10060. m.headimg = nil
  10061. }
  10062. // SetSex sets the "sex" field.
  10063. func (m *ContactMutation) SetSex(i int) {
  10064. m.sex = &i
  10065. m.addsex = nil
  10066. }
  10067. // Sex returns the value of the "sex" field in the mutation.
  10068. func (m *ContactMutation) Sex() (r int, exists bool) {
  10069. v := m.sex
  10070. if v == nil {
  10071. return
  10072. }
  10073. return *v, true
  10074. }
  10075. // OldSex returns the old "sex" field's value of the Contact entity.
  10076. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10078. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  10079. if !m.op.Is(OpUpdateOne) {
  10080. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  10081. }
  10082. if m.id == nil || m.oldValue == nil {
  10083. return v, errors.New("OldSex requires an ID field in the mutation")
  10084. }
  10085. oldValue, err := m.oldValue(ctx)
  10086. if err != nil {
  10087. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  10088. }
  10089. return oldValue.Sex, nil
  10090. }
  10091. // AddSex adds i to the "sex" field.
  10092. func (m *ContactMutation) AddSex(i int) {
  10093. if m.addsex != nil {
  10094. *m.addsex += i
  10095. } else {
  10096. m.addsex = &i
  10097. }
  10098. }
  10099. // AddedSex returns the value that was added to the "sex" field in this mutation.
  10100. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  10101. v := m.addsex
  10102. if v == nil {
  10103. return
  10104. }
  10105. return *v, true
  10106. }
  10107. // ResetSex resets all changes to the "sex" field.
  10108. func (m *ContactMutation) ResetSex() {
  10109. m.sex = nil
  10110. m.addsex = nil
  10111. }
  10112. // SetStarrole sets the "starrole" field.
  10113. func (m *ContactMutation) SetStarrole(s string) {
  10114. m.starrole = &s
  10115. }
  10116. // Starrole returns the value of the "starrole" field in the mutation.
  10117. func (m *ContactMutation) Starrole() (r string, exists bool) {
  10118. v := m.starrole
  10119. if v == nil {
  10120. return
  10121. }
  10122. return *v, true
  10123. }
  10124. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  10125. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10127. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  10128. if !m.op.Is(OpUpdateOne) {
  10129. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  10130. }
  10131. if m.id == nil || m.oldValue == nil {
  10132. return v, errors.New("OldStarrole requires an ID field in the mutation")
  10133. }
  10134. oldValue, err := m.oldValue(ctx)
  10135. if err != nil {
  10136. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  10137. }
  10138. return oldValue.Starrole, nil
  10139. }
  10140. // ResetStarrole resets all changes to the "starrole" field.
  10141. func (m *ContactMutation) ResetStarrole() {
  10142. m.starrole = nil
  10143. }
  10144. // SetDontseeit sets the "dontseeit" field.
  10145. func (m *ContactMutation) SetDontseeit(i int) {
  10146. m.dontseeit = &i
  10147. m.adddontseeit = nil
  10148. }
  10149. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  10150. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  10151. v := m.dontseeit
  10152. if v == nil {
  10153. return
  10154. }
  10155. return *v, true
  10156. }
  10157. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  10158. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10160. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  10161. if !m.op.Is(OpUpdateOne) {
  10162. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  10163. }
  10164. if m.id == nil || m.oldValue == nil {
  10165. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  10166. }
  10167. oldValue, err := m.oldValue(ctx)
  10168. if err != nil {
  10169. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  10170. }
  10171. return oldValue.Dontseeit, nil
  10172. }
  10173. // AddDontseeit adds i to the "dontseeit" field.
  10174. func (m *ContactMutation) AddDontseeit(i int) {
  10175. if m.adddontseeit != nil {
  10176. *m.adddontseeit += i
  10177. } else {
  10178. m.adddontseeit = &i
  10179. }
  10180. }
  10181. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  10182. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  10183. v := m.adddontseeit
  10184. if v == nil {
  10185. return
  10186. }
  10187. return *v, true
  10188. }
  10189. // ResetDontseeit resets all changes to the "dontseeit" field.
  10190. func (m *ContactMutation) ResetDontseeit() {
  10191. m.dontseeit = nil
  10192. m.adddontseeit = nil
  10193. }
  10194. // SetDontseeme sets the "dontseeme" field.
  10195. func (m *ContactMutation) SetDontseeme(i int) {
  10196. m.dontseeme = &i
  10197. m.adddontseeme = nil
  10198. }
  10199. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  10200. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  10201. v := m.dontseeme
  10202. if v == nil {
  10203. return
  10204. }
  10205. return *v, true
  10206. }
  10207. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  10208. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10210. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  10211. if !m.op.Is(OpUpdateOne) {
  10212. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  10213. }
  10214. if m.id == nil || m.oldValue == nil {
  10215. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  10216. }
  10217. oldValue, err := m.oldValue(ctx)
  10218. if err != nil {
  10219. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  10220. }
  10221. return oldValue.Dontseeme, nil
  10222. }
  10223. // AddDontseeme adds i to the "dontseeme" field.
  10224. func (m *ContactMutation) AddDontseeme(i int) {
  10225. if m.adddontseeme != nil {
  10226. *m.adddontseeme += i
  10227. } else {
  10228. m.adddontseeme = &i
  10229. }
  10230. }
  10231. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  10232. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  10233. v := m.adddontseeme
  10234. if v == nil {
  10235. return
  10236. }
  10237. return *v, true
  10238. }
  10239. // ResetDontseeme resets all changes to the "dontseeme" field.
  10240. func (m *ContactMutation) ResetDontseeme() {
  10241. m.dontseeme = nil
  10242. m.adddontseeme = nil
  10243. }
  10244. // SetLag sets the "lag" field.
  10245. func (m *ContactMutation) SetLag(s string) {
  10246. m.lag = &s
  10247. }
  10248. // Lag returns the value of the "lag" field in the mutation.
  10249. func (m *ContactMutation) Lag() (r string, exists bool) {
  10250. v := m.lag
  10251. if v == nil {
  10252. return
  10253. }
  10254. return *v, true
  10255. }
  10256. // OldLag returns the old "lag" field's value of the Contact entity.
  10257. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10259. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  10260. if !m.op.Is(OpUpdateOne) {
  10261. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  10262. }
  10263. if m.id == nil || m.oldValue == nil {
  10264. return v, errors.New("OldLag requires an ID field in the mutation")
  10265. }
  10266. oldValue, err := m.oldValue(ctx)
  10267. if err != nil {
  10268. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  10269. }
  10270. return oldValue.Lag, nil
  10271. }
  10272. // ResetLag resets all changes to the "lag" field.
  10273. func (m *ContactMutation) ResetLag() {
  10274. m.lag = nil
  10275. }
  10276. // SetGid sets the "gid" field.
  10277. func (m *ContactMutation) SetGid(s string) {
  10278. m.gid = &s
  10279. }
  10280. // Gid returns the value of the "gid" field in the mutation.
  10281. func (m *ContactMutation) Gid() (r string, exists bool) {
  10282. v := m.gid
  10283. if v == nil {
  10284. return
  10285. }
  10286. return *v, true
  10287. }
  10288. // OldGid returns the old "gid" field's value of the Contact entity.
  10289. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10291. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  10292. if !m.op.Is(OpUpdateOne) {
  10293. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  10294. }
  10295. if m.id == nil || m.oldValue == nil {
  10296. return v, errors.New("OldGid requires an ID field in the mutation")
  10297. }
  10298. oldValue, err := m.oldValue(ctx)
  10299. if err != nil {
  10300. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  10301. }
  10302. return oldValue.Gid, nil
  10303. }
  10304. // ResetGid resets all changes to the "gid" field.
  10305. func (m *ContactMutation) ResetGid() {
  10306. m.gid = nil
  10307. }
  10308. // SetGname sets the "gname" field.
  10309. func (m *ContactMutation) SetGname(s string) {
  10310. m.gname = &s
  10311. }
  10312. // Gname returns the value of the "gname" field in the mutation.
  10313. func (m *ContactMutation) Gname() (r string, exists bool) {
  10314. v := m.gname
  10315. if v == nil {
  10316. return
  10317. }
  10318. return *v, true
  10319. }
  10320. // OldGname returns the old "gname" field's value of the Contact entity.
  10321. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10323. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  10324. if !m.op.Is(OpUpdateOne) {
  10325. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  10326. }
  10327. if m.id == nil || m.oldValue == nil {
  10328. return v, errors.New("OldGname requires an ID field in the mutation")
  10329. }
  10330. oldValue, err := m.oldValue(ctx)
  10331. if err != nil {
  10332. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  10333. }
  10334. return oldValue.Gname, nil
  10335. }
  10336. // ResetGname resets all changes to the "gname" field.
  10337. func (m *ContactMutation) ResetGname() {
  10338. m.gname = nil
  10339. }
  10340. // SetV3 sets the "v3" field.
  10341. func (m *ContactMutation) SetV3(s string) {
  10342. m.v3 = &s
  10343. }
  10344. // V3 returns the value of the "v3" field in the mutation.
  10345. func (m *ContactMutation) V3() (r string, exists bool) {
  10346. v := m.v3
  10347. if v == nil {
  10348. return
  10349. }
  10350. return *v, true
  10351. }
  10352. // OldV3 returns the old "v3" field's value of the Contact entity.
  10353. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10355. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  10356. if !m.op.Is(OpUpdateOne) {
  10357. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  10358. }
  10359. if m.id == nil || m.oldValue == nil {
  10360. return v, errors.New("OldV3 requires an ID field in the mutation")
  10361. }
  10362. oldValue, err := m.oldValue(ctx)
  10363. if err != nil {
  10364. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  10365. }
  10366. return oldValue.V3, nil
  10367. }
  10368. // ResetV3 resets all changes to the "v3" field.
  10369. func (m *ContactMutation) ResetV3() {
  10370. m.v3 = nil
  10371. }
  10372. // SetOrganizationID sets the "organization_id" field.
  10373. func (m *ContactMutation) SetOrganizationID(u uint64) {
  10374. m.organization_id = &u
  10375. m.addorganization_id = nil
  10376. }
  10377. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10378. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  10379. v := m.organization_id
  10380. if v == nil {
  10381. return
  10382. }
  10383. return *v, true
  10384. }
  10385. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  10386. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10388. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10389. if !m.op.Is(OpUpdateOne) {
  10390. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10391. }
  10392. if m.id == nil || m.oldValue == nil {
  10393. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10394. }
  10395. oldValue, err := m.oldValue(ctx)
  10396. if err != nil {
  10397. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10398. }
  10399. return oldValue.OrganizationID, nil
  10400. }
  10401. // AddOrganizationID adds u to the "organization_id" field.
  10402. func (m *ContactMutation) AddOrganizationID(u int64) {
  10403. if m.addorganization_id != nil {
  10404. *m.addorganization_id += u
  10405. } else {
  10406. m.addorganization_id = &u
  10407. }
  10408. }
  10409. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10410. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  10411. v := m.addorganization_id
  10412. if v == nil {
  10413. return
  10414. }
  10415. return *v, true
  10416. }
  10417. // ClearOrganizationID clears the value of the "organization_id" field.
  10418. func (m *ContactMutation) ClearOrganizationID() {
  10419. m.organization_id = nil
  10420. m.addorganization_id = nil
  10421. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  10422. }
  10423. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10424. func (m *ContactMutation) OrganizationIDCleared() bool {
  10425. _, ok := m.clearedFields[contact.FieldOrganizationID]
  10426. return ok
  10427. }
  10428. // ResetOrganizationID resets all changes to the "organization_id" field.
  10429. func (m *ContactMutation) ResetOrganizationID() {
  10430. m.organization_id = nil
  10431. m.addorganization_id = nil
  10432. delete(m.clearedFields, contact.FieldOrganizationID)
  10433. }
  10434. // SetCtype sets the "ctype" field.
  10435. func (m *ContactMutation) SetCtype(u uint64) {
  10436. m.ctype = &u
  10437. m.addctype = nil
  10438. }
  10439. // Ctype returns the value of the "ctype" field in the mutation.
  10440. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  10441. v := m.ctype
  10442. if v == nil {
  10443. return
  10444. }
  10445. return *v, true
  10446. }
  10447. // OldCtype returns the old "ctype" field's value of the Contact entity.
  10448. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10450. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  10451. if !m.op.Is(OpUpdateOne) {
  10452. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  10453. }
  10454. if m.id == nil || m.oldValue == nil {
  10455. return v, errors.New("OldCtype requires an ID field in the mutation")
  10456. }
  10457. oldValue, err := m.oldValue(ctx)
  10458. if err != nil {
  10459. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  10460. }
  10461. return oldValue.Ctype, nil
  10462. }
  10463. // AddCtype adds u to the "ctype" field.
  10464. func (m *ContactMutation) AddCtype(u int64) {
  10465. if m.addctype != nil {
  10466. *m.addctype += u
  10467. } else {
  10468. m.addctype = &u
  10469. }
  10470. }
  10471. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  10472. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  10473. v := m.addctype
  10474. if v == nil {
  10475. return
  10476. }
  10477. return *v, true
  10478. }
  10479. // ResetCtype resets all changes to the "ctype" field.
  10480. func (m *ContactMutation) ResetCtype() {
  10481. m.ctype = nil
  10482. m.addctype = nil
  10483. }
  10484. // SetCage sets the "cage" field.
  10485. func (m *ContactMutation) SetCage(i int) {
  10486. m.cage = &i
  10487. m.addcage = nil
  10488. }
  10489. // Cage returns the value of the "cage" field in the mutation.
  10490. func (m *ContactMutation) Cage() (r int, exists bool) {
  10491. v := m.cage
  10492. if v == nil {
  10493. return
  10494. }
  10495. return *v, true
  10496. }
  10497. // OldCage returns the old "cage" field's value of the Contact entity.
  10498. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10500. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  10501. if !m.op.Is(OpUpdateOne) {
  10502. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  10503. }
  10504. if m.id == nil || m.oldValue == nil {
  10505. return v, errors.New("OldCage requires an ID field in the mutation")
  10506. }
  10507. oldValue, err := m.oldValue(ctx)
  10508. if err != nil {
  10509. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  10510. }
  10511. return oldValue.Cage, nil
  10512. }
  10513. // AddCage adds i to the "cage" field.
  10514. func (m *ContactMutation) AddCage(i int) {
  10515. if m.addcage != nil {
  10516. *m.addcage += i
  10517. } else {
  10518. m.addcage = &i
  10519. }
  10520. }
  10521. // AddedCage returns the value that was added to the "cage" field in this mutation.
  10522. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  10523. v := m.addcage
  10524. if v == nil {
  10525. return
  10526. }
  10527. return *v, true
  10528. }
  10529. // ResetCage resets all changes to the "cage" field.
  10530. func (m *ContactMutation) ResetCage() {
  10531. m.cage = nil
  10532. m.addcage = nil
  10533. }
  10534. // SetCname sets the "cname" field.
  10535. func (m *ContactMutation) SetCname(s string) {
  10536. m.cname = &s
  10537. }
  10538. // Cname returns the value of the "cname" field in the mutation.
  10539. func (m *ContactMutation) Cname() (r string, exists bool) {
  10540. v := m.cname
  10541. if v == nil {
  10542. return
  10543. }
  10544. return *v, true
  10545. }
  10546. // OldCname returns the old "cname" field's value of the Contact entity.
  10547. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10549. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  10550. if !m.op.Is(OpUpdateOne) {
  10551. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  10552. }
  10553. if m.id == nil || m.oldValue == nil {
  10554. return v, errors.New("OldCname requires an ID field in the mutation")
  10555. }
  10556. oldValue, err := m.oldValue(ctx)
  10557. if err != nil {
  10558. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  10559. }
  10560. return oldValue.Cname, nil
  10561. }
  10562. // ResetCname resets all changes to the "cname" field.
  10563. func (m *ContactMutation) ResetCname() {
  10564. m.cname = nil
  10565. }
  10566. // SetCarea sets the "carea" field.
  10567. func (m *ContactMutation) SetCarea(s string) {
  10568. m.carea = &s
  10569. }
  10570. // Carea returns the value of the "carea" field in the mutation.
  10571. func (m *ContactMutation) Carea() (r string, exists bool) {
  10572. v := m.carea
  10573. if v == nil {
  10574. return
  10575. }
  10576. return *v, true
  10577. }
  10578. // OldCarea returns the old "carea" field's value of the Contact entity.
  10579. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10581. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  10582. if !m.op.Is(OpUpdateOne) {
  10583. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  10584. }
  10585. if m.id == nil || m.oldValue == nil {
  10586. return v, errors.New("OldCarea requires an ID field in the mutation")
  10587. }
  10588. oldValue, err := m.oldValue(ctx)
  10589. if err != nil {
  10590. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  10591. }
  10592. return oldValue.Carea, nil
  10593. }
  10594. // ResetCarea resets all changes to the "carea" field.
  10595. func (m *ContactMutation) ResetCarea() {
  10596. m.carea = nil
  10597. }
  10598. // SetCbirthday sets the "cbirthday" field.
  10599. func (m *ContactMutation) SetCbirthday(s string) {
  10600. m.cbirthday = &s
  10601. }
  10602. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  10603. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  10604. v := m.cbirthday
  10605. if v == nil {
  10606. return
  10607. }
  10608. return *v, true
  10609. }
  10610. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  10611. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10613. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  10614. if !m.op.Is(OpUpdateOne) {
  10615. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  10616. }
  10617. if m.id == nil || m.oldValue == nil {
  10618. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  10619. }
  10620. oldValue, err := m.oldValue(ctx)
  10621. if err != nil {
  10622. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  10623. }
  10624. return oldValue.Cbirthday, nil
  10625. }
  10626. // ResetCbirthday resets all changes to the "cbirthday" field.
  10627. func (m *ContactMutation) ResetCbirthday() {
  10628. m.cbirthday = nil
  10629. }
  10630. // SetCbirtharea sets the "cbirtharea" field.
  10631. func (m *ContactMutation) SetCbirtharea(s string) {
  10632. m.cbirtharea = &s
  10633. }
  10634. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  10635. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  10636. v := m.cbirtharea
  10637. if v == nil {
  10638. return
  10639. }
  10640. return *v, true
  10641. }
  10642. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  10643. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10645. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  10646. if !m.op.Is(OpUpdateOne) {
  10647. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  10648. }
  10649. if m.id == nil || m.oldValue == nil {
  10650. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  10651. }
  10652. oldValue, err := m.oldValue(ctx)
  10653. if err != nil {
  10654. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  10655. }
  10656. return oldValue.Cbirtharea, nil
  10657. }
  10658. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  10659. func (m *ContactMutation) ResetCbirtharea() {
  10660. m.cbirtharea = nil
  10661. }
  10662. // SetCidcardNo sets the "cidcard_no" field.
  10663. func (m *ContactMutation) SetCidcardNo(s string) {
  10664. m.cidcard_no = &s
  10665. }
  10666. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  10667. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  10668. v := m.cidcard_no
  10669. if v == nil {
  10670. return
  10671. }
  10672. return *v, true
  10673. }
  10674. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  10675. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10677. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  10678. if !m.op.Is(OpUpdateOne) {
  10679. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  10680. }
  10681. if m.id == nil || m.oldValue == nil {
  10682. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  10683. }
  10684. oldValue, err := m.oldValue(ctx)
  10685. if err != nil {
  10686. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  10687. }
  10688. return oldValue.CidcardNo, nil
  10689. }
  10690. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  10691. func (m *ContactMutation) ResetCidcardNo() {
  10692. m.cidcard_no = nil
  10693. }
  10694. // SetCtitle sets the "ctitle" field.
  10695. func (m *ContactMutation) SetCtitle(s string) {
  10696. m.ctitle = &s
  10697. }
  10698. // Ctitle returns the value of the "ctitle" field in the mutation.
  10699. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  10700. v := m.ctitle
  10701. if v == nil {
  10702. return
  10703. }
  10704. return *v, true
  10705. }
  10706. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  10707. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10709. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  10710. if !m.op.Is(OpUpdateOne) {
  10711. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  10712. }
  10713. if m.id == nil || m.oldValue == nil {
  10714. return v, errors.New("OldCtitle requires an ID field in the mutation")
  10715. }
  10716. oldValue, err := m.oldValue(ctx)
  10717. if err != nil {
  10718. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  10719. }
  10720. return oldValue.Ctitle, nil
  10721. }
  10722. // ResetCtitle resets all changes to the "ctitle" field.
  10723. func (m *ContactMutation) ResetCtitle() {
  10724. m.ctitle = nil
  10725. }
  10726. // SetCc sets the "cc" field.
  10727. func (m *ContactMutation) SetCc(s string) {
  10728. m.cc = &s
  10729. }
  10730. // Cc returns the value of the "cc" field in the mutation.
  10731. func (m *ContactMutation) Cc() (r string, exists bool) {
  10732. v := m.cc
  10733. if v == nil {
  10734. return
  10735. }
  10736. return *v, true
  10737. }
  10738. // OldCc returns the old "cc" field's value of the Contact entity.
  10739. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10741. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  10742. if !m.op.Is(OpUpdateOne) {
  10743. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  10744. }
  10745. if m.id == nil || m.oldValue == nil {
  10746. return v, errors.New("OldCc requires an ID field in the mutation")
  10747. }
  10748. oldValue, err := m.oldValue(ctx)
  10749. if err != nil {
  10750. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  10751. }
  10752. return oldValue.Cc, nil
  10753. }
  10754. // ResetCc resets all changes to the "cc" field.
  10755. func (m *ContactMutation) ResetCc() {
  10756. m.cc = nil
  10757. }
  10758. // SetPhone sets the "phone" field.
  10759. func (m *ContactMutation) SetPhone(s string) {
  10760. m.phone = &s
  10761. }
  10762. // Phone returns the value of the "phone" field in the mutation.
  10763. func (m *ContactMutation) Phone() (r string, exists bool) {
  10764. v := m.phone
  10765. if v == nil {
  10766. return
  10767. }
  10768. return *v, true
  10769. }
  10770. // OldPhone returns the old "phone" field's value of the Contact entity.
  10771. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10773. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  10774. if !m.op.Is(OpUpdateOne) {
  10775. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  10776. }
  10777. if m.id == nil || m.oldValue == nil {
  10778. return v, errors.New("OldPhone requires an ID field in the mutation")
  10779. }
  10780. oldValue, err := m.oldValue(ctx)
  10781. if err != nil {
  10782. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  10783. }
  10784. return oldValue.Phone, nil
  10785. }
  10786. // ResetPhone resets all changes to the "phone" field.
  10787. func (m *ContactMutation) ResetPhone() {
  10788. m.phone = nil
  10789. }
  10790. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  10791. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  10792. if m.contact_relationships == nil {
  10793. m.contact_relationships = make(map[uint64]struct{})
  10794. }
  10795. for i := range ids {
  10796. m.contact_relationships[ids[i]] = struct{}{}
  10797. }
  10798. }
  10799. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  10800. func (m *ContactMutation) ClearContactRelationships() {
  10801. m.clearedcontact_relationships = true
  10802. }
  10803. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  10804. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  10805. return m.clearedcontact_relationships
  10806. }
  10807. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  10808. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  10809. if m.removedcontact_relationships == nil {
  10810. m.removedcontact_relationships = make(map[uint64]struct{})
  10811. }
  10812. for i := range ids {
  10813. delete(m.contact_relationships, ids[i])
  10814. m.removedcontact_relationships[ids[i]] = struct{}{}
  10815. }
  10816. }
  10817. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  10818. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  10819. for id := range m.removedcontact_relationships {
  10820. ids = append(ids, id)
  10821. }
  10822. return
  10823. }
  10824. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  10825. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  10826. for id := range m.contact_relationships {
  10827. ids = append(ids, id)
  10828. }
  10829. return
  10830. }
  10831. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  10832. func (m *ContactMutation) ResetContactRelationships() {
  10833. m.contact_relationships = nil
  10834. m.clearedcontact_relationships = false
  10835. m.removedcontact_relationships = nil
  10836. }
  10837. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  10838. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  10839. if m.contact_messages == nil {
  10840. m.contact_messages = make(map[uint64]struct{})
  10841. }
  10842. for i := range ids {
  10843. m.contact_messages[ids[i]] = struct{}{}
  10844. }
  10845. }
  10846. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  10847. func (m *ContactMutation) ClearContactMessages() {
  10848. m.clearedcontact_messages = true
  10849. }
  10850. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  10851. func (m *ContactMutation) ContactMessagesCleared() bool {
  10852. return m.clearedcontact_messages
  10853. }
  10854. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  10855. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  10856. if m.removedcontact_messages == nil {
  10857. m.removedcontact_messages = make(map[uint64]struct{})
  10858. }
  10859. for i := range ids {
  10860. delete(m.contact_messages, ids[i])
  10861. m.removedcontact_messages[ids[i]] = struct{}{}
  10862. }
  10863. }
  10864. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  10865. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  10866. for id := range m.removedcontact_messages {
  10867. ids = append(ids, id)
  10868. }
  10869. return
  10870. }
  10871. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  10872. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  10873. for id := range m.contact_messages {
  10874. ids = append(ids, id)
  10875. }
  10876. return
  10877. }
  10878. // ResetContactMessages resets all changes to the "contact_messages" edge.
  10879. func (m *ContactMutation) ResetContactMessages() {
  10880. m.contact_messages = nil
  10881. m.clearedcontact_messages = false
  10882. m.removedcontact_messages = nil
  10883. }
  10884. // Where appends a list predicates to the ContactMutation builder.
  10885. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  10886. m.predicates = append(m.predicates, ps...)
  10887. }
  10888. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  10889. // users can use type-assertion to append predicates that do not depend on any generated package.
  10890. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  10891. p := make([]predicate.Contact, len(ps))
  10892. for i := range ps {
  10893. p[i] = ps[i]
  10894. }
  10895. m.Where(p...)
  10896. }
  10897. // Op returns the operation name.
  10898. func (m *ContactMutation) Op() Op {
  10899. return m.op
  10900. }
  10901. // SetOp allows setting the mutation operation.
  10902. func (m *ContactMutation) SetOp(op Op) {
  10903. m.op = op
  10904. }
  10905. // Type returns the node type of this mutation (Contact).
  10906. func (m *ContactMutation) Type() string {
  10907. return m.typ
  10908. }
  10909. // Fields returns all fields that were changed during this mutation. Note that in
  10910. // order to get all numeric fields that were incremented/decremented, call
  10911. // AddedFields().
  10912. func (m *ContactMutation) Fields() []string {
  10913. fields := make([]string, 0, 30)
  10914. if m.created_at != nil {
  10915. fields = append(fields, contact.FieldCreatedAt)
  10916. }
  10917. if m.updated_at != nil {
  10918. fields = append(fields, contact.FieldUpdatedAt)
  10919. }
  10920. if m.status != nil {
  10921. fields = append(fields, contact.FieldStatus)
  10922. }
  10923. if m.deleted_at != nil {
  10924. fields = append(fields, contact.FieldDeletedAt)
  10925. }
  10926. if m.wx_wxid != nil {
  10927. fields = append(fields, contact.FieldWxWxid)
  10928. }
  10929. if m._type != nil {
  10930. fields = append(fields, contact.FieldType)
  10931. }
  10932. if m.wxid != nil {
  10933. fields = append(fields, contact.FieldWxid)
  10934. }
  10935. if m.account != nil {
  10936. fields = append(fields, contact.FieldAccount)
  10937. }
  10938. if m.nickname != nil {
  10939. fields = append(fields, contact.FieldNickname)
  10940. }
  10941. if m.markname != nil {
  10942. fields = append(fields, contact.FieldMarkname)
  10943. }
  10944. if m.headimg != nil {
  10945. fields = append(fields, contact.FieldHeadimg)
  10946. }
  10947. if m.sex != nil {
  10948. fields = append(fields, contact.FieldSex)
  10949. }
  10950. if m.starrole != nil {
  10951. fields = append(fields, contact.FieldStarrole)
  10952. }
  10953. if m.dontseeit != nil {
  10954. fields = append(fields, contact.FieldDontseeit)
  10955. }
  10956. if m.dontseeme != nil {
  10957. fields = append(fields, contact.FieldDontseeme)
  10958. }
  10959. if m.lag != nil {
  10960. fields = append(fields, contact.FieldLag)
  10961. }
  10962. if m.gid != nil {
  10963. fields = append(fields, contact.FieldGid)
  10964. }
  10965. if m.gname != nil {
  10966. fields = append(fields, contact.FieldGname)
  10967. }
  10968. if m.v3 != nil {
  10969. fields = append(fields, contact.FieldV3)
  10970. }
  10971. if m.organization_id != nil {
  10972. fields = append(fields, contact.FieldOrganizationID)
  10973. }
  10974. if m.ctype != nil {
  10975. fields = append(fields, contact.FieldCtype)
  10976. }
  10977. if m.cage != nil {
  10978. fields = append(fields, contact.FieldCage)
  10979. }
  10980. if m.cname != nil {
  10981. fields = append(fields, contact.FieldCname)
  10982. }
  10983. if m.carea != nil {
  10984. fields = append(fields, contact.FieldCarea)
  10985. }
  10986. if m.cbirthday != nil {
  10987. fields = append(fields, contact.FieldCbirthday)
  10988. }
  10989. if m.cbirtharea != nil {
  10990. fields = append(fields, contact.FieldCbirtharea)
  10991. }
  10992. if m.cidcard_no != nil {
  10993. fields = append(fields, contact.FieldCidcardNo)
  10994. }
  10995. if m.ctitle != nil {
  10996. fields = append(fields, contact.FieldCtitle)
  10997. }
  10998. if m.cc != nil {
  10999. fields = append(fields, contact.FieldCc)
  11000. }
  11001. if m.phone != nil {
  11002. fields = append(fields, contact.FieldPhone)
  11003. }
  11004. return fields
  11005. }
  11006. // Field returns the value of a field with the given name. The second boolean
  11007. // return value indicates that this field was not set, or was not defined in the
  11008. // schema.
  11009. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  11010. switch name {
  11011. case contact.FieldCreatedAt:
  11012. return m.CreatedAt()
  11013. case contact.FieldUpdatedAt:
  11014. return m.UpdatedAt()
  11015. case contact.FieldStatus:
  11016. return m.Status()
  11017. case contact.FieldDeletedAt:
  11018. return m.DeletedAt()
  11019. case contact.FieldWxWxid:
  11020. return m.WxWxid()
  11021. case contact.FieldType:
  11022. return m.GetType()
  11023. case contact.FieldWxid:
  11024. return m.Wxid()
  11025. case contact.FieldAccount:
  11026. return m.Account()
  11027. case contact.FieldNickname:
  11028. return m.Nickname()
  11029. case contact.FieldMarkname:
  11030. return m.Markname()
  11031. case contact.FieldHeadimg:
  11032. return m.Headimg()
  11033. case contact.FieldSex:
  11034. return m.Sex()
  11035. case contact.FieldStarrole:
  11036. return m.Starrole()
  11037. case contact.FieldDontseeit:
  11038. return m.Dontseeit()
  11039. case contact.FieldDontseeme:
  11040. return m.Dontseeme()
  11041. case contact.FieldLag:
  11042. return m.Lag()
  11043. case contact.FieldGid:
  11044. return m.Gid()
  11045. case contact.FieldGname:
  11046. return m.Gname()
  11047. case contact.FieldV3:
  11048. return m.V3()
  11049. case contact.FieldOrganizationID:
  11050. return m.OrganizationID()
  11051. case contact.FieldCtype:
  11052. return m.Ctype()
  11053. case contact.FieldCage:
  11054. return m.Cage()
  11055. case contact.FieldCname:
  11056. return m.Cname()
  11057. case contact.FieldCarea:
  11058. return m.Carea()
  11059. case contact.FieldCbirthday:
  11060. return m.Cbirthday()
  11061. case contact.FieldCbirtharea:
  11062. return m.Cbirtharea()
  11063. case contact.FieldCidcardNo:
  11064. return m.CidcardNo()
  11065. case contact.FieldCtitle:
  11066. return m.Ctitle()
  11067. case contact.FieldCc:
  11068. return m.Cc()
  11069. case contact.FieldPhone:
  11070. return m.Phone()
  11071. }
  11072. return nil, false
  11073. }
  11074. // OldField returns the old value of the field from the database. An error is
  11075. // returned if the mutation operation is not UpdateOne, or the query to the
  11076. // database failed.
  11077. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11078. switch name {
  11079. case contact.FieldCreatedAt:
  11080. return m.OldCreatedAt(ctx)
  11081. case contact.FieldUpdatedAt:
  11082. return m.OldUpdatedAt(ctx)
  11083. case contact.FieldStatus:
  11084. return m.OldStatus(ctx)
  11085. case contact.FieldDeletedAt:
  11086. return m.OldDeletedAt(ctx)
  11087. case contact.FieldWxWxid:
  11088. return m.OldWxWxid(ctx)
  11089. case contact.FieldType:
  11090. return m.OldType(ctx)
  11091. case contact.FieldWxid:
  11092. return m.OldWxid(ctx)
  11093. case contact.FieldAccount:
  11094. return m.OldAccount(ctx)
  11095. case contact.FieldNickname:
  11096. return m.OldNickname(ctx)
  11097. case contact.FieldMarkname:
  11098. return m.OldMarkname(ctx)
  11099. case contact.FieldHeadimg:
  11100. return m.OldHeadimg(ctx)
  11101. case contact.FieldSex:
  11102. return m.OldSex(ctx)
  11103. case contact.FieldStarrole:
  11104. return m.OldStarrole(ctx)
  11105. case contact.FieldDontseeit:
  11106. return m.OldDontseeit(ctx)
  11107. case contact.FieldDontseeme:
  11108. return m.OldDontseeme(ctx)
  11109. case contact.FieldLag:
  11110. return m.OldLag(ctx)
  11111. case contact.FieldGid:
  11112. return m.OldGid(ctx)
  11113. case contact.FieldGname:
  11114. return m.OldGname(ctx)
  11115. case contact.FieldV3:
  11116. return m.OldV3(ctx)
  11117. case contact.FieldOrganizationID:
  11118. return m.OldOrganizationID(ctx)
  11119. case contact.FieldCtype:
  11120. return m.OldCtype(ctx)
  11121. case contact.FieldCage:
  11122. return m.OldCage(ctx)
  11123. case contact.FieldCname:
  11124. return m.OldCname(ctx)
  11125. case contact.FieldCarea:
  11126. return m.OldCarea(ctx)
  11127. case contact.FieldCbirthday:
  11128. return m.OldCbirthday(ctx)
  11129. case contact.FieldCbirtharea:
  11130. return m.OldCbirtharea(ctx)
  11131. case contact.FieldCidcardNo:
  11132. return m.OldCidcardNo(ctx)
  11133. case contact.FieldCtitle:
  11134. return m.OldCtitle(ctx)
  11135. case contact.FieldCc:
  11136. return m.OldCc(ctx)
  11137. case contact.FieldPhone:
  11138. return m.OldPhone(ctx)
  11139. }
  11140. return nil, fmt.Errorf("unknown Contact field %s", name)
  11141. }
  11142. // SetField sets the value of a field with the given name. It returns an error if
  11143. // the field is not defined in the schema, or if the type mismatched the field
  11144. // type.
  11145. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  11146. switch name {
  11147. case contact.FieldCreatedAt:
  11148. v, ok := value.(time.Time)
  11149. if !ok {
  11150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11151. }
  11152. m.SetCreatedAt(v)
  11153. return nil
  11154. case contact.FieldUpdatedAt:
  11155. v, ok := value.(time.Time)
  11156. if !ok {
  11157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11158. }
  11159. m.SetUpdatedAt(v)
  11160. return nil
  11161. case contact.FieldStatus:
  11162. v, ok := value.(uint8)
  11163. if !ok {
  11164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11165. }
  11166. m.SetStatus(v)
  11167. return nil
  11168. case contact.FieldDeletedAt:
  11169. v, ok := value.(time.Time)
  11170. if !ok {
  11171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11172. }
  11173. m.SetDeletedAt(v)
  11174. return nil
  11175. case contact.FieldWxWxid:
  11176. v, ok := value.(string)
  11177. if !ok {
  11178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11179. }
  11180. m.SetWxWxid(v)
  11181. return nil
  11182. case contact.FieldType:
  11183. v, ok := value.(int)
  11184. if !ok {
  11185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11186. }
  11187. m.SetType(v)
  11188. return nil
  11189. case contact.FieldWxid:
  11190. v, ok := value.(string)
  11191. if !ok {
  11192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11193. }
  11194. m.SetWxid(v)
  11195. return nil
  11196. case contact.FieldAccount:
  11197. v, ok := value.(string)
  11198. if !ok {
  11199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11200. }
  11201. m.SetAccount(v)
  11202. return nil
  11203. case contact.FieldNickname:
  11204. v, ok := value.(string)
  11205. if !ok {
  11206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11207. }
  11208. m.SetNickname(v)
  11209. return nil
  11210. case contact.FieldMarkname:
  11211. v, ok := value.(string)
  11212. if !ok {
  11213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11214. }
  11215. m.SetMarkname(v)
  11216. return nil
  11217. case contact.FieldHeadimg:
  11218. v, ok := value.(string)
  11219. if !ok {
  11220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11221. }
  11222. m.SetHeadimg(v)
  11223. return nil
  11224. case contact.FieldSex:
  11225. v, ok := value.(int)
  11226. if !ok {
  11227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11228. }
  11229. m.SetSex(v)
  11230. return nil
  11231. case contact.FieldStarrole:
  11232. v, ok := value.(string)
  11233. if !ok {
  11234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11235. }
  11236. m.SetStarrole(v)
  11237. return nil
  11238. case contact.FieldDontseeit:
  11239. v, ok := value.(int)
  11240. if !ok {
  11241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11242. }
  11243. m.SetDontseeit(v)
  11244. return nil
  11245. case contact.FieldDontseeme:
  11246. v, ok := value.(int)
  11247. if !ok {
  11248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11249. }
  11250. m.SetDontseeme(v)
  11251. return nil
  11252. case contact.FieldLag:
  11253. v, ok := value.(string)
  11254. if !ok {
  11255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11256. }
  11257. m.SetLag(v)
  11258. return nil
  11259. case contact.FieldGid:
  11260. v, ok := value.(string)
  11261. if !ok {
  11262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11263. }
  11264. m.SetGid(v)
  11265. return nil
  11266. case contact.FieldGname:
  11267. v, ok := value.(string)
  11268. if !ok {
  11269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11270. }
  11271. m.SetGname(v)
  11272. return nil
  11273. case contact.FieldV3:
  11274. v, ok := value.(string)
  11275. if !ok {
  11276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11277. }
  11278. m.SetV3(v)
  11279. return nil
  11280. case contact.FieldOrganizationID:
  11281. v, ok := value.(uint64)
  11282. if !ok {
  11283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11284. }
  11285. m.SetOrganizationID(v)
  11286. return nil
  11287. case contact.FieldCtype:
  11288. v, ok := value.(uint64)
  11289. if !ok {
  11290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11291. }
  11292. m.SetCtype(v)
  11293. return nil
  11294. case contact.FieldCage:
  11295. v, ok := value.(int)
  11296. if !ok {
  11297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11298. }
  11299. m.SetCage(v)
  11300. return nil
  11301. case contact.FieldCname:
  11302. v, ok := value.(string)
  11303. if !ok {
  11304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11305. }
  11306. m.SetCname(v)
  11307. return nil
  11308. case contact.FieldCarea:
  11309. v, ok := value.(string)
  11310. if !ok {
  11311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11312. }
  11313. m.SetCarea(v)
  11314. return nil
  11315. case contact.FieldCbirthday:
  11316. v, ok := value.(string)
  11317. if !ok {
  11318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11319. }
  11320. m.SetCbirthday(v)
  11321. return nil
  11322. case contact.FieldCbirtharea:
  11323. v, ok := value.(string)
  11324. if !ok {
  11325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11326. }
  11327. m.SetCbirtharea(v)
  11328. return nil
  11329. case contact.FieldCidcardNo:
  11330. v, ok := value.(string)
  11331. if !ok {
  11332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11333. }
  11334. m.SetCidcardNo(v)
  11335. return nil
  11336. case contact.FieldCtitle:
  11337. v, ok := value.(string)
  11338. if !ok {
  11339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11340. }
  11341. m.SetCtitle(v)
  11342. return nil
  11343. case contact.FieldCc:
  11344. v, ok := value.(string)
  11345. if !ok {
  11346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11347. }
  11348. m.SetCc(v)
  11349. return nil
  11350. case contact.FieldPhone:
  11351. v, ok := value.(string)
  11352. if !ok {
  11353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11354. }
  11355. m.SetPhone(v)
  11356. return nil
  11357. }
  11358. return fmt.Errorf("unknown Contact field %s", name)
  11359. }
  11360. // AddedFields returns all numeric fields that were incremented/decremented during
  11361. // this mutation.
  11362. func (m *ContactMutation) AddedFields() []string {
  11363. var fields []string
  11364. if m.addstatus != nil {
  11365. fields = append(fields, contact.FieldStatus)
  11366. }
  11367. if m.add_type != nil {
  11368. fields = append(fields, contact.FieldType)
  11369. }
  11370. if m.addsex != nil {
  11371. fields = append(fields, contact.FieldSex)
  11372. }
  11373. if m.adddontseeit != nil {
  11374. fields = append(fields, contact.FieldDontseeit)
  11375. }
  11376. if m.adddontseeme != nil {
  11377. fields = append(fields, contact.FieldDontseeme)
  11378. }
  11379. if m.addorganization_id != nil {
  11380. fields = append(fields, contact.FieldOrganizationID)
  11381. }
  11382. if m.addctype != nil {
  11383. fields = append(fields, contact.FieldCtype)
  11384. }
  11385. if m.addcage != nil {
  11386. fields = append(fields, contact.FieldCage)
  11387. }
  11388. return fields
  11389. }
  11390. // AddedField returns the numeric value that was incremented/decremented on a field
  11391. // with the given name. The second boolean return value indicates that this field
  11392. // was not set, or was not defined in the schema.
  11393. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  11394. switch name {
  11395. case contact.FieldStatus:
  11396. return m.AddedStatus()
  11397. case contact.FieldType:
  11398. return m.AddedType()
  11399. case contact.FieldSex:
  11400. return m.AddedSex()
  11401. case contact.FieldDontseeit:
  11402. return m.AddedDontseeit()
  11403. case contact.FieldDontseeme:
  11404. return m.AddedDontseeme()
  11405. case contact.FieldOrganizationID:
  11406. return m.AddedOrganizationID()
  11407. case contact.FieldCtype:
  11408. return m.AddedCtype()
  11409. case contact.FieldCage:
  11410. return m.AddedCage()
  11411. }
  11412. return nil, false
  11413. }
  11414. // AddField adds the value to the field with the given name. It returns an error if
  11415. // the field is not defined in the schema, or if the type mismatched the field
  11416. // type.
  11417. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  11418. switch name {
  11419. case contact.FieldStatus:
  11420. v, ok := value.(int8)
  11421. if !ok {
  11422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11423. }
  11424. m.AddStatus(v)
  11425. return nil
  11426. case contact.FieldType:
  11427. v, ok := value.(int)
  11428. if !ok {
  11429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11430. }
  11431. m.AddType(v)
  11432. return nil
  11433. case contact.FieldSex:
  11434. v, ok := value.(int)
  11435. if !ok {
  11436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11437. }
  11438. m.AddSex(v)
  11439. return nil
  11440. case contact.FieldDontseeit:
  11441. v, ok := value.(int)
  11442. if !ok {
  11443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11444. }
  11445. m.AddDontseeit(v)
  11446. return nil
  11447. case contact.FieldDontseeme:
  11448. v, ok := value.(int)
  11449. if !ok {
  11450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11451. }
  11452. m.AddDontseeme(v)
  11453. return nil
  11454. case contact.FieldOrganizationID:
  11455. v, ok := value.(int64)
  11456. if !ok {
  11457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11458. }
  11459. m.AddOrganizationID(v)
  11460. return nil
  11461. case contact.FieldCtype:
  11462. v, ok := value.(int64)
  11463. if !ok {
  11464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11465. }
  11466. m.AddCtype(v)
  11467. return nil
  11468. case contact.FieldCage:
  11469. v, ok := value.(int)
  11470. if !ok {
  11471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11472. }
  11473. m.AddCage(v)
  11474. return nil
  11475. }
  11476. return fmt.Errorf("unknown Contact numeric field %s", name)
  11477. }
  11478. // ClearedFields returns all nullable fields that were cleared during this
  11479. // mutation.
  11480. func (m *ContactMutation) ClearedFields() []string {
  11481. var fields []string
  11482. if m.FieldCleared(contact.FieldStatus) {
  11483. fields = append(fields, contact.FieldStatus)
  11484. }
  11485. if m.FieldCleared(contact.FieldDeletedAt) {
  11486. fields = append(fields, contact.FieldDeletedAt)
  11487. }
  11488. if m.FieldCleared(contact.FieldType) {
  11489. fields = append(fields, contact.FieldType)
  11490. }
  11491. if m.FieldCleared(contact.FieldOrganizationID) {
  11492. fields = append(fields, contact.FieldOrganizationID)
  11493. }
  11494. return fields
  11495. }
  11496. // FieldCleared returns a boolean indicating if a field with the given name was
  11497. // cleared in this mutation.
  11498. func (m *ContactMutation) FieldCleared(name string) bool {
  11499. _, ok := m.clearedFields[name]
  11500. return ok
  11501. }
  11502. // ClearField clears the value of the field with the given name. It returns an
  11503. // error if the field is not defined in the schema.
  11504. func (m *ContactMutation) ClearField(name string) error {
  11505. switch name {
  11506. case contact.FieldStatus:
  11507. m.ClearStatus()
  11508. return nil
  11509. case contact.FieldDeletedAt:
  11510. m.ClearDeletedAt()
  11511. return nil
  11512. case contact.FieldType:
  11513. m.ClearType()
  11514. return nil
  11515. case contact.FieldOrganizationID:
  11516. m.ClearOrganizationID()
  11517. return nil
  11518. }
  11519. return fmt.Errorf("unknown Contact nullable field %s", name)
  11520. }
  11521. // ResetField resets all changes in the mutation for the field with the given name.
  11522. // It returns an error if the field is not defined in the schema.
  11523. func (m *ContactMutation) ResetField(name string) error {
  11524. switch name {
  11525. case contact.FieldCreatedAt:
  11526. m.ResetCreatedAt()
  11527. return nil
  11528. case contact.FieldUpdatedAt:
  11529. m.ResetUpdatedAt()
  11530. return nil
  11531. case contact.FieldStatus:
  11532. m.ResetStatus()
  11533. return nil
  11534. case contact.FieldDeletedAt:
  11535. m.ResetDeletedAt()
  11536. return nil
  11537. case contact.FieldWxWxid:
  11538. m.ResetWxWxid()
  11539. return nil
  11540. case contact.FieldType:
  11541. m.ResetType()
  11542. return nil
  11543. case contact.FieldWxid:
  11544. m.ResetWxid()
  11545. return nil
  11546. case contact.FieldAccount:
  11547. m.ResetAccount()
  11548. return nil
  11549. case contact.FieldNickname:
  11550. m.ResetNickname()
  11551. return nil
  11552. case contact.FieldMarkname:
  11553. m.ResetMarkname()
  11554. return nil
  11555. case contact.FieldHeadimg:
  11556. m.ResetHeadimg()
  11557. return nil
  11558. case contact.FieldSex:
  11559. m.ResetSex()
  11560. return nil
  11561. case contact.FieldStarrole:
  11562. m.ResetStarrole()
  11563. return nil
  11564. case contact.FieldDontseeit:
  11565. m.ResetDontseeit()
  11566. return nil
  11567. case contact.FieldDontseeme:
  11568. m.ResetDontseeme()
  11569. return nil
  11570. case contact.FieldLag:
  11571. m.ResetLag()
  11572. return nil
  11573. case contact.FieldGid:
  11574. m.ResetGid()
  11575. return nil
  11576. case contact.FieldGname:
  11577. m.ResetGname()
  11578. return nil
  11579. case contact.FieldV3:
  11580. m.ResetV3()
  11581. return nil
  11582. case contact.FieldOrganizationID:
  11583. m.ResetOrganizationID()
  11584. return nil
  11585. case contact.FieldCtype:
  11586. m.ResetCtype()
  11587. return nil
  11588. case contact.FieldCage:
  11589. m.ResetCage()
  11590. return nil
  11591. case contact.FieldCname:
  11592. m.ResetCname()
  11593. return nil
  11594. case contact.FieldCarea:
  11595. m.ResetCarea()
  11596. return nil
  11597. case contact.FieldCbirthday:
  11598. m.ResetCbirthday()
  11599. return nil
  11600. case contact.FieldCbirtharea:
  11601. m.ResetCbirtharea()
  11602. return nil
  11603. case contact.FieldCidcardNo:
  11604. m.ResetCidcardNo()
  11605. return nil
  11606. case contact.FieldCtitle:
  11607. m.ResetCtitle()
  11608. return nil
  11609. case contact.FieldCc:
  11610. m.ResetCc()
  11611. return nil
  11612. case contact.FieldPhone:
  11613. m.ResetPhone()
  11614. return nil
  11615. }
  11616. return fmt.Errorf("unknown Contact field %s", name)
  11617. }
  11618. // AddedEdges returns all edge names that were set/added in this mutation.
  11619. func (m *ContactMutation) AddedEdges() []string {
  11620. edges := make([]string, 0, 2)
  11621. if m.contact_relationships != nil {
  11622. edges = append(edges, contact.EdgeContactRelationships)
  11623. }
  11624. if m.contact_messages != nil {
  11625. edges = append(edges, contact.EdgeContactMessages)
  11626. }
  11627. return edges
  11628. }
  11629. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11630. // name in this mutation.
  11631. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  11632. switch name {
  11633. case contact.EdgeContactRelationships:
  11634. ids := make([]ent.Value, 0, len(m.contact_relationships))
  11635. for id := range m.contact_relationships {
  11636. ids = append(ids, id)
  11637. }
  11638. return ids
  11639. case contact.EdgeContactMessages:
  11640. ids := make([]ent.Value, 0, len(m.contact_messages))
  11641. for id := range m.contact_messages {
  11642. ids = append(ids, id)
  11643. }
  11644. return ids
  11645. }
  11646. return nil
  11647. }
  11648. // RemovedEdges returns all edge names that were removed in this mutation.
  11649. func (m *ContactMutation) RemovedEdges() []string {
  11650. edges := make([]string, 0, 2)
  11651. if m.removedcontact_relationships != nil {
  11652. edges = append(edges, contact.EdgeContactRelationships)
  11653. }
  11654. if m.removedcontact_messages != nil {
  11655. edges = append(edges, contact.EdgeContactMessages)
  11656. }
  11657. return edges
  11658. }
  11659. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11660. // the given name in this mutation.
  11661. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  11662. switch name {
  11663. case contact.EdgeContactRelationships:
  11664. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  11665. for id := range m.removedcontact_relationships {
  11666. ids = append(ids, id)
  11667. }
  11668. return ids
  11669. case contact.EdgeContactMessages:
  11670. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  11671. for id := range m.removedcontact_messages {
  11672. ids = append(ids, id)
  11673. }
  11674. return ids
  11675. }
  11676. return nil
  11677. }
  11678. // ClearedEdges returns all edge names that were cleared in this mutation.
  11679. func (m *ContactMutation) ClearedEdges() []string {
  11680. edges := make([]string, 0, 2)
  11681. if m.clearedcontact_relationships {
  11682. edges = append(edges, contact.EdgeContactRelationships)
  11683. }
  11684. if m.clearedcontact_messages {
  11685. edges = append(edges, contact.EdgeContactMessages)
  11686. }
  11687. return edges
  11688. }
  11689. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11690. // was cleared in this mutation.
  11691. func (m *ContactMutation) EdgeCleared(name string) bool {
  11692. switch name {
  11693. case contact.EdgeContactRelationships:
  11694. return m.clearedcontact_relationships
  11695. case contact.EdgeContactMessages:
  11696. return m.clearedcontact_messages
  11697. }
  11698. return false
  11699. }
  11700. // ClearEdge clears the value of the edge with the given name. It returns an error
  11701. // if that edge is not defined in the schema.
  11702. func (m *ContactMutation) ClearEdge(name string) error {
  11703. switch name {
  11704. }
  11705. return fmt.Errorf("unknown Contact unique edge %s", name)
  11706. }
  11707. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11708. // It returns an error if the edge is not defined in the schema.
  11709. func (m *ContactMutation) ResetEdge(name string) error {
  11710. switch name {
  11711. case contact.EdgeContactRelationships:
  11712. m.ResetContactRelationships()
  11713. return nil
  11714. case contact.EdgeContactMessages:
  11715. m.ResetContactMessages()
  11716. return nil
  11717. }
  11718. return fmt.Errorf("unknown Contact edge %s", name)
  11719. }
  11720. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  11721. type CreditBalanceMutation struct {
  11722. config
  11723. op Op
  11724. typ string
  11725. id *uint64
  11726. created_at *time.Time
  11727. updated_at *time.Time
  11728. deleted_at *time.Time
  11729. user_id *string
  11730. balance *float32
  11731. addbalance *float32
  11732. status *int
  11733. addstatus *int
  11734. organization_id *uint64
  11735. addorganization_id *int64
  11736. clearedFields map[string]struct{}
  11737. done bool
  11738. oldValue func(context.Context) (*CreditBalance, error)
  11739. predicates []predicate.CreditBalance
  11740. }
  11741. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  11742. // creditbalanceOption allows management of the mutation configuration using functional options.
  11743. type creditbalanceOption func(*CreditBalanceMutation)
  11744. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  11745. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  11746. m := &CreditBalanceMutation{
  11747. config: c,
  11748. op: op,
  11749. typ: TypeCreditBalance,
  11750. clearedFields: make(map[string]struct{}),
  11751. }
  11752. for _, opt := range opts {
  11753. opt(m)
  11754. }
  11755. return m
  11756. }
  11757. // withCreditBalanceID sets the ID field of the mutation.
  11758. func withCreditBalanceID(id uint64) creditbalanceOption {
  11759. return func(m *CreditBalanceMutation) {
  11760. var (
  11761. err error
  11762. once sync.Once
  11763. value *CreditBalance
  11764. )
  11765. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  11766. once.Do(func() {
  11767. if m.done {
  11768. err = errors.New("querying old values post mutation is not allowed")
  11769. } else {
  11770. value, err = m.Client().CreditBalance.Get(ctx, id)
  11771. }
  11772. })
  11773. return value, err
  11774. }
  11775. m.id = &id
  11776. }
  11777. }
  11778. // withCreditBalance sets the old CreditBalance of the mutation.
  11779. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  11780. return func(m *CreditBalanceMutation) {
  11781. m.oldValue = func(context.Context) (*CreditBalance, error) {
  11782. return node, nil
  11783. }
  11784. m.id = &node.ID
  11785. }
  11786. }
  11787. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11788. // executed in a transaction (ent.Tx), a transactional client is returned.
  11789. func (m CreditBalanceMutation) Client() *Client {
  11790. client := &Client{config: m.config}
  11791. client.init()
  11792. return client
  11793. }
  11794. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11795. // it returns an error otherwise.
  11796. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  11797. if _, ok := m.driver.(*txDriver); !ok {
  11798. return nil, errors.New("ent: mutation is not running in a transaction")
  11799. }
  11800. tx := &Tx{config: m.config}
  11801. tx.init()
  11802. return tx, nil
  11803. }
  11804. // SetID sets the value of the id field. Note that this
  11805. // operation is only accepted on creation of CreditBalance entities.
  11806. func (m *CreditBalanceMutation) SetID(id uint64) {
  11807. m.id = &id
  11808. }
  11809. // ID returns the ID value in the mutation. Note that the ID is only available
  11810. // if it was provided to the builder or after it was returned from the database.
  11811. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  11812. if m.id == nil {
  11813. return
  11814. }
  11815. return *m.id, true
  11816. }
  11817. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11818. // That means, if the mutation is applied within a transaction with an isolation level such
  11819. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11820. // or updated by the mutation.
  11821. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  11822. switch {
  11823. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11824. id, exists := m.ID()
  11825. if exists {
  11826. return []uint64{id}, nil
  11827. }
  11828. fallthrough
  11829. case m.op.Is(OpUpdate | OpDelete):
  11830. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  11831. default:
  11832. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11833. }
  11834. }
  11835. // SetCreatedAt sets the "created_at" field.
  11836. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  11837. m.created_at = &t
  11838. }
  11839. // CreatedAt returns the value of the "created_at" field in the mutation.
  11840. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  11841. v := m.created_at
  11842. if v == nil {
  11843. return
  11844. }
  11845. return *v, true
  11846. }
  11847. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  11848. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11850. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11851. if !m.op.Is(OpUpdateOne) {
  11852. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11853. }
  11854. if m.id == nil || m.oldValue == nil {
  11855. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11856. }
  11857. oldValue, err := m.oldValue(ctx)
  11858. if err != nil {
  11859. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11860. }
  11861. return oldValue.CreatedAt, nil
  11862. }
  11863. // ResetCreatedAt resets all changes to the "created_at" field.
  11864. func (m *CreditBalanceMutation) ResetCreatedAt() {
  11865. m.created_at = nil
  11866. }
  11867. // SetUpdatedAt sets the "updated_at" field.
  11868. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  11869. m.updated_at = &t
  11870. }
  11871. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11872. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  11873. v := m.updated_at
  11874. if v == nil {
  11875. return
  11876. }
  11877. return *v, true
  11878. }
  11879. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  11880. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11882. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11883. if !m.op.Is(OpUpdateOne) {
  11884. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11885. }
  11886. if m.id == nil || m.oldValue == nil {
  11887. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11888. }
  11889. oldValue, err := m.oldValue(ctx)
  11890. if err != nil {
  11891. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11892. }
  11893. return oldValue.UpdatedAt, nil
  11894. }
  11895. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11896. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  11897. m.updated_at = nil
  11898. }
  11899. // SetDeletedAt sets the "deleted_at" field.
  11900. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  11901. m.deleted_at = &t
  11902. }
  11903. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11904. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  11905. v := m.deleted_at
  11906. if v == nil {
  11907. return
  11908. }
  11909. return *v, true
  11910. }
  11911. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  11912. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11914. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11915. if !m.op.Is(OpUpdateOne) {
  11916. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11917. }
  11918. if m.id == nil || m.oldValue == nil {
  11919. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11920. }
  11921. oldValue, err := m.oldValue(ctx)
  11922. if err != nil {
  11923. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11924. }
  11925. return oldValue.DeletedAt, nil
  11926. }
  11927. // ClearDeletedAt clears the value of the "deleted_at" field.
  11928. func (m *CreditBalanceMutation) ClearDeletedAt() {
  11929. m.deleted_at = nil
  11930. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  11931. }
  11932. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11933. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  11934. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  11935. return ok
  11936. }
  11937. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11938. func (m *CreditBalanceMutation) ResetDeletedAt() {
  11939. m.deleted_at = nil
  11940. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  11941. }
  11942. // SetUserID sets the "user_id" field.
  11943. func (m *CreditBalanceMutation) SetUserID(s string) {
  11944. m.user_id = &s
  11945. }
  11946. // UserID returns the value of the "user_id" field in the mutation.
  11947. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  11948. v := m.user_id
  11949. if v == nil {
  11950. return
  11951. }
  11952. return *v, true
  11953. }
  11954. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  11955. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  11956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11957. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  11958. if !m.op.Is(OpUpdateOne) {
  11959. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  11960. }
  11961. if m.id == nil || m.oldValue == nil {
  11962. return v, errors.New("OldUserID requires an ID field in the mutation")
  11963. }
  11964. oldValue, err := m.oldValue(ctx)
  11965. if err != nil {
  11966. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  11967. }
  11968. return oldValue.UserID, nil
  11969. }
  11970. // ClearUserID clears the value of the "user_id" field.
  11971. func (m *CreditBalanceMutation) ClearUserID() {
  11972. m.user_id = nil
  11973. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  11974. }
  11975. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  11976. func (m *CreditBalanceMutation) UserIDCleared() bool {
  11977. _, ok := m.clearedFields[creditbalance.FieldUserID]
  11978. return ok
  11979. }
  11980. // ResetUserID resets all changes to the "user_id" field.
  11981. func (m *CreditBalanceMutation) ResetUserID() {
  11982. m.user_id = nil
  11983. delete(m.clearedFields, creditbalance.FieldUserID)
  11984. }
  11985. // SetBalance sets the "balance" field.
  11986. func (m *CreditBalanceMutation) SetBalance(f float32) {
  11987. m.balance = &f
  11988. m.addbalance = nil
  11989. }
  11990. // Balance returns the value of the "balance" field in the mutation.
  11991. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  11992. v := m.balance
  11993. if v == nil {
  11994. return
  11995. }
  11996. return *v, true
  11997. }
  11998. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  11999. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12001. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  12002. if !m.op.Is(OpUpdateOne) {
  12003. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  12004. }
  12005. if m.id == nil || m.oldValue == nil {
  12006. return v, errors.New("OldBalance requires an ID field in the mutation")
  12007. }
  12008. oldValue, err := m.oldValue(ctx)
  12009. if err != nil {
  12010. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  12011. }
  12012. return oldValue.Balance, nil
  12013. }
  12014. // AddBalance adds f to the "balance" field.
  12015. func (m *CreditBalanceMutation) AddBalance(f float32) {
  12016. if m.addbalance != nil {
  12017. *m.addbalance += f
  12018. } else {
  12019. m.addbalance = &f
  12020. }
  12021. }
  12022. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  12023. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  12024. v := m.addbalance
  12025. if v == nil {
  12026. return
  12027. }
  12028. return *v, true
  12029. }
  12030. // ResetBalance resets all changes to the "balance" field.
  12031. func (m *CreditBalanceMutation) ResetBalance() {
  12032. m.balance = nil
  12033. m.addbalance = nil
  12034. }
  12035. // SetStatus sets the "status" field.
  12036. func (m *CreditBalanceMutation) SetStatus(i int) {
  12037. m.status = &i
  12038. m.addstatus = nil
  12039. }
  12040. // Status returns the value of the "status" field in the mutation.
  12041. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  12042. v := m.status
  12043. if v == nil {
  12044. return
  12045. }
  12046. return *v, true
  12047. }
  12048. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  12049. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12051. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  12052. if !m.op.Is(OpUpdateOne) {
  12053. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12054. }
  12055. if m.id == nil || m.oldValue == nil {
  12056. return v, errors.New("OldStatus requires an ID field in the mutation")
  12057. }
  12058. oldValue, err := m.oldValue(ctx)
  12059. if err != nil {
  12060. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12061. }
  12062. return oldValue.Status, nil
  12063. }
  12064. // AddStatus adds i to the "status" field.
  12065. func (m *CreditBalanceMutation) AddStatus(i int) {
  12066. if m.addstatus != nil {
  12067. *m.addstatus += i
  12068. } else {
  12069. m.addstatus = &i
  12070. }
  12071. }
  12072. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12073. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  12074. v := m.addstatus
  12075. if v == nil {
  12076. return
  12077. }
  12078. return *v, true
  12079. }
  12080. // ClearStatus clears the value of the "status" field.
  12081. func (m *CreditBalanceMutation) ClearStatus() {
  12082. m.status = nil
  12083. m.addstatus = nil
  12084. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  12085. }
  12086. // StatusCleared returns if the "status" field was cleared in this mutation.
  12087. func (m *CreditBalanceMutation) StatusCleared() bool {
  12088. _, ok := m.clearedFields[creditbalance.FieldStatus]
  12089. return ok
  12090. }
  12091. // ResetStatus resets all changes to the "status" field.
  12092. func (m *CreditBalanceMutation) ResetStatus() {
  12093. m.status = nil
  12094. m.addstatus = nil
  12095. delete(m.clearedFields, creditbalance.FieldStatus)
  12096. }
  12097. // SetOrganizationID sets the "organization_id" field.
  12098. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  12099. m.organization_id = &u
  12100. m.addorganization_id = nil
  12101. }
  12102. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12103. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  12104. v := m.organization_id
  12105. if v == nil {
  12106. return
  12107. }
  12108. return *v, true
  12109. }
  12110. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  12111. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12113. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12114. if !m.op.Is(OpUpdateOne) {
  12115. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12116. }
  12117. if m.id == nil || m.oldValue == nil {
  12118. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12119. }
  12120. oldValue, err := m.oldValue(ctx)
  12121. if err != nil {
  12122. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12123. }
  12124. return oldValue.OrganizationID, nil
  12125. }
  12126. // AddOrganizationID adds u to the "organization_id" field.
  12127. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  12128. if m.addorganization_id != nil {
  12129. *m.addorganization_id += u
  12130. } else {
  12131. m.addorganization_id = &u
  12132. }
  12133. }
  12134. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12135. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  12136. v := m.addorganization_id
  12137. if v == nil {
  12138. return
  12139. }
  12140. return *v, true
  12141. }
  12142. // ClearOrganizationID clears the value of the "organization_id" field.
  12143. func (m *CreditBalanceMutation) ClearOrganizationID() {
  12144. m.organization_id = nil
  12145. m.addorganization_id = nil
  12146. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  12147. }
  12148. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12149. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  12150. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  12151. return ok
  12152. }
  12153. // ResetOrganizationID resets all changes to the "organization_id" field.
  12154. func (m *CreditBalanceMutation) ResetOrganizationID() {
  12155. m.organization_id = nil
  12156. m.addorganization_id = nil
  12157. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  12158. }
  12159. // Where appends a list predicates to the CreditBalanceMutation builder.
  12160. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  12161. m.predicates = append(m.predicates, ps...)
  12162. }
  12163. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  12164. // users can use type-assertion to append predicates that do not depend on any generated package.
  12165. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  12166. p := make([]predicate.CreditBalance, len(ps))
  12167. for i := range ps {
  12168. p[i] = ps[i]
  12169. }
  12170. m.Where(p...)
  12171. }
  12172. // Op returns the operation name.
  12173. func (m *CreditBalanceMutation) Op() Op {
  12174. return m.op
  12175. }
  12176. // SetOp allows setting the mutation operation.
  12177. func (m *CreditBalanceMutation) SetOp(op Op) {
  12178. m.op = op
  12179. }
  12180. // Type returns the node type of this mutation (CreditBalance).
  12181. func (m *CreditBalanceMutation) Type() string {
  12182. return m.typ
  12183. }
  12184. // Fields returns all fields that were changed during this mutation. Note that in
  12185. // order to get all numeric fields that were incremented/decremented, call
  12186. // AddedFields().
  12187. func (m *CreditBalanceMutation) Fields() []string {
  12188. fields := make([]string, 0, 7)
  12189. if m.created_at != nil {
  12190. fields = append(fields, creditbalance.FieldCreatedAt)
  12191. }
  12192. if m.updated_at != nil {
  12193. fields = append(fields, creditbalance.FieldUpdatedAt)
  12194. }
  12195. if m.deleted_at != nil {
  12196. fields = append(fields, creditbalance.FieldDeletedAt)
  12197. }
  12198. if m.user_id != nil {
  12199. fields = append(fields, creditbalance.FieldUserID)
  12200. }
  12201. if m.balance != nil {
  12202. fields = append(fields, creditbalance.FieldBalance)
  12203. }
  12204. if m.status != nil {
  12205. fields = append(fields, creditbalance.FieldStatus)
  12206. }
  12207. if m.organization_id != nil {
  12208. fields = append(fields, creditbalance.FieldOrganizationID)
  12209. }
  12210. return fields
  12211. }
  12212. // Field returns the value of a field with the given name. The second boolean
  12213. // return value indicates that this field was not set, or was not defined in the
  12214. // schema.
  12215. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  12216. switch name {
  12217. case creditbalance.FieldCreatedAt:
  12218. return m.CreatedAt()
  12219. case creditbalance.FieldUpdatedAt:
  12220. return m.UpdatedAt()
  12221. case creditbalance.FieldDeletedAt:
  12222. return m.DeletedAt()
  12223. case creditbalance.FieldUserID:
  12224. return m.UserID()
  12225. case creditbalance.FieldBalance:
  12226. return m.Balance()
  12227. case creditbalance.FieldStatus:
  12228. return m.Status()
  12229. case creditbalance.FieldOrganizationID:
  12230. return m.OrganizationID()
  12231. }
  12232. return nil, false
  12233. }
  12234. // OldField returns the old value of the field from the database. An error is
  12235. // returned if the mutation operation is not UpdateOne, or the query to the
  12236. // database failed.
  12237. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12238. switch name {
  12239. case creditbalance.FieldCreatedAt:
  12240. return m.OldCreatedAt(ctx)
  12241. case creditbalance.FieldUpdatedAt:
  12242. return m.OldUpdatedAt(ctx)
  12243. case creditbalance.FieldDeletedAt:
  12244. return m.OldDeletedAt(ctx)
  12245. case creditbalance.FieldUserID:
  12246. return m.OldUserID(ctx)
  12247. case creditbalance.FieldBalance:
  12248. return m.OldBalance(ctx)
  12249. case creditbalance.FieldStatus:
  12250. return m.OldStatus(ctx)
  12251. case creditbalance.FieldOrganizationID:
  12252. return m.OldOrganizationID(ctx)
  12253. }
  12254. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  12255. }
  12256. // SetField sets the value of a field with the given name. It returns an error if
  12257. // the field is not defined in the schema, or if the type mismatched the field
  12258. // type.
  12259. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  12260. switch name {
  12261. case creditbalance.FieldCreatedAt:
  12262. v, ok := value.(time.Time)
  12263. if !ok {
  12264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12265. }
  12266. m.SetCreatedAt(v)
  12267. return nil
  12268. case creditbalance.FieldUpdatedAt:
  12269. v, ok := value.(time.Time)
  12270. if !ok {
  12271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12272. }
  12273. m.SetUpdatedAt(v)
  12274. return nil
  12275. case creditbalance.FieldDeletedAt:
  12276. v, ok := value.(time.Time)
  12277. if !ok {
  12278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12279. }
  12280. m.SetDeletedAt(v)
  12281. return nil
  12282. case creditbalance.FieldUserID:
  12283. v, ok := value.(string)
  12284. if !ok {
  12285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12286. }
  12287. m.SetUserID(v)
  12288. return nil
  12289. case creditbalance.FieldBalance:
  12290. v, ok := value.(float32)
  12291. if !ok {
  12292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12293. }
  12294. m.SetBalance(v)
  12295. return nil
  12296. case creditbalance.FieldStatus:
  12297. v, ok := value.(int)
  12298. if !ok {
  12299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12300. }
  12301. m.SetStatus(v)
  12302. return nil
  12303. case creditbalance.FieldOrganizationID:
  12304. v, ok := value.(uint64)
  12305. if !ok {
  12306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12307. }
  12308. m.SetOrganizationID(v)
  12309. return nil
  12310. }
  12311. return fmt.Errorf("unknown CreditBalance field %s", name)
  12312. }
  12313. // AddedFields returns all numeric fields that were incremented/decremented during
  12314. // this mutation.
  12315. func (m *CreditBalanceMutation) AddedFields() []string {
  12316. var fields []string
  12317. if m.addbalance != nil {
  12318. fields = append(fields, creditbalance.FieldBalance)
  12319. }
  12320. if m.addstatus != nil {
  12321. fields = append(fields, creditbalance.FieldStatus)
  12322. }
  12323. if m.addorganization_id != nil {
  12324. fields = append(fields, creditbalance.FieldOrganizationID)
  12325. }
  12326. return fields
  12327. }
  12328. // AddedField returns the numeric value that was incremented/decremented on a field
  12329. // with the given name. The second boolean return value indicates that this field
  12330. // was not set, or was not defined in the schema.
  12331. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  12332. switch name {
  12333. case creditbalance.FieldBalance:
  12334. return m.AddedBalance()
  12335. case creditbalance.FieldStatus:
  12336. return m.AddedStatus()
  12337. case creditbalance.FieldOrganizationID:
  12338. return m.AddedOrganizationID()
  12339. }
  12340. return nil, false
  12341. }
  12342. // AddField adds the value to the field with the given name. It returns an error if
  12343. // the field is not defined in the schema, or if the type mismatched the field
  12344. // type.
  12345. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  12346. switch name {
  12347. case creditbalance.FieldBalance:
  12348. v, ok := value.(float32)
  12349. if !ok {
  12350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12351. }
  12352. m.AddBalance(v)
  12353. return nil
  12354. case creditbalance.FieldStatus:
  12355. v, ok := value.(int)
  12356. if !ok {
  12357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12358. }
  12359. m.AddStatus(v)
  12360. return nil
  12361. case creditbalance.FieldOrganizationID:
  12362. v, ok := value.(int64)
  12363. if !ok {
  12364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12365. }
  12366. m.AddOrganizationID(v)
  12367. return nil
  12368. }
  12369. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  12370. }
  12371. // ClearedFields returns all nullable fields that were cleared during this
  12372. // mutation.
  12373. func (m *CreditBalanceMutation) ClearedFields() []string {
  12374. var fields []string
  12375. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  12376. fields = append(fields, creditbalance.FieldDeletedAt)
  12377. }
  12378. if m.FieldCleared(creditbalance.FieldUserID) {
  12379. fields = append(fields, creditbalance.FieldUserID)
  12380. }
  12381. if m.FieldCleared(creditbalance.FieldStatus) {
  12382. fields = append(fields, creditbalance.FieldStatus)
  12383. }
  12384. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  12385. fields = append(fields, creditbalance.FieldOrganizationID)
  12386. }
  12387. return fields
  12388. }
  12389. // FieldCleared returns a boolean indicating if a field with the given name was
  12390. // cleared in this mutation.
  12391. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  12392. _, ok := m.clearedFields[name]
  12393. return ok
  12394. }
  12395. // ClearField clears the value of the field with the given name. It returns an
  12396. // error if the field is not defined in the schema.
  12397. func (m *CreditBalanceMutation) ClearField(name string) error {
  12398. switch name {
  12399. case creditbalance.FieldDeletedAt:
  12400. m.ClearDeletedAt()
  12401. return nil
  12402. case creditbalance.FieldUserID:
  12403. m.ClearUserID()
  12404. return nil
  12405. case creditbalance.FieldStatus:
  12406. m.ClearStatus()
  12407. return nil
  12408. case creditbalance.FieldOrganizationID:
  12409. m.ClearOrganizationID()
  12410. return nil
  12411. }
  12412. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  12413. }
  12414. // ResetField resets all changes in the mutation for the field with the given name.
  12415. // It returns an error if the field is not defined in the schema.
  12416. func (m *CreditBalanceMutation) ResetField(name string) error {
  12417. switch name {
  12418. case creditbalance.FieldCreatedAt:
  12419. m.ResetCreatedAt()
  12420. return nil
  12421. case creditbalance.FieldUpdatedAt:
  12422. m.ResetUpdatedAt()
  12423. return nil
  12424. case creditbalance.FieldDeletedAt:
  12425. m.ResetDeletedAt()
  12426. return nil
  12427. case creditbalance.FieldUserID:
  12428. m.ResetUserID()
  12429. return nil
  12430. case creditbalance.FieldBalance:
  12431. m.ResetBalance()
  12432. return nil
  12433. case creditbalance.FieldStatus:
  12434. m.ResetStatus()
  12435. return nil
  12436. case creditbalance.FieldOrganizationID:
  12437. m.ResetOrganizationID()
  12438. return nil
  12439. }
  12440. return fmt.Errorf("unknown CreditBalance field %s", name)
  12441. }
  12442. // AddedEdges returns all edge names that were set/added in this mutation.
  12443. func (m *CreditBalanceMutation) AddedEdges() []string {
  12444. edges := make([]string, 0, 0)
  12445. return edges
  12446. }
  12447. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12448. // name in this mutation.
  12449. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  12450. return nil
  12451. }
  12452. // RemovedEdges returns all edge names that were removed in this mutation.
  12453. func (m *CreditBalanceMutation) RemovedEdges() []string {
  12454. edges := make([]string, 0, 0)
  12455. return edges
  12456. }
  12457. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12458. // the given name in this mutation.
  12459. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  12460. return nil
  12461. }
  12462. // ClearedEdges returns all edge names that were cleared in this mutation.
  12463. func (m *CreditBalanceMutation) ClearedEdges() []string {
  12464. edges := make([]string, 0, 0)
  12465. return edges
  12466. }
  12467. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12468. // was cleared in this mutation.
  12469. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  12470. return false
  12471. }
  12472. // ClearEdge clears the value of the edge with the given name. It returns an error
  12473. // if that edge is not defined in the schema.
  12474. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  12475. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  12476. }
  12477. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12478. // It returns an error if the edge is not defined in the schema.
  12479. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  12480. return fmt.Errorf("unknown CreditBalance edge %s", name)
  12481. }
  12482. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  12483. type CreditUsageMutation struct {
  12484. config
  12485. op Op
  12486. typ string
  12487. id *uint64
  12488. created_at *time.Time
  12489. updated_at *time.Time
  12490. deleted_at *time.Time
  12491. user_id *string
  12492. number *float32
  12493. addnumber *float32
  12494. status *int
  12495. addstatus *int
  12496. ntype *int
  12497. addntype *int
  12498. table *string
  12499. organization_id *uint64
  12500. addorganization_id *int64
  12501. nid *uint64
  12502. addnid *int64
  12503. reason *string
  12504. operator *string
  12505. clearedFields map[string]struct{}
  12506. done bool
  12507. oldValue func(context.Context) (*CreditUsage, error)
  12508. predicates []predicate.CreditUsage
  12509. }
  12510. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  12511. // creditusageOption allows management of the mutation configuration using functional options.
  12512. type creditusageOption func(*CreditUsageMutation)
  12513. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  12514. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  12515. m := &CreditUsageMutation{
  12516. config: c,
  12517. op: op,
  12518. typ: TypeCreditUsage,
  12519. clearedFields: make(map[string]struct{}),
  12520. }
  12521. for _, opt := range opts {
  12522. opt(m)
  12523. }
  12524. return m
  12525. }
  12526. // withCreditUsageID sets the ID field of the mutation.
  12527. func withCreditUsageID(id uint64) creditusageOption {
  12528. return func(m *CreditUsageMutation) {
  12529. var (
  12530. err error
  12531. once sync.Once
  12532. value *CreditUsage
  12533. )
  12534. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  12535. once.Do(func() {
  12536. if m.done {
  12537. err = errors.New("querying old values post mutation is not allowed")
  12538. } else {
  12539. value, err = m.Client().CreditUsage.Get(ctx, id)
  12540. }
  12541. })
  12542. return value, err
  12543. }
  12544. m.id = &id
  12545. }
  12546. }
  12547. // withCreditUsage sets the old CreditUsage of the mutation.
  12548. func withCreditUsage(node *CreditUsage) creditusageOption {
  12549. return func(m *CreditUsageMutation) {
  12550. m.oldValue = func(context.Context) (*CreditUsage, error) {
  12551. return node, nil
  12552. }
  12553. m.id = &node.ID
  12554. }
  12555. }
  12556. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12557. // executed in a transaction (ent.Tx), a transactional client is returned.
  12558. func (m CreditUsageMutation) Client() *Client {
  12559. client := &Client{config: m.config}
  12560. client.init()
  12561. return client
  12562. }
  12563. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12564. // it returns an error otherwise.
  12565. func (m CreditUsageMutation) Tx() (*Tx, error) {
  12566. if _, ok := m.driver.(*txDriver); !ok {
  12567. return nil, errors.New("ent: mutation is not running in a transaction")
  12568. }
  12569. tx := &Tx{config: m.config}
  12570. tx.init()
  12571. return tx, nil
  12572. }
  12573. // SetID sets the value of the id field. Note that this
  12574. // operation is only accepted on creation of CreditUsage entities.
  12575. func (m *CreditUsageMutation) SetID(id uint64) {
  12576. m.id = &id
  12577. }
  12578. // ID returns the ID value in the mutation. Note that the ID is only available
  12579. // if it was provided to the builder or after it was returned from the database.
  12580. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  12581. if m.id == nil {
  12582. return
  12583. }
  12584. return *m.id, true
  12585. }
  12586. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12587. // That means, if the mutation is applied within a transaction with an isolation level such
  12588. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12589. // or updated by the mutation.
  12590. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  12591. switch {
  12592. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12593. id, exists := m.ID()
  12594. if exists {
  12595. return []uint64{id}, nil
  12596. }
  12597. fallthrough
  12598. case m.op.Is(OpUpdate | OpDelete):
  12599. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  12600. default:
  12601. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12602. }
  12603. }
  12604. // SetCreatedAt sets the "created_at" field.
  12605. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  12606. m.created_at = &t
  12607. }
  12608. // CreatedAt returns the value of the "created_at" field in the mutation.
  12609. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  12610. v := m.created_at
  12611. if v == nil {
  12612. return
  12613. }
  12614. return *v, true
  12615. }
  12616. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  12617. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12619. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12620. if !m.op.Is(OpUpdateOne) {
  12621. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12622. }
  12623. if m.id == nil || m.oldValue == nil {
  12624. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12625. }
  12626. oldValue, err := m.oldValue(ctx)
  12627. if err != nil {
  12628. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12629. }
  12630. return oldValue.CreatedAt, nil
  12631. }
  12632. // ResetCreatedAt resets all changes to the "created_at" field.
  12633. func (m *CreditUsageMutation) ResetCreatedAt() {
  12634. m.created_at = nil
  12635. }
  12636. // SetUpdatedAt sets the "updated_at" field.
  12637. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  12638. m.updated_at = &t
  12639. }
  12640. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12641. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  12642. v := m.updated_at
  12643. if v == nil {
  12644. return
  12645. }
  12646. return *v, true
  12647. }
  12648. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  12649. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12651. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12652. if !m.op.Is(OpUpdateOne) {
  12653. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12654. }
  12655. if m.id == nil || m.oldValue == nil {
  12656. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12657. }
  12658. oldValue, err := m.oldValue(ctx)
  12659. if err != nil {
  12660. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12661. }
  12662. return oldValue.UpdatedAt, nil
  12663. }
  12664. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12665. func (m *CreditUsageMutation) ResetUpdatedAt() {
  12666. m.updated_at = nil
  12667. }
  12668. // SetDeletedAt sets the "deleted_at" field.
  12669. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  12670. m.deleted_at = &t
  12671. }
  12672. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12673. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  12674. v := m.deleted_at
  12675. if v == nil {
  12676. return
  12677. }
  12678. return *v, true
  12679. }
  12680. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  12681. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12683. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12684. if !m.op.Is(OpUpdateOne) {
  12685. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12686. }
  12687. if m.id == nil || m.oldValue == nil {
  12688. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12689. }
  12690. oldValue, err := m.oldValue(ctx)
  12691. if err != nil {
  12692. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12693. }
  12694. return oldValue.DeletedAt, nil
  12695. }
  12696. // ClearDeletedAt clears the value of the "deleted_at" field.
  12697. func (m *CreditUsageMutation) ClearDeletedAt() {
  12698. m.deleted_at = nil
  12699. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  12700. }
  12701. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12702. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  12703. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  12704. return ok
  12705. }
  12706. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12707. func (m *CreditUsageMutation) ResetDeletedAt() {
  12708. m.deleted_at = nil
  12709. delete(m.clearedFields, creditusage.FieldDeletedAt)
  12710. }
  12711. // SetUserID sets the "user_id" field.
  12712. func (m *CreditUsageMutation) SetUserID(s string) {
  12713. m.user_id = &s
  12714. }
  12715. // UserID returns the value of the "user_id" field in the mutation.
  12716. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  12717. v := m.user_id
  12718. if v == nil {
  12719. return
  12720. }
  12721. return *v, true
  12722. }
  12723. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  12724. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12726. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  12727. if !m.op.Is(OpUpdateOne) {
  12728. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12729. }
  12730. if m.id == nil || m.oldValue == nil {
  12731. return v, errors.New("OldUserID requires an ID field in the mutation")
  12732. }
  12733. oldValue, err := m.oldValue(ctx)
  12734. if err != nil {
  12735. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12736. }
  12737. return oldValue.UserID, nil
  12738. }
  12739. // ClearUserID clears the value of the "user_id" field.
  12740. func (m *CreditUsageMutation) ClearUserID() {
  12741. m.user_id = nil
  12742. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  12743. }
  12744. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12745. func (m *CreditUsageMutation) UserIDCleared() bool {
  12746. _, ok := m.clearedFields[creditusage.FieldUserID]
  12747. return ok
  12748. }
  12749. // ResetUserID resets all changes to the "user_id" field.
  12750. func (m *CreditUsageMutation) ResetUserID() {
  12751. m.user_id = nil
  12752. delete(m.clearedFields, creditusage.FieldUserID)
  12753. }
  12754. // SetNumber sets the "number" field.
  12755. func (m *CreditUsageMutation) SetNumber(f float32) {
  12756. m.number = &f
  12757. m.addnumber = nil
  12758. }
  12759. // Number returns the value of the "number" field in the mutation.
  12760. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  12761. v := m.number
  12762. if v == nil {
  12763. return
  12764. }
  12765. return *v, true
  12766. }
  12767. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  12768. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12770. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  12771. if !m.op.Is(OpUpdateOne) {
  12772. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  12773. }
  12774. if m.id == nil || m.oldValue == nil {
  12775. return v, errors.New("OldNumber requires an ID field in the mutation")
  12776. }
  12777. oldValue, err := m.oldValue(ctx)
  12778. if err != nil {
  12779. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  12780. }
  12781. return oldValue.Number, nil
  12782. }
  12783. // AddNumber adds f to the "number" field.
  12784. func (m *CreditUsageMutation) AddNumber(f float32) {
  12785. if m.addnumber != nil {
  12786. *m.addnumber += f
  12787. } else {
  12788. m.addnumber = &f
  12789. }
  12790. }
  12791. // AddedNumber returns the value that was added to the "number" field in this mutation.
  12792. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  12793. v := m.addnumber
  12794. if v == nil {
  12795. return
  12796. }
  12797. return *v, true
  12798. }
  12799. // ResetNumber resets all changes to the "number" field.
  12800. func (m *CreditUsageMutation) ResetNumber() {
  12801. m.number = nil
  12802. m.addnumber = nil
  12803. }
  12804. // SetStatus sets the "status" field.
  12805. func (m *CreditUsageMutation) SetStatus(i int) {
  12806. m.status = &i
  12807. m.addstatus = nil
  12808. }
  12809. // Status returns the value of the "status" field in the mutation.
  12810. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  12811. v := m.status
  12812. if v == nil {
  12813. return
  12814. }
  12815. return *v, true
  12816. }
  12817. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  12818. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12820. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  12821. if !m.op.Is(OpUpdateOne) {
  12822. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12823. }
  12824. if m.id == nil || m.oldValue == nil {
  12825. return v, errors.New("OldStatus requires an ID field in the mutation")
  12826. }
  12827. oldValue, err := m.oldValue(ctx)
  12828. if err != nil {
  12829. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12830. }
  12831. return oldValue.Status, nil
  12832. }
  12833. // AddStatus adds i to the "status" field.
  12834. func (m *CreditUsageMutation) AddStatus(i int) {
  12835. if m.addstatus != nil {
  12836. *m.addstatus += i
  12837. } else {
  12838. m.addstatus = &i
  12839. }
  12840. }
  12841. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12842. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  12843. v := m.addstatus
  12844. if v == nil {
  12845. return
  12846. }
  12847. return *v, true
  12848. }
  12849. // ClearStatus clears the value of the "status" field.
  12850. func (m *CreditUsageMutation) ClearStatus() {
  12851. m.status = nil
  12852. m.addstatus = nil
  12853. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  12854. }
  12855. // StatusCleared returns if the "status" field was cleared in this mutation.
  12856. func (m *CreditUsageMutation) StatusCleared() bool {
  12857. _, ok := m.clearedFields[creditusage.FieldStatus]
  12858. return ok
  12859. }
  12860. // ResetStatus resets all changes to the "status" field.
  12861. func (m *CreditUsageMutation) ResetStatus() {
  12862. m.status = nil
  12863. m.addstatus = nil
  12864. delete(m.clearedFields, creditusage.FieldStatus)
  12865. }
  12866. // SetNtype sets the "ntype" field.
  12867. func (m *CreditUsageMutation) SetNtype(i int) {
  12868. m.ntype = &i
  12869. m.addntype = nil
  12870. }
  12871. // Ntype returns the value of the "ntype" field in the mutation.
  12872. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  12873. v := m.ntype
  12874. if v == nil {
  12875. return
  12876. }
  12877. return *v, true
  12878. }
  12879. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  12880. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12882. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  12883. if !m.op.Is(OpUpdateOne) {
  12884. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  12885. }
  12886. if m.id == nil || m.oldValue == nil {
  12887. return v, errors.New("OldNtype requires an ID field in the mutation")
  12888. }
  12889. oldValue, err := m.oldValue(ctx)
  12890. if err != nil {
  12891. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  12892. }
  12893. return oldValue.Ntype, nil
  12894. }
  12895. // AddNtype adds i to the "ntype" field.
  12896. func (m *CreditUsageMutation) AddNtype(i int) {
  12897. if m.addntype != nil {
  12898. *m.addntype += i
  12899. } else {
  12900. m.addntype = &i
  12901. }
  12902. }
  12903. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  12904. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  12905. v := m.addntype
  12906. if v == nil {
  12907. return
  12908. }
  12909. return *v, true
  12910. }
  12911. // ResetNtype resets all changes to the "ntype" field.
  12912. func (m *CreditUsageMutation) ResetNtype() {
  12913. m.ntype = nil
  12914. m.addntype = nil
  12915. }
  12916. // SetTable sets the "table" field.
  12917. func (m *CreditUsageMutation) SetTable(s string) {
  12918. m.table = &s
  12919. }
  12920. // Table returns the value of the "table" field in the mutation.
  12921. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  12922. v := m.table
  12923. if v == nil {
  12924. return
  12925. }
  12926. return *v, true
  12927. }
  12928. // OldTable returns the old "table" field's value of the CreditUsage entity.
  12929. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12931. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  12932. if !m.op.Is(OpUpdateOne) {
  12933. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  12934. }
  12935. if m.id == nil || m.oldValue == nil {
  12936. return v, errors.New("OldTable requires an ID field in the mutation")
  12937. }
  12938. oldValue, err := m.oldValue(ctx)
  12939. if err != nil {
  12940. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  12941. }
  12942. return oldValue.Table, nil
  12943. }
  12944. // ResetTable resets all changes to the "table" field.
  12945. func (m *CreditUsageMutation) ResetTable() {
  12946. m.table = nil
  12947. }
  12948. // SetOrganizationID sets the "organization_id" field.
  12949. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  12950. m.organization_id = &u
  12951. m.addorganization_id = nil
  12952. }
  12953. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12954. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  12955. v := m.organization_id
  12956. if v == nil {
  12957. return
  12958. }
  12959. return *v, true
  12960. }
  12961. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  12962. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  12963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12964. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12965. if !m.op.Is(OpUpdateOne) {
  12966. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12967. }
  12968. if m.id == nil || m.oldValue == nil {
  12969. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12970. }
  12971. oldValue, err := m.oldValue(ctx)
  12972. if err != nil {
  12973. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12974. }
  12975. return oldValue.OrganizationID, nil
  12976. }
  12977. // AddOrganizationID adds u to the "organization_id" field.
  12978. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  12979. if m.addorganization_id != nil {
  12980. *m.addorganization_id += u
  12981. } else {
  12982. m.addorganization_id = &u
  12983. }
  12984. }
  12985. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12986. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  12987. v := m.addorganization_id
  12988. if v == nil {
  12989. return
  12990. }
  12991. return *v, true
  12992. }
  12993. // ClearOrganizationID clears the value of the "organization_id" field.
  12994. func (m *CreditUsageMutation) ClearOrganizationID() {
  12995. m.organization_id = nil
  12996. m.addorganization_id = nil
  12997. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  12998. }
  12999. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13000. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  13001. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  13002. return ok
  13003. }
  13004. // ResetOrganizationID resets all changes to the "organization_id" field.
  13005. func (m *CreditUsageMutation) ResetOrganizationID() {
  13006. m.organization_id = nil
  13007. m.addorganization_id = nil
  13008. delete(m.clearedFields, creditusage.FieldOrganizationID)
  13009. }
  13010. // SetNid sets the "nid" field.
  13011. func (m *CreditUsageMutation) SetNid(u uint64) {
  13012. m.nid = &u
  13013. m.addnid = nil
  13014. }
  13015. // Nid returns the value of the "nid" field in the mutation.
  13016. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  13017. v := m.nid
  13018. if v == nil {
  13019. return
  13020. }
  13021. return *v, true
  13022. }
  13023. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  13024. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13026. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  13027. if !m.op.Is(OpUpdateOne) {
  13028. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  13029. }
  13030. if m.id == nil || m.oldValue == nil {
  13031. return v, errors.New("OldNid requires an ID field in the mutation")
  13032. }
  13033. oldValue, err := m.oldValue(ctx)
  13034. if err != nil {
  13035. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  13036. }
  13037. return oldValue.Nid, nil
  13038. }
  13039. // AddNid adds u to the "nid" field.
  13040. func (m *CreditUsageMutation) AddNid(u int64) {
  13041. if m.addnid != nil {
  13042. *m.addnid += u
  13043. } else {
  13044. m.addnid = &u
  13045. }
  13046. }
  13047. // AddedNid returns the value that was added to the "nid" field in this mutation.
  13048. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  13049. v := m.addnid
  13050. if v == nil {
  13051. return
  13052. }
  13053. return *v, true
  13054. }
  13055. // ResetNid resets all changes to the "nid" field.
  13056. func (m *CreditUsageMutation) ResetNid() {
  13057. m.nid = nil
  13058. m.addnid = nil
  13059. }
  13060. // SetReason sets the "reason" field.
  13061. func (m *CreditUsageMutation) SetReason(s string) {
  13062. m.reason = &s
  13063. }
  13064. // Reason returns the value of the "reason" field in the mutation.
  13065. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  13066. v := m.reason
  13067. if v == nil {
  13068. return
  13069. }
  13070. return *v, true
  13071. }
  13072. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  13073. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13075. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  13076. if !m.op.Is(OpUpdateOne) {
  13077. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  13078. }
  13079. if m.id == nil || m.oldValue == nil {
  13080. return v, errors.New("OldReason requires an ID field in the mutation")
  13081. }
  13082. oldValue, err := m.oldValue(ctx)
  13083. if err != nil {
  13084. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  13085. }
  13086. return oldValue.Reason, nil
  13087. }
  13088. // ResetReason resets all changes to the "reason" field.
  13089. func (m *CreditUsageMutation) ResetReason() {
  13090. m.reason = nil
  13091. }
  13092. // SetOperator sets the "operator" field.
  13093. func (m *CreditUsageMutation) SetOperator(s string) {
  13094. m.operator = &s
  13095. }
  13096. // Operator returns the value of the "operator" field in the mutation.
  13097. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  13098. v := m.operator
  13099. if v == nil {
  13100. return
  13101. }
  13102. return *v, true
  13103. }
  13104. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  13105. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13106. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13107. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  13108. if !m.op.Is(OpUpdateOne) {
  13109. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  13110. }
  13111. if m.id == nil || m.oldValue == nil {
  13112. return v, errors.New("OldOperator requires an ID field in the mutation")
  13113. }
  13114. oldValue, err := m.oldValue(ctx)
  13115. if err != nil {
  13116. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  13117. }
  13118. return oldValue.Operator, nil
  13119. }
  13120. // ResetOperator resets all changes to the "operator" field.
  13121. func (m *CreditUsageMutation) ResetOperator() {
  13122. m.operator = nil
  13123. }
  13124. // Where appends a list predicates to the CreditUsageMutation builder.
  13125. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  13126. m.predicates = append(m.predicates, ps...)
  13127. }
  13128. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  13129. // users can use type-assertion to append predicates that do not depend on any generated package.
  13130. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  13131. p := make([]predicate.CreditUsage, len(ps))
  13132. for i := range ps {
  13133. p[i] = ps[i]
  13134. }
  13135. m.Where(p...)
  13136. }
  13137. // Op returns the operation name.
  13138. func (m *CreditUsageMutation) Op() Op {
  13139. return m.op
  13140. }
  13141. // SetOp allows setting the mutation operation.
  13142. func (m *CreditUsageMutation) SetOp(op Op) {
  13143. m.op = op
  13144. }
  13145. // Type returns the node type of this mutation (CreditUsage).
  13146. func (m *CreditUsageMutation) Type() string {
  13147. return m.typ
  13148. }
  13149. // Fields returns all fields that were changed during this mutation. Note that in
  13150. // order to get all numeric fields that were incremented/decremented, call
  13151. // AddedFields().
  13152. func (m *CreditUsageMutation) Fields() []string {
  13153. fields := make([]string, 0, 12)
  13154. if m.created_at != nil {
  13155. fields = append(fields, creditusage.FieldCreatedAt)
  13156. }
  13157. if m.updated_at != nil {
  13158. fields = append(fields, creditusage.FieldUpdatedAt)
  13159. }
  13160. if m.deleted_at != nil {
  13161. fields = append(fields, creditusage.FieldDeletedAt)
  13162. }
  13163. if m.user_id != nil {
  13164. fields = append(fields, creditusage.FieldUserID)
  13165. }
  13166. if m.number != nil {
  13167. fields = append(fields, creditusage.FieldNumber)
  13168. }
  13169. if m.status != nil {
  13170. fields = append(fields, creditusage.FieldStatus)
  13171. }
  13172. if m.ntype != nil {
  13173. fields = append(fields, creditusage.FieldNtype)
  13174. }
  13175. if m.table != nil {
  13176. fields = append(fields, creditusage.FieldTable)
  13177. }
  13178. if m.organization_id != nil {
  13179. fields = append(fields, creditusage.FieldOrganizationID)
  13180. }
  13181. if m.nid != nil {
  13182. fields = append(fields, creditusage.FieldNid)
  13183. }
  13184. if m.reason != nil {
  13185. fields = append(fields, creditusage.FieldReason)
  13186. }
  13187. if m.operator != nil {
  13188. fields = append(fields, creditusage.FieldOperator)
  13189. }
  13190. return fields
  13191. }
  13192. // Field returns the value of a field with the given name. The second boolean
  13193. // return value indicates that this field was not set, or was not defined in the
  13194. // schema.
  13195. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  13196. switch name {
  13197. case creditusage.FieldCreatedAt:
  13198. return m.CreatedAt()
  13199. case creditusage.FieldUpdatedAt:
  13200. return m.UpdatedAt()
  13201. case creditusage.FieldDeletedAt:
  13202. return m.DeletedAt()
  13203. case creditusage.FieldUserID:
  13204. return m.UserID()
  13205. case creditusage.FieldNumber:
  13206. return m.Number()
  13207. case creditusage.FieldStatus:
  13208. return m.Status()
  13209. case creditusage.FieldNtype:
  13210. return m.Ntype()
  13211. case creditusage.FieldTable:
  13212. return m.Table()
  13213. case creditusage.FieldOrganizationID:
  13214. return m.OrganizationID()
  13215. case creditusage.FieldNid:
  13216. return m.Nid()
  13217. case creditusage.FieldReason:
  13218. return m.Reason()
  13219. case creditusage.FieldOperator:
  13220. return m.Operator()
  13221. }
  13222. return nil, false
  13223. }
  13224. // OldField returns the old value of the field from the database. An error is
  13225. // returned if the mutation operation is not UpdateOne, or the query to the
  13226. // database failed.
  13227. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13228. switch name {
  13229. case creditusage.FieldCreatedAt:
  13230. return m.OldCreatedAt(ctx)
  13231. case creditusage.FieldUpdatedAt:
  13232. return m.OldUpdatedAt(ctx)
  13233. case creditusage.FieldDeletedAt:
  13234. return m.OldDeletedAt(ctx)
  13235. case creditusage.FieldUserID:
  13236. return m.OldUserID(ctx)
  13237. case creditusage.FieldNumber:
  13238. return m.OldNumber(ctx)
  13239. case creditusage.FieldStatus:
  13240. return m.OldStatus(ctx)
  13241. case creditusage.FieldNtype:
  13242. return m.OldNtype(ctx)
  13243. case creditusage.FieldTable:
  13244. return m.OldTable(ctx)
  13245. case creditusage.FieldOrganizationID:
  13246. return m.OldOrganizationID(ctx)
  13247. case creditusage.FieldNid:
  13248. return m.OldNid(ctx)
  13249. case creditusage.FieldReason:
  13250. return m.OldReason(ctx)
  13251. case creditusage.FieldOperator:
  13252. return m.OldOperator(ctx)
  13253. }
  13254. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  13255. }
  13256. // SetField sets the value of a field with the given name. It returns an error if
  13257. // the field is not defined in the schema, or if the type mismatched the field
  13258. // type.
  13259. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  13260. switch name {
  13261. case creditusage.FieldCreatedAt:
  13262. v, ok := value.(time.Time)
  13263. if !ok {
  13264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13265. }
  13266. m.SetCreatedAt(v)
  13267. return nil
  13268. case creditusage.FieldUpdatedAt:
  13269. v, ok := value.(time.Time)
  13270. if !ok {
  13271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13272. }
  13273. m.SetUpdatedAt(v)
  13274. return nil
  13275. case creditusage.FieldDeletedAt:
  13276. v, ok := value.(time.Time)
  13277. if !ok {
  13278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13279. }
  13280. m.SetDeletedAt(v)
  13281. return nil
  13282. case creditusage.FieldUserID:
  13283. v, ok := value.(string)
  13284. if !ok {
  13285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13286. }
  13287. m.SetUserID(v)
  13288. return nil
  13289. case creditusage.FieldNumber:
  13290. v, ok := value.(float32)
  13291. if !ok {
  13292. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13293. }
  13294. m.SetNumber(v)
  13295. return nil
  13296. case creditusage.FieldStatus:
  13297. v, ok := value.(int)
  13298. if !ok {
  13299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13300. }
  13301. m.SetStatus(v)
  13302. return nil
  13303. case creditusage.FieldNtype:
  13304. v, ok := value.(int)
  13305. if !ok {
  13306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13307. }
  13308. m.SetNtype(v)
  13309. return nil
  13310. case creditusage.FieldTable:
  13311. v, ok := value.(string)
  13312. if !ok {
  13313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13314. }
  13315. m.SetTable(v)
  13316. return nil
  13317. case creditusage.FieldOrganizationID:
  13318. v, ok := value.(uint64)
  13319. if !ok {
  13320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13321. }
  13322. m.SetOrganizationID(v)
  13323. return nil
  13324. case creditusage.FieldNid:
  13325. v, ok := value.(uint64)
  13326. if !ok {
  13327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13328. }
  13329. m.SetNid(v)
  13330. return nil
  13331. case creditusage.FieldReason:
  13332. v, ok := value.(string)
  13333. if !ok {
  13334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13335. }
  13336. m.SetReason(v)
  13337. return nil
  13338. case creditusage.FieldOperator:
  13339. v, ok := value.(string)
  13340. if !ok {
  13341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13342. }
  13343. m.SetOperator(v)
  13344. return nil
  13345. }
  13346. return fmt.Errorf("unknown CreditUsage field %s", name)
  13347. }
  13348. // AddedFields returns all numeric fields that were incremented/decremented during
  13349. // this mutation.
  13350. func (m *CreditUsageMutation) AddedFields() []string {
  13351. var fields []string
  13352. if m.addnumber != nil {
  13353. fields = append(fields, creditusage.FieldNumber)
  13354. }
  13355. if m.addstatus != nil {
  13356. fields = append(fields, creditusage.FieldStatus)
  13357. }
  13358. if m.addntype != nil {
  13359. fields = append(fields, creditusage.FieldNtype)
  13360. }
  13361. if m.addorganization_id != nil {
  13362. fields = append(fields, creditusage.FieldOrganizationID)
  13363. }
  13364. if m.addnid != nil {
  13365. fields = append(fields, creditusage.FieldNid)
  13366. }
  13367. return fields
  13368. }
  13369. // AddedField returns the numeric value that was incremented/decremented on a field
  13370. // with the given name. The second boolean return value indicates that this field
  13371. // was not set, or was not defined in the schema.
  13372. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  13373. switch name {
  13374. case creditusage.FieldNumber:
  13375. return m.AddedNumber()
  13376. case creditusage.FieldStatus:
  13377. return m.AddedStatus()
  13378. case creditusage.FieldNtype:
  13379. return m.AddedNtype()
  13380. case creditusage.FieldOrganizationID:
  13381. return m.AddedOrganizationID()
  13382. case creditusage.FieldNid:
  13383. return m.AddedNid()
  13384. }
  13385. return nil, false
  13386. }
  13387. // AddField adds the value to the field with the given name. It returns an error if
  13388. // the field is not defined in the schema, or if the type mismatched the field
  13389. // type.
  13390. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  13391. switch name {
  13392. case creditusage.FieldNumber:
  13393. v, ok := value.(float32)
  13394. if !ok {
  13395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13396. }
  13397. m.AddNumber(v)
  13398. return nil
  13399. case creditusage.FieldStatus:
  13400. v, ok := value.(int)
  13401. if !ok {
  13402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13403. }
  13404. m.AddStatus(v)
  13405. return nil
  13406. case creditusage.FieldNtype:
  13407. v, ok := value.(int)
  13408. if !ok {
  13409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13410. }
  13411. m.AddNtype(v)
  13412. return nil
  13413. case creditusage.FieldOrganizationID:
  13414. v, ok := value.(int64)
  13415. if !ok {
  13416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13417. }
  13418. m.AddOrganizationID(v)
  13419. return nil
  13420. case creditusage.FieldNid:
  13421. v, ok := value.(int64)
  13422. if !ok {
  13423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13424. }
  13425. m.AddNid(v)
  13426. return nil
  13427. }
  13428. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  13429. }
  13430. // ClearedFields returns all nullable fields that were cleared during this
  13431. // mutation.
  13432. func (m *CreditUsageMutation) ClearedFields() []string {
  13433. var fields []string
  13434. if m.FieldCleared(creditusage.FieldDeletedAt) {
  13435. fields = append(fields, creditusage.FieldDeletedAt)
  13436. }
  13437. if m.FieldCleared(creditusage.FieldUserID) {
  13438. fields = append(fields, creditusage.FieldUserID)
  13439. }
  13440. if m.FieldCleared(creditusage.FieldStatus) {
  13441. fields = append(fields, creditusage.FieldStatus)
  13442. }
  13443. if m.FieldCleared(creditusage.FieldOrganizationID) {
  13444. fields = append(fields, creditusage.FieldOrganizationID)
  13445. }
  13446. return fields
  13447. }
  13448. // FieldCleared returns a boolean indicating if a field with the given name was
  13449. // cleared in this mutation.
  13450. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  13451. _, ok := m.clearedFields[name]
  13452. return ok
  13453. }
  13454. // ClearField clears the value of the field with the given name. It returns an
  13455. // error if the field is not defined in the schema.
  13456. func (m *CreditUsageMutation) ClearField(name string) error {
  13457. switch name {
  13458. case creditusage.FieldDeletedAt:
  13459. m.ClearDeletedAt()
  13460. return nil
  13461. case creditusage.FieldUserID:
  13462. m.ClearUserID()
  13463. return nil
  13464. case creditusage.FieldStatus:
  13465. m.ClearStatus()
  13466. return nil
  13467. case creditusage.FieldOrganizationID:
  13468. m.ClearOrganizationID()
  13469. return nil
  13470. }
  13471. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  13472. }
  13473. // ResetField resets all changes in the mutation for the field with the given name.
  13474. // It returns an error if the field is not defined in the schema.
  13475. func (m *CreditUsageMutation) ResetField(name string) error {
  13476. switch name {
  13477. case creditusage.FieldCreatedAt:
  13478. m.ResetCreatedAt()
  13479. return nil
  13480. case creditusage.FieldUpdatedAt:
  13481. m.ResetUpdatedAt()
  13482. return nil
  13483. case creditusage.FieldDeletedAt:
  13484. m.ResetDeletedAt()
  13485. return nil
  13486. case creditusage.FieldUserID:
  13487. m.ResetUserID()
  13488. return nil
  13489. case creditusage.FieldNumber:
  13490. m.ResetNumber()
  13491. return nil
  13492. case creditusage.FieldStatus:
  13493. m.ResetStatus()
  13494. return nil
  13495. case creditusage.FieldNtype:
  13496. m.ResetNtype()
  13497. return nil
  13498. case creditusage.FieldTable:
  13499. m.ResetTable()
  13500. return nil
  13501. case creditusage.FieldOrganizationID:
  13502. m.ResetOrganizationID()
  13503. return nil
  13504. case creditusage.FieldNid:
  13505. m.ResetNid()
  13506. return nil
  13507. case creditusage.FieldReason:
  13508. m.ResetReason()
  13509. return nil
  13510. case creditusage.FieldOperator:
  13511. m.ResetOperator()
  13512. return nil
  13513. }
  13514. return fmt.Errorf("unknown CreditUsage field %s", name)
  13515. }
  13516. // AddedEdges returns all edge names that were set/added in this mutation.
  13517. func (m *CreditUsageMutation) AddedEdges() []string {
  13518. edges := make([]string, 0, 0)
  13519. return edges
  13520. }
  13521. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13522. // name in this mutation.
  13523. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  13524. return nil
  13525. }
  13526. // RemovedEdges returns all edge names that were removed in this mutation.
  13527. func (m *CreditUsageMutation) RemovedEdges() []string {
  13528. edges := make([]string, 0, 0)
  13529. return edges
  13530. }
  13531. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13532. // the given name in this mutation.
  13533. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  13534. return nil
  13535. }
  13536. // ClearedEdges returns all edge names that were cleared in this mutation.
  13537. func (m *CreditUsageMutation) ClearedEdges() []string {
  13538. edges := make([]string, 0, 0)
  13539. return edges
  13540. }
  13541. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13542. // was cleared in this mutation.
  13543. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  13544. return false
  13545. }
  13546. // ClearEdge clears the value of the edge with the given name. It returns an error
  13547. // if that edge is not defined in the schema.
  13548. func (m *CreditUsageMutation) ClearEdge(name string) error {
  13549. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  13550. }
  13551. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13552. // It returns an error if the edge is not defined in the schema.
  13553. func (m *CreditUsageMutation) ResetEdge(name string) error {
  13554. return fmt.Errorf("unknown CreditUsage edge %s", name)
  13555. }
  13556. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  13557. type EmployeeMutation struct {
  13558. config
  13559. op Op
  13560. typ string
  13561. id *uint64
  13562. created_at *time.Time
  13563. updated_at *time.Time
  13564. deleted_at *time.Time
  13565. title *string
  13566. avatar *string
  13567. tags *string
  13568. hire_count *int
  13569. addhire_count *int
  13570. service_count *int
  13571. addservice_count *int
  13572. achievement_count *int
  13573. addachievement_count *int
  13574. intro *string
  13575. estimate *string
  13576. skill *string
  13577. ability_type *string
  13578. scene *string
  13579. switch_in *string
  13580. video_url *string
  13581. organization_id *uint64
  13582. addorganization_id *int64
  13583. category_id *uint64
  13584. addcategory_id *int64
  13585. api_base *string
  13586. api_key *string
  13587. ai_info *string
  13588. is_vip *int
  13589. addis_vip *int
  13590. chat_url *string
  13591. clearedFields map[string]struct{}
  13592. em_work_experiences map[uint64]struct{}
  13593. removedem_work_experiences map[uint64]struct{}
  13594. clearedem_work_experiences bool
  13595. em_tutorial map[uint64]struct{}
  13596. removedem_tutorial map[uint64]struct{}
  13597. clearedem_tutorial bool
  13598. done bool
  13599. oldValue func(context.Context) (*Employee, error)
  13600. predicates []predicate.Employee
  13601. }
  13602. var _ ent.Mutation = (*EmployeeMutation)(nil)
  13603. // employeeOption allows management of the mutation configuration using functional options.
  13604. type employeeOption func(*EmployeeMutation)
  13605. // newEmployeeMutation creates new mutation for the Employee entity.
  13606. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  13607. m := &EmployeeMutation{
  13608. config: c,
  13609. op: op,
  13610. typ: TypeEmployee,
  13611. clearedFields: make(map[string]struct{}),
  13612. }
  13613. for _, opt := range opts {
  13614. opt(m)
  13615. }
  13616. return m
  13617. }
  13618. // withEmployeeID sets the ID field of the mutation.
  13619. func withEmployeeID(id uint64) employeeOption {
  13620. return func(m *EmployeeMutation) {
  13621. var (
  13622. err error
  13623. once sync.Once
  13624. value *Employee
  13625. )
  13626. m.oldValue = func(ctx context.Context) (*Employee, error) {
  13627. once.Do(func() {
  13628. if m.done {
  13629. err = errors.New("querying old values post mutation is not allowed")
  13630. } else {
  13631. value, err = m.Client().Employee.Get(ctx, id)
  13632. }
  13633. })
  13634. return value, err
  13635. }
  13636. m.id = &id
  13637. }
  13638. }
  13639. // withEmployee sets the old Employee of the mutation.
  13640. func withEmployee(node *Employee) employeeOption {
  13641. return func(m *EmployeeMutation) {
  13642. m.oldValue = func(context.Context) (*Employee, error) {
  13643. return node, nil
  13644. }
  13645. m.id = &node.ID
  13646. }
  13647. }
  13648. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13649. // executed in a transaction (ent.Tx), a transactional client is returned.
  13650. func (m EmployeeMutation) Client() *Client {
  13651. client := &Client{config: m.config}
  13652. client.init()
  13653. return client
  13654. }
  13655. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13656. // it returns an error otherwise.
  13657. func (m EmployeeMutation) Tx() (*Tx, error) {
  13658. if _, ok := m.driver.(*txDriver); !ok {
  13659. return nil, errors.New("ent: mutation is not running in a transaction")
  13660. }
  13661. tx := &Tx{config: m.config}
  13662. tx.init()
  13663. return tx, nil
  13664. }
  13665. // SetID sets the value of the id field. Note that this
  13666. // operation is only accepted on creation of Employee entities.
  13667. func (m *EmployeeMutation) SetID(id uint64) {
  13668. m.id = &id
  13669. }
  13670. // ID returns the ID value in the mutation. Note that the ID is only available
  13671. // if it was provided to the builder or after it was returned from the database.
  13672. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  13673. if m.id == nil {
  13674. return
  13675. }
  13676. return *m.id, true
  13677. }
  13678. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13679. // That means, if the mutation is applied within a transaction with an isolation level such
  13680. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13681. // or updated by the mutation.
  13682. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  13683. switch {
  13684. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13685. id, exists := m.ID()
  13686. if exists {
  13687. return []uint64{id}, nil
  13688. }
  13689. fallthrough
  13690. case m.op.Is(OpUpdate | OpDelete):
  13691. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  13692. default:
  13693. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13694. }
  13695. }
  13696. // SetCreatedAt sets the "created_at" field.
  13697. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  13698. m.created_at = &t
  13699. }
  13700. // CreatedAt returns the value of the "created_at" field in the mutation.
  13701. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  13702. v := m.created_at
  13703. if v == nil {
  13704. return
  13705. }
  13706. return *v, true
  13707. }
  13708. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  13709. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13711. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13712. if !m.op.Is(OpUpdateOne) {
  13713. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13714. }
  13715. if m.id == nil || m.oldValue == nil {
  13716. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13717. }
  13718. oldValue, err := m.oldValue(ctx)
  13719. if err != nil {
  13720. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13721. }
  13722. return oldValue.CreatedAt, nil
  13723. }
  13724. // ResetCreatedAt resets all changes to the "created_at" field.
  13725. func (m *EmployeeMutation) ResetCreatedAt() {
  13726. m.created_at = nil
  13727. }
  13728. // SetUpdatedAt sets the "updated_at" field.
  13729. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  13730. m.updated_at = &t
  13731. }
  13732. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13733. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  13734. v := m.updated_at
  13735. if v == nil {
  13736. return
  13737. }
  13738. return *v, true
  13739. }
  13740. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  13741. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13743. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13744. if !m.op.Is(OpUpdateOne) {
  13745. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13746. }
  13747. if m.id == nil || m.oldValue == nil {
  13748. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13749. }
  13750. oldValue, err := m.oldValue(ctx)
  13751. if err != nil {
  13752. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13753. }
  13754. return oldValue.UpdatedAt, nil
  13755. }
  13756. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13757. func (m *EmployeeMutation) ResetUpdatedAt() {
  13758. m.updated_at = nil
  13759. }
  13760. // SetDeletedAt sets the "deleted_at" field.
  13761. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  13762. m.deleted_at = &t
  13763. }
  13764. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13765. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  13766. v := m.deleted_at
  13767. if v == nil {
  13768. return
  13769. }
  13770. return *v, true
  13771. }
  13772. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  13773. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13775. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13776. if !m.op.Is(OpUpdateOne) {
  13777. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13778. }
  13779. if m.id == nil || m.oldValue == nil {
  13780. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13781. }
  13782. oldValue, err := m.oldValue(ctx)
  13783. if err != nil {
  13784. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13785. }
  13786. return oldValue.DeletedAt, nil
  13787. }
  13788. // ClearDeletedAt clears the value of the "deleted_at" field.
  13789. func (m *EmployeeMutation) ClearDeletedAt() {
  13790. m.deleted_at = nil
  13791. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  13792. }
  13793. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13794. func (m *EmployeeMutation) DeletedAtCleared() bool {
  13795. _, ok := m.clearedFields[employee.FieldDeletedAt]
  13796. return ok
  13797. }
  13798. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13799. func (m *EmployeeMutation) ResetDeletedAt() {
  13800. m.deleted_at = nil
  13801. delete(m.clearedFields, employee.FieldDeletedAt)
  13802. }
  13803. // SetTitle sets the "title" field.
  13804. func (m *EmployeeMutation) SetTitle(s string) {
  13805. m.title = &s
  13806. }
  13807. // Title returns the value of the "title" field in the mutation.
  13808. func (m *EmployeeMutation) Title() (r string, exists bool) {
  13809. v := m.title
  13810. if v == nil {
  13811. return
  13812. }
  13813. return *v, true
  13814. }
  13815. // OldTitle returns the old "title" field's value of the Employee entity.
  13816. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13818. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  13819. if !m.op.Is(OpUpdateOne) {
  13820. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13821. }
  13822. if m.id == nil || m.oldValue == nil {
  13823. return v, errors.New("OldTitle requires an ID field in the mutation")
  13824. }
  13825. oldValue, err := m.oldValue(ctx)
  13826. if err != nil {
  13827. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13828. }
  13829. return oldValue.Title, nil
  13830. }
  13831. // ResetTitle resets all changes to the "title" field.
  13832. func (m *EmployeeMutation) ResetTitle() {
  13833. m.title = nil
  13834. }
  13835. // SetAvatar sets the "avatar" field.
  13836. func (m *EmployeeMutation) SetAvatar(s string) {
  13837. m.avatar = &s
  13838. }
  13839. // Avatar returns the value of the "avatar" field in the mutation.
  13840. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  13841. v := m.avatar
  13842. if v == nil {
  13843. return
  13844. }
  13845. return *v, true
  13846. }
  13847. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  13848. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13850. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  13851. if !m.op.Is(OpUpdateOne) {
  13852. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  13853. }
  13854. if m.id == nil || m.oldValue == nil {
  13855. return v, errors.New("OldAvatar requires an ID field in the mutation")
  13856. }
  13857. oldValue, err := m.oldValue(ctx)
  13858. if err != nil {
  13859. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  13860. }
  13861. return oldValue.Avatar, nil
  13862. }
  13863. // ResetAvatar resets all changes to the "avatar" field.
  13864. func (m *EmployeeMutation) ResetAvatar() {
  13865. m.avatar = nil
  13866. }
  13867. // SetTags sets the "tags" field.
  13868. func (m *EmployeeMutation) SetTags(s string) {
  13869. m.tags = &s
  13870. }
  13871. // Tags returns the value of the "tags" field in the mutation.
  13872. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  13873. v := m.tags
  13874. if v == nil {
  13875. return
  13876. }
  13877. return *v, true
  13878. }
  13879. // OldTags returns the old "tags" field's value of the Employee entity.
  13880. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13882. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  13883. if !m.op.Is(OpUpdateOne) {
  13884. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  13885. }
  13886. if m.id == nil || m.oldValue == nil {
  13887. return v, errors.New("OldTags requires an ID field in the mutation")
  13888. }
  13889. oldValue, err := m.oldValue(ctx)
  13890. if err != nil {
  13891. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  13892. }
  13893. return oldValue.Tags, nil
  13894. }
  13895. // ResetTags resets all changes to the "tags" field.
  13896. func (m *EmployeeMutation) ResetTags() {
  13897. m.tags = nil
  13898. }
  13899. // SetHireCount sets the "hire_count" field.
  13900. func (m *EmployeeMutation) SetHireCount(i int) {
  13901. m.hire_count = &i
  13902. m.addhire_count = nil
  13903. }
  13904. // HireCount returns the value of the "hire_count" field in the mutation.
  13905. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  13906. v := m.hire_count
  13907. if v == nil {
  13908. return
  13909. }
  13910. return *v, true
  13911. }
  13912. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  13913. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13915. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  13916. if !m.op.Is(OpUpdateOne) {
  13917. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  13918. }
  13919. if m.id == nil || m.oldValue == nil {
  13920. return v, errors.New("OldHireCount requires an ID field in the mutation")
  13921. }
  13922. oldValue, err := m.oldValue(ctx)
  13923. if err != nil {
  13924. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  13925. }
  13926. return oldValue.HireCount, nil
  13927. }
  13928. // AddHireCount adds i to the "hire_count" field.
  13929. func (m *EmployeeMutation) AddHireCount(i int) {
  13930. if m.addhire_count != nil {
  13931. *m.addhire_count += i
  13932. } else {
  13933. m.addhire_count = &i
  13934. }
  13935. }
  13936. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  13937. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  13938. v := m.addhire_count
  13939. if v == nil {
  13940. return
  13941. }
  13942. return *v, true
  13943. }
  13944. // ResetHireCount resets all changes to the "hire_count" field.
  13945. func (m *EmployeeMutation) ResetHireCount() {
  13946. m.hire_count = nil
  13947. m.addhire_count = nil
  13948. }
  13949. // SetServiceCount sets the "service_count" field.
  13950. func (m *EmployeeMutation) SetServiceCount(i int) {
  13951. m.service_count = &i
  13952. m.addservice_count = nil
  13953. }
  13954. // ServiceCount returns the value of the "service_count" field in the mutation.
  13955. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  13956. v := m.service_count
  13957. if v == nil {
  13958. return
  13959. }
  13960. return *v, true
  13961. }
  13962. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  13963. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  13964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13965. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  13966. if !m.op.Is(OpUpdateOne) {
  13967. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  13968. }
  13969. if m.id == nil || m.oldValue == nil {
  13970. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  13971. }
  13972. oldValue, err := m.oldValue(ctx)
  13973. if err != nil {
  13974. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  13975. }
  13976. return oldValue.ServiceCount, nil
  13977. }
  13978. // AddServiceCount adds i to the "service_count" field.
  13979. func (m *EmployeeMutation) AddServiceCount(i int) {
  13980. if m.addservice_count != nil {
  13981. *m.addservice_count += i
  13982. } else {
  13983. m.addservice_count = &i
  13984. }
  13985. }
  13986. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  13987. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  13988. v := m.addservice_count
  13989. if v == nil {
  13990. return
  13991. }
  13992. return *v, true
  13993. }
  13994. // ResetServiceCount resets all changes to the "service_count" field.
  13995. func (m *EmployeeMutation) ResetServiceCount() {
  13996. m.service_count = nil
  13997. m.addservice_count = nil
  13998. }
  13999. // SetAchievementCount sets the "achievement_count" field.
  14000. func (m *EmployeeMutation) SetAchievementCount(i int) {
  14001. m.achievement_count = &i
  14002. m.addachievement_count = nil
  14003. }
  14004. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  14005. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  14006. v := m.achievement_count
  14007. if v == nil {
  14008. return
  14009. }
  14010. return *v, true
  14011. }
  14012. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  14013. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14015. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  14016. if !m.op.Is(OpUpdateOne) {
  14017. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  14018. }
  14019. if m.id == nil || m.oldValue == nil {
  14020. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  14021. }
  14022. oldValue, err := m.oldValue(ctx)
  14023. if err != nil {
  14024. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  14025. }
  14026. return oldValue.AchievementCount, nil
  14027. }
  14028. // AddAchievementCount adds i to the "achievement_count" field.
  14029. func (m *EmployeeMutation) AddAchievementCount(i int) {
  14030. if m.addachievement_count != nil {
  14031. *m.addachievement_count += i
  14032. } else {
  14033. m.addachievement_count = &i
  14034. }
  14035. }
  14036. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  14037. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  14038. v := m.addachievement_count
  14039. if v == nil {
  14040. return
  14041. }
  14042. return *v, true
  14043. }
  14044. // ResetAchievementCount resets all changes to the "achievement_count" field.
  14045. func (m *EmployeeMutation) ResetAchievementCount() {
  14046. m.achievement_count = nil
  14047. m.addachievement_count = nil
  14048. }
  14049. // SetIntro sets the "intro" field.
  14050. func (m *EmployeeMutation) SetIntro(s string) {
  14051. m.intro = &s
  14052. }
  14053. // Intro returns the value of the "intro" field in the mutation.
  14054. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  14055. v := m.intro
  14056. if v == nil {
  14057. return
  14058. }
  14059. return *v, true
  14060. }
  14061. // OldIntro returns the old "intro" field's value of the Employee entity.
  14062. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14064. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  14065. if !m.op.Is(OpUpdateOne) {
  14066. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  14067. }
  14068. if m.id == nil || m.oldValue == nil {
  14069. return v, errors.New("OldIntro requires an ID field in the mutation")
  14070. }
  14071. oldValue, err := m.oldValue(ctx)
  14072. if err != nil {
  14073. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  14074. }
  14075. return oldValue.Intro, nil
  14076. }
  14077. // ResetIntro resets all changes to the "intro" field.
  14078. func (m *EmployeeMutation) ResetIntro() {
  14079. m.intro = nil
  14080. }
  14081. // SetEstimate sets the "estimate" field.
  14082. func (m *EmployeeMutation) SetEstimate(s string) {
  14083. m.estimate = &s
  14084. }
  14085. // Estimate returns the value of the "estimate" field in the mutation.
  14086. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  14087. v := m.estimate
  14088. if v == nil {
  14089. return
  14090. }
  14091. return *v, true
  14092. }
  14093. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  14094. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14096. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  14097. if !m.op.Is(OpUpdateOne) {
  14098. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  14099. }
  14100. if m.id == nil || m.oldValue == nil {
  14101. return v, errors.New("OldEstimate requires an ID field in the mutation")
  14102. }
  14103. oldValue, err := m.oldValue(ctx)
  14104. if err != nil {
  14105. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  14106. }
  14107. return oldValue.Estimate, nil
  14108. }
  14109. // ResetEstimate resets all changes to the "estimate" field.
  14110. func (m *EmployeeMutation) ResetEstimate() {
  14111. m.estimate = nil
  14112. }
  14113. // SetSkill sets the "skill" field.
  14114. func (m *EmployeeMutation) SetSkill(s string) {
  14115. m.skill = &s
  14116. }
  14117. // Skill returns the value of the "skill" field in the mutation.
  14118. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  14119. v := m.skill
  14120. if v == nil {
  14121. return
  14122. }
  14123. return *v, true
  14124. }
  14125. // OldSkill returns the old "skill" field's value of the Employee entity.
  14126. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14128. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  14129. if !m.op.Is(OpUpdateOne) {
  14130. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  14131. }
  14132. if m.id == nil || m.oldValue == nil {
  14133. return v, errors.New("OldSkill requires an ID field in the mutation")
  14134. }
  14135. oldValue, err := m.oldValue(ctx)
  14136. if err != nil {
  14137. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  14138. }
  14139. return oldValue.Skill, nil
  14140. }
  14141. // ResetSkill resets all changes to the "skill" field.
  14142. func (m *EmployeeMutation) ResetSkill() {
  14143. m.skill = nil
  14144. }
  14145. // SetAbilityType sets the "ability_type" field.
  14146. func (m *EmployeeMutation) SetAbilityType(s string) {
  14147. m.ability_type = &s
  14148. }
  14149. // AbilityType returns the value of the "ability_type" field in the mutation.
  14150. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  14151. v := m.ability_type
  14152. if v == nil {
  14153. return
  14154. }
  14155. return *v, true
  14156. }
  14157. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  14158. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14160. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  14161. if !m.op.Is(OpUpdateOne) {
  14162. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  14163. }
  14164. if m.id == nil || m.oldValue == nil {
  14165. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  14166. }
  14167. oldValue, err := m.oldValue(ctx)
  14168. if err != nil {
  14169. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  14170. }
  14171. return oldValue.AbilityType, nil
  14172. }
  14173. // ResetAbilityType resets all changes to the "ability_type" field.
  14174. func (m *EmployeeMutation) ResetAbilityType() {
  14175. m.ability_type = nil
  14176. }
  14177. // SetScene sets the "scene" field.
  14178. func (m *EmployeeMutation) SetScene(s string) {
  14179. m.scene = &s
  14180. }
  14181. // Scene returns the value of the "scene" field in the mutation.
  14182. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  14183. v := m.scene
  14184. if v == nil {
  14185. return
  14186. }
  14187. return *v, true
  14188. }
  14189. // OldScene returns the old "scene" field's value of the Employee entity.
  14190. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14192. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  14193. if !m.op.Is(OpUpdateOne) {
  14194. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  14195. }
  14196. if m.id == nil || m.oldValue == nil {
  14197. return v, errors.New("OldScene requires an ID field in the mutation")
  14198. }
  14199. oldValue, err := m.oldValue(ctx)
  14200. if err != nil {
  14201. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  14202. }
  14203. return oldValue.Scene, nil
  14204. }
  14205. // ResetScene resets all changes to the "scene" field.
  14206. func (m *EmployeeMutation) ResetScene() {
  14207. m.scene = nil
  14208. }
  14209. // SetSwitchIn sets the "switch_in" field.
  14210. func (m *EmployeeMutation) SetSwitchIn(s string) {
  14211. m.switch_in = &s
  14212. }
  14213. // SwitchIn returns the value of the "switch_in" field in the mutation.
  14214. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  14215. v := m.switch_in
  14216. if v == nil {
  14217. return
  14218. }
  14219. return *v, true
  14220. }
  14221. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  14222. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14224. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  14225. if !m.op.Is(OpUpdateOne) {
  14226. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  14227. }
  14228. if m.id == nil || m.oldValue == nil {
  14229. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  14230. }
  14231. oldValue, err := m.oldValue(ctx)
  14232. if err != nil {
  14233. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  14234. }
  14235. return oldValue.SwitchIn, nil
  14236. }
  14237. // ResetSwitchIn resets all changes to the "switch_in" field.
  14238. func (m *EmployeeMutation) ResetSwitchIn() {
  14239. m.switch_in = nil
  14240. }
  14241. // SetVideoURL sets the "video_url" field.
  14242. func (m *EmployeeMutation) SetVideoURL(s string) {
  14243. m.video_url = &s
  14244. }
  14245. // VideoURL returns the value of the "video_url" field in the mutation.
  14246. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  14247. v := m.video_url
  14248. if v == nil {
  14249. return
  14250. }
  14251. return *v, true
  14252. }
  14253. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  14254. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14256. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  14257. if !m.op.Is(OpUpdateOne) {
  14258. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  14259. }
  14260. if m.id == nil || m.oldValue == nil {
  14261. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  14262. }
  14263. oldValue, err := m.oldValue(ctx)
  14264. if err != nil {
  14265. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  14266. }
  14267. return oldValue.VideoURL, nil
  14268. }
  14269. // ResetVideoURL resets all changes to the "video_url" field.
  14270. func (m *EmployeeMutation) ResetVideoURL() {
  14271. m.video_url = nil
  14272. }
  14273. // SetOrganizationID sets the "organization_id" field.
  14274. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  14275. m.organization_id = &u
  14276. m.addorganization_id = nil
  14277. }
  14278. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14279. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  14280. v := m.organization_id
  14281. if v == nil {
  14282. return
  14283. }
  14284. return *v, true
  14285. }
  14286. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  14287. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14289. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14290. if !m.op.Is(OpUpdateOne) {
  14291. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14292. }
  14293. if m.id == nil || m.oldValue == nil {
  14294. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14295. }
  14296. oldValue, err := m.oldValue(ctx)
  14297. if err != nil {
  14298. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14299. }
  14300. return oldValue.OrganizationID, nil
  14301. }
  14302. // AddOrganizationID adds u to the "organization_id" field.
  14303. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  14304. if m.addorganization_id != nil {
  14305. *m.addorganization_id += u
  14306. } else {
  14307. m.addorganization_id = &u
  14308. }
  14309. }
  14310. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14311. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  14312. v := m.addorganization_id
  14313. if v == nil {
  14314. return
  14315. }
  14316. return *v, true
  14317. }
  14318. // ResetOrganizationID resets all changes to the "organization_id" field.
  14319. func (m *EmployeeMutation) ResetOrganizationID() {
  14320. m.organization_id = nil
  14321. m.addorganization_id = nil
  14322. }
  14323. // SetCategoryID sets the "category_id" field.
  14324. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  14325. m.category_id = &u
  14326. m.addcategory_id = nil
  14327. }
  14328. // CategoryID returns the value of the "category_id" field in the mutation.
  14329. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  14330. v := m.category_id
  14331. if v == nil {
  14332. return
  14333. }
  14334. return *v, true
  14335. }
  14336. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  14337. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14339. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  14340. if !m.op.Is(OpUpdateOne) {
  14341. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  14342. }
  14343. if m.id == nil || m.oldValue == nil {
  14344. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  14345. }
  14346. oldValue, err := m.oldValue(ctx)
  14347. if err != nil {
  14348. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  14349. }
  14350. return oldValue.CategoryID, nil
  14351. }
  14352. // AddCategoryID adds u to the "category_id" field.
  14353. func (m *EmployeeMutation) AddCategoryID(u int64) {
  14354. if m.addcategory_id != nil {
  14355. *m.addcategory_id += u
  14356. } else {
  14357. m.addcategory_id = &u
  14358. }
  14359. }
  14360. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  14361. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  14362. v := m.addcategory_id
  14363. if v == nil {
  14364. return
  14365. }
  14366. return *v, true
  14367. }
  14368. // ResetCategoryID resets all changes to the "category_id" field.
  14369. func (m *EmployeeMutation) ResetCategoryID() {
  14370. m.category_id = nil
  14371. m.addcategory_id = nil
  14372. }
  14373. // SetAPIBase sets the "api_base" field.
  14374. func (m *EmployeeMutation) SetAPIBase(s string) {
  14375. m.api_base = &s
  14376. }
  14377. // APIBase returns the value of the "api_base" field in the mutation.
  14378. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  14379. v := m.api_base
  14380. if v == nil {
  14381. return
  14382. }
  14383. return *v, true
  14384. }
  14385. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  14386. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14388. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  14389. if !m.op.Is(OpUpdateOne) {
  14390. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  14391. }
  14392. if m.id == nil || m.oldValue == nil {
  14393. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  14394. }
  14395. oldValue, err := m.oldValue(ctx)
  14396. if err != nil {
  14397. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  14398. }
  14399. return oldValue.APIBase, nil
  14400. }
  14401. // ResetAPIBase resets all changes to the "api_base" field.
  14402. func (m *EmployeeMutation) ResetAPIBase() {
  14403. m.api_base = nil
  14404. }
  14405. // SetAPIKey sets the "api_key" field.
  14406. func (m *EmployeeMutation) SetAPIKey(s string) {
  14407. m.api_key = &s
  14408. }
  14409. // APIKey returns the value of the "api_key" field in the mutation.
  14410. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  14411. v := m.api_key
  14412. if v == nil {
  14413. return
  14414. }
  14415. return *v, true
  14416. }
  14417. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  14418. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14420. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  14421. if !m.op.Is(OpUpdateOne) {
  14422. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  14423. }
  14424. if m.id == nil || m.oldValue == nil {
  14425. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  14426. }
  14427. oldValue, err := m.oldValue(ctx)
  14428. if err != nil {
  14429. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  14430. }
  14431. return oldValue.APIKey, nil
  14432. }
  14433. // ResetAPIKey resets all changes to the "api_key" field.
  14434. func (m *EmployeeMutation) ResetAPIKey() {
  14435. m.api_key = nil
  14436. }
  14437. // SetAiInfo sets the "ai_info" field.
  14438. func (m *EmployeeMutation) SetAiInfo(s string) {
  14439. m.ai_info = &s
  14440. }
  14441. // AiInfo returns the value of the "ai_info" field in the mutation.
  14442. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  14443. v := m.ai_info
  14444. if v == nil {
  14445. return
  14446. }
  14447. return *v, true
  14448. }
  14449. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  14450. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14452. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  14453. if !m.op.Is(OpUpdateOne) {
  14454. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  14455. }
  14456. if m.id == nil || m.oldValue == nil {
  14457. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  14458. }
  14459. oldValue, err := m.oldValue(ctx)
  14460. if err != nil {
  14461. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  14462. }
  14463. return oldValue.AiInfo, nil
  14464. }
  14465. // ClearAiInfo clears the value of the "ai_info" field.
  14466. func (m *EmployeeMutation) ClearAiInfo() {
  14467. m.ai_info = nil
  14468. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  14469. }
  14470. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  14471. func (m *EmployeeMutation) AiInfoCleared() bool {
  14472. _, ok := m.clearedFields[employee.FieldAiInfo]
  14473. return ok
  14474. }
  14475. // ResetAiInfo resets all changes to the "ai_info" field.
  14476. func (m *EmployeeMutation) ResetAiInfo() {
  14477. m.ai_info = nil
  14478. delete(m.clearedFields, employee.FieldAiInfo)
  14479. }
  14480. // SetIsVip sets the "is_vip" field.
  14481. func (m *EmployeeMutation) SetIsVip(i int) {
  14482. m.is_vip = &i
  14483. m.addis_vip = nil
  14484. }
  14485. // IsVip returns the value of the "is_vip" field in the mutation.
  14486. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  14487. v := m.is_vip
  14488. if v == nil {
  14489. return
  14490. }
  14491. return *v, true
  14492. }
  14493. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  14494. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14496. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  14497. if !m.op.Is(OpUpdateOne) {
  14498. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  14499. }
  14500. if m.id == nil || m.oldValue == nil {
  14501. return v, errors.New("OldIsVip requires an ID field in the mutation")
  14502. }
  14503. oldValue, err := m.oldValue(ctx)
  14504. if err != nil {
  14505. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  14506. }
  14507. return oldValue.IsVip, nil
  14508. }
  14509. // AddIsVip adds i to the "is_vip" field.
  14510. func (m *EmployeeMutation) AddIsVip(i int) {
  14511. if m.addis_vip != nil {
  14512. *m.addis_vip += i
  14513. } else {
  14514. m.addis_vip = &i
  14515. }
  14516. }
  14517. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  14518. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  14519. v := m.addis_vip
  14520. if v == nil {
  14521. return
  14522. }
  14523. return *v, true
  14524. }
  14525. // ResetIsVip resets all changes to the "is_vip" field.
  14526. func (m *EmployeeMutation) ResetIsVip() {
  14527. m.is_vip = nil
  14528. m.addis_vip = nil
  14529. }
  14530. // SetChatURL sets the "chat_url" field.
  14531. func (m *EmployeeMutation) SetChatURL(s string) {
  14532. m.chat_url = &s
  14533. }
  14534. // ChatURL returns the value of the "chat_url" field in the mutation.
  14535. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  14536. v := m.chat_url
  14537. if v == nil {
  14538. return
  14539. }
  14540. return *v, true
  14541. }
  14542. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  14543. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14545. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  14546. if !m.op.Is(OpUpdateOne) {
  14547. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  14548. }
  14549. if m.id == nil || m.oldValue == nil {
  14550. return v, errors.New("OldChatURL requires an ID field in the mutation")
  14551. }
  14552. oldValue, err := m.oldValue(ctx)
  14553. if err != nil {
  14554. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  14555. }
  14556. return oldValue.ChatURL, nil
  14557. }
  14558. // ResetChatURL resets all changes to the "chat_url" field.
  14559. func (m *EmployeeMutation) ResetChatURL() {
  14560. m.chat_url = nil
  14561. }
  14562. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  14563. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  14564. if m.em_work_experiences == nil {
  14565. m.em_work_experiences = make(map[uint64]struct{})
  14566. }
  14567. for i := range ids {
  14568. m.em_work_experiences[ids[i]] = struct{}{}
  14569. }
  14570. }
  14571. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  14572. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  14573. m.clearedem_work_experiences = true
  14574. }
  14575. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  14576. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  14577. return m.clearedem_work_experiences
  14578. }
  14579. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  14580. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  14581. if m.removedem_work_experiences == nil {
  14582. m.removedem_work_experiences = make(map[uint64]struct{})
  14583. }
  14584. for i := range ids {
  14585. delete(m.em_work_experiences, ids[i])
  14586. m.removedem_work_experiences[ids[i]] = struct{}{}
  14587. }
  14588. }
  14589. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  14590. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  14591. for id := range m.removedem_work_experiences {
  14592. ids = append(ids, id)
  14593. }
  14594. return
  14595. }
  14596. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  14597. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  14598. for id := range m.em_work_experiences {
  14599. ids = append(ids, id)
  14600. }
  14601. return
  14602. }
  14603. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  14604. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  14605. m.em_work_experiences = nil
  14606. m.clearedem_work_experiences = false
  14607. m.removedem_work_experiences = nil
  14608. }
  14609. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  14610. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  14611. if m.em_tutorial == nil {
  14612. m.em_tutorial = make(map[uint64]struct{})
  14613. }
  14614. for i := range ids {
  14615. m.em_tutorial[ids[i]] = struct{}{}
  14616. }
  14617. }
  14618. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  14619. func (m *EmployeeMutation) ClearEmTutorial() {
  14620. m.clearedem_tutorial = true
  14621. }
  14622. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  14623. func (m *EmployeeMutation) EmTutorialCleared() bool {
  14624. return m.clearedem_tutorial
  14625. }
  14626. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  14627. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  14628. if m.removedem_tutorial == nil {
  14629. m.removedem_tutorial = make(map[uint64]struct{})
  14630. }
  14631. for i := range ids {
  14632. delete(m.em_tutorial, ids[i])
  14633. m.removedem_tutorial[ids[i]] = struct{}{}
  14634. }
  14635. }
  14636. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  14637. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  14638. for id := range m.removedem_tutorial {
  14639. ids = append(ids, id)
  14640. }
  14641. return
  14642. }
  14643. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  14644. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  14645. for id := range m.em_tutorial {
  14646. ids = append(ids, id)
  14647. }
  14648. return
  14649. }
  14650. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  14651. func (m *EmployeeMutation) ResetEmTutorial() {
  14652. m.em_tutorial = nil
  14653. m.clearedem_tutorial = false
  14654. m.removedem_tutorial = nil
  14655. }
  14656. // Where appends a list predicates to the EmployeeMutation builder.
  14657. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  14658. m.predicates = append(m.predicates, ps...)
  14659. }
  14660. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  14661. // users can use type-assertion to append predicates that do not depend on any generated package.
  14662. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  14663. p := make([]predicate.Employee, len(ps))
  14664. for i := range ps {
  14665. p[i] = ps[i]
  14666. }
  14667. m.Where(p...)
  14668. }
  14669. // Op returns the operation name.
  14670. func (m *EmployeeMutation) Op() Op {
  14671. return m.op
  14672. }
  14673. // SetOp allows setting the mutation operation.
  14674. func (m *EmployeeMutation) SetOp(op Op) {
  14675. m.op = op
  14676. }
  14677. // Type returns the node type of this mutation (Employee).
  14678. func (m *EmployeeMutation) Type() string {
  14679. return m.typ
  14680. }
  14681. // Fields returns all fields that were changed during this mutation. Note that in
  14682. // order to get all numeric fields that were incremented/decremented, call
  14683. // AddedFields().
  14684. func (m *EmployeeMutation) Fields() []string {
  14685. fields := make([]string, 0, 23)
  14686. if m.created_at != nil {
  14687. fields = append(fields, employee.FieldCreatedAt)
  14688. }
  14689. if m.updated_at != nil {
  14690. fields = append(fields, employee.FieldUpdatedAt)
  14691. }
  14692. if m.deleted_at != nil {
  14693. fields = append(fields, employee.FieldDeletedAt)
  14694. }
  14695. if m.title != nil {
  14696. fields = append(fields, employee.FieldTitle)
  14697. }
  14698. if m.avatar != nil {
  14699. fields = append(fields, employee.FieldAvatar)
  14700. }
  14701. if m.tags != nil {
  14702. fields = append(fields, employee.FieldTags)
  14703. }
  14704. if m.hire_count != nil {
  14705. fields = append(fields, employee.FieldHireCount)
  14706. }
  14707. if m.service_count != nil {
  14708. fields = append(fields, employee.FieldServiceCount)
  14709. }
  14710. if m.achievement_count != nil {
  14711. fields = append(fields, employee.FieldAchievementCount)
  14712. }
  14713. if m.intro != nil {
  14714. fields = append(fields, employee.FieldIntro)
  14715. }
  14716. if m.estimate != nil {
  14717. fields = append(fields, employee.FieldEstimate)
  14718. }
  14719. if m.skill != nil {
  14720. fields = append(fields, employee.FieldSkill)
  14721. }
  14722. if m.ability_type != nil {
  14723. fields = append(fields, employee.FieldAbilityType)
  14724. }
  14725. if m.scene != nil {
  14726. fields = append(fields, employee.FieldScene)
  14727. }
  14728. if m.switch_in != nil {
  14729. fields = append(fields, employee.FieldSwitchIn)
  14730. }
  14731. if m.video_url != nil {
  14732. fields = append(fields, employee.FieldVideoURL)
  14733. }
  14734. if m.organization_id != nil {
  14735. fields = append(fields, employee.FieldOrganizationID)
  14736. }
  14737. if m.category_id != nil {
  14738. fields = append(fields, employee.FieldCategoryID)
  14739. }
  14740. if m.api_base != nil {
  14741. fields = append(fields, employee.FieldAPIBase)
  14742. }
  14743. if m.api_key != nil {
  14744. fields = append(fields, employee.FieldAPIKey)
  14745. }
  14746. if m.ai_info != nil {
  14747. fields = append(fields, employee.FieldAiInfo)
  14748. }
  14749. if m.is_vip != nil {
  14750. fields = append(fields, employee.FieldIsVip)
  14751. }
  14752. if m.chat_url != nil {
  14753. fields = append(fields, employee.FieldChatURL)
  14754. }
  14755. return fields
  14756. }
  14757. // Field returns the value of a field with the given name. The second boolean
  14758. // return value indicates that this field was not set, or was not defined in the
  14759. // schema.
  14760. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  14761. switch name {
  14762. case employee.FieldCreatedAt:
  14763. return m.CreatedAt()
  14764. case employee.FieldUpdatedAt:
  14765. return m.UpdatedAt()
  14766. case employee.FieldDeletedAt:
  14767. return m.DeletedAt()
  14768. case employee.FieldTitle:
  14769. return m.Title()
  14770. case employee.FieldAvatar:
  14771. return m.Avatar()
  14772. case employee.FieldTags:
  14773. return m.Tags()
  14774. case employee.FieldHireCount:
  14775. return m.HireCount()
  14776. case employee.FieldServiceCount:
  14777. return m.ServiceCount()
  14778. case employee.FieldAchievementCount:
  14779. return m.AchievementCount()
  14780. case employee.FieldIntro:
  14781. return m.Intro()
  14782. case employee.FieldEstimate:
  14783. return m.Estimate()
  14784. case employee.FieldSkill:
  14785. return m.Skill()
  14786. case employee.FieldAbilityType:
  14787. return m.AbilityType()
  14788. case employee.FieldScene:
  14789. return m.Scene()
  14790. case employee.FieldSwitchIn:
  14791. return m.SwitchIn()
  14792. case employee.FieldVideoURL:
  14793. return m.VideoURL()
  14794. case employee.FieldOrganizationID:
  14795. return m.OrganizationID()
  14796. case employee.FieldCategoryID:
  14797. return m.CategoryID()
  14798. case employee.FieldAPIBase:
  14799. return m.APIBase()
  14800. case employee.FieldAPIKey:
  14801. return m.APIKey()
  14802. case employee.FieldAiInfo:
  14803. return m.AiInfo()
  14804. case employee.FieldIsVip:
  14805. return m.IsVip()
  14806. case employee.FieldChatURL:
  14807. return m.ChatURL()
  14808. }
  14809. return nil, false
  14810. }
  14811. // OldField returns the old value of the field from the database. An error is
  14812. // returned if the mutation operation is not UpdateOne, or the query to the
  14813. // database failed.
  14814. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14815. switch name {
  14816. case employee.FieldCreatedAt:
  14817. return m.OldCreatedAt(ctx)
  14818. case employee.FieldUpdatedAt:
  14819. return m.OldUpdatedAt(ctx)
  14820. case employee.FieldDeletedAt:
  14821. return m.OldDeletedAt(ctx)
  14822. case employee.FieldTitle:
  14823. return m.OldTitle(ctx)
  14824. case employee.FieldAvatar:
  14825. return m.OldAvatar(ctx)
  14826. case employee.FieldTags:
  14827. return m.OldTags(ctx)
  14828. case employee.FieldHireCount:
  14829. return m.OldHireCount(ctx)
  14830. case employee.FieldServiceCount:
  14831. return m.OldServiceCount(ctx)
  14832. case employee.FieldAchievementCount:
  14833. return m.OldAchievementCount(ctx)
  14834. case employee.FieldIntro:
  14835. return m.OldIntro(ctx)
  14836. case employee.FieldEstimate:
  14837. return m.OldEstimate(ctx)
  14838. case employee.FieldSkill:
  14839. return m.OldSkill(ctx)
  14840. case employee.FieldAbilityType:
  14841. return m.OldAbilityType(ctx)
  14842. case employee.FieldScene:
  14843. return m.OldScene(ctx)
  14844. case employee.FieldSwitchIn:
  14845. return m.OldSwitchIn(ctx)
  14846. case employee.FieldVideoURL:
  14847. return m.OldVideoURL(ctx)
  14848. case employee.FieldOrganizationID:
  14849. return m.OldOrganizationID(ctx)
  14850. case employee.FieldCategoryID:
  14851. return m.OldCategoryID(ctx)
  14852. case employee.FieldAPIBase:
  14853. return m.OldAPIBase(ctx)
  14854. case employee.FieldAPIKey:
  14855. return m.OldAPIKey(ctx)
  14856. case employee.FieldAiInfo:
  14857. return m.OldAiInfo(ctx)
  14858. case employee.FieldIsVip:
  14859. return m.OldIsVip(ctx)
  14860. case employee.FieldChatURL:
  14861. return m.OldChatURL(ctx)
  14862. }
  14863. return nil, fmt.Errorf("unknown Employee field %s", name)
  14864. }
  14865. // SetField sets the value of a field with the given name. It returns an error if
  14866. // the field is not defined in the schema, or if the type mismatched the field
  14867. // type.
  14868. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  14869. switch name {
  14870. case employee.FieldCreatedAt:
  14871. v, ok := value.(time.Time)
  14872. if !ok {
  14873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14874. }
  14875. m.SetCreatedAt(v)
  14876. return nil
  14877. case employee.FieldUpdatedAt:
  14878. v, ok := value.(time.Time)
  14879. if !ok {
  14880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14881. }
  14882. m.SetUpdatedAt(v)
  14883. return nil
  14884. case employee.FieldDeletedAt:
  14885. v, ok := value.(time.Time)
  14886. if !ok {
  14887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14888. }
  14889. m.SetDeletedAt(v)
  14890. return nil
  14891. case employee.FieldTitle:
  14892. v, ok := value.(string)
  14893. if !ok {
  14894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14895. }
  14896. m.SetTitle(v)
  14897. return nil
  14898. case employee.FieldAvatar:
  14899. v, ok := value.(string)
  14900. if !ok {
  14901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14902. }
  14903. m.SetAvatar(v)
  14904. return nil
  14905. case employee.FieldTags:
  14906. v, ok := value.(string)
  14907. if !ok {
  14908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14909. }
  14910. m.SetTags(v)
  14911. return nil
  14912. case employee.FieldHireCount:
  14913. v, ok := value.(int)
  14914. if !ok {
  14915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14916. }
  14917. m.SetHireCount(v)
  14918. return nil
  14919. case employee.FieldServiceCount:
  14920. v, ok := value.(int)
  14921. if !ok {
  14922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14923. }
  14924. m.SetServiceCount(v)
  14925. return nil
  14926. case employee.FieldAchievementCount:
  14927. v, ok := value.(int)
  14928. if !ok {
  14929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14930. }
  14931. m.SetAchievementCount(v)
  14932. return nil
  14933. case employee.FieldIntro:
  14934. v, ok := value.(string)
  14935. if !ok {
  14936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14937. }
  14938. m.SetIntro(v)
  14939. return nil
  14940. case employee.FieldEstimate:
  14941. v, ok := value.(string)
  14942. if !ok {
  14943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14944. }
  14945. m.SetEstimate(v)
  14946. return nil
  14947. case employee.FieldSkill:
  14948. v, ok := value.(string)
  14949. if !ok {
  14950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14951. }
  14952. m.SetSkill(v)
  14953. return nil
  14954. case employee.FieldAbilityType:
  14955. v, ok := value.(string)
  14956. if !ok {
  14957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14958. }
  14959. m.SetAbilityType(v)
  14960. return nil
  14961. case employee.FieldScene:
  14962. v, ok := value.(string)
  14963. if !ok {
  14964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14965. }
  14966. m.SetScene(v)
  14967. return nil
  14968. case employee.FieldSwitchIn:
  14969. v, ok := value.(string)
  14970. if !ok {
  14971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14972. }
  14973. m.SetSwitchIn(v)
  14974. return nil
  14975. case employee.FieldVideoURL:
  14976. v, ok := value.(string)
  14977. if !ok {
  14978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14979. }
  14980. m.SetVideoURL(v)
  14981. return nil
  14982. case employee.FieldOrganizationID:
  14983. v, ok := value.(uint64)
  14984. if !ok {
  14985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14986. }
  14987. m.SetOrganizationID(v)
  14988. return nil
  14989. case employee.FieldCategoryID:
  14990. v, ok := value.(uint64)
  14991. if !ok {
  14992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14993. }
  14994. m.SetCategoryID(v)
  14995. return nil
  14996. case employee.FieldAPIBase:
  14997. v, ok := value.(string)
  14998. if !ok {
  14999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15000. }
  15001. m.SetAPIBase(v)
  15002. return nil
  15003. case employee.FieldAPIKey:
  15004. v, ok := value.(string)
  15005. if !ok {
  15006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15007. }
  15008. m.SetAPIKey(v)
  15009. return nil
  15010. case employee.FieldAiInfo:
  15011. v, ok := value.(string)
  15012. if !ok {
  15013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15014. }
  15015. m.SetAiInfo(v)
  15016. return nil
  15017. case employee.FieldIsVip:
  15018. v, ok := value.(int)
  15019. if !ok {
  15020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15021. }
  15022. m.SetIsVip(v)
  15023. return nil
  15024. case employee.FieldChatURL:
  15025. v, ok := value.(string)
  15026. if !ok {
  15027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15028. }
  15029. m.SetChatURL(v)
  15030. return nil
  15031. }
  15032. return fmt.Errorf("unknown Employee field %s", name)
  15033. }
  15034. // AddedFields returns all numeric fields that were incremented/decremented during
  15035. // this mutation.
  15036. func (m *EmployeeMutation) AddedFields() []string {
  15037. var fields []string
  15038. if m.addhire_count != nil {
  15039. fields = append(fields, employee.FieldHireCount)
  15040. }
  15041. if m.addservice_count != nil {
  15042. fields = append(fields, employee.FieldServiceCount)
  15043. }
  15044. if m.addachievement_count != nil {
  15045. fields = append(fields, employee.FieldAchievementCount)
  15046. }
  15047. if m.addorganization_id != nil {
  15048. fields = append(fields, employee.FieldOrganizationID)
  15049. }
  15050. if m.addcategory_id != nil {
  15051. fields = append(fields, employee.FieldCategoryID)
  15052. }
  15053. if m.addis_vip != nil {
  15054. fields = append(fields, employee.FieldIsVip)
  15055. }
  15056. return fields
  15057. }
  15058. // AddedField returns the numeric value that was incremented/decremented on a field
  15059. // with the given name. The second boolean return value indicates that this field
  15060. // was not set, or was not defined in the schema.
  15061. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  15062. switch name {
  15063. case employee.FieldHireCount:
  15064. return m.AddedHireCount()
  15065. case employee.FieldServiceCount:
  15066. return m.AddedServiceCount()
  15067. case employee.FieldAchievementCount:
  15068. return m.AddedAchievementCount()
  15069. case employee.FieldOrganizationID:
  15070. return m.AddedOrganizationID()
  15071. case employee.FieldCategoryID:
  15072. return m.AddedCategoryID()
  15073. case employee.FieldIsVip:
  15074. return m.AddedIsVip()
  15075. }
  15076. return nil, false
  15077. }
  15078. // AddField adds the value to the field with the given name. It returns an error if
  15079. // the field is not defined in the schema, or if the type mismatched the field
  15080. // type.
  15081. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  15082. switch name {
  15083. case employee.FieldHireCount:
  15084. v, ok := value.(int)
  15085. if !ok {
  15086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15087. }
  15088. m.AddHireCount(v)
  15089. return nil
  15090. case employee.FieldServiceCount:
  15091. v, ok := value.(int)
  15092. if !ok {
  15093. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15094. }
  15095. m.AddServiceCount(v)
  15096. return nil
  15097. case employee.FieldAchievementCount:
  15098. v, ok := value.(int)
  15099. if !ok {
  15100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15101. }
  15102. m.AddAchievementCount(v)
  15103. return nil
  15104. case employee.FieldOrganizationID:
  15105. v, ok := value.(int64)
  15106. if !ok {
  15107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15108. }
  15109. m.AddOrganizationID(v)
  15110. return nil
  15111. case employee.FieldCategoryID:
  15112. v, ok := value.(int64)
  15113. if !ok {
  15114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15115. }
  15116. m.AddCategoryID(v)
  15117. return nil
  15118. case employee.FieldIsVip:
  15119. v, ok := value.(int)
  15120. if !ok {
  15121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15122. }
  15123. m.AddIsVip(v)
  15124. return nil
  15125. }
  15126. return fmt.Errorf("unknown Employee numeric field %s", name)
  15127. }
  15128. // ClearedFields returns all nullable fields that were cleared during this
  15129. // mutation.
  15130. func (m *EmployeeMutation) ClearedFields() []string {
  15131. var fields []string
  15132. if m.FieldCleared(employee.FieldDeletedAt) {
  15133. fields = append(fields, employee.FieldDeletedAt)
  15134. }
  15135. if m.FieldCleared(employee.FieldAiInfo) {
  15136. fields = append(fields, employee.FieldAiInfo)
  15137. }
  15138. return fields
  15139. }
  15140. // FieldCleared returns a boolean indicating if a field with the given name was
  15141. // cleared in this mutation.
  15142. func (m *EmployeeMutation) FieldCleared(name string) bool {
  15143. _, ok := m.clearedFields[name]
  15144. return ok
  15145. }
  15146. // ClearField clears the value of the field with the given name. It returns an
  15147. // error if the field is not defined in the schema.
  15148. func (m *EmployeeMutation) ClearField(name string) error {
  15149. switch name {
  15150. case employee.FieldDeletedAt:
  15151. m.ClearDeletedAt()
  15152. return nil
  15153. case employee.FieldAiInfo:
  15154. m.ClearAiInfo()
  15155. return nil
  15156. }
  15157. return fmt.Errorf("unknown Employee nullable field %s", name)
  15158. }
  15159. // ResetField resets all changes in the mutation for the field with the given name.
  15160. // It returns an error if the field is not defined in the schema.
  15161. func (m *EmployeeMutation) ResetField(name string) error {
  15162. switch name {
  15163. case employee.FieldCreatedAt:
  15164. m.ResetCreatedAt()
  15165. return nil
  15166. case employee.FieldUpdatedAt:
  15167. m.ResetUpdatedAt()
  15168. return nil
  15169. case employee.FieldDeletedAt:
  15170. m.ResetDeletedAt()
  15171. return nil
  15172. case employee.FieldTitle:
  15173. m.ResetTitle()
  15174. return nil
  15175. case employee.FieldAvatar:
  15176. m.ResetAvatar()
  15177. return nil
  15178. case employee.FieldTags:
  15179. m.ResetTags()
  15180. return nil
  15181. case employee.FieldHireCount:
  15182. m.ResetHireCount()
  15183. return nil
  15184. case employee.FieldServiceCount:
  15185. m.ResetServiceCount()
  15186. return nil
  15187. case employee.FieldAchievementCount:
  15188. m.ResetAchievementCount()
  15189. return nil
  15190. case employee.FieldIntro:
  15191. m.ResetIntro()
  15192. return nil
  15193. case employee.FieldEstimate:
  15194. m.ResetEstimate()
  15195. return nil
  15196. case employee.FieldSkill:
  15197. m.ResetSkill()
  15198. return nil
  15199. case employee.FieldAbilityType:
  15200. m.ResetAbilityType()
  15201. return nil
  15202. case employee.FieldScene:
  15203. m.ResetScene()
  15204. return nil
  15205. case employee.FieldSwitchIn:
  15206. m.ResetSwitchIn()
  15207. return nil
  15208. case employee.FieldVideoURL:
  15209. m.ResetVideoURL()
  15210. return nil
  15211. case employee.FieldOrganizationID:
  15212. m.ResetOrganizationID()
  15213. return nil
  15214. case employee.FieldCategoryID:
  15215. m.ResetCategoryID()
  15216. return nil
  15217. case employee.FieldAPIBase:
  15218. m.ResetAPIBase()
  15219. return nil
  15220. case employee.FieldAPIKey:
  15221. m.ResetAPIKey()
  15222. return nil
  15223. case employee.FieldAiInfo:
  15224. m.ResetAiInfo()
  15225. return nil
  15226. case employee.FieldIsVip:
  15227. m.ResetIsVip()
  15228. return nil
  15229. case employee.FieldChatURL:
  15230. m.ResetChatURL()
  15231. return nil
  15232. }
  15233. return fmt.Errorf("unknown Employee field %s", name)
  15234. }
  15235. // AddedEdges returns all edge names that were set/added in this mutation.
  15236. func (m *EmployeeMutation) AddedEdges() []string {
  15237. edges := make([]string, 0, 2)
  15238. if m.em_work_experiences != nil {
  15239. edges = append(edges, employee.EdgeEmWorkExperiences)
  15240. }
  15241. if m.em_tutorial != nil {
  15242. edges = append(edges, employee.EdgeEmTutorial)
  15243. }
  15244. return edges
  15245. }
  15246. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15247. // name in this mutation.
  15248. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  15249. switch name {
  15250. case employee.EdgeEmWorkExperiences:
  15251. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  15252. for id := range m.em_work_experiences {
  15253. ids = append(ids, id)
  15254. }
  15255. return ids
  15256. case employee.EdgeEmTutorial:
  15257. ids := make([]ent.Value, 0, len(m.em_tutorial))
  15258. for id := range m.em_tutorial {
  15259. ids = append(ids, id)
  15260. }
  15261. return ids
  15262. }
  15263. return nil
  15264. }
  15265. // RemovedEdges returns all edge names that were removed in this mutation.
  15266. func (m *EmployeeMutation) RemovedEdges() []string {
  15267. edges := make([]string, 0, 2)
  15268. if m.removedem_work_experiences != nil {
  15269. edges = append(edges, employee.EdgeEmWorkExperiences)
  15270. }
  15271. if m.removedem_tutorial != nil {
  15272. edges = append(edges, employee.EdgeEmTutorial)
  15273. }
  15274. return edges
  15275. }
  15276. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15277. // the given name in this mutation.
  15278. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  15279. switch name {
  15280. case employee.EdgeEmWorkExperiences:
  15281. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  15282. for id := range m.removedem_work_experiences {
  15283. ids = append(ids, id)
  15284. }
  15285. return ids
  15286. case employee.EdgeEmTutorial:
  15287. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  15288. for id := range m.removedem_tutorial {
  15289. ids = append(ids, id)
  15290. }
  15291. return ids
  15292. }
  15293. return nil
  15294. }
  15295. // ClearedEdges returns all edge names that were cleared in this mutation.
  15296. func (m *EmployeeMutation) ClearedEdges() []string {
  15297. edges := make([]string, 0, 2)
  15298. if m.clearedem_work_experiences {
  15299. edges = append(edges, employee.EdgeEmWorkExperiences)
  15300. }
  15301. if m.clearedem_tutorial {
  15302. edges = append(edges, employee.EdgeEmTutorial)
  15303. }
  15304. return edges
  15305. }
  15306. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15307. // was cleared in this mutation.
  15308. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  15309. switch name {
  15310. case employee.EdgeEmWorkExperiences:
  15311. return m.clearedem_work_experiences
  15312. case employee.EdgeEmTutorial:
  15313. return m.clearedem_tutorial
  15314. }
  15315. return false
  15316. }
  15317. // ClearEdge clears the value of the edge with the given name. It returns an error
  15318. // if that edge is not defined in the schema.
  15319. func (m *EmployeeMutation) ClearEdge(name string) error {
  15320. switch name {
  15321. }
  15322. return fmt.Errorf("unknown Employee unique edge %s", name)
  15323. }
  15324. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15325. // It returns an error if the edge is not defined in the schema.
  15326. func (m *EmployeeMutation) ResetEdge(name string) error {
  15327. switch name {
  15328. case employee.EdgeEmWorkExperiences:
  15329. m.ResetEmWorkExperiences()
  15330. return nil
  15331. case employee.EdgeEmTutorial:
  15332. m.ResetEmTutorial()
  15333. return nil
  15334. }
  15335. return fmt.Errorf("unknown Employee edge %s", name)
  15336. }
  15337. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  15338. type EmployeeConfigMutation struct {
  15339. config
  15340. op Op
  15341. typ string
  15342. id *uint64
  15343. created_at *time.Time
  15344. updated_at *time.Time
  15345. deleted_at *time.Time
  15346. stype *string
  15347. title *string
  15348. photo *string
  15349. organization_id *uint64
  15350. addorganization_id *int64
  15351. clearedFields map[string]struct{}
  15352. done bool
  15353. oldValue func(context.Context) (*EmployeeConfig, error)
  15354. predicates []predicate.EmployeeConfig
  15355. }
  15356. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  15357. // employeeconfigOption allows management of the mutation configuration using functional options.
  15358. type employeeconfigOption func(*EmployeeConfigMutation)
  15359. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  15360. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  15361. m := &EmployeeConfigMutation{
  15362. config: c,
  15363. op: op,
  15364. typ: TypeEmployeeConfig,
  15365. clearedFields: make(map[string]struct{}),
  15366. }
  15367. for _, opt := range opts {
  15368. opt(m)
  15369. }
  15370. return m
  15371. }
  15372. // withEmployeeConfigID sets the ID field of the mutation.
  15373. func withEmployeeConfigID(id uint64) employeeconfigOption {
  15374. return func(m *EmployeeConfigMutation) {
  15375. var (
  15376. err error
  15377. once sync.Once
  15378. value *EmployeeConfig
  15379. )
  15380. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  15381. once.Do(func() {
  15382. if m.done {
  15383. err = errors.New("querying old values post mutation is not allowed")
  15384. } else {
  15385. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  15386. }
  15387. })
  15388. return value, err
  15389. }
  15390. m.id = &id
  15391. }
  15392. }
  15393. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  15394. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  15395. return func(m *EmployeeConfigMutation) {
  15396. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  15397. return node, nil
  15398. }
  15399. m.id = &node.ID
  15400. }
  15401. }
  15402. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15403. // executed in a transaction (ent.Tx), a transactional client is returned.
  15404. func (m EmployeeConfigMutation) Client() *Client {
  15405. client := &Client{config: m.config}
  15406. client.init()
  15407. return client
  15408. }
  15409. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15410. // it returns an error otherwise.
  15411. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  15412. if _, ok := m.driver.(*txDriver); !ok {
  15413. return nil, errors.New("ent: mutation is not running in a transaction")
  15414. }
  15415. tx := &Tx{config: m.config}
  15416. tx.init()
  15417. return tx, nil
  15418. }
  15419. // SetID sets the value of the id field. Note that this
  15420. // operation is only accepted on creation of EmployeeConfig entities.
  15421. func (m *EmployeeConfigMutation) SetID(id uint64) {
  15422. m.id = &id
  15423. }
  15424. // ID returns the ID value in the mutation. Note that the ID is only available
  15425. // if it was provided to the builder or after it was returned from the database.
  15426. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  15427. if m.id == nil {
  15428. return
  15429. }
  15430. return *m.id, true
  15431. }
  15432. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15433. // That means, if the mutation is applied within a transaction with an isolation level such
  15434. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15435. // or updated by the mutation.
  15436. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  15437. switch {
  15438. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15439. id, exists := m.ID()
  15440. if exists {
  15441. return []uint64{id}, nil
  15442. }
  15443. fallthrough
  15444. case m.op.Is(OpUpdate | OpDelete):
  15445. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  15446. default:
  15447. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15448. }
  15449. }
  15450. // SetCreatedAt sets the "created_at" field.
  15451. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  15452. m.created_at = &t
  15453. }
  15454. // CreatedAt returns the value of the "created_at" field in the mutation.
  15455. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  15456. v := m.created_at
  15457. if v == nil {
  15458. return
  15459. }
  15460. return *v, true
  15461. }
  15462. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  15463. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15465. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15466. if !m.op.Is(OpUpdateOne) {
  15467. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15468. }
  15469. if m.id == nil || m.oldValue == nil {
  15470. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15471. }
  15472. oldValue, err := m.oldValue(ctx)
  15473. if err != nil {
  15474. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15475. }
  15476. return oldValue.CreatedAt, nil
  15477. }
  15478. // ResetCreatedAt resets all changes to the "created_at" field.
  15479. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  15480. m.created_at = nil
  15481. }
  15482. // SetUpdatedAt sets the "updated_at" field.
  15483. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  15484. m.updated_at = &t
  15485. }
  15486. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15487. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  15488. v := m.updated_at
  15489. if v == nil {
  15490. return
  15491. }
  15492. return *v, true
  15493. }
  15494. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  15495. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15497. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15498. if !m.op.Is(OpUpdateOne) {
  15499. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15500. }
  15501. if m.id == nil || m.oldValue == nil {
  15502. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15503. }
  15504. oldValue, err := m.oldValue(ctx)
  15505. if err != nil {
  15506. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15507. }
  15508. return oldValue.UpdatedAt, nil
  15509. }
  15510. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15511. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  15512. m.updated_at = nil
  15513. }
  15514. // SetDeletedAt sets the "deleted_at" field.
  15515. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  15516. m.deleted_at = &t
  15517. }
  15518. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15519. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  15520. v := m.deleted_at
  15521. if v == nil {
  15522. return
  15523. }
  15524. return *v, true
  15525. }
  15526. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  15527. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15529. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15530. if !m.op.Is(OpUpdateOne) {
  15531. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15532. }
  15533. if m.id == nil || m.oldValue == nil {
  15534. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15535. }
  15536. oldValue, err := m.oldValue(ctx)
  15537. if err != nil {
  15538. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15539. }
  15540. return oldValue.DeletedAt, nil
  15541. }
  15542. // ClearDeletedAt clears the value of the "deleted_at" field.
  15543. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  15544. m.deleted_at = nil
  15545. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  15546. }
  15547. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15548. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  15549. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  15550. return ok
  15551. }
  15552. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15553. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  15554. m.deleted_at = nil
  15555. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  15556. }
  15557. // SetStype sets the "stype" field.
  15558. func (m *EmployeeConfigMutation) SetStype(s string) {
  15559. m.stype = &s
  15560. }
  15561. // Stype returns the value of the "stype" field in the mutation.
  15562. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  15563. v := m.stype
  15564. if v == nil {
  15565. return
  15566. }
  15567. return *v, true
  15568. }
  15569. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  15570. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15572. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  15573. if !m.op.Is(OpUpdateOne) {
  15574. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  15575. }
  15576. if m.id == nil || m.oldValue == nil {
  15577. return v, errors.New("OldStype requires an ID field in the mutation")
  15578. }
  15579. oldValue, err := m.oldValue(ctx)
  15580. if err != nil {
  15581. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  15582. }
  15583. return oldValue.Stype, nil
  15584. }
  15585. // ResetStype resets all changes to the "stype" field.
  15586. func (m *EmployeeConfigMutation) ResetStype() {
  15587. m.stype = nil
  15588. }
  15589. // SetTitle sets the "title" field.
  15590. func (m *EmployeeConfigMutation) SetTitle(s string) {
  15591. m.title = &s
  15592. }
  15593. // Title returns the value of the "title" field in the mutation.
  15594. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  15595. v := m.title
  15596. if v == nil {
  15597. return
  15598. }
  15599. return *v, true
  15600. }
  15601. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  15602. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15604. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  15605. if !m.op.Is(OpUpdateOne) {
  15606. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  15607. }
  15608. if m.id == nil || m.oldValue == nil {
  15609. return v, errors.New("OldTitle requires an ID field in the mutation")
  15610. }
  15611. oldValue, err := m.oldValue(ctx)
  15612. if err != nil {
  15613. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  15614. }
  15615. return oldValue.Title, nil
  15616. }
  15617. // ResetTitle resets all changes to the "title" field.
  15618. func (m *EmployeeConfigMutation) ResetTitle() {
  15619. m.title = nil
  15620. }
  15621. // SetPhoto sets the "photo" field.
  15622. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  15623. m.photo = &s
  15624. }
  15625. // Photo returns the value of the "photo" field in the mutation.
  15626. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  15627. v := m.photo
  15628. if v == nil {
  15629. return
  15630. }
  15631. return *v, true
  15632. }
  15633. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  15634. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15636. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  15637. if !m.op.Is(OpUpdateOne) {
  15638. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  15639. }
  15640. if m.id == nil || m.oldValue == nil {
  15641. return v, errors.New("OldPhoto requires an ID field in the mutation")
  15642. }
  15643. oldValue, err := m.oldValue(ctx)
  15644. if err != nil {
  15645. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  15646. }
  15647. return oldValue.Photo, nil
  15648. }
  15649. // ResetPhoto resets all changes to the "photo" field.
  15650. func (m *EmployeeConfigMutation) ResetPhoto() {
  15651. m.photo = nil
  15652. }
  15653. // SetOrganizationID sets the "organization_id" field.
  15654. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  15655. m.organization_id = &u
  15656. m.addorganization_id = nil
  15657. }
  15658. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15659. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  15660. v := m.organization_id
  15661. if v == nil {
  15662. return
  15663. }
  15664. return *v, true
  15665. }
  15666. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  15667. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  15668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15669. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15670. if !m.op.Is(OpUpdateOne) {
  15671. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15672. }
  15673. if m.id == nil || m.oldValue == nil {
  15674. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15675. }
  15676. oldValue, err := m.oldValue(ctx)
  15677. if err != nil {
  15678. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15679. }
  15680. return oldValue.OrganizationID, nil
  15681. }
  15682. // AddOrganizationID adds u to the "organization_id" field.
  15683. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  15684. if m.addorganization_id != nil {
  15685. *m.addorganization_id += u
  15686. } else {
  15687. m.addorganization_id = &u
  15688. }
  15689. }
  15690. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15691. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  15692. v := m.addorganization_id
  15693. if v == nil {
  15694. return
  15695. }
  15696. return *v, true
  15697. }
  15698. // ClearOrganizationID clears the value of the "organization_id" field.
  15699. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  15700. m.organization_id = nil
  15701. m.addorganization_id = nil
  15702. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  15703. }
  15704. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  15705. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  15706. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  15707. return ok
  15708. }
  15709. // ResetOrganizationID resets all changes to the "organization_id" field.
  15710. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  15711. m.organization_id = nil
  15712. m.addorganization_id = nil
  15713. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  15714. }
  15715. // Where appends a list predicates to the EmployeeConfigMutation builder.
  15716. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  15717. m.predicates = append(m.predicates, ps...)
  15718. }
  15719. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  15720. // users can use type-assertion to append predicates that do not depend on any generated package.
  15721. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  15722. p := make([]predicate.EmployeeConfig, len(ps))
  15723. for i := range ps {
  15724. p[i] = ps[i]
  15725. }
  15726. m.Where(p...)
  15727. }
  15728. // Op returns the operation name.
  15729. func (m *EmployeeConfigMutation) Op() Op {
  15730. return m.op
  15731. }
  15732. // SetOp allows setting the mutation operation.
  15733. func (m *EmployeeConfigMutation) SetOp(op Op) {
  15734. m.op = op
  15735. }
  15736. // Type returns the node type of this mutation (EmployeeConfig).
  15737. func (m *EmployeeConfigMutation) Type() string {
  15738. return m.typ
  15739. }
  15740. // Fields returns all fields that were changed during this mutation. Note that in
  15741. // order to get all numeric fields that were incremented/decremented, call
  15742. // AddedFields().
  15743. func (m *EmployeeConfigMutation) Fields() []string {
  15744. fields := make([]string, 0, 7)
  15745. if m.created_at != nil {
  15746. fields = append(fields, employeeconfig.FieldCreatedAt)
  15747. }
  15748. if m.updated_at != nil {
  15749. fields = append(fields, employeeconfig.FieldUpdatedAt)
  15750. }
  15751. if m.deleted_at != nil {
  15752. fields = append(fields, employeeconfig.FieldDeletedAt)
  15753. }
  15754. if m.stype != nil {
  15755. fields = append(fields, employeeconfig.FieldStype)
  15756. }
  15757. if m.title != nil {
  15758. fields = append(fields, employeeconfig.FieldTitle)
  15759. }
  15760. if m.photo != nil {
  15761. fields = append(fields, employeeconfig.FieldPhoto)
  15762. }
  15763. if m.organization_id != nil {
  15764. fields = append(fields, employeeconfig.FieldOrganizationID)
  15765. }
  15766. return fields
  15767. }
  15768. // Field returns the value of a field with the given name. The second boolean
  15769. // return value indicates that this field was not set, or was not defined in the
  15770. // schema.
  15771. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  15772. switch name {
  15773. case employeeconfig.FieldCreatedAt:
  15774. return m.CreatedAt()
  15775. case employeeconfig.FieldUpdatedAt:
  15776. return m.UpdatedAt()
  15777. case employeeconfig.FieldDeletedAt:
  15778. return m.DeletedAt()
  15779. case employeeconfig.FieldStype:
  15780. return m.Stype()
  15781. case employeeconfig.FieldTitle:
  15782. return m.Title()
  15783. case employeeconfig.FieldPhoto:
  15784. return m.Photo()
  15785. case employeeconfig.FieldOrganizationID:
  15786. return m.OrganizationID()
  15787. }
  15788. return nil, false
  15789. }
  15790. // OldField returns the old value of the field from the database. An error is
  15791. // returned if the mutation operation is not UpdateOne, or the query to the
  15792. // database failed.
  15793. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15794. switch name {
  15795. case employeeconfig.FieldCreatedAt:
  15796. return m.OldCreatedAt(ctx)
  15797. case employeeconfig.FieldUpdatedAt:
  15798. return m.OldUpdatedAt(ctx)
  15799. case employeeconfig.FieldDeletedAt:
  15800. return m.OldDeletedAt(ctx)
  15801. case employeeconfig.FieldStype:
  15802. return m.OldStype(ctx)
  15803. case employeeconfig.FieldTitle:
  15804. return m.OldTitle(ctx)
  15805. case employeeconfig.FieldPhoto:
  15806. return m.OldPhoto(ctx)
  15807. case employeeconfig.FieldOrganizationID:
  15808. return m.OldOrganizationID(ctx)
  15809. }
  15810. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  15811. }
  15812. // SetField sets the value of a field with the given name. It returns an error if
  15813. // the field is not defined in the schema, or if the type mismatched the field
  15814. // type.
  15815. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  15816. switch name {
  15817. case employeeconfig.FieldCreatedAt:
  15818. v, ok := value.(time.Time)
  15819. if !ok {
  15820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15821. }
  15822. m.SetCreatedAt(v)
  15823. return nil
  15824. case employeeconfig.FieldUpdatedAt:
  15825. v, ok := value.(time.Time)
  15826. if !ok {
  15827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15828. }
  15829. m.SetUpdatedAt(v)
  15830. return nil
  15831. case employeeconfig.FieldDeletedAt:
  15832. v, ok := value.(time.Time)
  15833. if !ok {
  15834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15835. }
  15836. m.SetDeletedAt(v)
  15837. return nil
  15838. case employeeconfig.FieldStype:
  15839. v, ok := value.(string)
  15840. if !ok {
  15841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15842. }
  15843. m.SetStype(v)
  15844. return nil
  15845. case employeeconfig.FieldTitle:
  15846. v, ok := value.(string)
  15847. if !ok {
  15848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15849. }
  15850. m.SetTitle(v)
  15851. return nil
  15852. case employeeconfig.FieldPhoto:
  15853. v, ok := value.(string)
  15854. if !ok {
  15855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15856. }
  15857. m.SetPhoto(v)
  15858. return nil
  15859. case employeeconfig.FieldOrganizationID:
  15860. v, ok := value.(uint64)
  15861. if !ok {
  15862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15863. }
  15864. m.SetOrganizationID(v)
  15865. return nil
  15866. }
  15867. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15868. }
  15869. // AddedFields returns all numeric fields that were incremented/decremented during
  15870. // this mutation.
  15871. func (m *EmployeeConfigMutation) AddedFields() []string {
  15872. var fields []string
  15873. if m.addorganization_id != nil {
  15874. fields = append(fields, employeeconfig.FieldOrganizationID)
  15875. }
  15876. return fields
  15877. }
  15878. // AddedField returns the numeric value that was incremented/decremented on a field
  15879. // with the given name. The second boolean return value indicates that this field
  15880. // was not set, or was not defined in the schema.
  15881. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  15882. switch name {
  15883. case employeeconfig.FieldOrganizationID:
  15884. return m.AddedOrganizationID()
  15885. }
  15886. return nil, false
  15887. }
  15888. // AddField adds the value to the field with the given name. It returns an error if
  15889. // the field is not defined in the schema, or if the type mismatched the field
  15890. // type.
  15891. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  15892. switch name {
  15893. case employeeconfig.FieldOrganizationID:
  15894. v, ok := value.(int64)
  15895. if !ok {
  15896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15897. }
  15898. m.AddOrganizationID(v)
  15899. return nil
  15900. }
  15901. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  15902. }
  15903. // ClearedFields returns all nullable fields that were cleared during this
  15904. // mutation.
  15905. func (m *EmployeeConfigMutation) ClearedFields() []string {
  15906. var fields []string
  15907. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  15908. fields = append(fields, employeeconfig.FieldDeletedAt)
  15909. }
  15910. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  15911. fields = append(fields, employeeconfig.FieldOrganizationID)
  15912. }
  15913. return fields
  15914. }
  15915. // FieldCleared returns a boolean indicating if a field with the given name was
  15916. // cleared in this mutation.
  15917. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  15918. _, ok := m.clearedFields[name]
  15919. return ok
  15920. }
  15921. // ClearField clears the value of the field with the given name. It returns an
  15922. // error if the field is not defined in the schema.
  15923. func (m *EmployeeConfigMutation) ClearField(name string) error {
  15924. switch name {
  15925. case employeeconfig.FieldDeletedAt:
  15926. m.ClearDeletedAt()
  15927. return nil
  15928. case employeeconfig.FieldOrganizationID:
  15929. m.ClearOrganizationID()
  15930. return nil
  15931. }
  15932. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  15933. }
  15934. // ResetField resets all changes in the mutation for the field with the given name.
  15935. // It returns an error if the field is not defined in the schema.
  15936. func (m *EmployeeConfigMutation) ResetField(name string) error {
  15937. switch name {
  15938. case employeeconfig.FieldCreatedAt:
  15939. m.ResetCreatedAt()
  15940. return nil
  15941. case employeeconfig.FieldUpdatedAt:
  15942. m.ResetUpdatedAt()
  15943. return nil
  15944. case employeeconfig.FieldDeletedAt:
  15945. m.ResetDeletedAt()
  15946. return nil
  15947. case employeeconfig.FieldStype:
  15948. m.ResetStype()
  15949. return nil
  15950. case employeeconfig.FieldTitle:
  15951. m.ResetTitle()
  15952. return nil
  15953. case employeeconfig.FieldPhoto:
  15954. m.ResetPhoto()
  15955. return nil
  15956. case employeeconfig.FieldOrganizationID:
  15957. m.ResetOrganizationID()
  15958. return nil
  15959. }
  15960. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  15961. }
  15962. // AddedEdges returns all edge names that were set/added in this mutation.
  15963. func (m *EmployeeConfigMutation) AddedEdges() []string {
  15964. edges := make([]string, 0, 0)
  15965. return edges
  15966. }
  15967. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15968. // name in this mutation.
  15969. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  15970. return nil
  15971. }
  15972. // RemovedEdges returns all edge names that were removed in this mutation.
  15973. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  15974. edges := make([]string, 0, 0)
  15975. return edges
  15976. }
  15977. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15978. // the given name in this mutation.
  15979. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  15980. return nil
  15981. }
  15982. // ClearedEdges returns all edge names that were cleared in this mutation.
  15983. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  15984. edges := make([]string, 0, 0)
  15985. return edges
  15986. }
  15987. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15988. // was cleared in this mutation.
  15989. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  15990. return false
  15991. }
  15992. // ClearEdge clears the value of the edge with the given name. It returns an error
  15993. // if that edge is not defined in the schema.
  15994. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  15995. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  15996. }
  15997. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15998. // It returns an error if the edge is not defined in the schema.
  15999. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  16000. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  16001. }
  16002. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  16003. type LabelMutation struct {
  16004. config
  16005. op Op
  16006. typ string
  16007. id *uint64
  16008. created_at *time.Time
  16009. updated_at *time.Time
  16010. status *uint8
  16011. addstatus *int8
  16012. _type *int
  16013. add_type *int
  16014. name *string
  16015. from *int
  16016. addfrom *int
  16017. mode *int
  16018. addmode *int
  16019. conditions *string
  16020. organization_id *uint64
  16021. addorganization_id *int64
  16022. clearedFields map[string]struct{}
  16023. label_relationships map[uint64]struct{}
  16024. removedlabel_relationships map[uint64]struct{}
  16025. clearedlabel_relationships bool
  16026. done bool
  16027. oldValue func(context.Context) (*Label, error)
  16028. predicates []predicate.Label
  16029. }
  16030. var _ ent.Mutation = (*LabelMutation)(nil)
  16031. // labelOption allows management of the mutation configuration using functional options.
  16032. type labelOption func(*LabelMutation)
  16033. // newLabelMutation creates new mutation for the Label entity.
  16034. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  16035. m := &LabelMutation{
  16036. config: c,
  16037. op: op,
  16038. typ: TypeLabel,
  16039. clearedFields: make(map[string]struct{}),
  16040. }
  16041. for _, opt := range opts {
  16042. opt(m)
  16043. }
  16044. return m
  16045. }
  16046. // withLabelID sets the ID field of the mutation.
  16047. func withLabelID(id uint64) labelOption {
  16048. return func(m *LabelMutation) {
  16049. var (
  16050. err error
  16051. once sync.Once
  16052. value *Label
  16053. )
  16054. m.oldValue = func(ctx context.Context) (*Label, error) {
  16055. once.Do(func() {
  16056. if m.done {
  16057. err = errors.New("querying old values post mutation is not allowed")
  16058. } else {
  16059. value, err = m.Client().Label.Get(ctx, id)
  16060. }
  16061. })
  16062. return value, err
  16063. }
  16064. m.id = &id
  16065. }
  16066. }
  16067. // withLabel sets the old Label of the mutation.
  16068. func withLabel(node *Label) labelOption {
  16069. return func(m *LabelMutation) {
  16070. m.oldValue = func(context.Context) (*Label, error) {
  16071. return node, nil
  16072. }
  16073. m.id = &node.ID
  16074. }
  16075. }
  16076. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16077. // executed in a transaction (ent.Tx), a transactional client is returned.
  16078. func (m LabelMutation) Client() *Client {
  16079. client := &Client{config: m.config}
  16080. client.init()
  16081. return client
  16082. }
  16083. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16084. // it returns an error otherwise.
  16085. func (m LabelMutation) Tx() (*Tx, error) {
  16086. if _, ok := m.driver.(*txDriver); !ok {
  16087. return nil, errors.New("ent: mutation is not running in a transaction")
  16088. }
  16089. tx := &Tx{config: m.config}
  16090. tx.init()
  16091. return tx, nil
  16092. }
  16093. // SetID sets the value of the id field. Note that this
  16094. // operation is only accepted on creation of Label entities.
  16095. func (m *LabelMutation) SetID(id uint64) {
  16096. m.id = &id
  16097. }
  16098. // ID returns the ID value in the mutation. Note that the ID is only available
  16099. // if it was provided to the builder or after it was returned from the database.
  16100. func (m *LabelMutation) ID() (id uint64, exists bool) {
  16101. if m.id == nil {
  16102. return
  16103. }
  16104. return *m.id, true
  16105. }
  16106. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16107. // That means, if the mutation is applied within a transaction with an isolation level such
  16108. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16109. // or updated by the mutation.
  16110. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  16111. switch {
  16112. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16113. id, exists := m.ID()
  16114. if exists {
  16115. return []uint64{id}, nil
  16116. }
  16117. fallthrough
  16118. case m.op.Is(OpUpdate | OpDelete):
  16119. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  16120. default:
  16121. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16122. }
  16123. }
  16124. // SetCreatedAt sets the "created_at" field.
  16125. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  16126. m.created_at = &t
  16127. }
  16128. // CreatedAt returns the value of the "created_at" field in the mutation.
  16129. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  16130. v := m.created_at
  16131. if v == nil {
  16132. return
  16133. }
  16134. return *v, true
  16135. }
  16136. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  16137. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16139. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16140. if !m.op.Is(OpUpdateOne) {
  16141. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16142. }
  16143. if m.id == nil || m.oldValue == nil {
  16144. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16145. }
  16146. oldValue, err := m.oldValue(ctx)
  16147. if err != nil {
  16148. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16149. }
  16150. return oldValue.CreatedAt, nil
  16151. }
  16152. // ResetCreatedAt resets all changes to the "created_at" field.
  16153. func (m *LabelMutation) ResetCreatedAt() {
  16154. m.created_at = nil
  16155. }
  16156. // SetUpdatedAt sets the "updated_at" field.
  16157. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  16158. m.updated_at = &t
  16159. }
  16160. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16161. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  16162. v := m.updated_at
  16163. if v == nil {
  16164. return
  16165. }
  16166. return *v, true
  16167. }
  16168. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  16169. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16171. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16172. if !m.op.Is(OpUpdateOne) {
  16173. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16174. }
  16175. if m.id == nil || m.oldValue == nil {
  16176. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16177. }
  16178. oldValue, err := m.oldValue(ctx)
  16179. if err != nil {
  16180. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16181. }
  16182. return oldValue.UpdatedAt, nil
  16183. }
  16184. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16185. func (m *LabelMutation) ResetUpdatedAt() {
  16186. m.updated_at = nil
  16187. }
  16188. // SetStatus sets the "status" field.
  16189. func (m *LabelMutation) SetStatus(u uint8) {
  16190. m.status = &u
  16191. m.addstatus = nil
  16192. }
  16193. // Status returns the value of the "status" field in the mutation.
  16194. func (m *LabelMutation) Status() (r uint8, exists bool) {
  16195. v := m.status
  16196. if v == nil {
  16197. return
  16198. }
  16199. return *v, true
  16200. }
  16201. // OldStatus returns the old "status" field's value of the Label entity.
  16202. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16204. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16205. if !m.op.Is(OpUpdateOne) {
  16206. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16207. }
  16208. if m.id == nil || m.oldValue == nil {
  16209. return v, errors.New("OldStatus requires an ID field in the mutation")
  16210. }
  16211. oldValue, err := m.oldValue(ctx)
  16212. if err != nil {
  16213. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16214. }
  16215. return oldValue.Status, nil
  16216. }
  16217. // AddStatus adds u to the "status" field.
  16218. func (m *LabelMutation) AddStatus(u int8) {
  16219. if m.addstatus != nil {
  16220. *m.addstatus += u
  16221. } else {
  16222. m.addstatus = &u
  16223. }
  16224. }
  16225. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16226. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  16227. v := m.addstatus
  16228. if v == nil {
  16229. return
  16230. }
  16231. return *v, true
  16232. }
  16233. // ClearStatus clears the value of the "status" field.
  16234. func (m *LabelMutation) ClearStatus() {
  16235. m.status = nil
  16236. m.addstatus = nil
  16237. m.clearedFields[label.FieldStatus] = struct{}{}
  16238. }
  16239. // StatusCleared returns if the "status" field was cleared in this mutation.
  16240. func (m *LabelMutation) StatusCleared() bool {
  16241. _, ok := m.clearedFields[label.FieldStatus]
  16242. return ok
  16243. }
  16244. // ResetStatus resets all changes to the "status" field.
  16245. func (m *LabelMutation) ResetStatus() {
  16246. m.status = nil
  16247. m.addstatus = nil
  16248. delete(m.clearedFields, label.FieldStatus)
  16249. }
  16250. // SetType sets the "type" field.
  16251. func (m *LabelMutation) SetType(i int) {
  16252. m._type = &i
  16253. m.add_type = nil
  16254. }
  16255. // GetType returns the value of the "type" field in the mutation.
  16256. func (m *LabelMutation) GetType() (r int, exists bool) {
  16257. v := m._type
  16258. if v == nil {
  16259. return
  16260. }
  16261. return *v, true
  16262. }
  16263. // OldType returns the old "type" field's value of the Label entity.
  16264. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16266. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  16267. if !m.op.Is(OpUpdateOne) {
  16268. return v, errors.New("OldType is only allowed on UpdateOne operations")
  16269. }
  16270. if m.id == nil || m.oldValue == nil {
  16271. return v, errors.New("OldType requires an ID field in the mutation")
  16272. }
  16273. oldValue, err := m.oldValue(ctx)
  16274. if err != nil {
  16275. return v, fmt.Errorf("querying old value for OldType: %w", err)
  16276. }
  16277. return oldValue.Type, nil
  16278. }
  16279. // AddType adds i to the "type" field.
  16280. func (m *LabelMutation) AddType(i int) {
  16281. if m.add_type != nil {
  16282. *m.add_type += i
  16283. } else {
  16284. m.add_type = &i
  16285. }
  16286. }
  16287. // AddedType returns the value that was added to the "type" field in this mutation.
  16288. func (m *LabelMutation) AddedType() (r int, exists bool) {
  16289. v := m.add_type
  16290. if v == nil {
  16291. return
  16292. }
  16293. return *v, true
  16294. }
  16295. // ResetType resets all changes to the "type" field.
  16296. func (m *LabelMutation) ResetType() {
  16297. m._type = nil
  16298. m.add_type = nil
  16299. }
  16300. // SetName sets the "name" field.
  16301. func (m *LabelMutation) SetName(s string) {
  16302. m.name = &s
  16303. }
  16304. // Name returns the value of the "name" field in the mutation.
  16305. func (m *LabelMutation) Name() (r string, exists bool) {
  16306. v := m.name
  16307. if v == nil {
  16308. return
  16309. }
  16310. return *v, true
  16311. }
  16312. // OldName returns the old "name" field's value of the Label entity.
  16313. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16315. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  16316. if !m.op.Is(OpUpdateOne) {
  16317. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16318. }
  16319. if m.id == nil || m.oldValue == nil {
  16320. return v, errors.New("OldName requires an ID field in the mutation")
  16321. }
  16322. oldValue, err := m.oldValue(ctx)
  16323. if err != nil {
  16324. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16325. }
  16326. return oldValue.Name, nil
  16327. }
  16328. // ResetName resets all changes to the "name" field.
  16329. func (m *LabelMutation) ResetName() {
  16330. m.name = nil
  16331. }
  16332. // SetFrom sets the "from" field.
  16333. func (m *LabelMutation) SetFrom(i int) {
  16334. m.from = &i
  16335. m.addfrom = nil
  16336. }
  16337. // From returns the value of the "from" field in the mutation.
  16338. func (m *LabelMutation) From() (r int, exists bool) {
  16339. v := m.from
  16340. if v == nil {
  16341. return
  16342. }
  16343. return *v, true
  16344. }
  16345. // OldFrom returns the old "from" field's value of the Label entity.
  16346. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16348. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  16349. if !m.op.Is(OpUpdateOne) {
  16350. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  16351. }
  16352. if m.id == nil || m.oldValue == nil {
  16353. return v, errors.New("OldFrom requires an ID field in the mutation")
  16354. }
  16355. oldValue, err := m.oldValue(ctx)
  16356. if err != nil {
  16357. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  16358. }
  16359. return oldValue.From, nil
  16360. }
  16361. // AddFrom adds i to the "from" field.
  16362. func (m *LabelMutation) AddFrom(i int) {
  16363. if m.addfrom != nil {
  16364. *m.addfrom += i
  16365. } else {
  16366. m.addfrom = &i
  16367. }
  16368. }
  16369. // AddedFrom returns the value that was added to the "from" field in this mutation.
  16370. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  16371. v := m.addfrom
  16372. if v == nil {
  16373. return
  16374. }
  16375. return *v, true
  16376. }
  16377. // ResetFrom resets all changes to the "from" field.
  16378. func (m *LabelMutation) ResetFrom() {
  16379. m.from = nil
  16380. m.addfrom = nil
  16381. }
  16382. // SetMode sets the "mode" field.
  16383. func (m *LabelMutation) SetMode(i int) {
  16384. m.mode = &i
  16385. m.addmode = nil
  16386. }
  16387. // Mode returns the value of the "mode" field in the mutation.
  16388. func (m *LabelMutation) Mode() (r int, exists bool) {
  16389. v := m.mode
  16390. if v == nil {
  16391. return
  16392. }
  16393. return *v, true
  16394. }
  16395. // OldMode returns the old "mode" field's value of the Label entity.
  16396. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16398. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  16399. if !m.op.Is(OpUpdateOne) {
  16400. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  16401. }
  16402. if m.id == nil || m.oldValue == nil {
  16403. return v, errors.New("OldMode requires an ID field in the mutation")
  16404. }
  16405. oldValue, err := m.oldValue(ctx)
  16406. if err != nil {
  16407. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  16408. }
  16409. return oldValue.Mode, nil
  16410. }
  16411. // AddMode adds i to the "mode" field.
  16412. func (m *LabelMutation) AddMode(i int) {
  16413. if m.addmode != nil {
  16414. *m.addmode += i
  16415. } else {
  16416. m.addmode = &i
  16417. }
  16418. }
  16419. // AddedMode returns the value that was added to the "mode" field in this mutation.
  16420. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  16421. v := m.addmode
  16422. if v == nil {
  16423. return
  16424. }
  16425. return *v, true
  16426. }
  16427. // ResetMode resets all changes to the "mode" field.
  16428. func (m *LabelMutation) ResetMode() {
  16429. m.mode = nil
  16430. m.addmode = nil
  16431. }
  16432. // SetConditions sets the "conditions" field.
  16433. func (m *LabelMutation) SetConditions(s string) {
  16434. m.conditions = &s
  16435. }
  16436. // Conditions returns the value of the "conditions" field in the mutation.
  16437. func (m *LabelMutation) Conditions() (r string, exists bool) {
  16438. v := m.conditions
  16439. if v == nil {
  16440. return
  16441. }
  16442. return *v, true
  16443. }
  16444. // OldConditions returns the old "conditions" field's value of the Label entity.
  16445. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16447. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  16448. if !m.op.Is(OpUpdateOne) {
  16449. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  16450. }
  16451. if m.id == nil || m.oldValue == nil {
  16452. return v, errors.New("OldConditions requires an ID field in the mutation")
  16453. }
  16454. oldValue, err := m.oldValue(ctx)
  16455. if err != nil {
  16456. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  16457. }
  16458. return oldValue.Conditions, nil
  16459. }
  16460. // ClearConditions clears the value of the "conditions" field.
  16461. func (m *LabelMutation) ClearConditions() {
  16462. m.conditions = nil
  16463. m.clearedFields[label.FieldConditions] = struct{}{}
  16464. }
  16465. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  16466. func (m *LabelMutation) ConditionsCleared() bool {
  16467. _, ok := m.clearedFields[label.FieldConditions]
  16468. return ok
  16469. }
  16470. // ResetConditions resets all changes to the "conditions" field.
  16471. func (m *LabelMutation) ResetConditions() {
  16472. m.conditions = nil
  16473. delete(m.clearedFields, label.FieldConditions)
  16474. }
  16475. // SetOrganizationID sets the "organization_id" field.
  16476. func (m *LabelMutation) SetOrganizationID(u uint64) {
  16477. m.organization_id = &u
  16478. m.addorganization_id = nil
  16479. }
  16480. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16481. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  16482. v := m.organization_id
  16483. if v == nil {
  16484. return
  16485. }
  16486. return *v, true
  16487. }
  16488. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  16489. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16491. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16492. if !m.op.Is(OpUpdateOne) {
  16493. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16494. }
  16495. if m.id == nil || m.oldValue == nil {
  16496. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16497. }
  16498. oldValue, err := m.oldValue(ctx)
  16499. if err != nil {
  16500. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16501. }
  16502. return oldValue.OrganizationID, nil
  16503. }
  16504. // AddOrganizationID adds u to the "organization_id" field.
  16505. func (m *LabelMutation) AddOrganizationID(u int64) {
  16506. if m.addorganization_id != nil {
  16507. *m.addorganization_id += u
  16508. } else {
  16509. m.addorganization_id = &u
  16510. }
  16511. }
  16512. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16513. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  16514. v := m.addorganization_id
  16515. if v == nil {
  16516. return
  16517. }
  16518. return *v, true
  16519. }
  16520. // ClearOrganizationID clears the value of the "organization_id" field.
  16521. func (m *LabelMutation) ClearOrganizationID() {
  16522. m.organization_id = nil
  16523. m.addorganization_id = nil
  16524. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  16525. }
  16526. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16527. func (m *LabelMutation) OrganizationIDCleared() bool {
  16528. _, ok := m.clearedFields[label.FieldOrganizationID]
  16529. return ok
  16530. }
  16531. // ResetOrganizationID resets all changes to the "organization_id" field.
  16532. func (m *LabelMutation) ResetOrganizationID() {
  16533. m.organization_id = nil
  16534. m.addorganization_id = nil
  16535. delete(m.clearedFields, label.FieldOrganizationID)
  16536. }
  16537. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  16538. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  16539. if m.label_relationships == nil {
  16540. m.label_relationships = make(map[uint64]struct{})
  16541. }
  16542. for i := range ids {
  16543. m.label_relationships[ids[i]] = struct{}{}
  16544. }
  16545. }
  16546. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  16547. func (m *LabelMutation) ClearLabelRelationships() {
  16548. m.clearedlabel_relationships = true
  16549. }
  16550. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  16551. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  16552. return m.clearedlabel_relationships
  16553. }
  16554. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  16555. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  16556. if m.removedlabel_relationships == nil {
  16557. m.removedlabel_relationships = make(map[uint64]struct{})
  16558. }
  16559. for i := range ids {
  16560. delete(m.label_relationships, ids[i])
  16561. m.removedlabel_relationships[ids[i]] = struct{}{}
  16562. }
  16563. }
  16564. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  16565. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  16566. for id := range m.removedlabel_relationships {
  16567. ids = append(ids, id)
  16568. }
  16569. return
  16570. }
  16571. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  16572. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  16573. for id := range m.label_relationships {
  16574. ids = append(ids, id)
  16575. }
  16576. return
  16577. }
  16578. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  16579. func (m *LabelMutation) ResetLabelRelationships() {
  16580. m.label_relationships = nil
  16581. m.clearedlabel_relationships = false
  16582. m.removedlabel_relationships = nil
  16583. }
  16584. // Where appends a list predicates to the LabelMutation builder.
  16585. func (m *LabelMutation) Where(ps ...predicate.Label) {
  16586. m.predicates = append(m.predicates, ps...)
  16587. }
  16588. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  16589. // users can use type-assertion to append predicates that do not depend on any generated package.
  16590. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  16591. p := make([]predicate.Label, len(ps))
  16592. for i := range ps {
  16593. p[i] = ps[i]
  16594. }
  16595. m.Where(p...)
  16596. }
  16597. // Op returns the operation name.
  16598. func (m *LabelMutation) Op() Op {
  16599. return m.op
  16600. }
  16601. // SetOp allows setting the mutation operation.
  16602. func (m *LabelMutation) SetOp(op Op) {
  16603. m.op = op
  16604. }
  16605. // Type returns the node type of this mutation (Label).
  16606. func (m *LabelMutation) Type() string {
  16607. return m.typ
  16608. }
  16609. // Fields returns all fields that were changed during this mutation. Note that in
  16610. // order to get all numeric fields that were incremented/decremented, call
  16611. // AddedFields().
  16612. func (m *LabelMutation) Fields() []string {
  16613. fields := make([]string, 0, 9)
  16614. if m.created_at != nil {
  16615. fields = append(fields, label.FieldCreatedAt)
  16616. }
  16617. if m.updated_at != nil {
  16618. fields = append(fields, label.FieldUpdatedAt)
  16619. }
  16620. if m.status != nil {
  16621. fields = append(fields, label.FieldStatus)
  16622. }
  16623. if m._type != nil {
  16624. fields = append(fields, label.FieldType)
  16625. }
  16626. if m.name != nil {
  16627. fields = append(fields, label.FieldName)
  16628. }
  16629. if m.from != nil {
  16630. fields = append(fields, label.FieldFrom)
  16631. }
  16632. if m.mode != nil {
  16633. fields = append(fields, label.FieldMode)
  16634. }
  16635. if m.conditions != nil {
  16636. fields = append(fields, label.FieldConditions)
  16637. }
  16638. if m.organization_id != nil {
  16639. fields = append(fields, label.FieldOrganizationID)
  16640. }
  16641. return fields
  16642. }
  16643. // Field returns the value of a field with the given name. The second boolean
  16644. // return value indicates that this field was not set, or was not defined in the
  16645. // schema.
  16646. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  16647. switch name {
  16648. case label.FieldCreatedAt:
  16649. return m.CreatedAt()
  16650. case label.FieldUpdatedAt:
  16651. return m.UpdatedAt()
  16652. case label.FieldStatus:
  16653. return m.Status()
  16654. case label.FieldType:
  16655. return m.GetType()
  16656. case label.FieldName:
  16657. return m.Name()
  16658. case label.FieldFrom:
  16659. return m.From()
  16660. case label.FieldMode:
  16661. return m.Mode()
  16662. case label.FieldConditions:
  16663. return m.Conditions()
  16664. case label.FieldOrganizationID:
  16665. return m.OrganizationID()
  16666. }
  16667. return nil, false
  16668. }
  16669. // OldField returns the old value of the field from the database. An error is
  16670. // returned if the mutation operation is not UpdateOne, or the query to the
  16671. // database failed.
  16672. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16673. switch name {
  16674. case label.FieldCreatedAt:
  16675. return m.OldCreatedAt(ctx)
  16676. case label.FieldUpdatedAt:
  16677. return m.OldUpdatedAt(ctx)
  16678. case label.FieldStatus:
  16679. return m.OldStatus(ctx)
  16680. case label.FieldType:
  16681. return m.OldType(ctx)
  16682. case label.FieldName:
  16683. return m.OldName(ctx)
  16684. case label.FieldFrom:
  16685. return m.OldFrom(ctx)
  16686. case label.FieldMode:
  16687. return m.OldMode(ctx)
  16688. case label.FieldConditions:
  16689. return m.OldConditions(ctx)
  16690. case label.FieldOrganizationID:
  16691. return m.OldOrganizationID(ctx)
  16692. }
  16693. return nil, fmt.Errorf("unknown Label field %s", name)
  16694. }
  16695. // SetField sets the value of a field with the given name. It returns an error if
  16696. // the field is not defined in the schema, or if the type mismatched the field
  16697. // type.
  16698. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  16699. switch name {
  16700. case label.FieldCreatedAt:
  16701. v, ok := value.(time.Time)
  16702. if !ok {
  16703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16704. }
  16705. m.SetCreatedAt(v)
  16706. return nil
  16707. case label.FieldUpdatedAt:
  16708. v, ok := value.(time.Time)
  16709. if !ok {
  16710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16711. }
  16712. m.SetUpdatedAt(v)
  16713. return nil
  16714. case label.FieldStatus:
  16715. v, ok := value.(uint8)
  16716. if !ok {
  16717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16718. }
  16719. m.SetStatus(v)
  16720. return nil
  16721. case label.FieldType:
  16722. v, ok := value.(int)
  16723. if !ok {
  16724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16725. }
  16726. m.SetType(v)
  16727. return nil
  16728. case label.FieldName:
  16729. v, ok := value.(string)
  16730. if !ok {
  16731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16732. }
  16733. m.SetName(v)
  16734. return nil
  16735. case label.FieldFrom:
  16736. v, ok := value.(int)
  16737. if !ok {
  16738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16739. }
  16740. m.SetFrom(v)
  16741. return nil
  16742. case label.FieldMode:
  16743. v, ok := value.(int)
  16744. if !ok {
  16745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16746. }
  16747. m.SetMode(v)
  16748. return nil
  16749. case label.FieldConditions:
  16750. v, ok := value.(string)
  16751. if !ok {
  16752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16753. }
  16754. m.SetConditions(v)
  16755. return nil
  16756. case label.FieldOrganizationID:
  16757. v, ok := value.(uint64)
  16758. if !ok {
  16759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16760. }
  16761. m.SetOrganizationID(v)
  16762. return nil
  16763. }
  16764. return fmt.Errorf("unknown Label field %s", name)
  16765. }
  16766. // AddedFields returns all numeric fields that were incremented/decremented during
  16767. // this mutation.
  16768. func (m *LabelMutation) AddedFields() []string {
  16769. var fields []string
  16770. if m.addstatus != nil {
  16771. fields = append(fields, label.FieldStatus)
  16772. }
  16773. if m.add_type != nil {
  16774. fields = append(fields, label.FieldType)
  16775. }
  16776. if m.addfrom != nil {
  16777. fields = append(fields, label.FieldFrom)
  16778. }
  16779. if m.addmode != nil {
  16780. fields = append(fields, label.FieldMode)
  16781. }
  16782. if m.addorganization_id != nil {
  16783. fields = append(fields, label.FieldOrganizationID)
  16784. }
  16785. return fields
  16786. }
  16787. // AddedField returns the numeric value that was incremented/decremented on a field
  16788. // with the given name. The second boolean return value indicates that this field
  16789. // was not set, or was not defined in the schema.
  16790. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  16791. switch name {
  16792. case label.FieldStatus:
  16793. return m.AddedStatus()
  16794. case label.FieldType:
  16795. return m.AddedType()
  16796. case label.FieldFrom:
  16797. return m.AddedFrom()
  16798. case label.FieldMode:
  16799. return m.AddedMode()
  16800. case label.FieldOrganizationID:
  16801. return m.AddedOrganizationID()
  16802. }
  16803. return nil, false
  16804. }
  16805. // AddField adds the value to the field with the given name. It returns an error if
  16806. // the field is not defined in the schema, or if the type mismatched the field
  16807. // type.
  16808. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  16809. switch name {
  16810. case label.FieldStatus:
  16811. v, ok := value.(int8)
  16812. if !ok {
  16813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16814. }
  16815. m.AddStatus(v)
  16816. return nil
  16817. case label.FieldType:
  16818. v, ok := value.(int)
  16819. if !ok {
  16820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16821. }
  16822. m.AddType(v)
  16823. return nil
  16824. case label.FieldFrom:
  16825. v, ok := value.(int)
  16826. if !ok {
  16827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16828. }
  16829. m.AddFrom(v)
  16830. return nil
  16831. case label.FieldMode:
  16832. v, ok := value.(int)
  16833. if !ok {
  16834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16835. }
  16836. m.AddMode(v)
  16837. return nil
  16838. case label.FieldOrganizationID:
  16839. v, ok := value.(int64)
  16840. if !ok {
  16841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16842. }
  16843. m.AddOrganizationID(v)
  16844. return nil
  16845. }
  16846. return fmt.Errorf("unknown Label numeric field %s", name)
  16847. }
  16848. // ClearedFields returns all nullable fields that were cleared during this
  16849. // mutation.
  16850. func (m *LabelMutation) ClearedFields() []string {
  16851. var fields []string
  16852. if m.FieldCleared(label.FieldStatus) {
  16853. fields = append(fields, label.FieldStatus)
  16854. }
  16855. if m.FieldCleared(label.FieldConditions) {
  16856. fields = append(fields, label.FieldConditions)
  16857. }
  16858. if m.FieldCleared(label.FieldOrganizationID) {
  16859. fields = append(fields, label.FieldOrganizationID)
  16860. }
  16861. return fields
  16862. }
  16863. // FieldCleared returns a boolean indicating if a field with the given name was
  16864. // cleared in this mutation.
  16865. func (m *LabelMutation) FieldCleared(name string) bool {
  16866. _, ok := m.clearedFields[name]
  16867. return ok
  16868. }
  16869. // ClearField clears the value of the field with the given name. It returns an
  16870. // error if the field is not defined in the schema.
  16871. func (m *LabelMutation) ClearField(name string) error {
  16872. switch name {
  16873. case label.FieldStatus:
  16874. m.ClearStatus()
  16875. return nil
  16876. case label.FieldConditions:
  16877. m.ClearConditions()
  16878. return nil
  16879. case label.FieldOrganizationID:
  16880. m.ClearOrganizationID()
  16881. return nil
  16882. }
  16883. return fmt.Errorf("unknown Label nullable field %s", name)
  16884. }
  16885. // ResetField resets all changes in the mutation for the field with the given name.
  16886. // It returns an error if the field is not defined in the schema.
  16887. func (m *LabelMutation) ResetField(name string) error {
  16888. switch name {
  16889. case label.FieldCreatedAt:
  16890. m.ResetCreatedAt()
  16891. return nil
  16892. case label.FieldUpdatedAt:
  16893. m.ResetUpdatedAt()
  16894. return nil
  16895. case label.FieldStatus:
  16896. m.ResetStatus()
  16897. return nil
  16898. case label.FieldType:
  16899. m.ResetType()
  16900. return nil
  16901. case label.FieldName:
  16902. m.ResetName()
  16903. return nil
  16904. case label.FieldFrom:
  16905. m.ResetFrom()
  16906. return nil
  16907. case label.FieldMode:
  16908. m.ResetMode()
  16909. return nil
  16910. case label.FieldConditions:
  16911. m.ResetConditions()
  16912. return nil
  16913. case label.FieldOrganizationID:
  16914. m.ResetOrganizationID()
  16915. return nil
  16916. }
  16917. return fmt.Errorf("unknown Label field %s", name)
  16918. }
  16919. // AddedEdges returns all edge names that were set/added in this mutation.
  16920. func (m *LabelMutation) AddedEdges() []string {
  16921. edges := make([]string, 0, 1)
  16922. if m.label_relationships != nil {
  16923. edges = append(edges, label.EdgeLabelRelationships)
  16924. }
  16925. return edges
  16926. }
  16927. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16928. // name in this mutation.
  16929. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  16930. switch name {
  16931. case label.EdgeLabelRelationships:
  16932. ids := make([]ent.Value, 0, len(m.label_relationships))
  16933. for id := range m.label_relationships {
  16934. ids = append(ids, id)
  16935. }
  16936. return ids
  16937. }
  16938. return nil
  16939. }
  16940. // RemovedEdges returns all edge names that were removed in this mutation.
  16941. func (m *LabelMutation) RemovedEdges() []string {
  16942. edges := make([]string, 0, 1)
  16943. if m.removedlabel_relationships != nil {
  16944. edges = append(edges, label.EdgeLabelRelationships)
  16945. }
  16946. return edges
  16947. }
  16948. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16949. // the given name in this mutation.
  16950. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  16951. switch name {
  16952. case label.EdgeLabelRelationships:
  16953. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  16954. for id := range m.removedlabel_relationships {
  16955. ids = append(ids, id)
  16956. }
  16957. return ids
  16958. }
  16959. return nil
  16960. }
  16961. // ClearedEdges returns all edge names that were cleared in this mutation.
  16962. func (m *LabelMutation) ClearedEdges() []string {
  16963. edges := make([]string, 0, 1)
  16964. if m.clearedlabel_relationships {
  16965. edges = append(edges, label.EdgeLabelRelationships)
  16966. }
  16967. return edges
  16968. }
  16969. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16970. // was cleared in this mutation.
  16971. func (m *LabelMutation) EdgeCleared(name string) bool {
  16972. switch name {
  16973. case label.EdgeLabelRelationships:
  16974. return m.clearedlabel_relationships
  16975. }
  16976. return false
  16977. }
  16978. // ClearEdge clears the value of the edge with the given name. It returns an error
  16979. // if that edge is not defined in the schema.
  16980. func (m *LabelMutation) ClearEdge(name string) error {
  16981. switch name {
  16982. }
  16983. return fmt.Errorf("unknown Label unique edge %s", name)
  16984. }
  16985. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16986. // It returns an error if the edge is not defined in the schema.
  16987. func (m *LabelMutation) ResetEdge(name string) error {
  16988. switch name {
  16989. case label.EdgeLabelRelationships:
  16990. m.ResetLabelRelationships()
  16991. return nil
  16992. }
  16993. return fmt.Errorf("unknown Label edge %s", name)
  16994. }
  16995. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  16996. type LabelRelationshipMutation struct {
  16997. config
  16998. op Op
  16999. typ string
  17000. id *uint64
  17001. created_at *time.Time
  17002. updated_at *time.Time
  17003. status *uint8
  17004. addstatus *int8
  17005. organization_id *uint64
  17006. addorganization_id *int64
  17007. clearedFields map[string]struct{}
  17008. contacts *uint64
  17009. clearedcontacts bool
  17010. labels *uint64
  17011. clearedlabels bool
  17012. done bool
  17013. oldValue func(context.Context) (*LabelRelationship, error)
  17014. predicates []predicate.LabelRelationship
  17015. }
  17016. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  17017. // labelrelationshipOption allows management of the mutation configuration using functional options.
  17018. type labelrelationshipOption func(*LabelRelationshipMutation)
  17019. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  17020. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  17021. m := &LabelRelationshipMutation{
  17022. config: c,
  17023. op: op,
  17024. typ: TypeLabelRelationship,
  17025. clearedFields: make(map[string]struct{}),
  17026. }
  17027. for _, opt := range opts {
  17028. opt(m)
  17029. }
  17030. return m
  17031. }
  17032. // withLabelRelationshipID sets the ID field of the mutation.
  17033. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  17034. return func(m *LabelRelationshipMutation) {
  17035. var (
  17036. err error
  17037. once sync.Once
  17038. value *LabelRelationship
  17039. )
  17040. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  17041. once.Do(func() {
  17042. if m.done {
  17043. err = errors.New("querying old values post mutation is not allowed")
  17044. } else {
  17045. value, err = m.Client().LabelRelationship.Get(ctx, id)
  17046. }
  17047. })
  17048. return value, err
  17049. }
  17050. m.id = &id
  17051. }
  17052. }
  17053. // withLabelRelationship sets the old LabelRelationship of the mutation.
  17054. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  17055. return func(m *LabelRelationshipMutation) {
  17056. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  17057. return node, nil
  17058. }
  17059. m.id = &node.ID
  17060. }
  17061. }
  17062. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17063. // executed in a transaction (ent.Tx), a transactional client is returned.
  17064. func (m LabelRelationshipMutation) Client() *Client {
  17065. client := &Client{config: m.config}
  17066. client.init()
  17067. return client
  17068. }
  17069. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17070. // it returns an error otherwise.
  17071. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  17072. if _, ok := m.driver.(*txDriver); !ok {
  17073. return nil, errors.New("ent: mutation is not running in a transaction")
  17074. }
  17075. tx := &Tx{config: m.config}
  17076. tx.init()
  17077. return tx, nil
  17078. }
  17079. // SetID sets the value of the id field. Note that this
  17080. // operation is only accepted on creation of LabelRelationship entities.
  17081. func (m *LabelRelationshipMutation) SetID(id uint64) {
  17082. m.id = &id
  17083. }
  17084. // ID returns the ID value in the mutation. Note that the ID is only available
  17085. // if it was provided to the builder or after it was returned from the database.
  17086. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  17087. if m.id == nil {
  17088. return
  17089. }
  17090. return *m.id, true
  17091. }
  17092. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17093. // That means, if the mutation is applied within a transaction with an isolation level such
  17094. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17095. // or updated by the mutation.
  17096. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  17097. switch {
  17098. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17099. id, exists := m.ID()
  17100. if exists {
  17101. return []uint64{id}, nil
  17102. }
  17103. fallthrough
  17104. case m.op.Is(OpUpdate | OpDelete):
  17105. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  17106. default:
  17107. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17108. }
  17109. }
  17110. // SetCreatedAt sets the "created_at" field.
  17111. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  17112. m.created_at = &t
  17113. }
  17114. // CreatedAt returns the value of the "created_at" field in the mutation.
  17115. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  17116. v := m.created_at
  17117. if v == nil {
  17118. return
  17119. }
  17120. return *v, true
  17121. }
  17122. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  17123. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17125. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17126. if !m.op.Is(OpUpdateOne) {
  17127. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17128. }
  17129. if m.id == nil || m.oldValue == nil {
  17130. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17131. }
  17132. oldValue, err := m.oldValue(ctx)
  17133. if err != nil {
  17134. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17135. }
  17136. return oldValue.CreatedAt, nil
  17137. }
  17138. // ResetCreatedAt resets all changes to the "created_at" field.
  17139. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  17140. m.created_at = nil
  17141. }
  17142. // SetUpdatedAt sets the "updated_at" field.
  17143. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  17144. m.updated_at = &t
  17145. }
  17146. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17147. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  17148. v := m.updated_at
  17149. if v == nil {
  17150. return
  17151. }
  17152. return *v, true
  17153. }
  17154. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  17155. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17157. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17158. if !m.op.Is(OpUpdateOne) {
  17159. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17160. }
  17161. if m.id == nil || m.oldValue == nil {
  17162. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17163. }
  17164. oldValue, err := m.oldValue(ctx)
  17165. if err != nil {
  17166. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17167. }
  17168. return oldValue.UpdatedAt, nil
  17169. }
  17170. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17171. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  17172. m.updated_at = nil
  17173. }
  17174. // SetStatus sets the "status" field.
  17175. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  17176. m.status = &u
  17177. m.addstatus = nil
  17178. }
  17179. // Status returns the value of the "status" field in the mutation.
  17180. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  17181. v := m.status
  17182. if v == nil {
  17183. return
  17184. }
  17185. return *v, true
  17186. }
  17187. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  17188. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17190. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17191. if !m.op.Is(OpUpdateOne) {
  17192. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17193. }
  17194. if m.id == nil || m.oldValue == nil {
  17195. return v, errors.New("OldStatus requires an ID field in the mutation")
  17196. }
  17197. oldValue, err := m.oldValue(ctx)
  17198. if err != nil {
  17199. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17200. }
  17201. return oldValue.Status, nil
  17202. }
  17203. // AddStatus adds u to the "status" field.
  17204. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  17205. if m.addstatus != nil {
  17206. *m.addstatus += u
  17207. } else {
  17208. m.addstatus = &u
  17209. }
  17210. }
  17211. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17212. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  17213. v := m.addstatus
  17214. if v == nil {
  17215. return
  17216. }
  17217. return *v, true
  17218. }
  17219. // ClearStatus clears the value of the "status" field.
  17220. func (m *LabelRelationshipMutation) ClearStatus() {
  17221. m.status = nil
  17222. m.addstatus = nil
  17223. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  17224. }
  17225. // StatusCleared returns if the "status" field was cleared in this mutation.
  17226. func (m *LabelRelationshipMutation) StatusCleared() bool {
  17227. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  17228. return ok
  17229. }
  17230. // ResetStatus resets all changes to the "status" field.
  17231. func (m *LabelRelationshipMutation) ResetStatus() {
  17232. m.status = nil
  17233. m.addstatus = nil
  17234. delete(m.clearedFields, labelrelationship.FieldStatus)
  17235. }
  17236. // SetLabelID sets the "label_id" field.
  17237. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  17238. m.labels = &u
  17239. }
  17240. // LabelID returns the value of the "label_id" field in the mutation.
  17241. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  17242. v := m.labels
  17243. if v == nil {
  17244. return
  17245. }
  17246. return *v, true
  17247. }
  17248. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  17249. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17251. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  17252. if !m.op.Is(OpUpdateOne) {
  17253. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  17254. }
  17255. if m.id == nil || m.oldValue == nil {
  17256. return v, errors.New("OldLabelID requires an ID field in the mutation")
  17257. }
  17258. oldValue, err := m.oldValue(ctx)
  17259. if err != nil {
  17260. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  17261. }
  17262. return oldValue.LabelID, nil
  17263. }
  17264. // ResetLabelID resets all changes to the "label_id" field.
  17265. func (m *LabelRelationshipMutation) ResetLabelID() {
  17266. m.labels = nil
  17267. }
  17268. // SetContactID sets the "contact_id" field.
  17269. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  17270. m.contacts = &u
  17271. }
  17272. // ContactID returns the value of the "contact_id" field in the mutation.
  17273. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  17274. v := m.contacts
  17275. if v == nil {
  17276. return
  17277. }
  17278. return *v, true
  17279. }
  17280. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  17281. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17283. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  17284. if !m.op.Is(OpUpdateOne) {
  17285. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  17286. }
  17287. if m.id == nil || m.oldValue == nil {
  17288. return v, errors.New("OldContactID requires an ID field in the mutation")
  17289. }
  17290. oldValue, err := m.oldValue(ctx)
  17291. if err != nil {
  17292. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  17293. }
  17294. return oldValue.ContactID, nil
  17295. }
  17296. // ResetContactID resets all changes to the "contact_id" field.
  17297. func (m *LabelRelationshipMutation) ResetContactID() {
  17298. m.contacts = nil
  17299. }
  17300. // SetOrganizationID sets the "organization_id" field.
  17301. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  17302. m.organization_id = &u
  17303. m.addorganization_id = nil
  17304. }
  17305. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17306. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  17307. v := m.organization_id
  17308. if v == nil {
  17309. return
  17310. }
  17311. return *v, true
  17312. }
  17313. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  17314. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17316. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17317. if !m.op.Is(OpUpdateOne) {
  17318. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17319. }
  17320. if m.id == nil || m.oldValue == nil {
  17321. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17322. }
  17323. oldValue, err := m.oldValue(ctx)
  17324. if err != nil {
  17325. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17326. }
  17327. return oldValue.OrganizationID, nil
  17328. }
  17329. // AddOrganizationID adds u to the "organization_id" field.
  17330. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  17331. if m.addorganization_id != nil {
  17332. *m.addorganization_id += u
  17333. } else {
  17334. m.addorganization_id = &u
  17335. }
  17336. }
  17337. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17338. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  17339. v := m.addorganization_id
  17340. if v == nil {
  17341. return
  17342. }
  17343. return *v, true
  17344. }
  17345. // ClearOrganizationID clears the value of the "organization_id" field.
  17346. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  17347. m.organization_id = nil
  17348. m.addorganization_id = nil
  17349. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  17350. }
  17351. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17352. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  17353. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  17354. return ok
  17355. }
  17356. // ResetOrganizationID resets all changes to the "organization_id" field.
  17357. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  17358. m.organization_id = nil
  17359. m.addorganization_id = nil
  17360. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  17361. }
  17362. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  17363. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  17364. m.contacts = &id
  17365. }
  17366. // ClearContacts clears the "contacts" edge to the Contact entity.
  17367. func (m *LabelRelationshipMutation) ClearContacts() {
  17368. m.clearedcontacts = true
  17369. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  17370. }
  17371. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  17372. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  17373. return m.clearedcontacts
  17374. }
  17375. // ContactsID returns the "contacts" edge ID in the mutation.
  17376. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  17377. if m.contacts != nil {
  17378. return *m.contacts, true
  17379. }
  17380. return
  17381. }
  17382. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  17383. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17384. // ContactsID instead. It exists only for internal usage by the builders.
  17385. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  17386. if id := m.contacts; id != nil {
  17387. ids = append(ids, *id)
  17388. }
  17389. return
  17390. }
  17391. // ResetContacts resets all changes to the "contacts" edge.
  17392. func (m *LabelRelationshipMutation) ResetContacts() {
  17393. m.contacts = nil
  17394. m.clearedcontacts = false
  17395. }
  17396. // SetLabelsID sets the "labels" edge to the Label entity by id.
  17397. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  17398. m.labels = &id
  17399. }
  17400. // ClearLabels clears the "labels" edge to the Label entity.
  17401. func (m *LabelRelationshipMutation) ClearLabels() {
  17402. m.clearedlabels = true
  17403. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  17404. }
  17405. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  17406. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  17407. return m.clearedlabels
  17408. }
  17409. // LabelsID returns the "labels" edge ID in the mutation.
  17410. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  17411. if m.labels != nil {
  17412. return *m.labels, true
  17413. }
  17414. return
  17415. }
  17416. // LabelsIDs returns the "labels" edge IDs in the mutation.
  17417. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17418. // LabelsID instead. It exists only for internal usage by the builders.
  17419. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  17420. if id := m.labels; id != nil {
  17421. ids = append(ids, *id)
  17422. }
  17423. return
  17424. }
  17425. // ResetLabels resets all changes to the "labels" edge.
  17426. func (m *LabelRelationshipMutation) ResetLabels() {
  17427. m.labels = nil
  17428. m.clearedlabels = false
  17429. }
  17430. // Where appends a list predicates to the LabelRelationshipMutation builder.
  17431. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  17432. m.predicates = append(m.predicates, ps...)
  17433. }
  17434. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  17435. // users can use type-assertion to append predicates that do not depend on any generated package.
  17436. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  17437. p := make([]predicate.LabelRelationship, len(ps))
  17438. for i := range ps {
  17439. p[i] = ps[i]
  17440. }
  17441. m.Where(p...)
  17442. }
  17443. // Op returns the operation name.
  17444. func (m *LabelRelationshipMutation) Op() Op {
  17445. return m.op
  17446. }
  17447. // SetOp allows setting the mutation operation.
  17448. func (m *LabelRelationshipMutation) SetOp(op Op) {
  17449. m.op = op
  17450. }
  17451. // Type returns the node type of this mutation (LabelRelationship).
  17452. func (m *LabelRelationshipMutation) Type() string {
  17453. return m.typ
  17454. }
  17455. // Fields returns all fields that were changed during this mutation. Note that in
  17456. // order to get all numeric fields that were incremented/decremented, call
  17457. // AddedFields().
  17458. func (m *LabelRelationshipMutation) Fields() []string {
  17459. fields := make([]string, 0, 6)
  17460. if m.created_at != nil {
  17461. fields = append(fields, labelrelationship.FieldCreatedAt)
  17462. }
  17463. if m.updated_at != nil {
  17464. fields = append(fields, labelrelationship.FieldUpdatedAt)
  17465. }
  17466. if m.status != nil {
  17467. fields = append(fields, labelrelationship.FieldStatus)
  17468. }
  17469. if m.labels != nil {
  17470. fields = append(fields, labelrelationship.FieldLabelID)
  17471. }
  17472. if m.contacts != nil {
  17473. fields = append(fields, labelrelationship.FieldContactID)
  17474. }
  17475. if m.organization_id != nil {
  17476. fields = append(fields, labelrelationship.FieldOrganizationID)
  17477. }
  17478. return fields
  17479. }
  17480. // Field returns the value of a field with the given name. The second boolean
  17481. // return value indicates that this field was not set, or was not defined in the
  17482. // schema.
  17483. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  17484. switch name {
  17485. case labelrelationship.FieldCreatedAt:
  17486. return m.CreatedAt()
  17487. case labelrelationship.FieldUpdatedAt:
  17488. return m.UpdatedAt()
  17489. case labelrelationship.FieldStatus:
  17490. return m.Status()
  17491. case labelrelationship.FieldLabelID:
  17492. return m.LabelID()
  17493. case labelrelationship.FieldContactID:
  17494. return m.ContactID()
  17495. case labelrelationship.FieldOrganizationID:
  17496. return m.OrganizationID()
  17497. }
  17498. return nil, false
  17499. }
  17500. // OldField returns the old value of the field from the database. An error is
  17501. // returned if the mutation operation is not UpdateOne, or the query to the
  17502. // database failed.
  17503. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17504. switch name {
  17505. case labelrelationship.FieldCreatedAt:
  17506. return m.OldCreatedAt(ctx)
  17507. case labelrelationship.FieldUpdatedAt:
  17508. return m.OldUpdatedAt(ctx)
  17509. case labelrelationship.FieldStatus:
  17510. return m.OldStatus(ctx)
  17511. case labelrelationship.FieldLabelID:
  17512. return m.OldLabelID(ctx)
  17513. case labelrelationship.FieldContactID:
  17514. return m.OldContactID(ctx)
  17515. case labelrelationship.FieldOrganizationID:
  17516. return m.OldOrganizationID(ctx)
  17517. }
  17518. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  17519. }
  17520. // SetField sets the value of a field with the given name. It returns an error if
  17521. // the field is not defined in the schema, or if the type mismatched the field
  17522. // type.
  17523. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  17524. switch name {
  17525. case labelrelationship.FieldCreatedAt:
  17526. v, ok := value.(time.Time)
  17527. if !ok {
  17528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17529. }
  17530. m.SetCreatedAt(v)
  17531. return nil
  17532. case labelrelationship.FieldUpdatedAt:
  17533. v, ok := value.(time.Time)
  17534. if !ok {
  17535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17536. }
  17537. m.SetUpdatedAt(v)
  17538. return nil
  17539. case labelrelationship.FieldStatus:
  17540. v, ok := value.(uint8)
  17541. if !ok {
  17542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17543. }
  17544. m.SetStatus(v)
  17545. return nil
  17546. case labelrelationship.FieldLabelID:
  17547. v, ok := value.(uint64)
  17548. if !ok {
  17549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17550. }
  17551. m.SetLabelID(v)
  17552. return nil
  17553. case labelrelationship.FieldContactID:
  17554. v, ok := value.(uint64)
  17555. if !ok {
  17556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17557. }
  17558. m.SetContactID(v)
  17559. return nil
  17560. case labelrelationship.FieldOrganizationID:
  17561. v, ok := value.(uint64)
  17562. if !ok {
  17563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17564. }
  17565. m.SetOrganizationID(v)
  17566. return nil
  17567. }
  17568. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17569. }
  17570. // AddedFields returns all numeric fields that were incremented/decremented during
  17571. // this mutation.
  17572. func (m *LabelRelationshipMutation) AddedFields() []string {
  17573. var fields []string
  17574. if m.addstatus != nil {
  17575. fields = append(fields, labelrelationship.FieldStatus)
  17576. }
  17577. if m.addorganization_id != nil {
  17578. fields = append(fields, labelrelationship.FieldOrganizationID)
  17579. }
  17580. return fields
  17581. }
  17582. // AddedField returns the numeric value that was incremented/decremented on a field
  17583. // with the given name. The second boolean return value indicates that this field
  17584. // was not set, or was not defined in the schema.
  17585. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  17586. switch name {
  17587. case labelrelationship.FieldStatus:
  17588. return m.AddedStatus()
  17589. case labelrelationship.FieldOrganizationID:
  17590. return m.AddedOrganizationID()
  17591. }
  17592. return nil, false
  17593. }
  17594. // AddField adds the value to the field with the given name. It returns an error if
  17595. // the field is not defined in the schema, or if the type mismatched the field
  17596. // type.
  17597. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  17598. switch name {
  17599. case labelrelationship.FieldStatus:
  17600. v, ok := value.(int8)
  17601. if !ok {
  17602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17603. }
  17604. m.AddStatus(v)
  17605. return nil
  17606. case labelrelationship.FieldOrganizationID:
  17607. v, ok := value.(int64)
  17608. if !ok {
  17609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17610. }
  17611. m.AddOrganizationID(v)
  17612. return nil
  17613. }
  17614. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  17615. }
  17616. // ClearedFields returns all nullable fields that were cleared during this
  17617. // mutation.
  17618. func (m *LabelRelationshipMutation) ClearedFields() []string {
  17619. var fields []string
  17620. if m.FieldCleared(labelrelationship.FieldStatus) {
  17621. fields = append(fields, labelrelationship.FieldStatus)
  17622. }
  17623. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  17624. fields = append(fields, labelrelationship.FieldOrganizationID)
  17625. }
  17626. return fields
  17627. }
  17628. // FieldCleared returns a boolean indicating if a field with the given name was
  17629. // cleared in this mutation.
  17630. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  17631. _, ok := m.clearedFields[name]
  17632. return ok
  17633. }
  17634. // ClearField clears the value of the field with the given name. It returns an
  17635. // error if the field is not defined in the schema.
  17636. func (m *LabelRelationshipMutation) ClearField(name string) error {
  17637. switch name {
  17638. case labelrelationship.FieldStatus:
  17639. m.ClearStatus()
  17640. return nil
  17641. case labelrelationship.FieldOrganizationID:
  17642. m.ClearOrganizationID()
  17643. return nil
  17644. }
  17645. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  17646. }
  17647. // ResetField resets all changes in the mutation for the field with the given name.
  17648. // It returns an error if the field is not defined in the schema.
  17649. func (m *LabelRelationshipMutation) ResetField(name string) error {
  17650. switch name {
  17651. case labelrelationship.FieldCreatedAt:
  17652. m.ResetCreatedAt()
  17653. return nil
  17654. case labelrelationship.FieldUpdatedAt:
  17655. m.ResetUpdatedAt()
  17656. return nil
  17657. case labelrelationship.FieldStatus:
  17658. m.ResetStatus()
  17659. return nil
  17660. case labelrelationship.FieldLabelID:
  17661. m.ResetLabelID()
  17662. return nil
  17663. case labelrelationship.FieldContactID:
  17664. m.ResetContactID()
  17665. return nil
  17666. case labelrelationship.FieldOrganizationID:
  17667. m.ResetOrganizationID()
  17668. return nil
  17669. }
  17670. return fmt.Errorf("unknown LabelRelationship field %s", name)
  17671. }
  17672. // AddedEdges returns all edge names that were set/added in this mutation.
  17673. func (m *LabelRelationshipMutation) AddedEdges() []string {
  17674. edges := make([]string, 0, 2)
  17675. if m.contacts != nil {
  17676. edges = append(edges, labelrelationship.EdgeContacts)
  17677. }
  17678. if m.labels != nil {
  17679. edges = append(edges, labelrelationship.EdgeLabels)
  17680. }
  17681. return edges
  17682. }
  17683. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17684. // name in this mutation.
  17685. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  17686. switch name {
  17687. case labelrelationship.EdgeContacts:
  17688. if id := m.contacts; id != nil {
  17689. return []ent.Value{*id}
  17690. }
  17691. case labelrelationship.EdgeLabels:
  17692. if id := m.labels; id != nil {
  17693. return []ent.Value{*id}
  17694. }
  17695. }
  17696. return nil
  17697. }
  17698. // RemovedEdges returns all edge names that were removed in this mutation.
  17699. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  17700. edges := make([]string, 0, 2)
  17701. return edges
  17702. }
  17703. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17704. // the given name in this mutation.
  17705. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  17706. return nil
  17707. }
  17708. // ClearedEdges returns all edge names that were cleared in this mutation.
  17709. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  17710. edges := make([]string, 0, 2)
  17711. if m.clearedcontacts {
  17712. edges = append(edges, labelrelationship.EdgeContacts)
  17713. }
  17714. if m.clearedlabels {
  17715. edges = append(edges, labelrelationship.EdgeLabels)
  17716. }
  17717. return edges
  17718. }
  17719. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17720. // was cleared in this mutation.
  17721. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  17722. switch name {
  17723. case labelrelationship.EdgeContacts:
  17724. return m.clearedcontacts
  17725. case labelrelationship.EdgeLabels:
  17726. return m.clearedlabels
  17727. }
  17728. return false
  17729. }
  17730. // ClearEdge clears the value of the edge with the given name. It returns an error
  17731. // if that edge is not defined in the schema.
  17732. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  17733. switch name {
  17734. case labelrelationship.EdgeContacts:
  17735. m.ClearContacts()
  17736. return nil
  17737. case labelrelationship.EdgeLabels:
  17738. m.ClearLabels()
  17739. return nil
  17740. }
  17741. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  17742. }
  17743. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17744. // It returns an error if the edge is not defined in the schema.
  17745. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  17746. switch name {
  17747. case labelrelationship.EdgeContacts:
  17748. m.ResetContacts()
  17749. return nil
  17750. case labelrelationship.EdgeLabels:
  17751. m.ResetLabels()
  17752. return nil
  17753. }
  17754. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  17755. }
  17756. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  17757. type LabelTaggingMutation struct {
  17758. config
  17759. op Op
  17760. typ string
  17761. id *uint64
  17762. created_at *time.Time
  17763. updated_at *time.Time
  17764. status *uint8
  17765. addstatus *int8
  17766. deleted_at *time.Time
  17767. organization_id *uint64
  17768. addorganization_id *int64
  17769. _type *int
  17770. add_type *int
  17771. conditions *string
  17772. action_label_add *[]uint64
  17773. appendaction_label_add []uint64
  17774. action_label_del *[]uint64
  17775. appendaction_label_del []uint64
  17776. clearedFields map[string]struct{}
  17777. done bool
  17778. oldValue func(context.Context) (*LabelTagging, error)
  17779. predicates []predicate.LabelTagging
  17780. }
  17781. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  17782. // labeltaggingOption allows management of the mutation configuration using functional options.
  17783. type labeltaggingOption func(*LabelTaggingMutation)
  17784. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  17785. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  17786. m := &LabelTaggingMutation{
  17787. config: c,
  17788. op: op,
  17789. typ: TypeLabelTagging,
  17790. clearedFields: make(map[string]struct{}),
  17791. }
  17792. for _, opt := range opts {
  17793. opt(m)
  17794. }
  17795. return m
  17796. }
  17797. // withLabelTaggingID sets the ID field of the mutation.
  17798. func withLabelTaggingID(id uint64) labeltaggingOption {
  17799. return func(m *LabelTaggingMutation) {
  17800. var (
  17801. err error
  17802. once sync.Once
  17803. value *LabelTagging
  17804. )
  17805. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  17806. once.Do(func() {
  17807. if m.done {
  17808. err = errors.New("querying old values post mutation is not allowed")
  17809. } else {
  17810. value, err = m.Client().LabelTagging.Get(ctx, id)
  17811. }
  17812. })
  17813. return value, err
  17814. }
  17815. m.id = &id
  17816. }
  17817. }
  17818. // withLabelTagging sets the old LabelTagging of the mutation.
  17819. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  17820. return func(m *LabelTaggingMutation) {
  17821. m.oldValue = func(context.Context) (*LabelTagging, error) {
  17822. return node, nil
  17823. }
  17824. m.id = &node.ID
  17825. }
  17826. }
  17827. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17828. // executed in a transaction (ent.Tx), a transactional client is returned.
  17829. func (m LabelTaggingMutation) Client() *Client {
  17830. client := &Client{config: m.config}
  17831. client.init()
  17832. return client
  17833. }
  17834. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17835. // it returns an error otherwise.
  17836. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  17837. if _, ok := m.driver.(*txDriver); !ok {
  17838. return nil, errors.New("ent: mutation is not running in a transaction")
  17839. }
  17840. tx := &Tx{config: m.config}
  17841. tx.init()
  17842. return tx, nil
  17843. }
  17844. // SetID sets the value of the id field. Note that this
  17845. // operation is only accepted on creation of LabelTagging entities.
  17846. func (m *LabelTaggingMutation) SetID(id uint64) {
  17847. m.id = &id
  17848. }
  17849. // ID returns the ID value in the mutation. Note that the ID is only available
  17850. // if it was provided to the builder or after it was returned from the database.
  17851. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  17852. if m.id == nil {
  17853. return
  17854. }
  17855. return *m.id, true
  17856. }
  17857. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17858. // That means, if the mutation is applied within a transaction with an isolation level such
  17859. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17860. // or updated by the mutation.
  17861. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  17862. switch {
  17863. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17864. id, exists := m.ID()
  17865. if exists {
  17866. return []uint64{id}, nil
  17867. }
  17868. fallthrough
  17869. case m.op.Is(OpUpdate | OpDelete):
  17870. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  17871. default:
  17872. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17873. }
  17874. }
  17875. // SetCreatedAt sets the "created_at" field.
  17876. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  17877. m.created_at = &t
  17878. }
  17879. // CreatedAt returns the value of the "created_at" field in the mutation.
  17880. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  17881. v := m.created_at
  17882. if v == nil {
  17883. return
  17884. }
  17885. return *v, true
  17886. }
  17887. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  17888. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17890. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17891. if !m.op.Is(OpUpdateOne) {
  17892. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17893. }
  17894. if m.id == nil || m.oldValue == nil {
  17895. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17896. }
  17897. oldValue, err := m.oldValue(ctx)
  17898. if err != nil {
  17899. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17900. }
  17901. return oldValue.CreatedAt, nil
  17902. }
  17903. // ResetCreatedAt resets all changes to the "created_at" field.
  17904. func (m *LabelTaggingMutation) ResetCreatedAt() {
  17905. m.created_at = nil
  17906. }
  17907. // SetUpdatedAt sets the "updated_at" field.
  17908. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  17909. m.updated_at = &t
  17910. }
  17911. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17912. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  17913. v := m.updated_at
  17914. if v == nil {
  17915. return
  17916. }
  17917. return *v, true
  17918. }
  17919. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  17920. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17922. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17923. if !m.op.Is(OpUpdateOne) {
  17924. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17925. }
  17926. if m.id == nil || m.oldValue == nil {
  17927. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17928. }
  17929. oldValue, err := m.oldValue(ctx)
  17930. if err != nil {
  17931. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17932. }
  17933. return oldValue.UpdatedAt, nil
  17934. }
  17935. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17936. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  17937. m.updated_at = nil
  17938. }
  17939. // SetStatus sets the "status" field.
  17940. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  17941. m.status = &u
  17942. m.addstatus = nil
  17943. }
  17944. // Status returns the value of the "status" field in the mutation.
  17945. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  17946. v := m.status
  17947. if v == nil {
  17948. return
  17949. }
  17950. return *v, true
  17951. }
  17952. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  17953. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  17954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17955. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17956. if !m.op.Is(OpUpdateOne) {
  17957. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17958. }
  17959. if m.id == nil || m.oldValue == nil {
  17960. return v, errors.New("OldStatus requires an ID field in the mutation")
  17961. }
  17962. oldValue, err := m.oldValue(ctx)
  17963. if err != nil {
  17964. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17965. }
  17966. return oldValue.Status, nil
  17967. }
  17968. // AddStatus adds u to the "status" field.
  17969. func (m *LabelTaggingMutation) AddStatus(u int8) {
  17970. if m.addstatus != nil {
  17971. *m.addstatus += u
  17972. } else {
  17973. m.addstatus = &u
  17974. }
  17975. }
  17976. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17977. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  17978. v := m.addstatus
  17979. if v == nil {
  17980. return
  17981. }
  17982. return *v, true
  17983. }
  17984. // ClearStatus clears the value of the "status" field.
  17985. func (m *LabelTaggingMutation) ClearStatus() {
  17986. m.status = nil
  17987. m.addstatus = nil
  17988. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  17989. }
  17990. // StatusCleared returns if the "status" field was cleared in this mutation.
  17991. func (m *LabelTaggingMutation) StatusCleared() bool {
  17992. _, ok := m.clearedFields[labeltagging.FieldStatus]
  17993. return ok
  17994. }
  17995. // ResetStatus resets all changes to the "status" field.
  17996. func (m *LabelTaggingMutation) ResetStatus() {
  17997. m.status = nil
  17998. m.addstatus = nil
  17999. delete(m.clearedFields, labeltagging.FieldStatus)
  18000. }
  18001. // SetDeletedAt sets the "deleted_at" field.
  18002. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  18003. m.deleted_at = &t
  18004. }
  18005. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18006. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  18007. v := m.deleted_at
  18008. if v == nil {
  18009. return
  18010. }
  18011. return *v, true
  18012. }
  18013. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  18014. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18015. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18016. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18017. if !m.op.Is(OpUpdateOne) {
  18018. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18019. }
  18020. if m.id == nil || m.oldValue == nil {
  18021. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18022. }
  18023. oldValue, err := m.oldValue(ctx)
  18024. if err != nil {
  18025. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18026. }
  18027. return oldValue.DeletedAt, nil
  18028. }
  18029. // ClearDeletedAt clears the value of the "deleted_at" field.
  18030. func (m *LabelTaggingMutation) ClearDeletedAt() {
  18031. m.deleted_at = nil
  18032. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  18033. }
  18034. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18035. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  18036. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  18037. return ok
  18038. }
  18039. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18040. func (m *LabelTaggingMutation) ResetDeletedAt() {
  18041. m.deleted_at = nil
  18042. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  18043. }
  18044. // SetOrganizationID sets the "organization_id" field.
  18045. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  18046. m.organization_id = &u
  18047. m.addorganization_id = nil
  18048. }
  18049. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18050. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  18051. v := m.organization_id
  18052. if v == nil {
  18053. return
  18054. }
  18055. return *v, true
  18056. }
  18057. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  18058. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18060. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18061. if !m.op.Is(OpUpdateOne) {
  18062. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18063. }
  18064. if m.id == nil || m.oldValue == nil {
  18065. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18066. }
  18067. oldValue, err := m.oldValue(ctx)
  18068. if err != nil {
  18069. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18070. }
  18071. return oldValue.OrganizationID, nil
  18072. }
  18073. // AddOrganizationID adds u to the "organization_id" field.
  18074. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  18075. if m.addorganization_id != nil {
  18076. *m.addorganization_id += u
  18077. } else {
  18078. m.addorganization_id = &u
  18079. }
  18080. }
  18081. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18082. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  18083. v := m.addorganization_id
  18084. if v == nil {
  18085. return
  18086. }
  18087. return *v, true
  18088. }
  18089. // ResetOrganizationID resets all changes to the "organization_id" field.
  18090. func (m *LabelTaggingMutation) ResetOrganizationID() {
  18091. m.organization_id = nil
  18092. m.addorganization_id = nil
  18093. }
  18094. // SetType sets the "type" field.
  18095. func (m *LabelTaggingMutation) SetType(i int) {
  18096. m._type = &i
  18097. m.add_type = nil
  18098. }
  18099. // GetType returns the value of the "type" field in the mutation.
  18100. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  18101. v := m._type
  18102. if v == nil {
  18103. return
  18104. }
  18105. return *v, true
  18106. }
  18107. // OldType returns the old "type" field's value of the LabelTagging entity.
  18108. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18110. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  18111. if !m.op.Is(OpUpdateOne) {
  18112. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18113. }
  18114. if m.id == nil || m.oldValue == nil {
  18115. return v, errors.New("OldType requires an ID field in the mutation")
  18116. }
  18117. oldValue, err := m.oldValue(ctx)
  18118. if err != nil {
  18119. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18120. }
  18121. return oldValue.Type, nil
  18122. }
  18123. // AddType adds i to the "type" field.
  18124. func (m *LabelTaggingMutation) AddType(i int) {
  18125. if m.add_type != nil {
  18126. *m.add_type += i
  18127. } else {
  18128. m.add_type = &i
  18129. }
  18130. }
  18131. // AddedType returns the value that was added to the "type" field in this mutation.
  18132. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  18133. v := m.add_type
  18134. if v == nil {
  18135. return
  18136. }
  18137. return *v, true
  18138. }
  18139. // ResetType resets all changes to the "type" field.
  18140. func (m *LabelTaggingMutation) ResetType() {
  18141. m._type = nil
  18142. m.add_type = nil
  18143. }
  18144. // SetConditions sets the "conditions" field.
  18145. func (m *LabelTaggingMutation) SetConditions(s string) {
  18146. m.conditions = &s
  18147. }
  18148. // Conditions returns the value of the "conditions" field in the mutation.
  18149. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  18150. v := m.conditions
  18151. if v == nil {
  18152. return
  18153. }
  18154. return *v, true
  18155. }
  18156. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  18157. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18159. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  18160. if !m.op.Is(OpUpdateOne) {
  18161. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18162. }
  18163. if m.id == nil || m.oldValue == nil {
  18164. return v, errors.New("OldConditions requires an ID field in the mutation")
  18165. }
  18166. oldValue, err := m.oldValue(ctx)
  18167. if err != nil {
  18168. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  18169. }
  18170. return oldValue.Conditions, nil
  18171. }
  18172. // ResetConditions resets all changes to the "conditions" field.
  18173. func (m *LabelTaggingMutation) ResetConditions() {
  18174. m.conditions = nil
  18175. }
  18176. // SetActionLabelAdd sets the "action_label_add" field.
  18177. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  18178. m.action_label_add = &u
  18179. m.appendaction_label_add = nil
  18180. }
  18181. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  18182. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  18183. v := m.action_label_add
  18184. if v == nil {
  18185. return
  18186. }
  18187. return *v, true
  18188. }
  18189. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  18190. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18192. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  18193. if !m.op.Is(OpUpdateOne) {
  18194. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  18195. }
  18196. if m.id == nil || m.oldValue == nil {
  18197. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  18198. }
  18199. oldValue, err := m.oldValue(ctx)
  18200. if err != nil {
  18201. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  18202. }
  18203. return oldValue.ActionLabelAdd, nil
  18204. }
  18205. // AppendActionLabelAdd adds u to the "action_label_add" field.
  18206. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  18207. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  18208. }
  18209. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  18210. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  18211. if len(m.appendaction_label_add) == 0 {
  18212. return nil, false
  18213. }
  18214. return m.appendaction_label_add, true
  18215. }
  18216. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  18217. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  18218. m.action_label_add = nil
  18219. m.appendaction_label_add = nil
  18220. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  18221. }
  18222. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  18223. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  18224. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  18225. return ok
  18226. }
  18227. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  18228. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  18229. m.action_label_add = nil
  18230. m.appendaction_label_add = nil
  18231. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  18232. }
  18233. // SetActionLabelDel sets the "action_label_del" field.
  18234. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  18235. m.action_label_del = &u
  18236. m.appendaction_label_del = nil
  18237. }
  18238. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  18239. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  18240. v := m.action_label_del
  18241. if v == nil {
  18242. return
  18243. }
  18244. return *v, true
  18245. }
  18246. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  18247. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18249. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  18250. if !m.op.Is(OpUpdateOne) {
  18251. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  18252. }
  18253. if m.id == nil || m.oldValue == nil {
  18254. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  18255. }
  18256. oldValue, err := m.oldValue(ctx)
  18257. if err != nil {
  18258. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  18259. }
  18260. return oldValue.ActionLabelDel, nil
  18261. }
  18262. // AppendActionLabelDel adds u to the "action_label_del" field.
  18263. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  18264. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  18265. }
  18266. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  18267. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  18268. if len(m.appendaction_label_del) == 0 {
  18269. return nil, false
  18270. }
  18271. return m.appendaction_label_del, true
  18272. }
  18273. // ClearActionLabelDel clears the value of the "action_label_del" field.
  18274. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  18275. m.action_label_del = nil
  18276. m.appendaction_label_del = nil
  18277. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  18278. }
  18279. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  18280. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  18281. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  18282. return ok
  18283. }
  18284. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  18285. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  18286. m.action_label_del = nil
  18287. m.appendaction_label_del = nil
  18288. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  18289. }
  18290. // Where appends a list predicates to the LabelTaggingMutation builder.
  18291. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  18292. m.predicates = append(m.predicates, ps...)
  18293. }
  18294. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  18295. // users can use type-assertion to append predicates that do not depend on any generated package.
  18296. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  18297. p := make([]predicate.LabelTagging, len(ps))
  18298. for i := range ps {
  18299. p[i] = ps[i]
  18300. }
  18301. m.Where(p...)
  18302. }
  18303. // Op returns the operation name.
  18304. func (m *LabelTaggingMutation) Op() Op {
  18305. return m.op
  18306. }
  18307. // SetOp allows setting the mutation operation.
  18308. func (m *LabelTaggingMutation) SetOp(op Op) {
  18309. m.op = op
  18310. }
  18311. // Type returns the node type of this mutation (LabelTagging).
  18312. func (m *LabelTaggingMutation) Type() string {
  18313. return m.typ
  18314. }
  18315. // Fields returns all fields that were changed during this mutation. Note that in
  18316. // order to get all numeric fields that were incremented/decremented, call
  18317. // AddedFields().
  18318. func (m *LabelTaggingMutation) Fields() []string {
  18319. fields := make([]string, 0, 9)
  18320. if m.created_at != nil {
  18321. fields = append(fields, labeltagging.FieldCreatedAt)
  18322. }
  18323. if m.updated_at != nil {
  18324. fields = append(fields, labeltagging.FieldUpdatedAt)
  18325. }
  18326. if m.status != nil {
  18327. fields = append(fields, labeltagging.FieldStatus)
  18328. }
  18329. if m.deleted_at != nil {
  18330. fields = append(fields, labeltagging.FieldDeletedAt)
  18331. }
  18332. if m.organization_id != nil {
  18333. fields = append(fields, labeltagging.FieldOrganizationID)
  18334. }
  18335. if m._type != nil {
  18336. fields = append(fields, labeltagging.FieldType)
  18337. }
  18338. if m.conditions != nil {
  18339. fields = append(fields, labeltagging.FieldConditions)
  18340. }
  18341. if m.action_label_add != nil {
  18342. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18343. }
  18344. if m.action_label_del != nil {
  18345. fields = append(fields, labeltagging.FieldActionLabelDel)
  18346. }
  18347. return fields
  18348. }
  18349. // Field returns the value of a field with the given name. The second boolean
  18350. // return value indicates that this field was not set, or was not defined in the
  18351. // schema.
  18352. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  18353. switch name {
  18354. case labeltagging.FieldCreatedAt:
  18355. return m.CreatedAt()
  18356. case labeltagging.FieldUpdatedAt:
  18357. return m.UpdatedAt()
  18358. case labeltagging.FieldStatus:
  18359. return m.Status()
  18360. case labeltagging.FieldDeletedAt:
  18361. return m.DeletedAt()
  18362. case labeltagging.FieldOrganizationID:
  18363. return m.OrganizationID()
  18364. case labeltagging.FieldType:
  18365. return m.GetType()
  18366. case labeltagging.FieldConditions:
  18367. return m.Conditions()
  18368. case labeltagging.FieldActionLabelAdd:
  18369. return m.ActionLabelAdd()
  18370. case labeltagging.FieldActionLabelDel:
  18371. return m.ActionLabelDel()
  18372. }
  18373. return nil, false
  18374. }
  18375. // OldField returns the old value of the field from the database. An error is
  18376. // returned if the mutation operation is not UpdateOne, or the query to the
  18377. // database failed.
  18378. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18379. switch name {
  18380. case labeltagging.FieldCreatedAt:
  18381. return m.OldCreatedAt(ctx)
  18382. case labeltagging.FieldUpdatedAt:
  18383. return m.OldUpdatedAt(ctx)
  18384. case labeltagging.FieldStatus:
  18385. return m.OldStatus(ctx)
  18386. case labeltagging.FieldDeletedAt:
  18387. return m.OldDeletedAt(ctx)
  18388. case labeltagging.FieldOrganizationID:
  18389. return m.OldOrganizationID(ctx)
  18390. case labeltagging.FieldType:
  18391. return m.OldType(ctx)
  18392. case labeltagging.FieldConditions:
  18393. return m.OldConditions(ctx)
  18394. case labeltagging.FieldActionLabelAdd:
  18395. return m.OldActionLabelAdd(ctx)
  18396. case labeltagging.FieldActionLabelDel:
  18397. return m.OldActionLabelDel(ctx)
  18398. }
  18399. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  18400. }
  18401. // SetField sets the value of a field with the given name. It returns an error if
  18402. // the field is not defined in the schema, or if the type mismatched the field
  18403. // type.
  18404. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  18405. switch name {
  18406. case labeltagging.FieldCreatedAt:
  18407. v, ok := value.(time.Time)
  18408. if !ok {
  18409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18410. }
  18411. m.SetCreatedAt(v)
  18412. return nil
  18413. case labeltagging.FieldUpdatedAt:
  18414. v, ok := value.(time.Time)
  18415. if !ok {
  18416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18417. }
  18418. m.SetUpdatedAt(v)
  18419. return nil
  18420. case labeltagging.FieldStatus:
  18421. v, ok := value.(uint8)
  18422. if !ok {
  18423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18424. }
  18425. m.SetStatus(v)
  18426. return nil
  18427. case labeltagging.FieldDeletedAt:
  18428. v, ok := value.(time.Time)
  18429. if !ok {
  18430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18431. }
  18432. m.SetDeletedAt(v)
  18433. return nil
  18434. case labeltagging.FieldOrganizationID:
  18435. v, ok := value.(uint64)
  18436. if !ok {
  18437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18438. }
  18439. m.SetOrganizationID(v)
  18440. return nil
  18441. case labeltagging.FieldType:
  18442. v, ok := value.(int)
  18443. if !ok {
  18444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18445. }
  18446. m.SetType(v)
  18447. return nil
  18448. case labeltagging.FieldConditions:
  18449. v, ok := value.(string)
  18450. if !ok {
  18451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18452. }
  18453. m.SetConditions(v)
  18454. return nil
  18455. case labeltagging.FieldActionLabelAdd:
  18456. v, ok := value.([]uint64)
  18457. if !ok {
  18458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18459. }
  18460. m.SetActionLabelAdd(v)
  18461. return nil
  18462. case labeltagging.FieldActionLabelDel:
  18463. v, ok := value.([]uint64)
  18464. if !ok {
  18465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18466. }
  18467. m.SetActionLabelDel(v)
  18468. return nil
  18469. }
  18470. return fmt.Errorf("unknown LabelTagging field %s", name)
  18471. }
  18472. // AddedFields returns all numeric fields that were incremented/decremented during
  18473. // this mutation.
  18474. func (m *LabelTaggingMutation) AddedFields() []string {
  18475. var fields []string
  18476. if m.addstatus != nil {
  18477. fields = append(fields, labeltagging.FieldStatus)
  18478. }
  18479. if m.addorganization_id != nil {
  18480. fields = append(fields, labeltagging.FieldOrganizationID)
  18481. }
  18482. if m.add_type != nil {
  18483. fields = append(fields, labeltagging.FieldType)
  18484. }
  18485. return fields
  18486. }
  18487. // AddedField returns the numeric value that was incremented/decremented on a field
  18488. // with the given name. The second boolean return value indicates that this field
  18489. // was not set, or was not defined in the schema.
  18490. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  18491. switch name {
  18492. case labeltagging.FieldStatus:
  18493. return m.AddedStatus()
  18494. case labeltagging.FieldOrganizationID:
  18495. return m.AddedOrganizationID()
  18496. case labeltagging.FieldType:
  18497. return m.AddedType()
  18498. }
  18499. return nil, false
  18500. }
  18501. // AddField adds the value to the field with the given name. It returns an error if
  18502. // the field is not defined in the schema, or if the type mismatched the field
  18503. // type.
  18504. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  18505. switch name {
  18506. case labeltagging.FieldStatus:
  18507. v, ok := value.(int8)
  18508. if !ok {
  18509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18510. }
  18511. m.AddStatus(v)
  18512. return nil
  18513. case labeltagging.FieldOrganizationID:
  18514. v, ok := value.(int64)
  18515. if !ok {
  18516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18517. }
  18518. m.AddOrganizationID(v)
  18519. return nil
  18520. case labeltagging.FieldType:
  18521. v, ok := value.(int)
  18522. if !ok {
  18523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18524. }
  18525. m.AddType(v)
  18526. return nil
  18527. }
  18528. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  18529. }
  18530. // ClearedFields returns all nullable fields that were cleared during this
  18531. // mutation.
  18532. func (m *LabelTaggingMutation) ClearedFields() []string {
  18533. var fields []string
  18534. if m.FieldCleared(labeltagging.FieldStatus) {
  18535. fields = append(fields, labeltagging.FieldStatus)
  18536. }
  18537. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  18538. fields = append(fields, labeltagging.FieldDeletedAt)
  18539. }
  18540. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  18541. fields = append(fields, labeltagging.FieldActionLabelAdd)
  18542. }
  18543. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  18544. fields = append(fields, labeltagging.FieldActionLabelDel)
  18545. }
  18546. return fields
  18547. }
  18548. // FieldCleared returns a boolean indicating if a field with the given name was
  18549. // cleared in this mutation.
  18550. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  18551. _, ok := m.clearedFields[name]
  18552. return ok
  18553. }
  18554. // ClearField clears the value of the field with the given name. It returns an
  18555. // error if the field is not defined in the schema.
  18556. func (m *LabelTaggingMutation) ClearField(name string) error {
  18557. switch name {
  18558. case labeltagging.FieldStatus:
  18559. m.ClearStatus()
  18560. return nil
  18561. case labeltagging.FieldDeletedAt:
  18562. m.ClearDeletedAt()
  18563. return nil
  18564. case labeltagging.FieldActionLabelAdd:
  18565. m.ClearActionLabelAdd()
  18566. return nil
  18567. case labeltagging.FieldActionLabelDel:
  18568. m.ClearActionLabelDel()
  18569. return nil
  18570. }
  18571. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  18572. }
  18573. // ResetField resets all changes in the mutation for the field with the given name.
  18574. // It returns an error if the field is not defined in the schema.
  18575. func (m *LabelTaggingMutation) ResetField(name string) error {
  18576. switch name {
  18577. case labeltagging.FieldCreatedAt:
  18578. m.ResetCreatedAt()
  18579. return nil
  18580. case labeltagging.FieldUpdatedAt:
  18581. m.ResetUpdatedAt()
  18582. return nil
  18583. case labeltagging.FieldStatus:
  18584. m.ResetStatus()
  18585. return nil
  18586. case labeltagging.FieldDeletedAt:
  18587. m.ResetDeletedAt()
  18588. return nil
  18589. case labeltagging.FieldOrganizationID:
  18590. m.ResetOrganizationID()
  18591. return nil
  18592. case labeltagging.FieldType:
  18593. m.ResetType()
  18594. return nil
  18595. case labeltagging.FieldConditions:
  18596. m.ResetConditions()
  18597. return nil
  18598. case labeltagging.FieldActionLabelAdd:
  18599. m.ResetActionLabelAdd()
  18600. return nil
  18601. case labeltagging.FieldActionLabelDel:
  18602. m.ResetActionLabelDel()
  18603. return nil
  18604. }
  18605. return fmt.Errorf("unknown LabelTagging field %s", name)
  18606. }
  18607. // AddedEdges returns all edge names that were set/added in this mutation.
  18608. func (m *LabelTaggingMutation) AddedEdges() []string {
  18609. edges := make([]string, 0, 0)
  18610. return edges
  18611. }
  18612. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18613. // name in this mutation.
  18614. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  18615. return nil
  18616. }
  18617. // RemovedEdges returns all edge names that were removed in this mutation.
  18618. func (m *LabelTaggingMutation) RemovedEdges() []string {
  18619. edges := make([]string, 0, 0)
  18620. return edges
  18621. }
  18622. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18623. // the given name in this mutation.
  18624. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  18625. return nil
  18626. }
  18627. // ClearedEdges returns all edge names that were cleared in this mutation.
  18628. func (m *LabelTaggingMutation) ClearedEdges() []string {
  18629. edges := make([]string, 0, 0)
  18630. return edges
  18631. }
  18632. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18633. // was cleared in this mutation.
  18634. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  18635. return false
  18636. }
  18637. // ClearEdge clears the value of the edge with the given name. It returns an error
  18638. // if that edge is not defined in the schema.
  18639. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  18640. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  18641. }
  18642. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18643. // It returns an error if the edge is not defined in the schema.
  18644. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  18645. return fmt.Errorf("unknown LabelTagging edge %s", name)
  18646. }
  18647. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  18648. type MessageMutation struct {
  18649. config
  18650. op Op
  18651. typ string
  18652. id *int
  18653. wx_wxid *string
  18654. wxid *string
  18655. content *string
  18656. clearedFields map[string]struct{}
  18657. done bool
  18658. oldValue func(context.Context) (*Message, error)
  18659. predicates []predicate.Message
  18660. }
  18661. var _ ent.Mutation = (*MessageMutation)(nil)
  18662. // messageOption allows management of the mutation configuration using functional options.
  18663. type messageOption func(*MessageMutation)
  18664. // newMessageMutation creates new mutation for the Message entity.
  18665. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  18666. m := &MessageMutation{
  18667. config: c,
  18668. op: op,
  18669. typ: TypeMessage,
  18670. clearedFields: make(map[string]struct{}),
  18671. }
  18672. for _, opt := range opts {
  18673. opt(m)
  18674. }
  18675. return m
  18676. }
  18677. // withMessageID sets the ID field of the mutation.
  18678. func withMessageID(id int) messageOption {
  18679. return func(m *MessageMutation) {
  18680. var (
  18681. err error
  18682. once sync.Once
  18683. value *Message
  18684. )
  18685. m.oldValue = func(ctx context.Context) (*Message, error) {
  18686. once.Do(func() {
  18687. if m.done {
  18688. err = errors.New("querying old values post mutation is not allowed")
  18689. } else {
  18690. value, err = m.Client().Message.Get(ctx, id)
  18691. }
  18692. })
  18693. return value, err
  18694. }
  18695. m.id = &id
  18696. }
  18697. }
  18698. // withMessage sets the old Message of the mutation.
  18699. func withMessage(node *Message) messageOption {
  18700. return func(m *MessageMutation) {
  18701. m.oldValue = func(context.Context) (*Message, error) {
  18702. return node, nil
  18703. }
  18704. m.id = &node.ID
  18705. }
  18706. }
  18707. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18708. // executed in a transaction (ent.Tx), a transactional client is returned.
  18709. func (m MessageMutation) Client() *Client {
  18710. client := &Client{config: m.config}
  18711. client.init()
  18712. return client
  18713. }
  18714. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18715. // it returns an error otherwise.
  18716. func (m MessageMutation) Tx() (*Tx, error) {
  18717. if _, ok := m.driver.(*txDriver); !ok {
  18718. return nil, errors.New("ent: mutation is not running in a transaction")
  18719. }
  18720. tx := &Tx{config: m.config}
  18721. tx.init()
  18722. return tx, nil
  18723. }
  18724. // ID returns the ID value in the mutation. Note that the ID is only available
  18725. // if it was provided to the builder or after it was returned from the database.
  18726. func (m *MessageMutation) ID() (id int, exists bool) {
  18727. if m.id == nil {
  18728. return
  18729. }
  18730. return *m.id, true
  18731. }
  18732. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18733. // That means, if the mutation is applied within a transaction with an isolation level such
  18734. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18735. // or updated by the mutation.
  18736. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  18737. switch {
  18738. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18739. id, exists := m.ID()
  18740. if exists {
  18741. return []int{id}, nil
  18742. }
  18743. fallthrough
  18744. case m.op.Is(OpUpdate | OpDelete):
  18745. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  18746. default:
  18747. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18748. }
  18749. }
  18750. // SetWxWxid sets the "wx_wxid" field.
  18751. func (m *MessageMutation) SetWxWxid(s string) {
  18752. m.wx_wxid = &s
  18753. }
  18754. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  18755. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  18756. v := m.wx_wxid
  18757. if v == nil {
  18758. return
  18759. }
  18760. return *v, true
  18761. }
  18762. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  18763. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18765. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  18766. if !m.op.Is(OpUpdateOne) {
  18767. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  18768. }
  18769. if m.id == nil || m.oldValue == nil {
  18770. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  18771. }
  18772. oldValue, err := m.oldValue(ctx)
  18773. if err != nil {
  18774. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  18775. }
  18776. return oldValue.WxWxid, nil
  18777. }
  18778. // ClearWxWxid clears the value of the "wx_wxid" field.
  18779. func (m *MessageMutation) ClearWxWxid() {
  18780. m.wx_wxid = nil
  18781. m.clearedFields[message.FieldWxWxid] = struct{}{}
  18782. }
  18783. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  18784. func (m *MessageMutation) WxWxidCleared() bool {
  18785. _, ok := m.clearedFields[message.FieldWxWxid]
  18786. return ok
  18787. }
  18788. // ResetWxWxid resets all changes to the "wx_wxid" field.
  18789. func (m *MessageMutation) ResetWxWxid() {
  18790. m.wx_wxid = nil
  18791. delete(m.clearedFields, message.FieldWxWxid)
  18792. }
  18793. // SetWxid sets the "wxid" field.
  18794. func (m *MessageMutation) SetWxid(s string) {
  18795. m.wxid = &s
  18796. }
  18797. // Wxid returns the value of the "wxid" field in the mutation.
  18798. func (m *MessageMutation) Wxid() (r string, exists bool) {
  18799. v := m.wxid
  18800. if v == nil {
  18801. return
  18802. }
  18803. return *v, true
  18804. }
  18805. // OldWxid returns the old "wxid" field's value of the Message entity.
  18806. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18808. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  18809. if !m.op.Is(OpUpdateOne) {
  18810. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  18811. }
  18812. if m.id == nil || m.oldValue == nil {
  18813. return v, errors.New("OldWxid requires an ID field in the mutation")
  18814. }
  18815. oldValue, err := m.oldValue(ctx)
  18816. if err != nil {
  18817. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  18818. }
  18819. return oldValue.Wxid, nil
  18820. }
  18821. // ResetWxid resets all changes to the "wxid" field.
  18822. func (m *MessageMutation) ResetWxid() {
  18823. m.wxid = nil
  18824. }
  18825. // SetContent sets the "content" field.
  18826. func (m *MessageMutation) SetContent(s string) {
  18827. m.content = &s
  18828. }
  18829. // Content returns the value of the "content" field in the mutation.
  18830. func (m *MessageMutation) Content() (r string, exists bool) {
  18831. v := m.content
  18832. if v == nil {
  18833. return
  18834. }
  18835. return *v, true
  18836. }
  18837. // OldContent returns the old "content" field's value of the Message entity.
  18838. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  18839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18840. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  18841. if !m.op.Is(OpUpdateOne) {
  18842. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  18843. }
  18844. if m.id == nil || m.oldValue == nil {
  18845. return v, errors.New("OldContent requires an ID field in the mutation")
  18846. }
  18847. oldValue, err := m.oldValue(ctx)
  18848. if err != nil {
  18849. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  18850. }
  18851. return oldValue.Content, nil
  18852. }
  18853. // ResetContent resets all changes to the "content" field.
  18854. func (m *MessageMutation) ResetContent() {
  18855. m.content = nil
  18856. }
  18857. // Where appends a list predicates to the MessageMutation builder.
  18858. func (m *MessageMutation) Where(ps ...predicate.Message) {
  18859. m.predicates = append(m.predicates, ps...)
  18860. }
  18861. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  18862. // users can use type-assertion to append predicates that do not depend on any generated package.
  18863. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  18864. p := make([]predicate.Message, len(ps))
  18865. for i := range ps {
  18866. p[i] = ps[i]
  18867. }
  18868. m.Where(p...)
  18869. }
  18870. // Op returns the operation name.
  18871. func (m *MessageMutation) Op() Op {
  18872. return m.op
  18873. }
  18874. // SetOp allows setting the mutation operation.
  18875. func (m *MessageMutation) SetOp(op Op) {
  18876. m.op = op
  18877. }
  18878. // Type returns the node type of this mutation (Message).
  18879. func (m *MessageMutation) Type() string {
  18880. return m.typ
  18881. }
  18882. // Fields returns all fields that were changed during this mutation. Note that in
  18883. // order to get all numeric fields that were incremented/decremented, call
  18884. // AddedFields().
  18885. func (m *MessageMutation) Fields() []string {
  18886. fields := make([]string, 0, 3)
  18887. if m.wx_wxid != nil {
  18888. fields = append(fields, message.FieldWxWxid)
  18889. }
  18890. if m.wxid != nil {
  18891. fields = append(fields, message.FieldWxid)
  18892. }
  18893. if m.content != nil {
  18894. fields = append(fields, message.FieldContent)
  18895. }
  18896. return fields
  18897. }
  18898. // Field returns the value of a field with the given name. The second boolean
  18899. // return value indicates that this field was not set, or was not defined in the
  18900. // schema.
  18901. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  18902. switch name {
  18903. case message.FieldWxWxid:
  18904. return m.WxWxid()
  18905. case message.FieldWxid:
  18906. return m.Wxid()
  18907. case message.FieldContent:
  18908. return m.Content()
  18909. }
  18910. return nil, false
  18911. }
  18912. // OldField returns the old value of the field from the database. An error is
  18913. // returned if the mutation operation is not UpdateOne, or the query to the
  18914. // database failed.
  18915. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18916. switch name {
  18917. case message.FieldWxWxid:
  18918. return m.OldWxWxid(ctx)
  18919. case message.FieldWxid:
  18920. return m.OldWxid(ctx)
  18921. case message.FieldContent:
  18922. return m.OldContent(ctx)
  18923. }
  18924. return nil, fmt.Errorf("unknown Message field %s", name)
  18925. }
  18926. // SetField sets the value of a field with the given name. It returns an error if
  18927. // the field is not defined in the schema, or if the type mismatched the field
  18928. // type.
  18929. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  18930. switch name {
  18931. case message.FieldWxWxid:
  18932. v, ok := value.(string)
  18933. if !ok {
  18934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18935. }
  18936. m.SetWxWxid(v)
  18937. return nil
  18938. case message.FieldWxid:
  18939. v, ok := value.(string)
  18940. if !ok {
  18941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18942. }
  18943. m.SetWxid(v)
  18944. return nil
  18945. case message.FieldContent:
  18946. v, ok := value.(string)
  18947. if !ok {
  18948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18949. }
  18950. m.SetContent(v)
  18951. return nil
  18952. }
  18953. return fmt.Errorf("unknown Message field %s", name)
  18954. }
  18955. // AddedFields returns all numeric fields that were incremented/decremented during
  18956. // this mutation.
  18957. func (m *MessageMutation) AddedFields() []string {
  18958. return nil
  18959. }
  18960. // AddedField returns the numeric value that was incremented/decremented on a field
  18961. // with the given name. The second boolean return value indicates that this field
  18962. // was not set, or was not defined in the schema.
  18963. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  18964. return nil, false
  18965. }
  18966. // AddField adds the value to the field with the given name. It returns an error if
  18967. // the field is not defined in the schema, or if the type mismatched the field
  18968. // type.
  18969. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  18970. switch name {
  18971. }
  18972. return fmt.Errorf("unknown Message numeric field %s", name)
  18973. }
  18974. // ClearedFields returns all nullable fields that were cleared during this
  18975. // mutation.
  18976. func (m *MessageMutation) ClearedFields() []string {
  18977. var fields []string
  18978. if m.FieldCleared(message.FieldWxWxid) {
  18979. fields = append(fields, message.FieldWxWxid)
  18980. }
  18981. return fields
  18982. }
  18983. // FieldCleared returns a boolean indicating if a field with the given name was
  18984. // cleared in this mutation.
  18985. func (m *MessageMutation) FieldCleared(name string) bool {
  18986. _, ok := m.clearedFields[name]
  18987. return ok
  18988. }
  18989. // ClearField clears the value of the field with the given name. It returns an
  18990. // error if the field is not defined in the schema.
  18991. func (m *MessageMutation) ClearField(name string) error {
  18992. switch name {
  18993. case message.FieldWxWxid:
  18994. m.ClearWxWxid()
  18995. return nil
  18996. }
  18997. return fmt.Errorf("unknown Message nullable field %s", name)
  18998. }
  18999. // ResetField resets all changes in the mutation for the field with the given name.
  19000. // It returns an error if the field is not defined in the schema.
  19001. func (m *MessageMutation) ResetField(name string) error {
  19002. switch name {
  19003. case message.FieldWxWxid:
  19004. m.ResetWxWxid()
  19005. return nil
  19006. case message.FieldWxid:
  19007. m.ResetWxid()
  19008. return nil
  19009. case message.FieldContent:
  19010. m.ResetContent()
  19011. return nil
  19012. }
  19013. return fmt.Errorf("unknown Message field %s", name)
  19014. }
  19015. // AddedEdges returns all edge names that were set/added in this mutation.
  19016. func (m *MessageMutation) AddedEdges() []string {
  19017. edges := make([]string, 0, 0)
  19018. return edges
  19019. }
  19020. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19021. // name in this mutation.
  19022. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  19023. return nil
  19024. }
  19025. // RemovedEdges returns all edge names that were removed in this mutation.
  19026. func (m *MessageMutation) RemovedEdges() []string {
  19027. edges := make([]string, 0, 0)
  19028. return edges
  19029. }
  19030. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19031. // the given name in this mutation.
  19032. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  19033. return nil
  19034. }
  19035. // ClearedEdges returns all edge names that were cleared in this mutation.
  19036. func (m *MessageMutation) ClearedEdges() []string {
  19037. edges := make([]string, 0, 0)
  19038. return edges
  19039. }
  19040. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19041. // was cleared in this mutation.
  19042. func (m *MessageMutation) EdgeCleared(name string) bool {
  19043. return false
  19044. }
  19045. // ClearEdge clears the value of the edge with the given name. It returns an error
  19046. // if that edge is not defined in the schema.
  19047. func (m *MessageMutation) ClearEdge(name string) error {
  19048. return fmt.Errorf("unknown Message unique edge %s", name)
  19049. }
  19050. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19051. // It returns an error if the edge is not defined in the schema.
  19052. func (m *MessageMutation) ResetEdge(name string) error {
  19053. return fmt.Errorf("unknown Message edge %s", name)
  19054. }
  19055. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  19056. type MessageRecordsMutation struct {
  19057. config
  19058. op Op
  19059. typ string
  19060. id *uint64
  19061. created_at *time.Time
  19062. updated_at *time.Time
  19063. status *uint8
  19064. addstatus *int8
  19065. bot_wxid *string
  19066. contact_type *int
  19067. addcontact_type *int
  19068. contact_wxid *string
  19069. content_type *int
  19070. addcontent_type *int
  19071. content *string
  19072. meta *custom_types.Meta
  19073. error_detail *string
  19074. send_time *time.Time
  19075. source_type *int
  19076. addsource_type *int
  19077. organization_id *uint64
  19078. addorganization_id *int64
  19079. clearedFields map[string]struct{}
  19080. sop_stage *uint64
  19081. clearedsop_stage bool
  19082. sop_node *uint64
  19083. clearedsop_node bool
  19084. message_contact *uint64
  19085. clearedmessage_contact bool
  19086. done bool
  19087. oldValue func(context.Context) (*MessageRecords, error)
  19088. predicates []predicate.MessageRecords
  19089. }
  19090. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  19091. // messagerecordsOption allows management of the mutation configuration using functional options.
  19092. type messagerecordsOption func(*MessageRecordsMutation)
  19093. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  19094. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  19095. m := &MessageRecordsMutation{
  19096. config: c,
  19097. op: op,
  19098. typ: TypeMessageRecords,
  19099. clearedFields: make(map[string]struct{}),
  19100. }
  19101. for _, opt := range opts {
  19102. opt(m)
  19103. }
  19104. return m
  19105. }
  19106. // withMessageRecordsID sets the ID field of the mutation.
  19107. func withMessageRecordsID(id uint64) messagerecordsOption {
  19108. return func(m *MessageRecordsMutation) {
  19109. var (
  19110. err error
  19111. once sync.Once
  19112. value *MessageRecords
  19113. )
  19114. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  19115. once.Do(func() {
  19116. if m.done {
  19117. err = errors.New("querying old values post mutation is not allowed")
  19118. } else {
  19119. value, err = m.Client().MessageRecords.Get(ctx, id)
  19120. }
  19121. })
  19122. return value, err
  19123. }
  19124. m.id = &id
  19125. }
  19126. }
  19127. // withMessageRecords sets the old MessageRecords of the mutation.
  19128. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  19129. return func(m *MessageRecordsMutation) {
  19130. m.oldValue = func(context.Context) (*MessageRecords, error) {
  19131. return node, nil
  19132. }
  19133. m.id = &node.ID
  19134. }
  19135. }
  19136. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19137. // executed in a transaction (ent.Tx), a transactional client is returned.
  19138. func (m MessageRecordsMutation) Client() *Client {
  19139. client := &Client{config: m.config}
  19140. client.init()
  19141. return client
  19142. }
  19143. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19144. // it returns an error otherwise.
  19145. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  19146. if _, ok := m.driver.(*txDriver); !ok {
  19147. return nil, errors.New("ent: mutation is not running in a transaction")
  19148. }
  19149. tx := &Tx{config: m.config}
  19150. tx.init()
  19151. return tx, nil
  19152. }
  19153. // SetID sets the value of the id field. Note that this
  19154. // operation is only accepted on creation of MessageRecords entities.
  19155. func (m *MessageRecordsMutation) SetID(id uint64) {
  19156. m.id = &id
  19157. }
  19158. // ID returns the ID value in the mutation. Note that the ID is only available
  19159. // if it was provided to the builder or after it was returned from the database.
  19160. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  19161. if m.id == nil {
  19162. return
  19163. }
  19164. return *m.id, true
  19165. }
  19166. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19167. // That means, if the mutation is applied within a transaction with an isolation level such
  19168. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19169. // or updated by the mutation.
  19170. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  19171. switch {
  19172. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19173. id, exists := m.ID()
  19174. if exists {
  19175. return []uint64{id}, nil
  19176. }
  19177. fallthrough
  19178. case m.op.Is(OpUpdate | OpDelete):
  19179. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  19180. default:
  19181. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19182. }
  19183. }
  19184. // SetCreatedAt sets the "created_at" field.
  19185. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  19186. m.created_at = &t
  19187. }
  19188. // CreatedAt returns the value of the "created_at" field in the mutation.
  19189. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  19190. v := m.created_at
  19191. if v == nil {
  19192. return
  19193. }
  19194. return *v, true
  19195. }
  19196. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  19197. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19199. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19200. if !m.op.Is(OpUpdateOne) {
  19201. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19202. }
  19203. if m.id == nil || m.oldValue == nil {
  19204. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19205. }
  19206. oldValue, err := m.oldValue(ctx)
  19207. if err != nil {
  19208. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19209. }
  19210. return oldValue.CreatedAt, nil
  19211. }
  19212. // ResetCreatedAt resets all changes to the "created_at" field.
  19213. func (m *MessageRecordsMutation) ResetCreatedAt() {
  19214. m.created_at = nil
  19215. }
  19216. // SetUpdatedAt sets the "updated_at" field.
  19217. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  19218. m.updated_at = &t
  19219. }
  19220. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19221. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  19222. v := m.updated_at
  19223. if v == nil {
  19224. return
  19225. }
  19226. return *v, true
  19227. }
  19228. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  19229. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19231. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19232. if !m.op.Is(OpUpdateOne) {
  19233. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19234. }
  19235. if m.id == nil || m.oldValue == nil {
  19236. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19237. }
  19238. oldValue, err := m.oldValue(ctx)
  19239. if err != nil {
  19240. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19241. }
  19242. return oldValue.UpdatedAt, nil
  19243. }
  19244. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19245. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  19246. m.updated_at = nil
  19247. }
  19248. // SetStatus sets the "status" field.
  19249. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  19250. m.status = &u
  19251. m.addstatus = nil
  19252. }
  19253. // Status returns the value of the "status" field in the mutation.
  19254. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  19255. v := m.status
  19256. if v == nil {
  19257. return
  19258. }
  19259. return *v, true
  19260. }
  19261. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  19262. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19264. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19265. if !m.op.Is(OpUpdateOne) {
  19266. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19267. }
  19268. if m.id == nil || m.oldValue == nil {
  19269. return v, errors.New("OldStatus requires an ID field in the mutation")
  19270. }
  19271. oldValue, err := m.oldValue(ctx)
  19272. if err != nil {
  19273. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19274. }
  19275. return oldValue.Status, nil
  19276. }
  19277. // AddStatus adds u to the "status" field.
  19278. func (m *MessageRecordsMutation) AddStatus(u int8) {
  19279. if m.addstatus != nil {
  19280. *m.addstatus += u
  19281. } else {
  19282. m.addstatus = &u
  19283. }
  19284. }
  19285. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19286. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  19287. v := m.addstatus
  19288. if v == nil {
  19289. return
  19290. }
  19291. return *v, true
  19292. }
  19293. // ClearStatus clears the value of the "status" field.
  19294. func (m *MessageRecordsMutation) ClearStatus() {
  19295. m.status = nil
  19296. m.addstatus = nil
  19297. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  19298. }
  19299. // StatusCleared returns if the "status" field was cleared in this mutation.
  19300. func (m *MessageRecordsMutation) StatusCleared() bool {
  19301. _, ok := m.clearedFields[messagerecords.FieldStatus]
  19302. return ok
  19303. }
  19304. // ResetStatus resets all changes to the "status" field.
  19305. func (m *MessageRecordsMutation) ResetStatus() {
  19306. m.status = nil
  19307. m.addstatus = nil
  19308. delete(m.clearedFields, messagerecords.FieldStatus)
  19309. }
  19310. // SetBotWxid sets the "bot_wxid" field.
  19311. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  19312. m.bot_wxid = &s
  19313. }
  19314. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  19315. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  19316. v := m.bot_wxid
  19317. if v == nil {
  19318. return
  19319. }
  19320. return *v, true
  19321. }
  19322. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  19323. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19325. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  19326. if !m.op.Is(OpUpdateOne) {
  19327. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  19328. }
  19329. if m.id == nil || m.oldValue == nil {
  19330. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  19331. }
  19332. oldValue, err := m.oldValue(ctx)
  19333. if err != nil {
  19334. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  19335. }
  19336. return oldValue.BotWxid, nil
  19337. }
  19338. // ResetBotWxid resets all changes to the "bot_wxid" field.
  19339. func (m *MessageRecordsMutation) ResetBotWxid() {
  19340. m.bot_wxid = nil
  19341. }
  19342. // SetContactID sets the "contact_id" field.
  19343. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  19344. m.message_contact = &u
  19345. }
  19346. // ContactID returns the value of the "contact_id" field in the mutation.
  19347. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  19348. v := m.message_contact
  19349. if v == nil {
  19350. return
  19351. }
  19352. return *v, true
  19353. }
  19354. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  19355. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19357. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  19358. if !m.op.Is(OpUpdateOne) {
  19359. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  19360. }
  19361. if m.id == nil || m.oldValue == nil {
  19362. return v, errors.New("OldContactID requires an ID field in the mutation")
  19363. }
  19364. oldValue, err := m.oldValue(ctx)
  19365. if err != nil {
  19366. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  19367. }
  19368. return oldValue.ContactID, nil
  19369. }
  19370. // ClearContactID clears the value of the "contact_id" field.
  19371. func (m *MessageRecordsMutation) ClearContactID() {
  19372. m.message_contact = nil
  19373. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19374. }
  19375. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  19376. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  19377. _, ok := m.clearedFields[messagerecords.FieldContactID]
  19378. return ok
  19379. }
  19380. // ResetContactID resets all changes to the "contact_id" field.
  19381. func (m *MessageRecordsMutation) ResetContactID() {
  19382. m.message_contact = nil
  19383. delete(m.clearedFields, messagerecords.FieldContactID)
  19384. }
  19385. // SetContactType sets the "contact_type" field.
  19386. func (m *MessageRecordsMutation) SetContactType(i int) {
  19387. m.contact_type = &i
  19388. m.addcontact_type = nil
  19389. }
  19390. // ContactType returns the value of the "contact_type" field in the mutation.
  19391. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  19392. v := m.contact_type
  19393. if v == nil {
  19394. return
  19395. }
  19396. return *v, true
  19397. }
  19398. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  19399. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19401. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  19402. if !m.op.Is(OpUpdateOne) {
  19403. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  19404. }
  19405. if m.id == nil || m.oldValue == nil {
  19406. return v, errors.New("OldContactType requires an ID field in the mutation")
  19407. }
  19408. oldValue, err := m.oldValue(ctx)
  19409. if err != nil {
  19410. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  19411. }
  19412. return oldValue.ContactType, nil
  19413. }
  19414. // AddContactType adds i to the "contact_type" field.
  19415. func (m *MessageRecordsMutation) AddContactType(i int) {
  19416. if m.addcontact_type != nil {
  19417. *m.addcontact_type += i
  19418. } else {
  19419. m.addcontact_type = &i
  19420. }
  19421. }
  19422. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  19423. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  19424. v := m.addcontact_type
  19425. if v == nil {
  19426. return
  19427. }
  19428. return *v, true
  19429. }
  19430. // ResetContactType resets all changes to the "contact_type" field.
  19431. func (m *MessageRecordsMutation) ResetContactType() {
  19432. m.contact_type = nil
  19433. m.addcontact_type = nil
  19434. }
  19435. // SetContactWxid sets the "contact_wxid" field.
  19436. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  19437. m.contact_wxid = &s
  19438. }
  19439. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  19440. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  19441. v := m.contact_wxid
  19442. if v == nil {
  19443. return
  19444. }
  19445. return *v, true
  19446. }
  19447. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  19448. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19450. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  19451. if !m.op.Is(OpUpdateOne) {
  19452. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  19453. }
  19454. if m.id == nil || m.oldValue == nil {
  19455. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  19456. }
  19457. oldValue, err := m.oldValue(ctx)
  19458. if err != nil {
  19459. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  19460. }
  19461. return oldValue.ContactWxid, nil
  19462. }
  19463. // ResetContactWxid resets all changes to the "contact_wxid" field.
  19464. func (m *MessageRecordsMutation) ResetContactWxid() {
  19465. m.contact_wxid = nil
  19466. }
  19467. // SetContentType sets the "content_type" field.
  19468. func (m *MessageRecordsMutation) SetContentType(i int) {
  19469. m.content_type = &i
  19470. m.addcontent_type = nil
  19471. }
  19472. // ContentType returns the value of the "content_type" field in the mutation.
  19473. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  19474. v := m.content_type
  19475. if v == nil {
  19476. return
  19477. }
  19478. return *v, true
  19479. }
  19480. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  19481. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19483. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  19484. if !m.op.Is(OpUpdateOne) {
  19485. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  19486. }
  19487. if m.id == nil || m.oldValue == nil {
  19488. return v, errors.New("OldContentType requires an ID field in the mutation")
  19489. }
  19490. oldValue, err := m.oldValue(ctx)
  19491. if err != nil {
  19492. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  19493. }
  19494. return oldValue.ContentType, nil
  19495. }
  19496. // AddContentType adds i to the "content_type" field.
  19497. func (m *MessageRecordsMutation) AddContentType(i int) {
  19498. if m.addcontent_type != nil {
  19499. *m.addcontent_type += i
  19500. } else {
  19501. m.addcontent_type = &i
  19502. }
  19503. }
  19504. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  19505. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  19506. v := m.addcontent_type
  19507. if v == nil {
  19508. return
  19509. }
  19510. return *v, true
  19511. }
  19512. // ResetContentType resets all changes to the "content_type" field.
  19513. func (m *MessageRecordsMutation) ResetContentType() {
  19514. m.content_type = nil
  19515. m.addcontent_type = nil
  19516. }
  19517. // SetContent sets the "content" field.
  19518. func (m *MessageRecordsMutation) SetContent(s string) {
  19519. m.content = &s
  19520. }
  19521. // Content returns the value of the "content" field in the mutation.
  19522. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  19523. v := m.content
  19524. if v == nil {
  19525. return
  19526. }
  19527. return *v, true
  19528. }
  19529. // OldContent returns the old "content" field's value of the MessageRecords entity.
  19530. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19532. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  19533. if !m.op.Is(OpUpdateOne) {
  19534. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19535. }
  19536. if m.id == nil || m.oldValue == nil {
  19537. return v, errors.New("OldContent requires an ID field in the mutation")
  19538. }
  19539. oldValue, err := m.oldValue(ctx)
  19540. if err != nil {
  19541. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19542. }
  19543. return oldValue.Content, nil
  19544. }
  19545. // ResetContent resets all changes to the "content" field.
  19546. func (m *MessageRecordsMutation) ResetContent() {
  19547. m.content = nil
  19548. }
  19549. // SetMeta sets the "meta" field.
  19550. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  19551. m.meta = &ct
  19552. }
  19553. // Meta returns the value of the "meta" field in the mutation.
  19554. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  19555. v := m.meta
  19556. if v == nil {
  19557. return
  19558. }
  19559. return *v, true
  19560. }
  19561. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  19562. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19564. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  19565. if !m.op.Is(OpUpdateOne) {
  19566. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  19567. }
  19568. if m.id == nil || m.oldValue == nil {
  19569. return v, errors.New("OldMeta requires an ID field in the mutation")
  19570. }
  19571. oldValue, err := m.oldValue(ctx)
  19572. if err != nil {
  19573. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  19574. }
  19575. return oldValue.Meta, nil
  19576. }
  19577. // ClearMeta clears the value of the "meta" field.
  19578. func (m *MessageRecordsMutation) ClearMeta() {
  19579. m.meta = nil
  19580. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  19581. }
  19582. // MetaCleared returns if the "meta" field was cleared in this mutation.
  19583. func (m *MessageRecordsMutation) MetaCleared() bool {
  19584. _, ok := m.clearedFields[messagerecords.FieldMeta]
  19585. return ok
  19586. }
  19587. // ResetMeta resets all changes to the "meta" field.
  19588. func (m *MessageRecordsMutation) ResetMeta() {
  19589. m.meta = nil
  19590. delete(m.clearedFields, messagerecords.FieldMeta)
  19591. }
  19592. // SetErrorDetail sets the "error_detail" field.
  19593. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  19594. m.error_detail = &s
  19595. }
  19596. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  19597. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  19598. v := m.error_detail
  19599. if v == nil {
  19600. return
  19601. }
  19602. return *v, true
  19603. }
  19604. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  19605. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19607. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  19608. if !m.op.Is(OpUpdateOne) {
  19609. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  19610. }
  19611. if m.id == nil || m.oldValue == nil {
  19612. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  19613. }
  19614. oldValue, err := m.oldValue(ctx)
  19615. if err != nil {
  19616. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  19617. }
  19618. return oldValue.ErrorDetail, nil
  19619. }
  19620. // ResetErrorDetail resets all changes to the "error_detail" field.
  19621. func (m *MessageRecordsMutation) ResetErrorDetail() {
  19622. m.error_detail = nil
  19623. }
  19624. // SetSendTime sets the "send_time" field.
  19625. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  19626. m.send_time = &t
  19627. }
  19628. // SendTime returns the value of the "send_time" field in the mutation.
  19629. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  19630. v := m.send_time
  19631. if v == nil {
  19632. return
  19633. }
  19634. return *v, true
  19635. }
  19636. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  19637. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19639. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  19640. if !m.op.Is(OpUpdateOne) {
  19641. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  19642. }
  19643. if m.id == nil || m.oldValue == nil {
  19644. return v, errors.New("OldSendTime requires an ID field in the mutation")
  19645. }
  19646. oldValue, err := m.oldValue(ctx)
  19647. if err != nil {
  19648. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  19649. }
  19650. return oldValue.SendTime, nil
  19651. }
  19652. // ClearSendTime clears the value of the "send_time" field.
  19653. func (m *MessageRecordsMutation) ClearSendTime() {
  19654. m.send_time = nil
  19655. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  19656. }
  19657. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  19658. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  19659. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  19660. return ok
  19661. }
  19662. // ResetSendTime resets all changes to the "send_time" field.
  19663. func (m *MessageRecordsMutation) ResetSendTime() {
  19664. m.send_time = nil
  19665. delete(m.clearedFields, messagerecords.FieldSendTime)
  19666. }
  19667. // SetSourceType sets the "source_type" field.
  19668. func (m *MessageRecordsMutation) SetSourceType(i int) {
  19669. m.source_type = &i
  19670. m.addsource_type = nil
  19671. }
  19672. // SourceType returns the value of the "source_type" field in the mutation.
  19673. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  19674. v := m.source_type
  19675. if v == nil {
  19676. return
  19677. }
  19678. return *v, true
  19679. }
  19680. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  19681. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19683. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  19684. if !m.op.Is(OpUpdateOne) {
  19685. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  19686. }
  19687. if m.id == nil || m.oldValue == nil {
  19688. return v, errors.New("OldSourceType requires an ID field in the mutation")
  19689. }
  19690. oldValue, err := m.oldValue(ctx)
  19691. if err != nil {
  19692. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  19693. }
  19694. return oldValue.SourceType, nil
  19695. }
  19696. // AddSourceType adds i to the "source_type" field.
  19697. func (m *MessageRecordsMutation) AddSourceType(i int) {
  19698. if m.addsource_type != nil {
  19699. *m.addsource_type += i
  19700. } else {
  19701. m.addsource_type = &i
  19702. }
  19703. }
  19704. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  19705. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  19706. v := m.addsource_type
  19707. if v == nil {
  19708. return
  19709. }
  19710. return *v, true
  19711. }
  19712. // ResetSourceType resets all changes to the "source_type" field.
  19713. func (m *MessageRecordsMutation) ResetSourceType() {
  19714. m.source_type = nil
  19715. m.addsource_type = nil
  19716. }
  19717. // SetSourceID sets the "source_id" field.
  19718. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  19719. m.sop_stage = &u
  19720. }
  19721. // SourceID returns the value of the "source_id" field in the mutation.
  19722. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  19723. v := m.sop_stage
  19724. if v == nil {
  19725. return
  19726. }
  19727. return *v, true
  19728. }
  19729. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  19730. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19732. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  19733. if !m.op.Is(OpUpdateOne) {
  19734. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  19735. }
  19736. if m.id == nil || m.oldValue == nil {
  19737. return v, errors.New("OldSourceID requires an ID field in the mutation")
  19738. }
  19739. oldValue, err := m.oldValue(ctx)
  19740. if err != nil {
  19741. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  19742. }
  19743. return oldValue.SourceID, nil
  19744. }
  19745. // ClearSourceID clears the value of the "source_id" field.
  19746. func (m *MessageRecordsMutation) ClearSourceID() {
  19747. m.sop_stage = nil
  19748. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19749. }
  19750. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  19751. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  19752. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  19753. return ok
  19754. }
  19755. // ResetSourceID resets all changes to the "source_id" field.
  19756. func (m *MessageRecordsMutation) ResetSourceID() {
  19757. m.sop_stage = nil
  19758. delete(m.clearedFields, messagerecords.FieldSourceID)
  19759. }
  19760. // SetSubSourceID sets the "sub_source_id" field.
  19761. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  19762. m.sop_node = &u
  19763. }
  19764. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  19765. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  19766. v := m.sop_node
  19767. if v == nil {
  19768. return
  19769. }
  19770. return *v, true
  19771. }
  19772. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  19773. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19775. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  19776. if !m.op.Is(OpUpdateOne) {
  19777. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  19778. }
  19779. if m.id == nil || m.oldValue == nil {
  19780. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  19781. }
  19782. oldValue, err := m.oldValue(ctx)
  19783. if err != nil {
  19784. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  19785. }
  19786. return oldValue.SubSourceID, nil
  19787. }
  19788. // ClearSubSourceID clears the value of the "sub_source_id" field.
  19789. func (m *MessageRecordsMutation) ClearSubSourceID() {
  19790. m.sop_node = nil
  19791. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19792. }
  19793. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  19794. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  19795. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  19796. return ok
  19797. }
  19798. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  19799. func (m *MessageRecordsMutation) ResetSubSourceID() {
  19800. m.sop_node = nil
  19801. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  19802. }
  19803. // SetOrganizationID sets the "organization_id" field.
  19804. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  19805. m.organization_id = &u
  19806. m.addorganization_id = nil
  19807. }
  19808. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19809. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  19810. v := m.organization_id
  19811. if v == nil {
  19812. return
  19813. }
  19814. return *v, true
  19815. }
  19816. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  19817. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  19818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19819. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19820. if !m.op.Is(OpUpdateOne) {
  19821. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19822. }
  19823. if m.id == nil || m.oldValue == nil {
  19824. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19825. }
  19826. oldValue, err := m.oldValue(ctx)
  19827. if err != nil {
  19828. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19829. }
  19830. return oldValue.OrganizationID, nil
  19831. }
  19832. // AddOrganizationID adds u to the "organization_id" field.
  19833. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  19834. if m.addorganization_id != nil {
  19835. *m.addorganization_id += u
  19836. } else {
  19837. m.addorganization_id = &u
  19838. }
  19839. }
  19840. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19841. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  19842. v := m.addorganization_id
  19843. if v == nil {
  19844. return
  19845. }
  19846. return *v, true
  19847. }
  19848. // ClearOrganizationID clears the value of the "organization_id" field.
  19849. func (m *MessageRecordsMutation) ClearOrganizationID() {
  19850. m.organization_id = nil
  19851. m.addorganization_id = nil
  19852. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  19853. }
  19854. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  19855. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  19856. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  19857. return ok
  19858. }
  19859. // ResetOrganizationID resets all changes to the "organization_id" field.
  19860. func (m *MessageRecordsMutation) ResetOrganizationID() {
  19861. m.organization_id = nil
  19862. m.addorganization_id = nil
  19863. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  19864. }
  19865. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  19866. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  19867. m.sop_stage = &id
  19868. }
  19869. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  19870. func (m *MessageRecordsMutation) ClearSopStage() {
  19871. m.clearedsop_stage = true
  19872. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  19873. }
  19874. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  19875. func (m *MessageRecordsMutation) SopStageCleared() bool {
  19876. return m.SourceIDCleared() || m.clearedsop_stage
  19877. }
  19878. // SopStageID returns the "sop_stage" edge ID in the mutation.
  19879. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  19880. if m.sop_stage != nil {
  19881. return *m.sop_stage, true
  19882. }
  19883. return
  19884. }
  19885. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  19886. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19887. // SopStageID instead. It exists only for internal usage by the builders.
  19888. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  19889. if id := m.sop_stage; id != nil {
  19890. ids = append(ids, *id)
  19891. }
  19892. return
  19893. }
  19894. // ResetSopStage resets all changes to the "sop_stage" edge.
  19895. func (m *MessageRecordsMutation) ResetSopStage() {
  19896. m.sop_stage = nil
  19897. m.clearedsop_stage = false
  19898. }
  19899. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  19900. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  19901. m.sop_node = &id
  19902. }
  19903. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  19904. func (m *MessageRecordsMutation) ClearSopNode() {
  19905. m.clearedsop_node = true
  19906. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  19907. }
  19908. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  19909. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  19910. return m.SubSourceIDCleared() || m.clearedsop_node
  19911. }
  19912. // SopNodeID returns the "sop_node" edge ID in the mutation.
  19913. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  19914. if m.sop_node != nil {
  19915. return *m.sop_node, true
  19916. }
  19917. return
  19918. }
  19919. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  19920. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19921. // SopNodeID instead. It exists only for internal usage by the builders.
  19922. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  19923. if id := m.sop_node; id != nil {
  19924. ids = append(ids, *id)
  19925. }
  19926. return
  19927. }
  19928. // ResetSopNode resets all changes to the "sop_node" edge.
  19929. func (m *MessageRecordsMutation) ResetSopNode() {
  19930. m.sop_node = nil
  19931. m.clearedsop_node = false
  19932. }
  19933. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  19934. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  19935. m.message_contact = &id
  19936. }
  19937. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  19938. func (m *MessageRecordsMutation) ClearMessageContact() {
  19939. m.clearedmessage_contact = true
  19940. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  19941. }
  19942. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  19943. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  19944. return m.ContactIDCleared() || m.clearedmessage_contact
  19945. }
  19946. // MessageContactID returns the "message_contact" edge ID in the mutation.
  19947. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  19948. if m.message_contact != nil {
  19949. return *m.message_contact, true
  19950. }
  19951. return
  19952. }
  19953. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  19954. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19955. // MessageContactID instead. It exists only for internal usage by the builders.
  19956. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  19957. if id := m.message_contact; id != nil {
  19958. ids = append(ids, *id)
  19959. }
  19960. return
  19961. }
  19962. // ResetMessageContact resets all changes to the "message_contact" edge.
  19963. func (m *MessageRecordsMutation) ResetMessageContact() {
  19964. m.message_contact = nil
  19965. m.clearedmessage_contact = false
  19966. }
  19967. // Where appends a list predicates to the MessageRecordsMutation builder.
  19968. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  19969. m.predicates = append(m.predicates, ps...)
  19970. }
  19971. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  19972. // users can use type-assertion to append predicates that do not depend on any generated package.
  19973. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  19974. p := make([]predicate.MessageRecords, len(ps))
  19975. for i := range ps {
  19976. p[i] = ps[i]
  19977. }
  19978. m.Where(p...)
  19979. }
  19980. // Op returns the operation name.
  19981. func (m *MessageRecordsMutation) Op() Op {
  19982. return m.op
  19983. }
  19984. // SetOp allows setting the mutation operation.
  19985. func (m *MessageRecordsMutation) SetOp(op Op) {
  19986. m.op = op
  19987. }
  19988. // Type returns the node type of this mutation (MessageRecords).
  19989. func (m *MessageRecordsMutation) Type() string {
  19990. return m.typ
  19991. }
  19992. // Fields returns all fields that were changed during this mutation. Note that in
  19993. // order to get all numeric fields that were incremented/decremented, call
  19994. // AddedFields().
  19995. func (m *MessageRecordsMutation) Fields() []string {
  19996. fields := make([]string, 0, 16)
  19997. if m.created_at != nil {
  19998. fields = append(fields, messagerecords.FieldCreatedAt)
  19999. }
  20000. if m.updated_at != nil {
  20001. fields = append(fields, messagerecords.FieldUpdatedAt)
  20002. }
  20003. if m.status != nil {
  20004. fields = append(fields, messagerecords.FieldStatus)
  20005. }
  20006. if m.bot_wxid != nil {
  20007. fields = append(fields, messagerecords.FieldBotWxid)
  20008. }
  20009. if m.message_contact != nil {
  20010. fields = append(fields, messagerecords.FieldContactID)
  20011. }
  20012. if m.contact_type != nil {
  20013. fields = append(fields, messagerecords.FieldContactType)
  20014. }
  20015. if m.contact_wxid != nil {
  20016. fields = append(fields, messagerecords.FieldContactWxid)
  20017. }
  20018. if m.content_type != nil {
  20019. fields = append(fields, messagerecords.FieldContentType)
  20020. }
  20021. if m.content != nil {
  20022. fields = append(fields, messagerecords.FieldContent)
  20023. }
  20024. if m.meta != nil {
  20025. fields = append(fields, messagerecords.FieldMeta)
  20026. }
  20027. if m.error_detail != nil {
  20028. fields = append(fields, messagerecords.FieldErrorDetail)
  20029. }
  20030. if m.send_time != nil {
  20031. fields = append(fields, messagerecords.FieldSendTime)
  20032. }
  20033. if m.source_type != nil {
  20034. fields = append(fields, messagerecords.FieldSourceType)
  20035. }
  20036. if m.sop_stage != nil {
  20037. fields = append(fields, messagerecords.FieldSourceID)
  20038. }
  20039. if m.sop_node != nil {
  20040. fields = append(fields, messagerecords.FieldSubSourceID)
  20041. }
  20042. if m.organization_id != nil {
  20043. fields = append(fields, messagerecords.FieldOrganizationID)
  20044. }
  20045. return fields
  20046. }
  20047. // Field returns the value of a field with the given name. The second boolean
  20048. // return value indicates that this field was not set, or was not defined in the
  20049. // schema.
  20050. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  20051. switch name {
  20052. case messagerecords.FieldCreatedAt:
  20053. return m.CreatedAt()
  20054. case messagerecords.FieldUpdatedAt:
  20055. return m.UpdatedAt()
  20056. case messagerecords.FieldStatus:
  20057. return m.Status()
  20058. case messagerecords.FieldBotWxid:
  20059. return m.BotWxid()
  20060. case messagerecords.FieldContactID:
  20061. return m.ContactID()
  20062. case messagerecords.FieldContactType:
  20063. return m.ContactType()
  20064. case messagerecords.FieldContactWxid:
  20065. return m.ContactWxid()
  20066. case messagerecords.FieldContentType:
  20067. return m.ContentType()
  20068. case messagerecords.FieldContent:
  20069. return m.Content()
  20070. case messagerecords.FieldMeta:
  20071. return m.Meta()
  20072. case messagerecords.FieldErrorDetail:
  20073. return m.ErrorDetail()
  20074. case messagerecords.FieldSendTime:
  20075. return m.SendTime()
  20076. case messagerecords.FieldSourceType:
  20077. return m.SourceType()
  20078. case messagerecords.FieldSourceID:
  20079. return m.SourceID()
  20080. case messagerecords.FieldSubSourceID:
  20081. return m.SubSourceID()
  20082. case messagerecords.FieldOrganizationID:
  20083. return m.OrganizationID()
  20084. }
  20085. return nil, false
  20086. }
  20087. // OldField returns the old value of the field from the database. An error is
  20088. // returned if the mutation operation is not UpdateOne, or the query to the
  20089. // database failed.
  20090. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20091. switch name {
  20092. case messagerecords.FieldCreatedAt:
  20093. return m.OldCreatedAt(ctx)
  20094. case messagerecords.FieldUpdatedAt:
  20095. return m.OldUpdatedAt(ctx)
  20096. case messagerecords.FieldStatus:
  20097. return m.OldStatus(ctx)
  20098. case messagerecords.FieldBotWxid:
  20099. return m.OldBotWxid(ctx)
  20100. case messagerecords.FieldContactID:
  20101. return m.OldContactID(ctx)
  20102. case messagerecords.FieldContactType:
  20103. return m.OldContactType(ctx)
  20104. case messagerecords.FieldContactWxid:
  20105. return m.OldContactWxid(ctx)
  20106. case messagerecords.FieldContentType:
  20107. return m.OldContentType(ctx)
  20108. case messagerecords.FieldContent:
  20109. return m.OldContent(ctx)
  20110. case messagerecords.FieldMeta:
  20111. return m.OldMeta(ctx)
  20112. case messagerecords.FieldErrorDetail:
  20113. return m.OldErrorDetail(ctx)
  20114. case messagerecords.FieldSendTime:
  20115. return m.OldSendTime(ctx)
  20116. case messagerecords.FieldSourceType:
  20117. return m.OldSourceType(ctx)
  20118. case messagerecords.FieldSourceID:
  20119. return m.OldSourceID(ctx)
  20120. case messagerecords.FieldSubSourceID:
  20121. return m.OldSubSourceID(ctx)
  20122. case messagerecords.FieldOrganizationID:
  20123. return m.OldOrganizationID(ctx)
  20124. }
  20125. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  20126. }
  20127. // SetField sets the value of a field with the given name. It returns an error if
  20128. // the field is not defined in the schema, or if the type mismatched the field
  20129. // type.
  20130. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  20131. switch name {
  20132. case messagerecords.FieldCreatedAt:
  20133. v, ok := value.(time.Time)
  20134. if !ok {
  20135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20136. }
  20137. m.SetCreatedAt(v)
  20138. return nil
  20139. case messagerecords.FieldUpdatedAt:
  20140. v, ok := value.(time.Time)
  20141. if !ok {
  20142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20143. }
  20144. m.SetUpdatedAt(v)
  20145. return nil
  20146. case messagerecords.FieldStatus:
  20147. v, ok := value.(uint8)
  20148. if !ok {
  20149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20150. }
  20151. m.SetStatus(v)
  20152. return nil
  20153. case messagerecords.FieldBotWxid:
  20154. v, ok := value.(string)
  20155. if !ok {
  20156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20157. }
  20158. m.SetBotWxid(v)
  20159. return nil
  20160. case messagerecords.FieldContactID:
  20161. v, ok := value.(uint64)
  20162. if !ok {
  20163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20164. }
  20165. m.SetContactID(v)
  20166. return nil
  20167. case messagerecords.FieldContactType:
  20168. v, ok := value.(int)
  20169. if !ok {
  20170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20171. }
  20172. m.SetContactType(v)
  20173. return nil
  20174. case messagerecords.FieldContactWxid:
  20175. v, ok := value.(string)
  20176. if !ok {
  20177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20178. }
  20179. m.SetContactWxid(v)
  20180. return nil
  20181. case messagerecords.FieldContentType:
  20182. v, ok := value.(int)
  20183. if !ok {
  20184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20185. }
  20186. m.SetContentType(v)
  20187. return nil
  20188. case messagerecords.FieldContent:
  20189. v, ok := value.(string)
  20190. if !ok {
  20191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20192. }
  20193. m.SetContent(v)
  20194. return nil
  20195. case messagerecords.FieldMeta:
  20196. v, ok := value.(custom_types.Meta)
  20197. if !ok {
  20198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20199. }
  20200. m.SetMeta(v)
  20201. return nil
  20202. case messagerecords.FieldErrorDetail:
  20203. v, ok := value.(string)
  20204. if !ok {
  20205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20206. }
  20207. m.SetErrorDetail(v)
  20208. return nil
  20209. case messagerecords.FieldSendTime:
  20210. v, ok := value.(time.Time)
  20211. if !ok {
  20212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20213. }
  20214. m.SetSendTime(v)
  20215. return nil
  20216. case messagerecords.FieldSourceType:
  20217. v, ok := value.(int)
  20218. if !ok {
  20219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20220. }
  20221. m.SetSourceType(v)
  20222. return nil
  20223. case messagerecords.FieldSourceID:
  20224. v, ok := value.(uint64)
  20225. if !ok {
  20226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20227. }
  20228. m.SetSourceID(v)
  20229. return nil
  20230. case messagerecords.FieldSubSourceID:
  20231. v, ok := value.(uint64)
  20232. if !ok {
  20233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20234. }
  20235. m.SetSubSourceID(v)
  20236. return nil
  20237. case messagerecords.FieldOrganizationID:
  20238. v, ok := value.(uint64)
  20239. if !ok {
  20240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20241. }
  20242. m.SetOrganizationID(v)
  20243. return nil
  20244. }
  20245. return fmt.Errorf("unknown MessageRecords field %s", name)
  20246. }
  20247. // AddedFields returns all numeric fields that were incremented/decremented during
  20248. // this mutation.
  20249. func (m *MessageRecordsMutation) AddedFields() []string {
  20250. var fields []string
  20251. if m.addstatus != nil {
  20252. fields = append(fields, messagerecords.FieldStatus)
  20253. }
  20254. if m.addcontact_type != nil {
  20255. fields = append(fields, messagerecords.FieldContactType)
  20256. }
  20257. if m.addcontent_type != nil {
  20258. fields = append(fields, messagerecords.FieldContentType)
  20259. }
  20260. if m.addsource_type != nil {
  20261. fields = append(fields, messagerecords.FieldSourceType)
  20262. }
  20263. if m.addorganization_id != nil {
  20264. fields = append(fields, messagerecords.FieldOrganizationID)
  20265. }
  20266. return fields
  20267. }
  20268. // AddedField returns the numeric value that was incremented/decremented on a field
  20269. // with the given name. The second boolean return value indicates that this field
  20270. // was not set, or was not defined in the schema.
  20271. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  20272. switch name {
  20273. case messagerecords.FieldStatus:
  20274. return m.AddedStatus()
  20275. case messagerecords.FieldContactType:
  20276. return m.AddedContactType()
  20277. case messagerecords.FieldContentType:
  20278. return m.AddedContentType()
  20279. case messagerecords.FieldSourceType:
  20280. return m.AddedSourceType()
  20281. case messagerecords.FieldOrganizationID:
  20282. return m.AddedOrganizationID()
  20283. }
  20284. return nil, false
  20285. }
  20286. // AddField adds the value to the field with the given name. It returns an error if
  20287. // the field is not defined in the schema, or if the type mismatched the field
  20288. // type.
  20289. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  20290. switch name {
  20291. case messagerecords.FieldStatus:
  20292. v, ok := value.(int8)
  20293. if !ok {
  20294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20295. }
  20296. m.AddStatus(v)
  20297. return nil
  20298. case messagerecords.FieldContactType:
  20299. v, ok := value.(int)
  20300. if !ok {
  20301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20302. }
  20303. m.AddContactType(v)
  20304. return nil
  20305. case messagerecords.FieldContentType:
  20306. v, ok := value.(int)
  20307. if !ok {
  20308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20309. }
  20310. m.AddContentType(v)
  20311. return nil
  20312. case messagerecords.FieldSourceType:
  20313. v, ok := value.(int)
  20314. if !ok {
  20315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20316. }
  20317. m.AddSourceType(v)
  20318. return nil
  20319. case messagerecords.FieldOrganizationID:
  20320. v, ok := value.(int64)
  20321. if !ok {
  20322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20323. }
  20324. m.AddOrganizationID(v)
  20325. return nil
  20326. }
  20327. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  20328. }
  20329. // ClearedFields returns all nullable fields that were cleared during this
  20330. // mutation.
  20331. func (m *MessageRecordsMutation) ClearedFields() []string {
  20332. var fields []string
  20333. if m.FieldCleared(messagerecords.FieldStatus) {
  20334. fields = append(fields, messagerecords.FieldStatus)
  20335. }
  20336. if m.FieldCleared(messagerecords.FieldContactID) {
  20337. fields = append(fields, messagerecords.FieldContactID)
  20338. }
  20339. if m.FieldCleared(messagerecords.FieldMeta) {
  20340. fields = append(fields, messagerecords.FieldMeta)
  20341. }
  20342. if m.FieldCleared(messagerecords.FieldSendTime) {
  20343. fields = append(fields, messagerecords.FieldSendTime)
  20344. }
  20345. if m.FieldCleared(messagerecords.FieldSourceID) {
  20346. fields = append(fields, messagerecords.FieldSourceID)
  20347. }
  20348. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  20349. fields = append(fields, messagerecords.FieldSubSourceID)
  20350. }
  20351. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  20352. fields = append(fields, messagerecords.FieldOrganizationID)
  20353. }
  20354. return fields
  20355. }
  20356. // FieldCleared returns a boolean indicating if a field with the given name was
  20357. // cleared in this mutation.
  20358. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  20359. _, ok := m.clearedFields[name]
  20360. return ok
  20361. }
  20362. // ClearField clears the value of the field with the given name. It returns an
  20363. // error if the field is not defined in the schema.
  20364. func (m *MessageRecordsMutation) ClearField(name string) error {
  20365. switch name {
  20366. case messagerecords.FieldStatus:
  20367. m.ClearStatus()
  20368. return nil
  20369. case messagerecords.FieldContactID:
  20370. m.ClearContactID()
  20371. return nil
  20372. case messagerecords.FieldMeta:
  20373. m.ClearMeta()
  20374. return nil
  20375. case messagerecords.FieldSendTime:
  20376. m.ClearSendTime()
  20377. return nil
  20378. case messagerecords.FieldSourceID:
  20379. m.ClearSourceID()
  20380. return nil
  20381. case messagerecords.FieldSubSourceID:
  20382. m.ClearSubSourceID()
  20383. return nil
  20384. case messagerecords.FieldOrganizationID:
  20385. m.ClearOrganizationID()
  20386. return nil
  20387. }
  20388. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  20389. }
  20390. // ResetField resets all changes in the mutation for the field with the given name.
  20391. // It returns an error if the field is not defined in the schema.
  20392. func (m *MessageRecordsMutation) ResetField(name string) error {
  20393. switch name {
  20394. case messagerecords.FieldCreatedAt:
  20395. m.ResetCreatedAt()
  20396. return nil
  20397. case messagerecords.FieldUpdatedAt:
  20398. m.ResetUpdatedAt()
  20399. return nil
  20400. case messagerecords.FieldStatus:
  20401. m.ResetStatus()
  20402. return nil
  20403. case messagerecords.FieldBotWxid:
  20404. m.ResetBotWxid()
  20405. return nil
  20406. case messagerecords.FieldContactID:
  20407. m.ResetContactID()
  20408. return nil
  20409. case messagerecords.FieldContactType:
  20410. m.ResetContactType()
  20411. return nil
  20412. case messagerecords.FieldContactWxid:
  20413. m.ResetContactWxid()
  20414. return nil
  20415. case messagerecords.FieldContentType:
  20416. m.ResetContentType()
  20417. return nil
  20418. case messagerecords.FieldContent:
  20419. m.ResetContent()
  20420. return nil
  20421. case messagerecords.FieldMeta:
  20422. m.ResetMeta()
  20423. return nil
  20424. case messagerecords.FieldErrorDetail:
  20425. m.ResetErrorDetail()
  20426. return nil
  20427. case messagerecords.FieldSendTime:
  20428. m.ResetSendTime()
  20429. return nil
  20430. case messagerecords.FieldSourceType:
  20431. m.ResetSourceType()
  20432. return nil
  20433. case messagerecords.FieldSourceID:
  20434. m.ResetSourceID()
  20435. return nil
  20436. case messagerecords.FieldSubSourceID:
  20437. m.ResetSubSourceID()
  20438. return nil
  20439. case messagerecords.FieldOrganizationID:
  20440. m.ResetOrganizationID()
  20441. return nil
  20442. }
  20443. return fmt.Errorf("unknown MessageRecords field %s", name)
  20444. }
  20445. // AddedEdges returns all edge names that were set/added in this mutation.
  20446. func (m *MessageRecordsMutation) AddedEdges() []string {
  20447. edges := make([]string, 0, 3)
  20448. if m.sop_stage != nil {
  20449. edges = append(edges, messagerecords.EdgeSopStage)
  20450. }
  20451. if m.sop_node != nil {
  20452. edges = append(edges, messagerecords.EdgeSopNode)
  20453. }
  20454. if m.message_contact != nil {
  20455. edges = append(edges, messagerecords.EdgeMessageContact)
  20456. }
  20457. return edges
  20458. }
  20459. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20460. // name in this mutation.
  20461. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  20462. switch name {
  20463. case messagerecords.EdgeSopStage:
  20464. if id := m.sop_stage; id != nil {
  20465. return []ent.Value{*id}
  20466. }
  20467. case messagerecords.EdgeSopNode:
  20468. if id := m.sop_node; id != nil {
  20469. return []ent.Value{*id}
  20470. }
  20471. case messagerecords.EdgeMessageContact:
  20472. if id := m.message_contact; id != nil {
  20473. return []ent.Value{*id}
  20474. }
  20475. }
  20476. return nil
  20477. }
  20478. // RemovedEdges returns all edge names that were removed in this mutation.
  20479. func (m *MessageRecordsMutation) RemovedEdges() []string {
  20480. edges := make([]string, 0, 3)
  20481. return edges
  20482. }
  20483. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20484. // the given name in this mutation.
  20485. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  20486. return nil
  20487. }
  20488. // ClearedEdges returns all edge names that were cleared in this mutation.
  20489. func (m *MessageRecordsMutation) ClearedEdges() []string {
  20490. edges := make([]string, 0, 3)
  20491. if m.clearedsop_stage {
  20492. edges = append(edges, messagerecords.EdgeSopStage)
  20493. }
  20494. if m.clearedsop_node {
  20495. edges = append(edges, messagerecords.EdgeSopNode)
  20496. }
  20497. if m.clearedmessage_contact {
  20498. edges = append(edges, messagerecords.EdgeMessageContact)
  20499. }
  20500. return edges
  20501. }
  20502. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20503. // was cleared in this mutation.
  20504. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  20505. switch name {
  20506. case messagerecords.EdgeSopStage:
  20507. return m.clearedsop_stage
  20508. case messagerecords.EdgeSopNode:
  20509. return m.clearedsop_node
  20510. case messagerecords.EdgeMessageContact:
  20511. return m.clearedmessage_contact
  20512. }
  20513. return false
  20514. }
  20515. // ClearEdge clears the value of the edge with the given name. It returns an error
  20516. // if that edge is not defined in the schema.
  20517. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  20518. switch name {
  20519. case messagerecords.EdgeSopStage:
  20520. m.ClearSopStage()
  20521. return nil
  20522. case messagerecords.EdgeSopNode:
  20523. m.ClearSopNode()
  20524. return nil
  20525. case messagerecords.EdgeMessageContact:
  20526. m.ClearMessageContact()
  20527. return nil
  20528. }
  20529. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  20530. }
  20531. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20532. // It returns an error if the edge is not defined in the schema.
  20533. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  20534. switch name {
  20535. case messagerecords.EdgeSopStage:
  20536. m.ResetSopStage()
  20537. return nil
  20538. case messagerecords.EdgeSopNode:
  20539. m.ResetSopNode()
  20540. return nil
  20541. case messagerecords.EdgeMessageContact:
  20542. m.ResetMessageContact()
  20543. return nil
  20544. }
  20545. return fmt.Errorf("unknown MessageRecords edge %s", name)
  20546. }
  20547. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  20548. type MsgMutation struct {
  20549. config
  20550. op Op
  20551. typ string
  20552. id *uint64
  20553. created_at *time.Time
  20554. updated_at *time.Time
  20555. deleted_at *time.Time
  20556. status *uint8
  20557. addstatus *int8
  20558. fromwxid *string
  20559. toid *string
  20560. msgtype *int32
  20561. addmsgtype *int32
  20562. msg *string
  20563. batch_no *string
  20564. cc *string
  20565. phone *string
  20566. clearedFields map[string]struct{}
  20567. done bool
  20568. oldValue func(context.Context) (*Msg, error)
  20569. predicates []predicate.Msg
  20570. }
  20571. var _ ent.Mutation = (*MsgMutation)(nil)
  20572. // msgOption allows management of the mutation configuration using functional options.
  20573. type msgOption func(*MsgMutation)
  20574. // newMsgMutation creates new mutation for the Msg entity.
  20575. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  20576. m := &MsgMutation{
  20577. config: c,
  20578. op: op,
  20579. typ: TypeMsg,
  20580. clearedFields: make(map[string]struct{}),
  20581. }
  20582. for _, opt := range opts {
  20583. opt(m)
  20584. }
  20585. return m
  20586. }
  20587. // withMsgID sets the ID field of the mutation.
  20588. func withMsgID(id uint64) msgOption {
  20589. return func(m *MsgMutation) {
  20590. var (
  20591. err error
  20592. once sync.Once
  20593. value *Msg
  20594. )
  20595. m.oldValue = func(ctx context.Context) (*Msg, error) {
  20596. once.Do(func() {
  20597. if m.done {
  20598. err = errors.New("querying old values post mutation is not allowed")
  20599. } else {
  20600. value, err = m.Client().Msg.Get(ctx, id)
  20601. }
  20602. })
  20603. return value, err
  20604. }
  20605. m.id = &id
  20606. }
  20607. }
  20608. // withMsg sets the old Msg of the mutation.
  20609. func withMsg(node *Msg) msgOption {
  20610. return func(m *MsgMutation) {
  20611. m.oldValue = func(context.Context) (*Msg, error) {
  20612. return node, nil
  20613. }
  20614. m.id = &node.ID
  20615. }
  20616. }
  20617. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20618. // executed in a transaction (ent.Tx), a transactional client is returned.
  20619. func (m MsgMutation) Client() *Client {
  20620. client := &Client{config: m.config}
  20621. client.init()
  20622. return client
  20623. }
  20624. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20625. // it returns an error otherwise.
  20626. func (m MsgMutation) Tx() (*Tx, error) {
  20627. if _, ok := m.driver.(*txDriver); !ok {
  20628. return nil, errors.New("ent: mutation is not running in a transaction")
  20629. }
  20630. tx := &Tx{config: m.config}
  20631. tx.init()
  20632. return tx, nil
  20633. }
  20634. // SetID sets the value of the id field. Note that this
  20635. // operation is only accepted on creation of Msg entities.
  20636. func (m *MsgMutation) SetID(id uint64) {
  20637. m.id = &id
  20638. }
  20639. // ID returns the ID value in the mutation. Note that the ID is only available
  20640. // if it was provided to the builder or after it was returned from the database.
  20641. func (m *MsgMutation) ID() (id uint64, exists bool) {
  20642. if m.id == nil {
  20643. return
  20644. }
  20645. return *m.id, true
  20646. }
  20647. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20648. // That means, if the mutation is applied within a transaction with an isolation level such
  20649. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20650. // or updated by the mutation.
  20651. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  20652. switch {
  20653. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20654. id, exists := m.ID()
  20655. if exists {
  20656. return []uint64{id}, nil
  20657. }
  20658. fallthrough
  20659. case m.op.Is(OpUpdate | OpDelete):
  20660. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  20661. default:
  20662. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20663. }
  20664. }
  20665. // SetCreatedAt sets the "created_at" field.
  20666. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  20667. m.created_at = &t
  20668. }
  20669. // CreatedAt returns the value of the "created_at" field in the mutation.
  20670. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  20671. v := m.created_at
  20672. if v == nil {
  20673. return
  20674. }
  20675. return *v, true
  20676. }
  20677. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  20678. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20680. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20681. if !m.op.Is(OpUpdateOne) {
  20682. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20683. }
  20684. if m.id == nil || m.oldValue == nil {
  20685. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20686. }
  20687. oldValue, err := m.oldValue(ctx)
  20688. if err != nil {
  20689. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20690. }
  20691. return oldValue.CreatedAt, nil
  20692. }
  20693. // ResetCreatedAt resets all changes to the "created_at" field.
  20694. func (m *MsgMutation) ResetCreatedAt() {
  20695. m.created_at = nil
  20696. }
  20697. // SetUpdatedAt sets the "updated_at" field.
  20698. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  20699. m.updated_at = &t
  20700. }
  20701. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20702. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  20703. v := m.updated_at
  20704. if v == nil {
  20705. return
  20706. }
  20707. return *v, true
  20708. }
  20709. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  20710. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20712. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20713. if !m.op.Is(OpUpdateOne) {
  20714. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20715. }
  20716. if m.id == nil || m.oldValue == nil {
  20717. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20718. }
  20719. oldValue, err := m.oldValue(ctx)
  20720. if err != nil {
  20721. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20722. }
  20723. return oldValue.UpdatedAt, nil
  20724. }
  20725. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20726. func (m *MsgMutation) ResetUpdatedAt() {
  20727. m.updated_at = nil
  20728. }
  20729. // SetDeletedAt sets the "deleted_at" field.
  20730. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  20731. m.deleted_at = &t
  20732. }
  20733. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20734. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  20735. v := m.deleted_at
  20736. if v == nil {
  20737. return
  20738. }
  20739. return *v, true
  20740. }
  20741. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  20742. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20744. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20745. if !m.op.Is(OpUpdateOne) {
  20746. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20747. }
  20748. if m.id == nil || m.oldValue == nil {
  20749. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20750. }
  20751. oldValue, err := m.oldValue(ctx)
  20752. if err != nil {
  20753. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20754. }
  20755. return oldValue.DeletedAt, nil
  20756. }
  20757. // ClearDeletedAt clears the value of the "deleted_at" field.
  20758. func (m *MsgMutation) ClearDeletedAt() {
  20759. m.deleted_at = nil
  20760. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  20761. }
  20762. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20763. func (m *MsgMutation) DeletedAtCleared() bool {
  20764. _, ok := m.clearedFields[msg.FieldDeletedAt]
  20765. return ok
  20766. }
  20767. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20768. func (m *MsgMutation) ResetDeletedAt() {
  20769. m.deleted_at = nil
  20770. delete(m.clearedFields, msg.FieldDeletedAt)
  20771. }
  20772. // SetStatus sets the "status" field.
  20773. func (m *MsgMutation) SetStatus(u uint8) {
  20774. m.status = &u
  20775. m.addstatus = nil
  20776. }
  20777. // Status returns the value of the "status" field in the mutation.
  20778. func (m *MsgMutation) Status() (r uint8, exists bool) {
  20779. v := m.status
  20780. if v == nil {
  20781. return
  20782. }
  20783. return *v, true
  20784. }
  20785. // OldStatus returns the old "status" field's value of the Msg entity.
  20786. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20787. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20788. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20789. if !m.op.Is(OpUpdateOne) {
  20790. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20791. }
  20792. if m.id == nil || m.oldValue == nil {
  20793. return v, errors.New("OldStatus requires an ID field in the mutation")
  20794. }
  20795. oldValue, err := m.oldValue(ctx)
  20796. if err != nil {
  20797. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20798. }
  20799. return oldValue.Status, nil
  20800. }
  20801. // AddStatus adds u to the "status" field.
  20802. func (m *MsgMutation) AddStatus(u int8) {
  20803. if m.addstatus != nil {
  20804. *m.addstatus += u
  20805. } else {
  20806. m.addstatus = &u
  20807. }
  20808. }
  20809. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20810. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  20811. v := m.addstatus
  20812. if v == nil {
  20813. return
  20814. }
  20815. return *v, true
  20816. }
  20817. // ClearStatus clears the value of the "status" field.
  20818. func (m *MsgMutation) ClearStatus() {
  20819. m.status = nil
  20820. m.addstatus = nil
  20821. m.clearedFields[msg.FieldStatus] = struct{}{}
  20822. }
  20823. // StatusCleared returns if the "status" field was cleared in this mutation.
  20824. func (m *MsgMutation) StatusCleared() bool {
  20825. _, ok := m.clearedFields[msg.FieldStatus]
  20826. return ok
  20827. }
  20828. // ResetStatus resets all changes to the "status" field.
  20829. func (m *MsgMutation) ResetStatus() {
  20830. m.status = nil
  20831. m.addstatus = nil
  20832. delete(m.clearedFields, msg.FieldStatus)
  20833. }
  20834. // SetFromwxid sets the "fromwxid" field.
  20835. func (m *MsgMutation) SetFromwxid(s string) {
  20836. m.fromwxid = &s
  20837. }
  20838. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  20839. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  20840. v := m.fromwxid
  20841. if v == nil {
  20842. return
  20843. }
  20844. return *v, true
  20845. }
  20846. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  20847. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20849. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  20850. if !m.op.Is(OpUpdateOne) {
  20851. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  20852. }
  20853. if m.id == nil || m.oldValue == nil {
  20854. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  20855. }
  20856. oldValue, err := m.oldValue(ctx)
  20857. if err != nil {
  20858. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  20859. }
  20860. return oldValue.Fromwxid, nil
  20861. }
  20862. // ClearFromwxid clears the value of the "fromwxid" field.
  20863. func (m *MsgMutation) ClearFromwxid() {
  20864. m.fromwxid = nil
  20865. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  20866. }
  20867. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  20868. func (m *MsgMutation) FromwxidCleared() bool {
  20869. _, ok := m.clearedFields[msg.FieldFromwxid]
  20870. return ok
  20871. }
  20872. // ResetFromwxid resets all changes to the "fromwxid" field.
  20873. func (m *MsgMutation) ResetFromwxid() {
  20874. m.fromwxid = nil
  20875. delete(m.clearedFields, msg.FieldFromwxid)
  20876. }
  20877. // SetToid sets the "toid" field.
  20878. func (m *MsgMutation) SetToid(s string) {
  20879. m.toid = &s
  20880. }
  20881. // Toid returns the value of the "toid" field in the mutation.
  20882. func (m *MsgMutation) Toid() (r string, exists bool) {
  20883. v := m.toid
  20884. if v == nil {
  20885. return
  20886. }
  20887. return *v, true
  20888. }
  20889. // OldToid returns the old "toid" field's value of the Msg entity.
  20890. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20892. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  20893. if !m.op.Is(OpUpdateOne) {
  20894. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  20895. }
  20896. if m.id == nil || m.oldValue == nil {
  20897. return v, errors.New("OldToid requires an ID field in the mutation")
  20898. }
  20899. oldValue, err := m.oldValue(ctx)
  20900. if err != nil {
  20901. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  20902. }
  20903. return oldValue.Toid, nil
  20904. }
  20905. // ClearToid clears the value of the "toid" field.
  20906. func (m *MsgMutation) ClearToid() {
  20907. m.toid = nil
  20908. m.clearedFields[msg.FieldToid] = struct{}{}
  20909. }
  20910. // ToidCleared returns if the "toid" field was cleared in this mutation.
  20911. func (m *MsgMutation) ToidCleared() bool {
  20912. _, ok := m.clearedFields[msg.FieldToid]
  20913. return ok
  20914. }
  20915. // ResetToid resets all changes to the "toid" field.
  20916. func (m *MsgMutation) ResetToid() {
  20917. m.toid = nil
  20918. delete(m.clearedFields, msg.FieldToid)
  20919. }
  20920. // SetMsgtype sets the "msgtype" field.
  20921. func (m *MsgMutation) SetMsgtype(i int32) {
  20922. m.msgtype = &i
  20923. m.addmsgtype = nil
  20924. }
  20925. // Msgtype returns the value of the "msgtype" field in the mutation.
  20926. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  20927. v := m.msgtype
  20928. if v == nil {
  20929. return
  20930. }
  20931. return *v, true
  20932. }
  20933. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  20934. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20936. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  20937. if !m.op.Is(OpUpdateOne) {
  20938. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  20939. }
  20940. if m.id == nil || m.oldValue == nil {
  20941. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  20942. }
  20943. oldValue, err := m.oldValue(ctx)
  20944. if err != nil {
  20945. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  20946. }
  20947. return oldValue.Msgtype, nil
  20948. }
  20949. // AddMsgtype adds i to the "msgtype" field.
  20950. func (m *MsgMutation) AddMsgtype(i int32) {
  20951. if m.addmsgtype != nil {
  20952. *m.addmsgtype += i
  20953. } else {
  20954. m.addmsgtype = &i
  20955. }
  20956. }
  20957. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  20958. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  20959. v := m.addmsgtype
  20960. if v == nil {
  20961. return
  20962. }
  20963. return *v, true
  20964. }
  20965. // ClearMsgtype clears the value of the "msgtype" field.
  20966. func (m *MsgMutation) ClearMsgtype() {
  20967. m.msgtype = nil
  20968. m.addmsgtype = nil
  20969. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  20970. }
  20971. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  20972. func (m *MsgMutation) MsgtypeCleared() bool {
  20973. _, ok := m.clearedFields[msg.FieldMsgtype]
  20974. return ok
  20975. }
  20976. // ResetMsgtype resets all changes to the "msgtype" field.
  20977. func (m *MsgMutation) ResetMsgtype() {
  20978. m.msgtype = nil
  20979. m.addmsgtype = nil
  20980. delete(m.clearedFields, msg.FieldMsgtype)
  20981. }
  20982. // SetMsg sets the "msg" field.
  20983. func (m *MsgMutation) SetMsg(s string) {
  20984. m.msg = &s
  20985. }
  20986. // Msg returns the value of the "msg" field in the mutation.
  20987. func (m *MsgMutation) Msg() (r string, exists bool) {
  20988. v := m.msg
  20989. if v == nil {
  20990. return
  20991. }
  20992. return *v, true
  20993. }
  20994. // OldMsg returns the old "msg" field's value of the Msg entity.
  20995. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  20996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20997. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  20998. if !m.op.Is(OpUpdateOne) {
  20999. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  21000. }
  21001. if m.id == nil || m.oldValue == nil {
  21002. return v, errors.New("OldMsg requires an ID field in the mutation")
  21003. }
  21004. oldValue, err := m.oldValue(ctx)
  21005. if err != nil {
  21006. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  21007. }
  21008. return oldValue.Msg, nil
  21009. }
  21010. // ClearMsg clears the value of the "msg" field.
  21011. func (m *MsgMutation) ClearMsg() {
  21012. m.msg = nil
  21013. m.clearedFields[msg.FieldMsg] = struct{}{}
  21014. }
  21015. // MsgCleared returns if the "msg" field was cleared in this mutation.
  21016. func (m *MsgMutation) MsgCleared() bool {
  21017. _, ok := m.clearedFields[msg.FieldMsg]
  21018. return ok
  21019. }
  21020. // ResetMsg resets all changes to the "msg" field.
  21021. func (m *MsgMutation) ResetMsg() {
  21022. m.msg = nil
  21023. delete(m.clearedFields, msg.FieldMsg)
  21024. }
  21025. // SetBatchNo sets the "batch_no" field.
  21026. func (m *MsgMutation) SetBatchNo(s string) {
  21027. m.batch_no = &s
  21028. }
  21029. // BatchNo returns the value of the "batch_no" field in the mutation.
  21030. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  21031. v := m.batch_no
  21032. if v == nil {
  21033. return
  21034. }
  21035. return *v, true
  21036. }
  21037. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  21038. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21040. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  21041. if !m.op.Is(OpUpdateOne) {
  21042. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  21043. }
  21044. if m.id == nil || m.oldValue == nil {
  21045. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  21046. }
  21047. oldValue, err := m.oldValue(ctx)
  21048. if err != nil {
  21049. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  21050. }
  21051. return oldValue.BatchNo, nil
  21052. }
  21053. // ClearBatchNo clears the value of the "batch_no" field.
  21054. func (m *MsgMutation) ClearBatchNo() {
  21055. m.batch_no = nil
  21056. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  21057. }
  21058. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  21059. func (m *MsgMutation) BatchNoCleared() bool {
  21060. _, ok := m.clearedFields[msg.FieldBatchNo]
  21061. return ok
  21062. }
  21063. // ResetBatchNo resets all changes to the "batch_no" field.
  21064. func (m *MsgMutation) ResetBatchNo() {
  21065. m.batch_no = nil
  21066. delete(m.clearedFields, msg.FieldBatchNo)
  21067. }
  21068. // SetCc sets the "cc" field.
  21069. func (m *MsgMutation) SetCc(s string) {
  21070. m.cc = &s
  21071. }
  21072. // Cc returns the value of the "cc" field in the mutation.
  21073. func (m *MsgMutation) Cc() (r string, exists bool) {
  21074. v := m.cc
  21075. if v == nil {
  21076. return
  21077. }
  21078. return *v, true
  21079. }
  21080. // OldCc returns the old "cc" field's value of the Msg entity.
  21081. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21083. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  21084. if !m.op.Is(OpUpdateOne) {
  21085. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  21086. }
  21087. if m.id == nil || m.oldValue == nil {
  21088. return v, errors.New("OldCc requires an ID field in the mutation")
  21089. }
  21090. oldValue, err := m.oldValue(ctx)
  21091. if err != nil {
  21092. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  21093. }
  21094. return oldValue.Cc, nil
  21095. }
  21096. // ResetCc resets all changes to the "cc" field.
  21097. func (m *MsgMutation) ResetCc() {
  21098. m.cc = nil
  21099. }
  21100. // SetPhone sets the "phone" field.
  21101. func (m *MsgMutation) SetPhone(s string) {
  21102. m.phone = &s
  21103. }
  21104. // Phone returns the value of the "phone" field in the mutation.
  21105. func (m *MsgMutation) Phone() (r string, exists bool) {
  21106. v := m.phone
  21107. if v == nil {
  21108. return
  21109. }
  21110. return *v, true
  21111. }
  21112. // OldPhone returns the old "phone" field's value of the Msg entity.
  21113. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21115. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  21116. if !m.op.Is(OpUpdateOne) {
  21117. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  21118. }
  21119. if m.id == nil || m.oldValue == nil {
  21120. return v, errors.New("OldPhone requires an ID field in the mutation")
  21121. }
  21122. oldValue, err := m.oldValue(ctx)
  21123. if err != nil {
  21124. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  21125. }
  21126. return oldValue.Phone, nil
  21127. }
  21128. // ResetPhone resets all changes to the "phone" field.
  21129. func (m *MsgMutation) ResetPhone() {
  21130. m.phone = nil
  21131. }
  21132. // Where appends a list predicates to the MsgMutation builder.
  21133. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  21134. m.predicates = append(m.predicates, ps...)
  21135. }
  21136. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  21137. // users can use type-assertion to append predicates that do not depend on any generated package.
  21138. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  21139. p := make([]predicate.Msg, len(ps))
  21140. for i := range ps {
  21141. p[i] = ps[i]
  21142. }
  21143. m.Where(p...)
  21144. }
  21145. // Op returns the operation name.
  21146. func (m *MsgMutation) Op() Op {
  21147. return m.op
  21148. }
  21149. // SetOp allows setting the mutation operation.
  21150. func (m *MsgMutation) SetOp(op Op) {
  21151. m.op = op
  21152. }
  21153. // Type returns the node type of this mutation (Msg).
  21154. func (m *MsgMutation) Type() string {
  21155. return m.typ
  21156. }
  21157. // Fields returns all fields that were changed during this mutation. Note that in
  21158. // order to get all numeric fields that were incremented/decremented, call
  21159. // AddedFields().
  21160. func (m *MsgMutation) Fields() []string {
  21161. fields := make([]string, 0, 11)
  21162. if m.created_at != nil {
  21163. fields = append(fields, msg.FieldCreatedAt)
  21164. }
  21165. if m.updated_at != nil {
  21166. fields = append(fields, msg.FieldUpdatedAt)
  21167. }
  21168. if m.deleted_at != nil {
  21169. fields = append(fields, msg.FieldDeletedAt)
  21170. }
  21171. if m.status != nil {
  21172. fields = append(fields, msg.FieldStatus)
  21173. }
  21174. if m.fromwxid != nil {
  21175. fields = append(fields, msg.FieldFromwxid)
  21176. }
  21177. if m.toid != nil {
  21178. fields = append(fields, msg.FieldToid)
  21179. }
  21180. if m.msgtype != nil {
  21181. fields = append(fields, msg.FieldMsgtype)
  21182. }
  21183. if m.msg != nil {
  21184. fields = append(fields, msg.FieldMsg)
  21185. }
  21186. if m.batch_no != nil {
  21187. fields = append(fields, msg.FieldBatchNo)
  21188. }
  21189. if m.cc != nil {
  21190. fields = append(fields, msg.FieldCc)
  21191. }
  21192. if m.phone != nil {
  21193. fields = append(fields, msg.FieldPhone)
  21194. }
  21195. return fields
  21196. }
  21197. // Field returns the value of a field with the given name. The second boolean
  21198. // return value indicates that this field was not set, or was not defined in the
  21199. // schema.
  21200. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  21201. switch name {
  21202. case msg.FieldCreatedAt:
  21203. return m.CreatedAt()
  21204. case msg.FieldUpdatedAt:
  21205. return m.UpdatedAt()
  21206. case msg.FieldDeletedAt:
  21207. return m.DeletedAt()
  21208. case msg.FieldStatus:
  21209. return m.Status()
  21210. case msg.FieldFromwxid:
  21211. return m.Fromwxid()
  21212. case msg.FieldToid:
  21213. return m.Toid()
  21214. case msg.FieldMsgtype:
  21215. return m.Msgtype()
  21216. case msg.FieldMsg:
  21217. return m.Msg()
  21218. case msg.FieldBatchNo:
  21219. return m.BatchNo()
  21220. case msg.FieldCc:
  21221. return m.Cc()
  21222. case msg.FieldPhone:
  21223. return m.Phone()
  21224. }
  21225. return nil, false
  21226. }
  21227. // OldField returns the old value of the field from the database. An error is
  21228. // returned if the mutation operation is not UpdateOne, or the query to the
  21229. // database failed.
  21230. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21231. switch name {
  21232. case msg.FieldCreatedAt:
  21233. return m.OldCreatedAt(ctx)
  21234. case msg.FieldUpdatedAt:
  21235. return m.OldUpdatedAt(ctx)
  21236. case msg.FieldDeletedAt:
  21237. return m.OldDeletedAt(ctx)
  21238. case msg.FieldStatus:
  21239. return m.OldStatus(ctx)
  21240. case msg.FieldFromwxid:
  21241. return m.OldFromwxid(ctx)
  21242. case msg.FieldToid:
  21243. return m.OldToid(ctx)
  21244. case msg.FieldMsgtype:
  21245. return m.OldMsgtype(ctx)
  21246. case msg.FieldMsg:
  21247. return m.OldMsg(ctx)
  21248. case msg.FieldBatchNo:
  21249. return m.OldBatchNo(ctx)
  21250. case msg.FieldCc:
  21251. return m.OldCc(ctx)
  21252. case msg.FieldPhone:
  21253. return m.OldPhone(ctx)
  21254. }
  21255. return nil, fmt.Errorf("unknown Msg field %s", name)
  21256. }
  21257. // SetField sets the value of a field with the given name. It returns an error if
  21258. // the field is not defined in the schema, or if the type mismatched the field
  21259. // type.
  21260. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  21261. switch name {
  21262. case msg.FieldCreatedAt:
  21263. v, ok := value.(time.Time)
  21264. if !ok {
  21265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21266. }
  21267. m.SetCreatedAt(v)
  21268. return nil
  21269. case msg.FieldUpdatedAt:
  21270. v, ok := value.(time.Time)
  21271. if !ok {
  21272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21273. }
  21274. m.SetUpdatedAt(v)
  21275. return nil
  21276. case msg.FieldDeletedAt:
  21277. v, ok := value.(time.Time)
  21278. if !ok {
  21279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21280. }
  21281. m.SetDeletedAt(v)
  21282. return nil
  21283. case msg.FieldStatus:
  21284. v, ok := value.(uint8)
  21285. if !ok {
  21286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21287. }
  21288. m.SetStatus(v)
  21289. return nil
  21290. case msg.FieldFromwxid:
  21291. v, ok := value.(string)
  21292. if !ok {
  21293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21294. }
  21295. m.SetFromwxid(v)
  21296. return nil
  21297. case msg.FieldToid:
  21298. v, ok := value.(string)
  21299. if !ok {
  21300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21301. }
  21302. m.SetToid(v)
  21303. return nil
  21304. case msg.FieldMsgtype:
  21305. v, ok := value.(int32)
  21306. if !ok {
  21307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21308. }
  21309. m.SetMsgtype(v)
  21310. return nil
  21311. case msg.FieldMsg:
  21312. v, ok := value.(string)
  21313. if !ok {
  21314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21315. }
  21316. m.SetMsg(v)
  21317. return nil
  21318. case msg.FieldBatchNo:
  21319. v, ok := value.(string)
  21320. if !ok {
  21321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21322. }
  21323. m.SetBatchNo(v)
  21324. return nil
  21325. case msg.FieldCc:
  21326. v, ok := value.(string)
  21327. if !ok {
  21328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21329. }
  21330. m.SetCc(v)
  21331. return nil
  21332. case msg.FieldPhone:
  21333. v, ok := value.(string)
  21334. if !ok {
  21335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21336. }
  21337. m.SetPhone(v)
  21338. return nil
  21339. }
  21340. return fmt.Errorf("unknown Msg field %s", name)
  21341. }
  21342. // AddedFields returns all numeric fields that were incremented/decremented during
  21343. // this mutation.
  21344. func (m *MsgMutation) AddedFields() []string {
  21345. var fields []string
  21346. if m.addstatus != nil {
  21347. fields = append(fields, msg.FieldStatus)
  21348. }
  21349. if m.addmsgtype != nil {
  21350. fields = append(fields, msg.FieldMsgtype)
  21351. }
  21352. return fields
  21353. }
  21354. // AddedField returns the numeric value that was incremented/decremented on a field
  21355. // with the given name. The second boolean return value indicates that this field
  21356. // was not set, or was not defined in the schema.
  21357. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  21358. switch name {
  21359. case msg.FieldStatus:
  21360. return m.AddedStatus()
  21361. case msg.FieldMsgtype:
  21362. return m.AddedMsgtype()
  21363. }
  21364. return nil, false
  21365. }
  21366. // AddField adds the value to the field with the given name. It returns an error if
  21367. // the field is not defined in the schema, or if the type mismatched the field
  21368. // type.
  21369. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  21370. switch name {
  21371. case msg.FieldStatus:
  21372. v, ok := value.(int8)
  21373. if !ok {
  21374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21375. }
  21376. m.AddStatus(v)
  21377. return nil
  21378. case msg.FieldMsgtype:
  21379. v, ok := value.(int32)
  21380. if !ok {
  21381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21382. }
  21383. m.AddMsgtype(v)
  21384. return nil
  21385. }
  21386. return fmt.Errorf("unknown Msg numeric field %s", name)
  21387. }
  21388. // ClearedFields returns all nullable fields that were cleared during this
  21389. // mutation.
  21390. func (m *MsgMutation) ClearedFields() []string {
  21391. var fields []string
  21392. if m.FieldCleared(msg.FieldDeletedAt) {
  21393. fields = append(fields, msg.FieldDeletedAt)
  21394. }
  21395. if m.FieldCleared(msg.FieldStatus) {
  21396. fields = append(fields, msg.FieldStatus)
  21397. }
  21398. if m.FieldCleared(msg.FieldFromwxid) {
  21399. fields = append(fields, msg.FieldFromwxid)
  21400. }
  21401. if m.FieldCleared(msg.FieldToid) {
  21402. fields = append(fields, msg.FieldToid)
  21403. }
  21404. if m.FieldCleared(msg.FieldMsgtype) {
  21405. fields = append(fields, msg.FieldMsgtype)
  21406. }
  21407. if m.FieldCleared(msg.FieldMsg) {
  21408. fields = append(fields, msg.FieldMsg)
  21409. }
  21410. if m.FieldCleared(msg.FieldBatchNo) {
  21411. fields = append(fields, msg.FieldBatchNo)
  21412. }
  21413. return fields
  21414. }
  21415. // FieldCleared returns a boolean indicating if a field with the given name was
  21416. // cleared in this mutation.
  21417. func (m *MsgMutation) FieldCleared(name string) bool {
  21418. _, ok := m.clearedFields[name]
  21419. return ok
  21420. }
  21421. // ClearField clears the value of the field with the given name. It returns an
  21422. // error if the field is not defined in the schema.
  21423. func (m *MsgMutation) ClearField(name string) error {
  21424. switch name {
  21425. case msg.FieldDeletedAt:
  21426. m.ClearDeletedAt()
  21427. return nil
  21428. case msg.FieldStatus:
  21429. m.ClearStatus()
  21430. return nil
  21431. case msg.FieldFromwxid:
  21432. m.ClearFromwxid()
  21433. return nil
  21434. case msg.FieldToid:
  21435. m.ClearToid()
  21436. return nil
  21437. case msg.FieldMsgtype:
  21438. m.ClearMsgtype()
  21439. return nil
  21440. case msg.FieldMsg:
  21441. m.ClearMsg()
  21442. return nil
  21443. case msg.FieldBatchNo:
  21444. m.ClearBatchNo()
  21445. return nil
  21446. }
  21447. return fmt.Errorf("unknown Msg nullable field %s", name)
  21448. }
  21449. // ResetField resets all changes in the mutation for the field with the given name.
  21450. // It returns an error if the field is not defined in the schema.
  21451. func (m *MsgMutation) ResetField(name string) error {
  21452. switch name {
  21453. case msg.FieldCreatedAt:
  21454. m.ResetCreatedAt()
  21455. return nil
  21456. case msg.FieldUpdatedAt:
  21457. m.ResetUpdatedAt()
  21458. return nil
  21459. case msg.FieldDeletedAt:
  21460. m.ResetDeletedAt()
  21461. return nil
  21462. case msg.FieldStatus:
  21463. m.ResetStatus()
  21464. return nil
  21465. case msg.FieldFromwxid:
  21466. m.ResetFromwxid()
  21467. return nil
  21468. case msg.FieldToid:
  21469. m.ResetToid()
  21470. return nil
  21471. case msg.FieldMsgtype:
  21472. m.ResetMsgtype()
  21473. return nil
  21474. case msg.FieldMsg:
  21475. m.ResetMsg()
  21476. return nil
  21477. case msg.FieldBatchNo:
  21478. m.ResetBatchNo()
  21479. return nil
  21480. case msg.FieldCc:
  21481. m.ResetCc()
  21482. return nil
  21483. case msg.FieldPhone:
  21484. m.ResetPhone()
  21485. return nil
  21486. }
  21487. return fmt.Errorf("unknown Msg field %s", name)
  21488. }
  21489. // AddedEdges returns all edge names that were set/added in this mutation.
  21490. func (m *MsgMutation) AddedEdges() []string {
  21491. edges := make([]string, 0, 0)
  21492. return edges
  21493. }
  21494. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21495. // name in this mutation.
  21496. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  21497. return nil
  21498. }
  21499. // RemovedEdges returns all edge names that were removed in this mutation.
  21500. func (m *MsgMutation) RemovedEdges() []string {
  21501. edges := make([]string, 0, 0)
  21502. return edges
  21503. }
  21504. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21505. // the given name in this mutation.
  21506. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  21507. return nil
  21508. }
  21509. // ClearedEdges returns all edge names that were cleared in this mutation.
  21510. func (m *MsgMutation) ClearedEdges() []string {
  21511. edges := make([]string, 0, 0)
  21512. return edges
  21513. }
  21514. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21515. // was cleared in this mutation.
  21516. func (m *MsgMutation) EdgeCleared(name string) bool {
  21517. return false
  21518. }
  21519. // ClearEdge clears the value of the edge with the given name. It returns an error
  21520. // if that edge is not defined in the schema.
  21521. func (m *MsgMutation) ClearEdge(name string) error {
  21522. return fmt.Errorf("unknown Msg unique edge %s", name)
  21523. }
  21524. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21525. // It returns an error if the edge is not defined in the schema.
  21526. func (m *MsgMutation) ResetEdge(name string) error {
  21527. return fmt.Errorf("unknown Msg edge %s", name)
  21528. }
  21529. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  21530. type PayRechargeMutation struct {
  21531. config
  21532. op Op
  21533. typ string
  21534. id *uint64
  21535. created_at *time.Time
  21536. updated_at *time.Time
  21537. deleted_at *time.Time
  21538. user_id *string
  21539. number *float32
  21540. addnumber *float32
  21541. status *int
  21542. addstatus *int
  21543. money *float32
  21544. addmoney *float32
  21545. out_trade_no *string
  21546. organization_id *uint64
  21547. addorganization_id *int64
  21548. clearedFields map[string]struct{}
  21549. done bool
  21550. oldValue func(context.Context) (*PayRecharge, error)
  21551. predicates []predicate.PayRecharge
  21552. }
  21553. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  21554. // payrechargeOption allows management of the mutation configuration using functional options.
  21555. type payrechargeOption func(*PayRechargeMutation)
  21556. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  21557. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  21558. m := &PayRechargeMutation{
  21559. config: c,
  21560. op: op,
  21561. typ: TypePayRecharge,
  21562. clearedFields: make(map[string]struct{}),
  21563. }
  21564. for _, opt := range opts {
  21565. opt(m)
  21566. }
  21567. return m
  21568. }
  21569. // withPayRechargeID sets the ID field of the mutation.
  21570. func withPayRechargeID(id uint64) payrechargeOption {
  21571. return func(m *PayRechargeMutation) {
  21572. var (
  21573. err error
  21574. once sync.Once
  21575. value *PayRecharge
  21576. )
  21577. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  21578. once.Do(func() {
  21579. if m.done {
  21580. err = errors.New("querying old values post mutation is not allowed")
  21581. } else {
  21582. value, err = m.Client().PayRecharge.Get(ctx, id)
  21583. }
  21584. })
  21585. return value, err
  21586. }
  21587. m.id = &id
  21588. }
  21589. }
  21590. // withPayRecharge sets the old PayRecharge of the mutation.
  21591. func withPayRecharge(node *PayRecharge) payrechargeOption {
  21592. return func(m *PayRechargeMutation) {
  21593. m.oldValue = func(context.Context) (*PayRecharge, error) {
  21594. return node, nil
  21595. }
  21596. m.id = &node.ID
  21597. }
  21598. }
  21599. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21600. // executed in a transaction (ent.Tx), a transactional client is returned.
  21601. func (m PayRechargeMutation) Client() *Client {
  21602. client := &Client{config: m.config}
  21603. client.init()
  21604. return client
  21605. }
  21606. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21607. // it returns an error otherwise.
  21608. func (m PayRechargeMutation) Tx() (*Tx, error) {
  21609. if _, ok := m.driver.(*txDriver); !ok {
  21610. return nil, errors.New("ent: mutation is not running in a transaction")
  21611. }
  21612. tx := &Tx{config: m.config}
  21613. tx.init()
  21614. return tx, nil
  21615. }
  21616. // SetID sets the value of the id field. Note that this
  21617. // operation is only accepted on creation of PayRecharge entities.
  21618. func (m *PayRechargeMutation) SetID(id uint64) {
  21619. m.id = &id
  21620. }
  21621. // ID returns the ID value in the mutation. Note that the ID is only available
  21622. // if it was provided to the builder or after it was returned from the database.
  21623. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  21624. if m.id == nil {
  21625. return
  21626. }
  21627. return *m.id, true
  21628. }
  21629. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21630. // That means, if the mutation is applied within a transaction with an isolation level such
  21631. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21632. // or updated by the mutation.
  21633. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  21634. switch {
  21635. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21636. id, exists := m.ID()
  21637. if exists {
  21638. return []uint64{id}, nil
  21639. }
  21640. fallthrough
  21641. case m.op.Is(OpUpdate | OpDelete):
  21642. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  21643. default:
  21644. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21645. }
  21646. }
  21647. // SetCreatedAt sets the "created_at" field.
  21648. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  21649. m.created_at = &t
  21650. }
  21651. // CreatedAt returns the value of the "created_at" field in the mutation.
  21652. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  21653. v := m.created_at
  21654. if v == nil {
  21655. return
  21656. }
  21657. return *v, true
  21658. }
  21659. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  21660. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21662. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21663. if !m.op.Is(OpUpdateOne) {
  21664. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21665. }
  21666. if m.id == nil || m.oldValue == nil {
  21667. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21668. }
  21669. oldValue, err := m.oldValue(ctx)
  21670. if err != nil {
  21671. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21672. }
  21673. return oldValue.CreatedAt, nil
  21674. }
  21675. // ResetCreatedAt resets all changes to the "created_at" field.
  21676. func (m *PayRechargeMutation) ResetCreatedAt() {
  21677. m.created_at = nil
  21678. }
  21679. // SetUpdatedAt sets the "updated_at" field.
  21680. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  21681. m.updated_at = &t
  21682. }
  21683. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21684. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  21685. v := m.updated_at
  21686. if v == nil {
  21687. return
  21688. }
  21689. return *v, true
  21690. }
  21691. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  21692. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21694. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21695. if !m.op.Is(OpUpdateOne) {
  21696. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21697. }
  21698. if m.id == nil || m.oldValue == nil {
  21699. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21700. }
  21701. oldValue, err := m.oldValue(ctx)
  21702. if err != nil {
  21703. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21704. }
  21705. return oldValue.UpdatedAt, nil
  21706. }
  21707. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21708. func (m *PayRechargeMutation) ResetUpdatedAt() {
  21709. m.updated_at = nil
  21710. }
  21711. // SetDeletedAt sets the "deleted_at" field.
  21712. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  21713. m.deleted_at = &t
  21714. }
  21715. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21716. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  21717. v := m.deleted_at
  21718. if v == nil {
  21719. return
  21720. }
  21721. return *v, true
  21722. }
  21723. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  21724. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21726. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21727. if !m.op.Is(OpUpdateOne) {
  21728. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21729. }
  21730. if m.id == nil || m.oldValue == nil {
  21731. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21732. }
  21733. oldValue, err := m.oldValue(ctx)
  21734. if err != nil {
  21735. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21736. }
  21737. return oldValue.DeletedAt, nil
  21738. }
  21739. // ClearDeletedAt clears the value of the "deleted_at" field.
  21740. func (m *PayRechargeMutation) ClearDeletedAt() {
  21741. m.deleted_at = nil
  21742. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  21743. }
  21744. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21745. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  21746. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  21747. return ok
  21748. }
  21749. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21750. func (m *PayRechargeMutation) ResetDeletedAt() {
  21751. m.deleted_at = nil
  21752. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  21753. }
  21754. // SetUserID sets the "user_id" field.
  21755. func (m *PayRechargeMutation) SetUserID(s string) {
  21756. m.user_id = &s
  21757. }
  21758. // UserID returns the value of the "user_id" field in the mutation.
  21759. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  21760. v := m.user_id
  21761. if v == nil {
  21762. return
  21763. }
  21764. return *v, true
  21765. }
  21766. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  21767. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21769. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  21770. if !m.op.Is(OpUpdateOne) {
  21771. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  21772. }
  21773. if m.id == nil || m.oldValue == nil {
  21774. return v, errors.New("OldUserID requires an ID field in the mutation")
  21775. }
  21776. oldValue, err := m.oldValue(ctx)
  21777. if err != nil {
  21778. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  21779. }
  21780. return oldValue.UserID, nil
  21781. }
  21782. // ResetUserID resets all changes to the "user_id" field.
  21783. func (m *PayRechargeMutation) ResetUserID() {
  21784. m.user_id = nil
  21785. }
  21786. // SetNumber sets the "number" field.
  21787. func (m *PayRechargeMutation) SetNumber(f float32) {
  21788. m.number = &f
  21789. m.addnumber = nil
  21790. }
  21791. // Number returns the value of the "number" field in the mutation.
  21792. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  21793. v := m.number
  21794. if v == nil {
  21795. return
  21796. }
  21797. return *v, true
  21798. }
  21799. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  21800. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21802. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  21803. if !m.op.Is(OpUpdateOne) {
  21804. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  21805. }
  21806. if m.id == nil || m.oldValue == nil {
  21807. return v, errors.New("OldNumber requires an ID field in the mutation")
  21808. }
  21809. oldValue, err := m.oldValue(ctx)
  21810. if err != nil {
  21811. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  21812. }
  21813. return oldValue.Number, nil
  21814. }
  21815. // AddNumber adds f to the "number" field.
  21816. func (m *PayRechargeMutation) AddNumber(f float32) {
  21817. if m.addnumber != nil {
  21818. *m.addnumber += f
  21819. } else {
  21820. m.addnumber = &f
  21821. }
  21822. }
  21823. // AddedNumber returns the value that was added to the "number" field in this mutation.
  21824. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  21825. v := m.addnumber
  21826. if v == nil {
  21827. return
  21828. }
  21829. return *v, true
  21830. }
  21831. // ResetNumber resets all changes to the "number" field.
  21832. func (m *PayRechargeMutation) ResetNumber() {
  21833. m.number = nil
  21834. m.addnumber = nil
  21835. }
  21836. // SetStatus sets the "status" field.
  21837. func (m *PayRechargeMutation) SetStatus(i int) {
  21838. m.status = &i
  21839. m.addstatus = nil
  21840. }
  21841. // Status returns the value of the "status" field in the mutation.
  21842. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  21843. v := m.status
  21844. if v == nil {
  21845. return
  21846. }
  21847. return *v, true
  21848. }
  21849. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  21850. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21852. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  21853. if !m.op.Is(OpUpdateOne) {
  21854. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21855. }
  21856. if m.id == nil || m.oldValue == nil {
  21857. return v, errors.New("OldStatus requires an ID field in the mutation")
  21858. }
  21859. oldValue, err := m.oldValue(ctx)
  21860. if err != nil {
  21861. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21862. }
  21863. return oldValue.Status, nil
  21864. }
  21865. // AddStatus adds i to the "status" field.
  21866. func (m *PayRechargeMutation) AddStatus(i int) {
  21867. if m.addstatus != nil {
  21868. *m.addstatus += i
  21869. } else {
  21870. m.addstatus = &i
  21871. }
  21872. }
  21873. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21874. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  21875. v := m.addstatus
  21876. if v == nil {
  21877. return
  21878. }
  21879. return *v, true
  21880. }
  21881. // ClearStatus clears the value of the "status" field.
  21882. func (m *PayRechargeMutation) ClearStatus() {
  21883. m.status = nil
  21884. m.addstatus = nil
  21885. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  21886. }
  21887. // StatusCleared returns if the "status" field was cleared in this mutation.
  21888. func (m *PayRechargeMutation) StatusCleared() bool {
  21889. _, ok := m.clearedFields[payrecharge.FieldStatus]
  21890. return ok
  21891. }
  21892. // ResetStatus resets all changes to the "status" field.
  21893. func (m *PayRechargeMutation) ResetStatus() {
  21894. m.status = nil
  21895. m.addstatus = nil
  21896. delete(m.clearedFields, payrecharge.FieldStatus)
  21897. }
  21898. // SetMoney sets the "money" field.
  21899. func (m *PayRechargeMutation) SetMoney(f float32) {
  21900. m.money = &f
  21901. m.addmoney = nil
  21902. }
  21903. // Money returns the value of the "money" field in the mutation.
  21904. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  21905. v := m.money
  21906. if v == nil {
  21907. return
  21908. }
  21909. return *v, true
  21910. }
  21911. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  21912. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21914. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  21915. if !m.op.Is(OpUpdateOne) {
  21916. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  21917. }
  21918. if m.id == nil || m.oldValue == nil {
  21919. return v, errors.New("OldMoney requires an ID field in the mutation")
  21920. }
  21921. oldValue, err := m.oldValue(ctx)
  21922. if err != nil {
  21923. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  21924. }
  21925. return oldValue.Money, nil
  21926. }
  21927. // AddMoney adds f to the "money" field.
  21928. func (m *PayRechargeMutation) AddMoney(f float32) {
  21929. if m.addmoney != nil {
  21930. *m.addmoney += f
  21931. } else {
  21932. m.addmoney = &f
  21933. }
  21934. }
  21935. // AddedMoney returns the value that was added to the "money" field in this mutation.
  21936. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  21937. v := m.addmoney
  21938. if v == nil {
  21939. return
  21940. }
  21941. return *v, true
  21942. }
  21943. // ClearMoney clears the value of the "money" field.
  21944. func (m *PayRechargeMutation) ClearMoney() {
  21945. m.money = nil
  21946. m.addmoney = nil
  21947. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  21948. }
  21949. // MoneyCleared returns if the "money" field was cleared in this mutation.
  21950. func (m *PayRechargeMutation) MoneyCleared() bool {
  21951. _, ok := m.clearedFields[payrecharge.FieldMoney]
  21952. return ok
  21953. }
  21954. // ResetMoney resets all changes to the "money" field.
  21955. func (m *PayRechargeMutation) ResetMoney() {
  21956. m.money = nil
  21957. m.addmoney = nil
  21958. delete(m.clearedFields, payrecharge.FieldMoney)
  21959. }
  21960. // SetOutTradeNo sets the "out_trade_no" field.
  21961. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  21962. m.out_trade_no = &s
  21963. }
  21964. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  21965. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  21966. v := m.out_trade_no
  21967. if v == nil {
  21968. return
  21969. }
  21970. return *v, true
  21971. }
  21972. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  21973. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  21974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21975. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  21976. if !m.op.Is(OpUpdateOne) {
  21977. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  21978. }
  21979. if m.id == nil || m.oldValue == nil {
  21980. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  21981. }
  21982. oldValue, err := m.oldValue(ctx)
  21983. if err != nil {
  21984. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  21985. }
  21986. return oldValue.OutTradeNo, nil
  21987. }
  21988. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  21989. func (m *PayRechargeMutation) ClearOutTradeNo() {
  21990. m.out_trade_no = nil
  21991. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  21992. }
  21993. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  21994. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  21995. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  21996. return ok
  21997. }
  21998. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  21999. func (m *PayRechargeMutation) ResetOutTradeNo() {
  22000. m.out_trade_no = nil
  22001. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  22002. }
  22003. // SetOrganizationID sets the "organization_id" field.
  22004. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  22005. m.organization_id = &u
  22006. m.addorganization_id = nil
  22007. }
  22008. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22009. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  22010. v := m.organization_id
  22011. if v == nil {
  22012. return
  22013. }
  22014. return *v, true
  22015. }
  22016. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  22017. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22019. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22020. if !m.op.Is(OpUpdateOne) {
  22021. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22022. }
  22023. if m.id == nil || m.oldValue == nil {
  22024. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22025. }
  22026. oldValue, err := m.oldValue(ctx)
  22027. if err != nil {
  22028. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22029. }
  22030. return oldValue.OrganizationID, nil
  22031. }
  22032. // AddOrganizationID adds u to the "organization_id" field.
  22033. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  22034. if m.addorganization_id != nil {
  22035. *m.addorganization_id += u
  22036. } else {
  22037. m.addorganization_id = &u
  22038. }
  22039. }
  22040. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22041. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  22042. v := m.addorganization_id
  22043. if v == nil {
  22044. return
  22045. }
  22046. return *v, true
  22047. }
  22048. // ResetOrganizationID resets all changes to the "organization_id" field.
  22049. func (m *PayRechargeMutation) ResetOrganizationID() {
  22050. m.organization_id = nil
  22051. m.addorganization_id = nil
  22052. }
  22053. // Where appends a list predicates to the PayRechargeMutation builder.
  22054. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  22055. m.predicates = append(m.predicates, ps...)
  22056. }
  22057. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  22058. // users can use type-assertion to append predicates that do not depend on any generated package.
  22059. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  22060. p := make([]predicate.PayRecharge, len(ps))
  22061. for i := range ps {
  22062. p[i] = ps[i]
  22063. }
  22064. m.Where(p...)
  22065. }
  22066. // Op returns the operation name.
  22067. func (m *PayRechargeMutation) Op() Op {
  22068. return m.op
  22069. }
  22070. // SetOp allows setting the mutation operation.
  22071. func (m *PayRechargeMutation) SetOp(op Op) {
  22072. m.op = op
  22073. }
  22074. // Type returns the node type of this mutation (PayRecharge).
  22075. func (m *PayRechargeMutation) Type() string {
  22076. return m.typ
  22077. }
  22078. // Fields returns all fields that were changed during this mutation. Note that in
  22079. // order to get all numeric fields that were incremented/decremented, call
  22080. // AddedFields().
  22081. func (m *PayRechargeMutation) Fields() []string {
  22082. fields := make([]string, 0, 9)
  22083. if m.created_at != nil {
  22084. fields = append(fields, payrecharge.FieldCreatedAt)
  22085. }
  22086. if m.updated_at != nil {
  22087. fields = append(fields, payrecharge.FieldUpdatedAt)
  22088. }
  22089. if m.deleted_at != nil {
  22090. fields = append(fields, payrecharge.FieldDeletedAt)
  22091. }
  22092. if m.user_id != nil {
  22093. fields = append(fields, payrecharge.FieldUserID)
  22094. }
  22095. if m.number != nil {
  22096. fields = append(fields, payrecharge.FieldNumber)
  22097. }
  22098. if m.status != nil {
  22099. fields = append(fields, payrecharge.FieldStatus)
  22100. }
  22101. if m.money != nil {
  22102. fields = append(fields, payrecharge.FieldMoney)
  22103. }
  22104. if m.out_trade_no != nil {
  22105. fields = append(fields, payrecharge.FieldOutTradeNo)
  22106. }
  22107. if m.organization_id != nil {
  22108. fields = append(fields, payrecharge.FieldOrganizationID)
  22109. }
  22110. return fields
  22111. }
  22112. // Field returns the value of a field with the given name. The second boolean
  22113. // return value indicates that this field was not set, or was not defined in the
  22114. // schema.
  22115. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  22116. switch name {
  22117. case payrecharge.FieldCreatedAt:
  22118. return m.CreatedAt()
  22119. case payrecharge.FieldUpdatedAt:
  22120. return m.UpdatedAt()
  22121. case payrecharge.FieldDeletedAt:
  22122. return m.DeletedAt()
  22123. case payrecharge.FieldUserID:
  22124. return m.UserID()
  22125. case payrecharge.FieldNumber:
  22126. return m.Number()
  22127. case payrecharge.FieldStatus:
  22128. return m.Status()
  22129. case payrecharge.FieldMoney:
  22130. return m.Money()
  22131. case payrecharge.FieldOutTradeNo:
  22132. return m.OutTradeNo()
  22133. case payrecharge.FieldOrganizationID:
  22134. return m.OrganizationID()
  22135. }
  22136. return nil, false
  22137. }
  22138. // OldField returns the old value of the field from the database. An error is
  22139. // returned if the mutation operation is not UpdateOne, or the query to the
  22140. // database failed.
  22141. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22142. switch name {
  22143. case payrecharge.FieldCreatedAt:
  22144. return m.OldCreatedAt(ctx)
  22145. case payrecharge.FieldUpdatedAt:
  22146. return m.OldUpdatedAt(ctx)
  22147. case payrecharge.FieldDeletedAt:
  22148. return m.OldDeletedAt(ctx)
  22149. case payrecharge.FieldUserID:
  22150. return m.OldUserID(ctx)
  22151. case payrecharge.FieldNumber:
  22152. return m.OldNumber(ctx)
  22153. case payrecharge.FieldStatus:
  22154. return m.OldStatus(ctx)
  22155. case payrecharge.FieldMoney:
  22156. return m.OldMoney(ctx)
  22157. case payrecharge.FieldOutTradeNo:
  22158. return m.OldOutTradeNo(ctx)
  22159. case payrecharge.FieldOrganizationID:
  22160. return m.OldOrganizationID(ctx)
  22161. }
  22162. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  22163. }
  22164. // SetField sets the value of a field with the given name. It returns an error if
  22165. // the field is not defined in the schema, or if the type mismatched the field
  22166. // type.
  22167. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  22168. switch name {
  22169. case payrecharge.FieldCreatedAt:
  22170. v, ok := value.(time.Time)
  22171. if !ok {
  22172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22173. }
  22174. m.SetCreatedAt(v)
  22175. return nil
  22176. case payrecharge.FieldUpdatedAt:
  22177. v, ok := value.(time.Time)
  22178. if !ok {
  22179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22180. }
  22181. m.SetUpdatedAt(v)
  22182. return nil
  22183. case payrecharge.FieldDeletedAt:
  22184. v, ok := value.(time.Time)
  22185. if !ok {
  22186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22187. }
  22188. m.SetDeletedAt(v)
  22189. return nil
  22190. case payrecharge.FieldUserID:
  22191. v, ok := value.(string)
  22192. if !ok {
  22193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22194. }
  22195. m.SetUserID(v)
  22196. return nil
  22197. case payrecharge.FieldNumber:
  22198. v, ok := value.(float32)
  22199. if !ok {
  22200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22201. }
  22202. m.SetNumber(v)
  22203. return nil
  22204. case payrecharge.FieldStatus:
  22205. v, ok := value.(int)
  22206. if !ok {
  22207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22208. }
  22209. m.SetStatus(v)
  22210. return nil
  22211. case payrecharge.FieldMoney:
  22212. v, ok := value.(float32)
  22213. if !ok {
  22214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22215. }
  22216. m.SetMoney(v)
  22217. return nil
  22218. case payrecharge.FieldOutTradeNo:
  22219. v, ok := value.(string)
  22220. if !ok {
  22221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22222. }
  22223. m.SetOutTradeNo(v)
  22224. return nil
  22225. case payrecharge.FieldOrganizationID:
  22226. v, ok := value.(uint64)
  22227. if !ok {
  22228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22229. }
  22230. m.SetOrganizationID(v)
  22231. return nil
  22232. }
  22233. return fmt.Errorf("unknown PayRecharge field %s", name)
  22234. }
  22235. // AddedFields returns all numeric fields that were incremented/decremented during
  22236. // this mutation.
  22237. func (m *PayRechargeMutation) AddedFields() []string {
  22238. var fields []string
  22239. if m.addnumber != nil {
  22240. fields = append(fields, payrecharge.FieldNumber)
  22241. }
  22242. if m.addstatus != nil {
  22243. fields = append(fields, payrecharge.FieldStatus)
  22244. }
  22245. if m.addmoney != nil {
  22246. fields = append(fields, payrecharge.FieldMoney)
  22247. }
  22248. if m.addorganization_id != nil {
  22249. fields = append(fields, payrecharge.FieldOrganizationID)
  22250. }
  22251. return fields
  22252. }
  22253. // AddedField returns the numeric value that was incremented/decremented on a field
  22254. // with the given name. The second boolean return value indicates that this field
  22255. // was not set, or was not defined in the schema.
  22256. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  22257. switch name {
  22258. case payrecharge.FieldNumber:
  22259. return m.AddedNumber()
  22260. case payrecharge.FieldStatus:
  22261. return m.AddedStatus()
  22262. case payrecharge.FieldMoney:
  22263. return m.AddedMoney()
  22264. case payrecharge.FieldOrganizationID:
  22265. return m.AddedOrganizationID()
  22266. }
  22267. return nil, false
  22268. }
  22269. // AddField adds the value to the field with the given name. It returns an error if
  22270. // the field is not defined in the schema, or if the type mismatched the field
  22271. // type.
  22272. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  22273. switch name {
  22274. case payrecharge.FieldNumber:
  22275. v, ok := value.(float32)
  22276. if !ok {
  22277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22278. }
  22279. m.AddNumber(v)
  22280. return nil
  22281. case payrecharge.FieldStatus:
  22282. v, ok := value.(int)
  22283. if !ok {
  22284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22285. }
  22286. m.AddStatus(v)
  22287. return nil
  22288. case payrecharge.FieldMoney:
  22289. v, ok := value.(float32)
  22290. if !ok {
  22291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22292. }
  22293. m.AddMoney(v)
  22294. return nil
  22295. case payrecharge.FieldOrganizationID:
  22296. v, ok := value.(int64)
  22297. if !ok {
  22298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22299. }
  22300. m.AddOrganizationID(v)
  22301. return nil
  22302. }
  22303. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  22304. }
  22305. // ClearedFields returns all nullable fields that were cleared during this
  22306. // mutation.
  22307. func (m *PayRechargeMutation) ClearedFields() []string {
  22308. var fields []string
  22309. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  22310. fields = append(fields, payrecharge.FieldDeletedAt)
  22311. }
  22312. if m.FieldCleared(payrecharge.FieldStatus) {
  22313. fields = append(fields, payrecharge.FieldStatus)
  22314. }
  22315. if m.FieldCleared(payrecharge.FieldMoney) {
  22316. fields = append(fields, payrecharge.FieldMoney)
  22317. }
  22318. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  22319. fields = append(fields, payrecharge.FieldOutTradeNo)
  22320. }
  22321. return fields
  22322. }
  22323. // FieldCleared returns a boolean indicating if a field with the given name was
  22324. // cleared in this mutation.
  22325. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  22326. _, ok := m.clearedFields[name]
  22327. return ok
  22328. }
  22329. // ClearField clears the value of the field with the given name. It returns an
  22330. // error if the field is not defined in the schema.
  22331. func (m *PayRechargeMutation) ClearField(name string) error {
  22332. switch name {
  22333. case payrecharge.FieldDeletedAt:
  22334. m.ClearDeletedAt()
  22335. return nil
  22336. case payrecharge.FieldStatus:
  22337. m.ClearStatus()
  22338. return nil
  22339. case payrecharge.FieldMoney:
  22340. m.ClearMoney()
  22341. return nil
  22342. case payrecharge.FieldOutTradeNo:
  22343. m.ClearOutTradeNo()
  22344. return nil
  22345. }
  22346. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  22347. }
  22348. // ResetField resets all changes in the mutation for the field with the given name.
  22349. // It returns an error if the field is not defined in the schema.
  22350. func (m *PayRechargeMutation) ResetField(name string) error {
  22351. switch name {
  22352. case payrecharge.FieldCreatedAt:
  22353. m.ResetCreatedAt()
  22354. return nil
  22355. case payrecharge.FieldUpdatedAt:
  22356. m.ResetUpdatedAt()
  22357. return nil
  22358. case payrecharge.FieldDeletedAt:
  22359. m.ResetDeletedAt()
  22360. return nil
  22361. case payrecharge.FieldUserID:
  22362. m.ResetUserID()
  22363. return nil
  22364. case payrecharge.FieldNumber:
  22365. m.ResetNumber()
  22366. return nil
  22367. case payrecharge.FieldStatus:
  22368. m.ResetStatus()
  22369. return nil
  22370. case payrecharge.FieldMoney:
  22371. m.ResetMoney()
  22372. return nil
  22373. case payrecharge.FieldOutTradeNo:
  22374. m.ResetOutTradeNo()
  22375. return nil
  22376. case payrecharge.FieldOrganizationID:
  22377. m.ResetOrganizationID()
  22378. return nil
  22379. }
  22380. return fmt.Errorf("unknown PayRecharge field %s", name)
  22381. }
  22382. // AddedEdges returns all edge names that were set/added in this mutation.
  22383. func (m *PayRechargeMutation) AddedEdges() []string {
  22384. edges := make([]string, 0, 0)
  22385. return edges
  22386. }
  22387. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22388. // name in this mutation.
  22389. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  22390. return nil
  22391. }
  22392. // RemovedEdges returns all edge names that were removed in this mutation.
  22393. func (m *PayRechargeMutation) RemovedEdges() []string {
  22394. edges := make([]string, 0, 0)
  22395. return edges
  22396. }
  22397. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22398. // the given name in this mutation.
  22399. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  22400. return nil
  22401. }
  22402. // ClearedEdges returns all edge names that were cleared in this mutation.
  22403. func (m *PayRechargeMutation) ClearedEdges() []string {
  22404. edges := make([]string, 0, 0)
  22405. return edges
  22406. }
  22407. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22408. // was cleared in this mutation.
  22409. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  22410. return false
  22411. }
  22412. // ClearEdge clears the value of the edge with the given name. It returns an error
  22413. // if that edge is not defined in the schema.
  22414. func (m *PayRechargeMutation) ClearEdge(name string) error {
  22415. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  22416. }
  22417. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22418. // It returns an error if the edge is not defined in the schema.
  22419. func (m *PayRechargeMutation) ResetEdge(name string) error {
  22420. return fmt.Errorf("unknown PayRecharge edge %s", name)
  22421. }
  22422. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  22423. type ServerMutation struct {
  22424. config
  22425. op Op
  22426. typ string
  22427. id *uint64
  22428. created_at *time.Time
  22429. updated_at *time.Time
  22430. status *uint8
  22431. addstatus *int8
  22432. deleted_at *time.Time
  22433. name *string
  22434. public_ip *string
  22435. private_ip *string
  22436. admin_port *string
  22437. clearedFields map[string]struct{}
  22438. wxs map[uint64]struct{}
  22439. removedwxs map[uint64]struct{}
  22440. clearedwxs bool
  22441. done bool
  22442. oldValue func(context.Context) (*Server, error)
  22443. predicates []predicate.Server
  22444. }
  22445. var _ ent.Mutation = (*ServerMutation)(nil)
  22446. // serverOption allows management of the mutation configuration using functional options.
  22447. type serverOption func(*ServerMutation)
  22448. // newServerMutation creates new mutation for the Server entity.
  22449. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  22450. m := &ServerMutation{
  22451. config: c,
  22452. op: op,
  22453. typ: TypeServer,
  22454. clearedFields: make(map[string]struct{}),
  22455. }
  22456. for _, opt := range opts {
  22457. opt(m)
  22458. }
  22459. return m
  22460. }
  22461. // withServerID sets the ID field of the mutation.
  22462. func withServerID(id uint64) serverOption {
  22463. return func(m *ServerMutation) {
  22464. var (
  22465. err error
  22466. once sync.Once
  22467. value *Server
  22468. )
  22469. m.oldValue = func(ctx context.Context) (*Server, error) {
  22470. once.Do(func() {
  22471. if m.done {
  22472. err = errors.New("querying old values post mutation is not allowed")
  22473. } else {
  22474. value, err = m.Client().Server.Get(ctx, id)
  22475. }
  22476. })
  22477. return value, err
  22478. }
  22479. m.id = &id
  22480. }
  22481. }
  22482. // withServer sets the old Server of the mutation.
  22483. func withServer(node *Server) serverOption {
  22484. return func(m *ServerMutation) {
  22485. m.oldValue = func(context.Context) (*Server, error) {
  22486. return node, nil
  22487. }
  22488. m.id = &node.ID
  22489. }
  22490. }
  22491. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22492. // executed in a transaction (ent.Tx), a transactional client is returned.
  22493. func (m ServerMutation) Client() *Client {
  22494. client := &Client{config: m.config}
  22495. client.init()
  22496. return client
  22497. }
  22498. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22499. // it returns an error otherwise.
  22500. func (m ServerMutation) Tx() (*Tx, error) {
  22501. if _, ok := m.driver.(*txDriver); !ok {
  22502. return nil, errors.New("ent: mutation is not running in a transaction")
  22503. }
  22504. tx := &Tx{config: m.config}
  22505. tx.init()
  22506. return tx, nil
  22507. }
  22508. // SetID sets the value of the id field. Note that this
  22509. // operation is only accepted on creation of Server entities.
  22510. func (m *ServerMutation) SetID(id uint64) {
  22511. m.id = &id
  22512. }
  22513. // ID returns the ID value in the mutation. Note that the ID is only available
  22514. // if it was provided to the builder or after it was returned from the database.
  22515. func (m *ServerMutation) ID() (id uint64, exists bool) {
  22516. if m.id == nil {
  22517. return
  22518. }
  22519. return *m.id, true
  22520. }
  22521. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22522. // That means, if the mutation is applied within a transaction with an isolation level such
  22523. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22524. // or updated by the mutation.
  22525. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  22526. switch {
  22527. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22528. id, exists := m.ID()
  22529. if exists {
  22530. return []uint64{id}, nil
  22531. }
  22532. fallthrough
  22533. case m.op.Is(OpUpdate | OpDelete):
  22534. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  22535. default:
  22536. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22537. }
  22538. }
  22539. // SetCreatedAt sets the "created_at" field.
  22540. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  22541. m.created_at = &t
  22542. }
  22543. // CreatedAt returns the value of the "created_at" field in the mutation.
  22544. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  22545. v := m.created_at
  22546. if v == nil {
  22547. return
  22548. }
  22549. return *v, true
  22550. }
  22551. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  22552. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22554. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22555. if !m.op.Is(OpUpdateOne) {
  22556. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22557. }
  22558. if m.id == nil || m.oldValue == nil {
  22559. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22560. }
  22561. oldValue, err := m.oldValue(ctx)
  22562. if err != nil {
  22563. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22564. }
  22565. return oldValue.CreatedAt, nil
  22566. }
  22567. // ResetCreatedAt resets all changes to the "created_at" field.
  22568. func (m *ServerMutation) ResetCreatedAt() {
  22569. m.created_at = nil
  22570. }
  22571. // SetUpdatedAt sets the "updated_at" field.
  22572. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  22573. m.updated_at = &t
  22574. }
  22575. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22576. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  22577. v := m.updated_at
  22578. if v == nil {
  22579. return
  22580. }
  22581. return *v, true
  22582. }
  22583. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  22584. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22586. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22587. if !m.op.Is(OpUpdateOne) {
  22588. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22589. }
  22590. if m.id == nil || m.oldValue == nil {
  22591. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22592. }
  22593. oldValue, err := m.oldValue(ctx)
  22594. if err != nil {
  22595. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22596. }
  22597. return oldValue.UpdatedAt, nil
  22598. }
  22599. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22600. func (m *ServerMutation) ResetUpdatedAt() {
  22601. m.updated_at = nil
  22602. }
  22603. // SetStatus sets the "status" field.
  22604. func (m *ServerMutation) SetStatus(u uint8) {
  22605. m.status = &u
  22606. m.addstatus = nil
  22607. }
  22608. // Status returns the value of the "status" field in the mutation.
  22609. func (m *ServerMutation) Status() (r uint8, exists bool) {
  22610. v := m.status
  22611. if v == nil {
  22612. return
  22613. }
  22614. return *v, true
  22615. }
  22616. // OldStatus returns the old "status" field's value of the Server entity.
  22617. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22619. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22620. if !m.op.Is(OpUpdateOne) {
  22621. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22622. }
  22623. if m.id == nil || m.oldValue == nil {
  22624. return v, errors.New("OldStatus requires an ID field in the mutation")
  22625. }
  22626. oldValue, err := m.oldValue(ctx)
  22627. if err != nil {
  22628. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22629. }
  22630. return oldValue.Status, nil
  22631. }
  22632. // AddStatus adds u to the "status" field.
  22633. func (m *ServerMutation) AddStatus(u int8) {
  22634. if m.addstatus != nil {
  22635. *m.addstatus += u
  22636. } else {
  22637. m.addstatus = &u
  22638. }
  22639. }
  22640. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22641. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  22642. v := m.addstatus
  22643. if v == nil {
  22644. return
  22645. }
  22646. return *v, true
  22647. }
  22648. // ClearStatus clears the value of the "status" field.
  22649. func (m *ServerMutation) ClearStatus() {
  22650. m.status = nil
  22651. m.addstatus = nil
  22652. m.clearedFields[server.FieldStatus] = struct{}{}
  22653. }
  22654. // StatusCleared returns if the "status" field was cleared in this mutation.
  22655. func (m *ServerMutation) StatusCleared() bool {
  22656. _, ok := m.clearedFields[server.FieldStatus]
  22657. return ok
  22658. }
  22659. // ResetStatus resets all changes to the "status" field.
  22660. func (m *ServerMutation) ResetStatus() {
  22661. m.status = nil
  22662. m.addstatus = nil
  22663. delete(m.clearedFields, server.FieldStatus)
  22664. }
  22665. // SetDeletedAt sets the "deleted_at" field.
  22666. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  22667. m.deleted_at = &t
  22668. }
  22669. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22670. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  22671. v := m.deleted_at
  22672. if v == nil {
  22673. return
  22674. }
  22675. return *v, true
  22676. }
  22677. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  22678. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22680. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22681. if !m.op.Is(OpUpdateOne) {
  22682. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22683. }
  22684. if m.id == nil || m.oldValue == nil {
  22685. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22686. }
  22687. oldValue, err := m.oldValue(ctx)
  22688. if err != nil {
  22689. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22690. }
  22691. return oldValue.DeletedAt, nil
  22692. }
  22693. // ClearDeletedAt clears the value of the "deleted_at" field.
  22694. func (m *ServerMutation) ClearDeletedAt() {
  22695. m.deleted_at = nil
  22696. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  22697. }
  22698. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22699. func (m *ServerMutation) DeletedAtCleared() bool {
  22700. _, ok := m.clearedFields[server.FieldDeletedAt]
  22701. return ok
  22702. }
  22703. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22704. func (m *ServerMutation) ResetDeletedAt() {
  22705. m.deleted_at = nil
  22706. delete(m.clearedFields, server.FieldDeletedAt)
  22707. }
  22708. // SetName sets the "name" field.
  22709. func (m *ServerMutation) SetName(s string) {
  22710. m.name = &s
  22711. }
  22712. // Name returns the value of the "name" field in the mutation.
  22713. func (m *ServerMutation) Name() (r string, exists bool) {
  22714. v := m.name
  22715. if v == nil {
  22716. return
  22717. }
  22718. return *v, true
  22719. }
  22720. // OldName returns the old "name" field's value of the Server entity.
  22721. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22723. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  22724. if !m.op.Is(OpUpdateOne) {
  22725. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22726. }
  22727. if m.id == nil || m.oldValue == nil {
  22728. return v, errors.New("OldName requires an ID field in the mutation")
  22729. }
  22730. oldValue, err := m.oldValue(ctx)
  22731. if err != nil {
  22732. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22733. }
  22734. return oldValue.Name, nil
  22735. }
  22736. // ResetName resets all changes to the "name" field.
  22737. func (m *ServerMutation) ResetName() {
  22738. m.name = nil
  22739. }
  22740. // SetPublicIP sets the "public_ip" field.
  22741. func (m *ServerMutation) SetPublicIP(s string) {
  22742. m.public_ip = &s
  22743. }
  22744. // PublicIP returns the value of the "public_ip" field in the mutation.
  22745. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  22746. v := m.public_ip
  22747. if v == nil {
  22748. return
  22749. }
  22750. return *v, true
  22751. }
  22752. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  22753. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22755. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  22756. if !m.op.Is(OpUpdateOne) {
  22757. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  22758. }
  22759. if m.id == nil || m.oldValue == nil {
  22760. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  22761. }
  22762. oldValue, err := m.oldValue(ctx)
  22763. if err != nil {
  22764. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  22765. }
  22766. return oldValue.PublicIP, nil
  22767. }
  22768. // ResetPublicIP resets all changes to the "public_ip" field.
  22769. func (m *ServerMutation) ResetPublicIP() {
  22770. m.public_ip = nil
  22771. }
  22772. // SetPrivateIP sets the "private_ip" field.
  22773. func (m *ServerMutation) SetPrivateIP(s string) {
  22774. m.private_ip = &s
  22775. }
  22776. // PrivateIP returns the value of the "private_ip" field in the mutation.
  22777. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  22778. v := m.private_ip
  22779. if v == nil {
  22780. return
  22781. }
  22782. return *v, true
  22783. }
  22784. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  22785. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22787. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  22788. if !m.op.Is(OpUpdateOne) {
  22789. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  22790. }
  22791. if m.id == nil || m.oldValue == nil {
  22792. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  22793. }
  22794. oldValue, err := m.oldValue(ctx)
  22795. if err != nil {
  22796. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  22797. }
  22798. return oldValue.PrivateIP, nil
  22799. }
  22800. // ResetPrivateIP resets all changes to the "private_ip" field.
  22801. func (m *ServerMutation) ResetPrivateIP() {
  22802. m.private_ip = nil
  22803. }
  22804. // SetAdminPort sets the "admin_port" field.
  22805. func (m *ServerMutation) SetAdminPort(s string) {
  22806. m.admin_port = &s
  22807. }
  22808. // AdminPort returns the value of the "admin_port" field in the mutation.
  22809. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  22810. v := m.admin_port
  22811. if v == nil {
  22812. return
  22813. }
  22814. return *v, true
  22815. }
  22816. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  22817. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  22818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22819. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  22820. if !m.op.Is(OpUpdateOne) {
  22821. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  22822. }
  22823. if m.id == nil || m.oldValue == nil {
  22824. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  22825. }
  22826. oldValue, err := m.oldValue(ctx)
  22827. if err != nil {
  22828. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  22829. }
  22830. return oldValue.AdminPort, nil
  22831. }
  22832. // ResetAdminPort resets all changes to the "admin_port" field.
  22833. func (m *ServerMutation) ResetAdminPort() {
  22834. m.admin_port = nil
  22835. }
  22836. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  22837. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  22838. if m.wxs == nil {
  22839. m.wxs = make(map[uint64]struct{})
  22840. }
  22841. for i := range ids {
  22842. m.wxs[ids[i]] = struct{}{}
  22843. }
  22844. }
  22845. // ClearWxs clears the "wxs" edge to the Wx entity.
  22846. func (m *ServerMutation) ClearWxs() {
  22847. m.clearedwxs = true
  22848. }
  22849. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  22850. func (m *ServerMutation) WxsCleared() bool {
  22851. return m.clearedwxs
  22852. }
  22853. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  22854. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  22855. if m.removedwxs == nil {
  22856. m.removedwxs = make(map[uint64]struct{})
  22857. }
  22858. for i := range ids {
  22859. delete(m.wxs, ids[i])
  22860. m.removedwxs[ids[i]] = struct{}{}
  22861. }
  22862. }
  22863. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  22864. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  22865. for id := range m.removedwxs {
  22866. ids = append(ids, id)
  22867. }
  22868. return
  22869. }
  22870. // WxsIDs returns the "wxs" edge IDs in the mutation.
  22871. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  22872. for id := range m.wxs {
  22873. ids = append(ids, id)
  22874. }
  22875. return
  22876. }
  22877. // ResetWxs resets all changes to the "wxs" edge.
  22878. func (m *ServerMutation) ResetWxs() {
  22879. m.wxs = nil
  22880. m.clearedwxs = false
  22881. m.removedwxs = nil
  22882. }
  22883. // Where appends a list predicates to the ServerMutation builder.
  22884. func (m *ServerMutation) Where(ps ...predicate.Server) {
  22885. m.predicates = append(m.predicates, ps...)
  22886. }
  22887. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  22888. // users can use type-assertion to append predicates that do not depend on any generated package.
  22889. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  22890. p := make([]predicate.Server, len(ps))
  22891. for i := range ps {
  22892. p[i] = ps[i]
  22893. }
  22894. m.Where(p...)
  22895. }
  22896. // Op returns the operation name.
  22897. func (m *ServerMutation) Op() Op {
  22898. return m.op
  22899. }
  22900. // SetOp allows setting the mutation operation.
  22901. func (m *ServerMutation) SetOp(op Op) {
  22902. m.op = op
  22903. }
  22904. // Type returns the node type of this mutation (Server).
  22905. func (m *ServerMutation) Type() string {
  22906. return m.typ
  22907. }
  22908. // Fields returns all fields that were changed during this mutation. Note that in
  22909. // order to get all numeric fields that were incremented/decremented, call
  22910. // AddedFields().
  22911. func (m *ServerMutation) Fields() []string {
  22912. fields := make([]string, 0, 8)
  22913. if m.created_at != nil {
  22914. fields = append(fields, server.FieldCreatedAt)
  22915. }
  22916. if m.updated_at != nil {
  22917. fields = append(fields, server.FieldUpdatedAt)
  22918. }
  22919. if m.status != nil {
  22920. fields = append(fields, server.FieldStatus)
  22921. }
  22922. if m.deleted_at != nil {
  22923. fields = append(fields, server.FieldDeletedAt)
  22924. }
  22925. if m.name != nil {
  22926. fields = append(fields, server.FieldName)
  22927. }
  22928. if m.public_ip != nil {
  22929. fields = append(fields, server.FieldPublicIP)
  22930. }
  22931. if m.private_ip != nil {
  22932. fields = append(fields, server.FieldPrivateIP)
  22933. }
  22934. if m.admin_port != nil {
  22935. fields = append(fields, server.FieldAdminPort)
  22936. }
  22937. return fields
  22938. }
  22939. // Field returns the value of a field with the given name. The second boolean
  22940. // return value indicates that this field was not set, or was not defined in the
  22941. // schema.
  22942. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  22943. switch name {
  22944. case server.FieldCreatedAt:
  22945. return m.CreatedAt()
  22946. case server.FieldUpdatedAt:
  22947. return m.UpdatedAt()
  22948. case server.FieldStatus:
  22949. return m.Status()
  22950. case server.FieldDeletedAt:
  22951. return m.DeletedAt()
  22952. case server.FieldName:
  22953. return m.Name()
  22954. case server.FieldPublicIP:
  22955. return m.PublicIP()
  22956. case server.FieldPrivateIP:
  22957. return m.PrivateIP()
  22958. case server.FieldAdminPort:
  22959. return m.AdminPort()
  22960. }
  22961. return nil, false
  22962. }
  22963. // OldField returns the old value of the field from the database. An error is
  22964. // returned if the mutation operation is not UpdateOne, or the query to the
  22965. // database failed.
  22966. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22967. switch name {
  22968. case server.FieldCreatedAt:
  22969. return m.OldCreatedAt(ctx)
  22970. case server.FieldUpdatedAt:
  22971. return m.OldUpdatedAt(ctx)
  22972. case server.FieldStatus:
  22973. return m.OldStatus(ctx)
  22974. case server.FieldDeletedAt:
  22975. return m.OldDeletedAt(ctx)
  22976. case server.FieldName:
  22977. return m.OldName(ctx)
  22978. case server.FieldPublicIP:
  22979. return m.OldPublicIP(ctx)
  22980. case server.FieldPrivateIP:
  22981. return m.OldPrivateIP(ctx)
  22982. case server.FieldAdminPort:
  22983. return m.OldAdminPort(ctx)
  22984. }
  22985. return nil, fmt.Errorf("unknown Server field %s", name)
  22986. }
  22987. // SetField sets the value of a field with the given name. It returns an error if
  22988. // the field is not defined in the schema, or if the type mismatched the field
  22989. // type.
  22990. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  22991. switch name {
  22992. case server.FieldCreatedAt:
  22993. v, ok := value.(time.Time)
  22994. if !ok {
  22995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22996. }
  22997. m.SetCreatedAt(v)
  22998. return nil
  22999. case server.FieldUpdatedAt:
  23000. v, ok := value.(time.Time)
  23001. if !ok {
  23002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23003. }
  23004. m.SetUpdatedAt(v)
  23005. return nil
  23006. case server.FieldStatus:
  23007. v, ok := value.(uint8)
  23008. if !ok {
  23009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23010. }
  23011. m.SetStatus(v)
  23012. return nil
  23013. case server.FieldDeletedAt:
  23014. v, ok := value.(time.Time)
  23015. if !ok {
  23016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23017. }
  23018. m.SetDeletedAt(v)
  23019. return nil
  23020. case server.FieldName:
  23021. v, ok := value.(string)
  23022. if !ok {
  23023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23024. }
  23025. m.SetName(v)
  23026. return nil
  23027. case server.FieldPublicIP:
  23028. v, ok := value.(string)
  23029. if !ok {
  23030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23031. }
  23032. m.SetPublicIP(v)
  23033. return nil
  23034. case server.FieldPrivateIP:
  23035. v, ok := value.(string)
  23036. if !ok {
  23037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23038. }
  23039. m.SetPrivateIP(v)
  23040. return nil
  23041. case server.FieldAdminPort:
  23042. v, ok := value.(string)
  23043. if !ok {
  23044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23045. }
  23046. m.SetAdminPort(v)
  23047. return nil
  23048. }
  23049. return fmt.Errorf("unknown Server field %s", name)
  23050. }
  23051. // AddedFields returns all numeric fields that were incremented/decremented during
  23052. // this mutation.
  23053. func (m *ServerMutation) AddedFields() []string {
  23054. var fields []string
  23055. if m.addstatus != nil {
  23056. fields = append(fields, server.FieldStatus)
  23057. }
  23058. return fields
  23059. }
  23060. // AddedField returns the numeric value that was incremented/decremented on a field
  23061. // with the given name. The second boolean return value indicates that this field
  23062. // was not set, or was not defined in the schema.
  23063. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  23064. switch name {
  23065. case server.FieldStatus:
  23066. return m.AddedStatus()
  23067. }
  23068. return nil, false
  23069. }
  23070. // AddField adds the value to the field with the given name. It returns an error if
  23071. // the field is not defined in the schema, or if the type mismatched the field
  23072. // type.
  23073. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  23074. switch name {
  23075. case server.FieldStatus:
  23076. v, ok := value.(int8)
  23077. if !ok {
  23078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23079. }
  23080. m.AddStatus(v)
  23081. return nil
  23082. }
  23083. return fmt.Errorf("unknown Server numeric field %s", name)
  23084. }
  23085. // ClearedFields returns all nullable fields that were cleared during this
  23086. // mutation.
  23087. func (m *ServerMutation) ClearedFields() []string {
  23088. var fields []string
  23089. if m.FieldCleared(server.FieldStatus) {
  23090. fields = append(fields, server.FieldStatus)
  23091. }
  23092. if m.FieldCleared(server.FieldDeletedAt) {
  23093. fields = append(fields, server.FieldDeletedAt)
  23094. }
  23095. return fields
  23096. }
  23097. // FieldCleared returns a boolean indicating if a field with the given name was
  23098. // cleared in this mutation.
  23099. func (m *ServerMutation) FieldCleared(name string) bool {
  23100. _, ok := m.clearedFields[name]
  23101. return ok
  23102. }
  23103. // ClearField clears the value of the field with the given name. It returns an
  23104. // error if the field is not defined in the schema.
  23105. func (m *ServerMutation) ClearField(name string) error {
  23106. switch name {
  23107. case server.FieldStatus:
  23108. m.ClearStatus()
  23109. return nil
  23110. case server.FieldDeletedAt:
  23111. m.ClearDeletedAt()
  23112. return nil
  23113. }
  23114. return fmt.Errorf("unknown Server nullable field %s", name)
  23115. }
  23116. // ResetField resets all changes in the mutation for the field with the given name.
  23117. // It returns an error if the field is not defined in the schema.
  23118. func (m *ServerMutation) ResetField(name string) error {
  23119. switch name {
  23120. case server.FieldCreatedAt:
  23121. m.ResetCreatedAt()
  23122. return nil
  23123. case server.FieldUpdatedAt:
  23124. m.ResetUpdatedAt()
  23125. return nil
  23126. case server.FieldStatus:
  23127. m.ResetStatus()
  23128. return nil
  23129. case server.FieldDeletedAt:
  23130. m.ResetDeletedAt()
  23131. return nil
  23132. case server.FieldName:
  23133. m.ResetName()
  23134. return nil
  23135. case server.FieldPublicIP:
  23136. m.ResetPublicIP()
  23137. return nil
  23138. case server.FieldPrivateIP:
  23139. m.ResetPrivateIP()
  23140. return nil
  23141. case server.FieldAdminPort:
  23142. m.ResetAdminPort()
  23143. return nil
  23144. }
  23145. return fmt.Errorf("unknown Server field %s", name)
  23146. }
  23147. // AddedEdges returns all edge names that were set/added in this mutation.
  23148. func (m *ServerMutation) AddedEdges() []string {
  23149. edges := make([]string, 0, 1)
  23150. if m.wxs != nil {
  23151. edges = append(edges, server.EdgeWxs)
  23152. }
  23153. return edges
  23154. }
  23155. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23156. // name in this mutation.
  23157. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  23158. switch name {
  23159. case server.EdgeWxs:
  23160. ids := make([]ent.Value, 0, len(m.wxs))
  23161. for id := range m.wxs {
  23162. ids = append(ids, id)
  23163. }
  23164. return ids
  23165. }
  23166. return nil
  23167. }
  23168. // RemovedEdges returns all edge names that were removed in this mutation.
  23169. func (m *ServerMutation) RemovedEdges() []string {
  23170. edges := make([]string, 0, 1)
  23171. if m.removedwxs != nil {
  23172. edges = append(edges, server.EdgeWxs)
  23173. }
  23174. return edges
  23175. }
  23176. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23177. // the given name in this mutation.
  23178. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  23179. switch name {
  23180. case server.EdgeWxs:
  23181. ids := make([]ent.Value, 0, len(m.removedwxs))
  23182. for id := range m.removedwxs {
  23183. ids = append(ids, id)
  23184. }
  23185. return ids
  23186. }
  23187. return nil
  23188. }
  23189. // ClearedEdges returns all edge names that were cleared in this mutation.
  23190. func (m *ServerMutation) ClearedEdges() []string {
  23191. edges := make([]string, 0, 1)
  23192. if m.clearedwxs {
  23193. edges = append(edges, server.EdgeWxs)
  23194. }
  23195. return edges
  23196. }
  23197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23198. // was cleared in this mutation.
  23199. func (m *ServerMutation) EdgeCleared(name string) bool {
  23200. switch name {
  23201. case server.EdgeWxs:
  23202. return m.clearedwxs
  23203. }
  23204. return false
  23205. }
  23206. // ClearEdge clears the value of the edge with the given name. It returns an error
  23207. // if that edge is not defined in the schema.
  23208. func (m *ServerMutation) ClearEdge(name string) error {
  23209. switch name {
  23210. }
  23211. return fmt.Errorf("unknown Server unique edge %s", name)
  23212. }
  23213. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23214. // It returns an error if the edge is not defined in the schema.
  23215. func (m *ServerMutation) ResetEdge(name string) error {
  23216. switch name {
  23217. case server.EdgeWxs:
  23218. m.ResetWxs()
  23219. return nil
  23220. }
  23221. return fmt.Errorf("unknown Server edge %s", name)
  23222. }
  23223. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  23224. type SopNodeMutation struct {
  23225. config
  23226. op Op
  23227. typ string
  23228. id *uint64
  23229. created_at *time.Time
  23230. updated_at *time.Time
  23231. status *uint8
  23232. addstatus *int8
  23233. deleted_at *time.Time
  23234. parent_id *uint64
  23235. addparent_id *int64
  23236. name *string
  23237. condition_type *int
  23238. addcondition_type *int
  23239. condition_list *[]string
  23240. appendcondition_list []string
  23241. no_reply_condition *uint64
  23242. addno_reply_condition *int64
  23243. no_reply_unit *string
  23244. action_message *[]custom_types.Action
  23245. appendaction_message []custom_types.Action
  23246. action_label_add *[]uint64
  23247. appendaction_label_add []uint64
  23248. action_label_del *[]uint64
  23249. appendaction_label_del []uint64
  23250. action_forward **custom_types.ActionForward
  23251. clearedFields map[string]struct{}
  23252. sop_stage *uint64
  23253. clearedsop_stage bool
  23254. node_messages map[uint64]struct{}
  23255. removednode_messages map[uint64]struct{}
  23256. clearednode_messages bool
  23257. done bool
  23258. oldValue func(context.Context) (*SopNode, error)
  23259. predicates []predicate.SopNode
  23260. }
  23261. var _ ent.Mutation = (*SopNodeMutation)(nil)
  23262. // sopnodeOption allows management of the mutation configuration using functional options.
  23263. type sopnodeOption func(*SopNodeMutation)
  23264. // newSopNodeMutation creates new mutation for the SopNode entity.
  23265. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  23266. m := &SopNodeMutation{
  23267. config: c,
  23268. op: op,
  23269. typ: TypeSopNode,
  23270. clearedFields: make(map[string]struct{}),
  23271. }
  23272. for _, opt := range opts {
  23273. opt(m)
  23274. }
  23275. return m
  23276. }
  23277. // withSopNodeID sets the ID field of the mutation.
  23278. func withSopNodeID(id uint64) sopnodeOption {
  23279. return func(m *SopNodeMutation) {
  23280. var (
  23281. err error
  23282. once sync.Once
  23283. value *SopNode
  23284. )
  23285. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  23286. once.Do(func() {
  23287. if m.done {
  23288. err = errors.New("querying old values post mutation is not allowed")
  23289. } else {
  23290. value, err = m.Client().SopNode.Get(ctx, id)
  23291. }
  23292. })
  23293. return value, err
  23294. }
  23295. m.id = &id
  23296. }
  23297. }
  23298. // withSopNode sets the old SopNode of the mutation.
  23299. func withSopNode(node *SopNode) sopnodeOption {
  23300. return func(m *SopNodeMutation) {
  23301. m.oldValue = func(context.Context) (*SopNode, error) {
  23302. return node, nil
  23303. }
  23304. m.id = &node.ID
  23305. }
  23306. }
  23307. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23308. // executed in a transaction (ent.Tx), a transactional client is returned.
  23309. func (m SopNodeMutation) Client() *Client {
  23310. client := &Client{config: m.config}
  23311. client.init()
  23312. return client
  23313. }
  23314. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23315. // it returns an error otherwise.
  23316. func (m SopNodeMutation) Tx() (*Tx, error) {
  23317. if _, ok := m.driver.(*txDriver); !ok {
  23318. return nil, errors.New("ent: mutation is not running in a transaction")
  23319. }
  23320. tx := &Tx{config: m.config}
  23321. tx.init()
  23322. return tx, nil
  23323. }
  23324. // SetID sets the value of the id field. Note that this
  23325. // operation is only accepted on creation of SopNode entities.
  23326. func (m *SopNodeMutation) SetID(id uint64) {
  23327. m.id = &id
  23328. }
  23329. // ID returns the ID value in the mutation. Note that the ID is only available
  23330. // if it was provided to the builder or after it was returned from the database.
  23331. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  23332. if m.id == nil {
  23333. return
  23334. }
  23335. return *m.id, true
  23336. }
  23337. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23338. // That means, if the mutation is applied within a transaction with an isolation level such
  23339. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23340. // or updated by the mutation.
  23341. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  23342. switch {
  23343. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23344. id, exists := m.ID()
  23345. if exists {
  23346. return []uint64{id}, nil
  23347. }
  23348. fallthrough
  23349. case m.op.Is(OpUpdate | OpDelete):
  23350. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  23351. default:
  23352. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23353. }
  23354. }
  23355. // SetCreatedAt sets the "created_at" field.
  23356. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  23357. m.created_at = &t
  23358. }
  23359. // CreatedAt returns the value of the "created_at" field in the mutation.
  23360. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  23361. v := m.created_at
  23362. if v == nil {
  23363. return
  23364. }
  23365. return *v, true
  23366. }
  23367. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  23368. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23370. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23371. if !m.op.Is(OpUpdateOne) {
  23372. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23373. }
  23374. if m.id == nil || m.oldValue == nil {
  23375. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23376. }
  23377. oldValue, err := m.oldValue(ctx)
  23378. if err != nil {
  23379. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23380. }
  23381. return oldValue.CreatedAt, nil
  23382. }
  23383. // ResetCreatedAt resets all changes to the "created_at" field.
  23384. func (m *SopNodeMutation) ResetCreatedAt() {
  23385. m.created_at = nil
  23386. }
  23387. // SetUpdatedAt sets the "updated_at" field.
  23388. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  23389. m.updated_at = &t
  23390. }
  23391. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23392. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  23393. v := m.updated_at
  23394. if v == nil {
  23395. return
  23396. }
  23397. return *v, true
  23398. }
  23399. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  23400. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23402. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23403. if !m.op.Is(OpUpdateOne) {
  23404. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23405. }
  23406. if m.id == nil || m.oldValue == nil {
  23407. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23408. }
  23409. oldValue, err := m.oldValue(ctx)
  23410. if err != nil {
  23411. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23412. }
  23413. return oldValue.UpdatedAt, nil
  23414. }
  23415. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23416. func (m *SopNodeMutation) ResetUpdatedAt() {
  23417. m.updated_at = nil
  23418. }
  23419. // SetStatus sets the "status" field.
  23420. func (m *SopNodeMutation) SetStatus(u uint8) {
  23421. m.status = &u
  23422. m.addstatus = nil
  23423. }
  23424. // Status returns the value of the "status" field in the mutation.
  23425. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  23426. v := m.status
  23427. if v == nil {
  23428. return
  23429. }
  23430. return *v, true
  23431. }
  23432. // OldStatus returns the old "status" field's value of the SopNode entity.
  23433. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23435. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23436. if !m.op.Is(OpUpdateOne) {
  23437. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23438. }
  23439. if m.id == nil || m.oldValue == nil {
  23440. return v, errors.New("OldStatus requires an ID field in the mutation")
  23441. }
  23442. oldValue, err := m.oldValue(ctx)
  23443. if err != nil {
  23444. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23445. }
  23446. return oldValue.Status, nil
  23447. }
  23448. // AddStatus adds u to the "status" field.
  23449. func (m *SopNodeMutation) AddStatus(u int8) {
  23450. if m.addstatus != nil {
  23451. *m.addstatus += u
  23452. } else {
  23453. m.addstatus = &u
  23454. }
  23455. }
  23456. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23457. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  23458. v := m.addstatus
  23459. if v == nil {
  23460. return
  23461. }
  23462. return *v, true
  23463. }
  23464. // ClearStatus clears the value of the "status" field.
  23465. func (m *SopNodeMutation) ClearStatus() {
  23466. m.status = nil
  23467. m.addstatus = nil
  23468. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  23469. }
  23470. // StatusCleared returns if the "status" field was cleared in this mutation.
  23471. func (m *SopNodeMutation) StatusCleared() bool {
  23472. _, ok := m.clearedFields[sopnode.FieldStatus]
  23473. return ok
  23474. }
  23475. // ResetStatus resets all changes to the "status" field.
  23476. func (m *SopNodeMutation) ResetStatus() {
  23477. m.status = nil
  23478. m.addstatus = nil
  23479. delete(m.clearedFields, sopnode.FieldStatus)
  23480. }
  23481. // SetDeletedAt sets the "deleted_at" field.
  23482. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  23483. m.deleted_at = &t
  23484. }
  23485. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23486. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  23487. v := m.deleted_at
  23488. if v == nil {
  23489. return
  23490. }
  23491. return *v, true
  23492. }
  23493. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  23494. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23496. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23497. if !m.op.Is(OpUpdateOne) {
  23498. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23499. }
  23500. if m.id == nil || m.oldValue == nil {
  23501. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23502. }
  23503. oldValue, err := m.oldValue(ctx)
  23504. if err != nil {
  23505. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23506. }
  23507. return oldValue.DeletedAt, nil
  23508. }
  23509. // ClearDeletedAt clears the value of the "deleted_at" field.
  23510. func (m *SopNodeMutation) ClearDeletedAt() {
  23511. m.deleted_at = nil
  23512. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  23513. }
  23514. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23515. func (m *SopNodeMutation) DeletedAtCleared() bool {
  23516. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  23517. return ok
  23518. }
  23519. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23520. func (m *SopNodeMutation) ResetDeletedAt() {
  23521. m.deleted_at = nil
  23522. delete(m.clearedFields, sopnode.FieldDeletedAt)
  23523. }
  23524. // SetStageID sets the "stage_id" field.
  23525. func (m *SopNodeMutation) SetStageID(u uint64) {
  23526. m.sop_stage = &u
  23527. }
  23528. // StageID returns the value of the "stage_id" field in the mutation.
  23529. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  23530. v := m.sop_stage
  23531. if v == nil {
  23532. return
  23533. }
  23534. return *v, true
  23535. }
  23536. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  23537. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23538. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23539. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  23540. if !m.op.Is(OpUpdateOne) {
  23541. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  23542. }
  23543. if m.id == nil || m.oldValue == nil {
  23544. return v, errors.New("OldStageID requires an ID field in the mutation")
  23545. }
  23546. oldValue, err := m.oldValue(ctx)
  23547. if err != nil {
  23548. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  23549. }
  23550. return oldValue.StageID, nil
  23551. }
  23552. // ResetStageID resets all changes to the "stage_id" field.
  23553. func (m *SopNodeMutation) ResetStageID() {
  23554. m.sop_stage = nil
  23555. }
  23556. // SetParentID sets the "parent_id" field.
  23557. func (m *SopNodeMutation) SetParentID(u uint64) {
  23558. m.parent_id = &u
  23559. m.addparent_id = nil
  23560. }
  23561. // ParentID returns the value of the "parent_id" field in the mutation.
  23562. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  23563. v := m.parent_id
  23564. if v == nil {
  23565. return
  23566. }
  23567. return *v, true
  23568. }
  23569. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  23570. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23572. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  23573. if !m.op.Is(OpUpdateOne) {
  23574. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  23575. }
  23576. if m.id == nil || m.oldValue == nil {
  23577. return v, errors.New("OldParentID requires an ID field in the mutation")
  23578. }
  23579. oldValue, err := m.oldValue(ctx)
  23580. if err != nil {
  23581. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  23582. }
  23583. return oldValue.ParentID, nil
  23584. }
  23585. // AddParentID adds u to the "parent_id" field.
  23586. func (m *SopNodeMutation) AddParentID(u int64) {
  23587. if m.addparent_id != nil {
  23588. *m.addparent_id += u
  23589. } else {
  23590. m.addparent_id = &u
  23591. }
  23592. }
  23593. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  23594. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  23595. v := m.addparent_id
  23596. if v == nil {
  23597. return
  23598. }
  23599. return *v, true
  23600. }
  23601. // ResetParentID resets all changes to the "parent_id" field.
  23602. func (m *SopNodeMutation) ResetParentID() {
  23603. m.parent_id = nil
  23604. m.addparent_id = nil
  23605. }
  23606. // SetName sets the "name" field.
  23607. func (m *SopNodeMutation) SetName(s string) {
  23608. m.name = &s
  23609. }
  23610. // Name returns the value of the "name" field in the mutation.
  23611. func (m *SopNodeMutation) Name() (r string, exists bool) {
  23612. v := m.name
  23613. if v == nil {
  23614. return
  23615. }
  23616. return *v, true
  23617. }
  23618. // OldName returns the old "name" field's value of the SopNode entity.
  23619. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23621. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  23622. if !m.op.Is(OpUpdateOne) {
  23623. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23624. }
  23625. if m.id == nil || m.oldValue == nil {
  23626. return v, errors.New("OldName requires an ID field in the mutation")
  23627. }
  23628. oldValue, err := m.oldValue(ctx)
  23629. if err != nil {
  23630. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23631. }
  23632. return oldValue.Name, nil
  23633. }
  23634. // ResetName resets all changes to the "name" field.
  23635. func (m *SopNodeMutation) ResetName() {
  23636. m.name = nil
  23637. }
  23638. // SetConditionType sets the "condition_type" field.
  23639. func (m *SopNodeMutation) SetConditionType(i int) {
  23640. m.condition_type = &i
  23641. m.addcondition_type = nil
  23642. }
  23643. // ConditionType returns the value of the "condition_type" field in the mutation.
  23644. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  23645. v := m.condition_type
  23646. if v == nil {
  23647. return
  23648. }
  23649. return *v, true
  23650. }
  23651. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  23652. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23654. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  23655. if !m.op.Is(OpUpdateOne) {
  23656. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  23657. }
  23658. if m.id == nil || m.oldValue == nil {
  23659. return v, errors.New("OldConditionType requires an ID field in the mutation")
  23660. }
  23661. oldValue, err := m.oldValue(ctx)
  23662. if err != nil {
  23663. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  23664. }
  23665. return oldValue.ConditionType, nil
  23666. }
  23667. // AddConditionType adds i to the "condition_type" field.
  23668. func (m *SopNodeMutation) AddConditionType(i int) {
  23669. if m.addcondition_type != nil {
  23670. *m.addcondition_type += i
  23671. } else {
  23672. m.addcondition_type = &i
  23673. }
  23674. }
  23675. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  23676. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  23677. v := m.addcondition_type
  23678. if v == nil {
  23679. return
  23680. }
  23681. return *v, true
  23682. }
  23683. // ResetConditionType resets all changes to the "condition_type" field.
  23684. func (m *SopNodeMutation) ResetConditionType() {
  23685. m.condition_type = nil
  23686. m.addcondition_type = nil
  23687. }
  23688. // SetConditionList sets the "condition_list" field.
  23689. func (m *SopNodeMutation) SetConditionList(s []string) {
  23690. m.condition_list = &s
  23691. m.appendcondition_list = nil
  23692. }
  23693. // ConditionList returns the value of the "condition_list" field in the mutation.
  23694. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  23695. v := m.condition_list
  23696. if v == nil {
  23697. return
  23698. }
  23699. return *v, true
  23700. }
  23701. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  23702. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23704. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  23705. if !m.op.Is(OpUpdateOne) {
  23706. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  23707. }
  23708. if m.id == nil || m.oldValue == nil {
  23709. return v, errors.New("OldConditionList requires an ID field in the mutation")
  23710. }
  23711. oldValue, err := m.oldValue(ctx)
  23712. if err != nil {
  23713. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  23714. }
  23715. return oldValue.ConditionList, nil
  23716. }
  23717. // AppendConditionList adds s to the "condition_list" field.
  23718. func (m *SopNodeMutation) AppendConditionList(s []string) {
  23719. m.appendcondition_list = append(m.appendcondition_list, s...)
  23720. }
  23721. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  23722. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  23723. if len(m.appendcondition_list) == 0 {
  23724. return nil, false
  23725. }
  23726. return m.appendcondition_list, true
  23727. }
  23728. // ClearConditionList clears the value of the "condition_list" field.
  23729. func (m *SopNodeMutation) ClearConditionList() {
  23730. m.condition_list = nil
  23731. m.appendcondition_list = nil
  23732. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  23733. }
  23734. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  23735. func (m *SopNodeMutation) ConditionListCleared() bool {
  23736. _, ok := m.clearedFields[sopnode.FieldConditionList]
  23737. return ok
  23738. }
  23739. // ResetConditionList resets all changes to the "condition_list" field.
  23740. func (m *SopNodeMutation) ResetConditionList() {
  23741. m.condition_list = nil
  23742. m.appendcondition_list = nil
  23743. delete(m.clearedFields, sopnode.FieldConditionList)
  23744. }
  23745. // SetNoReplyCondition sets the "no_reply_condition" field.
  23746. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  23747. m.no_reply_condition = &u
  23748. m.addno_reply_condition = nil
  23749. }
  23750. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  23751. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  23752. v := m.no_reply_condition
  23753. if v == nil {
  23754. return
  23755. }
  23756. return *v, true
  23757. }
  23758. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  23759. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23761. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  23762. if !m.op.Is(OpUpdateOne) {
  23763. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  23764. }
  23765. if m.id == nil || m.oldValue == nil {
  23766. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  23767. }
  23768. oldValue, err := m.oldValue(ctx)
  23769. if err != nil {
  23770. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  23771. }
  23772. return oldValue.NoReplyCondition, nil
  23773. }
  23774. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  23775. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  23776. if m.addno_reply_condition != nil {
  23777. *m.addno_reply_condition += u
  23778. } else {
  23779. m.addno_reply_condition = &u
  23780. }
  23781. }
  23782. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  23783. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  23784. v := m.addno_reply_condition
  23785. if v == nil {
  23786. return
  23787. }
  23788. return *v, true
  23789. }
  23790. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  23791. func (m *SopNodeMutation) ResetNoReplyCondition() {
  23792. m.no_reply_condition = nil
  23793. m.addno_reply_condition = nil
  23794. }
  23795. // SetNoReplyUnit sets the "no_reply_unit" field.
  23796. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  23797. m.no_reply_unit = &s
  23798. }
  23799. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  23800. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  23801. v := m.no_reply_unit
  23802. if v == nil {
  23803. return
  23804. }
  23805. return *v, true
  23806. }
  23807. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  23808. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23810. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  23811. if !m.op.Is(OpUpdateOne) {
  23812. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  23813. }
  23814. if m.id == nil || m.oldValue == nil {
  23815. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  23816. }
  23817. oldValue, err := m.oldValue(ctx)
  23818. if err != nil {
  23819. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  23820. }
  23821. return oldValue.NoReplyUnit, nil
  23822. }
  23823. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  23824. func (m *SopNodeMutation) ResetNoReplyUnit() {
  23825. m.no_reply_unit = nil
  23826. }
  23827. // SetActionMessage sets the "action_message" field.
  23828. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  23829. m.action_message = &ct
  23830. m.appendaction_message = nil
  23831. }
  23832. // ActionMessage returns the value of the "action_message" field in the mutation.
  23833. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  23834. v := m.action_message
  23835. if v == nil {
  23836. return
  23837. }
  23838. return *v, true
  23839. }
  23840. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  23841. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23843. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  23844. if !m.op.Is(OpUpdateOne) {
  23845. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  23846. }
  23847. if m.id == nil || m.oldValue == nil {
  23848. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  23849. }
  23850. oldValue, err := m.oldValue(ctx)
  23851. if err != nil {
  23852. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  23853. }
  23854. return oldValue.ActionMessage, nil
  23855. }
  23856. // AppendActionMessage adds ct to the "action_message" field.
  23857. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  23858. m.appendaction_message = append(m.appendaction_message, ct...)
  23859. }
  23860. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  23861. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  23862. if len(m.appendaction_message) == 0 {
  23863. return nil, false
  23864. }
  23865. return m.appendaction_message, true
  23866. }
  23867. // ClearActionMessage clears the value of the "action_message" field.
  23868. func (m *SopNodeMutation) ClearActionMessage() {
  23869. m.action_message = nil
  23870. m.appendaction_message = nil
  23871. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  23872. }
  23873. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  23874. func (m *SopNodeMutation) ActionMessageCleared() bool {
  23875. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  23876. return ok
  23877. }
  23878. // ResetActionMessage resets all changes to the "action_message" field.
  23879. func (m *SopNodeMutation) ResetActionMessage() {
  23880. m.action_message = nil
  23881. m.appendaction_message = nil
  23882. delete(m.clearedFields, sopnode.FieldActionMessage)
  23883. }
  23884. // SetActionLabelAdd sets the "action_label_add" field.
  23885. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  23886. m.action_label_add = &u
  23887. m.appendaction_label_add = nil
  23888. }
  23889. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23890. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23891. v := m.action_label_add
  23892. if v == nil {
  23893. return
  23894. }
  23895. return *v, true
  23896. }
  23897. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  23898. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23900. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23901. if !m.op.Is(OpUpdateOne) {
  23902. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23903. }
  23904. if m.id == nil || m.oldValue == nil {
  23905. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23906. }
  23907. oldValue, err := m.oldValue(ctx)
  23908. if err != nil {
  23909. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23910. }
  23911. return oldValue.ActionLabelAdd, nil
  23912. }
  23913. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23914. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  23915. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23916. }
  23917. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23918. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23919. if len(m.appendaction_label_add) == 0 {
  23920. return nil, false
  23921. }
  23922. return m.appendaction_label_add, true
  23923. }
  23924. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23925. func (m *SopNodeMutation) ClearActionLabelAdd() {
  23926. m.action_label_add = nil
  23927. m.appendaction_label_add = nil
  23928. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  23929. }
  23930. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23931. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  23932. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  23933. return ok
  23934. }
  23935. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23936. func (m *SopNodeMutation) ResetActionLabelAdd() {
  23937. m.action_label_add = nil
  23938. m.appendaction_label_add = nil
  23939. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  23940. }
  23941. // SetActionLabelDel sets the "action_label_del" field.
  23942. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  23943. m.action_label_del = &u
  23944. m.appendaction_label_del = nil
  23945. }
  23946. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23947. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  23948. v := m.action_label_del
  23949. if v == nil {
  23950. return
  23951. }
  23952. return *v, true
  23953. }
  23954. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  23955. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  23956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23957. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23958. if !m.op.Is(OpUpdateOne) {
  23959. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23960. }
  23961. if m.id == nil || m.oldValue == nil {
  23962. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23963. }
  23964. oldValue, err := m.oldValue(ctx)
  23965. if err != nil {
  23966. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23967. }
  23968. return oldValue.ActionLabelDel, nil
  23969. }
  23970. // AppendActionLabelDel adds u to the "action_label_del" field.
  23971. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  23972. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23973. }
  23974. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23975. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23976. if len(m.appendaction_label_del) == 0 {
  23977. return nil, false
  23978. }
  23979. return m.appendaction_label_del, true
  23980. }
  23981. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23982. func (m *SopNodeMutation) ClearActionLabelDel() {
  23983. m.action_label_del = nil
  23984. m.appendaction_label_del = nil
  23985. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  23986. }
  23987. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23988. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  23989. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  23990. return ok
  23991. }
  23992. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23993. func (m *SopNodeMutation) ResetActionLabelDel() {
  23994. m.action_label_del = nil
  23995. m.appendaction_label_del = nil
  23996. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  23997. }
  23998. // SetActionForward sets the "action_forward" field.
  23999. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  24000. m.action_forward = &ctf
  24001. }
  24002. // ActionForward returns the value of the "action_forward" field in the mutation.
  24003. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  24004. v := m.action_forward
  24005. if v == nil {
  24006. return
  24007. }
  24008. return *v, true
  24009. }
  24010. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  24011. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24013. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  24014. if !m.op.Is(OpUpdateOne) {
  24015. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  24016. }
  24017. if m.id == nil || m.oldValue == nil {
  24018. return v, errors.New("OldActionForward requires an ID field in the mutation")
  24019. }
  24020. oldValue, err := m.oldValue(ctx)
  24021. if err != nil {
  24022. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  24023. }
  24024. return oldValue.ActionForward, nil
  24025. }
  24026. // ClearActionForward clears the value of the "action_forward" field.
  24027. func (m *SopNodeMutation) ClearActionForward() {
  24028. m.action_forward = nil
  24029. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  24030. }
  24031. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  24032. func (m *SopNodeMutation) ActionForwardCleared() bool {
  24033. _, ok := m.clearedFields[sopnode.FieldActionForward]
  24034. return ok
  24035. }
  24036. // ResetActionForward resets all changes to the "action_forward" field.
  24037. func (m *SopNodeMutation) ResetActionForward() {
  24038. m.action_forward = nil
  24039. delete(m.clearedFields, sopnode.FieldActionForward)
  24040. }
  24041. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  24042. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  24043. m.sop_stage = &id
  24044. }
  24045. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  24046. func (m *SopNodeMutation) ClearSopStage() {
  24047. m.clearedsop_stage = true
  24048. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  24049. }
  24050. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  24051. func (m *SopNodeMutation) SopStageCleared() bool {
  24052. return m.clearedsop_stage
  24053. }
  24054. // SopStageID returns the "sop_stage" edge ID in the mutation.
  24055. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  24056. if m.sop_stage != nil {
  24057. return *m.sop_stage, true
  24058. }
  24059. return
  24060. }
  24061. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  24062. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24063. // SopStageID instead. It exists only for internal usage by the builders.
  24064. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  24065. if id := m.sop_stage; id != nil {
  24066. ids = append(ids, *id)
  24067. }
  24068. return
  24069. }
  24070. // ResetSopStage resets all changes to the "sop_stage" edge.
  24071. func (m *SopNodeMutation) ResetSopStage() {
  24072. m.sop_stage = nil
  24073. m.clearedsop_stage = false
  24074. }
  24075. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  24076. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  24077. if m.node_messages == nil {
  24078. m.node_messages = make(map[uint64]struct{})
  24079. }
  24080. for i := range ids {
  24081. m.node_messages[ids[i]] = struct{}{}
  24082. }
  24083. }
  24084. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  24085. func (m *SopNodeMutation) ClearNodeMessages() {
  24086. m.clearednode_messages = true
  24087. }
  24088. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  24089. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  24090. return m.clearednode_messages
  24091. }
  24092. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  24093. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  24094. if m.removednode_messages == nil {
  24095. m.removednode_messages = make(map[uint64]struct{})
  24096. }
  24097. for i := range ids {
  24098. delete(m.node_messages, ids[i])
  24099. m.removednode_messages[ids[i]] = struct{}{}
  24100. }
  24101. }
  24102. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  24103. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  24104. for id := range m.removednode_messages {
  24105. ids = append(ids, id)
  24106. }
  24107. return
  24108. }
  24109. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  24110. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  24111. for id := range m.node_messages {
  24112. ids = append(ids, id)
  24113. }
  24114. return
  24115. }
  24116. // ResetNodeMessages resets all changes to the "node_messages" edge.
  24117. func (m *SopNodeMutation) ResetNodeMessages() {
  24118. m.node_messages = nil
  24119. m.clearednode_messages = false
  24120. m.removednode_messages = nil
  24121. }
  24122. // Where appends a list predicates to the SopNodeMutation builder.
  24123. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  24124. m.predicates = append(m.predicates, ps...)
  24125. }
  24126. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  24127. // users can use type-assertion to append predicates that do not depend on any generated package.
  24128. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  24129. p := make([]predicate.SopNode, len(ps))
  24130. for i := range ps {
  24131. p[i] = ps[i]
  24132. }
  24133. m.Where(p...)
  24134. }
  24135. // Op returns the operation name.
  24136. func (m *SopNodeMutation) Op() Op {
  24137. return m.op
  24138. }
  24139. // SetOp allows setting the mutation operation.
  24140. func (m *SopNodeMutation) SetOp(op Op) {
  24141. m.op = op
  24142. }
  24143. // Type returns the node type of this mutation (SopNode).
  24144. func (m *SopNodeMutation) Type() string {
  24145. return m.typ
  24146. }
  24147. // Fields returns all fields that were changed during this mutation. Note that in
  24148. // order to get all numeric fields that were incremented/decremented, call
  24149. // AddedFields().
  24150. func (m *SopNodeMutation) Fields() []string {
  24151. fields := make([]string, 0, 15)
  24152. if m.created_at != nil {
  24153. fields = append(fields, sopnode.FieldCreatedAt)
  24154. }
  24155. if m.updated_at != nil {
  24156. fields = append(fields, sopnode.FieldUpdatedAt)
  24157. }
  24158. if m.status != nil {
  24159. fields = append(fields, sopnode.FieldStatus)
  24160. }
  24161. if m.deleted_at != nil {
  24162. fields = append(fields, sopnode.FieldDeletedAt)
  24163. }
  24164. if m.sop_stage != nil {
  24165. fields = append(fields, sopnode.FieldStageID)
  24166. }
  24167. if m.parent_id != nil {
  24168. fields = append(fields, sopnode.FieldParentID)
  24169. }
  24170. if m.name != nil {
  24171. fields = append(fields, sopnode.FieldName)
  24172. }
  24173. if m.condition_type != nil {
  24174. fields = append(fields, sopnode.FieldConditionType)
  24175. }
  24176. if m.condition_list != nil {
  24177. fields = append(fields, sopnode.FieldConditionList)
  24178. }
  24179. if m.no_reply_condition != nil {
  24180. fields = append(fields, sopnode.FieldNoReplyCondition)
  24181. }
  24182. if m.no_reply_unit != nil {
  24183. fields = append(fields, sopnode.FieldNoReplyUnit)
  24184. }
  24185. if m.action_message != nil {
  24186. fields = append(fields, sopnode.FieldActionMessage)
  24187. }
  24188. if m.action_label_add != nil {
  24189. fields = append(fields, sopnode.FieldActionLabelAdd)
  24190. }
  24191. if m.action_label_del != nil {
  24192. fields = append(fields, sopnode.FieldActionLabelDel)
  24193. }
  24194. if m.action_forward != nil {
  24195. fields = append(fields, sopnode.FieldActionForward)
  24196. }
  24197. return fields
  24198. }
  24199. // Field returns the value of a field with the given name. The second boolean
  24200. // return value indicates that this field was not set, or was not defined in the
  24201. // schema.
  24202. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  24203. switch name {
  24204. case sopnode.FieldCreatedAt:
  24205. return m.CreatedAt()
  24206. case sopnode.FieldUpdatedAt:
  24207. return m.UpdatedAt()
  24208. case sopnode.FieldStatus:
  24209. return m.Status()
  24210. case sopnode.FieldDeletedAt:
  24211. return m.DeletedAt()
  24212. case sopnode.FieldStageID:
  24213. return m.StageID()
  24214. case sopnode.FieldParentID:
  24215. return m.ParentID()
  24216. case sopnode.FieldName:
  24217. return m.Name()
  24218. case sopnode.FieldConditionType:
  24219. return m.ConditionType()
  24220. case sopnode.FieldConditionList:
  24221. return m.ConditionList()
  24222. case sopnode.FieldNoReplyCondition:
  24223. return m.NoReplyCondition()
  24224. case sopnode.FieldNoReplyUnit:
  24225. return m.NoReplyUnit()
  24226. case sopnode.FieldActionMessage:
  24227. return m.ActionMessage()
  24228. case sopnode.FieldActionLabelAdd:
  24229. return m.ActionLabelAdd()
  24230. case sopnode.FieldActionLabelDel:
  24231. return m.ActionLabelDel()
  24232. case sopnode.FieldActionForward:
  24233. return m.ActionForward()
  24234. }
  24235. return nil, false
  24236. }
  24237. // OldField returns the old value of the field from the database. An error is
  24238. // returned if the mutation operation is not UpdateOne, or the query to the
  24239. // database failed.
  24240. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24241. switch name {
  24242. case sopnode.FieldCreatedAt:
  24243. return m.OldCreatedAt(ctx)
  24244. case sopnode.FieldUpdatedAt:
  24245. return m.OldUpdatedAt(ctx)
  24246. case sopnode.FieldStatus:
  24247. return m.OldStatus(ctx)
  24248. case sopnode.FieldDeletedAt:
  24249. return m.OldDeletedAt(ctx)
  24250. case sopnode.FieldStageID:
  24251. return m.OldStageID(ctx)
  24252. case sopnode.FieldParentID:
  24253. return m.OldParentID(ctx)
  24254. case sopnode.FieldName:
  24255. return m.OldName(ctx)
  24256. case sopnode.FieldConditionType:
  24257. return m.OldConditionType(ctx)
  24258. case sopnode.FieldConditionList:
  24259. return m.OldConditionList(ctx)
  24260. case sopnode.FieldNoReplyCondition:
  24261. return m.OldNoReplyCondition(ctx)
  24262. case sopnode.FieldNoReplyUnit:
  24263. return m.OldNoReplyUnit(ctx)
  24264. case sopnode.FieldActionMessage:
  24265. return m.OldActionMessage(ctx)
  24266. case sopnode.FieldActionLabelAdd:
  24267. return m.OldActionLabelAdd(ctx)
  24268. case sopnode.FieldActionLabelDel:
  24269. return m.OldActionLabelDel(ctx)
  24270. case sopnode.FieldActionForward:
  24271. return m.OldActionForward(ctx)
  24272. }
  24273. return nil, fmt.Errorf("unknown SopNode field %s", name)
  24274. }
  24275. // SetField sets the value of a field with the given name. It returns an error if
  24276. // the field is not defined in the schema, or if the type mismatched the field
  24277. // type.
  24278. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  24279. switch name {
  24280. case sopnode.FieldCreatedAt:
  24281. v, ok := value.(time.Time)
  24282. if !ok {
  24283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24284. }
  24285. m.SetCreatedAt(v)
  24286. return nil
  24287. case sopnode.FieldUpdatedAt:
  24288. v, ok := value.(time.Time)
  24289. if !ok {
  24290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24291. }
  24292. m.SetUpdatedAt(v)
  24293. return nil
  24294. case sopnode.FieldStatus:
  24295. v, ok := value.(uint8)
  24296. if !ok {
  24297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24298. }
  24299. m.SetStatus(v)
  24300. return nil
  24301. case sopnode.FieldDeletedAt:
  24302. v, ok := value.(time.Time)
  24303. if !ok {
  24304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24305. }
  24306. m.SetDeletedAt(v)
  24307. return nil
  24308. case sopnode.FieldStageID:
  24309. v, ok := value.(uint64)
  24310. if !ok {
  24311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24312. }
  24313. m.SetStageID(v)
  24314. return nil
  24315. case sopnode.FieldParentID:
  24316. v, ok := value.(uint64)
  24317. if !ok {
  24318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24319. }
  24320. m.SetParentID(v)
  24321. return nil
  24322. case sopnode.FieldName:
  24323. v, ok := value.(string)
  24324. if !ok {
  24325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24326. }
  24327. m.SetName(v)
  24328. return nil
  24329. case sopnode.FieldConditionType:
  24330. v, ok := value.(int)
  24331. if !ok {
  24332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24333. }
  24334. m.SetConditionType(v)
  24335. return nil
  24336. case sopnode.FieldConditionList:
  24337. v, ok := value.([]string)
  24338. if !ok {
  24339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24340. }
  24341. m.SetConditionList(v)
  24342. return nil
  24343. case sopnode.FieldNoReplyCondition:
  24344. v, ok := value.(uint64)
  24345. if !ok {
  24346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24347. }
  24348. m.SetNoReplyCondition(v)
  24349. return nil
  24350. case sopnode.FieldNoReplyUnit:
  24351. v, ok := value.(string)
  24352. if !ok {
  24353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24354. }
  24355. m.SetNoReplyUnit(v)
  24356. return nil
  24357. case sopnode.FieldActionMessage:
  24358. v, ok := value.([]custom_types.Action)
  24359. if !ok {
  24360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24361. }
  24362. m.SetActionMessage(v)
  24363. return nil
  24364. case sopnode.FieldActionLabelAdd:
  24365. v, ok := value.([]uint64)
  24366. if !ok {
  24367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24368. }
  24369. m.SetActionLabelAdd(v)
  24370. return nil
  24371. case sopnode.FieldActionLabelDel:
  24372. v, ok := value.([]uint64)
  24373. if !ok {
  24374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24375. }
  24376. m.SetActionLabelDel(v)
  24377. return nil
  24378. case sopnode.FieldActionForward:
  24379. v, ok := value.(*custom_types.ActionForward)
  24380. if !ok {
  24381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24382. }
  24383. m.SetActionForward(v)
  24384. return nil
  24385. }
  24386. return fmt.Errorf("unknown SopNode field %s", name)
  24387. }
  24388. // AddedFields returns all numeric fields that were incremented/decremented during
  24389. // this mutation.
  24390. func (m *SopNodeMutation) AddedFields() []string {
  24391. var fields []string
  24392. if m.addstatus != nil {
  24393. fields = append(fields, sopnode.FieldStatus)
  24394. }
  24395. if m.addparent_id != nil {
  24396. fields = append(fields, sopnode.FieldParentID)
  24397. }
  24398. if m.addcondition_type != nil {
  24399. fields = append(fields, sopnode.FieldConditionType)
  24400. }
  24401. if m.addno_reply_condition != nil {
  24402. fields = append(fields, sopnode.FieldNoReplyCondition)
  24403. }
  24404. return fields
  24405. }
  24406. // AddedField returns the numeric value that was incremented/decremented on a field
  24407. // with the given name. The second boolean return value indicates that this field
  24408. // was not set, or was not defined in the schema.
  24409. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  24410. switch name {
  24411. case sopnode.FieldStatus:
  24412. return m.AddedStatus()
  24413. case sopnode.FieldParentID:
  24414. return m.AddedParentID()
  24415. case sopnode.FieldConditionType:
  24416. return m.AddedConditionType()
  24417. case sopnode.FieldNoReplyCondition:
  24418. return m.AddedNoReplyCondition()
  24419. }
  24420. return nil, false
  24421. }
  24422. // AddField adds the value to the field with the given name. It returns an error if
  24423. // the field is not defined in the schema, or if the type mismatched the field
  24424. // type.
  24425. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  24426. switch name {
  24427. case sopnode.FieldStatus:
  24428. v, ok := value.(int8)
  24429. if !ok {
  24430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24431. }
  24432. m.AddStatus(v)
  24433. return nil
  24434. case sopnode.FieldParentID:
  24435. v, ok := value.(int64)
  24436. if !ok {
  24437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24438. }
  24439. m.AddParentID(v)
  24440. return nil
  24441. case sopnode.FieldConditionType:
  24442. v, ok := value.(int)
  24443. if !ok {
  24444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24445. }
  24446. m.AddConditionType(v)
  24447. return nil
  24448. case sopnode.FieldNoReplyCondition:
  24449. v, ok := value.(int64)
  24450. if !ok {
  24451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24452. }
  24453. m.AddNoReplyCondition(v)
  24454. return nil
  24455. }
  24456. return fmt.Errorf("unknown SopNode numeric field %s", name)
  24457. }
  24458. // ClearedFields returns all nullable fields that were cleared during this
  24459. // mutation.
  24460. func (m *SopNodeMutation) ClearedFields() []string {
  24461. var fields []string
  24462. if m.FieldCleared(sopnode.FieldStatus) {
  24463. fields = append(fields, sopnode.FieldStatus)
  24464. }
  24465. if m.FieldCleared(sopnode.FieldDeletedAt) {
  24466. fields = append(fields, sopnode.FieldDeletedAt)
  24467. }
  24468. if m.FieldCleared(sopnode.FieldConditionList) {
  24469. fields = append(fields, sopnode.FieldConditionList)
  24470. }
  24471. if m.FieldCleared(sopnode.FieldActionMessage) {
  24472. fields = append(fields, sopnode.FieldActionMessage)
  24473. }
  24474. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  24475. fields = append(fields, sopnode.FieldActionLabelAdd)
  24476. }
  24477. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  24478. fields = append(fields, sopnode.FieldActionLabelDel)
  24479. }
  24480. if m.FieldCleared(sopnode.FieldActionForward) {
  24481. fields = append(fields, sopnode.FieldActionForward)
  24482. }
  24483. return fields
  24484. }
  24485. // FieldCleared returns a boolean indicating if a field with the given name was
  24486. // cleared in this mutation.
  24487. func (m *SopNodeMutation) FieldCleared(name string) bool {
  24488. _, ok := m.clearedFields[name]
  24489. return ok
  24490. }
  24491. // ClearField clears the value of the field with the given name. It returns an
  24492. // error if the field is not defined in the schema.
  24493. func (m *SopNodeMutation) ClearField(name string) error {
  24494. switch name {
  24495. case sopnode.FieldStatus:
  24496. m.ClearStatus()
  24497. return nil
  24498. case sopnode.FieldDeletedAt:
  24499. m.ClearDeletedAt()
  24500. return nil
  24501. case sopnode.FieldConditionList:
  24502. m.ClearConditionList()
  24503. return nil
  24504. case sopnode.FieldActionMessage:
  24505. m.ClearActionMessage()
  24506. return nil
  24507. case sopnode.FieldActionLabelAdd:
  24508. m.ClearActionLabelAdd()
  24509. return nil
  24510. case sopnode.FieldActionLabelDel:
  24511. m.ClearActionLabelDel()
  24512. return nil
  24513. case sopnode.FieldActionForward:
  24514. m.ClearActionForward()
  24515. return nil
  24516. }
  24517. return fmt.Errorf("unknown SopNode nullable field %s", name)
  24518. }
  24519. // ResetField resets all changes in the mutation for the field with the given name.
  24520. // It returns an error if the field is not defined in the schema.
  24521. func (m *SopNodeMutation) ResetField(name string) error {
  24522. switch name {
  24523. case sopnode.FieldCreatedAt:
  24524. m.ResetCreatedAt()
  24525. return nil
  24526. case sopnode.FieldUpdatedAt:
  24527. m.ResetUpdatedAt()
  24528. return nil
  24529. case sopnode.FieldStatus:
  24530. m.ResetStatus()
  24531. return nil
  24532. case sopnode.FieldDeletedAt:
  24533. m.ResetDeletedAt()
  24534. return nil
  24535. case sopnode.FieldStageID:
  24536. m.ResetStageID()
  24537. return nil
  24538. case sopnode.FieldParentID:
  24539. m.ResetParentID()
  24540. return nil
  24541. case sopnode.FieldName:
  24542. m.ResetName()
  24543. return nil
  24544. case sopnode.FieldConditionType:
  24545. m.ResetConditionType()
  24546. return nil
  24547. case sopnode.FieldConditionList:
  24548. m.ResetConditionList()
  24549. return nil
  24550. case sopnode.FieldNoReplyCondition:
  24551. m.ResetNoReplyCondition()
  24552. return nil
  24553. case sopnode.FieldNoReplyUnit:
  24554. m.ResetNoReplyUnit()
  24555. return nil
  24556. case sopnode.FieldActionMessage:
  24557. m.ResetActionMessage()
  24558. return nil
  24559. case sopnode.FieldActionLabelAdd:
  24560. m.ResetActionLabelAdd()
  24561. return nil
  24562. case sopnode.FieldActionLabelDel:
  24563. m.ResetActionLabelDel()
  24564. return nil
  24565. case sopnode.FieldActionForward:
  24566. m.ResetActionForward()
  24567. return nil
  24568. }
  24569. return fmt.Errorf("unknown SopNode field %s", name)
  24570. }
  24571. // AddedEdges returns all edge names that were set/added in this mutation.
  24572. func (m *SopNodeMutation) AddedEdges() []string {
  24573. edges := make([]string, 0, 2)
  24574. if m.sop_stage != nil {
  24575. edges = append(edges, sopnode.EdgeSopStage)
  24576. }
  24577. if m.node_messages != nil {
  24578. edges = append(edges, sopnode.EdgeNodeMessages)
  24579. }
  24580. return edges
  24581. }
  24582. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24583. // name in this mutation.
  24584. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  24585. switch name {
  24586. case sopnode.EdgeSopStage:
  24587. if id := m.sop_stage; id != nil {
  24588. return []ent.Value{*id}
  24589. }
  24590. case sopnode.EdgeNodeMessages:
  24591. ids := make([]ent.Value, 0, len(m.node_messages))
  24592. for id := range m.node_messages {
  24593. ids = append(ids, id)
  24594. }
  24595. return ids
  24596. }
  24597. return nil
  24598. }
  24599. // RemovedEdges returns all edge names that were removed in this mutation.
  24600. func (m *SopNodeMutation) RemovedEdges() []string {
  24601. edges := make([]string, 0, 2)
  24602. if m.removednode_messages != nil {
  24603. edges = append(edges, sopnode.EdgeNodeMessages)
  24604. }
  24605. return edges
  24606. }
  24607. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24608. // the given name in this mutation.
  24609. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  24610. switch name {
  24611. case sopnode.EdgeNodeMessages:
  24612. ids := make([]ent.Value, 0, len(m.removednode_messages))
  24613. for id := range m.removednode_messages {
  24614. ids = append(ids, id)
  24615. }
  24616. return ids
  24617. }
  24618. return nil
  24619. }
  24620. // ClearedEdges returns all edge names that were cleared in this mutation.
  24621. func (m *SopNodeMutation) ClearedEdges() []string {
  24622. edges := make([]string, 0, 2)
  24623. if m.clearedsop_stage {
  24624. edges = append(edges, sopnode.EdgeSopStage)
  24625. }
  24626. if m.clearednode_messages {
  24627. edges = append(edges, sopnode.EdgeNodeMessages)
  24628. }
  24629. return edges
  24630. }
  24631. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24632. // was cleared in this mutation.
  24633. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  24634. switch name {
  24635. case sopnode.EdgeSopStage:
  24636. return m.clearedsop_stage
  24637. case sopnode.EdgeNodeMessages:
  24638. return m.clearednode_messages
  24639. }
  24640. return false
  24641. }
  24642. // ClearEdge clears the value of the edge with the given name. It returns an error
  24643. // if that edge is not defined in the schema.
  24644. func (m *SopNodeMutation) ClearEdge(name string) error {
  24645. switch name {
  24646. case sopnode.EdgeSopStage:
  24647. m.ClearSopStage()
  24648. return nil
  24649. }
  24650. return fmt.Errorf("unknown SopNode unique edge %s", name)
  24651. }
  24652. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24653. // It returns an error if the edge is not defined in the schema.
  24654. func (m *SopNodeMutation) ResetEdge(name string) error {
  24655. switch name {
  24656. case sopnode.EdgeSopStage:
  24657. m.ResetSopStage()
  24658. return nil
  24659. case sopnode.EdgeNodeMessages:
  24660. m.ResetNodeMessages()
  24661. return nil
  24662. }
  24663. return fmt.Errorf("unknown SopNode edge %s", name)
  24664. }
  24665. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  24666. type SopStageMutation struct {
  24667. config
  24668. op Op
  24669. typ string
  24670. id *uint64
  24671. created_at *time.Time
  24672. updated_at *time.Time
  24673. status *uint8
  24674. addstatus *int8
  24675. deleted_at *time.Time
  24676. name *string
  24677. condition_type *int
  24678. addcondition_type *int
  24679. condition_operator *int
  24680. addcondition_operator *int
  24681. condition_list *[]custom_types.Condition
  24682. appendcondition_list []custom_types.Condition
  24683. action_message *[]custom_types.Action
  24684. appendaction_message []custom_types.Action
  24685. action_label_add *[]uint64
  24686. appendaction_label_add []uint64
  24687. action_label_del *[]uint64
  24688. appendaction_label_del []uint64
  24689. action_forward **custom_types.ActionForward
  24690. index_sort *int
  24691. addindex_sort *int
  24692. clearedFields map[string]struct{}
  24693. sop_task *uint64
  24694. clearedsop_task bool
  24695. stage_nodes map[uint64]struct{}
  24696. removedstage_nodes map[uint64]struct{}
  24697. clearedstage_nodes bool
  24698. stage_messages map[uint64]struct{}
  24699. removedstage_messages map[uint64]struct{}
  24700. clearedstage_messages bool
  24701. done bool
  24702. oldValue func(context.Context) (*SopStage, error)
  24703. predicates []predicate.SopStage
  24704. }
  24705. var _ ent.Mutation = (*SopStageMutation)(nil)
  24706. // sopstageOption allows management of the mutation configuration using functional options.
  24707. type sopstageOption func(*SopStageMutation)
  24708. // newSopStageMutation creates new mutation for the SopStage entity.
  24709. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  24710. m := &SopStageMutation{
  24711. config: c,
  24712. op: op,
  24713. typ: TypeSopStage,
  24714. clearedFields: make(map[string]struct{}),
  24715. }
  24716. for _, opt := range opts {
  24717. opt(m)
  24718. }
  24719. return m
  24720. }
  24721. // withSopStageID sets the ID field of the mutation.
  24722. func withSopStageID(id uint64) sopstageOption {
  24723. return func(m *SopStageMutation) {
  24724. var (
  24725. err error
  24726. once sync.Once
  24727. value *SopStage
  24728. )
  24729. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  24730. once.Do(func() {
  24731. if m.done {
  24732. err = errors.New("querying old values post mutation is not allowed")
  24733. } else {
  24734. value, err = m.Client().SopStage.Get(ctx, id)
  24735. }
  24736. })
  24737. return value, err
  24738. }
  24739. m.id = &id
  24740. }
  24741. }
  24742. // withSopStage sets the old SopStage of the mutation.
  24743. func withSopStage(node *SopStage) sopstageOption {
  24744. return func(m *SopStageMutation) {
  24745. m.oldValue = func(context.Context) (*SopStage, error) {
  24746. return node, nil
  24747. }
  24748. m.id = &node.ID
  24749. }
  24750. }
  24751. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24752. // executed in a transaction (ent.Tx), a transactional client is returned.
  24753. func (m SopStageMutation) Client() *Client {
  24754. client := &Client{config: m.config}
  24755. client.init()
  24756. return client
  24757. }
  24758. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24759. // it returns an error otherwise.
  24760. func (m SopStageMutation) Tx() (*Tx, error) {
  24761. if _, ok := m.driver.(*txDriver); !ok {
  24762. return nil, errors.New("ent: mutation is not running in a transaction")
  24763. }
  24764. tx := &Tx{config: m.config}
  24765. tx.init()
  24766. return tx, nil
  24767. }
  24768. // SetID sets the value of the id field. Note that this
  24769. // operation is only accepted on creation of SopStage entities.
  24770. func (m *SopStageMutation) SetID(id uint64) {
  24771. m.id = &id
  24772. }
  24773. // ID returns the ID value in the mutation. Note that the ID is only available
  24774. // if it was provided to the builder or after it was returned from the database.
  24775. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  24776. if m.id == nil {
  24777. return
  24778. }
  24779. return *m.id, true
  24780. }
  24781. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24782. // That means, if the mutation is applied within a transaction with an isolation level such
  24783. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24784. // or updated by the mutation.
  24785. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  24786. switch {
  24787. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24788. id, exists := m.ID()
  24789. if exists {
  24790. return []uint64{id}, nil
  24791. }
  24792. fallthrough
  24793. case m.op.Is(OpUpdate | OpDelete):
  24794. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  24795. default:
  24796. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24797. }
  24798. }
  24799. // SetCreatedAt sets the "created_at" field.
  24800. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  24801. m.created_at = &t
  24802. }
  24803. // CreatedAt returns the value of the "created_at" field in the mutation.
  24804. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  24805. v := m.created_at
  24806. if v == nil {
  24807. return
  24808. }
  24809. return *v, true
  24810. }
  24811. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  24812. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24813. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24814. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24815. if !m.op.Is(OpUpdateOne) {
  24816. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24817. }
  24818. if m.id == nil || m.oldValue == nil {
  24819. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24820. }
  24821. oldValue, err := m.oldValue(ctx)
  24822. if err != nil {
  24823. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24824. }
  24825. return oldValue.CreatedAt, nil
  24826. }
  24827. // ResetCreatedAt resets all changes to the "created_at" field.
  24828. func (m *SopStageMutation) ResetCreatedAt() {
  24829. m.created_at = nil
  24830. }
  24831. // SetUpdatedAt sets the "updated_at" field.
  24832. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  24833. m.updated_at = &t
  24834. }
  24835. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24836. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  24837. v := m.updated_at
  24838. if v == nil {
  24839. return
  24840. }
  24841. return *v, true
  24842. }
  24843. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  24844. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24846. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24847. if !m.op.Is(OpUpdateOne) {
  24848. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24849. }
  24850. if m.id == nil || m.oldValue == nil {
  24851. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24852. }
  24853. oldValue, err := m.oldValue(ctx)
  24854. if err != nil {
  24855. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24856. }
  24857. return oldValue.UpdatedAt, nil
  24858. }
  24859. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24860. func (m *SopStageMutation) ResetUpdatedAt() {
  24861. m.updated_at = nil
  24862. }
  24863. // SetStatus sets the "status" field.
  24864. func (m *SopStageMutation) SetStatus(u uint8) {
  24865. m.status = &u
  24866. m.addstatus = nil
  24867. }
  24868. // Status returns the value of the "status" field in the mutation.
  24869. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  24870. v := m.status
  24871. if v == nil {
  24872. return
  24873. }
  24874. return *v, true
  24875. }
  24876. // OldStatus returns the old "status" field's value of the SopStage entity.
  24877. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24879. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24880. if !m.op.Is(OpUpdateOne) {
  24881. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24882. }
  24883. if m.id == nil || m.oldValue == nil {
  24884. return v, errors.New("OldStatus requires an ID field in the mutation")
  24885. }
  24886. oldValue, err := m.oldValue(ctx)
  24887. if err != nil {
  24888. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24889. }
  24890. return oldValue.Status, nil
  24891. }
  24892. // AddStatus adds u to the "status" field.
  24893. func (m *SopStageMutation) AddStatus(u int8) {
  24894. if m.addstatus != nil {
  24895. *m.addstatus += u
  24896. } else {
  24897. m.addstatus = &u
  24898. }
  24899. }
  24900. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24901. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  24902. v := m.addstatus
  24903. if v == nil {
  24904. return
  24905. }
  24906. return *v, true
  24907. }
  24908. // ClearStatus clears the value of the "status" field.
  24909. func (m *SopStageMutation) ClearStatus() {
  24910. m.status = nil
  24911. m.addstatus = nil
  24912. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  24913. }
  24914. // StatusCleared returns if the "status" field was cleared in this mutation.
  24915. func (m *SopStageMutation) StatusCleared() bool {
  24916. _, ok := m.clearedFields[sopstage.FieldStatus]
  24917. return ok
  24918. }
  24919. // ResetStatus resets all changes to the "status" field.
  24920. func (m *SopStageMutation) ResetStatus() {
  24921. m.status = nil
  24922. m.addstatus = nil
  24923. delete(m.clearedFields, sopstage.FieldStatus)
  24924. }
  24925. // SetDeletedAt sets the "deleted_at" field.
  24926. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  24927. m.deleted_at = &t
  24928. }
  24929. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24930. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  24931. v := m.deleted_at
  24932. if v == nil {
  24933. return
  24934. }
  24935. return *v, true
  24936. }
  24937. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  24938. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24940. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24941. if !m.op.Is(OpUpdateOne) {
  24942. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24943. }
  24944. if m.id == nil || m.oldValue == nil {
  24945. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24946. }
  24947. oldValue, err := m.oldValue(ctx)
  24948. if err != nil {
  24949. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24950. }
  24951. return oldValue.DeletedAt, nil
  24952. }
  24953. // ClearDeletedAt clears the value of the "deleted_at" field.
  24954. func (m *SopStageMutation) ClearDeletedAt() {
  24955. m.deleted_at = nil
  24956. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  24957. }
  24958. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24959. func (m *SopStageMutation) DeletedAtCleared() bool {
  24960. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  24961. return ok
  24962. }
  24963. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24964. func (m *SopStageMutation) ResetDeletedAt() {
  24965. m.deleted_at = nil
  24966. delete(m.clearedFields, sopstage.FieldDeletedAt)
  24967. }
  24968. // SetTaskID sets the "task_id" field.
  24969. func (m *SopStageMutation) SetTaskID(u uint64) {
  24970. m.sop_task = &u
  24971. }
  24972. // TaskID returns the value of the "task_id" field in the mutation.
  24973. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  24974. v := m.sop_task
  24975. if v == nil {
  24976. return
  24977. }
  24978. return *v, true
  24979. }
  24980. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  24981. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  24982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24983. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  24984. if !m.op.Is(OpUpdateOne) {
  24985. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  24986. }
  24987. if m.id == nil || m.oldValue == nil {
  24988. return v, errors.New("OldTaskID requires an ID field in the mutation")
  24989. }
  24990. oldValue, err := m.oldValue(ctx)
  24991. if err != nil {
  24992. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  24993. }
  24994. return oldValue.TaskID, nil
  24995. }
  24996. // ResetTaskID resets all changes to the "task_id" field.
  24997. func (m *SopStageMutation) ResetTaskID() {
  24998. m.sop_task = nil
  24999. }
  25000. // SetName sets the "name" field.
  25001. func (m *SopStageMutation) SetName(s string) {
  25002. m.name = &s
  25003. }
  25004. // Name returns the value of the "name" field in the mutation.
  25005. func (m *SopStageMutation) Name() (r string, exists bool) {
  25006. v := m.name
  25007. if v == nil {
  25008. return
  25009. }
  25010. return *v, true
  25011. }
  25012. // OldName returns the old "name" field's value of the SopStage entity.
  25013. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25015. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  25016. if !m.op.Is(OpUpdateOne) {
  25017. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25018. }
  25019. if m.id == nil || m.oldValue == nil {
  25020. return v, errors.New("OldName requires an ID field in the mutation")
  25021. }
  25022. oldValue, err := m.oldValue(ctx)
  25023. if err != nil {
  25024. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25025. }
  25026. return oldValue.Name, nil
  25027. }
  25028. // ResetName resets all changes to the "name" field.
  25029. func (m *SopStageMutation) ResetName() {
  25030. m.name = nil
  25031. }
  25032. // SetConditionType sets the "condition_type" field.
  25033. func (m *SopStageMutation) SetConditionType(i int) {
  25034. m.condition_type = &i
  25035. m.addcondition_type = nil
  25036. }
  25037. // ConditionType returns the value of the "condition_type" field in the mutation.
  25038. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  25039. v := m.condition_type
  25040. if v == nil {
  25041. return
  25042. }
  25043. return *v, true
  25044. }
  25045. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  25046. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25048. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25049. if !m.op.Is(OpUpdateOne) {
  25050. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25051. }
  25052. if m.id == nil || m.oldValue == nil {
  25053. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25054. }
  25055. oldValue, err := m.oldValue(ctx)
  25056. if err != nil {
  25057. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25058. }
  25059. return oldValue.ConditionType, nil
  25060. }
  25061. // AddConditionType adds i to the "condition_type" field.
  25062. func (m *SopStageMutation) AddConditionType(i int) {
  25063. if m.addcondition_type != nil {
  25064. *m.addcondition_type += i
  25065. } else {
  25066. m.addcondition_type = &i
  25067. }
  25068. }
  25069. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25070. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  25071. v := m.addcondition_type
  25072. if v == nil {
  25073. return
  25074. }
  25075. return *v, true
  25076. }
  25077. // ResetConditionType resets all changes to the "condition_type" field.
  25078. func (m *SopStageMutation) ResetConditionType() {
  25079. m.condition_type = nil
  25080. m.addcondition_type = nil
  25081. }
  25082. // SetConditionOperator sets the "condition_operator" field.
  25083. func (m *SopStageMutation) SetConditionOperator(i int) {
  25084. m.condition_operator = &i
  25085. m.addcondition_operator = nil
  25086. }
  25087. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  25088. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  25089. v := m.condition_operator
  25090. if v == nil {
  25091. return
  25092. }
  25093. return *v, true
  25094. }
  25095. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  25096. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25098. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  25099. if !m.op.Is(OpUpdateOne) {
  25100. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  25101. }
  25102. if m.id == nil || m.oldValue == nil {
  25103. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  25104. }
  25105. oldValue, err := m.oldValue(ctx)
  25106. if err != nil {
  25107. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  25108. }
  25109. return oldValue.ConditionOperator, nil
  25110. }
  25111. // AddConditionOperator adds i to the "condition_operator" field.
  25112. func (m *SopStageMutation) AddConditionOperator(i int) {
  25113. if m.addcondition_operator != nil {
  25114. *m.addcondition_operator += i
  25115. } else {
  25116. m.addcondition_operator = &i
  25117. }
  25118. }
  25119. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  25120. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  25121. v := m.addcondition_operator
  25122. if v == nil {
  25123. return
  25124. }
  25125. return *v, true
  25126. }
  25127. // ResetConditionOperator resets all changes to the "condition_operator" field.
  25128. func (m *SopStageMutation) ResetConditionOperator() {
  25129. m.condition_operator = nil
  25130. m.addcondition_operator = nil
  25131. }
  25132. // SetConditionList sets the "condition_list" field.
  25133. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  25134. m.condition_list = &ct
  25135. m.appendcondition_list = nil
  25136. }
  25137. // ConditionList returns the value of the "condition_list" field in the mutation.
  25138. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  25139. v := m.condition_list
  25140. if v == nil {
  25141. return
  25142. }
  25143. return *v, true
  25144. }
  25145. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  25146. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25148. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  25149. if !m.op.Is(OpUpdateOne) {
  25150. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25151. }
  25152. if m.id == nil || m.oldValue == nil {
  25153. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25154. }
  25155. oldValue, err := m.oldValue(ctx)
  25156. if err != nil {
  25157. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25158. }
  25159. return oldValue.ConditionList, nil
  25160. }
  25161. // AppendConditionList adds ct to the "condition_list" field.
  25162. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  25163. m.appendcondition_list = append(m.appendcondition_list, ct...)
  25164. }
  25165. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25166. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  25167. if len(m.appendcondition_list) == 0 {
  25168. return nil, false
  25169. }
  25170. return m.appendcondition_list, true
  25171. }
  25172. // ResetConditionList resets all changes to the "condition_list" field.
  25173. func (m *SopStageMutation) ResetConditionList() {
  25174. m.condition_list = nil
  25175. m.appendcondition_list = nil
  25176. }
  25177. // SetActionMessage sets the "action_message" field.
  25178. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  25179. m.action_message = &ct
  25180. m.appendaction_message = nil
  25181. }
  25182. // ActionMessage returns the value of the "action_message" field in the mutation.
  25183. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  25184. v := m.action_message
  25185. if v == nil {
  25186. return
  25187. }
  25188. return *v, true
  25189. }
  25190. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  25191. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25193. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  25194. if !m.op.Is(OpUpdateOne) {
  25195. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  25196. }
  25197. if m.id == nil || m.oldValue == nil {
  25198. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  25199. }
  25200. oldValue, err := m.oldValue(ctx)
  25201. if err != nil {
  25202. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  25203. }
  25204. return oldValue.ActionMessage, nil
  25205. }
  25206. // AppendActionMessage adds ct to the "action_message" field.
  25207. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  25208. m.appendaction_message = append(m.appendaction_message, ct...)
  25209. }
  25210. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  25211. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  25212. if len(m.appendaction_message) == 0 {
  25213. return nil, false
  25214. }
  25215. return m.appendaction_message, true
  25216. }
  25217. // ClearActionMessage clears the value of the "action_message" field.
  25218. func (m *SopStageMutation) ClearActionMessage() {
  25219. m.action_message = nil
  25220. m.appendaction_message = nil
  25221. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  25222. }
  25223. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  25224. func (m *SopStageMutation) ActionMessageCleared() bool {
  25225. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  25226. return ok
  25227. }
  25228. // ResetActionMessage resets all changes to the "action_message" field.
  25229. func (m *SopStageMutation) ResetActionMessage() {
  25230. m.action_message = nil
  25231. m.appendaction_message = nil
  25232. delete(m.clearedFields, sopstage.FieldActionMessage)
  25233. }
  25234. // SetActionLabelAdd sets the "action_label_add" field.
  25235. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  25236. m.action_label_add = &u
  25237. m.appendaction_label_add = nil
  25238. }
  25239. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  25240. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  25241. v := m.action_label_add
  25242. if v == nil {
  25243. return
  25244. }
  25245. return *v, true
  25246. }
  25247. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  25248. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25250. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  25251. if !m.op.Is(OpUpdateOne) {
  25252. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  25253. }
  25254. if m.id == nil || m.oldValue == nil {
  25255. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  25256. }
  25257. oldValue, err := m.oldValue(ctx)
  25258. if err != nil {
  25259. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  25260. }
  25261. return oldValue.ActionLabelAdd, nil
  25262. }
  25263. // AppendActionLabelAdd adds u to the "action_label_add" field.
  25264. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  25265. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  25266. }
  25267. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  25268. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  25269. if len(m.appendaction_label_add) == 0 {
  25270. return nil, false
  25271. }
  25272. return m.appendaction_label_add, true
  25273. }
  25274. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  25275. func (m *SopStageMutation) ClearActionLabelAdd() {
  25276. m.action_label_add = nil
  25277. m.appendaction_label_add = nil
  25278. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  25279. }
  25280. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  25281. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  25282. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  25283. return ok
  25284. }
  25285. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  25286. func (m *SopStageMutation) ResetActionLabelAdd() {
  25287. m.action_label_add = nil
  25288. m.appendaction_label_add = nil
  25289. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  25290. }
  25291. // SetActionLabelDel sets the "action_label_del" field.
  25292. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  25293. m.action_label_del = &u
  25294. m.appendaction_label_del = nil
  25295. }
  25296. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  25297. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  25298. v := m.action_label_del
  25299. if v == nil {
  25300. return
  25301. }
  25302. return *v, true
  25303. }
  25304. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  25305. // If the SopStage 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 *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  25308. if !m.op.Is(OpUpdateOne) {
  25309. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  25310. }
  25311. if m.id == nil || m.oldValue == nil {
  25312. return v, errors.New("OldActionLabelDel 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 OldActionLabelDel: %w", err)
  25317. }
  25318. return oldValue.ActionLabelDel, nil
  25319. }
  25320. // AppendActionLabelDel adds u to the "action_label_del" field.
  25321. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  25322. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  25323. }
  25324. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  25325. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  25326. if len(m.appendaction_label_del) == 0 {
  25327. return nil, false
  25328. }
  25329. return m.appendaction_label_del, true
  25330. }
  25331. // ClearActionLabelDel clears the value of the "action_label_del" field.
  25332. func (m *SopStageMutation) ClearActionLabelDel() {
  25333. m.action_label_del = nil
  25334. m.appendaction_label_del = nil
  25335. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  25336. }
  25337. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  25338. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  25339. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  25340. return ok
  25341. }
  25342. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  25343. func (m *SopStageMutation) ResetActionLabelDel() {
  25344. m.action_label_del = nil
  25345. m.appendaction_label_del = nil
  25346. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  25347. }
  25348. // SetActionForward sets the "action_forward" field.
  25349. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  25350. m.action_forward = &ctf
  25351. }
  25352. // ActionForward returns the value of the "action_forward" field in the mutation.
  25353. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  25354. v := m.action_forward
  25355. if v == nil {
  25356. return
  25357. }
  25358. return *v, true
  25359. }
  25360. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  25361. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25363. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  25364. if !m.op.Is(OpUpdateOne) {
  25365. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  25366. }
  25367. if m.id == nil || m.oldValue == nil {
  25368. return v, errors.New("OldActionForward requires an ID field in the mutation")
  25369. }
  25370. oldValue, err := m.oldValue(ctx)
  25371. if err != nil {
  25372. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  25373. }
  25374. return oldValue.ActionForward, nil
  25375. }
  25376. // ClearActionForward clears the value of the "action_forward" field.
  25377. func (m *SopStageMutation) ClearActionForward() {
  25378. m.action_forward = nil
  25379. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  25380. }
  25381. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  25382. func (m *SopStageMutation) ActionForwardCleared() bool {
  25383. _, ok := m.clearedFields[sopstage.FieldActionForward]
  25384. return ok
  25385. }
  25386. // ResetActionForward resets all changes to the "action_forward" field.
  25387. func (m *SopStageMutation) ResetActionForward() {
  25388. m.action_forward = nil
  25389. delete(m.clearedFields, sopstage.FieldActionForward)
  25390. }
  25391. // SetIndexSort sets the "index_sort" field.
  25392. func (m *SopStageMutation) SetIndexSort(i int) {
  25393. m.index_sort = &i
  25394. m.addindex_sort = nil
  25395. }
  25396. // IndexSort returns the value of the "index_sort" field in the mutation.
  25397. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  25398. v := m.index_sort
  25399. if v == nil {
  25400. return
  25401. }
  25402. return *v, true
  25403. }
  25404. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  25405. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25407. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  25408. if !m.op.Is(OpUpdateOne) {
  25409. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  25410. }
  25411. if m.id == nil || m.oldValue == nil {
  25412. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  25413. }
  25414. oldValue, err := m.oldValue(ctx)
  25415. if err != nil {
  25416. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  25417. }
  25418. return oldValue.IndexSort, nil
  25419. }
  25420. // AddIndexSort adds i to the "index_sort" field.
  25421. func (m *SopStageMutation) AddIndexSort(i int) {
  25422. if m.addindex_sort != nil {
  25423. *m.addindex_sort += i
  25424. } else {
  25425. m.addindex_sort = &i
  25426. }
  25427. }
  25428. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  25429. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  25430. v := m.addindex_sort
  25431. if v == nil {
  25432. return
  25433. }
  25434. return *v, true
  25435. }
  25436. // ClearIndexSort clears the value of the "index_sort" field.
  25437. func (m *SopStageMutation) ClearIndexSort() {
  25438. m.index_sort = nil
  25439. m.addindex_sort = nil
  25440. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  25441. }
  25442. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  25443. func (m *SopStageMutation) IndexSortCleared() bool {
  25444. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  25445. return ok
  25446. }
  25447. // ResetIndexSort resets all changes to the "index_sort" field.
  25448. func (m *SopStageMutation) ResetIndexSort() {
  25449. m.index_sort = nil
  25450. m.addindex_sort = nil
  25451. delete(m.clearedFields, sopstage.FieldIndexSort)
  25452. }
  25453. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  25454. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  25455. m.sop_task = &id
  25456. }
  25457. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  25458. func (m *SopStageMutation) ClearSopTask() {
  25459. m.clearedsop_task = true
  25460. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  25461. }
  25462. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  25463. func (m *SopStageMutation) SopTaskCleared() bool {
  25464. return m.clearedsop_task
  25465. }
  25466. // SopTaskID returns the "sop_task" edge ID in the mutation.
  25467. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  25468. if m.sop_task != nil {
  25469. return *m.sop_task, true
  25470. }
  25471. return
  25472. }
  25473. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  25474. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25475. // SopTaskID instead. It exists only for internal usage by the builders.
  25476. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  25477. if id := m.sop_task; id != nil {
  25478. ids = append(ids, *id)
  25479. }
  25480. return
  25481. }
  25482. // ResetSopTask resets all changes to the "sop_task" edge.
  25483. func (m *SopStageMutation) ResetSopTask() {
  25484. m.sop_task = nil
  25485. m.clearedsop_task = false
  25486. }
  25487. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  25488. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  25489. if m.stage_nodes == nil {
  25490. m.stage_nodes = make(map[uint64]struct{})
  25491. }
  25492. for i := range ids {
  25493. m.stage_nodes[ids[i]] = struct{}{}
  25494. }
  25495. }
  25496. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  25497. func (m *SopStageMutation) ClearStageNodes() {
  25498. m.clearedstage_nodes = true
  25499. }
  25500. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  25501. func (m *SopStageMutation) StageNodesCleared() bool {
  25502. return m.clearedstage_nodes
  25503. }
  25504. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  25505. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  25506. if m.removedstage_nodes == nil {
  25507. m.removedstage_nodes = make(map[uint64]struct{})
  25508. }
  25509. for i := range ids {
  25510. delete(m.stage_nodes, ids[i])
  25511. m.removedstage_nodes[ids[i]] = struct{}{}
  25512. }
  25513. }
  25514. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  25515. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  25516. for id := range m.removedstage_nodes {
  25517. ids = append(ids, id)
  25518. }
  25519. return
  25520. }
  25521. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  25522. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  25523. for id := range m.stage_nodes {
  25524. ids = append(ids, id)
  25525. }
  25526. return
  25527. }
  25528. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  25529. func (m *SopStageMutation) ResetStageNodes() {
  25530. m.stage_nodes = nil
  25531. m.clearedstage_nodes = false
  25532. m.removedstage_nodes = nil
  25533. }
  25534. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  25535. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  25536. if m.stage_messages == nil {
  25537. m.stage_messages = make(map[uint64]struct{})
  25538. }
  25539. for i := range ids {
  25540. m.stage_messages[ids[i]] = struct{}{}
  25541. }
  25542. }
  25543. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  25544. func (m *SopStageMutation) ClearStageMessages() {
  25545. m.clearedstage_messages = true
  25546. }
  25547. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  25548. func (m *SopStageMutation) StageMessagesCleared() bool {
  25549. return m.clearedstage_messages
  25550. }
  25551. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  25552. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  25553. if m.removedstage_messages == nil {
  25554. m.removedstage_messages = make(map[uint64]struct{})
  25555. }
  25556. for i := range ids {
  25557. delete(m.stage_messages, ids[i])
  25558. m.removedstage_messages[ids[i]] = struct{}{}
  25559. }
  25560. }
  25561. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  25562. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  25563. for id := range m.removedstage_messages {
  25564. ids = append(ids, id)
  25565. }
  25566. return
  25567. }
  25568. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  25569. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  25570. for id := range m.stage_messages {
  25571. ids = append(ids, id)
  25572. }
  25573. return
  25574. }
  25575. // ResetStageMessages resets all changes to the "stage_messages" edge.
  25576. func (m *SopStageMutation) ResetStageMessages() {
  25577. m.stage_messages = nil
  25578. m.clearedstage_messages = false
  25579. m.removedstage_messages = nil
  25580. }
  25581. // Where appends a list predicates to the SopStageMutation builder.
  25582. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  25583. m.predicates = append(m.predicates, ps...)
  25584. }
  25585. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  25586. // users can use type-assertion to append predicates that do not depend on any generated package.
  25587. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  25588. p := make([]predicate.SopStage, len(ps))
  25589. for i := range ps {
  25590. p[i] = ps[i]
  25591. }
  25592. m.Where(p...)
  25593. }
  25594. // Op returns the operation name.
  25595. func (m *SopStageMutation) Op() Op {
  25596. return m.op
  25597. }
  25598. // SetOp allows setting the mutation operation.
  25599. func (m *SopStageMutation) SetOp(op Op) {
  25600. m.op = op
  25601. }
  25602. // Type returns the node type of this mutation (SopStage).
  25603. func (m *SopStageMutation) Type() string {
  25604. return m.typ
  25605. }
  25606. // Fields returns all fields that were changed during this mutation. Note that in
  25607. // order to get all numeric fields that were incremented/decremented, call
  25608. // AddedFields().
  25609. func (m *SopStageMutation) Fields() []string {
  25610. fields := make([]string, 0, 14)
  25611. if m.created_at != nil {
  25612. fields = append(fields, sopstage.FieldCreatedAt)
  25613. }
  25614. if m.updated_at != nil {
  25615. fields = append(fields, sopstage.FieldUpdatedAt)
  25616. }
  25617. if m.status != nil {
  25618. fields = append(fields, sopstage.FieldStatus)
  25619. }
  25620. if m.deleted_at != nil {
  25621. fields = append(fields, sopstage.FieldDeletedAt)
  25622. }
  25623. if m.sop_task != nil {
  25624. fields = append(fields, sopstage.FieldTaskID)
  25625. }
  25626. if m.name != nil {
  25627. fields = append(fields, sopstage.FieldName)
  25628. }
  25629. if m.condition_type != nil {
  25630. fields = append(fields, sopstage.FieldConditionType)
  25631. }
  25632. if m.condition_operator != nil {
  25633. fields = append(fields, sopstage.FieldConditionOperator)
  25634. }
  25635. if m.condition_list != nil {
  25636. fields = append(fields, sopstage.FieldConditionList)
  25637. }
  25638. if m.action_message != nil {
  25639. fields = append(fields, sopstage.FieldActionMessage)
  25640. }
  25641. if m.action_label_add != nil {
  25642. fields = append(fields, sopstage.FieldActionLabelAdd)
  25643. }
  25644. if m.action_label_del != nil {
  25645. fields = append(fields, sopstage.FieldActionLabelDel)
  25646. }
  25647. if m.action_forward != nil {
  25648. fields = append(fields, sopstage.FieldActionForward)
  25649. }
  25650. if m.index_sort != nil {
  25651. fields = append(fields, sopstage.FieldIndexSort)
  25652. }
  25653. return fields
  25654. }
  25655. // Field returns the value of a field with the given name. The second boolean
  25656. // return value indicates that this field was not set, or was not defined in the
  25657. // schema.
  25658. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  25659. switch name {
  25660. case sopstage.FieldCreatedAt:
  25661. return m.CreatedAt()
  25662. case sopstage.FieldUpdatedAt:
  25663. return m.UpdatedAt()
  25664. case sopstage.FieldStatus:
  25665. return m.Status()
  25666. case sopstage.FieldDeletedAt:
  25667. return m.DeletedAt()
  25668. case sopstage.FieldTaskID:
  25669. return m.TaskID()
  25670. case sopstage.FieldName:
  25671. return m.Name()
  25672. case sopstage.FieldConditionType:
  25673. return m.ConditionType()
  25674. case sopstage.FieldConditionOperator:
  25675. return m.ConditionOperator()
  25676. case sopstage.FieldConditionList:
  25677. return m.ConditionList()
  25678. case sopstage.FieldActionMessage:
  25679. return m.ActionMessage()
  25680. case sopstage.FieldActionLabelAdd:
  25681. return m.ActionLabelAdd()
  25682. case sopstage.FieldActionLabelDel:
  25683. return m.ActionLabelDel()
  25684. case sopstage.FieldActionForward:
  25685. return m.ActionForward()
  25686. case sopstage.FieldIndexSort:
  25687. return m.IndexSort()
  25688. }
  25689. return nil, false
  25690. }
  25691. // OldField returns the old value of the field from the database. An error is
  25692. // returned if the mutation operation is not UpdateOne, or the query to the
  25693. // database failed.
  25694. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25695. switch name {
  25696. case sopstage.FieldCreatedAt:
  25697. return m.OldCreatedAt(ctx)
  25698. case sopstage.FieldUpdatedAt:
  25699. return m.OldUpdatedAt(ctx)
  25700. case sopstage.FieldStatus:
  25701. return m.OldStatus(ctx)
  25702. case sopstage.FieldDeletedAt:
  25703. return m.OldDeletedAt(ctx)
  25704. case sopstage.FieldTaskID:
  25705. return m.OldTaskID(ctx)
  25706. case sopstage.FieldName:
  25707. return m.OldName(ctx)
  25708. case sopstage.FieldConditionType:
  25709. return m.OldConditionType(ctx)
  25710. case sopstage.FieldConditionOperator:
  25711. return m.OldConditionOperator(ctx)
  25712. case sopstage.FieldConditionList:
  25713. return m.OldConditionList(ctx)
  25714. case sopstage.FieldActionMessage:
  25715. return m.OldActionMessage(ctx)
  25716. case sopstage.FieldActionLabelAdd:
  25717. return m.OldActionLabelAdd(ctx)
  25718. case sopstage.FieldActionLabelDel:
  25719. return m.OldActionLabelDel(ctx)
  25720. case sopstage.FieldActionForward:
  25721. return m.OldActionForward(ctx)
  25722. case sopstage.FieldIndexSort:
  25723. return m.OldIndexSort(ctx)
  25724. }
  25725. return nil, fmt.Errorf("unknown SopStage field %s", name)
  25726. }
  25727. // SetField sets the value of a field with the given name. It returns an error if
  25728. // the field is not defined in the schema, or if the type mismatched the field
  25729. // type.
  25730. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  25731. switch name {
  25732. case sopstage.FieldCreatedAt:
  25733. v, ok := value.(time.Time)
  25734. if !ok {
  25735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25736. }
  25737. m.SetCreatedAt(v)
  25738. return nil
  25739. case sopstage.FieldUpdatedAt:
  25740. v, ok := value.(time.Time)
  25741. if !ok {
  25742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25743. }
  25744. m.SetUpdatedAt(v)
  25745. return nil
  25746. case sopstage.FieldStatus:
  25747. v, ok := value.(uint8)
  25748. if !ok {
  25749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25750. }
  25751. m.SetStatus(v)
  25752. return nil
  25753. case sopstage.FieldDeletedAt:
  25754. v, ok := value.(time.Time)
  25755. if !ok {
  25756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25757. }
  25758. m.SetDeletedAt(v)
  25759. return nil
  25760. case sopstage.FieldTaskID:
  25761. v, ok := value.(uint64)
  25762. if !ok {
  25763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25764. }
  25765. m.SetTaskID(v)
  25766. return nil
  25767. case sopstage.FieldName:
  25768. v, ok := value.(string)
  25769. if !ok {
  25770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25771. }
  25772. m.SetName(v)
  25773. return nil
  25774. case sopstage.FieldConditionType:
  25775. v, ok := value.(int)
  25776. if !ok {
  25777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25778. }
  25779. m.SetConditionType(v)
  25780. return nil
  25781. case sopstage.FieldConditionOperator:
  25782. v, ok := value.(int)
  25783. if !ok {
  25784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25785. }
  25786. m.SetConditionOperator(v)
  25787. return nil
  25788. case sopstage.FieldConditionList:
  25789. v, ok := value.([]custom_types.Condition)
  25790. if !ok {
  25791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25792. }
  25793. m.SetConditionList(v)
  25794. return nil
  25795. case sopstage.FieldActionMessage:
  25796. v, ok := value.([]custom_types.Action)
  25797. if !ok {
  25798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25799. }
  25800. m.SetActionMessage(v)
  25801. return nil
  25802. case sopstage.FieldActionLabelAdd:
  25803. v, ok := value.([]uint64)
  25804. if !ok {
  25805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25806. }
  25807. m.SetActionLabelAdd(v)
  25808. return nil
  25809. case sopstage.FieldActionLabelDel:
  25810. v, ok := value.([]uint64)
  25811. if !ok {
  25812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25813. }
  25814. m.SetActionLabelDel(v)
  25815. return nil
  25816. case sopstage.FieldActionForward:
  25817. v, ok := value.(*custom_types.ActionForward)
  25818. if !ok {
  25819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25820. }
  25821. m.SetActionForward(v)
  25822. return nil
  25823. case sopstage.FieldIndexSort:
  25824. v, ok := value.(int)
  25825. if !ok {
  25826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25827. }
  25828. m.SetIndexSort(v)
  25829. return nil
  25830. }
  25831. return fmt.Errorf("unknown SopStage field %s", name)
  25832. }
  25833. // AddedFields returns all numeric fields that were incremented/decremented during
  25834. // this mutation.
  25835. func (m *SopStageMutation) AddedFields() []string {
  25836. var fields []string
  25837. if m.addstatus != nil {
  25838. fields = append(fields, sopstage.FieldStatus)
  25839. }
  25840. if m.addcondition_type != nil {
  25841. fields = append(fields, sopstage.FieldConditionType)
  25842. }
  25843. if m.addcondition_operator != nil {
  25844. fields = append(fields, sopstage.FieldConditionOperator)
  25845. }
  25846. if m.addindex_sort != nil {
  25847. fields = append(fields, sopstage.FieldIndexSort)
  25848. }
  25849. return fields
  25850. }
  25851. // AddedField returns the numeric value that was incremented/decremented on a field
  25852. // with the given name. The second boolean return value indicates that this field
  25853. // was not set, or was not defined in the schema.
  25854. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  25855. switch name {
  25856. case sopstage.FieldStatus:
  25857. return m.AddedStatus()
  25858. case sopstage.FieldConditionType:
  25859. return m.AddedConditionType()
  25860. case sopstage.FieldConditionOperator:
  25861. return m.AddedConditionOperator()
  25862. case sopstage.FieldIndexSort:
  25863. return m.AddedIndexSort()
  25864. }
  25865. return nil, false
  25866. }
  25867. // AddField adds the value to the field with the given name. It returns an error if
  25868. // the field is not defined in the schema, or if the type mismatched the field
  25869. // type.
  25870. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  25871. switch name {
  25872. case sopstage.FieldStatus:
  25873. v, ok := value.(int8)
  25874. if !ok {
  25875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25876. }
  25877. m.AddStatus(v)
  25878. return nil
  25879. case sopstage.FieldConditionType:
  25880. v, ok := value.(int)
  25881. if !ok {
  25882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25883. }
  25884. m.AddConditionType(v)
  25885. return nil
  25886. case sopstage.FieldConditionOperator:
  25887. v, ok := value.(int)
  25888. if !ok {
  25889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25890. }
  25891. m.AddConditionOperator(v)
  25892. return nil
  25893. case sopstage.FieldIndexSort:
  25894. v, ok := value.(int)
  25895. if !ok {
  25896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25897. }
  25898. m.AddIndexSort(v)
  25899. return nil
  25900. }
  25901. return fmt.Errorf("unknown SopStage numeric field %s", name)
  25902. }
  25903. // ClearedFields returns all nullable fields that were cleared during this
  25904. // mutation.
  25905. func (m *SopStageMutation) ClearedFields() []string {
  25906. var fields []string
  25907. if m.FieldCleared(sopstage.FieldStatus) {
  25908. fields = append(fields, sopstage.FieldStatus)
  25909. }
  25910. if m.FieldCleared(sopstage.FieldDeletedAt) {
  25911. fields = append(fields, sopstage.FieldDeletedAt)
  25912. }
  25913. if m.FieldCleared(sopstage.FieldActionMessage) {
  25914. fields = append(fields, sopstage.FieldActionMessage)
  25915. }
  25916. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  25917. fields = append(fields, sopstage.FieldActionLabelAdd)
  25918. }
  25919. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  25920. fields = append(fields, sopstage.FieldActionLabelDel)
  25921. }
  25922. if m.FieldCleared(sopstage.FieldActionForward) {
  25923. fields = append(fields, sopstage.FieldActionForward)
  25924. }
  25925. if m.FieldCleared(sopstage.FieldIndexSort) {
  25926. fields = append(fields, sopstage.FieldIndexSort)
  25927. }
  25928. return fields
  25929. }
  25930. // FieldCleared returns a boolean indicating if a field with the given name was
  25931. // cleared in this mutation.
  25932. func (m *SopStageMutation) FieldCleared(name string) bool {
  25933. _, ok := m.clearedFields[name]
  25934. return ok
  25935. }
  25936. // ClearField clears the value of the field with the given name. It returns an
  25937. // error if the field is not defined in the schema.
  25938. func (m *SopStageMutation) ClearField(name string) error {
  25939. switch name {
  25940. case sopstage.FieldStatus:
  25941. m.ClearStatus()
  25942. return nil
  25943. case sopstage.FieldDeletedAt:
  25944. m.ClearDeletedAt()
  25945. return nil
  25946. case sopstage.FieldActionMessage:
  25947. m.ClearActionMessage()
  25948. return nil
  25949. case sopstage.FieldActionLabelAdd:
  25950. m.ClearActionLabelAdd()
  25951. return nil
  25952. case sopstage.FieldActionLabelDel:
  25953. m.ClearActionLabelDel()
  25954. return nil
  25955. case sopstage.FieldActionForward:
  25956. m.ClearActionForward()
  25957. return nil
  25958. case sopstage.FieldIndexSort:
  25959. m.ClearIndexSort()
  25960. return nil
  25961. }
  25962. return fmt.Errorf("unknown SopStage nullable field %s", name)
  25963. }
  25964. // ResetField resets all changes in the mutation for the field with the given name.
  25965. // It returns an error if the field is not defined in the schema.
  25966. func (m *SopStageMutation) ResetField(name string) error {
  25967. switch name {
  25968. case sopstage.FieldCreatedAt:
  25969. m.ResetCreatedAt()
  25970. return nil
  25971. case sopstage.FieldUpdatedAt:
  25972. m.ResetUpdatedAt()
  25973. return nil
  25974. case sopstage.FieldStatus:
  25975. m.ResetStatus()
  25976. return nil
  25977. case sopstage.FieldDeletedAt:
  25978. m.ResetDeletedAt()
  25979. return nil
  25980. case sopstage.FieldTaskID:
  25981. m.ResetTaskID()
  25982. return nil
  25983. case sopstage.FieldName:
  25984. m.ResetName()
  25985. return nil
  25986. case sopstage.FieldConditionType:
  25987. m.ResetConditionType()
  25988. return nil
  25989. case sopstage.FieldConditionOperator:
  25990. m.ResetConditionOperator()
  25991. return nil
  25992. case sopstage.FieldConditionList:
  25993. m.ResetConditionList()
  25994. return nil
  25995. case sopstage.FieldActionMessage:
  25996. m.ResetActionMessage()
  25997. return nil
  25998. case sopstage.FieldActionLabelAdd:
  25999. m.ResetActionLabelAdd()
  26000. return nil
  26001. case sopstage.FieldActionLabelDel:
  26002. m.ResetActionLabelDel()
  26003. return nil
  26004. case sopstage.FieldActionForward:
  26005. m.ResetActionForward()
  26006. return nil
  26007. case sopstage.FieldIndexSort:
  26008. m.ResetIndexSort()
  26009. return nil
  26010. }
  26011. return fmt.Errorf("unknown SopStage field %s", name)
  26012. }
  26013. // AddedEdges returns all edge names that were set/added in this mutation.
  26014. func (m *SopStageMutation) AddedEdges() []string {
  26015. edges := make([]string, 0, 3)
  26016. if m.sop_task != nil {
  26017. edges = append(edges, sopstage.EdgeSopTask)
  26018. }
  26019. if m.stage_nodes != nil {
  26020. edges = append(edges, sopstage.EdgeStageNodes)
  26021. }
  26022. if m.stage_messages != nil {
  26023. edges = append(edges, sopstage.EdgeStageMessages)
  26024. }
  26025. return edges
  26026. }
  26027. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26028. // name in this mutation.
  26029. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  26030. switch name {
  26031. case sopstage.EdgeSopTask:
  26032. if id := m.sop_task; id != nil {
  26033. return []ent.Value{*id}
  26034. }
  26035. case sopstage.EdgeStageNodes:
  26036. ids := make([]ent.Value, 0, len(m.stage_nodes))
  26037. for id := range m.stage_nodes {
  26038. ids = append(ids, id)
  26039. }
  26040. return ids
  26041. case sopstage.EdgeStageMessages:
  26042. ids := make([]ent.Value, 0, len(m.stage_messages))
  26043. for id := range m.stage_messages {
  26044. ids = append(ids, id)
  26045. }
  26046. return ids
  26047. }
  26048. return nil
  26049. }
  26050. // RemovedEdges returns all edge names that were removed in this mutation.
  26051. func (m *SopStageMutation) RemovedEdges() []string {
  26052. edges := make([]string, 0, 3)
  26053. if m.removedstage_nodes != nil {
  26054. edges = append(edges, sopstage.EdgeStageNodes)
  26055. }
  26056. if m.removedstage_messages != nil {
  26057. edges = append(edges, sopstage.EdgeStageMessages)
  26058. }
  26059. return edges
  26060. }
  26061. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26062. // the given name in this mutation.
  26063. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  26064. switch name {
  26065. case sopstage.EdgeStageNodes:
  26066. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  26067. for id := range m.removedstage_nodes {
  26068. ids = append(ids, id)
  26069. }
  26070. return ids
  26071. case sopstage.EdgeStageMessages:
  26072. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  26073. for id := range m.removedstage_messages {
  26074. ids = append(ids, id)
  26075. }
  26076. return ids
  26077. }
  26078. return nil
  26079. }
  26080. // ClearedEdges returns all edge names that were cleared in this mutation.
  26081. func (m *SopStageMutation) ClearedEdges() []string {
  26082. edges := make([]string, 0, 3)
  26083. if m.clearedsop_task {
  26084. edges = append(edges, sopstage.EdgeSopTask)
  26085. }
  26086. if m.clearedstage_nodes {
  26087. edges = append(edges, sopstage.EdgeStageNodes)
  26088. }
  26089. if m.clearedstage_messages {
  26090. edges = append(edges, sopstage.EdgeStageMessages)
  26091. }
  26092. return edges
  26093. }
  26094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26095. // was cleared in this mutation.
  26096. func (m *SopStageMutation) EdgeCleared(name string) bool {
  26097. switch name {
  26098. case sopstage.EdgeSopTask:
  26099. return m.clearedsop_task
  26100. case sopstage.EdgeStageNodes:
  26101. return m.clearedstage_nodes
  26102. case sopstage.EdgeStageMessages:
  26103. return m.clearedstage_messages
  26104. }
  26105. return false
  26106. }
  26107. // ClearEdge clears the value of the edge with the given name. It returns an error
  26108. // if that edge is not defined in the schema.
  26109. func (m *SopStageMutation) ClearEdge(name string) error {
  26110. switch name {
  26111. case sopstage.EdgeSopTask:
  26112. m.ClearSopTask()
  26113. return nil
  26114. }
  26115. return fmt.Errorf("unknown SopStage unique edge %s", name)
  26116. }
  26117. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26118. // It returns an error if the edge is not defined in the schema.
  26119. func (m *SopStageMutation) ResetEdge(name string) error {
  26120. switch name {
  26121. case sopstage.EdgeSopTask:
  26122. m.ResetSopTask()
  26123. return nil
  26124. case sopstage.EdgeStageNodes:
  26125. m.ResetStageNodes()
  26126. return nil
  26127. case sopstage.EdgeStageMessages:
  26128. m.ResetStageMessages()
  26129. return nil
  26130. }
  26131. return fmt.Errorf("unknown SopStage edge %s", name)
  26132. }
  26133. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  26134. type SopTaskMutation struct {
  26135. config
  26136. op Op
  26137. typ string
  26138. id *uint64
  26139. created_at *time.Time
  26140. updated_at *time.Time
  26141. status *uint8
  26142. addstatus *int8
  26143. deleted_at *time.Time
  26144. name *string
  26145. bot_wxid_list *[]string
  26146. appendbot_wxid_list []string
  26147. _type *int
  26148. add_type *int
  26149. plan_start_time *time.Time
  26150. plan_end_time *time.Time
  26151. creator_id *string
  26152. organization_id *uint64
  26153. addorganization_id *int64
  26154. token *[]string
  26155. appendtoken []string
  26156. clearedFields map[string]struct{}
  26157. task_stages map[uint64]struct{}
  26158. removedtask_stages map[uint64]struct{}
  26159. clearedtask_stages bool
  26160. done bool
  26161. oldValue func(context.Context) (*SopTask, error)
  26162. predicates []predicate.SopTask
  26163. }
  26164. var _ ent.Mutation = (*SopTaskMutation)(nil)
  26165. // soptaskOption allows management of the mutation configuration using functional options.
  26166. type soptaskOption func(*SopTaskMutation)
  26167. // newSopTaskMutation creates new mutation for the SopTask entity.
  26168. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  26169. m := &SopTaskMutation{
  26170. config: c,
  26171. op: op,
  26172. typ: TypeSopTask,
  26173. clearedFields: make(map[string]struct{}),
  26174. }
  26175. for _, opt := range opts {
  26176. opt(m)
  26177. }
  26178. return m
  26179. }
  26180. // withSopTaskID sets the ID field of the mutation.
  26181. func withSopTaskID(id uint64) soptaskOption {
  26182. return func(m *SopTaskMutation) {
  26183. var (
  26184. err error
  26185. once sync.Once
  26186. value *SopTask
  26187. )
  26188. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  26189. once.Do(func() {
  26190. if m.done {
  26191. err = errors.New("querying old values post mutation is not allowed")
  26192. } else {
  26193. value, err = m.Client().SopTask.Get(ctx, id)
  26194. }
  26195. })
  26196. return value, err
  26197. }
  26198. m.id = &id
  26199. }
  26200. }
  26201. // withSopTask sets the old SopTask of the mutation.
  26202. func withSopTask(node *SopTask) soptaskOption {
  26203. return func(m *SopTaskMutation) {
  26204. m.oldValue = func(context.Context) (*SopTask, error) {
  26205. return node, nil
  26206. }
  26207. m.id = &node.ID
  26208. }
  26209. }
  26210. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26211. // executed in a transaction (ent.Tx), a transactional client is returned.
  26212. func (m SopTaskMutation) Client() *Client {
  26213. client := &Client{config: m.config}
  26214. client.init()
  26215. return client
  26216. }
  26217. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26218. // it returns an error otherwise.
  26219. func (m SopTaskMutation) Tx() (*Tx, error) {
  26220. if _, ok := m.driver.(*txDriver); !ok {
  26221. return nil, errors.New("ent: mutation is not running in a transaction")
  26222. }
  26223. tx := &Tx{config: m.config}
  26224. tx.init()
  26225. return tx, nil
  26226. }
  26227. // SetID sets the value of the id field. Note that this
  26228. // operation is only accepted on creation of SopTask entities.
  26229. func (m *SopTaskMutation) SetID(id uint64) {
  26230. m.id = &id
  26231. }
  26232. // ID returns the ID value in the mutation. Note that the ID is only available
  26233. // if it was provided to the builder or after it was returned from the database.
  26234. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  26235. if m.id == nil {
  26236. return
  26237. }
  26238. return *m.id, true
  26239. }
  26240. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26241. // That means, if the mutation is applied within a transaction with an isolation level such
  26242. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26243. // or updated by the mutation.
  26244. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  26245. switch {
  26246. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26247. id, exists := m.ID()
  26248. if exists {
  26249. return []uint64{id}, nil
  26250. }
  26251. fallthrough
  26252. case m.op.Is(OpUpdate | OpDelete):
  26253. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  26254. default:
  26255. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26256. }
  26257. }
  26258. // SetCreatedAt sets the "created_at" field.
  26259. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  26260. m.created_at = &t
  26261. }
  26262. // CreatedAt returns the value of the "created_at" field in the mutation.
  26263. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  26264. v := m.created_at
  26265. if v == nil {
  26266. return
  26267. }
  26268. return *v, true
  26269. }
  26270. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  26271. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26273. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26274. if !m.op.Is(OpUpdateOne) {
  26275. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26276. }
  26277. if m.id == nil || m.oldValue == nil {
  26278. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26279. }
  26280. oldValue, err := m.oldValue(ctx)
  26281. if err != nil {
  26282. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26283. }
  26284. return oldValue.CreatedAt, nil
  26285. }
  26286. // ResetCreatedAt resets all changes to the "created_at" field.
  26287. func (m *SopTaskMutation) ResetCreatedAt() {
  26288. m.created_at = nil
  26289. }
  26290. // SetUpdatedAt sets the "updated_at" field.
  26291. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  26292. m.updated_at = &t
  26293. }
  26294. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26295. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  26296. v := m.updated_at
  26297. if v == nil {
  26298. return
  26299. }
  26300. return *v, true
  26301. }
  26302. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  26303. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26305. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26306. if !m.op.Is(OpUpdateOne) {
  26307. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26308. }
  26309. if m.id == nil || m.oldValue == nil {
  26310. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26311. }
  26312. oldValue, err := m.oldValue(ctx)
  26313. if err != nil {
  26314. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26315. }
  26316. return oldValue.UpdatedAt, nil
  26317. }
  26318. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26319. func (m *SopTaskMutation) ResetUpdatedAt() {
  26320. m.updated_at = nil
  26321. }
  26322. // SetStatus sets the "status" field.
  26323. func (m *SopTaskMutation) SetStatus(u uint8) {
  26324. m.status = &u
  26325. m.addstatus = nil
  26326. }
  26327. // Status returns the value of the "status" field in the mutation.
  26328. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  26329. v := m.status
  26330. if v == nil {
  26331. return
  26332. }
  26333. return *v, true
  26334. }
  26335. // OldStatus returns the old "status" field's value of the SopTask entity.
  26336. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26338. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26339. if !m.op.Is(OpUpdateOne) {
  26340. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26341. }
  26342. if m.id == nil || m.oldValue == nil {
  26343. return v, errors.New("OldStatus requires an ID field in the mutation")
  26344. }
  26345. oldValue, err := m.oldValue(ctx)
  26346. if err != nil {
  26347. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26348. }
  26349. return oldValue.Status, nil
  26350. }
  26351. // AddStatus adds u to the "status" field.
  26352. func (m *SopTaskMutation) AddStatus(u int8) {
  26353. if m.addstatus != nil {
  26354. *m.addstatus += u
  26355. } else {
  26356. m.addstatus = &u
  26357. }
  26358. }
  26359. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26360. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  26361. v := m.addstatus
  26362. if v == nil {
  26363. return
  26364. }
  26365. return *v, true
  26366. }
  26367. // ClearStatus clears the value of the "status" field.
  26368. func (m *SopTaskMutation) ClearStatus() {
  26369. m.status = nil
  26370. m.addstatus = nil
  26371. m.clearedFields[soptask.FieldStatus] = struct{}{}
  26372. }
  26373. // StatusCleared returns if the "status" field was cleared in this mutation.
  26374. func (m *SopTaskMutation) StatusCleared() bool {
  26375. _, ok := m.clearedFields[soptask.FieldStatus]
  26376. return ok
  26377. }
  26378. // ResetStatus resets all changes to the "status" field.
  26379. func (m *SopTaskMutation) ResetStatus() {
  26380. m.status = nil
  26381. m.addstatus = nil
  26382. delete(m.clearedFields, soptask.FieldStatus)
  26383. }
  26384. // SetDeletedAt sets the "deleted_at" field.
  26385. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  26386. m.deleted_at = &t
  26387. }
  26388. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26389. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  26390. v := m.deleted_at
  26391. if v == nil {
  26392. return
  26393. }
  26394. return *v, true
  26395. }
  26396. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  26397. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26399. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26400. if !m.op.Is(OpUpdateOne) {
  26401. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26402. }
  26403. if m.id == nil || m.oldValue == nil {
  26404. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26405. }
  26406. oldValue, err := m.oldValue(ctx)
  26407. if err != nil {
  26408. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26409. }
  26410. return oldValue.DeletedAt, nil
  26411. }
  26412. // ClearDeletedAt clears the value of the "deleted_at" field.
  26413. func (m *SopTaskMutation) ClearDeletedAt() {
  26414. m.deleted_at = nil
  26415. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  26416. }
  26417. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26418. func (m *SopTaskMutation) DeletedAtCleared() bool {
  26419. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  26420. return ok
  26421. }
  26422. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26423. func (m *SopTaskMutation) ResetDeletedAt() {
  26424. m.deleted_at = nil
  26425. delete(m.clearedFields, soptask.FieldDeletedAt)
  26426. }
  26427. // SetName sets the "name" field.
  26428. func (m *SopTaskMutation) SetName(s string) {
  26429. m.name = &s
  26430. }
  26431. // Name returns the value of the "name" field in the mutation.
  26432. func (m *SopTaskMutation) Name() (r string, exists bool) {
  26433. v := m.name
  26434. if v == nil {
  26435. return
  26436. }
  26437. return *v, true
  26438. }
  26439. // OldName returns the old "name" field's value of the SopTask entity.
  26440. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26442. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  26443. if !m.op.Is(OpUpdateOne) {
  26444. return v, errors.New("OldName is only allowed on UpdateOne operations")
  26445. }
  26446. if m.id == nil || m.oldValue == nil {
  26447. return v, errors.New("OldName requires an ID field in the mutation")
  26448. }
  26449. oldValue, err := m.oldValue(ctx)
  26450. if err != nil {
  26451. return v, fmt.Errorf("querying old value for OldName: %w", err)
  26452. }
  26453. return oldValue.Name, nil
  26454. }
  26455. // ResetName resets all changes to the "name" field.
  26456. func (m *SopTaskMutation) ResetName() {
  26457. m.name = nil
  26458. }
  26459. // SetBotWxidList sets the "bot_wxid_list" field.
  26460. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  26461. m.bot_wxid_list = &s
  26462. m.appendbot_wxid_list = nil
  26463. }
  26464. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  26465. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  26466. v := m.bot_wxid_list
  26467. if v == nil {
  26468. return
  26469. }
  26470. return *v, true
  26471. }
  26472. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  26473. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26475. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  26476. if !m.op.Is(OpUpdateOne) {
  26477. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  26478. }
  26479. if m.id == nil || m.oldValue == nil {
  26480. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  26481. }
  26482. oldValue, err := m.oldValue(ctx)
  26483. if err != nil {
  26484. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  26485. }
  26486. return oldValue.BotWxidList, nil
  26487. }
  26488. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  26489. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  26490. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  26491. }
  26492. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  26493. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  26494. if len(m.appendbot_wxid_list) == 0 {
  26495. return nil, false
  26496. }
  26497. return m.appendbot_wxid_list, true
  26498. }
  26499. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  26500. func (m *SopTaskMutation) ClearBotWxidList() {
  26501. m.bot_wxid_list = nil
  26502. m.appendbot_wxid_list = nil
  26503. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  26504. }
  26505. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  26506. func (m *SopTaskMutation) BotWxidListCleared() bool {
  26507. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  26508. return ok
  26509. }
  26510. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  26511. func (m *SopTaskMutation) ResetBotWxidList() {
  26512. m.bot_wxid_list = nil
  26513. m.appendbot_wxid_list = nil
  26514. delete(m.clearedFields, soptask.FieldBotWxidList)
  26515. }
  26516. // SetType sets the "type" field.
  26517. func (m *SopTaskMutation) SetType(i int) {
  26518. m._type = &i
  26519. m.add_type = nil
  26520. }
  26521. // GetType returns the value of the "type" field in the mutation.
  26522. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  26523. v := m._type
  26524. if v == nil {
  26525. return
  26526. }
  26527. return *v, true
  26528. }
  26529. // OldType returns the old "type" field's value of the SopTask entity.
  26530. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26532. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  26533. if !m.op.Is(OpUpdateOne) {
  26534. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26535. }
  26536. if m.id == nil || m.oldValue == nil {
  26537. return v, errors.New("OldType requires an ID field in the mutation")
  26538. }
  26539. oldValue, err := m.oldValue(ctx)
  26540. if err != nil {
  26541. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26542. }
  26543. return oldValue.Type, nil
  26544. }
  26545. // AddType adds i to the "type" field.
  26546. func (m *SopTaskMutation) AddType(i int) {
  26547. if m.add_type != nil {
  26548. *m.add_type += i
  26549. } else {
  26550. m.add_type = &i
  26551. }
  26552. }
  26553. // AddedType returns the value that was added to the "type" field in this mutation.
  26554. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  26555. v := m.add_type
  26556. if v == nil {
  26557. return
  26558. }
  26559. return *v, true
  26560. }
  26561. // ResetType resets all changes to the "type" field.
  26562. func (m *SopTaskMutation) ResetType() {
  26563. m._type = nil
  26564. m.add_type = nil
  26565. }
  26566. // SetPlanStartTime sets the "plan_start_time" field.
  26567. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  26568. m.plan_start_time = &t
  26569. }
  26570. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  26571. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  26572. v := m.plan_start_time
  26573. if v == nil {
  26574. return
  26575. }
  26576. return *v, true
  26577. }
  26578. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  26579. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26581. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  26582. if !m.op.Is(OpUpdateOne) {
  26583. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  26584. }
  26585. if m.id == nil || m.oldValue == nil {
  26586. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  26587. }
  26588. oldValue, err := m.oldValue(ctx)
  26589. if err != nil {
  26590. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  26591. }
  26592. return oldValue.PlanStartTime, nil
  26593. }
  26594. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  26595. func (m *SopTaskMutation) ClearPlanStartTime() {
  26596. m.plan_start_time = nil
  26597. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  26598. }
  26599. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  26600. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  26601. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  26602. return ok
  26603. }
  26604. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  26605. func (m *SopTaskMutation) ResetPlanStartTime() {
  26606. m.plan_start_time = nil
  26607. delete(m.clearedFields, soptask.FieldPlanStartTime)
  26608. }
  26609. // SetPlanEndTime sets the "plan_end_time" field.
  26610. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  26611. m.plan_end_time = &t
  26612. }
  26613. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  26614. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  26615. v := m.plan_end_time
  26616. if v == nil {
  26617. return
  26618. }
  26619. return *v, true
  26620. }
  26621. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  26622. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26624. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  26625. if !m.op.Is(OpUpdateOne) {
  26626. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  26627. }
  26628. if m.id == nil || m.oldValue == nil {
  26629. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  26630. }
  26631. oldValue, err := m.oldValue(ctx)
  26632. if err != nil {
  26633. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  26634. }
  26635. return oldValue.PlanEndTime, nil
  26636. }
  26637. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  26638. func (m *SopTaskMutation) ClearPlanEndTime() {
  26639. m.plan_end_time = nil
  26640. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  26641. }
  26642. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  26643. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  26644. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  26645. return ok
  26646. }
  26647. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  26648. func (m *SopTaskMutation) ResetPlanEndTime() {
  26649. m.plan_end_time = nil
  26650. delete(m.clearedFields, soptask.FieldPlanEndTime)
  26651. }
  26652. // SetCreatorID sets the "creator_id" field.
  26653. func (m *SopTaskMutation) SetCreatorID(s string) {
  26654. m.creator_id = &s
  26655. }
  26656. // CreatorID returns the value of the "creator_id" field in the mutation.
  26657. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  26658. v := m.creator_id
  26659. if v == nil {
  26660. return
  26661. }
  26662. return *v, true
  26663. }
  26664. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  26665. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26667. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  26668. if !m.op.Is(OpUpdateOne) {
  26669. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  26670. }
  26671. if m.id == nil || m.oldValue == nil {
  26672. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  26673. }
  26674. oldValue, err := m.oldValue(ctx)
  26675. if err != nil {
  26676. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  26677. }
  26678. return oldValue.CreatorID, nil
  26679. }
  26680. // ClearCreatorID clears the value of the "creator_id" field.
  26681. func (m *SopTaskMutation) ClearCreatorID() {
  26682. m.creator_id = nil
  26683. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  26684. }
  26685. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  26686. func (m *SopTaskMutation) CreatorIDCleared() bool {
  26687. _, ok := m.clearedFields[soptask.FieldCreatorID]
  26688. return ok
  26689. }
  26690. // ResetCreatorID resets all changes to the "creator_id" field.
  26691. func (m *SopTaskMutation) ResetCreatorID() {
  26692. m.creator_id = nil
  26693. delete(m.clearedFields, soptask.FieldCreatorID)
  26694. }
  26695. // SetOrganizationID sets the "organization_id" field.
  26696. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  26697. m.organization_id = &u
  26698. m.addorganization_id = nil
  26699. }
  26700. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26701. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  26702. v := m.organization_id
  26703. if v == nil {
  26704. return
  26705. }
  26706. return *v, true
  26707. }
  26708. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  26709. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26711. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26712. if !m.op.Is(OpUpdateOne) {
  26713. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26714. }
  26715. if m.id == nil || m.oldValue == nil {
  26716. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26717. }
  26718. oldValue, err := m.oldValue(ctx)
  26719. if err != nil {
  26720. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26721. }
  26722. return oldValue.OrganizationID, nil
  26723. }
  26724. // AddOrganizationID adds u to the "organization_id" field.
  26725. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  26726. if m.addorganization_id != nil {
  26727. *m.addorganization_id += u
  26728. } else {
  26729. m.addorganization_id = &u
  26730. }
  26731. }
  26732. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26733. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  26734. v := m.addorganization_id
  26735. if v == nil {
  26736. return
  26737. }
  26738. return *v, true
  26739. }
  26740. // ClearOrganizationID clears the value of the "organization_id" field.
  26741. func (m *SopTaskMutation) ClearOrganizationID() {
  26742. m.organization_id = nil
  26743. m.addorganization_id = nil
  26744. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  26745. }
  26746. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26747. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  26748. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  26749. return ok
  26750. }
  26751. // ResetOrganizationID resets all changes to the "organization_id" field.
  26752. func (m *SopTaskMutation) ResetOrganizationID() {
  26753. m.organization_id = nil
  26754. m.addorganization_id = nil
  26755. delete(m.clearedFields, soptask.FieldOrganizationID)
  26756. }
  26757. // SetToken sets the "token" field.
  26758. func (m *SopTaskMutation) SetToken(s []string) {
  26759. m.token = &s
  26760. m.appendtoken = nil
  26761. }
  26762. // Token returns the value of the "token" field in the mutation.
  26763. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  26764. v := m.token
  26765. if v == nil {
  26766. return
  26767. }
  26768. return *v, true
  26769. }
  26770. // OldToken returns the old "token" field's value of the SopTask entity.
  26771. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  26772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26773. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  26774. if !m.op.Is(OpUpdateOne) {
  26775. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  26776. }
  26777. if m.id == nil || m.oldValue == nil {
  26778. return v, errors.New("OldToken requires an ID field in the mutation")
  26779. }
  26780. oldValue, err := m.oldValue(ctx)
  26781. if err != nil {
  26782. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  26783. }
  26784. return oldValue.Token, nil
  26785. }
  26786. // AppendToken adds s to the "token" field.
  26787. func (m *SopTaskMutation) AppendToken(s []string) {
  26788. m.appendtoken = append(m.appendtoken, s...)
  26789. }
  26790. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  26791. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  26792. if len(m.appendtoken) == 0 {
  26793. return nil, false
  26794. }
  26795. return m.appendtoken, true
  26796. }
  26797. // ClearToken clears the value of the "token" field.
  26798. func (m *SopTaskMutation) ClearToken() {
  26799. m.token = nil
  26800. m.appendtoken = nil
  26801. m.clearedFields[soptask.FieldToken] = struct{}{}
  26802. }
  26803. // TokenCleared returns if the "token" field was cleared in this mutation.
  26804. func (m *SopTaskMutation) TokenCleared() bool {
  26805. _, ok := m.clearedFields[soptask.FieldToken]
  26806. return ok
  26807. }
  26808. // ResetToken resets all changes to the "token" field.
  26809. func (m *SopTaskMutation) ResetToken() {
  26810. m.token = nil
  26811. m.appendtoken = nil
  26812. delete(m.clearedFields, soptask.FieldToken)
  26813. }
  26814. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  26815. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  26816. if m.task_stages == nil {
  26817. m.task_stages = make(map[uint64]struct{})
  26818. }
  26819. for i := range ids {
  26820. m.task_stages[ids[i]] = struct{}{}
  26821. }
  26822. }
  26823. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  26824. func (m *SopTaskMutation) ClearTaskStages() {
  26825. m.clearedtask_stages = true
  26826. }
  26827. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  26828. func (m *SopTaskMutation) TaskStagesCleared() bool {
  26829. return m.clearedtask_stages
  26830. }
  26831. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  26832. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  26833. if m.removedtask_stages == nil {
  26834. m.removedtask_stages = make(map[uint64]struct{})
  26835. }
  26836. for i := range ids {
  26837. delete(m.task_stages, ids[i])
  26838. m.removedtask_stages[ids[i]] = struct{}{}
  26839. }
  26840. }
  26841. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  26842. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  26843. for id := range m.removedtask_stages {
  26844. ids = append(ids, id)
  26845. }
  26846. return
  26847. }
  26848. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  26849. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  26850. for id := range m.task_stages {
  26851. ids = append(ids, id)
  26852. }
  26853. return
  26854. }
  26855. // ResetTaskStages resets all changes to the "task_stages" edge.
  26856. func (m *SopTaskMutation) ResetTaskStages() {
  26857. m.task_stages = nil
  26858. m.clearedtask_stages = false
  26859. m.removedtask_stages = nil
  26860. }
  26861. // Where appends a list predicates to the SopTaskMutation builder.
  26862. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  26863. m.predicates = append(m.predicates, ps...)
  26864. }
  26865. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  26866. // users can use type-assertion to append predicates that do not depend on any generated package.
  26867. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  26868. p := make([]predicate.SopTask, len(ps))
  26869. for i := range ps {
  26870. p[i] = ps[i]
  26871. }
  26872. m.Where(p...)
  26873. }
  26874. // Op returns the operation name.
  26875. func (m *SopTaskMutation) Op() Op {
  26876. return m.op
  26877. }
  26878. // SetOp allows setting the mutation operation.
  26879. func (m *SopTaskMutation) SetOp(op Op) {
  26880. m.op = op
  26881. }
  26882. // Type returns the node type of this mutation (SopTask).
  26883. func (m *SopTaskMutation) Type() string {
  26884. return m.typ
  26885. }
  26886. // Fields returns all fields that were changed during this mutation. Note that in
  26887. // order to get all numeric fields that were incremented/decremented, call
  26888. // AddedFields().
  26889. func (m *SopTaskMutation) Fields() []string {
  26890. fields := make([]string, 0, 12)
  26891. if m.created_at != nil {
  26892. fields = append(fields, soptask.FieldCreatedAt)
  26893. }
  26894. if m.updated_at != nil {
  26895. fields = append(fields, soptask.FieldUpdatedAt)
  26896. }
  26897. if m.status != nil {
  26898. fields = append(fields, soptask.FieldStatus)
  26899. }
  26900. if m.deleted_at != nil {
  26901. fields = append(fields, soptask.FieldDeletedAt)
  26902. }
  26903. if m.name != nil {
  26904. fields = append(fields, soptask.FieldName)
  26905. }
  26906. if m.bot_wxid_list != nil {
  26907. fields = append(fields, soptask.FieldBotWxidList)
  26908. }
  26909. if m._type != nil {
  26910. fields = append(fields, soptask.FieldType)
  26911. }
  26912. if m.plan_start_time != nil {
  26913. fields = append(fields, soptask.FieldPlanStartTime)
  26914. }
  26915. if m.plan_end_time != nil {
  26916. fields = append(fields, soptask.FieldPlanEndTime)
  26917. }
  26918. if m.creator_id != nil {
  26919. fields = append(fields, soptask.FieldCreatorID)
  26920. }
  26921. if m.organization_id != nil {
  26922. fields = append(fields, soptask.FieldOrganizationID)
  26923. }
  26924. if m.token != nil {
  26925. fields = append(fields, soptask.FieldToken)
  26926. }
  26927. return fields
  26928. }
  26929. // Field returns the value of a field with the given name. The second boolean
  26930. // return value indicates that this field was not set, or was not defined in the
  26931. // schema.
  26932. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  26933. switch name {
  26934. case soptask.FieldCreatedAt:
  26935. return m.CreatedAt()
  26936. case soptask.FieldUpdatedAt:
  26937. return m.UpdatedAt()
  26938. case soptask.FieldStatus:
  26939. return m.Status()
  26940. case soptask.FieldDeletedAt:
  26941. return m.DeletedAt()
  26942. case soptask.FieldName:
  26943. return m.Name()
  26944. case soptask.FieldBotWxidList:
  26945. return m.BotWxidList()
  26946. case soptask.FieldType:
  26947. return m.GetType()
  26948. case soptask.FieldPlanStartTime:
  26949. return m.PlanStartTime()
  26950. case soptask.FieldPlanEndTime:
  26951. return m.PlanEndTime()
  26952. case soptask.FieldCreatorID:
  26953. return m.CreatorID()
  26954. case soptask.FieldOrganizationID:
  26955. return m.OrganizationID()
  26956. case soptask.FieldToken:
  26957. return m.Token()
  26958. }
  26959. return nil, false
  26960. }
  26961. // OldField returns the old value of the field from the database. An error is
  26962. // returned if the mutation operation is not UpdateOne, or the query to the
  26963. // database failed.
  26964. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26965. switch name {
  26966. case soptask.FieldCreatedAt:
  26967. return m.OldCreatedAt(ctx)
  26968. case soptask.FieldUpdatedAt:
  26969. return m.OldUpdatedAt(ctx)
  26970. case soptask.FieldStatus:
  26971. return m.OldStatus(ctx)
  26972. case soptask.FieldDeletedAt:
  26973. return m.OldDeletedAt(ctx)
  26974. case soptask.FieldName:
  26975. return m.OldName(ctx)
  26976. case soptask.FieldBotWxidList:
  26977. return m.OldBotWxidList(ctx)
  26978. case soptask.FieldType:
  26979. return m.OldType(ctx)
  26980. case soptask.FieldPlanStartTime:
  26981. return m.OldPlanStartTime(ctx)
  26982. case soptask.FieldPlanEndTime:
  26983. return m.OldPlanEndTime(ctx)
  26984. case soptask.FieldCreatorID:
  26985. return m.OldCreatorID(ctx)
  26986. case soptask.FieldOrganizationID:
  26987. return m.OldOrganizationID(ctx)
  26988. case soptask.FieldToken:
  26989. return m.OldToken(ctx)
  26990. }
  26991. return nil, fmt.Errorf("unknown SopTask field %s", name)
  26992. }
  26993. // SetField sets the value of a field with the given name. It returns an error if
  26994. // the field is not defined in the schema, or if the type mismatched the field
  26995. // type.
  26996. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  26997. switch name {
  26998. case soptask.FieldCreatedAt:
  26999. v, ok := value.(time.Time)
  27000. if !ok {
  27001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27002. }
  27003. m.SetCreatedAt(v)
  27004. return nil
  27005. case soptask.FieldUpdatedAt:
  27006. v, ok := value.(time.Time)
  27007. if !ok {
  27008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27009. }
  27010. m.SetUpdatedAt(v)
  27011. return nil
  27012. case soptask.FieldStatus:
  27013. v, ok := value.(uint8)
  27014. if !ok {
  27015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27016. }
  27017. m.SetStatus(v)
  27018. return nil
  27019. case soptask.FieldDeletedAt:
  27020. v, ok := value.(time.Time)
  27021. if !ok {
  27022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27023. }
  27024. m.SetDeletedAt(v)
  27025. return nil
  27026. case soptask.FieldName:
  27027. v, ok := value.(string)
  27028. if !ok {
  27029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27030. }
  27031. m.SetName(v)
  27032. return nil
  27033. case soptask.FieldBotWxidList:
  27034. v, ok := value.([]string)
  27035. if !ok {
  27036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27037. }
  27038. m.SetBotWxidList(v)
  27039. return nil
  27040. case soptask.FieldType:
  27041. v, ok := value.(int)
  27042. if !ok {
  27043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27044. }
  27045. m.SetType(v)
  27046. return nil
  27047. case soptask.FieldPlanStartTime:
  27048. v, ok := value.(time.Time)
  27049. if !ok {
  27050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27051. }
  27052. m.SetPlanStartTime(v)
  27053. return nil
  27054. case soptask.FieldPlanEndTime:
  27055. v, ok := value.(time.Time)
  27056. if !ok {
  27057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27058. }
  27059. m.SetPlanEndTime(v)
  27060. return nil
  27061. case soptask.FieldCreatorID:
  27062. v, ok := value.(string)
  27063. if !ok {
  27064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27065. }
  27066. m.SetCreatorID(v)
  27067. return nil
  27068. case soptask.FieldOrganizationID:
  27069. v, ok := value.(uint64)
  27070. if !ok {
  27071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27072. }
  27073. m.SetOrganizationID(v)
  27074. return nil
  27075. case soptask.FieldToken:
  27076. v, ok := value.([]string)
  27077. if !ok {
  27078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27079. }
  27080. m.SetToken(v)
  27081. return nil
  27082. }
  27083. return fmt.Errorf("unknown SopTask field %s", name)
  27084. }
  27085. // AddedFields returns all numeric fields that were incremented/decremented during
  27086. // this mutation.
  27087. func (m *SopTaskMutation) AddedFields() []string {
  27088. var fields []string
  27089. if m.addstatus != nil {
  27090. fields = append(fields, soptask.FieldStatus)
  27091. }
  27092. if m.add_type != nil {
  27093. fields = append(fields, soptask.FieldType)
  27094. }
  27095. if m.addorganization_id != nil {
  27096. fields = append(fields, soptask.FieldOrganizationID)
  27097. }
  27098. return fields
  27099. }
  27100. // AddedField returns the numeric value that was incremented/decremented on a field
  27101. // with the given name. The second boolean return value indicates that this field
  27102. // was not set, or was not defined in the schema.
  27103. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  27104. switch name {
  27105. case soptask.FieldStatus:
  27106. return m.AddedStatus()
  27107. case soptask.FieldType:
  27108. return m.AddedType()
  27109. case soptask.FieldOrganizationID:
  27110. return m.AddedOrganizationID()
  27111. }
  27112. return nil, false
  27113. }
  27114. // AddField adds the value to the field with the given name. It returns an error if
  27115. // the field is not defined in the schema, or if the type mismatched the field
  27116. // type.
  27117. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  27118. switch name {
  27119. case soptask.FieldStatus:
  27120. v, ok := value.(int8)
  27121. if !ok {
  27122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27123. }
  27124. m.AddStatus(v)
  27125. return nil
  27126. case soptask.FieldType:
  27127. v, ok := value.(int)
  27128. if !ok {
  27129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27130. }
  27131. m.AddType(v)
  27132. return nil
  27133. case soptask.FieldOrganizationID:
  27134. v, ok := value.(int64)
  27135. if !ok {
  27136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27137. }
  27138. m.AddOrganizationID(v)
  27139. return nil
  27140. }
  27141. return fmt.Errorf("unknown SopTask numeric field %s", name)
  27142. }
  27143. // ClearedFields returns all nullable fields that were cleared during this
  27144. // mutation.
  27145. func (m *SopTaskMutation) ClearedFields() []string {
  27146. var fields []string
  27147. if m.FieldCleared(soptask.FieldStatus) {
  27148. fields = append(fields, soptask.FieldStatus)
  27149. }
  27150. if m.FieldCleared(soptask.FieldDeletedAt) {
  27151. fields = append(fields, soptask.FieldDeletedAt)
  27152. }
  27153. if m.FieldCleared(soptask.FieldBotWxidList) {
  27154. fields = append(fields, soptask.FieldBotWxidList)
  27155. }
  27156. if m.FieldCleared(soptask.FieldPlanStartTime) {
  27157. fields = append(fields, soptask.FieldPlanStartTime)
  27158. }
  27159. if m.FieldCleared(soptask.FieldPlanEndTime) {
  27160. fields = append(fields, soptask.FieldPlanEndTime)
  27161. }
  27162. if m.FieldCleared(soptask.FieldCreatorID) {
  27163. fields = append(fields, soptask.FieldCreatorID)
  27164. }
  27165. if m.FieldCleared(soptask.FieldOrganizationID) {
  27166. fields = append(fields, soptask.FieldOrganizationID)
  27167. }
  27168. if m.FieldCleared(soptask.FieldToken) {
  27169. fields = append(fields, soptask.FieldToken)
  27170. }
  27171. return fields
  27172. }
  27173. // FieldCleared returns a boolean indicating if a field with the given name was
  27174. // cleared in this mutation.
  27175. func (m *SopTaskMutation) FieldCleared(name string) bool {
  27176. _, ok := m.clearedFields[name]
  27177. return ok
  27178. }
  27179. // ClearField clears the value of the field with the given name. It returns an
  27180. // error if the field is not defined in the schema.
  27181. func (m *SopTaskMutation) ClearField(name string) error {
  27182. switch name {
  27183. case soptask.FieldStatus:
  27184. m.ClearStatus()
  27185. return nil
  27186. case soptask.FieldDeletedAt:
  27187. m.ClearDeletedAt()
  27188. return nil
  27189. case soptask.FieldBotWxidList:
  27190. m.ClearBotWxidList()
  27191. return nil
  27192. case soptask.FieldPlanStartTime:
  27193. m.ClearPlanStartTime()
  27194. return nil
  27195. case soptask.FieldPlanEndTime:
  27196. m.ClearPlanEndTime()
  27197. return nil
  27198. case soptask.FieldCreatorID:
  27199. m.ClearCreatorID()
  27200. return nil
  27201. case soptask.FieldOrganizationID:
  27202. m.ClearOrganizationID()
  27203. return nil
  27204. case soptask.FieldToken:
  27205. m.ClearToken()
  27206. return nil
  27207. }
  27208. return fmt.Errorf("unknown SopTask nullable field %s", name)
  27209. }
  27210. // ResetField resets all changes in the mutation for the field with the given name.
  27211. // It returns an error if the field is not defined in the schema.
  27212. func (m *SopTaskMutation) ResetField(name string) error {
  27213. switch name {
  27214. case soptask.FieldCreatedAt:
  27215. m.ResetCreatedAt()
  27216. return nil
  27217. case soptask.FieldUpdatedAt:
  27218. m.ResetUpdatedAt()
  27219. return nil
  27220. case soptask.FieldStatus:
  27221. m.ResetStatus()
  27222. return nil
  27223. case soptask.FieldDeletedAt:
  27224. m.ResetDeletedAt()
  27225. return nil
  27226. case soptask.FieldName:
  27227. m.ResetName()
  27228. return nil
  27229. case soptask.FieldBotWxidList:
  27230. m.ResetBotWxidList()
  27231. return nil
  27232. case soptask.FieldType:
  27233. m.ResetType()
  27234. return nil
  27235. case soptask.FieldPlanStartTime:
  27236. m.ResetPlanStartTime()
  27237. return nil
  27238. case soptask.FieldPlanEndTime:
  27239. m.ResetPlanEndTime()
  27240. return nil
  27241. case soptask.FieldCreatorID:
  27242. m.ResetCreatorID()
  27243. return nil
  27244. case soptask.FieldOrganizationID:
  27245. m.ResetOrganizationID()
  27246. return nil
  27247. case soptask.FieldToken:
  27248. m.ResetToken()
  27249. return nil
  27250. }
  27251. return fmt.Errorf("unknown SopTask field %s", name)
  27252. }
  27253. // AddedEdges returns all edge names that were set/added in this mutation.
  27254. func (m *SopTaskMutation) AddedEdges() []string {
  27255. edges := make([]string, 0, 1)
  27256. if m.task_stages != nil {
  27257. edges = append(edges, soptask.EdgeTaskStages)
  27258. }
  27259. return edges
  27260. }
  27261. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27262. // name in this mutation.
  27263. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  27264. switch name {
  27265. case soptask.EdgeTaskStages:
  27266. ids := make([]ent.Value, 0, len(m.task_stages))
  27267. for id := range m.task_stages {
  27268. ids = append(ids, id)
  27269. }
  27270. return ids
  27271. }
  27272. return nil
  27273. }
  27274. // RemovedEdges returns all edge names that were removed in this mutation.
  27275. func (m *SopTaskMutation) RemovedEdges() []string {
  27276. edges := make([]string, 0, 1)
  27277. if m.removedtask_stages != nil {
  27278. edges = append(edges, soptask.EdgeTaskStages)
  27279. }
  27280. return edges
  27281. }
  27282. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27283. // the given name in this mutation.
  27284. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  27285. switch name {
  27286. case soptask.EdgeTaskStages:
  27287. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  27288. for id := range m.removedtask_stages {
  27289. ids = append(ids, id)
  27290. }
  27291. return ids
  27292. }
  27293. return nil
  27294. }
  27295. // ClearedEdges returns all edge names that were cleared in this mutation.
  27296. func (m *SopTaskMutation) ClearedEdges() []string {
  27297. edges := make([]string, 0, 1)
  27298. if m.clearedtask_stages {
  27299. edges = append(edges, soptask.EdgeTaskStages)
  27300. }
  27301. return edges
  27302. }
  27303. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27304. // was cleared in this mutation.
  27305. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  27306. switch name {
  27307. case soptask.EdgeTaskStages:
  27308. return m.clearedtask_stages
  27309. }
  27310. return false
  27311. }
  27312. // ClearEdge clears the value of the edge with the given name. It returns an error
  27313. // if that edge is not defined in the schema.
  27314. func (m *SopTaskMutation) ClearEdge(name string) error {
  27315. switch name {
  27316. }
  27317. return fmt.Errorf("unknown SopTask unique edge %s", name)
  27318. }
  27319. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27320. // It returns an error if the edge is not defined in the schema.
  27321. func (m *SopTaskMutation) ResetEdge(name string) error {
  27322. switch name {
  27323. case soptask.EdgeTaskStages:
  27324. m.ResetTaskStages()
  27325. return nil
  27326. }
  27327. return fmt.Errorf("unknown SopTask edge %s", name)
  27328. }
  27329. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  27330. type TokenMutation struct {
  27331. config
  27332. op Op
  27333. typ string
  27334. id *uint64
  27335. created_at *time.Time
  27336. updated_at *time.Time
  27337. deleted_at *time.Time
  27338. expire_at *time.Time
  27339. token *string
  27340. mac *string
  27341. organization_id *uint64
  27342. addorganization_id *int64
  27343. custom_agent_base *string
  27344. custom_agent_key *string
  27345. openai_base *string
  27346. openai_key *string
  27347. clearedFields map[string]struct{}
  27348. agent *uint64
  27349. clearedagent bool
  27350. done bool
  27351. oldValue func(context.Context) (*Token, error)
  27352. predicates []predicate.Token
  27353. }
  27354. var _ ent.Mutation = (*TokenMutation)(nil)
  27355. // tokenOption allows management of the mutation configuration using functional options.
  27356. type tokenOption func(*TokenMutation)
  27357. // newTokenMutation creates new mutation for the Token entity.
  27358. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  27359. m := &TokenMutation{
  27360. config: c,
  27361. op: op,
  27362. typ: TypeToken,
  27363. clearedFields: make(map[string]struct{}),
  27364. }
  27365. for _, opt := range opts {
  27366. opt(m)
  27367. }
  27368. return m
  27369. }
  27370. // withTokenID sets the ID field of the mutation.
  27371. func withTokenID(id uint64) tokenOption {
  27372. return func(m *TokenMutation) {
  27373. var (
  27374. err error
  27375. once sync.Once
  27376. value *Token
  27377. )
  27378. m.oldValue = func(ctx context.Context) (*Token, error) {
  27379. once.Do(func() {
  27380. if m.done {
  27381. err = errors.New("querying old values post mutation is not allowed")
  27382. } else {
  27383. value, err = m.Client().Token.Get(ctx, id)
  27384. }
  27385. })
  27386. return value, err
  27387. }
  27388. m.id = &id
  27389. }
  27390. }
  27391. // withToken sets the old Token of the mutation.
  27392. func withToken(node *Token) tokenOption {
  27393. return func(m *TokenMutation) {
  27394. m.oldValue = func(context.Context) (*Token, error) {
  27395. return node, nil
  27396. }
  27397. m.id = &node.ID
  27398. }
  27399. }
  27400. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27401. // executed in a transaction (ent.Tx), a transactional client is returned.
  27402. func (m TokenMutation) Client() *Client {
  27403. client := &Client{config: m.config}
  27404. client.init()
  27405. return client
  27406. }
  27407. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27408. // it returns an error otherwise.
  27409. func (m TokenMutation) Tx() (*Tx, error) {
  27410. if _, ok := m.driver.(*txDriver); !ok {
  27411. return nil, errors.New("ent: mutation is not running in a transaction")
  27412. }
  27413. tx := &Tx{config: m.config}
  27414. tx.init()
  27415. return tx, nil
  27416. }
  27417. // SetID sets the value of the id field. Note that this
  27418. // operation is only accepted on creation of Token entities.
  27419. func (m *TokenMutation) SetID(id uint64) {
  27420. m.id = &id
  27421. }
  27422. // ID returns the ID value in the mutation. Note that the ID is only available
  27423. // if it was provided to the builder or after it was returned from the database.
  27424. func (m *TokenMutation) ID() (id uint64, exists bool) {
  27425. if m.id == nil {
  27426. return
  27427. }
  27428. return *m.id, true
  27429. }
  27430. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27431. // That means, if the mutation is applied within a transaction with an isolation level such
  27432. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27433. // or updated by the mutation.
  27434. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  27435. switch {
  27436. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27437. id, exists := m.ID()
  27438. if exists {
  27439. return []uint64{id}, nil
  27440. }
  27441. fallthrough
  27442. case m.op.Is(OpUpdate | OpDelete):
  27443. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  27444. default:
  27445. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27446. }
  27447. }
  27448. // SetCreatedAt sets the "created_at" field.
  27449. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  27450. m.created_at = &t
  27451. }
  27452. // CreatedAt returns the value of the "created_at" field in the mutation.
  27453. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  27454. v := m.created_at
  27455. if v == nil {
  27456. return
  27457. }
  27458. return *v, true
  27459. }
  27460. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  27461. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27463. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27464. if !m.op.Is(OpUpdateOne) {
  27465. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27466. }
  27467. if m.id == nil || m.oldValue == nil {
  27468. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27469. }
  27470. oldValue, err := m.oldValue(ctx)
  27471. if err != nil {
  27472. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27473. }
  27474. return oldValue.CreatedAt, nil
  27475. }
  27476. // ResetCreatedAt resets all changes to the "created_at" field.
  27477. func (m *TokenMutation) ResetCreatedAt() {
  27478. m.created_at = nil
  27479. }
  27480. // SetUpdatedAt sets the "updated_at" field.
  27481. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  27482. m.updated_at = &t
  27483. }
  27484. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27485. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  27486. v := m.updated_at
  27487. if v == nil {
  27488. return
  27489. }
  27490. return *v, true
  27491. }
  27492. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  27493. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27495. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27496. if !m.op.Is(OpUpdateOne) {
  27497. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27498. }
  27499. if m.id == nil || m.oldValue == nil {
  27500. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27501. }
  27502. oldValue, err := m.oldValue(ctx)
  27503. if err != nil {
  27504. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27505. }
  27506. return oldValue.UpdatedAt, nil
  27507. }
  27508. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27509. func (m *TokenMutation) ResetUpdatedAt() {
  27510. m.updated_at = nil
  27511. }
  27512. // SetDeletedAt sets the "deleted_at" field.
  27513. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  27514. m.deleted_at = &t
  27515. }
  27516. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27517. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  27518. v := m.deleted_at
  27519. if v == nil {
  27520. return
  27521. }
  27522. return *v, true
  27523. }
  27524. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  27525. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27527. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27528. if !m.op.Is(OpUpdateOne) {
  27529. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27530. }
  27531. if m.id == nil || m.oldValue == nil {
  27532. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27533. }
  27534. oldValue, err := m.oldValue(ctx)
  27535. if err != nil {
  27536. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27537. }
  27538. return oldValue.DeletedAt, nil
  27539. }
  27540. // ClearDeletedAt clears the value of the "deleted_at" field.
  27541. func (m *TokenMutation) ClearDeletedAt() {
  27542. m.deleted_at = nil
  27543. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  27544. }
  27545. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27546. func (m *TokenMutation) DeletedAtCleared() bool {
  27547. _, ok := m.clearedFields[token.FieldDeletedAt]
  27548. return ok
  27549. }
  27550. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27551. func (m *TokenMutation) ResetDeletedAt() {
  27552. m.deleted_at = nil
  27553. delete(m.clearedFields, token.FieldDeletedAt)
  27554. }
  27555. // SetExpireAt sets the "expire_at" field.
  27556. func (m *TokenMutation) SetExpireAt(t time.Time) {
  27557. m.expire_at = &t
  27558. }
  27559. // ExpireAt returns the value of the "expire_at" field in the mutation.
  27560. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  27561. v := m.expire_at
  27562. if v == nil {
  27563. return
  27564. }
  27565. return *v, true
  27566. }
  27567. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  27568. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27570. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  27571. if !m.op.Is(OpUpdateOne) {
  27572. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  27573. }
  27574. if m.id == nil || m.oldValue == nil {
  27575. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  27576. }
  27577. oldValue, err := m.oldValue(ctx)
  27578. if err != nil {
  27579. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  27580. }
  27581. return oldValue.ExpireAt, nil
  27582. }
  27583. // ClearExpireAt clears the value of the "expire_at" field.
  27584. func (m *TokenMutation) ClearExpireAt() {
  27585. m.expire_at = nil
  27586. m.clearedFields[token.FieldExpireAt] = struct{}{}
  27587. }
  27588. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  27589. func (m *TokenMutation) ExpireAtCleared() bool {
  27590. _, ok := m.clearedFields[token.FieldExpireAt]
  27591. return ok
  27592. }
  27593. // ResetExpireAt resets all changes to the "expire_at" field.
  27594. func (m *TokenMutation) ResetExpireAt() {
  27595. m.expire_at = nil
  27596. delete(m.clearedFields, token.FieldExpireAt)
  27597. }
  27598. // SetToken sets the "token" field.
  27599. func (m *TokenMutation) SetToken(s string) {
  27600. m.token = &s
  27601. }
  27602. // Token returns the value of the "token" field in the mutation.
  27603. func (m *TokenMutation) Token() (r string, exists bool) {
  27604. v := m.token
  27605. if v == nil {
  27606. return
  27607. }
  27608. return *v, true
  27609. }
  27610. // OldToken returns the old "token" field's value of the Token entity.
  27611. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27613. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  27614. if !m.op.Is(OpUpdateOne) {
  27615. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27616. }
  27617. if m.id == nil || m.oldValue == nil {
  27618. return v, errors.New("OldToken requires an ID field in the mutation")
  27619. }
  27620. oldValue, err := m.oldValue(ctx)
  27621. if err != nil {
  27622. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27623. }
  27624. return oldValue.Token, nil
  27625. }
  27626. // ClearToken clears the value of the "token" field.
  27627. func (m *TokenMutation) ClearToken() {
  27628. m.token = nil
  27629. m.clearedFields[token.FieldToken] = struct{}{}
  27630. }
  27631. // TokenCleared returns if the "token" field was cleared in this mutation.
  27632. func (m *TokenMutation) TokenCleared() bool {
  27633. _, ok := m.clearedFields[token.FieldToken]
  27634. return ok
  27635. }
  27636. // ResetToken resets all changes to the "token" field.
  27637. func (m *TokenMutation) ResetToken() {
  27638. m.token = nil
  27639. delete(m.clearedFields, token.FieldToken)
  27640. }
  27641. // SetMAC sets the "mac" field.
  27642. func (m *TokenMutation) SetMAC(s string) {
  27643. m.mac = &s
  27644. }
  27645. // MAC returns the value of the "mac" field in the mutation.
  27646. func (m *TokenMutation) MAC() (r string, exists bool) {
  27647. v := m.mac
  27648. if v == nil {
  27649. return
  27650. }
  27651. return *v, true
  27652. }
  27653. // OldMAC returns the old "mac" field's value of the Token entity.
  27654. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27656. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  27657. if !m.op.Is(OpUpdateOne) {
  27658. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  27659. }
  27660. if m.id == nil || m.oldValue == nil {
  27661. return v, errors.New("OldMAC requires an ID field in the mutation")
  27662. }
  27663. oldValue, err := m.oldValue(ctx)
  27664. if err != nil {
  27665. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  27666. }
  27667. return oldValue.MAC, nil
  27668. }
  27669. // ClearMAC clears the value of the "mac" field.
  27670. func (m *TokenMutation) ClearMAC() {
  27671. m.mac = nil
  27672. m.clearedFields[token.FieldMAC] = struct{}{}
  27673. }
  27674. // MACCleared returns if the "mac" field was cleared in this mutation.
  27675. func (m *TokenMutation) MACCleared() bool {
  27676. _, ok := m.clearedFields[token.FieldMAC]
  27677. return ok
  27678. }
  27679. // ResetMAC resets all changes to the "mac" field.
  27680. func (m *TokenMutation) ResetMAC() {
  27681. m.mac = nil
  27682. delete(m.clearedFields, token.FieldMAC)
  27683. }
  27684. // SetOrganizationID sets the "organization_id" field.
  27685. func (m *TokenMutation) SetOrganizationID(u uint64) {
  27686. m.organization_id = &u
  27687. m.addorganization_id = nil
  27688. }
  27689. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27690. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  27691. v := m.organization_id
  27692. if v == nil {
  27693. return
  27694. }
  27695. return *v, true
  27696. }
  27697. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  27698. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27700. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27701. if !m.op.Is(OpUpdateOne) {
  27702. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27703. }
  27704. if m.id == nil || m.oldValue == nil {
  27705. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27706. }
  27707. oldValue, err := m.oldValue(ctx)
  27708. if err != nil {
  27709. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27710. }
  27711. return oldValue.OrganizationID, nil
  27712. }
  27713. // AddOrganizationID adds u to the "organization_id" field.
  27714. func (m *TokenMutation) AddOrganizationID(u int64) {
  27715. if m.addorganization_id != nil {
  27716. *m.addorganization_id += u
  27717. } else {
  27718. m.addorganization_id = &u
  27719. }
  27720. }
  27721. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27722. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  27723. v := m.addorganization_id
  27724. if v == nil {
  27725. return
  27726. }
  27727. return *v, true
  27728. }
  27729. // ResetOrganizationID resets all changes to the "organization_id" field.
  27730. func (m *TokenMutation) ResetOrganizationID() {
  27731. m.organization_id = nil
  27732. m.addorganization_id = nil
  27733. }
  27734. // SetAgentID sets the "agent_id" field.
  27735. func (m *TokenMutation) SetAgentID(u uint64) {
  27736. m.agent = &u
  27737. }
  27738. // AgentID returns the value of the "agent_id" field in the mutation.
  27739. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  27740. v := m.agent
  27741. if v == nil {
  27742. return
  27743. }
  27744. return *v, true
  27745. }
  27746. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  27747. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27749. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  27750. if !m.op.Is(OpUpdateOne) {
  27751. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  27752. }
  27753. if m.id == nil || m.oldValue == nil {
  27754. return v, errors.New("OldAgentID requires an ID field in the mutation")
  27755. }
  27756. oldValue, err := m.oldValue(ctx)
  27757. if err != nil {
  27758. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  27759. }
  27760. return oldValue.AgentID, nil
  27761. }
  27762. // ResetAgentID resets all changes to the "agent_id" field.
  27763. func (m *TokenMutation) ResetAgentID() {
  27764. m.agent = nil
  27765. }
  27766. // SetCustomAgentBase sets the "custom_agent_base" field.
  27767. func (m *TokenMutation) SetCustomAgentBase(s string) {
  27768. m.custom_agent_base = &s
  27769. }
  27770. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  27771. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  27772. v := m.custom_agent_base
  27773. if v == nil {
  27774. return
  27775. }
  27776. return *v, true
  27777. }
  27778. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  27779. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27781. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  27782. if !m.op.Is(OpUpdateOne) {
  27783. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  27784. }
  27785. if m.id == nil || m.oldValue == nil {
  27786. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  27787. }
  27788. oldValue, err := m.oldValue(ctx)
  27789. if err != nil {
  27790. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  27791. }
  27792. return oldValue.CustomAgentBase, nil
  27793. }
  27794. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  27795. func (m *TokenMutation) ClearCustomAgentBase() {
  27796. m.custom_agent_base = nil
  27797. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  27798. }
  27799. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  27800. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  27801. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  27802. return ok
  27803. }
  27804. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  27805. func (m *TokenMutation) ResetCustomAgentBase() {
  27806. m.custom_agent_base = nil
  27807. delete(m.clearedFields, token.FieldCustomAgentBase)
  27808. }
  27809. // SetCustomAgentKey sets the "custom_agent_key" field.
  27810. func (m *TokenMutation) SetCustomAgentKey(s string) {
  27811. m.custom_agent_key = &s
  27812. }
  27813. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  27814. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  27815. v := m.custom_agent_key
  27816. if v == nil {
  27817. return
  27818. }
  27819. return *v, true
  27820. }
  27821. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  27822. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27824. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  27825. if !m.op.Is(OpUpdateOne) {
  27826. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  27827. }
  27828. if m.id == nil || m.oldValue == nil {
  27829. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  27830. }
  27831. oldValue, err := m.oldValue(ctx)
  27832. if err != nil {
  27833. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  27834. }
  27835. return oldValue.CustomAgentKey, nil
  27836. }
  27837. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  27838. func (m *TokenMutation) ClearCustomAgentKey() {
  27839. m.custom_agent_key = nil
  27840. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  27841. }
  27842. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  27843. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  27844. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  27845. return ok
  27846. }
  27847. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  27848. func (m *TokenMutation) ResetCustomAgentKey() {
  27849. m.custom_agent_key = nil
  27850. delete(m.clearedFields, token.FieldCustomAgentKey)
  27851. }
  27852. // SetOpenaiBase sets the "openai_base" field.
  27853. func (m *TokenMutation) SetOpenaiBase(s string) {
  27854. m.openai_base = &s
  27855. }
  27856. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  27857. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  27858. v := m.openai_base
  27859. if v == nil {
  27860. return
  27861. }
  27862. return *v, true
  27863. }
  27864. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  27865. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27867. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  27868. if !m.op.Is(OpUpdateOne) {
  27869. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  27870. }
  27871. if m.id == nil || m.oldValue == nil {
  27872. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  27873. }
  27874. oldValue, err := m.oldValue(ctx)
  27875. if err != nil {
  27876. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  27877. }
  27878. return oldValue.OpenaiBase, nil
  27879. }
  27880. // ClearOpenaiBase clears the value of the "openai_base" field.
  27881. func (m *TokenMutation) ClearOpenaiBase() {
  27882. m.openai_base = nil
  27883. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  27884. }
  27885. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  27886. func (m *TokenMutation) OpenaiBaseCleared() bool {
  27887. _, ok := m.clearedFields[token.FieldOpenaiBase]
  27888. return ok
  27889. }
  27890. // ResetOpenaiBase resets all changes to the "openai_base" field.
  27891. func (m *TokenMutation) ResetOpenaiBase() {
  27892. m.openai_base = nil
  27893. delete(m.clearedFields, token.FieldOpenaiBase)
  27894. }
  27895. // SetOpenaiKey sets the "openai_key" field.
  27896. func (m *TokenMutation) SetOpenaiKey(s string) {
  27897. m.openai_key = &s
  27898. }
  27899. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  27900. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  27901. v := m.openai_key
  27902. if v == nil {
  27903. return
  27904. }
  27905. return *v, true
  27906. }
  27907. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  27908. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  27909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27910. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  27911. if !m.op.Is(OpUpdateOne) {
  27912. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  27913. }
  27914. if m.id == nil || m.oldValue == nil {
  27915. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  27916. }
  27917. oldValue, err := m.oldValue(ctx)
  27918. if err != nil {
  27919. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  27920. }
  27921. return oldValue.OpenaiKey, nil
  27922. }
  27923. // ClearOpenaiKey clears the value of the "openai_key" field.
  27924. func (m *TokenMutation) ClearOpenaiKey() {
  27925. m.openai_key = nil
  27926. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  27927. }
  27928. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  27929. func (m *TokenMutation) OpenaiKeyCleared() bool {
  27930. _, ok := m.clearedFields[token.FieldOpenaiKey]
  27931. return ok
  27932. }
  27933. // ResetOpenaiKey resets all changes to the "openai_key" field.
  27934. func (m *TokenMutation) ResetOpenaiKey() {
  27935. m.openai_key = nil
  27936. delete(m.clearedFields, token.FieldOpenaiKey)
  27937. }
  27938. // ClearAgent clears the "agent" edge to the Agent entity.
  27939. func (m *TokenMutation) ClearAgent() {
  27940. m.clearedagent = true
  27941. m.clearedFields[token.FieldAgentID] = struct{}{}
  27942. }
  27943. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  27944. func (m *TokenMutation) AgentCleared() bool {
  27945. return m.clearedagent
  27946. }
  27947. // AgentIDs returns the "agent" edge IDs in the mutation.
  27948. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  27949. // AgentID instead. It exists only for internal usage by the builders.
  27950. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  27951. if id := m.agent; id != nil {
  27952. ids = append(ids, *id)
  27953. }
  27954. return
  27955. }
  27956. // ResetAgent resets all changes to the "agent" edge.
  27957. func (m *TokenMutation) ResetAgent() {
  27958. m.agent = nil
  27959. m.clearedagent = false
  27960. }
  27961. // Where appends a list predicates to the TokenMutation builder.
  27962. func (m *TokenMutation) Where(ps ...predicate.Token) {
  27963. m.predicates = append(m.predicates, ps...)
  27964. }
  27965. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  27966. // users can use type-assertion to append predicates that do not depend on any generated package.
  27967. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  27968. p := make([]predicate.Token, len(ps))
  27969. for i := range ps {
  27970. p[i] = ps[i]
  27971. }
  27972. m.Where(p...)
  27973. }
  27974. // Op returns the operation name.
  27975. func (m *TokenMutation) Op() Op {
  27976. return m.op
  27977. }
  27978. // SetOp allows setting the mutation operation.
  27979. func (m *TokenMutation) SetOp(op Op) {
  27980. m.op = op
  27981. }
  27982. // Type returns the node type of this mutation (Token).
  27983. func (m *TokenMutation) Type() string {
  27984. return m.typ
  27985. }
  27986. // Fields returns all fields that were changed during this mutation. Note that in
  27987. // order to get all numeric fields that were incremented/decremented, call
  27988. // AddedFields().
  27989. func (m *TokenMutation) Fields() []string {
  27990. fields := make([]string, 0, 12)
  27991. if m.created_at != nil {
  27992. fields = append(fields, token.FieldCreatedAt)
  27993. }
  27994. if m.updated_at != nil {
  27995. fields = append(fields, token.FieldUpdatedAt)
  27996. }
  27997. if m.deleted_at != nil {
  27998. fields = append(fields, token.FieldDeletedAt)
  27999. }
  28000. if m.expire_at != nil {
  28001. fields = append(fields, token.FieldExpireAt)
  28002. }
  28003. if m.token != nil {
  28004. fields = append(fields, token.FieldToken)
  28005. }
  28006. if m.mac != nil {
  28007. fields = append(fields, token.FieldMAC)
  28008. }
  28009. if m.organization_id != nil {
  28010. fields = append(fields, token.FieldOrganizationID)
  28011. }
  28012. if m.agent != nil {
  28013. fields = append(fields, token.FieldAgentID)
  28014. }
  28015. if m.custom_agent_base != nil {
  28016. fields = append(fields, token.FieldCustomAgentBase)
  28017. }
  28018. if m.custom_agent_key != nil {
  28019. fields = append(fields, token.FieldCustomAgentKey)
  28020. }
  28021. if m.openai_base != nil {
  28022. fields = append(fields, token.FieldOpenaiBase)
  28023. }
  28024. if m.openai_key != nil {
  28025. fields = append(fields, token.FieldOpenaiKey)
  28026. }
  28027. return fields
  28028. }
  28029. // Field returns the value of a field with the given name. The second boolean
  28030. // return value indicates that this field was not set, or was not defined in the
  28031. // schema.
  28032. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  28033. switch name {
  28034. case token.FieldCreatedAt:
  28035. return m.CreatedAt()
  28036. case token.FieldUpdatedAt:
  28037. return m.UpdatedAt()
  28038. case token.FieldDeletedAt:
  28039. return m.DeletedAt()
  28040. case token.FieldExpireAt:
  28041. return m.ExpireAt()
  28042. case token.FieldToken:
  28043. return m.Token()
  28044. case token.FieldMAC:
  28045. return m.MAC()
  28046. case token.FieldOrganizationID:
  28047. return m.OrganizationID()
  28048. case token.FieldAgentID:
  28049. return m.AgentID()
  28050. case token.FieldCustomAgentBase:
  28051. return m.CustomAgentBase()
  28052. case token.FieldCustomAgentKey:
  28053. return m.CustomAgentKey()
  28054. case token.FieldOpenaiBase:
  28055. return m.OpenaiBase()
  28056. case token.FieldOpenaiKey:
  28057. return m.OpenaiKey()
  28058. }
  28059. return nil, false
  28060. }
  28061. // OldField returns the old value of the field from the database. An error is
  28062. // returned if the mutation operation is not UpdateOne, or the query to the
  28063. // database failed.
  28064. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28065. switch name {
  28066. case token.FieldCreatedAt:
  28067. return m.OldCreatedAt(ctx)
  28068. case token.FieldUpdatedAt:
  28069. return m.OldUpdatedAt(ctx)
  28070. case token.FieldDeletedAt:
  28071. return m.OldDeletedAt(ctx)
  28072. case token.FieldExpireAt:
  28073. return m.OldExpireAt(ctx)
  28074. case token.FieldToken:
  28075. return m.OldToken(ctx)
  28076. case token.FieldMAC:
  28077. return m.OldMAC(ctx)
  28078. case token.FieldOrganizationID:
  28079. return m.OldOrganizationID(ctx)
  28080. case token.FieldAgentID:
  28081. return m.OldAgentID(ctx)
  28082. case token.FieldCustomAgentBase:
  28083. return m.OldCustomAgentBase(ctx)
  28084. case token.FieldCustomAgentKey:
  28085. return m.OldCustomAgentKey(ctx)
  28086. case token.FieldOpenaiBase:
  28087. return m.OldOpenaiBase(ctx)
  28088. case token.FieldOpenaiKey:
  28089. return m.OldOpenaiKey(ctx)
  28090. }
  28091. return nil, fmt.Errorf("unknown Token field %s", name)
  28092. }
  28093. // SetField sets the value of a field with the given name. It returns an error if
  28094. // the field is not defined in the schema, or if the type mismatched the field
  28095. // type.
  28096. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  28097. switch name {
  28098. case token.FieldCreatedAt:
  28099. v, ok := value.(time.Time)
  28100. if !ok {
  28101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28102. }
  28103. m.SetCreatedAt(v)
  28104. return nil
  28105. case token.FieldUpdatedAt:
  28106. v, ok := value.(time.Time)
  28107. if !ok {
  28108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28109. }
  28110. m.SetUpdatedAt(v)
  28111. return nil
  28112. case token.FieldDeletedAt:
  28113. v, ok := value.(time.Time)
  28114. if !ok {
  28115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28116. }
  28117. m.SetDeletedAt(v)
  28118. return nil
  28119. case token.FieldExpireAt:
  28120. v, ok := value.(time.Time)
  28121. if !ok {
  28122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28123. }
  28124. m.SetExpireAt(v)
  28125. return nil
  28126. case token.FieldToken:
  28127. v, ok := value.(string)
  28128. if !ok {
  28129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28130. }
  28131. m.SetToken(v)
  28132. return nil
  28133. case token.FieldMAC:
  28134. v, ok := value.(string)
  28135. if !ok {
  28136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28137. }
  28138. m.SetMAC(v)
  28139. return nil
  28140. case token.FieldOrganizationID:
  28141. v, ok := value.(uint64)
  28142. if !ok {
  28143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28144. }
  28145. m.SetOrganizationID(v)
  28146. return nil
  28147. case token.FieldAgentID:
  28148. v, ok := value.(uint64)
  28149. if !ok {
  28150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28151. }
  28152. m.SetAgentID(v)
  28153. return nil
  28154. case token.FieldCustomAgentBase:
  28155. v, ok := value.(string)
  28156. if !ok {
  28157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28158. }
  28159. m.SetCustomAgentBase(v)
  28160. return nil
  28161. case token.FieldCustomAgentKey:
  28162. v, ok := value.(string)
  28163. if !ok {
  28164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28165. }
  28166. m.SetCustomAgentKey(v)
  28167. return nil
  28168. case token.FieldOpenaiBase:
  28169. v, ok := value.(string)
  28170. if !ok {
  28171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28172. }
  28173. m.SetOpenaiBase(v)
  28174. return nil
  28175. case token.FieldOpenaiKey:
  28176. v, ok := value.(string)
  28177. if !ok {
  28178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28179. }
  28180. m.SetOpenaiKey(v)
  28181. return nil
  28182. }
  28183. return fmt.Errorf("unknown Token field %s", name)
  28184. }
  28185. // AddedFields returns all numeric fields that were incremented/decremented during
  28186. // this mutation.
  28187. func (m *TokenMutation) AddedFields() []string {
  28188. var fields []string
  28189. if m.addorganization_id != nil {
  28190. fields = append(fields, token.FieldOrganizationID)
  28191. }
  28192. return fields
  28193. }
  28194. // AddedField returns the numeric value that was incremented/decremented on a field
  28195. // with the given name. The second boolean return value indicates that this field
  28196. // was not set, or was not defined in the schema.
  28197. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  28198. switch name {
  28199. case token.FieldOrganizationID:
  28200. return m.AddedOrganizationID()
  28201. }
  28202. return nil, false
  28203. }
  28204. // AddField adds the value to the field with the given name. It returns an error if
  28205. // the field is not defined in the schema, or if the type mismatched the field
  28206. // type.
  28207. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  28208. switch name {
  28209. case token.FieldOrganizationID:
  28210. v, ok := value.(int64)
  28211. if !ok {
  28212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28213. }
  28214. m.AddOrganizationID(v)
  28215. return nil
  28216. }
  28217. return fmt.Errorf("unknown Token numeric field %s", name)
  28218. }
  28219. // ClearedFields returns all nullable fields that were cleared during this
  28220. // mutation.
  28221. func (m *TokenMutation) ClearedFields() []string {
  28222. var fields []string
  28223. if m.FieldCleared(token.FieldDeletedAt) {
  28224. fields = append(fields, token.FieldDeletedAt)
  28225. }
  28226. if m.FieldCleared(token.FieldExpireAt) {
  28227. fields = append(fields, token.FieldExpireAt)
  28228. }
  28229. if m.FieldCleared(token.FieldToken) {
  28230. fields = append(fields, token.FieldToken)
  28231. }
  28232. if m.FieldCleared(token.FieldMAC) {
  28233. fields = append(fields, token.FieldMAC)
  28234. }
  28235. if m.FieldCleared(token.FieldCustomAgentBase) {
  28236. fields = append(fields, token.FieldCustomAgentBase)
  28237. }
  28238. if m.FieldCleared(token.FieldCustomAgentKey) {
  28239. fields = append(fields, token.FieldCustomAgentKey)
  28240. }
  28241. if m.FieldCleared(token.FieldOpenaiBase) {
  28242. fields = append(fields, token.FieldOpenaiBase)
  28243. }
  28244. if m.FieldCleared(token.FieldOpenaiKey) {
  28245. fields = append(fields, token.FieldOpenaiKey)
  28246. }
  28247. return fields
  28248. }
  28249. // FieldCleared returns a boolean indicating if a field with the given name was
  28250. // cleared in this mutation.
  28251. func (m *TokenMutation) FieldCleared(name string) bool {
  28252. _, ok := m.clearedFields[name]
  28253. return ok
  28254. }
  28255. // ClearField clears the value of the field with the given name. It returns an
  28256. // error if the field is not defined in the schema.
  28257. func (m *TokenMutation) ClearField(name string) error {
  28258. switch name {
  28259. case token.FieldDeletedAt:
  28260. m.ClearDeletedAt()
  28261. return nil
  28262. case token.FieldExpireAt:
  28263. m.ClearExpireAt()
  28264. return nil
  28265. case token.FieldToken:
  28266. m.ClearToken()
  28267. return nil
  28268. case token.FieldMAC:
  28269. m.ClearMAC()
  28270. return nil
  28271. case token.FieldCustomAgentBase:
  28272. m.ClearCustomAgentBase()
  28273. return nil
  28274. case token.FieldCustomAgentKey:
  28275. m.ClearCustomAgentKey()
  28276. return nil
  28277. case token.FieldOpenaiBase:
  28278. m.ClearOpenaiBase()
  28279. return nil
  28280. case token.FieldOpenaiKey:
  28281. m.ClearOpenaiKey()
  28282. return nil
  28283. }
  28284. return fmt.Errorf("unknown Token nullable field %s", name)
  28285. }
  28286. // ResetField resets all changes in the mutation for the field with the given name.
  28287. // It returns an error if the field is not defined in the schema.
  28288. func (m *TokenMutation) ResetField(name string) error {
  28289. switch name {
  28290. case token.FieldCreatedAt:
  28291. m.ResetCreatedAt()
  28292. return nil
  28293. case token.FieldUpdatedAt:
  28294. m.ResetUpdatedAt()
  28295. return nil
  28296. case token.FieldDeletedAt:
  28297. m.ResetDeletedAt()
  28298. return nil
  28299. case token.FieldExpireAt:
  28300. m.ResetExpireAt()
  28301. return nil
  28302. case token.FieldToken:
  28303. m.ResetToken()
  28304. return nil
  28305. case token.FieldMAC:
  28306. m.ResetMAC()
  28307. return nil
  28308. case token.FieldOrganizationID:
  28309. m.ResetOrganizationID()
  28310. return nil
  28311. case token.FieldAgentID:
  28312. m.ResetAgentID()
  28313. return nil
  28314. case token.FieldCustomAgentBase:
  28315. m.ResetCustomAgentBase()
  28316. return nil
  28317. case token.FieldCustomAgentKey:
  28318. m.ResetCustomAgentKey()
  28319. return nil
  28320. case token.FieldOpenaiBase:
  28321. m.ResetOpenaiBase()
  28322. return nil
  28323. case token.FieldOpenaiKey:
  28324. m.ResetOpenaiKey()
  28325. return nil
  28326. }
  28327. return fmt.Errorf("unknown Token field %s", name)
  28328. }
  28329. // AddedEdges returns all edge names that were set/added in this mutation.
  28330. func (m *TokenMutation) AddedEdges() []string {
  28331. edges := make([]string, 0, 1)
  28332. if m.agent != nil {
  28333. edges = append(edges, token.EdgeAgent)
  28334. }
  28335. return edges
  28336. }
  28337. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28338. // name in this mutation.
  28339. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  28340. switch name {
  28341. case token.EdgeAgent:
  28342. if id := m.agent; id != nil {
  28343. return []ent.Value{*id}
  28344. }
  28345. }
  28346. return nil
  28347. }
  28348. // RemovedEdges returns all edge names that were removed in this mutation.
  28349. func (m *TokenMutation) RemovedEdges() []string {
  28350. edges := make([]string, 0, 1)
  28351. return edges
  28352. }
  28353. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28354. // the given name in this mutation.
  28355. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  28356. return nil
  28357. }
  28358. // ClearedEdges returns all edge names that were cleared in this mutation.
  28359. func (m *TokenMutation) ClearedEdges() []string {
  28360. edges := make([]string, 0, 1)
  28361. if m.clearedagent {
  28362. edges = append(edges, token.EdgeAgent)
  28363. }
  28364. return edges
  28365. }
  28366. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28367. // was cleared in this mutation.
  28368. func (m *TokenMutation) EdgeCleared(name string) bool {
  28369. switch name {
  28370. case token.EdgeAgent:
  28371. return m.clearedagent
  28372. }
  28373. return false
  28374. }
  28375. // ClearEdge clears the value of the edge with the given name. It returns an error
  28376. // if that edge is not defined in the schema.
  28377. func (m *TokenMutation) ClearEdge(name string) error {
  28378. switch name {
  28379. case token.EdgeAgent:
  28380. m.ClearAgent()
  28381. return nil
  28382. }
  28383. return fmt.Errorf("unknown Token unique edge %s", name)
  28384. }
  28385. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28386. // It returns an error if the edge is not defined in the schema.
  28387. func (m *TokenMutation) ResetEdge(name string) error {
  28388. switch name {
  28389. case token.EdgeAgent:
  28390. m.ResetAgent()
  28391. return nil
  28392. }
  28393. return fmt.Errorf("unknown Token edge %s", name)
  28394. }
  28395. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  28396. type TutorialMutation struct {
  28397. config
  28398. op Op
  28399. typ string
  28400. id *uint64
  28401. created_at *time.Time
  28402. updated_at *time.Time
  28403. deleted_at *time.Time
  28404. index *int
  28405. addindex *int
  28406. title *string
  28407. content *string
  28408. organization_id *uint64
  28409. addorganization_id *int64
  28410. clearedFields map[string]struct{}
  28411. employee *uint64
  28412. clearedemployee bool
  28413. done bool
  28414. oldValue func(context.Context) (*Tutorial, error)
  28415. predicates []predicate.Tutorial
  28416. }
  28417. var _ ent.Mutation = (*TutorialMutation)(nil)
  28418. // tutorialOption allows management of the mutation configuration using functional options.
  28419. type tutorialOption func(*TutorialMutation)
  28420. // newTutorialMutation creates new mutation for the Tutorial entity.
  28421. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  28422. m := &TutorialMutation{
  28423. config: c,
  28424. op: op,
  28425. typ: TypeTutorial,
  28426. clearedFields: make(map[string]struct{}),
  28427. }
  28428. for _, opt := range opts {
  28429. opt(m)
  28430. }
  28431. return m
  28432. }
  28433. // withTutorialID sets the ID field of the mutation.
  28434. func withTutorialID(id uint64) tutorialOption {
  28435. return func(m *TutorialMutation) {
  28436. var (
  28437. err error
  28438. once sync.Once
  28439. value *Tutorial
  28440. )
  28441. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  28442. once.Do(func() {
  28443. if m.done {
  28444. err = errors.New("querying old values post mutation is not allowed")
  28445. } else {
  28446. value, err = m.Client().Tutorial.Get(ctx, id)
  28447. }
  28448. })
  28449. return value, err
  28450. }
  28451. m.id = &id
  28452. }
  28453. }
  28454. // withTutorial sets the old Tutorial of the mutation.
  28455. func withTutorial(node *Tutorial) tutorialOption {
  28456. return func(m *TutorialMutation) {
  28457. m.oldValue = func(context.Context) (*Tutorial, error) {
  28458. return node, nil
  28459. }
  28460. m.id = &node.ID
  28461. }
  28462. }
  28463. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28464. // executed in a transaction (ent.Tx), a transactional client is returned.
  28465. func (m TutorialMutation) Client() *Client {
  28466. client := &Client{config: m.config}
  28467. client.init()
  28468. return client
  28469. }
  28470. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28471. // it returns an error otherwise.
  28472. func (m TutorialMutation) Tx() (*Tx, error) {
  28473. if _, ok := m.driver.(*txDriver); !ok {
  28474. return nil, errors.New("ent: mutation is not running in a transaction")
  28475. }
  28476. tx := &Tx{config: m.config}
  28477. tx.init()
  28478. return tx, nil
  28479. }
  28480. // SetID sets the value of the id field. Note that this
  28481. // operation is only accepted on creation of Tutorial entities.
  28482. func (m *TutorialMutation) SetID(id uint64) {
  28483. m.id = &id
  28484. }
  28485. // ID returns the ID value in the mutation. Note that the ID is only available
  28486. // if it was provided to the builder or after it was returned from the database.
  28487. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  28488. if m.id == nil {
  28489. return
  28490. }
  28491. return *m.id, true
  28492. }
  28493. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28494. // That means, if the mutation is applied within a transaction with an isolation level such
  28495. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28496. // or updated by the mutation.
  28497. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  28498. switch {
  28499. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28500. id, exists := m.ID()
  28501. if exists {
  28502. return []uint64{id}, nil
  28503. }
  28504. fallthrough
  28505. case m.op.Is(OpUpdate | OpDelete):
  28506. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  28507. default:
  28508. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28509. }
  28510. }
  28511. // SetCreatedAt sets the "created_at" field.
  28512. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  28513. m.created_at = &t
  28514. }
  28515. // CreatedAt returns the value of the "created_at" field in the mutation.
  28516. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  28517. v := m.created_at
  28518. if v == nil {
  28519. return
  28520. }
  28521. return *v, true
  28522. }
  28523. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  28524. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28526. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28527. if !m.op.Is(OpUpdateOne) {
  28528. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28529. }
  28530. if m.id == nil || m.oldValue == nil {
  28531. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28532. }
  28533. oldValue, err := m.oldValue(ctx)
  28534. if err != nil {
  28535. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28536. }
  28537. return oldValue.CreatedAt, nil
  28538. }
  28539. // ResetCreatedAt resets all changes to the "created_at" field.
  28540. func (m *TutorialMutation) ResetCreatedAt() {
  28541. m.created_at = nil
  28542. }
  28543. // SetUpdatedAt sets the "updated_at" field.
  28544. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  28545. m.updated_at = &t
  28546. }
  28547. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28548. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  28549. v := m.updated_at
  28550. if v == nil {
  28551. return
  28552. }
  28553. return *v, true
  28554. }
  28555. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  28556. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28558. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28559. if !m.op.Is(OpUpdateOne) {
  28560. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28561. }
  28562. if m.id == nil || m.oldValue == nil {
  28563. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28564. }
  28565. oldValue, err := m.oldValue(ctx)
  28566. if err != nil {
  28567. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28568. }
  28569. return oldValue.UpdatedAt, nil
  28570. }
  28571. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28572. func (m *TutorialMutation) ResetUpdatedAt() {
  28573. m.updated_at = nil
  28574. }
  28575. // SetDeletedAt sets the "deleted_at" field.
  28576. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  28577. m.deleted_at = &t
  28578. }
  28579. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28580. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  28581. v := m.deleted_at
  28582. if v == nil {
  28583. return
  28584. }
  28585. return *v, true
  28586. }
  28587. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  28588. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28590. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28591. if !m.op.Is(OpUpdateOne) {
  28592. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28593. }
  28594. if m.id == nil || m.oldValue == nil {
  28595. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28596. }
  28597. oldValue, err := m.oldValue(ctx)
  28598. if err != nil {
  28599. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28600. }
  28601. return oldValue.DeletedAt, nil
  28602. }
  28603. // ClearDeletedAt clears the value of the "deleted_at" field.
  28604. func (m *TutorialMutation) ClearDeletedAt() {
  28605. m.deleted_at = nil
  28606. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  28607. }
  28608. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28609. func (m *TutorialMutation) DeletedAtCleared() bool {
  28610. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  28611. return ok
  28612. }
  28613. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28614. func (m *TutorialMutation) ResetDeletedAt() {
  28615. m.deleted_at = nil
  28616. delete(m.clearedFields, tutorial.FieldDeletedAt)
  28617. }
  28618. // SetEmployeeID sets the "employee_id" field.
  28619. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  28620. m.employee = &u
  28621. }
  28622. // EmployeeID returns the value of the "employee_id" field in the mutation.
  28623. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  28624. v := m.employee
  28625. if v == nil {
  28626. return
  28627. }
  28628. return *v, true
  28629. }
  28630. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  28631. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28633. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  28634. if !m.op.Is(OpUpdateOne) {
  28635. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  28636. }
  28637. if m.id == nil || m.oldValue == nil {
  28638. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  28639. }
  28640. oldValue, err := m.oldValue(ctx)
  28641. if err != nil {
  28642. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  28643. }
  28644. return oldValue.EmployeeID, nil
  28645. }
  28646. // ResetEmployeeID resets all changes to the "employee_id" field.
  28647. func (m *TutorialMutation) ResetEmployeeID() {
  28648. m.employee = nil
  28649. }
  28650. // SetIndex sets the "index" field.
  28651. func (m *TutorialMutation) SetIndex(i int) {
  28652. m.index = &i
  28653. m.addindex = nil
  28654. }
  28655. // Index returns the value of the "index" field in the mutation.
  28656. func (m *TutorialMutation) Index() (r int, exists bool) {
  28657. v := m.index
  28658. if v == nil {
  28659. return
  28660. }
  28661. return *v, true
  28662. }
  28663. // OldIndex returns the old "index" field's value of the Tutorial entity.
  28664. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28666. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  28667. if !m.op.Is(OpUpdateOne) {
  28668. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  28669. }
  28670. if m.id == nil || m.oldValue == nil {
  28671. return v, errors.New("OldIndex requires an ID field in the mutation")
  28672. }
  28673. oldValue, err := m.oldValue(ctx)
  28674. if err != nil {
  28675. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  28676. }
  28677. return oldValue.Index, nil
  28678. }
  28679. // AddIndex adds i to the "index" field.
  28680. func (m *TutorialMutation) AddIndex(i int) {
  28681. if m.addindex != nil {
  28682. *m.addindex += i
  28683. } else {
  28684. m.addindex = &i
  28685. }
  28686. }
  28687. // AddedIndex returns the value that was added to the "index" field in this mutation.
  28688. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  28689. v := m.addindex
  28690. if v == nil {
  28691. return
  28692. }
  28693. return *v, true
  28694. }
  28695. // ResetIndex resets all changes to the "index" field.
  28696. func (m *TutorialMutation) ResetIndex() {
  28697. m.index = nil
  28698. m.addindex = nil
  28699. }
  28700. // SetTitle sets the "title" field.
  28701. func (m *TutorialMutation) SetTitle(s string) {
  28702. m.title = &s
  28703. }
  28704. // Title returns the value of the "title" field in the mutation.
  28705. func (m *TutorialMutation) Title() (r string, exists bool) {
  28706. v := m.title
  28707. if v == nil {
  28708. return
  28709. }
  28710. return *v, true
  28711. }
  28712. // OldTitle returns the old "title" field's value of the Tutorial entity.
  28713. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28715. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  28716. if !m.op.Is(OpUpdateOne) {
  28717. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  28718. }
  28719. if m.id == nil || m.oldValue == nil {
  28720. return v, errors.New("OldTitle requires an ID field in the mutation")
  28721. }
  28722. oldValue, err := m.oldValue(ctx)
  28723. if err != nil {
  28724. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  28725. }
  28726. return oldValue.Title, nil
  28727. }
  28728. // ResetTitle resets all changes to the "title" field.
  28729. func (m *TutorialMutation) ResetTitle() {
  28730. m.title = nil
  28731. }
  28732. // SetContent sets the "content" field.
  28733. func (m *TutorialMutation) SetContent(s string) {
  28734. m.content = &s
  28735. }
  28736. // Content returns the value of the "content" field in the mutation.
  28737. func (m *TutorialMutation) Content() (r string, exists bool) {
  28738. v := m.content
  28739. if v == nil {
  28740. return
  28741. }
  28742. return *v, true
  28743. }
  28744. // OldContent returns the old "content" field's value of the Tutorial entity.
  28745. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28747. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  28748. if !m.op.Is(OpUpdateOne) {
  28749. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  28750. }
  28751. if m.id == nil || m.oldValue == nil {
  28752. return v, errors.New("OldContent requires an ID field in the mutation")
  28753. }
  28754. oldValue, err := m.oldValue(ctx)
  28755. if err != nil {
  28756. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  28757. }
  28758. return oldValue.Content, nil
  28759. }
  28760. // ResetContent resets all changes to the "content" field.
  28761. func (m *TutorialMutation) ResetContent() {
  28762. m.content = nil
  28763. }
  28764. // SetOrganizationID sets the "organization_id" field.
  28765. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  28766. m.organization_id = &u
  28767. m.addorganization_id = nil
  28768. }
  28769. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28770. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  28771. v := m.organization_id
  28772. if v == nil {
  28773. return
  28774. }
  28775. return *v, true
  28776. }
  28777. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  28778. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  28779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28780. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28781. if !m.op.Is(OpUpdateOne) {
  28782. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28783. }
  28784. if m.id == nil || m.oldValue == nil {
  28785. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28786. }
  28787. oldValue, err := m.oldValue(ctx)
  28788. if err != nil {
  28789. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28790. }
  28791. return oldValue.OrganizationID, nil
  28792. }
  28793. // AddOrganizationID adds u to the "organization_id" field.
  28794. func (m *TutorialMutation) AddOrganizationID(u int64) {
  28795. if m.addorganization_id != nil {
  28796. *m.addorganization_id += u
  28797. } else {
  28798. m.addorganization_id = &u
  28799. }
  28800. }
  28801. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28802. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  28803. v := m.addorganization_id
  28804. if v == nil {
  28805. return
  28806. }
  28807. return *v, true
  28808. }
  28809. // ResetOrganizationID resets all changes to the "organization_id" field.
  28810. func (m *TutorialMutation) ResetOrganizationID() {
  28811. m.organization_id = nil
  28812. m.addorganization_id = nil
  28813. }
  28814. // ClearEmployee clears the "employee" edge to the Employee entity.
  28815. func (m *TutorialMutation) ClearEmployee() {
  28816. m.clearedemployee = true
  28817. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  28818. }
  28819. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  28820. func (m *TutorialMutation) EmployeeCleared() bool {
  28821. return m.clearedemployee
  28822. }
  28823. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  28824. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28825. // EmployeeID instead. It exists only for internal usage by the builders.
  28826. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  28827. if id := m.employee; id != nil {
  28828. ids = append(ids, *id)
  28829. }
  28830. return
  28831. }
  28832. // ResetEmployee resets all changes to the "employee" edge.
  28833. func (m *TutorialMutation) ResetEmployee() {
  28834. m.employee = nil
  28835. m.clearedemployee = false
  28836. }
  28837. // Where appends a list predicates to the TutorialMutation builder.
  28838. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  28839. m.predicates = append(m.predicates, ps...)
  28840. }
  28841. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  28842. // users can use type-assertion to append predicates that do not depend on any generated package.
  28843. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  28844. p := make([]predicate.Tutorial, len(ps))
  28845. for i := range ps {
  28846. p[i] = ps[i]
  28847. }
  28848. m.Where(p...)
  28849. }
  28850. // Op returns the operation name.
  28851. func (m *TutorialMutation) Op() Op {
  28852. return m.op
  28853. }
  28854. // SetOp allows setting the mutation operation.
  28855. func (m *TutorialMutation) SetOp(op Op) {
  28856. m.op = op
  28857. }
  28858. // Type returns the node type of this mutation (Tutorial).
  28859. func (m *TutorialMutation) Type() string {
  28860. return m.typ
  28861. }
  28862. // Fields returns all fields that were changed during this mutation. Note that in
  28863. // order to get all numeric fields that were incremented/decremented, call
  28864. // AddedFields().
  28865. func (m *TutorialMutation) Fields() []string {
  28866. fields := make([]string, 0, 8)
  28867. if m.created_at != nil {
  28868. fields = append(fields, tutorial.FieldCreatedAt)
  28869. }
  28870. if m.updated_at != nil {
  28871. fields = append(fields, tutorial.FieldUpdatedAt)
  28872. }
  28873. if m.deleted_at != nil {
  28874. fields = append(fields, tutorial.FieldDeletedAt)
  28875. }
  28876. if m.employee != nil {
  28877. fields = append(fields, tutorial.FieldEmployeeID)
  28878. }
  28879. if m.index != nil {
  28880. fields = append(fields, tutorial.FieldIndex)
  28881. }
  28882. if m.title != nil {
  28883. fields = append(fields, tutorial.FieldTitle)
  28884. }
  28885. if m.content != nil {
  28886. fields = append(fields, tutorial.FieldContent)
  28887. }
  28888. if m.organization_id != nil {
  28889. fields = append(fields, tutorial.FieldOrganizationID)
  28890. }
  28891. return fields
  28892. }
  28893. // Field returns the value of a field with the given name. The second boolean
  28894. // return value indicates that this field was not set, or was not defined in the
  28895. // schema.
  28896. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  28897. switch name {
  28898. case tutorial.FieldCreatedAt:
  28899. return m.CreatedAt()
  28900. case tutorial.FieldUpdatedAt:
  28901. return m.UpdatedAt()
  28902. case tutorial.FieldDeletedAt:
  28903. return m.DeletedAt()
  28904. case tutorial.FieldEmployeeID:
  28905. return m.EmployeeID()
  28906. case tutorial.FieldIndex:
  28907. return m.Index()
  28908. case tutorial.FieldTitle:
  28909. return m.Title()
  28910. case tutorial.FieldContent:
  28911. return m.Content()
  28912. case tutorial.FieldOrganizationID:
  28913. return m.OrganizationID()
  28914. }
  28915. return nil, false
  28916. }
  28917. // OldField returns the old value of the field from the database. An error is
  28918. // returned if the mutation operation is not UpdateOne, or the query to the
  28919. // database failed.
  28920. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28921. switch name {
  28922. case tutorial.FieldCreatedAt:
  28923. return m.OldCreatedAt(ctx)
  28924. case tutorial.FieldUpdatedAt:
  28925. return m.OldUpdatedAt(ctx)
  28926. case tutorial.FieldDeletedAt:
  28927. return m.OldDeletedAt(ctx)
  28928. case tutorial.FieldEmployeeID:
  28929. return m.OldEmployeeID(ctx)
  28930. case tutorial.FieldIndex:
  28931. return m.OldIndex(ctx)
  28932. case tutorial.FieldTitle:
  28933. return m.OldTitle(ctx)
  28934. case tutorial.FieldContent:
  28935. return m.OldContent(ctx)
  28936. case tutorial.FieldOrganizationID:
  28937. return m.OldOrganizationID(ctx)
  28938. }
  28939. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  28940. }
  28941. // SetField sets the value of a field with the given name. It returns an error if
  28942. // the field is not defined in the schema, or if the type mismatched the field
  28943. // type.
  28944. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  28945. switch name {
  28946. case tutorial.FieldCreatedAt:
  28947. v, ok := value.(time.Time)
  28948. if !ok {
  28949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28950. }
  28951. m.SetCreatedAt(v)
  28952. return nil
  28953. case tutorial.FieldUpdatedAt:
  28954. v, ok := value.(time.Time)
  28955. if !ok {
  28956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28957. }
  28958. m.SetUpdatedAt(v)
  28959. return nil
  28960. case tutorial.FieldDeletedAt:
  28961. v, ok := value.(time.Time)
  28962. if !ok {
  28963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28964. }
  28965. m.SetDeletedAt(v)
  28966. return nil
  28967. case tutorial.FieldEmployeeID:
  28968. v, ok := value.(uint64)
  28969. if !ok {
  28970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28971. }
  28972. m.SetEmployeeID(v)
  28973. return nil
  28974. case tutorial.FieldIndex:
  28975. v, ok := value.(int)
  28976. if !ok {
  28977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28978. }
  28979. m.SetIndex(v)
  28980. return nil
  28981. case tutorial.FieldTitle:
  28982. v, ok := value.(string)
  28983. if !ok {
  28984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28985. }
  28986. m.SetTitle(v)
  28987. return nil
  28988. case tutorial.FieldContent:
  28989. v, ok := value.(string)
  28990. if !ok {
  28991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28992. }
  28993. m.SetContent(v)
  28994. return nil
  28995. case tutorial.FieldOrganizationID:
  28996. v, ok := value.(uint64)
  28997. if !ok {
  28998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28999. }
  29000. m.SetOrganizationID(v)
  29001. return nil
  29002. }
  29003. return fmt.Errorf("unknown Tutorial field %s", name)
  29004. }
  29005. // AddedFields returns all numeric fields that were incremented/decremented during
  29006. // this mutation.
  29007. func (m *TutorialMutation) AddedFields() []string {
  29008. var fields []string
  29009. if m.addindex != nil {
  29010. fields = append(fields, tutorial.FieldIndex)
  29011. }
  29012. if m.addorganization_id != nil {
  29013. fields = append(fields, tutorial.FieldOrganizationID)
  29014. }
  29015. return fields
  29016. }
  29017. // AddedField returns the numeric value that was incremented/decremented on a field
  29018. // with the given name. The second boolean return value indicates that this field
  29019. // was not set, or was not defined in the schema.
  29020. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  29021. switch name {
  29022. case tutorial.FieldIndex:
  29023. return m.AddedIndex()
  29024. case tutorial.FieldOrganizationID:
  29025. return m.AddedOrganizationID()
  29026. }
  29027. return nil, false
  29028. }
  29029. // AddField adds the value to the field with the given name. It returns an error if
  29030. // the field is not defined in the schema, or if the type mismatched the field
  29031. // type.
  29032. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  29033. switch name {
  29034. case tutorial.FieldIndex:
  29035. v, ok := value.(int)
  29036. if !ok {
  29037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29038. }
  29039. m.AddIndex(v)
  29040. return nil
  29041. case tutorial.FieldOrganizationID:
  29042. v, ok := value.(int64)
  29043. if !ok {
  29044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29045. }
  29046. m.AddOrganizationID(v)
  29047. return nil
  29048. }
  29049. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  29050. }
  29051. // ClearedFields returns all nullable fields that were cleared during this
  29052. // mutation.
  29053. func (m *TutorialMutation) ClearedFields() []string {
  29054. var fields []string
  29055. if m.FieldCleared(tutorial.FieldDeletedAt) {
  29056. fields = append(fields, tutorial.FieldDeletedAt)
  29057. }
  29058. return fields
  29059. }
  29060. // FieldCleared returns a boolean indicating if a field with the given name was
  29061. // cleared in this mutation.
  29062. func (m *TutorialMutation) FieldCleared(name string) bool {
  29063. _, ok := m.clearedFields[name]
  29064. return ok
  29065. }
  29066. // ClearField clears the value of the field with the given name. It returns an
  29067. // error if the field is not defined in the schema.
  29068. func (m *TutorialMutation) ClearField(name string) error {
  29069. switch name {
  29070. case tutorial.FieldDeletedAt:
  29071. m.ClearDeletedAt()
  29072. return nil
  29073. }
  29074. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  29075. }
  29076. // ResetField resets all changes in the mutation for the field with the given name.
  29077. // It returns an error if the field is not defined in the schema.
  29078. func (m *TutorialMutation) ResetField(name string) error {
  29079. switch name {
  29080. case tutorial.FieldCreatedAt:
  29081. m.ResetCreatedAt()
  29082. return nil
  29083. case tutorial.FieldUpdatedAt:
  29084. m.ResetUpdatedAt()
  29085. return nil
  29086. case tutorial.FieldDeletedAt:
  29087. m.ResetDeletedAt()
  29088. return nil
  29089. case tutorial.FieldEmployeeID:
  29090. m.ResetEmployeeID()
  29091. return nil
  29092. case tutorial.FieldIndex:
  29093. m.ResetIndex()
  29094. return nil
  29095. case tutorial.FieldTitle:
  29096. m.ResetTitle()
  29097. return nil
  29098. case tutorial.FieldContent:
  29099. m.ResetContent()
  29100. return nil
  29101. case tutorial.FieldOrganizationID:
  29102. m.ResetOrganizationID()
  29103. return nil
  29104. }
  29105. return fmt.Errorf("unknown Tutorial field %s", name)
  29106. }
  29107. // AddedEdges returns all edge names that were set/added in this mutation.
  29108. func (m *TutorialMutation) AddedEdges() []string {
  29109. edges := make([]string, 0, 1)
  29110. if m.employee != nil {
  29111. edges = append(edges, tutorial.EdgeEmployee)
  29112. }
  29113. return edges
  29114. }
  29115. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29116. // name in this mutation.
  29117. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  29118. switch name {
  29119. case tutorial.EdgeEmployee:
  29120. if id := m.employee; id != nil {
  29121. return []ent.Value{*id}
  29122. }
  29123. }
  29124. return nil
  29125. }
  29126. // RemovedEdges returns all edge names that were removed in this mutation.
  29127. func (m *TutorialMutation) RemovedEdges() []string {
  29128. edges := make([]string, 0, 1)
  29129. return edges
  29130. }
  29131. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29132. // the given name in this mutation.
  29133. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  29134. return nil
  29135. }
  29136. // ClearedEdges returns all edge names that were cleared in this mutation.
  29137. func (m *TutorialMutation) ClearedEdges() []string {
  29138. edges := make([]string, 0, 1)
  29139. if m.clearedemployee {
  29140. edges = append(edges, tutorial.EdgeEmployee)
  29141. }
  29142. return edges
  29143. }
  29144. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29145. // was cleared in this mutation.
  29146. func (m *TutorialMutation) EdgeCleared(name string) bool {
  29147. switch name {
  29148. case tutorial.EdgeEmployee:
  29149. return m.clearedemployee
  29150. }
  29151. return false
  29152. }
  29153. // ClearEdge clears the value of the edge with the given name. It returns an error
  29154. // if that edge is not defined in the schema.
  29155. func (m *TutorialMutation) ClearEdge(name string) error {
  29156. switch name {
  29157. case tutorial.EdgeEmployee:
  29158. m.ClearEmployee()
  29159. return nil
  29160. }
  29161. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  29162. }
  29163. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29164. // It returns an error if the edge is not defined in the schema.
  29165. func (m *TutorialMutation) ResetEdge(name string) error {
  29166. switch name {
  29167. case tutorial.EdgeEmployee:
  29168. m.ResetEmployee()
  29169. return nil
  29170. }
  29171. return fmt.Errorf("unknown Tutorial edge %s", name)
  29172. }
  29173. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  29174. type UsageDetailMutation struct {
  29175. config
  29176. op Op
  29177. typ string
  29178. id *uint64
  29179. created_at *time.Time
  29180. updated_at *time.Time
  29181. status *uint8
  29182. addstatus *int8
  29183. _type *int
  29184. add_type *int
  29185. bot_id *string
  29186. receiver_id *string
  29187. app *int
  29188. addapp *int
  29189. session_id *uint64
  29190. addsession_id *int64
  29191. request *string
  29192. response *string
  29193. original_data *custom_types.OriginalData
  29194. total_tokens *uint64
  29195. addtotal_tokens *int64
  29196. prompt_tokens *uint64
  29197. addprompt_tokens *int64
  29198. completion_tokens *uint64
  29199. addcompletion_tokens *int64
  29200. organization_id *uint64
  29201. addorganization_id *int64
  29202. clearedFields map[string]struct{}
  29203. done bool
  29204. oldValue func(context.Context) (*UsageDetail, error)
  29205. predicates []predicate.UsageDetail
  29206. }
  29207. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  29208. // usagedetailOption allows management of the mutation configuration using functional options.
  29209. type usagedetailOption func(*UsageDetailMutation)
  29210. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  29211. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  29212. m := &UsageDetailMutation{
  29213. config: c,
  29214. op: op,
  29215. typ: TypeUsageDetail,
  29216. clearedFields: make(map[string]struct{}),
  29217. }
  29218. for _, opt := range opts {
  29219. opt(m)
  29220. }
  29221. return m
  29222. }
  29223. // withUsageDetailID sets the ID field of the mutation.
  29224. func withUsageDetailID(id uint64) usagedetailOption {
  29225. return func(m *UsageDetailMutation) {
  29226. var (
  29227. err error
  29228. once sync.Once
  29229. value *UsageDetail
  29230. )
  29231. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  29232. once.Do(func() {
  29233. if m.done {
  29234. err = errors.New("querying old values post mutation is not allowed")
  29235. } else {
  29236. value, err = m.Client().UsageDetail.Get(ctx, id)
  29237. }
  29238. })
  29239. return value, err
  29240. }
  29241. m.id = &id
  29242. }
  29243. }
  29244. // withUsageDetail sets the old UsageDetail of the mutation.
  29245. func withUsageDetail(node *UsageDetail) usagedetailOption {
  29246. return func(m *UsageDetailMutation) {
  29247. m.oldValue = func(context.Context) (*UsageDetail, error) {
  29248. return node, nil
  29249. }
  29250. m.id = &node.ID
  29251. }
  29252. }
  29253. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29254. // executed in a transaction (ent.Tx), a transactional client is returned.
  29255. func (m UsageDetailMutation) Client() *Client {
  29256. client := &Client{config: m.config}
  29257. client.init()
  29258. return client
  29259. }
  29260. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29261. // it returns an error otherwise.
  29262. func (m UsageDetailMutation) Tx() (*Tx, error) {
  29263. if _, ok := m.driver.(*txDriver); !ok {
  29264. return nil, errors.New("ent: mutation is not running in a transaction")
  29265. }
  29266. tx := &Tx{config: m.config}
  29267. tx.init()
  29268. return tx, nil
  29269. }
  29270. // SetID sets the value of the id field. Note that this
  29271. // operation is only accepted on creation of UsageDetail entities.
  29272. func (m *UsageDetailMutation) SetID(id uint64) {
  29273. m.id = &id
  29274. }
  29275. // ID returns the ID value in the mutation. Note that the ID is only available
  29276. // if it was provided to the builder or after it was returned from the database.
  29277. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  29278. if m.id == nil {
  29279. return
  29280. }
  29281. return *m.id, true
  29282. }
  29283. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29284. // That means, if the mutation is applied within a transaction with an isolation level such
  29285. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29286. // or updated by the mutation.
  29287. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  29288. switch {
  29289. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29290. id, exists := m.ID()
  29291. if exists {
  29292. return []uint64{id}, nil
  29293. }
  29294. fallthrough
  29295. case m.op.Is(OpUpdate | OpDelete):
  29296. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  29297. default:
  29298. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29299. }
  29300. }
  29301. // SetCreatedAt sets the "created_at" field.
  29302. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  29303. m.created_at = &t
  29304. }
  29305. // CreatedAt returns the value of the "created_at" field in the mutation.
  29306. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  29307. v := m.created_at
  29308. if v == nil {
  29309. return
  29310. }
  29311. return *v, true
  29312. }
  29313. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  29314. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29316. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29317. if !m.op.Is(OpUpdateOne) {
  29318. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29319. }
  29320. if m.id == nil || m.oldValue == nil {
  29321. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29322. }
  29323. oldValue, err := m.oldValue(ctx)
  29324. if err != nil {
  29325. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29326. }
  29327. return oldValue.CreatedAt, nil
  29328. }
  29329. // ResetCreatedAt resets all changes to the "created_at" field.
  29330. func (m *UsageDetailMutation) ResetCreatedAt() {
  29331. m.created_at = nil
  29332. }
  29333. // SetUpdatedAt sets the "updated_at" field.
  29334. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  29335. m.updated_at = &t
  29336. }
  29337. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29338. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  29339. v := m.updated_at
  29340. if v == nil {
  29341. return
  29342. }
  29343. return *v, true
  29344. }
  29345. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  29346. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29348. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29349. if !m.op.Is(OpUpdateOne) {
  29350. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29351. }
  29352. if m.id == nil || m.oldValue == nil {
  29353. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29354. }
  29355. oldValue, err := m.oldValue(ctx)
  29356. if err != nil {
  29357. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29358. }
  29359. return oldValue.UpdatedAt, nil
  29360. }
  29361. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29362. func (m *UsageDetailMutation) ResetUpdatedAt() {
  29363. m.updated_at = nil
  29364. }
  29365. // SetStatus sets the "status" field.
  29366. func (m *UsageDetailMutation) SetStatus(u uint8) {
  29367. m.status = &u
  29368. m.addstatus = nil
  29369. }
  29370. // Status returns the value of the "status" field in the mutation.
  29371. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  29372. v := m.status
  29373. if v == nil {
  29374. return
  29375. }
  29376. return *v, true
  29377. }
  29378. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  29379. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29381. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29382. if !m.op.Is(OpUpdateOne) {
  29383. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29384. }
  29385. if m.id == nil || m.oldValue == nil {
  29386. return v, errors.New("OldStatus requires an ID field in the mutation")
  29387. }
  29388. oldValue, err := m.oldValue(ctx)
  29389. if err != nil {
  29390. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29391. }
  29392. return oldValue.Status, nil
  29393. }
  29394. // AddStatus adds u to the "status" field.
  29395. func (m *UsageDetailMutation) AddStatus(u int8) {
  29396. if m.addstatus != nil {
  29397. *m.addstatus += u
  29398. } else {
  29399. m.addstatus = &u
  29400. }
  29401. }
  29402. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29403. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  29404. v := m.addstatus
  29405. if v == nil {
  29406. return
  29407. }
  29408. return *v, true
  29409. }
  29410. // ClearStatus clears the value of the "status" field.
  29411. func (m *UsageDetailMutation) ClearStatus() {
  29412. m.status = nil
  29413. m.addstatus = nil
  29414. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  29415. }
  29416. // StatusCleared returns if the "status" field was cleared in this mutation.
  29417. func (m *UsageDetailMutation) StatusCleared() bool {
  29418. _, ok := m.clearedFields[usagedetail.FieldStatus]
  29419. return ok
  29420. }
  29421. // ResetStatus resets all changes to the "status" field.
  29422. func (m *UsageDetailMutation) ResetStatus() {
  29423. m.status = nil
  29424. m.addstatus = nil
  29425. delete(m.clearedFields, usagedetail.FieldStatus)
  29426. }
  29427. // SetType sets the "type" field.
  29428. func (m *UsageDetailMutation) SetType(i int) {
  29429. m._type = &i
  29430. m.add_type = nil
  29431. }
  29432. // GetType returns the value of the "type" field in the mutation.
  29433. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  29434. v := m._type
  29435. if v == nil {
  29436. return
  29437. }
  29438. return *v, true
  29439. }
  29440. // OldType returns the old "type" field's value of the UsageDetail entity.
  29441. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29443. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  29444. if !m.op.Is(OpUpdateOne) {
  29445. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29446. }
  29447. if m.id == nil || m.oldValue == nil {
  29448. return v, errors.New("OldType requires an ID field in the mutation")
  29449. }
  29450. oldValue, err := m.oldValue(ctx)
  29451. if err != nil {
  29452. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29453. }
  29454. return oldValue.Type, nil
  29455. }
  29456. // AddType adds i to the "type" field.
  29457. func (m *UsageDetailMutation) AddType(i int) {
  29458. if m.add_type != nil {
  29459. *m.add_type += i
  29460. } else {
  29461. m.add_type = &i
  29462. }
  29463. }
  29464. // AddedType returns the value that was added to the "type" field in this mutation.
  29465. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  29466. v := m.add_type
  29467. if v == nil {
  29468. return
  29469. }
  29470. return *v, true
  29471. }
  29472. // ClearType clears the value of the "type" field.
  29473. func (m *UsageDetailMutation) ClearType() {
  29474. m._type = nil
  29475. m.add_type = nil
  29476. m.clearedFields[usagedetail.FieldType] = struct{}{}
  29477. }
  29478. // TypeCleared returns if the "type" field was cleared in this mutation.
  29479. func (m *UsageDetailMutation) TypeCleared() bool {
  29480. _, ok := m.clearedFields[usagedetail.FieldType]
  29481. return ok
  29482. }
  29483. // ResetType resets all changes to the "type" field.
  29484. func (m *UsageDetailMutation) ResetType() {
  29485. m._type = nil
  29486. m.add_type = nil
  29487. delete(m.clearedFields, usagedetail.FieldType)
  29488. }
  29489. // SetBotID sets the "bot_id" field.
  29490. func (m *UsageDetailMutation) SetBotID(s string) {
  29491. m.bot_id = &s
  29492. }
  29493. // BotID returns the value of the "bot_id" field in the mutation.
  29494. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  29495. v := m.bot_id
  29496. if v == nil {
  29497. return
  29498. }
  29499. return *v, true
  29500. }
  29501. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  29502. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29504. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  29505. if !m.op.Is(OpUpdateOne) {
  29506. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29507. }
  29508. if m.id == nil || m.oldValue == nil {
  29509. return v, errors.New("OldBotID requires an ID field in the mutation")
  29510. }
  29511. oldValue, err := m.oldValue(ctx)
  29512. if err != nil {
  29513. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29514. }
  29515. return oldValue.BotID, nil
  29516. }
  29517. // ResetBotID resets all changes to the "bot_id" field.
  29518. func (m *UsageDetailMutation) ResetBotID() {
  29519. m.bot_id = nil
  29520. }
  29521. // SetReceiverID sets the "receiver_id" field.
  29522. func (m *UsageDetailMutation) SetReceiverID(s string) {
  29523. m.receiver_id = &s
  29524. }
  29525. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  29526. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  29527. v := m.receiver_id
  29528. if v == nil {
  29529. return
  29530. }
  29531. return *v, true
  29532. }
  29533. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  29534. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29536. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  29537. if !m.op.Is(OpUpdateOne) {
  29538. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  29539. }
  29540. if m.id == nil || m.oldValue == nil {
  29541. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  29542. }
  29543. oldValue, err := m.oldValue(ctx)
  29544. if err != nil {
  29545. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  29546. }
  29547. return oldValue.ReceiverID, nil
  29548. }
  29549. // ResetReceiverID resets all changes to the "receiver_id" field.
  29550. func (m *UsageDetailMutation) ResetReceiverID() {
  29551. m.receiver_id = nil
  29552. }
  29553. // SetApp sets the "app" field.
  29554. func (m *UsageDetailMutation) SetApp(i int) {
  29555. m.app = &i
  29556. m.addapp = nil
  29557. }
  29558. // App returns the value of the "app" field in the mutation.
  29559. func (m *UsageDetailMutation) App() (r int, exists bool) {
  29560. v := m.app
  29561. if v == nil {
  29562. return
  29563. }
  29564. return *v, true
  29565. }
  29566. // OldApp returns the old "app" field's value of the UsageDetail entity.
  29567. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29569. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  29570. if !m.op.Is(OpUpdateOne) {
  29571. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  29572. }
  29573. if m.id == nil || m.oldValue == nil {
  29574. return v, errors.New("OldApp requires an ID field in the mutation")
  29575. }
  29576. oldValue, err := m.oldValue(ctx)
  29577. if err != nil {
  29578. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  29579. }
  29580. return oldValue.App, nil
  29581. }
  29582. // AddApp adds i to the "app" field.
  29583. func (m *UsageDetailMutation) AddApp(i int) {
  29584. if m.addapp != nil {
  29585. *m.addapp += i
  29586. } else {
  29587. m.addapp = &i
  29588. }
  29589. }
  29590. // AddedApp returns the value that was added to the "app" field in this mutation.
  29591. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  29592. v := m.addapp
  29593. if v == nil {
  29594. return
  29595. }
  29596. return *v, true
  29597. }
  29598. // ClearApp clears the value of the "app" field.
  29599. func (m *UsageDetailMutation) ClearApp() {
  29600. m.app = nil
  29601. m.addapp = nil
  29602. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  29603. }
  29604. // AppCleared returns if the "app" field was cleared in this mutation.
  29605. func (m *UsageDetailMutation) AppCleared() bool {
  29606. _, ok := m.clearedFields[usagedetail.FieldApp]
  29607. return ok
  29608. }
  29609. // ResetApp resets all changes to the "app" field.
  29610. func (m *UsageDetailMutation) ResetApp() {
  29611. m.app = nil
  29612. m.addapp = nil
  29613. delete(m.clearedFields, usagedetail.FieldApp)
  29614. }
  29615. // SetSessionID sets the "session_id" field.
  29616. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  29617. m.session_id = &u
  29618. m.addsession_id = nil
  29619. }
  29620. // SessionID returns the value of the "session_id" field in the mutation.
  29621. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  29622. v := m.session_id
  29623. if v == nil {
  29624. return
  29625. }
  29626. return *v, true
  29627. }
  29628. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  29629. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29631. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  29632. if !m.op.Is(OpUpdateOne) {
  29633. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  29634. }
  29635. if m.id == nil || m.oldValue == nil {
  29636. return v, errors.New("OldSessionID requires an ID field in the mutation")
  29637. }
  29638. oldValue, err := m.oldValue(ctx)
  29639. if err != nil {
  29640. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  29641. }
  29642. return oldValue.SessionID, nil
  29643. }
  29644. // AddSessionID adds u to the "session_id" field.
  29645. func (m *UsageDetailMutation) AddSessionID(u int64) {
  29646. if m.addsession_id != nil {
  29647. *m.addsession_id += u
  29648. } else {
  29649. m.addsession_id = &u
  29650. }
  29651. }
  29652. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  29653. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  29654. v := m.addsession_id
  29655. if v == nil {
  29656. return
  29657. }
  29658. return *v, true
  29659. }
  29660. // ClearSessionID clears the value of the "session_id" field.
  29661. func (m *UsageDetailMutation) ClearSessionID() {
  29662. m.session_id = nil
  29663. m.addsession_id = nil
  29664. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  29665. }
  29666. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  29667. func (m *UsageDetailMutation) SessionIDCleared() bool {
  29668. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  29669. return ok
  29670. }
  29671. // ResetSessionID resets all changes to the "session_id" field.
  29672. func (m *UsageDetailMutation) ResetSessionID() {
  29673. m.session_id = nil
  29674. m.addsession_id = nil
  29675. delete(m.clearedFields, usagedetail.FieldSessionID)
  29676. }
  29677. // SetRequest sets the "request" field.
  29678. func (m *UsageDetailMutation) SetRequest(s string) {
  29679. m.request = &s
  29680. }
  29681. // Request returns the value of the "request" field in the mutation.
  29682. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  29683. v := m.request
  29684. if v == nil {
  29685. return
  29686. }
  29687. return *v, true
  29688. }
  29689. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  29690. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29692. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  29693. if !m.op.Is(OpUpdateOne) {
  29694. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  29695. }
  29696. if m.id == nil || m.oldValue == nil {
  29697. return v, errors.New("OldRequest requires an ID field in the mutation")
  29698. }
  29699. oldValue, err := m.oldValue(ctx)
  29700. if err != nil {
  29701. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  29702. }
  29703. return oldValue.Request, nil
  29704. }
  29705. // ResetRequest resets all changes to the "request" field.
  29706. func (m *UsageDetailMutation) ResetRequest() {
  29707. m.request = nil
  29708. }
  29709. // SetResponse sets the "response" field.
  29710. func (m *UsageDetailMutation) SetResponse(s string) {
  29711. m.response = &s
  29712. }
  29713. // Response returns the value of the "response" field in the mutation.
  29714. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  29715. v := m.response
  29716. if v == nil {
  29717. return
  29718. }
  29719. return *v, true
  29720. }
  29721. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  29722. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29724. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  29725. if !m.op.Is(OpUpdateOne) {
  29726. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  29727. }
  29728. if m.id == nil || m.oldValue == nil {
  29729. return v, errors.New("OldResponse requires an ID field in the mutation")
  29730. }
  29731. oldValue, err := m.oldValue(ctx)
  29732. if err != nil {
  29733. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  29734. }
  29735. return oldValue.Response, nil
  29736. }
  29737. // ResetResponse resets all changes to the "response" field.
  29738. func (m *UsageDetailMutation) ResetResponse() {
  29739. m.response = nil
  29740. }
  29741. // SetOriginalData sets the "original_data" field.
  29742. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  29743. m.original_data = &ctd
  29744. }
  29745. // OriginalData returns the value of the "original_data" field in the mutation.
  29746. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  29747. v := m.original_data
  29748. if v == nil {
  29749. return
  29750. }
  29751. return *v, true
  29752. }
  29753. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  29754. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29756. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  29757. if !m.op.Is(OpUpdateOne) {
  29758. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  29759. }
  29760. if m.id == nil || m.oldValue == nil {
  29761. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  29762. }
  29763. oldValue, err := m.oldValue(ctx)
  29764. if err != nil {
  29765. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  29766. }
  29767. return oldValue.OriginalData, nil
  29768. }
  29769. // ResetOriginalData resets all changes to the "original_data" field.
  29770. func (m *UsageDetailMutation) ResetOriginalData() {
  29771. m.original_data = nil
  29772. }
  29773. // SetTotalTokens sets the "total_tokens" field.
  29774. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  29775. m.total_tokens = &u
  29776. m.addtotal_tokens = nil
  29777. }
  29778. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29779. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  29780. v := m.total_tokens
  29781. if v == nil {
  29782. return
  29783. }
  29784. return *v, true
  29785. }
  29786. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  29787. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29789. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29790. if !m.op.Is(OpUpdateOne) {
  29791. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29792. }
  29793. if m.id == nil || m.oldValue == nil {
  29794. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29795. }
  29796. oldValue, err := m.oldValue(ctx)
  29797. if err != nil {
  29798. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29799. }
  29800. return oldValue.TotalTokens, nil
  29801. }
  29802. // AddTotalTokens adds u to the "total_tokens" field.
  29803. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  29804. if m.addtotal_tokens != nil {
  29805. *m.addtotal_tokens += u
  29806. } else {
  29807. m.addtotal_tokens = &u
  29808. }
  29809. }
  29810. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29811. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  29812. v := m.addtotal_tokens
  29813. if v == nil {
  29814. return
  29815. }
  29816. return *v, true
  29817. }
  29818. // ClearTotalTokens clears the value of the "total_tokens" field.
  29819. func (m *UsageDetailMutation) ClearTotalTokens() {
  29820. m.total_tokens = nil
  29821. m.addtotal_tokens = nil
  29822. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  29823. }
  29824. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29825. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  29826. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  29827. return ok
  29828. }
  29829. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29830. func (m *UsageDetailMutation) ResetTotalTokens() {
  29831. m.total_tokens = nil
  29832. m.addtotal_tokens = nil
  29833. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  29834. }
  29835. // SetPromptTokens sets the "prompt_tokens" field.
  29836. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  29837. m.prompt_tokens = &u
  29838. m.addprompt_tokens = nil
  29839. }
  29840. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  29841. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  29842. v := m.prompt_tokens
  29843. if v == nil {
  29844. return
  29845. }
  29846. return *v, true
  29847. }
  29848. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  29849. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29851. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  29852. if !m.op.Is(OpUpdateOne) {
  29853. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  29854. }
  29855. if m.id == nil || m.oldValue == nil {
  29856. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  29857. }
  29858. oldValue, err := m.oldValue(ctx)
  29859. if err != nil {
  29860. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  29861. }
  29862. return oldValue.PromptTokens, nil
  29863. }
  29864. // AddPromptTokens adds u to the "prompt_tokens" field.
  29865. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  29866. if m.addprompt_tokens != nil {
  29867. *m.addprompt_tokens += u
  29868. } else {
  29869. m.addprompt_tokens = &u
  29870. }
  29871. }
  29872. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  29873. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  29874. v := m.addprompt_tokens
  29875. if v == nil {
  29876. return
  29877. }
  29878. return *v, true
  29879. }
  29880. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  29881. func (m *UsageDetailMutation) ClearPromptTokens() {
  29882. m.prompt_tokens = nil
  29883. m.addprompt_tokens = nil
  29884. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  29885. }
  29886. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  29887. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  29888. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  29889. return ok
  29890. }
  29891. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  29892. func (m *UsageDetailMutation) ResetPromptTokens() {
  29893. m.prompt_tokens = nil
  29894. m.addprompt_tokens = nil
  29895. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  29896. }
  29897. // SetCompletionTokens sets the "completion_tokens" field.
  29898. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  29899. m.completion_tokens = &u
  29900. m.addcompletion_tokens = nil
  29901. }
  29902. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  29903. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  29904. v := m.completion_tokens
  29905. if v == nil {
  29906. return
  29907. }
  29908. return *v, true
  29909. }
  29910. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  29911. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29913. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  29914. if !m.op.Is(OpUpdateOne) {
  29915. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  29916. }
  29917. if m.id == nil || m.oldValue == nil {
  29918. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  29919. }
  29920. oldValue, err := m.oldValue(ctx)
  29921. if err != nil {
  29922. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  29923. }
  29924. return oldValue.CompletionTokens, nil
  29925. }
  29926. // AddCompletionTokens adds u to the "completion_tokens" field.
  29927. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  29928. if m.addcompletion_tokens != nil {
  29929. *m.addcompletion_tokens += u
  29930. } else {
  29931. m.addcompletion_tokens = &u
  29932. }
  29933. }
  29934. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  29935. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  29936. v := m.addcompletion_tokens
  29937. if v == nil {
  29938. return
  29939. }
  29940. return *v, true
  29941. }
  29942. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  29943. func (m *UsageDetailMutation) ClearCompletionTokens() {
  29944. m.completion_tokens = nil
  29945. m.addcompletion_tokens = nil
  29946. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  29947. }
  29948. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  29949. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  29950. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  29951. return ok
  29952. }
  29953. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  29954. func (m *UsageDetailMutation) ResetCompletionTokens() {
  29955. m.completion_tokens = nil
  29956. m.addcompletion_tokens = nil
  29957. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  29958. }
  29959. // SetOrganizationID sets the "organization_id" field.
  29960. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  29961. m.organization_id = &u
  29962. m.addorganization_id = nil
  29963. }
  29964. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29965. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  29966. v := m.organization_id
  29967. if v == nil {
  29968. return
  29969. }
  29970. return *v, true
  29971. }
  29972. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  29973. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  29974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29975. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29976. if !m.op.Is(OpUpdateOne) {
  29977. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29978. }
  29979. if m.id == nil || m.oldValue == nil {
  29980. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29981. }
  29982. oldValue, err := m.oldValue(ctx)
  29983. if err != nil {
  29984. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29985. }
  29986. return oldValue.OrganizationID, nil
  29987. }
  29988. // AddOrganizationID adds u to the "organization_id" field.
  29989. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  29990. if m.addorganization_id != nil {
  29991. *m.addorganization_id += u
  29992. } else {
  29993. m.addorganization_id = &u
  29994. }
  29995. }
  29996. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29997. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  29998. v := m.addorganization_id
  29999. if v == nil {
  30000. return
  30001. }
  30002. return *v, true
  30003. }
  30004. // ClearOrganizationID clears the value of the "organization_id" field.
  30005. func (m *UsageDetailMutation) ClearOrganizationID() {
  30006. m.organization_id = nil
  30007. m.addorganization_id = nil
  30008. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  30009. }
  30010. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30011. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  30012. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  30013. return ok
  30014. }
  30015. // ResetOrganizationID resets all changes to the "organization_id" field.
  30016. func (m *UsageDetailMutation) ResetOrganizationID() {
  30017. m.organization_id = nil
  30018. m.addorganization_id = nil
  30019. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  30020. }
  30021. // Where appends a list predicates to the UsageDetailMutation builder.
  30022. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  30023. m.predicates = append(m.predicates, ps...)
  30024. }
  30025. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  30026. // users can use type-assertion to append predicates that do not depend on any generated package.
  30027. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  30028. p := make([]predicate.UsageDetail, len(ps))
  30029. for i := range ps {
  30030. p[i] = ps[i]
  30031. }
  30032. m.Where(p...)
  30033. }
  30034. // Op returns the operation name.
  30035. func (m *UsageDetailMutation) Op() Op {
  30036. return m.op
  30037. }
  30038. // SetOp allows setting the mutation operation.
  30039. func (m *UsageDetailMutation) SetOp(op Op) {
  30040. m.op = op
  30041. }
  30042. // Type returns the node type of this mutation (UsageDetail).
  30043. func (m *UsageDetailMutation) Type() string {
  30044. return m.typ
  30045. }
  30046. // Fields returns all fields that were changed during this mutation. Note that in
  30047. // order to get all numeric fields that were incremented/decremented, call
  30048. // AddedFields().
  30049. func (m *UsageDetailMutation) Fields() []string {
  30050. fields := make([]string, 0, 15)
  30051. if m.created_at != nil {
  30052. fields = append(fields, usagedetail.FieldCreatedAt)
  30053. }
  30054. if m.updated_at != nil {
  30055. fields = append(fields, usagedetail.FieldUpdatedAt)
  30056. }
  30057. if m.status != nil {
  30058. fields = append(fields, usagedetail.FieldStatus)
  30059. }
  30060. if m._type != nil {
  30061. fields = append(fields, usagedetail.FieldType)
  30062. }
  30063. if m.bot_id != nil {
  30064. fields = append(fields, usagedetail.FieldBotID)
  30065. }
  30066. if m.receiver_id != nil {
  30067. fields = append(fields, usagedetail.FieldReceiverID)
  30068. }
  30069. if m.app != nil {
  30070. fields = append(fields, usagedetail.FieldApp)
  30071. }
  30072. if m.session_id != nil {
  30073. fields = append(fields, usagedetail.FieldSessionID)
  30074. }
  30075. if m.request != nil {
  30076. fields = append(fields, usagedetail.FieldRequest)
  30077. }
  30078. if m.response != nil {
  30079. fields = append(fields, usagedetail.FieldResponse)
  30080. }
  30081. if m.original_data != nil {
  30082. fields = append(fields, usagedetail.FieldOriginalData)
  30083. }
  30084. if m.total_tokens != nil {
  30085. fields = append(fields, usagedetail.FieldTotalTokens)
  30086. }
  30087. if m.prompt_tokens != nil {
  30088. fields = append(fields, usagedetail.FieldPromptTokens)
  30089. }
  30090. if m.completion_tokens != nil {
  30091. fields = append(fields, usagedetail.FieldCompletionTokens)
  30092. }
  30093. if m.organization_id != nil {
  30094. fields = append(fields, usagedetail.FieldOrganizationID)
  30095. }
  30096. return fields
  30097. }
  30098. // Field returns the value of a field with the given name. The second boolean
  30099. // return value indicates that this field was not set, or was not defined in the
  30100. // schema.
  30101. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  30102. switch name {
  30103. case usagedetail.FieldCreatedAt:
  30104. return m.CreatedAt()
  30105. case usagedetail.FieldUpdatedAt:
  30106. return m.UpdatedAt()
  30107. case usagedetail.FieldStatus:
  30108. return m.Status()
  30109. case usagedetail.FieldType:
  30110. return m.GetType()
  30111. case usagedetail.FieldBotID:
  30112. return m.BotID()
  30113. case usagedetail.FieldReceiverID:
  30114. return m.ReceiverID()
  30115. case usagedetail.FieldApp:
  30116. return m.App()
  30117. case usagedetail.FieldSessionID:
  30118. return m.SessionID()
  30119. case usagedetail.FieldRequest:
  30120. return m.Request()
  30121. case usagedetail.FieldResponse:
  30122. return m.Response()
  30123. case usagedetail.FieldOriginalData:
  30124. return m.OriginalData()
  30125. case usagedetail.FieldTotalTokens:
  30126. return m.TotalTokens()
  30127. case usagedetail.FieldPromptTokens:
  30128. return m.PromptTokens()
  30129. case usagedetail.FieldCompletionTokens:
  30130. return m.CompletionTokens()
  30131. case usagedetail.FieldOrganizationID:
  30132. return m.OrganizationID()
  30133. }
  30134. return nil, false
  30135. }
  30136. // OldField returns the old value of the field from the database. An error is
  30137. // returned if the mutation operation is not UpdateOne, or the query to the
  30138. // database failed.
  30139. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30140. switch name {
  30141. case usagedetail.FieldCreatedAt:
  30142. return m.OldCreatedAt(ctx)
  30143. case usagedetail.FieldUpdatedAt:
  30144. return m.OldUpdatedAt(ctx)
  30145. case usagedetail.FieldStatus:
  30146. return m.OldStatus(ctx)
  30147. case usagedetail.FieldType:
  30148. return m.OldType(ctx)
  30149. case usagedetail.FieldBotID:
  30150. return m.OldBotID(ctx)
  30151. case usagedetail.FieldReceiverID:
  30152. return m.OldReceiverID(ctx)
  30153. case usagedetail.FieldApp:
  30154. return m.OldApp(ctx)
  30155. case usagedetail.FieldSessionID:
  30156. return m.OldSessionID(ctx)
  30157. case usagedetail.FieldRequest:
  30158. return m.OldRequest(ctx)
  30159. case usagedetail.FieldResponse:
  30160. return m.OldResponse(ctx)
  30161. case usagedetail.FieldOriginalData:
  30162. return m.OldOriginalData(ctx)
  30163. case usagedetail.FieldTotalTokens:
  30164. return m.OldTotalTokens(ctx)
  30165. case usagedetail.FieldPromptTokens:
  30166. return m.OldPromptTokens(ctx)
  30167. case usagedetail.FieldCompletionTokens:
  30168. return m.OldCompletionTokens(ctx)
  30169. case usagedetail.FieldOrganizationID:
  30170. return m.OldOrganizationID(ctx)
  30171. }
  30172. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  30173. }
  30174. // SetField sets the value of a field with the given name. It returns an error if
  30175. // the field is not defined in the schema, or if the type mismatched the field
  30176. // type.
  30177. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  30178. switch name {
  30179. case usagedetail.FieldCreatedAt:
  30180. v, ok := value.(time.Time)
  30181. if !ok {
  30182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30183. }
  30184. m.SetCreatedAt(v)
  30185. return nil
  30186. case usagedetail.FieldUpdatedAt:
  30187. v, ok := value.(time.Time)
  30188. if !ok {
  30189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30190. }
  30191. m.SetUpdatedAt(v)
  30192. return nil
  30193. case usagedetail.FieldStatus:
  30194. v, ok := value.(uint8)
  30195. if !ok {
  30196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30197. }
  30198. m.SetStatus(v)
  30199. return nil
  30200. case usagedetail.FieldType:
  30201. v, ok := value.(int)
  30202. if !ok {
  30203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30204. }
  30205. m.SetType(v)
  30206. return nil
  30207. case usagedetail.FieldBotID:
  30208. v, ok := value.(string)
  30209. if !ok {
  30210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30211. }
  30212. m.SetBotID(v)
  30213. return nil
  30214. case usagedetail.FieldReceiverID:
  30215. v, ok := value.(string)
  30216. if !ok {
  30217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30218. }
  30219. m.SetReceiverID(v)
  30220. return nil
  30221. case usagedetail.FieldApp:
  30222. v, ok := value.(int)
  30223. if !ok {
  30224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30225. }
  30226. m.SetApp(v)
  30227. return nil
  30228. case usagedetail.FieldSessionID:
  30229. v, ok := value.(uint64)
  30230. if !ok {
  30231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30232. }
  30233. m.SetSessionID(v)
  30234. return nil
  30235. case usagedetail.FieldRequest:
  30236. v, ok := value.(string)
  30237. if !ok {
  30238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30239. }
  30240. m.SetRequest(v)
  30241. return nil
  30242. case usagedetail.FieldResponse:
  30243. v, ok := value.(string)
  30244. if !ok {
  30245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30246. }
  30247. m.SetResponse(v)
  30248. return nil
  30249. case usagedetail.FieldOriginalData:
  30250. v, ok := value.(custom_types.OriginalData)
  30251. if !ok {
  30252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30253. }
  30254. m.SetOriginalData(v)
  30255. return nil
  30256. case usagedetail.FieldTotalTokens:
  30257. v, ok := value.(uint64)
  30258. if !ok {
  30259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30260. }
  30261. m.SetTotalTokens(v)
  30262. return nil
  30263. case usagedetail.FieldPromptTokens:
  30264. v, ok := value.(uint64)
  30265. if !ok {
  30266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30267. }
  30268. m.SetPromptTokens(v)
  30269. return nil
  30270. case usagedetail.FieldCompletionTokens:
  30271. v, ok := value.(uint64)
  30272. if !ok {
  30273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30274. }
  30275. m.SetCompletionTokens(v)
  30276. return nil
  30277. case usagedetail.FieldOrganizationID:
  30278. v, ok := value.(uint64)
  30279. if !ok {
  30280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30281. }
  30282. m.SetOrganizationID(v)
  30283. return nil
  30284. }
  30285. return fmt.Errorf("unknown UsageDetail field %s", name)
  30286. }
  30287. // AddedFields returns all numeric fields that were incremented/decremented during
  30288. // this mutation.
  30289. func (m *UsageDetailMutation) AddedFields() []string {
  30290. var fields []string
  30291. if m.addstatus != nil {
  30292. fields = append(fields, usagedetail.FieldStatus)
  30293. }
  30294. if m.add_type != nil {
  30295. fields = append(fields, usagedetail.FieldType)
  30296. }
  30297. if m.addapp != nil {
  30298. fields = append(fields, usagedetail.FieldApp)
  30299. }
  30300. if m.addsession_id != nil {
  30301. fields = append(fields, usagedetail.FieldSessionID)
  30302. }
  30303. if m.addtotal_tokens != nil {
  30304. fields = append(fields, usagedetail.FieldTotalTokens)
  30305. }
  30306. if m.addprompt_tokens != nil {
  30307. fields = append(fields, usagedetail.FieldPromptTokens)
  30308. }
  30309. if m.addcompletion_tokens != nil {
  30310. fields = append(fields, usagedetail.FieldCompletionTokens)
  30311. }
  30312. if m.addorganization_id != nil {
  30313. fields = append(fields, usagedetail.FieldOrganizationID)
  30314. }
  30315. return fields
  30316. }
  30317. // AddedField returns the numeric value that was incremented/decremented on a field
  30318. // with the given name. The second boolean return value indicates that this field
  30319. // was not set, or was not defined in the schema.
  30320. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  30321. switch name {
  30322. case usagedetail.FieldStatus:
  30323. return m.AddedStatus()
  30324. case usagedetail.FieldType:
  30325. return m.AddedType()
  30326. case usagedetail.FieldApp:
  30327. return m.AddedApp()
  30328. case usagedetail.FieldSessionID:
  30329. return m.AddedSessionID()
  30330. case usagedetail.FieldTotalTokens:
  30331. return m.AddedTotalTokens()
  30332. case usagedetail.FieldPromptTokens:
  30333. return m.AddedPromptTokens()
  30334. case usagedetail.FieldCompletionTokens:
  30335. return m.AddedCompletionTokens()
  30336. case usagedetail.FieldOrganizationID:
  30337. return m.AddedOrganizationID()
  30338. }
  30339. return nil, false
  30340. }
  30341. // AddField adds the value to the field with the given name. It returns an error if
  30342. // the field is not defined in the schema, or if the type mismatched the field
  30343. // type.
  30344. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  30345. switch name {
  30346. case usagedetail.FieldStatus:
  30347. v, ok := value.(int8)
  30348. if !ok {
  30349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30350. }
  30351. m.AddStatus(v)
  30352. return nil
  30353. case usagedetail.FieldType:
  30354. v, ok := value.(int)
  30355. if !ok {
  30356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30357. }
  30358. m.AddType(v)
  30359. return nil
  30360. case usagedetail.FieldApp:
  30361. v, ok := value.(int)
  30362. if !ok {
  30363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30364. }
  30365. m.AddApp(v)
  30366. return nil
  30367. case usagedetail.FieldSessionID:
  30368. v, ok := value.(int64)
  30369. if !ok {
  30370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30371. }
  30372. m.AddSessionID(v)
  30373. return nil
  30374. case usagedetail.FieldTotalTokens:
  30375. v, ok := value.(int64)
  30376. if !ok {
  30377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30378. }
  30379. m.AddTotalTokens(v)
  30380. return nil
  30381. case usagedetail.FieldPromptTokens:
  30382. v, ok := value.(int64)
  30383. if !ok {
  30384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30385. }
  30386. m.AddPromptTokens(v)
  30387. return nil
  30388. case usagedetail.FieldCompletionTokens:
  30389. v, ok := value.(int64)
  30390. if !ok {
  30391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30392. }
  30393. m.AddCompletionTokens(v)
  30394. return nil
  30395. case usagedetail.FieldOrganizationID:
  30396. v, ok := value.(int64)
  30397. if !ok {
  30398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30399. }
  30400. m.AddOrganizationID(v)
  30401. return nil
  30402. }
  30403. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  30404. }
  30405. // ClearedFields returns all nullable fields that were cleared during this
  30406. // mutation.
  30407. func (m *UsageDetailMutation) ClearedFields() []string {
  30408. var fields []string
  30409. if m.FieldCleared(usagedetail.FieldStatus) {
  30410. fields = append(fields, usagedetail.FieldStatus)
  30411. }
  30412. if m.FieldCleared(usagedetail.FieldType) {
  30413. fields = append(fields, usagedetail.FieldType)
  30414. }
  30415. if m.FieldCleared(usagedetail.FieldApp) {
  30416. fields = append(fields, usagedetail.FieldApp)
  30417. }
  30418. if m.FieldCleared(usagedetail.FieldSessionID) {
  30419. fields = append(fields, usagedetail.FieldSessionID)
  30420. }
  30421. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  30422. fields = append(fields, usagedetail.FieldTotalTokens)
  30423. }
  30424. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  30425. fields = append(fields, usagedetail.FieldPromptTokens)
  30426. }
  30427. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  30428. fields = append(fields, usagedetail.FieldCompletionTokens)
  30429. }
  30430. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  30431. fields = append(fields, usagedetail.FieldOrganizationID)
  30432. }
  30433. return fields
  30434. }
  30435. // FieldCleared returns a boolean indicating if a field with the given name was
  30436. // cleared in this mutation.
  30437. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  30438. _, ok := m.clearedFields[name]
  30439. return ok
  30440. }
  30441. // ClearField clears the value of the field with the given name. It returns an
  30442. // error if the field is not defined in the schema.
  30443. func (m *UsageDetailMutation) ClearField(name string) error {
  30444. switch name {
  30445. case usagedetail.FieldStatus:
  30446. m.ClearStatus()
  30447. return nil
  30448. case usagedetail.FieldType:
  30449. m.ClearType()
  30450. return nil
  30451. case usagedetail.FieldApp:
  30452. m.ClearApp()
  30453. return nil
  30454. case usagedetail.FieldSessionID:
  30455. m.ClearSessionID()
  30456. return nil
  30457. case usagedetail.FieldTotalTokens:
  30458. m.ClearTotalTokens()
  30459. return nil
  30460. case usagedetail.FieldPromptTokens:
  30461. m.ClearPromptTokens()
  30462. return nil
  30463. case usagedetail.FieldCompletionTokens:
  30464. m.ClearCompletionTokens()
  30465. return nil
  30466. case usagedetail.FieldOrganizationID:
  30467. m.ClearOrganizationID()
  30468. return nil
  30469. }
  30470. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  30471. }
  30472. // ResetField resets all changes in the mutation for the field with the given name.
  30473. // It returns an error if the field is not defined in the schema.
  30474. func (m *UsageDetailMutation) ResetField(name string) error {
  30475. switch name {
  30476. case usagedetail.FieldCreatedAt:
  30477. m.ResetCreatedAt()
  30478. return nil
  30479. case usagedetail.FieldUpdatedAt:
  30480. m.ResetUpdatedAt()
  30481. return nil
  30482. case usagedetail.FieldStatus:
  30483. m.ResetStatus()
  30484. return nil
  30485. case usagedetail.FieldType:
  30486. m.ResetType()
  30487. return nil
  30488. case usagedetail.FieldBotID:
  30489. m.ResetBotID()
  30490. return nil
  30491. case usagedetail.FieldReceiverID:
  30492. m.ResetReceiverID()
  30493. return nil
  30494. case usagedetail.FieldApp:
  30495. m.ResetApp()
  30496. return nil
  30497. case usagedetail.FieldSessionID:
  30498. m.ResetSessionID()
  30499. return nil
  30500. case usagedetail.FieldRequest:
  30501. m.ResetRequest()
  30502. return nil
  30503. case usagedetail.FieldResponse:
  30504. m.ResetResponse()
  30505. return nil
  30506. case usagedetail.FieldOriginalData:
  30507. m.ResetOriginalData()
  30508. return nil
  30509. case usagedetail.FieldTotalTokens:
  30510. m.ResetTotalTokens()
  30511. return nil
  30512. case usagedetail.FieldPromptTokens:
  30513. m.ResetPromptTokens()
  30514. return nil
  30515. case usagedetail.FieldCompletionTokens:
  30516. m.ResetCompletionTokens()
  30517. return nil
  30518. case usagedetail.FieldOrganizationID:
  30519. m.ResetOrganizationID()
  30520. return nil
  30521. }
  30522. return fmt.Errorf("unknown UsageDetail field %s", name)
  30523. }
  30524. // AddedEdges returns all edge names that were set/added in this mutation.
  30525. func (m *UsageDetailMutation) AddedEdges() []string {
  30526. edges := make([]string, 0, 0)
  30527. return edges
  30528. }
  30529. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30530. // name in this mutation.
  30531. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  30532. return nil
  30533. }
  30534. // RemovedEdges returns all edge names that were removed in this mutation.
  30535. func (m *UsageDetailMutation) RemovedEdges() []string {
  30536. edges := make([]string, 0, 0)
  30537. return edges
  30538. }
  30539. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30540. // the given name in this mutation.
  30541. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  30542. return nil
  30543. }
  30544. // ClearedEdges returns all edge names that were cleared in this mutation.
  30545. func (m *UsageDetailMutation) ClearedEdges() []string {
  30546. edges := make([]string, 0, 0)
  30547. return edges
  30548. }
  30549. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30550. // was cleared in this mutation.
  30551. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  30552. return false
  30553. }
  30554. // ClearEdge clears the value of the edge with the given name. It returns an error
  30555. // if that edge is not defined in the schema.
  30556. func (m *UsageDetailMutation) ClearEdge(name string) error {
  30557. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  30558. }
  30559. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30560. // It returns an error if the edge is not defined in the schema.
  30561. func (m *UsageDetailMutation) ResetEdge(name string) error {
  30562. return fmt.Errorf("unknown UsageDetail edge %s", name)
  30563. }
  30564. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  30565. type UsageStatisticDayMutation struct {
  30566. config
  30567. op Op
  30568. typ string
  30569. id *uint64
  30570. created_at *time.Time
  30571. updated_at *time.Time
  30572. status *uint8
  30573. addstatus *int8
  30574. deleted_at *time.Time
  30575. addtime *uint64
  30576. addaddtime *int64
  30577. _type *int
  30578. add_type *int
  30579. bot_id *string
  30580. organization_id *uint64
  30581. addorganization_id *int64
  30582. ai_response *uint64
  30583. addai_response *int64
  30584. sop_run *uint64
  30585. addsop_run *int64
  30586. total_friend *uint64
  30587. addtotal_friend *int64
  30588. total_group *uint64
  30589. addtotal_group *int64
  30590. account_balance *uint64
  30591. addaccount_balance *int64
  30592. consume_token *uint64
  30593. addconsume_token *int64
  30594. active_user *uint64
  30595. addactive_user *int64
  30596. new_user *int64
  30597. addnew_user *int64
  30598. label_dist *[]custom_types.LabelDist
  30599. appendlabel_dist []custom_types.LabelDist
  30600. clearedFields map[string]struct{}
  30601. done bool
  30602. oldValue func(context.Context) (*UsageStatisticDay, error)
  30603. predicates []predicate.UsageStatisticDay
  30604. }
  30605. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  30606. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  30607. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  30608. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  30609. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  30610. m := &UsageStatisticDayMutation{
  30611. config: c,
  30612. op: op,
  30613. typ: TypeUsageStatisticDay,
  30614. clearedFields: make(map[string]struct{}),
  30615. }
  30616. for _, opt := range opts {
  30617. opt(m)
  30618. }
  30619. return m
  30620. }
  30621. // withUsageStatisticDayID sets the ID field of the mutation.
  30622. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  30623. return func(m *UsageStatisticDayMutation) {
  30624. var (
  30625. err error
  30626. once sync.Once
  30627. value *UsageStatisticDay
  30628. )
  30629. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  30630. once.Do(func() {
  30631. if m.done {
  30632. err = errors.New("querying old values post mutation is not allowed")
  30633. } else {
  30634. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  30635. }
  30636. })
  30637. return value, err
  30638. }
  30639. m.id = &id
  30640. }
  30641. }
  30642. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  30643. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  30644. return func(m *UsageStatisticDayMutation) {
  30645. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  30646. return node, nil
  30647. }
  30648. m.id = &node.ID
  30649. }
  30650. }
  30651. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30652. // executed in a transaction (ent.Tx), a transactional client is returned.
  30653. func (m UsageStatisticDayMutation) Client() *Client {
  30654. client := &Client{config: m.config}
  30655. client.init()
  30656. return client
  30657. }
  30658. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30659. // it returns an error otherwise.
  30660. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  30661. if _, ok := m.driver.(*txDriver); !ok {
  30662. return nil, errors.New("ent: mutation is not running in a transaction")
  30663. }
  30664. tx := &Tx{config: m.config}
  30665. tx.init()
  30666. return tx, nil
  30667. }
  30668. // SetID sets the value of the id field. Note that this
  30669. // operation is only accepted on creation of UsageStatisticDay entities.
  30670. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  30671. m.id = &id
  30672. }
  30673. // ID returns the ID value in the mutation. Note that the ID is only available
  30674. // if it was provided to the builder or after it was returned from the database.
  30675. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  30676. if m.id == nil {
  30677. return
  30678. }
  30679. return *m.id, true
  30680. }
  30681. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30682. // That means, if the mutation is applied within a transaction with an isolation level such
  30683. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30684. // or updated by the mutation.
  30685. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  30686. switch {
  30687. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30688. id, exists := m.ID()
  30689. if exists {
  30690. return []uint64{id}, nil
  30691. }
  30692. fallthrough
  30693. case m.op.Is(OpUpdate | OpDelete):
  30694. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  30695. default:
  30696. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30697. }
  30698. }
  30699. // SetCreatedAt sets the "created_at" field.
  30700. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  30701. m.created_at = &t
  30702. }
  30703. // CreatedAt returns the value of the "created_at" field in the mutation.
  30704. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  30705. v := m.created_at
  30706. if v == nil {
  30707. return
  30708. }
  30709. return *v, true
  30710. }
  30711. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  30712. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30714. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30715. if !m.op.Is(OpUpdateOne) {
  30716. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30717. }
  30718. if m.id == nil || m.oldValue == nil {
  30719. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30720. }
  30721. oldValue, err := m.oldValue(ctx)
  30722. if err != nil {
  30723. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30724. }
  30725. return oldValue.CreatedAt, nil
  30726. }
  30727. // ResetCreatedAt resets all changes to the "created_at" field.
  30728. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  30729. m.created_at = nil
  30730. }
  30731. // SetUpdatedAt sets the "updated_at" field.
  30732. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  30733. m.updated_at = &t
  30734. }
  30735. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30736. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  30737. v := m.updated_at
  30738. if v == nil {
  30739. return
  30740. }
  30741. return *v, true
  30742. }
  30743. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  30744. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30746. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30747. if !m.op.Is(OpUpdateOne) {
  30748. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30749. }
  30750. if m.id == nil || m.oldValue == nil {
  30751. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30752. }
  30753. oldValue, err := m.oldValue(ctx)
  30754. if err != nil {
  30755. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30756. }
  30757. return oldValue.UpdatedAt, nil
  30758. }
  30759. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30760. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  30761. m.updated_at = nil
  30762. }
  30763. // SetStatus sets the "status" field.
  30764. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  30765. m.status = &u
  30766. m.addstatus = nil
  30767. }
  30768. // Status returns the value of the "status" field in the mutation.
  30769. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  30770. v := m.status
  30771. if v == nil {
  30772. return
  30773. }
  30774. return *v, true
  30775. }
  30776. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  30777. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30779. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30780. if !m.op.Is(OpUpdateOne) {
  30781. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30782. }
  30783. if m.id == nil || m.oldValue == nil {
  30784. return v, errors.New("OldStatus requires an ID field in the mutation")
  30785. }
  30786. oldValue, err := m.oldValue(ctx)
  30787. if err != nil {
  30788. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30789. }
  30790. return oldValue.Status, nil
  30791. }
  30792. // AddStatus adds u to the "status" field.
  30793. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  30794. if m.addstatus != nil {
  30795. *m.addstatus += u
  30796. } else {
  30797. m.addstatus = &u
  30798. }
  30799. }
  30800. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30801. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  30802. v := m.addstatus
  30803. if v == nil {
  30804. return
  30805. }
  30806. return *v, true
  30807. }
  30808. // ClearStatus clears the value of the "status" field.
  30809. func (m *UsageStatisticDayMutation) ClearStatus() {
  30810. m.status = nil
  30811. m.addstatus = nil
  30812. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  30813. }
  30814. // StatusCleared returns if the "status" field was cleared in this mutation.
  30815. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  30816. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  30817. return ok
  30818. }
  30819. // ResetStatus resets all changes to the "status" field.
  30820. func (m *UsageStatisticDayMutation) ResetStatus() {
  30821. m.status = nil
  30822. m.addstatus = nil
  30823. delete(m.clearedFields, usagestatisticday.FieldStatus)
  30824. }
  30825. // SetDeletedAt sets the "deleted_at" field.
  30826. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  30827. m.deleted_at = &t
  30828. }
  30829. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30830. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  30831. v := m.deleted_at
  30832. if v == nil {
  30833. return
  30834. }
  30835. return *v, true
  30836. }
  30837. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  30838. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30840. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30841. if !m.op.Is(OpUpdateOne) {
  30842. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30843. }
  30844. if m.id == nil || m.oldValue == nil {
  30845. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30846. }
  30847. oldValue, err := m.oldValue(ctx)
  30848. if err != nil {
  30849. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30850. }
  30851. return oldValue.DeletedAt, nil
  30852. }
  30853. // ClearDeletedAt clears the value of the "deleted_at" field.
  30854. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  30855. m.deleted_at = nil
  30856. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  30857. }
  30858. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30859. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  30860. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  30861. return ok
  30862. }
  30863. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30864. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  30865. m.deleted_at = nil
  30866. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  30867. }
  30868. // SetAddtime sets the "addtime" field.
  30869. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  30870. m.addtime = &u
  30871. m.addaddtime = nil
  30872. }
  30873. // Addtime returns the value of the "addtime" field in the mutation.
  30874. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  30875. v := m.addtime
  30876. if v == nil {
  30877. return
  30878. }
  30879. return *v, true
  30880. }
  30881. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  30882. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30884. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30885. if !m.op.Is(OpUpdateOne) {
  30886. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30887. }
  30888. if m.id == nil || m.oldValue == nil {
  30889. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30890. }
  30891. oldValue, err := m.oldValue(ctx)
  30892. if err != nil {
  30893. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30894. }
  30895. return oldValue.Addtime, nil
  30896. }
  30897. // AddAddtime adds u to the "addtime" field.
  30898. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  30899. if m.addaddtime != nil {
  30900. *m.addaddtime += u
  30901. } else {
  30902. m.addaddtime = &u
  30903. }
  30904. }
  30905. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30906. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  30907. v := m.addaddtime
  30908. if v == nil {
  30909. return
  30910. }
  30911. return *v, true
  30912. }
  30913. // ResetAddtime resets all changes to the "addtime" field.
  30914. func (m *UsageStatisticDayMutation) ResetAddtime() {
  30915. m.addtime = nil
  30916. m.addaddtime = nil
  30917. }
  30918. // SetType sets the "type" field.
  30919. func (m *UsageStatisticDayMutation) SetType(i int) {
  30920. m._type = &i
  30921. m.add_type = nil
  30922. }
  30923. // GetType returns the value of the "type" field in the mutation.
  30924. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  30925. v := m._type
  30926. if v == nil {
  30927. return
  30928. }
  30929. return *v, true
  30930. }
  30931. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  30932. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30934. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  30935. if !m.op.Is(OpUpdateOne) {
  30936. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30937. }
  30938. if m.id == nil || m.oldValue == nil {
  30939. return v, errors.New("OldType requires an ID field in the mutation")
  30940. }
  30941. oldValue, err := m.oldValue(ctx)
  30942. if err != nil {
  30943. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30944. }
  30945. return oldValue.Type, nil
  30946. }
  30947. // AddType adds i to the "type" field.
  30948. func (m *UsageStatisticDayMutation) AddType(i int) {
  30949. if m.add_type != nil {
  30950. *m.add_type += i
  30951. } else {
  30952. m.add_type = &i
  30953. }
  30954. }
  30955. // AddedType returns the value that was added to the "type" field in this mutation.
  30956. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  30957. v := m.add_type
  30958. if v == nil {
  30959. return
  30960. }
  30961. return *v, true
  30962. }
  30963. // ResetType resets all changes to the "type" field.
  30964. func (m *UsageStatisticDayMutation) ResetType() {
  30965. m._type = nil
  30966. m.add_type = nil
  30967. }
  30968. // SetBotID sets the "bot_id" field.
  30969. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  30970. m.bot_id = &s
  30971. }
  30972. // BotID returns the value of the "bot_id" field in the mutation.
  30973. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  30974. v := m.bot_id
  30975. if v == nil {
  30976. return
  30977. }
  30978. return *v, true
  30979. }
  30980. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  30981. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  30982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30983. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  30984. if !m.op.Is(OpUpdateOne) {
  30985. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30986. }
  30987. if m.id == nil || m.oldValue == nil {
  30988. return v, errors.New("OldBotID requires an ID field in the mutation")
  30989. }
  30990. oldValue, err := m.oldValue(ctx)
  30991. if err != nil {
  30992. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30993. }
  30994. return oldValue.BotID, nil
  30995. }
  30996. // ClearBotID clears the value of the "bot_id" field.
  30997. func (m *UsageStatisticDayMutation) ClearBotID() {
  30998. m.bot_id = nil
  30999. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  31000. }
  31001. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31002. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  31003. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  31004. return ok
  31005. }
  31006. // ResetBotID resets all changes to the "bot_id" field.
  31007. func (m *UsageStatisticDayMutation) ResetBotID() {
  31008. m.bot_id = nil
  31009. delete(m.clearedFields, usagestatisticday.FieldBotID)
  31010. }
  31011. // SetOrganizationID sets the "organization_id" field.
  31012. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  31013. m.organization_id = &u
  31014. m.addorganization_id = nil
  31015. }
  31016. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31017. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  31018. v := m.organization_id
  31019. if v == nil {
  31020. return
  31021. }
  31022. return *v, true
  31023. }
  31024. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  31025. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31027. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31028. if !m.op.Is(OpUpdateOne) {
  31029. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31030. }
  31031. if m.id == nil || m.oldValue == nil {
  31032. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31033. }
  31034. oldValue, err := m.oldValue(ctx)
  31035. if err != nil {
  31036. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31037. }
  31038. return oldValue.OrganizationID, nil
  31039. }
  31040. // AddOrganizationID adds u to the "organization_id" field.
  31041. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  31042. if m.addorganization_id != nil {
  31043. *m.addorganization_id += u
  31044. } else {
  31045. m.addorganization_id = &u
  31046. }
  31047. }
  31048. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31049. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  31050. v := m.addorganization_id
  31051. if v == nil {
  31052. return
  31053. }
  31054. return *v, true
  31055. }
  31056. // ClearOrganizationID clears the value of the "organization_id" field.
  31057. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  31058. m.organization_id = nil
  31059. m.addorganization_id = nil
  31060. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  31061. }
  31062. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31063. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  31064. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  31065. return ok
  31066. }
  31067. // ResetOrganizationID resets all changes to the "organization_id" field.
  31068. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  31069. m.organization_id = nil
  31070. m.addorganization_id = nil
  31071. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  31072. }
  31073. // SetAiResponse sets the "ai_response" field.
  31074. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  31075. m.ai_response = &u
  31076. m.addai_response = nil
  31077. }
  31078. // AiResponse returns the value of the "ai_response" field in the mutation.
  31079. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  31080. v := m.ai_response
  31081. if v == nil {
  31082. return
  31083. }
  31084. return *v, true
  31085. }
  31086. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  31087. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31089. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31090. if !m.op.Is(OpUpdateOne) {
  31091. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31092. }
  31093. if m.id == nil || m.oldValue == nil {
  31094. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31095. }
  31096. oldValue, err := m.oldValue(ctx)
  31097. if err != nil {
  31098. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31099. }
  31100. return oldValue.AiResponse, nil
  31101. }
  31102. // AddAiResponse adds u to the "ai_response" field.
  31103. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  31104. if m.addai_response != nil {
  31105. *m.addai_response += u
  31106. } else {
  31107. m.addai_response = &u
  31108. }
  31109. }
  31110. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31111. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  31112. v := m.addai_response
  31113. if v == nil {
  31114. return
  31115. }
  31116. return *v, true
  31117. }
  31118. // ResetAiResponse resets all changes to the "ai_response" field.
  31119. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  31120. m.ai_response = nil
  31121. m.addai_response = nil
  31122. }
  31123. // SetSopRun sets the "sop_run" field.
  31124. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  31125. m.sop_run = &u
  31126. m.addsop_run = nil
  31127. }
  31128. // SopRun returns the value of the "sop_run" field in the mutation.
  31129. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  31130. v := m.sop_run
  31131. if v == nil {
  31132. return
  31133. }
  31134. return *v, true
  31135. }
  31136. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  31137. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31139. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31140. if !m.op.Is(OpUpdateOne) {
  31141. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31142. }
  31143. if m.id == nil || m.oldValue == nil {
  31144. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31145. }
  31146. oldValue, err := m.oldValue(ctx)
  31147. if err != nil {
  31148. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31149. }
  31150. return oldValue.SopRun, nil
  31151. }
  31152. // AddSopRun adds u to the "sop_run" field.
  31153. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  31154. if m.addsop_run != nil {
  31155. *m.addsop_run += u
  31156. } else {
  31157. m.addsop_run = &u
  31158. }
  31159. }
  31160. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31161. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  31162. v := m.addsop_run
  31163. if v == nil {
  31164. return
  31165. }
  31166. return *v, true
  31167. }
  31168. // ResetSopRun resets all changes to the "sop_run" field.
  31169. func (m *UsageStatisticDayMutation) ResetSopRun() {
  31170. m.sop_run = nil
  31171. m.addsop_run = nil
  31172. }
  31173. // SetTotalFriend sets the "total_friend" field.
  31174. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  31175. m.total_friend = &u
  31176. m.addtotal_friend = nil
  31177. }
  31178. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31179. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  31180. v := m.total_friend
  31181. if v == nil {
  31182. return
  31183. }
  31184. return *v, true
  31185. }
  31186. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  31187. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31189. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31190. if !m.op.Is(OpUpdateOne) {
  31191. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31192. }
  31193. if m.id == nil || m.oldValue == nil {
  31194. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31195. }
  31196. oldValue, err := m.oldValue(ctx)
  31197. if err != nil {
  31198. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31199. }
  31200. return oldValue.TotalFriend, nil
  31201. }
  31202. // AddTotalFriend adds u to the "total_friend" field.
  31203. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  31204. if m.addtotal_friend != nil {
  31205. *m.addtotal_friend += u
  31206. } else {
  31207. m.addtotal_friend = &u
  31208. }
  31209. }
  31210. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31211. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  31212. v := m.addtotal_friend
  31213. if v == nil {
  31214. return
  31215. }
  31216. return *v, true
  31217. }
  31218. // ResetTotalFriend resets all changes to the "total_friend" field.
  31219. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  31220. m.total_friend = nil
  31221. m.addtotal_friend = nil
  31222. }
  31223. // SetTotalGroup sets the "total_group" field.
  31224. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  31225. m.total_group = &u
  31226. m.addtotal_group = nil
  31227. }
  31228. // TotalGroup returns the value of the "total_group" field in the mutation.
  31229. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  31230. v := m.total_group
  31231. if v == nil {
  31232. return
  31233. }
  31234. return *v, true
  31235. }
  31236. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  31237. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31239. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31240. if !m.op.Is(OpUpdateOne) {
  31241. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31242. }
  31243. if m.id == nil || m.oldValue == nil {
  31244. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31245. }
  31246. oldValue, err := m.oldValue(ctx)
  31247. if err != nil {
  31248. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31249. }
  31250. return oldValue.TotalGroup, nil
  31251. }
  31252. // AddTotalGroup adds u to the "total_group" field.
  31253. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  31254. if m.addtotal_group != nil {
  31255. *m.addtotal_group += u
  31256. } else {
  31257. m.addtotal_group = &u
  31258. }
  31259. }
  31260. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31261. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  31262. v := m.addtotal_group
  31263. if v == nil {
  31264. return
  31265. }
  31266. return *v, true
  31267. }
  31268. // ResetTotalGroup resets all changes to the "total_group" field.
  31269. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  31270. m.total_group = nil
  31271. m.addtotal_group = nil
  31272. }
  31273. // SetAccountBalance sets the "account_balance" field.
  31274. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  31275. m.account_balance = &u
  31276. m.addaccount_balance = nil
  31277. }
  31278. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31279. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  31280. v := m.account_balance
  31281. if v == nil {
  31282. return
  31283. }
  31284. return *v, true
  31285. }
  31286. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  31287. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31289. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31290. if !m.op.Is(OpUpdateOne) {
  31291. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31292. }
  31293. if m.id == nil || m.oldValue == nil {
  31294. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31295. }
  31296. oldValue, err := m.oldValue(ctx)
  31297. if err != nil {
  31298. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31299. }
  31300. return oldValue.AccountBalance, nil
  31301. }
  31302. // AddAccountBalance adds u to the "account_balance" field.
  31303. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  31304. if m.addaccount_balance != nil {
  31305. *m.addaccount_balance += u
  31306. } else {
  31307. m.addaccount_balance = &u
  31308. }
  31309. }
  31310. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31311. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  31312. v := m.addaccount_balance
  31313. if v == nil {
  31314. return
  31315. }
  31316. return *v, true
  31317. }
  31318. // ResetAccountBalance resets all changes to the "account_balance" field.
  31319. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  31320. m.account_balance = nil
  31321. m.addaccount_balance = nil
  31322. }
  31323. // SetConsumeToken sets the "consume_token" field.
  31324. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  31325. m.consume_token = &u
  31326. m.addconsume_token = nil
  31327. }
  31328. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31329. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  31330. v := m.consume_token
  31331. if v == nil {
  31332. return
  31333. }
  31334. return *v, true
  31335. }
  31336. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  31337. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31339. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31340. if !m.op.Is(OpUpdateOne) {
  31341. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31342. }
  31343. if m.id == nil || m.oldValue == nil {
  31344. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31345. }
  31346. oldValue, err := m.oldValue(ctx)
  31347. if err != nil {
  31348. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31349. }
  31350. return oldValue.ConsumeToken, nil
  31351. }
  31352. // AddConsumeToken adds u to the "consume_token" field.
  31353. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  31354. if m.addconsume_token != nil {
  31355. *m.addconsume_token += u
  31356. } else {
  31357. m.addconsume_token = &u
  31358. }
  31359. }
  31360. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31361. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  31362. v := m.addconsume_token
  31363. if v == nil {
  31364. return
  31365. }
  31366. return *v, true
  31367. }
  31368. // ResetConsumeToken resets all changes to the "consume_token" field.
  31369. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  31370. m.consume_token = nil
  31371. m.addconsume_token = nil
  31372. }
  31373. // SetActiveUser sets the "active_user" field.
  31374. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  31375. m.active_user = &u
  31376. m.addactive_user = nil
  31377. }
  31378. // ActiveUser returns the value of the "active_user" field in the mutation.
  31379. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  31380. v := m.active_user
  31381. if v == nil {
  31382. return
  31383. }
  31384. return *v, true
  31385. }
  31386. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  31387. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31389. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31390. if !m.op.Is(OpUpdateOne) {
  31391. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31392. }
  31393. if m.id == nil || m.oldValue == nil {
  31394. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31395. }
  31396. oldValue, err := m.oldValue(ctx)
  31397. if err != nil {
  31398. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31399. }
  31400. return oldValue.ActiveUser, nil
  31401. }
  31402. // AddActiveUser adds u to the "active_user" field.
  31403. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  31404. if m.addactive_user != nil {
  31405. *m.addactive_user += u
  31406. } else {
  31407. m.addactive_user = &u
  31408. }
  31409. }
  31410. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31411. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  31412. v := m.addactive_user
  31413. if v == nil {
  31414. return
  31415. }
  31416. return *v, true
  31417. }
  31418. // ResetActiveUser resets all changes to the "active_user" field.
  31419. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  31420. m.active_user = nil
  31421. m.addactive_user = nil
  31422. }
  31423. // SetNewUser sets the "new_user" field.
  31424. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  31425. m.new_user = &i
  31426. m.addnew_user = nil
  31427. }
  31428. // NewUser returns the value of the "new_user" field in the mutation.
  31429. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  31430. v := m.new_user
  31431. if v == nil {
  31432. return
  31433. }
  31434. return *v, true
  31435. }
  31436. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  31437. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31439. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31440. if !m.op.Is(OpUpdateOne) {
  31441. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31442. }
  31443. if m.id == nil || m.oldValue == nil {
  31444. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31445. }
  31446. oldValue, err := m.oldValue(ctx)
  31447. if err != nil {
  31448. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31449. }
  31450. return oldValue.NewUser, nil
  31451. }
  31452. // AddNewUser adds i to the "new_user" field.
  31453. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  31454. if m.addnew_user != nil {
  31455. *m.addnew_user += i
  31456. } else {
  31457. m.addnew_user = &i
  31458. }
  31459. }
  31460. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31461. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  31462. v := m.addnew_user
  31463. if v == nil {
  31464. return
  31465. }
  31466. return *v, true
  31467. }
  31468. // ResetNewUser resets all changes to the "new_user" field.
  31469. func (m *UsageStatisticDayMutation) ResetNewUser() {
  31470. m.new_user = nil
  31471. m.addnew_user = nil
  31472. }
  31473. // SetLabelDist sets the "label_dist" field.
  31474. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31475. m.label_dist = &ctd
  31476. m.appendlabel_dist = nil
  31477. }
  31478. // LabelDist returns the value of the "label_dist" field in the mutation.
  31479. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31480. v := m.label_dist
  31481. if v == nil {
  31482. return
  31483. }
  31484. return *v, true
  31485. }
  31486. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  31487. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31489. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31490. if !m.op.Is(OpUpdateOne) {
  31491. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31492. }
  31493. if m.id == nil || m.oldValue == nil {
  31494. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31495. }
  31496. oldValue, err := m.oldValue(ctx)
  31497. if err != nil {
  31498. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31499. }
  31500. return oldValue.LabelDist, nil
  31501. }
  31502. // AppendLabelDist adds ctd to the "label_dist" field.
  31503. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31504. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31505. }
  31506. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31507. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31508. if len(m.appendlabel_dist) == 0 {
  31509. return nil, false
  31510. }
  31511. return m.appendlabel_dist, true
  31512. }
  31513. // ResetLabelDist resets all changes to the "label_dist" field.
  31514. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  31515. m.label_dist = nil
  31516. m.appendlabel_dist = nil
  31517. }
  31518. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  31519. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  31520. m.predicates = append(m.predicates, ps...)
  31521. }
  31522. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  31523. // users can use type-assertion to append predicates that do not depend on any generated package.
  31524. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  31525. p := make([]predicate.UsageStatisticDay, len(ps))
  31526. for i := range ps {
  31527. p[i] = ps[i]
  31528. }
  31529. m.Where(p...)
  31530. }
  31531. // Op returns the operation name.
  31532. func (m *UsageStatisticDayMutation) Op() Op {
  31533. return m.op
  31534. }
  31535. // SetOp allows setting the mutation operation.
  31536. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  31537. m.op = op
  31538. }
  31539. // Type returns the node type of this mutation (UsageStatisticDay).
  31540. func (m *UsageStatisticDayMutation) Type() string {
  31541. return m.typ
  31542. }
  31543. // Fields returns all fields that were changed during this mutation. Note that in
  31544. // order to get all numeric fields that were incremented/decremented, call
  31545. // AddedFields().
  31546. func (m *UsageStatisticDayMutation) Fields() []string {
  31547. fields := make([]string, 0, 17)
  31548. if m.created_at != nil {
  31549. fields = append(fields, usagestatisticday.FieldCreatedAt)
  31550. }
  31551. if m.updated_at != nil {
  31552. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  31553. }
  31554. if m.status != nil {
  31555. fields = append(fields, usagestatisticday.FieldStatus)
  31556. }
  31557. if m.deleted_at != nil {
  31558. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31559. }
  31560. if m.addtime != nil {
  31561. fields = append(fields, usagestatisticday.FieldAddtime)
  31562. }
  31563. if m._type != nil {
  31564. fields = append(fields, usagestatisticday.FieldType)
  31565. }
  31566. if m.bot_id != nil {
  31567. fields = append(fields, usagestatisticday.FieldBotID)
  31568. }
  31569. if m.organization_id != nil {
  31570. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31571. }
  31572. if m.ai_response != nil {
  31573. fields = append(fields, usagestatisticday.FieldAiResponse)
  31574. }
  31575. if m.sop_run != nil {
  31576. fields = append(fields, usagestatisticday.FieldSopRun)
  31577. }
  31578. if m.total_friend != nil {
  31579. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31580. }
  31581. if m.total_group != nil {
  31582. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31583. }
  31584. if m.account_balance != nil {
  31585. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31586. }
  31587. if m.consume_token != nil {
  31588. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31589. }
  31590. if m.active_user != nil {
  31591. fields = append(fields, usagestatisticday.FieldActiveUser)
  31592. }
  31593. if m.new_user != nil {
  31594. fields = append(fields, usagestatisticday.FieldNewUser)
  31595. }
  31596. if m.label_dist != nil {
  31597. fields = append(fields, usagestatisticday.FieldLabelDist)
  31598. }
  31599. return fields
  31600. }
  31601. // Field returns the value of a field with the given name. The second boolean
  31602. // return value indicates that this field was not set, or was not defined in the
  31603. // schema.
  31604. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  31605. switch name {
  31606. case usagestatisticday.FieldCreatedAt:
  31607. return m.CreatedAt()
  31608. case usagestatisticday.FieldUpdatedAt:
  31609. return m.UpdatedAt()
  31610. case usagestatisticday.FieldStatus:
  31611. return m.Status()
  31612. case usagestatisticday.FieldDeletedAt:
  31613. return m.DeletedAt()
  31614. case usagestatisticday.FieldAddtime:
  31615. return m.Addtime()
  31616. case usagestatisticday.FieldType:
  31617. return m.GetType()
  31618. case usagestatisticday.FieldBotID:
  31619. return m.BotID()
  31620. case usagestatisticday.FieldOrganizationID:
  31621. return m.OrganizationID()
  31622. case usagestatisticday.FieldAiResponse:
  31623. return m.AiResponse()
  31624. case usagestatisticday.FieldSopRun:
  31625. return m.SopRun()
  31626. case usagestatisticday.FieldTotalFriend:
  31627. return m.TotalFriend()
  31628. case usagestatisticday.FieldTotalGroup:
  31629. return m.TotalGroup()
  31630. case usagestatisticday.FieldAccountBalance:
  31631. return m.AccountBalance()
  31632. case usagestatisticday.FieldConsumeToken:
  31633. return m.ConsumeToken()
  31634. case usagestatisticday.FieldActiveUser:
  31635. return m.ActiveUser()
  31636. case usagestatisticday.FieldNewUser:
  31637. return m.NewUser()
  31638. case usagestatisticday.FieldLabelDist:
  31639. return m.LabelDist()
  31640. }
  31641. return nil, false
  31642. }
  31643. // OldField returns the old value of the field from the database. An error is
  31644. // returned if the mutation operation is not UpdateOne, or the query to the
  31645. // database failed.
  31646. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31647. switch name {
  31648. case usagestatisticday.FieldCreatedAt:
  31649. return m.OldCreatedAt(ctx)
  31650. case usagestatisticday.FieldUpdatedAt:
  31651. return m.OldUpdatedAt(ctx)
  31652. case usagestatisticday.FieldStatus:
  31653. return m.OldStatus(ctx)
  31654. case usagestatisticday.FieldDeletedAt:
  31655. return m.OldDeletedAt(ctx)
  31656. case usagestatisticday.FieldAddtime:
  31657. return m.OldAddtime(ctx)
  31658. case usagestatisticday.FieldType:
  31659. return m.OldType(ctx)
  31660. case usagestatisticday.FieldBotID:
  31661. return m.OldBotID(ctx)
  31662. case usagestatisticday.FieldOrganizationID:
  31663. return m.OldOrganizationID(ctx)
  31664. case usagestatisticday.FieldAiResponse:
  31665. return m.OldAiResponse(ctx)
  31666. case usagestatisticday.FieldSopRun:
  31667. return m.OldSopRun(ctx)
  31668. case usagestatisticday.FieldTotalFriend:
  31669. return m.OldTotalFriend(ctx)
  31670. case usagestatisticday.FieldTotalGroup:
  31671. return m.OldTotalGroup(ctx)
  31672. case usagestatisticday.FieldAccountBalance:
  31673. return m.OldAccountBalance(ctx)
  31674. case usagestatisticday.FieldConsumeToken:
  31675. return m.OldConsumeToken(ctx)
  31676. case usagestatisticday.FieldActiveUser:
  31677. return m.OldActiveUser(ctx)
  31678. case usagestatisticday.FieldNewUser:
  31679. return m.OldNewUser(ctx)
  31680. case usagestatisticday.FieldLabelDist:
  31681. return m.OldLabelDist(ctx)
  31682. }
  31683. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31684. }
  31685. // SetField sets the value of a field with the given name. It returns an error if
  31686. // the field is not defined in the schema, or if the type mismatched the field
  31687. // type.
  31688. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  31689. switch name {
  31690. case usagestatisticday.FieldCreatedAt:
  31691. v, ok := value.(time.Time)
  31692. if !ok {
  31693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31694. }
  31695. m.SetCreatedAt(v)
  31696. return nil
  31697. case usagestatisticday.FieldUpdatedAt:
  31698. v, ok := value.(time.Time)
  31699. if !ok {
  31700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31701. }
  31702. m.SetUpdatedAt(v)
  31703. return nil
  31704. case usagestatisticday.FieldStatus:
  31705. v, ok := value.(uint8)
  31706. if !ok {
  31707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31708. }
  31709. m.SetStatus(v)
  31710. return nil
  31711. case usagestatisticday.FieldDeletedAt:
  31712. v, ok := value.(time.Time)
  31713. if !ok {
  31714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31715. }
  31716. m.SetDeletedAt(v)
  31717. return nil
  31718. case usagestatisticday.FieldAddtime:
  31719. v, ok := value.(uint64)
  31720. if !ok {
  31721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31722. }
  31723. m.SetAddtime(v)
  31724. return nil
  31725. case usagestatisticday.FieldType:
  31726. v, ok := value.(int)
  31727. if !ok {
  31728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31729. }
  31730. m.SetType(v)
  31731. return nil
  31732. case usagestatisticday.FieldBotID:
  31733. v, ok := value.(string)
  31734. if !ok {
  31735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31736. }
  31737. m.SetBotID(v)
  31738. return nil
  31739. case usagestatisticday.FieldOrganizationID:
  31740. v, ok := value.(uint64)
  31741. if !ok {
  31742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31743. }
  31744. m.SetOrganizationID(v)
  31745. return nil
  31746. case usagestatisticday.FieldAiResponse:
  31747. v, ok := value.(uint64)
  31748. if !ok {
  31749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31750. }
  31751. m.SetAiResponse(v)
  31752. return nil
  31753. case usagestatisticday.FieldSopRun:
  31754. v, ok := value.(uint64)
  31755. if !ok {
  31756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31757. }
  31758. m.SetSopRun(v)
  31759. return nil
  31760. case usagestatisticday.FieldTotalFriend:
  31761. v, ok := value.(uint64)
  31762. if !ok {
  31763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31764. }
  31765. m.SetTotalFriend(v)
  31766. return nil
  31767. case usagestatisticday.FieldTotalGroup:
  31768. v, ok := value.(uint64)
  31769. if !ok {
  31770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31771. }
  31772. m.SetTotalGroup(v)
  31773. return nil
  31774. case usagestatisticday.FieldAccountBalance:
  31775. v, ok := value.(uint64)
  31776. if !ok {
  31777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31778. }
  31779. m.SetAccountBalance(v)
  31780. return nil
  31781. case usagestatisticday.FieldConsumeToken:
  31782. v, ok := value.(uint64)
  31783. if !ok {
  31784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31785. }
  31786. m.SetConsumeToken(v)
  31787. return nil
  31788. case usagestatisticday.FieldActiveUser:
  31789. v, ok := value.(uint64)
  31790. if !ok {
  31791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31792. }
  31793. m.SetActiveUser(v)
  31794. return nil
  31795. case usagestatisticday.FieldNewUser:
  31796. v, ok := value.(int64)
  31797. if !ok {
  31798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31799. }
  31800. m.SetNewUser(v)
  31801. return nil
  31802. case usagestatisticday.FieldLabelDist:
  31803. v, ok := value.([]custom_types.LabelDist)
  31804. if !ok {
  31805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31806. }
  31807. m.SetLabelDist(v)
  31808. return nil
  31809. }
  31810. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  31811. }
  31812. // AddedFields returns all numeric fields that were incremented/decremented during
  31813. // this mutation.
  31814. func (m *UsageStatisticDayMutation) AddedFields() []string {
  31815. var fields []string
  31816. if m.addstatus != nil {
  31817. fields = append(fields, usagestatisticday.FieldStatus)
  31818. }
  31819. if m.addaddtime != nil {
  31820. fields = append(fields, usagestatisticday.FieldAddtime)
  31821. }
  31822. if m.add_type != nil {
  31823. fields = append(fields, usagestatisticday.FieldType)
  31824. }
  31825. if m.addorganization_id != nil {
  31826. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31827. }
  31828. if m.addai_response != nil {
  31829. fields = append(fields, usagestatisticday.FieldAiResponse)
  31830. }
  31831. if m.addsop_run != nil {
  31832. fields = append(fields, usagestatisticday.FieldSopRun)
  31833. }
  31834. if m.addtotal_friend != nil {
  31835. fields = append(fields, usagestatisticday.FieldTotalFriend)
  31836. }
  31837. if m.addtotal_group != nil {
  31838. fields = append(fields, usagestatisticday.FieldTotalGroup)
  31839. }
  31840. if m.addaccount_balance != nil {
  31841. fields = append(fields, usagestatisticday.FieldAccountBalance)
  31842. }
  31843. if m.addconsume_token != nil {
  31844. fields = append(fields, usagestatisticday.FieldConsumeToken)
  31845. }
  31846. if m.addactive_user != nil {
  31847. fields = append(fields, usagestatisticday.FieldActiveUser)
  31848. }
  31849. if m.addnew_user != nil {
  31850. fields = append(fields, usagestatisticday.FieldNewUser)
  31851. }
  31852. return fields
  31853. }
  31854. // AddedField returns the numeric value that was incremented/decremented on a field
  31855. // with the given name. The second boolean return value indicates that this field
  31856. // was not set, or was not defined in the schema.
  31857. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  31858. switch name {
  31859. case usagestatisticday.FieldStatus:
  31860. return m.AddedStatus()
  31861. case usagestatisticday.FieldAddtime:
  31862. return m.AddedAddtime()
  31863. case usagestatisticday.FieldType:
  31864. return m.AddedType()
  31865. case usagestatisticday.FieldOrganizationID:
  31866. return m.AddedOrganizationID()
  31867. case usagestatisticday.FieldAiResponse:
  31868. return m.AddedAiResponse()
  31869. case usagestatisticday.FieldSopRun:
  31870. return m.AddedSopRun()
  31871. case usagestatisticday.FieldTotalFriend:
  31872. return m.AddedTotalFriend()
  31873. case usagestatisticday.FieldTotalGroup:
  31874. return m.AddedTotalGroup()
  31875. case usagestatisticday.FieldAccountBalance:
  31876. return m.AddedAccountBalance()
  31877. case usagestatisticday.FieldConsumeToken:
  31878. return m.AddedConsumeToken()
  31879. case usagestatisticday.FieldActiveUser:
  31880. return m.AddedActiveUser()
  31881. case usagestatisticday.FieldNewUser:
  31882. return m.AddedNewUser()
  31883. }
  31884. return nil, false
  31885. }
  31886. // AddField adds the value to the field with the given name. It returns an error if
  31887. // the field is not defined in the schema, or if the type mismatched the field
  31888. // type.
  31889. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  31890. switch name {
  31891. case usagestatisticday.FieldStatus:
  31892. v, ok := value.(int8)
  31893. if !ok {
  31894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31895. }
  31896. m.AddStatus(v)
  31897. return nil
  31898. case usagestatisticday.FieldAddtime:
  31899. v, ok := value.(int64)
  31900. if !ok {
  31901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31902. }
  31903. m.AddAddtime(v)
  31904. return nil
  31905. case usagestatisticday.FieldType:
  31906. v, ok := value.(int)
  31907. if !ok {
  31908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31909. }
  31910. m.AddType(v)
  31911. return nil
  31912. case usagestatisticday.FieldOrganizationID:
  31913. v, ok := value.(int64)
  31914. if !ok {
  31915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31916. }
  31917. m.AddOrganizationID(v)
  31918. return nil
  31919. case usagestatisticday.FieldAiResponse:
  31920. v, ok := value.(int64)
  31921. if !ok {
  31922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31923. }
  31924. m.AddAiResponse(v)
  31925. return nil
  31926. case usagestatisticday.FieldSopRun:
  31927. v, ok := value.(int64)
  31928. if !ok {
  31929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31930. }
  31931. m.AddSopRun(v)
  31932. return nil
  31933. case usagestatisticday.FieldTotalFriend:
  31934. v, ok := value.(int64)
  31935. if !ok {
  31936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31937. }
  31938. m.AddTotalFriend(v)
  31939. return nil
  31940. case usagestatisticday.FieldTotalGroup:
  31941. v, ok := value.(int64)
  31942. if !ok {
  31943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31944. }
  31945. m.AddTotalGroup(v)
  31946. return nil
  31947. case usagestatisticday.FieldAccountBalance:
  31948. v, ok := value.(int64)
  31949. if !ok {
  31950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31951. }
  31952. m.AddAccountBalance(v)
  31953. return nil
  31954. case usagestatisticday.FieldConsumeToken:
  31955. v, ok := value.(int64)
  31956. if !ok {
  31957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31958. }
  31959. m.AddConsumeToken(v)
  31960. return nil
  31961. case usagestatisticday.FieldActiveUser:
  31962. v, ok := value.(int64)
  31963. if !ok {
  31964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31965. }
  31966. m.AddActiveUser(v)
  31967. return nil
  31968. case usagestatisticday.FieldNewUser:
  31969. v, ok := value.(int64)
  31970. if !ok {
  31971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31972. }
  31973. m.AddNewUser(v)
  31974. return nil
  31975. }
  31976. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  31977. }
  31978. // ClearedFields returns all nullable fields that were cleared during this
  31979. // mutation.
  31980. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  31981. var fields []string
  31982. if m.FieldCleared(usagestatisticday.FieldStatus) {
  31983. fields = append(fields, usagestatisticday.FieldStatus)
  31984. }
  31985. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  31986. fields = append(fields, usagestatisticday.FieldDeletedAt)
  31987. }
  31988. if m.FieldCleared(usagestatisticday.FieldBotID) {
  31989. fields = append(fields, usagestatisticday.FieldBotID)
  31990. }
  31991. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  31992. fields = append(fields, usagestatisticday.FieldOrganizationID)
  31993. }
  31994. return fields
  31995. }
  31996. // FieldCleared returns a boolean indicating if a field with the given name was
  31997. // cleared in this mutation.
  31998. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  31999. _, ok := m.clearedFields[name]
  32000. return ok
  32001. }
  32002. // ClearField clears the value of the field with the given name. It returns an
  32003. // error if the field is not defined in the schema.
  32004. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  32005. switch name {
  32006. case usagestatisticday.FieldStatus:
  32007. m.ClearStatus()
  32008. return nil
  32009. case usagestatisticday.FieldDeletedAt:
  32010. m.ClearDeletedAt()
  32011. return nil
  32012. case usagestatisticday.FieldBotID:
  32013. m.ClearBotID()
  32014. return nil
  32015. case usagestatisticday.FieldOrganizationID:
  32016. m.ClearOrganizationID()
  32017. return nil
  32018. }
  32019. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  32020. }
  32021. // ResetField resets all changes in the mutation for the field with the given name.
  32022. // It returns an error if the field is not defined in the schema.
  32023. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  32024. switch name {
  32025. case usagestatisticday.FieldCreatedAt:
  32026. m.ResetCreatedAt()
  32027. return nil
  32028. case usagestatisticday.FieldUpdatedAt:
  32029. m.ResetUpdatedAt()
  32030. return nil
  32031. case usagestatisticday.FieldStatus:
  32032. m.ResetStatus()
  32033. return nil
  32034. case usagestatisticday.FieldDeletedAt:
  32035. m.ResetDeletedAt()
  32036. return nil
  32037. case usagestatisticday.FieldAddtime:
  32038. m.ResetAddtime()
  32039. return nil
  32040. case usagestatisticday.FieldType:
  32041. m.ResetType()
  32042. return nil
  32043. case usagestatisticday.FieldBotID:
  32044. m.ResetBotID()
  32045. return nil
  32046. case usagestatisticday.FieldOrganizationID:
  32047. m.ResetOrganizationID()
  32048. return nil
  32049. case usagestatisticday.FieldAiResponse:
  32050. m.ResetAiResponse()
  32051. return nil
  32052. case usagestatisticday.FieldSopRun:
  32053. m.ResetSopRun()
  32054. return nil
  32055. case usagestatisticday.FieldTotalFriend:
  32056. m.ResetTotalFriend()
  32057. return nil
  32058. case usagestatisticday.FieldTotalGroup:
  32059. m.ResetTotalGroup()
  32060. return nil
  32061. case usagestatisticday.FieldAccountBalance:
  32062. m.ResetAccountBalance()
  32063. return nil
  32064. case usagestatisticday.FieldConsumeToken:
  32065. m.ResetConsumeToken()
  32066. return nil
  32067. case usagestatisticday.FieldActiveUser:
  32068. m.ResetActiveUser()
  32069. return nil
  32070. case usagestatisticday.FieldNewUser:
  32071. m.ResetNewUser()
  32072. return nil
  32073. case usagestatisticday.FieldLabelDist:
  32074. m.ResetLabelDist()
  32075. return nil
  32076. }
  32077. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32078. }
  32079. // AddedEdges returns all edge names that were set/added in this mutation.
  32080. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  32081. edges := make([]string, 0, 0)
  32082. return edges
  32083. }
  32084. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32085. // name in this mutation.
  32086. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  32087. return nil
  32088. }
  32089. // RemovedEdges returns all edge names that were removed in this mutation.
  32090. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  32091. edges := make([]string, 0, 0)
  32092. return edges
  32093. }
  32094. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32095. // the given name in this mutation.
  32096. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  32097. return nil
  32098. }
  32099. // ClearedEdges returns all edge names that were cleared in this mutation.
  32100. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  32101. edges := make([]string, 0, 0)
  32102. return edges
  32103. }
  32104. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32105. // was cleared in this mutation.
  32106. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  32107. return false
  32108. }
  32109. // ClearEdge clears the value of the edge with the given name. It returns an error
  32110. // if that edge is not defined in the schema.
  32111. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  32112. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  32113. }
  32114. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32115. // It returns an error if the edge is not defined in the schema.
  32116. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  32117. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  32118. }
  32119. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  32120. type UsageStatisticHourMutation struct {
  32121. config
  32122. op Op
  32123. typ string
  32124. id *uint64
  32125. created_at *time.Time
  32126. updated_at *time.Time
  32127. status *uint8
  32128. addstatus *int8
  32129. deleted_at *time.Time
  32130. addtime *uint64
  32131. addaddtime *int64
  32132. _type *int
  32133. add_type *int
  32134. bot_id *string
  32135. organization_id *uint64
  32136. addorganization_id *int64
  32137. ai_response *uint64
  32138. addai_response *int64
  32139. sop_run *uint64
  32140. addsop_run *int64
  32141. total_friend *uint64
  32142. addtotal_friend *int64
  32143. total_group *uint64
  32144. addtotal_group *int64
  32145. account_balance *uint64
  32146. addaccount_balance *int64
  32147. consume_token *uint64
  32148. addconsume_token *int64
  32149. active_user *uint64
  32150. addactive_user *int64
  32151. new_user *int64
  32152. addnew_user *int64
  32153. label_dist *[]custom_types.LabelDist
  32154. appendlabel_dist []custom_types.LabelDist
  32155. clearedFields map[string]struct{}
  32156. done bool
  32157. oldValue func(context.Context) (*UsageStatisticHour, error)
  32158. predicates []predicate.UsageStatisticHour
  32159. }
  32160. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  32161. // usagestatistichourOption allows management of the mutation configuration using functional options.
  32162. type usagestatistichourOption func(*UsageStatisticHourMutation)
  32163. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  32164. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  32165. m := &UsageStatisticHourMutation{
  32166. config: c,
  32167. op: op,
  32168. typ: TypeUsageStatisticHour,
  32169. clearedFields: make(map[string]struct{}),
  32170. }
  32171. for _, opt := range opts {
  32172. opt(m)
  32173. }
  32174. return m
  32175. }
  32176. // withUsageStatisticHourID sets the ID field of the mutation.
  32177. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  32178. return func(m *UsageStatisticHourMutation) {
  32179. var (
  32180. err error
  32181. once sync.Once
  32182. value *UsageStatisticHour
  32183. )
  32184. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  32185. once.Do(func() {
  32186. if m.done {
  32187. err = errors.New("querying old values post mutation is not allowed")
  32188. } else {
  32189. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  32190. }
  32191. })
  32192. return value, err
  32193. }
  32194. m.id = &id
  32195. }
  32196. }
  32197. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  32198. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  32199. return func(m *UsageStatisticHourMutation) {
  32200. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  32201. return node, nil
  32202. }
  32203. m.id = &node.ID
  32204. }
  32205. }
  32206. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32207. // executed in a transaction (ent.Tx), a transactional client is returned.
  32208. func (m UsageStatisticHourMutation) Client() *Client {
  32209. client := &Client{config: m.config}
  32210. client.init()
  32211. return client
  32212. }
  32213. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32214. // it returns an error otherwise.
  32215. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  32216. if _, ok := m.driver.(*txDriver); !ok {
  32217. return nil, errors.New("ent: mutation is not running in a transaction")
  32218. }
  32219. tx := &Tx{config: m.config}
  32220. tx.init()
  32221. return tx, nil
  32222. }
  32223. // SetID sets the value of the id field. Note that this
  32224. // operation is only accepted on creation of UsageStatisticHour entities.
  32225. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  32226. m.id = &id
  32227. }
  32228. // ID returns the ID value in the mutation. Note that the ID is only available
  32229. // if it was provided to the builder or after it was returned from the database.
  32230. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  32231. if m.id == nil {
  32232. return
  32233. }
  32234. return *m.id, true
  32235. }
  32236. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32237. // That means, if the mutation is applied within a transaction with an isolation level such
  32238. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32239. // or updated by the mutation.
  32240. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  32241. switch {
  32242. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32243. id, exists := m.ID()
  32244. if exists {
  32245. return []uint64{id}, nil
  32246. }
  32247. fallthrough
  32248. case m.op.Is(OpUpdate | OpDelete):
  32249. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  32250. default:
  32251. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32252. }
  32253. }
  32254. // SetCreatedAt sets the "created_at" field.
  32255. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  32256. m.created_at = &t
  32257. }
  32258. // CreatedAt returns the value of the "created_at" field in the mutation.
  32259. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  32260. v := m.created_at
  32261. if v == nil {
  32262. return
  32263. }
  32264. return *v, true
  32265. }
  32266. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  32267. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32269. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32270. if !m.op.Is(OpUpdateOne) {
  32271. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32272. }
  32273. if m.id == nil || m.oldValue == nil {
  32274. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32275. }
  32276. oldValue, err := m.oldValue(ctx)
  32277. if err != nil {
  32278. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32279. }
  32280. return oldValue.CreatedAt, nil
  32281. }
  32282. // ResetCreatedAt resets all changes to the "created_at" field.
  32283. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  32284. m.created_at = nil
  32285. }
  32286. // SetUpdatedAt sets the "updated_at" field.
  32287. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  32288. m.updated_at = &t
  32289. }
  32290. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32291. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  32292. v := m.updated_at
  32293. if v == nil {
  32294. return
  32295. }
  32296. return *v, true
  32297. }
  32298. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  32299. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32301. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32302. if !m.op.Is(OpUpdateOne) {
  32303. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32304. }
  32305. if m.id == nil || m.oldValue == nil {
  32306. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32307. }
  32308. oldValue, err := m.oldValue(ctx)
  32309. if err != nil {
  32310. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32311. }
  32312. return oldValue.UpdatedAt, nil
  32313. }
  32314. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32315. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  32316. m.updated_at = nil
  32317. }
  32318. // SetStatus sets the "status" field.
  32319. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  32320. m.status = &u
  32321. m.addstatus = nil
  32322. }
  32323. // Status returns the value of the "status" field in the mutation.
  32324. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  32325. v := m.status
  32326. if v == nil {
  32327. return
  32328. }
  32329. return *v, true
  32330. }
  32331. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  32332. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32334. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32335. if !m.op.Is(OpUpdateOne) {
  32336. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32337. }
  32338. if m.id == nil || m.oldValue == nil {
  32339. return v, errors.New("OldStatus requires an ID field in the mutation")
  32340. }
  32341. oldValue, err := m.oldValue(ctx)
  32342. if err != nil {
  32343. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32344. }
  32345. return oldValue.Status, nil
  32346. }
  32347. // AddStatus adds u to the "status" field.
  32348. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  32349. if m.addstatus != nil {
  32350. *m.addstatus += u
  32351. } else {
  32352. m.addstatus = &u
  32353. }
  32354. }
  32355. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32356. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  32357. v := m.addstatus
  32358. if v == nil {
  32359. return
  32360. }
  32361. return *v, true
  32362. }
  32363. // ClearStatus clears the value of the "status" field.
  32364. func (m *UsageStatisticHourMutation) ClearStatus() {
  32365. m.status = nil
  32366. m.addstatus = nil
  32367. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  32368. }
  32369. // StatusCleared returns if the "status" field was cleared in this mutation.
  32370. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  32371. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  32372. return ok
  32373. }
  32374. // ResetStatus resets all changes to the "status" field.
  32375. func (m *UsageStatisticHourMutation) ResetStatus() {
  32376. m.status = nil
  32377. m.addstatus = nil
  32378. delete(m.clearedFields, usagestatistichour.FieldStatus)
  32379. }
  32380. // SetDeletedAt sets the "deleted_at" field.
  32381. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  32382. m.deleted_at = &t
  32383. }
  32384. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32385. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  32386. v := m.deleted_at
  32387. if v == nil {
  32388. return
  32389. }
  32390. return *v, true
  32391. }
  32392. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  32393. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32395. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32396. if !m.op.Is(OpUpdateOne) {
  32397. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32398. }
  32399. if m.id == nil || m.oldValue == nil {
  32400. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32401. }
  32402. oldValue, err := m.oldValue(ctx)
  32403. if err != nil {
  32404. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32405. }
  32406. return oldValue.DeletedAt, nil
  32407. }
  32408. // ClearDeletedAt clears the value of the "deleted_at" field.
  32409. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  32410. m.deleted_at = nil
  32411. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  32412. }
  32413. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32414. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  32415. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  32416. return ok
  32417. }
  32418. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32419. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  32420. m.deleted_at = nil
  32421. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  32422. }
  32423. // SetAddtime sets the "addtime" field.
  32424. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  32425. m.addtime = &u
  32426. m.addaddtime = nil
  32427. }
  32428. // Addtime returns the value of the "addtime" field in the mutation.
  32429. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  32430. v := m.addtime
  32431. if v == nil {
  32432. return
  32433. }
  32434. return *v, true
  32435. }
  32436. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  32437. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32439. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  32440. if !m.op.Is(OpUpdateOne) {
  32441. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  32442. }
  32443. if m.id == nil || m.oldValue == nil {
  32444. return v, errors.New("OldAddtime requires an ID field in the mutation")
  32445. }
  32446. oldValue, err := m.oldValue(ctx)
  32447. if err != nil {
  32448. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  32449. }
  32450. return oldValue.Addtime, nil
  32451. }
  32452. // AddAddtime adds u to the "addtime" field.
  32453. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  32454. if m.addaddtime != nil {
  32455. *m.addaddtime += u
  32456. } else {
  32457. m.addaddtime = &u
  32458. }
  32459. }
  32460. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  32461. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  32462. v := m.addaddtime
  32463. if v == nil {
  32464. return
  32465. }
  32466. return *v, true
  32467. }
  32468. // ResetAddtime resets all changes to the "addtime" field.
  32469. func (m *UsageStatisticHourMutation) ResetAddtime() {
  32470. m.addtime = nil
  32471. m.addaddtime = nil
  32472. }
  32473. // SetType sets the "type" field.
  32474. func (m *UsageStatisticHourMutation) SetType(i int) {
  32475. m._type = &i
  32476. m.add_type = nil
  32477. }
  32478. // GetType returns the value of the "type" field in the mutation.
  32479. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  32480. v := m._type
  32481. if v == nil {
  32482. return
  32483. }
  32484. return *v, true
  32485. }
  32486. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  32487. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32489. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  32490. if !m.op.Is(OpUpdateOne) {
  32491. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32492. }
  32493. if m.id == nil || m.oldValue == nil {
  32494. return v, errors.New("OldType requires an ID field in the mutation")
  32495. }
  32496. oldValue, err := m.oldValue(ctx)
  32497. if err != nil {
  32498. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32499. }
  32500. return oldValue.Type, nil
  32501. }
  32502. // AddType adds i to the "type" field.
  32503. func (m *UsageStatisticHourMutation) AddType(i int) {
  32504. if m.add_type != nil {
  32505. *m.add_type += i
  32506. } else {
  32507. m.add_type = &i
  32508. }
  32509. }
  32510. // AddedType returns the value that was added to the "type" field in this mutation.
  32511. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  32512. v := m.add_type
  32513. if v == nil {
  32514. return
  32515. }
  32516. return *v, true
  32517. }
  32518. // ResetType resets all changes to the "type" field.
  32519. func (m *UsageStatisticHourMutation) ResetType() {
  32520. m._type = nil
  32521. m.add_type = nil
  32522. }
  32523. // SetBotID sets the "bot_id" field.
  32524. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  32525. m.bot_id = &s
  32526. }
  32527. // BotID returns the value of the "bot_id" field in the mutation.
  32528. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  32529. v := m.bot_id
  32530. if v == nil {
  32531. return
  32532. }
  32533. return *v, true
  32534. }
  32535. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  32536. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32538. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  32539. if !m.op.Is(OpUpdateOne) {
  32540. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32541. }
  32542. if m.id == nil || m.oldValue == nil {
  32543. return v, errors.New("OldBotID requires an ID field in the mutation")
  32544. }
  32545. oldValue, err := m.oldValue(ctx)
  32546. if err != nil {
  32547. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32548. }
  32549. return oldValue.BotID, nil
  32550. }
  32551. // ClearBotID clears the value of the "bot_id" field.
  32552. func (m *UsageStatisticHourMutation) ClearBotID() {
  32553. m.bot_id = nil
  32554. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  32555. }
  32556. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  32557. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  32558. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  32559. return ok
  32560. }
  32561. // ResetBotID resets all changes to the "bot_id" field.
  32562. func (m *UsageStatisticHourMutation) ResetBotID() {
  32563. m.bot_id = nil
  32564. delete(m.clearedFields, usagestatistichour.FieldBotID)
  32565. }
  32566. // SetOrganizationID sets the "organization_id" field.
  32567. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  32568. m.organization_id = &u
  32569. m.addorganization_id = nil
  32570. }
  32571. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32572. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  32573. v := m.organization_id
  32574. if v == nil {
  32575. return
  32576. }
  32577. return *v, true
  32578. }
  32579. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  32580. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32582. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32583. if !m.op.Is(OpUpdateOne) {
  32584. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32585. }
  32586. if m.id == nil || m.oldValue == nil {
  32587. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32588. }
  32589. oldValue, err := m.oldValue(ctx)
  32590. if err != nil {
  32591. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32592. }
  32593. return oldValue.OrganizationID, nil
  32594. }
  32595. // AddOrganizationID adds u to the "organization_id" field.
  32596. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  32597. if m.addorganization_id != nil {
  32598. *m.addorganization_id += u
  32599. } else {
  32600. m.addorganization_id = &u
  32601. }
  32602. }
  32603. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32604. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  32605. v := m.addorganization_id
  32606. if v == nil {
  32607. return
  32608. }
  32609. return *v, true
  32610. }
  32611. // ClearOrganizationID clears the value of the "organization_id" field.
  32612. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  32613. m.organization_id = nil
  32614. m.addorganization_id = nil
  32615. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  32616. }
  32617. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32618. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  32619. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  32620. return ok
  32621. }
  32622. // ResetOrganizationID resets all changes to the "organization_id" field.
  32623. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  32624. m.organization_id = nil
  32625. m.addorganization_id = nil
  32626. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  32627. }
  32628. // SetAiResponse sets the "ai_response" field.
  32629. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  32630. m.ai_response = &u
  32631. m.addai_response = nil
  32632. }
  32633. // AiResponse returns the value of the "ai_response" field in the mutation.
  32634. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  32635. v := m.ai_response
  32636. if v == nil {
  32637. return
  32638. }
  32639. return *v, true
  32640. }
  32641. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  32642. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32644. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  32645. if !m.op.Is(OpUpdateOne) {
  32646. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  32647. }
  32648. if m.id == nil || m.oldValue == nil {
  32649. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  32650. }
  32651. oldValue, err := m.oldValue(ctx)
  32652. if err != nil {
  32653. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  32654. }
  32655. return oldValue.AiResponse, nil
  32656. }
  32657. // AddAiResponse adds u to the "ai_response" field.
  32658. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  32659. if m.addai_response != nil {
  32660. *m.addai_response += u
  32661. } else {
  32662. m.addai_response = &u
  32663. }
  32664. }
  32665. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  32666. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  32667. v := m.addai_response
  32668. if v == nil {
  32669. return
  32670. }
  32671. return *v, true
  32672. }
  32673. // ResetAiResponse resets all changes to the "ai_response" field.
  32674. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  32675. m.ai_response = nil
  32676. m.addai_response = nil
  32677. }
  32678. // SetSopRun sets the "sop_run" field.
  32679. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  32680. m.sop_run = &u
  32681. m.addsop_run = nil
  32682. }
  32683. // SopRun returns the value of the "sop_run" field in the mutation.
  32684. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  32685. v := m.sop_run
  32686. if v == nil {
  32687. return
  32688. }
  32689. return *v, true
  32690. }
  32691. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  32692. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32694. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  32695. if !m.op.Is(OpUpdateOne) {
  32696. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  32697. }
  32698. if m.id == nil || m.oldValue == nil {
  32699. return v, errors.New("OldSopRun requires an ID field in the mutation")
  32700. }
  32701. oldValue, err := m.oldValue(ctx)
  32702. if err != nil {
  32703. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  32704. }
  32705. return oldValue.SopRun, nil
  32706. }
  32707. // AddSopRun adds u to the "sop_run" field.
  32708. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  32709. if m.addsop_run != nil {
  32710. *m.addsop_run += u
  32711. } else {
  32712. m.addsop_run = &u
  32713. }
  32714. }
  32715. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  32716. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  32717. v := m.addsop_run
  32718. if v == nil {
  32719. return
  32720. }
  32721. return *v, true
  32722. }
  32723. // ResetSopRun resets all changes to the "sop_run" field.
  32724. func (m *UsageStatisticHourMutation) ResetSopRun() {
  32725. m.sop_run = nil
  32726. m.addsop_run = nil
  32727. }
  32728. // SetTotalFriend sets the "total_friend" field.
  32729. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  32730. m.total_friend = &u
  32731. m.addtotal_friend = nil
  32732. }
  32733. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32734. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  32735. v := m.total_friend
  32736. if v == nil {
  32737. return
  32738. }
  32739. return *v, true
  32740. }
  32741. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  32742. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32744. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32745. if !m.op.Is(OpUpdateOne) {
  32746. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32747. }
  32748. if m.id == nil || m.oldValue == nil {
  32749. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32750. }
  32751. oldValue, err := m.oldValue(ctx)
  32752. if err != nil {
  32753. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32754. }
  32755. return oldValue.TotalFriend, nil
  32756. }
  32757. // AddTotalFriend adds u to the "total_friend" field.
  32758. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  32759. if m.addtotal_friend != nil {
  32760. *m.addtotal_friend += u
  32761. } else {
  32762. m.addtotal_friend = &u
  32763. }
  32764. }
  32765. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32766. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  32767. v := m.addtotal_friend
  32768. if v == nil {
  32769. return
  32770. }
  32771. return *v, true
  32772. }
  32773. // ResetTotalFriend resets all changes to the "total_friend" field.
  32774. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  32775. m.total_friend = nil
  32776. m.addtotal_friend = nil
  32777. }
  32778. // SetTotalGroup sets the "total_group" field.
  32779. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  32780. m.total_group = &u
  32781. m.addtotal_group = nil
  32782. }
  32783. // TotalGroup returns the value of the "total_group" field in the mutation.
  32784. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  32785. v := m.total_group
  32786. if v == nil {
  32787. return
  32788. }
  32789. return *v, true
  32790. }
  32791. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  32792. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32794. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32795. if !m.op.Is(OpUpdateOne) {
  32796. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32797. }
  32798. if m.id == nil || m.oldValue == nil {
  32799. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32800. }
  32801. oldValue, err := m.oldValue(ctx)
  32802. if err != nil {
  32803. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32804. }
  32805. return oldValue.TotalGroup, nil
  32806. }
  32807. // AddTotalGroup adds u to the "total_group" field.
  32808. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  32809. if m.addtotal_group != nil {
  32810. *m.addtotal_group += u
  32811. } else {
  32812. m.addtotal_group = &u
  32813. }
  32814. }
  32815. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32816. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  32817. v := m.addtotal_group
  32818. if v == nil {
  32819. return
  32820. }
  32821. return *v, true
  32822. }
  32823. // ResetTotalGroup resets all changes to the "total_group" field.
  32824. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  32825. m.total_group = nil
  32826. m.addtotal_group = nil
  32827. }
  32828. // SetAccountBalance sets the "account_balance" field.
  32829. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  32830. m.account_balance = &u
  32831. m.addaccount_balance = nil
  32832. }
  32833. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32834. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  32835. v := m.account_balance
  32836. if v == nil {
  32837. return
  32838. }
  32839. return *v, true
  32840. }
  32841. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  32842. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32843. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32844. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32845. if !m.op.Is(OpUpdateOne) {
  32846. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32847. }
  32848. if m.id == nil || m.oldValue == nil {
  32849. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32850. }
  32851. oldValue, err := m.oldValue(ctx)
  32852. if err != nil {
  32853. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32854. }
  32855. return oldValue.AccountBalance, nil
  32856. }
  32857. // AddAccountBalance adds u to the "account_balance" field.
  32858. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  32859. if m.addaccount_balance != nil {
  32860. *m.addaccount_balance += u
  32861. } else {
  32862. m.addaccount_balance = &u
  32863. }
  32864. }
  32865. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32866. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  32867. v := m.addaccount_balance
  32868. if v == nil {
  32869. return
  32870. }
  32871. return *v, true
  32872. }
  32873. // ResetAccountBalance resets all changes to the "account_balance" field.
  32874. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  32875. m.account_balance = nil
  32876. m.addaccount_balance = nil
  32877. }
  32878. // SetConsumeToken sets the "consume_token" field.
  32879. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  32880. m.consume_token = &u
  32881. m.addconsume_token = nil
  32882. }
  32883. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32884. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  32885. v := m.consume_token
  32886. if v == nil {
  32887. return
  32888. }
  32889. return *v, true
  32890. }
  32891. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  32892. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32894. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32895. if !m.op.Is(OpUpdateOne) {
  32896. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32897. }
  32898. if m.id == nil || m.oldValue == nil {
  32899. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32900. }
  32901. oldValue, err := m.oldValue(ctx)
  32902. if err != nil {
  32903. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32904. }
  32905. return oldValue.ConsumeToken, nil
  32906. }
  32907. // AddConsumeToken adds u to the "consume_token" field.
  32908. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  32909. if m.addconsume_token != nil {
  32910. *m.addconsume_token += u
  32911. } else {
  32912. m.addconsume_token = &u
  32913. }
  32914. }
  32915. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32916. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  32917. v := m.addconsume_token
  32918. if v == nil {
  32919. return
  32920. }
  32921. return *v, true
  32922. }
  32923. // ResetConsumeToken resets all changes to the "consume_token" field.
  32924. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  32925. m.consume_token = nil
  32926. m.addconsume_token = nil
  32927. }
  32928. // SetActiveUser sets the "active_user" field.
  32929. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  32930. m.active_user = &u
  32931. m.addactive_user = nil
  32932. }
  32933. // ActiveUser returns the value of the "active_user" field in the mutation.
  32934. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  32935. v := m.active_user
  32936. if v == nil {
  32937. return
  32938. }
  32939. return *v, true
  32940. }
  32941. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  32942. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32944. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32945. if !m.op.Is(OpUpdateOne) {
  32946. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32947. }
  32948. if m.id == nil || m.oldValue == nil {
  32949. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32950. }
  32951. oldValue, err := m.oldValue(ctx)
  32952. if err != nil {
  32953. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32954. }
  32955. return oldValue.ActiveUser, nil
  32956. }
  32957. // AddActiveUser adds u to the "active_user" field.
  32958. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  32959. if m.addactive_user != nil {
  32960. *m.addactive_user += u
  32961. } else {
  32962. m.addactive_user = &u
  32963. }
  32964. }
  32965. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32966. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  32967. v := m.addactive_user
  32968. if v == nil {
  32969. return
  32970. }
  32971. return *v, true
  32972. }
  32973. // ResetActiveUser resets all changes to the "active_user" field.
  32974. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  32975. m.active_user = nil
  32976. m.addactive_user = nil
  32977. }
  32978. // SetNewUser sets the "new_user" field.
  32979. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  32980. m.new_user = &i
  32981. m.addnew_user = nil
  32982. }
  32983. // NewUser returns the value of the "new_user" field in the mutation.
  32984. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  32985. v := m.new_user
  32986. if v == nil {
  32987. return
  32988. }
  32989. return *v, true
  32990. }
  32991. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  32992. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  32993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32994. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32995. if !m.op.Is(OpUpdateOne) {
  32996. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32997. }
  32998. if m.id == nil || m.oldValue == nil {
  32999. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33000. }
  33001. oldValue, err := m.oldValue(ctx)
  33002. if err != nil {
  33003. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33004. }
  33005. return oldValue.NewUser, nil
  33006. }
  33007. // AddNewUser adds i to the "new_user" field.
  33008. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  33009. if m.addnew_user != nil {
  33010. *m.addnew_user += i
  33011. } else {
  33012. m.addnew_user = &i
  33013. }
  33014. }
  33015. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33016. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  33017. v := m.addnew_user
  33018. if v == nil {
  33019. return
  33020. }
  33021. return *v, true
  33022. }
  33023. // ResetNewUser resets all changes to the "new_user" field.
  33024. func (m *UsageStatisticHourMutation) ResetNewUser() {
  33025. m.new_user = nil
  33026. m.addnew_user = nil
  33027. }
  33028. // SetLabelDist sets the "label_dist" field.
  33029. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33030. m.label_dist = &ctd
  33031. m.appendlabel_dist = nil
  33032. }
  33033. // LabelDist returns the value of the "label_dist" field in the mutation.
  33034. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33035. v := m.label_dist
  33036. if v == nil {
  33037. return
  33038. }
  33039. return *v, true
  33040. }
  33041. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  33042. // If the UsageStatisticHour 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 *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33045. if !m.op.Is(OpUpdateOne) {
  33046. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33047. }
  33048. if m.id == nil || m.oldValue == nil {
  33049. return v, errors.New("OldLabelDist 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 OldLabelDist: %w", err)
  33054. }
  33055. return oldValue.LabelDist, nil
  33056. }
  33057. // AppendLabelDist adds ctd to the "label_dist" field.
  33058. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33059. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33060. }
  33061. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33062. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33063. if len(m.appendlabel_dist) == 0 {
  33064. return nil, false
  33065. }
  33066. return m.appendlabel_dist, true
  33067. }
  33068. // ResetLabelDist resets all changes to the "label_dist" field.
  33069. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  33070. m.label_dist = nil
  33071. m.appendlabel_dist = nil
  33072. }
  33073. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  33074. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  33075. m.predicates = append(m.predicates, ps...)
  33076. }
  33077. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  33078. // users can use type-assertion to append predicates that do not depend on any generated package.
  33079. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  33080. p := make([]predicate.UsageStatisticHour, len(ps))
  33081. for i := range ps {
  33082. p[i] = ps[i]
  33083. }
  33084. m.Where(p...)
  33085. }
  33086. // Op returns the operation name.
  33087. func (m *UsageStatisticHourMutation) Op() Op {
  33088. return m.op
  33089. }
  33090. // SetOp allows setting the mutation operation.
  33091. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  33092. m.op = op
  33093. }
  33094. // Type returns the node type of this mutation (UsageStatisticHour).
  33095. func (m *UsageStatisticHourMutation) Type() string {
  33096. return m.typ
  33097. }
  33098. // Fields returns all fields that were changed during this mutation. Note that in
  33099. // order to get all numeric fields that were incremented/decremented, call
  33100. // AddedFields().
  33101. func (m *UsageStatisticHourMutation) Fields() []string {
  33102. fields := make([]string, 0, 17)
  33103. if m.created_at != nil {
  33104. fields = append(fields, usagestatistichour.FieldCreatedAt)
  33105. }
  33106. if m.updated_at != nil {
  33107. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  33108. }
  33109. if m.status != nil {
  33110. fields = append(fields, usagestatistichour.FieldStatus)
  33111. }
  33112. if m.deleted_at != nil {
  33113. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33114. }
  33115. if m.addtime != nil {
  33116. fields = append(fields, usagestatistichour.FieldAddtime)
  33117. }
  33118. if m._type != nil {
  33119. fields = append(fields, usagestatistichour.FieldType)
  33120. }
  33121. if m.bot_id != nil {
  33122. fields = append(fields, usagestatistichour.FieldBotID)
  33123. }
  33124. if m.organization_id != nil {
  33125. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33126. }
  33127. if m.ai_response != nil {
  33128. fields = append(fields, usagestatistichour.FieldAiResponse)
  33129. }
  33130. if m.sop_run != nil {
  33131. fields = append(fields, usagestatistichour.FieldSopRun)
  33132. }
  33133. if m.total_friend != nil {
  33134. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33135. }
  33136. if m.total_group != nil {
  33137. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33138. }
  33139. if m.account_balance != nil {
  33140. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33141. }
  33142. if m.consume_token != nil {
  33143. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33144. }
  33145. if m.active_user != nil {
  33146. fields = append(fields, usagestatistichour.FieldActiveUser)
  33147. }
  33148. if m.new_user != nil {
  33149. fields = append(fields, usagestatistichour.FieldNewUser)
  33150. }
  33151. if m.label_dist != nil {
  33152. fields = append(fields, usagestatistichour.FieldLabelDist)
  33153. }
  33154. return fields
  33155. }
  33156. // Field returns the value of a field with the given name. The second boolean
  33157. // return value indicates that this field was not set, or was not defined in the
  33158. // schema.
  33159. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  33160. switch name {
  33161. case usagestatistichour.FieldCreatedAt:
  33162. return m.CreatedAt()
  33163. case usagestatistichour.FieldUpdatedAt:
  33164. return m.UpdatedAt()
  33165. case usagestatistichour.FieldStatus:
  33166. return m.Status()
  33167. case usagestatistichour.FieldDeletedAt:
  33168. return m.DeletedAt()
  33169. case usagestatistichour.FieldAddtime:
  33170. return m.Addtime()
  33171. case usagestatistichour.FieldType:
  33172. return m.GetType()
  33173. case usagestatistichour.FieldBotID:
  33174. return m.BotID()
  33175. case usagestatistichour.FieldOrganizationID:
  33176. return m.OrganizationID()
  33177. case usagestatistichour.FieldAiResponse:
  33178. return m.AiResponse()
  33179. case usagestatistichour.FieldSopRun:
  33180. return m.SopRun()
  33181. case usagestatistichour.FieldTotalFriend:
  33182. return m.TotalFriend()
  33183. case usagestatistichour.FieldTotalGroup:
  33184. return m.TotalGroup()
  33185. case usagestatistichour.FieldAccountBalance:
  33186. return m.AccountBalance()
  33187. case usagestatistichour.FieldConsumeToken:
  33188. return m.ConsumeToken()
  33189. case usagestatistichour.FieldActiveUser:
  33190. return m.ActiveUser()
  33191. case usagestatistichour.FieldNewUser:
  33192. return m.NewUser()
  33193. case usagestatistichour.FieldLabelDist:
  33194. return m.LabelDist()
  33195. }
  33196. return nil, false
  33197. }
  33198. // OldField returns the old value of the field from the database. An error is
  33199. // returned if the mutation operation is not UpdateOne, or the query to the
  33200. // database failed.
  33201. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33202. switch name {
  33203. case usagestatistichour.FieldCreatedAt:
  33204. return m.OldCreatedAt(ctx)
  33205. case usagestatistichour.FieldUpdatedAt:
  33206. return m.OldUpdatedAt(ctx)
  33207. case usagestatistichour.FieldStatus:
  33208. return m.OldStatus(ctx)
  33209. case usagestatistichour.FieldDeletedAt:
  33210. return m.OldDeletedAt(ctx)
  33211. case usagestatistichour.FieldAddtime:
  33212. return m.OldAddtime(ctx)
  33213. case usagestatistichour.FieldType:
  33214. return m.OldType(ctx)
  33215. case usagestatistichour.FieldBotID:
  33216. return m.OldBotID(ctx)
  33217. case usagestatistichour.FieldOrganizationID:
  33218. return m.OldOrganizationID(ctx)
  33219. case usagestatistichour.FieldAiResponse:
  33220. return m.OldAiResponse(ctx)
  33221. case usagestatistichour.FieldSopRun:
  33222. return m.OldSopRun(ctx)
  33223. case usagestatistichour.FieldTotalFriend:
  33224. return m.OldTotalFriend(ctx)
  33225. case usagestatistichour.FieldTotalGroup:
  33226. return m.OldTotalGroup(ctx)
  33227. case usagestatistichour.FieldAccountBalance:
  33228. return m.OldAccountBalance(ctx)
  33229. case usagestatistichour.FieldConsumeToken:
  33230. return m.OldConsumeToken(ctx)
  33231. case usagestatistichour.FieldActiveUser:
  33232. return m.OldActiveUser(ctx)
  33233. case usagestatistichour.FieldNewUser:
  33234. return m.OldNewUser(ctx)
  33235. case usagestatistichour.FieldLabelDist:
  33236. return m.OldLabelDist(ctx)
  33237. }
  33238. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33239. }
  33240. // SetField sets the value of a field with the given name. It returns an error if
  33241. // the field is not defined in the schema, or if the type mismatched the field
  33242. // type.
  33243. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  33244. switch name {
  33245. case usagestatistichour.FieldCreatedAt:
  33246. v, ok := value.(time.Time)
  33247. if !ok {
  33248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33249. }
  33250. m.SetCreatedAt(v)
  33251. return nil
  33252. case usagestatistichour.FieldUpdatedAt:
  33253. v, ok := value.(time.Time)
  33254. if !ok {
  33255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33256. }
  33257. m.SetUpdatedAt(v)
  33258. return nil
  33259. case usagestatistichour.FieldStatus:
  33260. v, ok := value.(uint8)
  33261. if !ok {
  33262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33263. }
  33264. m.SetStatus(v)
  33265. return nil
  33266. case usagestatistichour.FieldDeletedAt:
  33267. v, ok := value.(time.Time)
  33268. if !ok {
  33269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33270. }
  33271. m.SetDeletedAt(v)
  33272. return nil
  33273. case usagestatistichour.FieldAddtime:
  33274. v, ok := value.(uint64)
  33275. if !ok {
  33276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33277. }
  33278. m.SetAddtime(v)
  33279. return nil
  33280. case usagestatistichour.FieldType:
  33281. v, ok := value.(int)
  33282. if !ok {
  33283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33284. }
  33285. m.SetType(v)
  33286. return nil
  33287. case usagestatistichour.FieldBotID:
  33288. v, ok := value.(string)
  33289. if !ok {
  33290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33291. }
  33292. m.SetBotID(v)
  33293. return nil
  33294. case usagestatistichour.FieldOrganizationID:
  33295. v, ok := value.(uint64)
  33296. if !ok {
  33297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33298. }
  33299. m.SetOrganizationID(v)
  33300. return nil
  33301. case usagestatistichour.FieldAiResponse:
  33302. v, ok := value.(uint64)
  33303. if !ok {
  33304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33305. }
  33306. m.SetAiResponse(v)
  33307. return nil
  33308. case usagestatistichour.FieldSopRun:
  33309. v, ok := value.(uint64)
  33310. if !ok {
  33311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33312. }
  33313. m.SetSopRun(v)
  33314. return nil
  33315. case usagestatistichour.FieldTotalFriend:
  33316. v, ok := value.(uint64)
  33317. if !ok {
  33318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33319. }
  33320. m.SetTotalFriend(v)
  33321. return nil
  33322. case usagestatistichour.FieldTotalGroup:
  33323. v, ok := value.(uint64)
  33324. if !ok {
  33325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33326. }
  33327. m.SetTotalGroup(v)
  33328. return nil
  33329. case usagestatistichour.FieldAccountBalance:
  33330. v, ok := value.(uint64)
  33331. if !ok {
  33332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33333. }
  33334. m.SetAccountBalance(v)
  33335. return nil
  33336. case usagestatistichour.FieldConsumeToken:
  33337. v, ok := value.(uint64)
  33338. if !ok {
  33339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33340. }
  33341. m.SetConsumeToken(v)
  33342. return nil
  33343. case usagestatistichour.FieldActiveUser:
  33344. v, ok := value.(uint64)
  33345. if !ok {
  33346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33347. }
  33348. m.SetActiveUser(v)
  33349. return nil
  33350. case usagestatistichour.FieldNewUser:
  33351. v, ok := value.(int64)
  33352. if !ok {
  33353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33354. }
  33355. m.SetNewUser(v)
  33356. return nil
  33357. case usagestatistichour.FieldLabelDist:
  33358. v, ok := value.([]custom_types.LabelDist)
  33359. if !ok {
  33360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33361. }
  33362. m.SetLabelDist(v)
  33363. return nil
  33364. }
  33365. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33366. }
  33367. // AddedFields returns all numeric fields that were incremented/decremented during
  33368. // this mutation.
  33369. func (m *UsageStatisticHourMutation) AddedFields() []string {
  33370. var fields []string
  33371. if m.addstatus != nil {
  33372. fields = append(fields, usagestatistichour.FieldStatus)
  33373. }
  33374. if m.addaddtime != nil {
  33375. fields = append(fields, usagestatistichour.FieldAddtime)
  33376. }
  33377. if m.add_type != nil {
  33378. fields = append(fields, usagestatistichour.FieldType)
  33379. }
  33380. if m.addorganization_id != nil {
  33381. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33382. }
  33383. if m.addai_response != nil {
  33384. fields = append(fields, usagestatistichour.FieldAiResponse)
  33385. }
  33386. if m.addsop_run != nil {
  33387. fields = append(fields, usagestatistichour.FieldSopRun)
  33388. }
  33389. if m.addtotal_friend != nil {
  33390. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33391. }
  33392. if m.addtotal_group != nil {
  33393. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33394. }
  33395. if m.addaccount_balance != nil {
  33396. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33397. }
  33398. if m.addconsume_token != nil {
  33399. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33400. }
  33401. if m.addactive_user != nil {
  33402. fields = append(fields, usagestatistichour.FieldActiveUser)
  33403. }
  33404. if m.addnew_user != nil {
  33405. fields = append(fields, usagestatistichour.FieldNewUser)
  33406. }
  33407. return fields
  33408. }
  33409. // AddedField returns the numeric value that was incremented/decremented on a field
  33410. // with the given name. The second boolean return value indicates that this field
  33411. // was not set, or was not defined in the schema.
  33412. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  33413. switch name {
  33414. case usagestatistichour.FieldStatus:
  33415. return m.AddedStatus()
  33416. case usagestatistichour.FieldAddtime:
  33417. return m.AddedAddtime()
  33418. case usagestatistichour.FieldType:
  33419. return m.AddedType()
  33420. case usagestatistichour.FieldOrganizationID:
  33421. return m.AddedOrganizationID()
  33422. case usagestatistichour.FieldAiResponse:
  33423. return m.AddedAiResponse()
  33424. case usagestatistichour.FieldSopRun:
  33425. return m.AddedSopRun()
  33426. case usagestatistichour.FieldTotalFriend:
  33427. return m.AddedTotalFriend()
  33428. case usagestatistichour.FieldTotalGroup:
  33429. return m.AddedTotalGroup()
  33430. case usagestatistichour.FieldAccountBalance:
  33431. return m.AddedAccountBalance()
  33432. case usagestatistichour.FieldConsumeToken:
  33433. return m.AddedConsumeToken()
  33434. case usagestatistichour.FieldActiveUser:
  33435. return m.AddedActiveUser()
  33436. case usagestatistichour.FieldNewUser:
  33437. return m.AddedNewUser()
  33438. }
  33439. return nil, false
  33440. }
  33441. // AddField adds the value to the field with the given name. It returns an error if
  33442. // the field is not defined in the schema, or if the type mismatched the field
  33443. // type.
  33444. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  33445. switch name {
  33446. case usagestatistichour.FieldStatus:
  33447. v, ok := value.(int8)
  33448. if !ok {
  33449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33450. }
  33451. m.AddStatus(v)
  33452. return nil
  33453. case usagestatistichour.FieldAddtime:
  33454. v, ok := value.(int64)
  33455. if !ok {
  33456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33457. }
  33458. m.AddAddtime(v)
  33459. return nil
  33460. case usagestatistichour.FieldType:
  33461. v, ok := value.(int)
  33462. if !ok {
  33463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33464. }
  33465. m.AddType(v)
  33466. return nil
  33467. case usagestatistichour.FieldOrganizationID:
  33468. v, ok := value.(int64)
  33469. if !ok {
  33470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33471. }
  33472. m.AddOrganizationID(v)
  33473. return nil
  33474. case usagestatistichour.FieldAiResponse:
  33475. v, ok := value.(int64)
  33476. if !ok {
  33477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33478. }
  33479. m.AddAiResponse(v)
  33480. return nil
  33481. case usagestatistichour.FieldSopRun:
  33482. v, ok := value.(int64)
  33483. if !ok {
  33484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33485. }
  33486. m.AddSopRun(v)
  33487. return nil
  33488. case usagestatistichour.FieldTotalFriend:
  33489. v, ok := value.(int64)
  33490. if !ok {
  33491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33492. }
  33493. m.AddTotalFriend(v)
  33494. return nil
  33495. case usagestatistichour.FieldTotalGroup:
  33496. v, ok := value.(int64)
  33497. if !ok {
  33498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33499. }
  33500. m.AddTotalGroup(v)
  33501. return nil
  33502. case usagestatistichour.FieldAccountBalance:
  33503. v, ok := value.(int64)
  33504. if !ok {
  33505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33506. }
  33507. m.AddAccountBalance(v)
  33508. return nil
  33509. case usagestatistichour.FieldConsumeToken:
  33510. v, ok := value.(int64)
  33511. if !ok {
  33512. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33513. }
  33514. m.AddConsumeToken(v)
  33515. return nil
  33516. case usagestatistichour.FieldActiveUser:
  33517. v, ok := value.(int64)
  33518. if !ok {
  33519. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33520. }
  33521. m.AddActiveUser(v)
  33522. return nil
  33523. case usagestatistichour.FieldNewUser:
  33524. v, ok := value.(int64)
  33525. if !ok {
  33526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33527. }
  33528. m.AddNewUser(v)
  33529. return nil
  33530. }
  33531. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  33532. }
  33533. // ClearedFields returns all nullable fields that were cleared during this
  33534. // mutation.
  33535. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  33536. var fields []string
  33537. if m.FieldCleared(usagestatistichour.FieldStatus) {
  33538. fields = append(fields, usagestatistichour.FieldStatus)
  33539. }
  33540. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  33541. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33542. }
  33543. if m.FieldCleared(usagestatistichour.FieldBotID) {
  33544. fields = append(fields, usagestatistichour.FieldBotID)
  33545. }
  33546. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  33547. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33548. }
  33549. return fields
  33550. }
  33551. // FieldCleared returns a boolean indicating if a field with the given name was
  33552. // cleared in this mutation.
  33553. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  33554. _, ok := m.clearedFields[name]
  33555. return ok
  33556. }
  33557. // ClearField clears the value of the field with the given name. It returns an
  33558. // error if the field is not defined in the schema.
  33559. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  33560. switch name {
  33561. case usagestatistichour.FieldStatus:
  33562. m.ClearStatus()
  33563. return nil
  33564. case usagestatistichour.FieldDeletedAt:
  33565. m.ClearDeletedAt()
  33566. return nil
  33567. case usagestatistichour.FieldBotID:
  33568. m.ClearBotID()
  33569. return nil
  33570. case usagestatistichour.FieldOrganizationID:
  33571. m.ClearOrganizationID()
  33572. return nil
  33573. }
  33574. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  33575. }
  33576. // ResetField resets all changes in the mutation for the field with the given name.
  33577. // It returns an error if the field is not defined in the schema.
  33578. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  33579. switch name {
  33580. case usagestatistichour.FieldCreatedAt:
  33581. m.ResetCreatedAt()
  33582. return nil
  33583. case usagestatistichour.FieldUpdatedAt:
  33584. m.ResetUpdatedAt()
  33585. return nil
  33586. case usagestatistichour.FieldStatus:
  33587. m.ResetStatus()
  33588. return nil
  33589. case usagestatistichour.FieldDeletedAt:
  33590. m.ResetDeletedAt()
  33591. return nil
  33592. case usagestatistichour.FieldAddtime:
  33593. m.ResetAddtime()
  33594. return nil
  33595. case usagestatistichour.FieldType:
  33596. m.ResetType()
  33597. return nil
  33598. case usagestatistichour.FieldBotID:
  33599. m.ResetBotID()
  33600. return nil
  33601. case usagestatistichour.FieldOrganizationID:
  33602. m.ResetOrganizationID()
  33603. return nil
  33604. case usagestatistichour.FieldAiResponse:
  33605. m.ResetAiResponse()
  33606. return nil
  33607. case usagestatistichour.FieldSopRun:
  33608. m.ResetSopRun()
  33609. return nil
  33610. case usagestatistichour.FieldTotalFriend:
  33611. m.ResetTotalFriend()
  33612. return nil
  33613. case usagestatistichour.FieldTotalGroup:
  33614. m.ResetTotalGroup()
  33615. return nil
  33616. case usagestatistichour.FieldAccountBalance:
  33617. m.ResetAccountBalance()
  33618. return nil
  33619. case usagestatistichour.FieldConsumeToken:
  33620. m.ResetConsumeToken()
  33621. return nil
  33622. case usagestatistichour.FieldActiveUser:
  33623. m.ResetActiveUser()
  33624. return nil
  33625. case usagestatistichour.FieldNewUser:
  33626. m.ResetNewUser()
  33627. return nil
  33628. case usagestatistichour.FieldLabelDist:
  33629. m.ResetLabelDist()
  33630. return nil
  33631. }
  33632. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  33633. }
  33634. // AddedEdges returns all edge names that were set/added in this mutation.
  33635. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  33636. edges := make([]string, 0, 0)
  33637. return edges
  33638. }
  33639. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33640. // name in this mutation.
  33641. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  33642. return nil
  33643. }
  33644. // RemovedEdges returns all edge names that were removed in this mutation.
  33645. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  33646. edges := make([]string, 0, 0)
  33647. return edges
  33648. }
  33649. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33650. // the given name in this mutation.
  33651. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  33652. return nil
  33653. }
  33654. // ClearedEdges returns all edge names that were cleared in this mutation.
  33655. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  33656. edges := make([]string, 0, 0)
  33657. return edges
  33658. }
  33659. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33660. // was cleared in this mutation.
  33661. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  33662. return false
  33663. }
  33664. // ClearEdge clears the value of the edge with the given name. It returns an error
  33665. // if that edge is not defined in the schema.
  33666. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  33667. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  33668. }
  33669. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33670. // It returns an error if the edge is not defined in the schema.
  33671. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  33672. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  33673. }
  33674. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  33675. type UsageStatisticMonthMutation struct {
  33676. config
  33677. op Op
  33678. typ string
  33679. id *uint64
  33680. created_at *time.Time
  33681. updated_at *time.Time
  33682. status *uint8
  33683. addstatus *int8
  33684. deleted_at *time.Time
  33685. addtime *uint64
  33686. addaddtime *int64
  33687. _type *int
  33688. add_type *int
  33689. bot_id *string
  33690. organization_id *uint64
  33691. addorganization_id *int64
  33692. ai_response *uint64
  33693. addai_response *int64
  33694. sop_run *uint64
  33695. addsop_run *int64
  33696. total_friend *uint64
  33697. addtotal_friend *int64
  33698. total_group *uint64
  33699. addtotal_group *int64
  33700. account_balance *uint64
  33701. addaccount_balance *int64
  33702. consume_token *uint64
  33703. addconsume_token *int64
  33704. active_user *uint64
  33705. addactive_user *int64
  33706. new_user *int64
  33707. addnew_user *int64
  33708. label_dist *[]custom_types.LabelDist
  33709. appendlabel_dist []custom_types.LabelDist
  33710. clearedFields map[string]struct{}
  33711. done bool
  33712. oldValue func(context.Context) (*UsageStatisticMonth, error)
  33713. predicates []predicate.UsageStatisticMonth
  33714. }
  33715. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  33716. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  33717. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  33718. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  33719. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  33720. m := &UsageStatisticMonthMutation{
  33721. config: c,
  33722. op: op,
  33723. typ: TypeUsageStatisticMonth,
  33724. clearedFields: make(map[string]struct{}),
  33725. }
  33726. for _, opt := range opts {
  33727. opt(m)
  33728. }
  33729. return m
  33730. }
  33731. // withUsageStatisticMonthID sets the ID field of the mutation.
  33732. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  33733. return func(m *UsageStatisticMonthMutation) {
  33734. var (
  33735. err error
  33736. once sync.Once
  33737. value *UsageStatisticMonth
  33738. )
  33739. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  33740. once.Do(func() {
  33741. if m.done {
  33742. err = errors.New("querying old values post mutation is not allowed")
  33743. } else {
  33744. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  33745. }
  33746. })
  33747. return value, err
  33748. }
  33749. m.id = &id
  33750. }
  33751. }
  33752. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  33753. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  33754. return func(m *UsageStatisticMonthMutation) {
  33755. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  33756. return node, nil
  33757. }
  33758. m.id = &node.ID
  33759. }
  33760. }
  33761. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33762. // executed in a transaction (ent.Tx), a transactional client is returned.
  33763. func (m UsageStatisticMonthMutation) Client() *Client {
  33764. client := &Client{config: m.config}
  33765. client.init()
  33766. return client
  33767. }
  33768. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33769. // it returns an error otherwise.
  33770. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  33771. if _, ok := m.driver.(*txDriver); !ok {
  33772. return nil, errors.New("ent: mutation is not running in a transaction")
  33773. }
  33774. tx := &Tx{config: m.config}
  33775. tx.init()
  33776. return tx, nil
  33777. }
  33778. // SetID sets the value of the id field. Note that this
  33779. // operation is only accepted on creation of UsageStatisticMonth entities.
  33780. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  33781. m.id = &id
  33782. }
  33783. // ID returns the ID value in the mutation. Note that the ID is only available
  33784. // if it was provided to the builder or after it was returned from the database.
  33785. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  33786. if m.id == nil {
  33787. return
  33788. }
  33789. return *m.id, true
  33790. }
  33791. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33792. // That means, if the mutation is applied within a transaction with an isolation level such
  33793. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33794. // or updated by the mutation.
  33795. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  33796. switch {
  33797. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33798. id, exists := m.ID()
  33799. if exists {
  33800. return []uint64{id}, nil
  33801. }
  33802. fallthrough
  33803. case m.op.Is(OpUpdate | OpDelete):
  33804. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  33805. default:
  33806. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33807. }
  33808. }
  33809. // SetCreatedAt sets the "created_at" field.
  33810. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  33811. m.created_at = &t
  33812. }
  33813. // CreatedAt returns the value of the "created_at" field in the mutation.
  33814. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  33815. v := m.created_at
  33816. if v == nil {
  33817. return
  33818. }
  33819. return *v, true
  33820. }
  33821. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  33822. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33824. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33825. if !m.op.Is(OpUpdateOne) {
  33826. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33827. }
  33828. if m.id == nil || m.oldValue == nil {
  33829. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33830. }
  33831. oldValue, err := m.oldValue(ctx)
  33832. if err != nil {
  33833. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33834. }
  33835. return oldValue.CreatedAt, nil
  33836. }
  33837. // ResetCreatedAt resets all changes to the "created_at" field.
  33838. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  33839. m.created_at = nil
  33840. }
  33841. // SetUpdatedAt sets the "updated_at" field.
  33842. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  33843. m.updated_at = &t
  33844. }
  33845. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33846. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  33847. v := m.updated_at
  33848. if v == nil {
  33849. return
  33850. }
  33851. return *v, true
  33852. }
  33853. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  33854. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33856. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33857. if !m.op.Is(OpUpdateOne) {
  33858. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33859. }
  33860. if m.id == nil || m.oldValue == nil {
  33861. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33862. }
  33863. oldValue, err := m.oldValue(ctx)
  33864. if err != nil {
  33865. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33866. }
  33867. return oldValue.UpdatedAt, nil
  33868. }
  33869. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33870. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  33871. m.updated_at = nil
  33872. }
  33873. // SetStatus sets the "status" field.
  33874. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  33875. m.status = &u
  33876. m.addstatus = nil
  33877. }
  33878. // Status returns the value of the "status" field in the mutation.
  33879. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  33880. v := m.status
  33881. if v == nil {
  33882. return
  33883. }
  33884. return *v, true
  33885. }
  33886. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  33887. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33889. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33890. if !m.op.Is(OpUpdateOne) {
  33891. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33892. }
  33893. if m.id == nil || m.oldValue == nil {
  33894. return v, errors.New("OldStatus requires an ID field in the mutation")
  33895. }
  33896. oldValue, err := m.oldValue(ctx)
  33897. if err != nil {
  33898. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33899. }
  33900. return oldValue.Status, nil
  33901. }
  33902. // AddStatus adds u to the "status" field.
  33903. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  33904. if m.addstatus != nil {
  33905. *m.addstatus += u
  33906. } else {
  33907. m.addstatus = &u
  33908. }
  33909. }
  33910. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33911. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  33912. v := m.addstatus
  33913. if v == nil {
  33914. return
  33915. }
  33916. return *v, true
  33917. }
  33918. // ClearStatus clears the value of the "status" field.
  33919. func (m *UsageStatisticMonthMutation) ClearStatus() {
  33920. m.status = nil
  33921. m.addstatus = nil
  33922. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  33923. }
  33924. // StatusCleared returns if the "status" field was cleared in this mutation.
  33925. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  33926. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  33927. return ok
  33928. }
  33929. // ResetStatus resets all changes to the "status" field.
  33930. func (m *UsageStatisticMonthMutation) ResetStatus() {
  33931. m.status = nil
  33932. m.addstatus = nil
  33933. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  33934. }
  33935. // SetDeletedAt sets the "deleted_at" field.
  33936. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  33937. m.deleted_at = &t
  33938. }
  33939. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33940. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  33941. v := m.deleted_at
  33942. if v == nil {
  33943. return
  33944. }
  33945. return *v, true
  33946. }
  33947. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  33948. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33950. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33951. if !m.op.Is(OpUpdateOne) {
  33952. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33953. }
  33954. if m.id == nil || m.oldValue == nil {
  33955. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33956. }
  33957. oldValue, err := m.oldValue(ctx)
  33958. if err != nil {
  33959. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33960. }
  33961. return oldValue.DeletedAt, nil
  33962. }
  33963. // ClearDeletedAt clears the value of the "deleted_at" field.
  33964. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  33965. m.deleted_at = nil
  33966. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  33967. }
  33968. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33969. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  33970. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  33971. return ok
  33972. }
  33973. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33974. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  33975. m.deleted_at = nil
  33976. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  33977. }
  33978. // SetAddtime sets the "addtime" field.
  33979. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  33980. m.addtime = &u
  33981. m.addaddtime = nil
  33982. }
  33983. // Addtime returns the value of the "addtime" field in the mutation.
  33984. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  33985. v := m.addtime
  33986. if v == nil {
  33987. return
  33988. }
  33989. return *v, true
  33990. }
  33991. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  33992. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  33993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33994. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33995. if !m.op.Is(OpUpdateOne) {
  33996. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33997. }
  33998. if m.id == nil || m.oldValue == nil {
  33999. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34000. }
  34001. oldValue, err := m.oldValue(ctx)
  34002. if err != nil {
  34003. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34004. }
  34005. return oldValue.Addtime, nil
  34006. }
  34007. // AddAddtime adds u to the "addtime" field.
  34008. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  34009. if m.addaddtime != nil {
  34010. *m.addaddtime += u
  34011. } else {
  34012. m.addaddtime = &u
  34013. }
  34014. }
  34015. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34016. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  34017. v := m.addaddtime
  34018. if v == nil {
  34019. return
  34020. }
  34021. return *v, true
  34022. }
  34023. // ResetAddtime resets all changes to the "addtime" field.
  34024. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  34025. m.addtime = nil
  34026. m.addaddtime = nil
  34027. }
  34028. // SetType sets the "type" field.
  34029. func (m *UsageStatisticMonthMutation) SetType(i int) {
  34030. m._type = &i
  34031. m.add_type = nil
  34032. }
  34033. // GetType returns the value of the "type" field in the mutation.
  34034. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  34035. v := m._type
  34036. if v == nil {
  34037. return
  34038. }
  34039. return *v, true
  34040. }
  34041. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  34042. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34044. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  34045. if !m.op.Is(OpUpdateOne) {
  34046. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34047. }
  34048. if m.id == nil || m.oldValue == nil {
  34049. return v, errors.New("OldType requires an ID field in the mutation")
  34050. }
  34051. oldValue, err := m.oldValue(ctx)
  34052. if err != nil {
  34053. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34054. }
  34055. return oldValue.Type, nil
  34056. }
  34057. // AddType adds i to the "type" field.
  34058. func (m *UsageStatisticMonthMutation) AddType(i int) {
  34059. if m.add_type != nil {
  34060. *m.add_type += i
  34061. } else {
  34062. m.add_type = &i
  34063. }
  34064. }
  34065. // AddedType returns the value that was added to the "type" field in this mutation.
  34066. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  34067. v := m.add_type
  34068. if v == nil {
  34069. return
  34070. }
  34071. return *v, true
  34072. }
  34073. // ResetType resets all changes to the "type" field.
  34074. func (m *UsageStatisticMonthMutation) ResetType() {
  34075. m._type = nil
  34076. m.add_type = nil
  34077. }
  34078. // SetBotID sets the "bot_id" field.
  34079. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  34080. m.bot_id = &s
  34081. }
  34082. // BotID returns the value of the "bot_id" field in the mutation.
  34083. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  34084. v := m.bot_id
  34085. if v == nil {
  34086. return
  34087. }
  34088. return *v, true
  34089. }
  34090. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  34091. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34093. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  34094. if !m.op.Is(OpUpdateOne) {
  34095. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34096. }
  34097. if m.id == nil || m.oldValue == nil {
  34098. return v, errors.New("OldBotID requires an ID field in the mutation")
  34099. }
  34100. oldValue, err := m.oldValue(ctx)
  34101. if err != nil {
  34102. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34103. }
  34104. return oldValue.BotID, nil
  34105. }
  34106. // ClearBotID clears the value of the "bot_id" field.
  34107. func (m *UsageStatisticMonthMutation) ClearBotID() {
  34108. m.bot_id = nil
  34109. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  34110. }
  34111. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34112. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  34113. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  34114. return ok
  34115. }
  34116. // ResetBotID resets all changes to the "bot_id" field.
  34117. func (m *UsageStatisticMonthMutation) ResetBotID() {
  34118. m.bot_id = nil
  34119. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  34120. }
  34121. // SetOrganizationID sets the "organization_id" field.
  34122. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  34123. m.organization_id = &u
  34124. m.addorganization_id = nil
  34125. }
  34126. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34127. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  34128. v := m.organization_id
  34129. if v == nil {
  34130. return
  34131. }
  34132. return *v, true
  34133. }
  34134. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  34135. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34137. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34138. if !m.op.Is(OpUpdateOne) {
  34139. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34140. }
  34141. if m.id == nil || m.oldValue == nil {
  34142. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34143. }
  34144. oldValue, err := m.oldValue(ctx)
  34145. if err != nil {
  34146. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34147. }
  34148. return oldValue.OrganizationID, nil
  34149. }
  34150. // AddOrganizationID adds u to the "organization_id" field.
  34151. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  34152. if m.addorganization_id != nil {
  34153. *m.addorganization_id += u
  34154. } else {
  34155. m.addorganization_id = &u
  34156. }
  34157. }
  34158. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34159. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  34160. v := m.addorganization_id
  34161. if v == nil {
  34162. return
  34163. }
  34164. return *v, true
  34165. }
  34166. // ClearOrganizationID clears the value of the "organization_id" field.
  34167. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  34168. m.organization_id = nil
  34169. m.addorganization_id = nil
  34170. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  34171. }
  34172. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34173. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  34174. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  34175. return ok
  34176. }
  34177. // ResetOrganizationID resets all changes to the "organization_id" field.
  34178. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  34179. m.organization_id = nil
  34180. m.addorganization_id = nil
  34181. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  34182. }
  34183. // SetAiResponse sets the "ai_response" field.
  34184. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  34185. m.ai_response = &u
  34186. m.addai_response = nil
  34187. }
  34188. // AiResponse returns the value of the "ai_response" field in the mutation.
  34189. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  34190. v := m.ai_response
  34191. if v == nil {
  34192. return
  34193. }
  34194. return *v, true
  34195. }
  34196. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  34197. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34199. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  34200. if !m.op.Is(OpUpdateOne) {
  34201. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  34202. }
  34203. if m.id == nil || m.oldValue == nil {
  34204. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  34205. }
  34206. oldValue, err := m.oldValue(ctx)
  34207. if err != nil {
  34208. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  34209. }
  34210. return oldValue.AiResponse, nil
  34211. }
  34212. // AddAiResponse adds u to the "ai_response" field.
  34213. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  34214. if m.addai_response != nil {
  34215. *m.addai_response += u
  34216. } else {
  34217. m.addai_response = &u
  34218. }
  34219. }
  34220. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  34221. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  34222. v := m.addai_response
  34223. if v == nil {
  34224. return
  34225. }
  34226. return *v, true
  34227. }
  34228. // ResetAiResponse resets all changes to the "ai_response" field.
  34229. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  34230. m.ai_response = nil
  34231. m.addai_response = nil
  34232. }
  34233. // SetSopRun sets the "sop_run" field.
  34234. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  34235. m.sop_run = &u
  34236. m.addsop_run = nil
  34237. }
  34238. // SopRun returns the value of the "sop_run" field in the mutation.
  34239. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  34240. v := m.sop_run
  34241. if v == nil {
  34242. return
  34243. }
  34244. return *v, true
  34245. }
  34246. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  34247. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34249. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  34250. if !m.op.Is(OpUpdateOne) {
  34251. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  34252. }
  34253. if m.id == nil || m.oldValue == nil {
  34254. return v, errors.New("OldSopRun requires an ID field in the mutation")
  34255. }
  34256. oldValue, err := m.oldValue(ctx)
  34257. if err != nil {
  34258. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  34259. }
  34260. return oldValue.SopRun, nil
  34261. }
  34262. // AddSopRun adds u to the "sop_run" field.
  34263. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  34264. if m.addsop_run != nil {
  34265. *m.addsop_run += u
  34266. } else {
  34267. m.addsop_run = &u
  34268. }
  34269. }
  34270. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  34271. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  34272. v := m.addsop_run
  34273. if v == nil {
  34274. return
  34275. }
  34276. return *v, true
  34277. }
  34278. // ResetSopRun resets all changes to the "sop_run" field.
  34279. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  34280. m.sop_run = nil
  34281. m.addsop_run = nil
  34282. }
  34283. // SetTotalFriend sets the "total_friend" field.
  34284. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  34285. m.total_friend = &u
  34286. m.addtotal_friend = nil
  34287. }
  34288. // TotalFriend returns the value of the "total_friend" field in the mutation.
  34289. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  34290. v := m.total_friend
  34291. if v == nil {
  34292. return
  34293. }
  34294. return *v, true
  34295. }
  34296. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  34297. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34299. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  34300. if !m.op.Is(OpUpdateOne) {
  34301. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  34302. }
  34303. if m.id == nil || m.oldValue == nil {
  34304. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  34305. }
  34306. oldValue, err := m.oldValue(ctx)
  34307. if err != nil {
  34308. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  34309. }
  34310. return oldValue.TotalFriend, nil
  34311. }
  34312. // AddTotalFriend adds u to the "total_friend" field.
  34313. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  34314. if m.addtotal_friend != nil {
  34315. *m.addtotal_friend += u
  34316. } else {
  34317. m.addtotal_friend = &u
  34318. }
  34319. }
  34320. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  34321. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  34322. v := m.addtotal_friend
  34323. if v == nil {
  34324. return
  34325. }
  34326. return *v, true
  34327. }
  34328. // ResetTotalFriend resets all changes to the "total_friend" field.
  34329. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  34330. m.total_friend = nil
  34331. m.addtotal_friend = nil
  34332. }
  34333. // SetTotalGroup sets the "total_group" field.
  34334. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  34335. m.total_group = &u
  34336. m.addtotal_group = nil
  34337. }
  34338. // TotalGroup returns the value of the "total_group" field in the mutation.
  34339. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  34340. v := m.total_group
  34341. if v == nil {
  34342. return
  34343. }
  34344. return *v, true
  34345. }
  34346. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  34347. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34349. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  34350. if !m.op.Is(OpUpdateOne) {
  34351. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  34352. }
  34353. if m.id == nil || m.oldValue == nil {
  34354. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  34355. }
  34356. oldValue, err := m.oldValue(ctx)
  34357. if err != nil {
  34358. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  34359. }
  34360. return oldValue.TotalGroup, nil
  34361. }
  34362. // AddTotalGroup adds u to the "total_group" field.
  34363. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  34364. if m.addtotal_group != nil {
  34365. *m.addtotal_group += u
  34366. } else {
  34367. m.addtotal_group = &u
  34368. }
  34369. }
  34370. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  34371. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  34372. v := m.addtotal_group
  34373. if v == nil {
  34374. return
  34375. }
  34376. return *v, true
  34377. }
  34378. // ResetTotalGroup resets all changes to the "total_group" field.
  34379. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  34380. m.total_group = nil
  34381. m.addtotal_group = nil
  34382. }
  34383. // SetAccountBalance sets the "account_balance" field.
  34384. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  34385. m.account_balance = &u
  34386. m.addaccount_balance = nil
  34387. }
  34388. // AccountBalance returns the value of the "account_balance" field in the mutation.
  34389. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  34390. v := m.account_balance
  34391. if v == nil {
  34392. return
  34393. }
  34394. return *v, true
  34395. }
  34396. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  34397. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34399. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  34400. if !m.op.Is(OpUpdateOne) {
  34401. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  34402. }
  34403. if m.id == nil || m.oldValue == nil {
  34404. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  34405. }
  34406. oldValue, err := m.oldValue(ctx)
  34407. if err != nil {
  34408. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  34409. }
  34410. return oldValue.AccountBalance, nil
  34411. }
  34412. // AddAccountBalance adds u to the "account_balance" field.
  34413. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  34414. if m.addaccount_balance != nil {
  34415. *m.addaccount_balance += u
  34416. } else {
  34417. m.addaccount_balance = &u
  34418. }
  34419. }
  34420. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  34421. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  34422. v := m.addaccount_balance
  34423. if v == nil {
  34424. return
  34425. }
  34426. return *v, true
  34427. }
  34428. // ResetAccountBalance resets all changes to the "account_balance" field.
  34429. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  34430. m.account_balance = nil
  34431. m.addaccount_balance = nil
  34432. }
  34433. // SetConsumeToken sets the "consume_token" field.
  34434. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  34435. m.consume_token = &u
  34436. m.addconsume_token = nil
  34437. }
  34438. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  34439. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  34440. v := m.consume_token
  34441. if v == nil {
  34442. return
  34443. }
  34444. return *v, true
  34445. }
  34446. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  34447. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34449. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  34450. if !m.op.Is(OpUpdateOne) {
  34451. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  34452. }
  34453. if m.id == nil || m.oldValue == nil {
  34454. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  34455. }
  34456. oldValue, err := m.oldValue(ctx)
  34457. if err != nil {
  34458. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  34459. }
  34460. return oldValue.ConsumeToken, nil
  34461. }
  34462. // AddConsumeToken adds u to the "consume_token" field.
  34463. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  34464. if m.addconsume_token != nil {
  34465. *m.addconsume_token += u
  34466. } else {
  34467. m.addconsume_token = &u
  34468. }
  34469. }
  34470. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  34471. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  34472. v := m.addconsume_token
  34473. if v == nil {
  34474. return
  34475. }
  34476. return *v, true
  34477. }
  34478. // ResetConsumeToken resets all changes to the "consume_token" field.
  34479. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  34480. m.consume_token = nil
  34481. m.addconsume_token = nil
  34482. }
  34483. // SetActiveUser sets the "active_user" field.
  34484. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  34485. m.active_user = &u
  34486. m.addactive_user = nil
  34487. }
  34488. // ActiveUser returns the value of the "active_user" field in the mutation.
  34489. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  34490. v := m.active_user
  34491. if v == nil {
  34492. return
  34493. }
  34494. return *v, true
  34495. }
  34496. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  34497. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34499. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  34500. if !m.op.Is(OpUpdateOne) {
  34501. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  34502. }
  34503. if m.id == nil || m.oldValue == nil {
  34504. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  34505. }
  34506. oldValue, err := m.oldValue(ctx)
  34507. if err != nil {
  34508. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  34509. }
  34510. return oldValue.ActiveUser, nil
  34511. }
  34512. // AddActiveUser adds u to the "active_user" field.
  34513. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  34514. if m.addactive_user != nil {
  34515. *m.addactive_user += u
  34516. } else {
  34517. m.addactive_user = &u
  34518. }
  34519. }
  34520. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  34521. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  34522. v := m.addactive_user
  34523. if v == nil {
  34524. return
  34525. }
  34526. return *v, true
  34527. }
  34528. // ResetActiveUser resets all changes to the "active_user" field.
  34529. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  34530. m.active_user = nil
  34531. m.addactive_user = nil
  34532. }
  34533. // SetNewUser sets the "new_user" field.
  34534. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  34535. m.new_user = &i
  34536. m.addnew_user = nil
  34537. }
  34538. // NewUser returns the value of the "new_user" field in the mutation.
  34539. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  34540. v := m.new_user
  34541. if v == nil {
  34542. return
  34543. }
  34544. return *v, true
  34545. }
  34546. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  34547. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34549. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  34550. if !m.op.Is(OpUpdateOne) {
  34551. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  34552. }
  34553. if m.id == nil || m.oldValue == nil {
  34554. return v, errors.New("OldNewUser requires an ID field in the mutation")
  34555. }
  34556. oldValue, err := m.oldValue(ctx)
  34557. if err != nil {
  34558. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  34559. }
  34560. return oldValue.NewUser, nil
  34561. }
  34562. // AddNewUser adds i to the "new_user" field.
  34563. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  34564. if m.addnew_user != nil {
  34565. *m.addnew_user += i
  34566. } else {
  34567. m.addnew_user = &i
  34568. }
  34569. }
  34570. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  34571. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  34572. v := m.addnew_user
  34573. if v == nil {
  34574. return
  34575. }
  34576. return *v, true
  34577. }
  34578. // ResetNewUser resets all changes to the "new_user" field.
  34579. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  34580. m.new_user = nil
  34581. m.addnew_user = nil
  34582. }
  34583. // SetLabelDist sets the "label_dist" field.
  34584. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  34585. m.label_dist = &ctd
  34586. m.appendlabel_dist = nil
  34587. }
  34588. // LabelDist returns the value of the "label_dist" field in the mutation.
  34589. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  34590. v := m.label_dist
  34591. if v == nil {
  34592. return
  34593. }
  34594. return *v, true
  34595. }
  34596. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  34597. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34599. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  34600. if !m.op.Is(OpUpdateOne) {
  34601. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  34602. }
  34603. if m.id == nil || m.oldValue == nil {
  34604. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  34605. }
  34606. oldValue, err := m.oldValue(ctx)
  34607. if err != nil {
  34608. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  34609. }
  34610. return oldValue.LabelDist, nil
  34611. }
  34612. // AppendLabelDist adds ctd to the "label_dist" field.
  34613. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  34614. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  34615. }
  34616. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  34617. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  34618. if len(m.appendlabel_dist) == 0 {
  34619. return nil, false
  34620. }
  34621. return m.appendlabel_dist, true
  34622. }
  34623. // ResetLabelDist resets all changes to the "label_dist" field.
  34624. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  34625. m.label_dist = nil
  34626. m.appendlabel_dist = nil
  34627. }
  34628. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  34629. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  34630. m.predicates = append(m.predicates, ps...)
  34631. }
  34632. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  34633. // users can use type-assertion to append predicates that do not depend on any generated package.
  34634. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  34635. p := make([]predicate.UsageStatisticMonth, len(ps))
  34636. for i := range ps {
  34637. p[i] = ps[i]
  34638. }
  34639. m.Where(p...)
  34640. }
  34641. // Op returns the operation name.
  34642. func (m *UsageStatisticMonthMutation) Op() Op {
  34643. return m.op
  34644. }
  34645. // SetOp allows setting the mutation operation.
  34646. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  34647. m.op = op
  34648. }
  34649. // Type returns the node type of this mutation (UsageStatisticMonth).
  34650. func (m *UsageStatisticMonthMutation) Type() string {
  34651. return m.typ
  34652. }
  34653. // Fields returns all fields that were changed during this mutation. Note that in
  34654. // order to get all numeric fields that were incremented/decremented, call
  34655. // AddedFields().
  34656. func (m *UsageStatisticMonthMutation) Fields() []string {
  34657. fields := make([]string, 0, 17)
  34658. if m.created_at != nil {
  34659. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  34660. }
  34661. if m.updated_at != nil {
  34662. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  34663. }
  34664. if m.status != nil {
  34665. fields = append(fields, usagestatisticmonth.FieldStatus)
  34666. }
  34667. if m.deleted_at != nil {
  34668. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  34669. }
  34670. if m.addtime != nil {
  34671. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34672. }
  34673. if m._type != nil {
  34674. fields = append(fields, usagestatisticmonth.FieldType)
  34675. }
  34676. if m.bot_id != nil {
  34677. fields = append(fields, usagestatisticmonth.FieldBotID)
  34678. }
  34679. if m.organization_id != nil {
  34680. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34681. }
  34682. if m.ai_response != nil {
  34683. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34684. }
  34685. if m.sop_run != nil {
  34686. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34687. }
  34688. if m.total_friend != nil {
  34689. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34690. }
  34691. if m.total_group != nil {
  34692. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34693. }
  34694. if m.account_balance != nil {
  34695. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34696. }
  34697. if m.consume_token != nil {
  34698. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34699. }
  34700. if m.active_user != nil {
  34701. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34702. }
  34703. if m.new_user != nil {
  34704. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34705. }
  34706. if m.label_dist != nil {
  34707. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  34708. }
  34709. return fields
  34710. }
  34711. // Field returns the value of a field with the given name. The second boolean
  34712. // return value indicates that this field was not set, or was not defined in the
  34713. // schema.
  34714. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  34715. switch name {
  34716. case usagestatisticmonth.FieldCreatedAt:
  34717. return m.CreatedAt()
  34718. case usagestatisticmonth.FieldUpdatedAt:
  34719. return m.UpdatedAt()
  34720. case usagestatisticmonth.FieldStatus:
  34721. return m.Status()
  34722. case usagestatisticmonth.FieldDeletedAt:
  34723. return m.DeletedAt()
  34724. case usagestatisticmonth.FieldAddtime:
  34725. return m.Addtime()
  34726. case usagestatisticmonth.FieldType:
  34727. return m.GetType()
  34728. case usagestatisticmonth.FieldBotID:
  34729. return m.BotID()
  34730. case usagestatisticmonth.FieldOrganizationID:
  34731. return m.OrganizationID()
  34732. case usagestatisticmonth.FieldAiResponse:
  34733. return m.AiResponse()
  34734. case usagestatisticmonth.FieldSopRun:
  34735. return m.SopRun()
  34736. case usagestatisticmonth.FieldTotalFriend:
  34737. return m.TotalFriend()
  34738. case usagestatisticmonth.FieldTotalGroup:
  34739. return m.TotalGroup()
  34740. case usagestatisticmonth.FieldAccountBalance:
  34741. return m.AccountBalance()
  34742. case usagestatisticmonth.FieldConsumeToken:
  34743. return m.ConsumeToken()
  34744. case usagestatisticmonth.FieldActiveUser:
  34745. return m.ActiveUser()
  34746. case usagestatisticmonth.FieldNewUser:
  34747. return m.NewUser()
  34748. case usagestatisticmonth.FieldLabelDist:
  34749. return m.LabelDist()
  34750. }
  34751. return nil, false
  34752. }
  34753. // OldField returns the old value of the field from the database. An error is
  34754. // returned if the mutation operation is not UpdateOne, or the query to the
  34755. // database failed.
  34756. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34757. switch name {
  34758. case usagestatisticmonth.FieldCreatedAt:
  34759. return m.OldCreatedAt(ctx)
  34760. case usagestatisticmonth.FieldUpdatedAt:
  34761. return m.OldUpdatedAt(ctx)
  34762. case usagestatisticmonth.FieldStatus:
  34763. return m.OldStatus(ctx)
  34764. case usagestatisticmonth.FieldDeletedAt:
  34765. return m.OldDeletedAt(ctx)
  34766. case usagestatisticmonth.FieldAddtime:
  34767. return m.OldAddtime(ctx)
  34768. case usagestatisticmonth.FieldType:
  34769. return m.OldType(ctx)
  34770. case usagestatisticmonth.FieldBotID:
  34771. return m.OldBotID(ctx)
  34772. case usagestatisticmonth.FieldOrganizationID:
  34773. return m.OldOrganizationID(ctx)
  34774. case usagestatisticmonth.FieldAiResponse:
  34775. return m.OldAiResponse(ctx)
  34776. case usagestatisticmonth.FieldSopRun:
  34777. return m.OldSopRun(ctx)
  34778. case usagestatisticmonth.FieldTotalFriend:
  34779. return m.OldTotalFriend(ctx)
  34780. case usagestatisticmonth.FieldTotalGroup:
  34781. return m.OldTotalGroup(ctx)
  34782. case usagestatisticmonth.FieldAccountBalance:
  34783. return m.OldAccountBalance(ctx)
  34784. case usagestatisticmonth.FieldConsumeToken:
  34785. return m.OldConsumeToken(ctx)
  34786. case usagestatisticmonth.FieldActiveUser:
  34787. return m.OldActiveUser(ctx)
  34788. case usagestatisticmonth.FieldNewUser:
  34789. return m.OldNewUser(ctx)
  34790. case usagestatisticmonth.FieldLabelDist:
  34791. return m.OldLabelDist(ctx)
  34792. }
  34793. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34794. }
  34795. // SetField sets the value of a field with the given name. It returns an error if
  34796. // the field is not defined in the schema, or if the type mismatched the field
  34797. // type.
  34798. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  34799. switch name {
  34800. case usagestatisticmonth.FieldCreatedAt:
  34801. v, ok := value.(time.Time)
  34802. if !ok {
  34803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34804. }
  34805. m.SetCreatedAt(v)
  34806. return nil
  34807. case usagestatisticmonth.FieldUpdatedAt:
  34808. v, ok := value.(time.Time)
  34809. if !ok {
  34810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34811. }
  34812. m.SetUpdatedAt(v)
  34813. return nil
  34814. case usagestatisticmonth.FieldStatus:
  34815. v, ok := value.(uint8)
  34816. if !ok {
  34817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34818. }
  34819. m.SetStatus(v)
  34820. return nil
  34821. case usagestatisticmonth.FieldDeletedAt:
  34822. v, ok := value.(time.Time)
  34823. if !ok {
  34824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34825. }
  34826. m.SetDeletedAt(v)
  34827. return nil
  34828. case usagestatisticmonth.FieldAddtime:
  34829. v, ok := value.(uint64)
  34830. if !ok {
  34831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34832. }
  34833. m.SetAddtime(v)
  34834. return nil
  34835. case usagestatisticmonth.FieldType:
  34836. v, ok := value.(int)
  34837. if !ok {
  34838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34839. }
  34840. m.SetType(v)
  34841. return nil
  34842. case usagestatisticmonth.FieldBotID:
  34843. v, ok := value.(string)
  34844. if !ok {
  34845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34846. }
  34847. m.SetBotID(v)
  34848. return nil
  34849. case usagestatisticmonth.FieldOrganizationID:
  34850. v, ok := value.(uint64)
  34851. if !ok {
  34852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34853. }
  34854. m.SetOrganizationID(v)
  34855. return nil
  34856. case usagestatisticmonth.FieldAiResponse:
  34857. v, ok := value.(uint64)
  34858. if !ok {
  34859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34860. }
  34861. m.SetAiResponse(v)
  34862. return nil
  34863. case usagestatisticmonth.FieldSopRun:
  34864. v, ok := value.(uint64)
  34865. if !ok {
  34866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34867. }
  34868. m.SetSopRun(v)
  34869. return nil
  34870. case usagestatisticmonth.FieldTotalFriend:
  34871. v, ok := value.(uint64)
  34872. if !ok {
  34873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34874. }
  34875. m.SetTotalFriend(v)
  34876. return nil
  34877. case usagestatisticmonth.FieldTotalGroup:
  34878. v, ok := value.(uint64)
  34879. if !ok {
  34880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34881. }
  34882. m.SetTotalGroup(v)
  34883. return nil
  34884. case usagestatisticmonth.FieldAccountBalance:
  34885. v, ok := value.(uint64)
  34886. if !ok {
  34887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34888. }
  34889. m.SetAccountBalance(v)
  34890. return nil
  34891. case usagestatisticmonth.FieldConsumeToken:
  34892. v, ok := value.(uint64)
  34893. if !ok {
  34894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34895. }
  34896. m.SetConsumeToken(v)
  34897. return nil
  34898. case usagestatisticmonth.FieldActiveUser:
  34899. v, ok := value.(uint64)
  34900. if !ok {
  34901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34902. }
  34903. m.SetActiveUser(v)
  34904. return nil
  34905. case usagestatisticmonth.FieldNewUser:
  34906. v, ok := value.(int64)
  34907. if !ok {
  34908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34909. }
  34910. m.SetNewUser(v)
  34911. return nil
  34912. case usagestatisticmonth.FieldLabelDist:
  34913. v, ok := value.([]custom_types.LabelDist)
  34914. if !ok {
  34915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34916. }
  34917. m.SetLabelDist(v)
  34918. return nil
  34919. }
  34920. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  34921. }
  34922. // AddedFields returns all numeric fields that were incremented/decremented during
  34923. // this mutation.
  34924. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  34925. var fields []string
  34926. if m.addstatus != nil {
  34927. fields = append(fields, usagestatisticmonth.FieldStatus)
  34928. }
  34929. if m.addaddtime != nil {
  34930. fields = append(fields, usagestatisticmonth.FieldAddtime)
  34931. }
  34932. if m.add_type != nil {
  34933. fields = append(fields, usagestatisticmonth.FieldType)
  34934. }
  34935. if m.addorganization_id != nil {
  34936. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  34937. }
  34938. if m.addai_response != nil {
  34939. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  34940. }
  34941. if m.addsop_run != nil {
  34942. fields = append(fields, usagestatisticmonth.FieldSopRun)
  34943. }
  34944. if m.addtotal_friend != nil {
  34945. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  34946. }
  34947. if m.addtotal_group != nil {
  34948. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  34949. }
  34950. if m.addaccount_balance != nil {
  34951. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  34952. }
  34953. if m.addconsume_token != nil {
  34954. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  34955. }
  34956. if m.addactive_user != nil {
  34957. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  34958. }
  34959. if m.addnew_user != nil {
  34960. fields = append(fields, usagestatisticmonth.FieldNewUser)
  34961. }
  34962. return fields
  34963. }
  34964. // AddedField returns the numeric value that was incremented/decremented on a field
  34965. // with the given name. The second boolean return value indicates that this field
  34966. // was not set, or was not defined in the schema.
  34967. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  34968. switch name {
  34969. case usagestatisticmonth.FieldStatus:
  34970. return m.AddedStatus()
  34971. case usagestatisticmonth.FieldAddtime:
  34972. return m.AddedAddtime()
  34973. case usagestatisticmonth.FieldType:
  34974. return m.AddedType()
  34975. case usagestatisticmonth.FieldOrganizationID:
  34976. return m.AddedOrganizationID()
  34977. case usagestatisticmonth.FieldAiResponse:
  34978. return m.AddedAiResponse()
  34979. case usagestatisticmonth.FieldSopRun:
  34980. return m.AddedSopRun()
  34981. case usagestatisticmonth.FieldTotalFriend:
  34982. return m.AddedTotalFriend()
  34983. case usagestatisticmonth.FieldTotalGroup:
  34984. return m.AddedTotalGroup()
  34985. case usagestatisticmonth.FieldAccountBalance:
  34986. return m.AddedAccountBalance()
  34987. case usagestatisticmonth.FieldConsumeToken:
  34988. return m.AddedConsumeToken()
  34989. case usagestatisticmonth.FieldActiveUser:
  34990. return m.AddedActiveUser()
  34991. case usagestatisticmonth.FieldNewUser:
  34992. return m.AddedNewUser()
  34993. }
  34994. return nil, false
  34995. }
  34996. // AddField adds the value to the field with the given name. It returns an error if
  34997. // the field is not defined in the schema, or if the type mismatched the field
  34998. // type.
  34999. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  35000. switch name {
  35001. case usagestatisticmonth.FieldStatus:
  35002. v, ok := value.(int8)
  35003. if !ok {
  35004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35005. }
  35006. m.AddStatus(v)
  35007. return nil
  35008. case usagestatisticmonth.FieldAddtime:
  35009. v, ok := value.(int64)
  35010. if !ok {
  35011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35012. }
  35013. m.AddAddtime(v)
  35014. return nil
  35015. case usagestatisticmonth.FieldType:
  35016. v, ok := value.(int)
  35017. if !ok {
  35018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35019. }
  35020. m.AddType(v)
  35021. return nil
  35022. case usagestatisticmonth.FieldOrganizationID:
  35023. v, ok := value.(int64)
  35024. if !ok {
  35025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35026. }
  35027. m.AddOrganizationID(v)
  35028. return nil
  35029. case usagestatisticmonth.FieldAiResponse:
  35030. v, ok := value.(int64)
  35031. if !ok {
  35032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35033. }
  35034. m.AddAiResponse(v)
  35035. return nil
  35036. case usagestatisticmonth.FieldSopRun:
  35037. v, ok := value.(int64)
  35038. if !ok {
  35039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35040. }
  35041. m.AddSopRun(v)
  35042. return nil
  35043. case usagestatisticmonth.FieldTotalFriend:
  35044. v, ok := value.(int64)
  35045. if !ok {
  35046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35047. }
  35048. m.AddTotalFriend(v)
  35049. return nil
  35050. case usagestatisticmonth.FieldTotalGroup:
  35051. v, ok := value.(int64)
  35052. if !ok {
  35053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35054. }
  35055. m.AddTotalGroup(v)
  35056. return nil
  35057. case usagestatisticmonth.FieldAccountBalance:
  35058. v, ok := value.(int64)
  35059. if !ok {
  35060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35061. }
  35062. m.AddAccountBalance(v)
  35063. return nil
  35064. case usagestatisticmonth.FieldConsumeToken:
  35065. v, ok := value.(int64)
  35066. if !ok {
  35067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35068. }
  35069. m.AddConsumeToken(v)
  35070. return nil
  35071. case usagestatisticmonth.FieldActiveUser:
  35072. v, ok := value.(int64)
  35073. if !ok {
  35074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35075. }
  35076. m.AddActiveUser(v)
  35077. return nil
  35078. case usagestatisticmonth.FieldNewUser:
  35079. v, ok := value.(int64)
  35080. if !ok {
  35081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35082. }
  35083. m.AddNewUser(v)
  35084. return nil
  35085. }
  35086. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  35087. }
  35088. // ClearedFields returns all nullable fields that were cleared during this
  35089. // mutation.
  35090. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  35091. var fields []string
  35092. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  35093. fields = append(fields, usagestatisticmonth.FieldStatus)
  35094. }
  35095. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  35096. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  35097. }
  35098. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  35099. fields = append(fields, usagestatisticmonth.FieldBotID)
  35100. }
  35101. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  35102. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35103. }
  35104. return fields
  35105. }
  35106. // FieldCleared returns a boolean indicating if a field with the given name was
  35107. // cleared in this mutation.
  35108. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  35109. _, ok := m.clearedFields[name]
  35110. return ok
  35111. }
  35112. // ClearField clears the value of the field with the given name. It returns an
  35113. // error if the field is not defined in the schema.
  35114. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  35115. switch name {
  35116. case usagestatisticmonth.FieldStatus:
  35117. m.ClearStatus()
  35118. return nil
  35119. case usagestatisticmonth.FieldDeletedAt:
  35120. m.ClearDeletedAt()
  35121. return nil
  35122. case usagestatisticmonth.FieldBotID:
  35123. m.ClearBotID()
  35124. return nil
  35125. case usagestatisticmonth.FieldOrganizationID:
  35126. m.ClearOrganizationID()
  35127. return nil
  35128. }
  35129. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  35130. }
  35131. // ResetField resets all changes in the mutation for the field with the given name.
  35132. // It returns an error if the field is not defined in the schema.
  35133. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  35134. switch name {
  35135. case usagestatisticmonth.FieldCreatedAt:
  35136. m.ResetCreatedAt()
  35137. return nil
  35138. case usagestatisticmonth.FieldUpdatedAt:
  35139. m.ResetUpdatedAt()
  35140. return nil
  35141. case usagestatisticmonth.FieldStatus:
  35142. m.ResetStatus()
  35143. return nil
  35144. case usagestatisticmonth.FieldDeletedAt:
  35145. m.ResetDeletedAt()
  35146. return nil
  35147. case usagestatisticmonth.FieldAddtime:
  35148. m.ResetAddtime()
  35149. return nil
  35150. case usagestatisticmonth.FieldType:
  35151. m.ResetType()
  35152. return nil
  35153. case usagestatisticmonth.FieldBotID:
  35154. m.ResetBotID()
  35155. return nil
  35156. case usagestatisticmonth.FieldOrganizationID:
  35157. m.ResetOrganizationID()
  35158. return nil
  35159. case usagestatisticmonth.FieldAiResponse:
  35160. m.ResetAiResponse()
  35161. return nil
  35162. case usagestatisticmonth.FieldSopRun:
  35163. m.ResetSopRun()
  35164. return nil
  35165. case usagestatisticmonth.FieldTotalFriend:
  35166. m.ResetTotalFriend()
  35167. return nil
  35168. case usagestatisticmonth.FieldTotalGroup:
  35169. m.ResetTotalGroup()
  35170. return nil
  35171. case usagestatisticmonth.FieldAccountBalance:
  35172. m.ResetAccountBalance()
  35173. return nil
  35174. case usagestatisticmonth.FieldConsumeToken:
  35175. m.ResetConsumeToken()
  35176. return nil
  35177. case usagestatisticmonth.FieldActiveUser:
  35178. m.ResetActiveUser()
  35179. return nil
  35180. case usagestatisticmonth.FieldNewUser:
  35181. m.ResetNewUser()
  35182. return nil
  35183. case usagestatisticmonth.FieldLabelDist:
  35184. m.ResetLabelDist()
  35185. return nil
  35186. }
  35187. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35188. }
  35189. // AddedEdges returns all edge names that were set/added in this mutation.
  35190. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  35191. edges := make([]string, 0, 0)
  35192. return edges
  35193. }
  35194. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35195. // name in this mutation.
  35196. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  35197. return nil
  35198. }
  35199. // RemovedEdges returns all edge names that were removed in this mutation.
  35200. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  35201. edges := make([]string, 0, 0)
  35202. return edges
  35203. }
  35204. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35205. // the given name in this mutation.
  35206. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  35207. return nil
  35208. }
  35209. // ClearedEdges returns all edge names that were cleared in this mutation.
  35210. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  35211. edges := make([]string, 0, 0)
  35212. return edges
  35213. }
  35214. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35215. // was cleared in this mutation.
  35216. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  35217. return false
  35218. }
  35219. // ClearEdge clears the value of the edge with the given name. It returns an error
  35220. // if that edge is not defined in the schema.
  35221. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  35222. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  35223. }
  35224. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35225. // It returns an error if the edge is not defined in the schema.
  35226. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  35227. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  35228. }
  35229. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  35230. type UsageTotalMutation struct {
  35231. config
  35232. op Op
  35233. typ string
  35234. id *uint64
  35235. created_at *time.Time
  35236. updated_at *time.Time
  35237. status *uint8
  35238. addstatus *int8
  35239. _type *int
  35240. add_type *int
  35241. bot_id *string
  35242. total_tokens *uint64
  35243. addtotal_tokens *int64
  35244. start_index *uint64
  35245. addstart_index *int64
  35246. end_index *uint64
  35247. addend_index *int64
  35248. organization_id *uint64
  35249. addorganization_id *int64
  35250. clearedFields map[string]struct{}
  35251. done bool
  35252. oldValue func(context.Context) (*UsageTotal, error)
  35253. predicates []predicate.UsageTotal
  35254. }
  35255. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  35256. // usagetotalOption allows management of the mutation configuration using functional options.
  35257. type usagetotalOption func(*UsageTotalMutation)
  35258. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  35259. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  35260. m := &UsageTotalMutation{
  35261. config: c,
  35262. op: op,
  35263. typ: TypeUsageTotal,
  35264. clearedFields: make(map[string]struct{}),
  35265. }
  35266. for _, opt := range opts {
  35267. opt(m)
  35268. }
  35269. return m
  35270. }
  35271. // withUsageTotalID sets the ID field of the mutation.
  35272. func withUsageTotalID(id uint64) usagetotalOption {
  35273. return func(m *UsageTotalMutation) {
  35274. var (
  35275. err error
  35276. once sync.Once
  35277. value *UsageTotal
  35278. )
  35279. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  35280. once.Do(func() {
  35281. if m.done {
  35282. err = errors.New("querying old values post mutation is not allowed")
  35283. } else {
  35284. value, err = m.Client().UsageTotal.Get(ctx, id)
  35285. }
  35286. })
  35287. return value, err
  35288. }
  35289. m.id = &id
  35290. }
  35291. }
  35292. // withUsageTotal sets the old UsageTotal of the mutation.
  35293. func withUsageTotal(node *UsageTotal) usagetotalOption {
  35294. return func(m *UsageTotalMutation) {
  35295. m.oldValue = func(context.Context) (*UsageTotal, error) {
  35296. return node, nil
  35297. }
  35298. m.id = &node.ID
  35299. }
  35300. }
  35301. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35302. // executed in a transaction (ent.Tx), a transactional client is returned.
  35303. func (m UsageTotalMutation) Client() *Client {
  35304. client := &Client{config: m.config}
  35305. client.init()
  35306. return client
  35307. }
  35308. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35309. // it returns an error otherwise.
  35310. func (m UsageTotalMutation) Tx() (*Tx, error) {
  35311. if _, ok := m.driver.(*txDriver); !ok {
  35312. return nil, errors.New("ent: mutation is not running in a transaction")
  35313. }
  35314. tx := &Tx{config: m.config}
  35315. tx.init()
  35316. return tx, nil
  35317. }
  35318. // SetID sets the value of the id field. Note that this
  35319. // operation is only accepted on creation of UsageTotal entities.
  35320. func (m *UsageTotalMutation) SetID(id uint64) {
  35321. m.id = &id
  35322. }
  35323. // ID returns the ID value in the mutation. Note that the ID is only available
  35324. // if it was provided to the builder or after it was returned from the database.
  35325. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  35326. if m.id == nil {
  35327. return
  35328. }
  35329. return *m.id, true
  35330. }
  35331. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35332. // That means, if the mutation is applied within a transaction with an isolation level such
  35333. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35334. // or updated by the mutation.
  35335. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  35336. switch {
  35337. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35338. id, exists := m.ID()
  35339. if exists {
  35340. return []uint64{id}, nil
  35341. }
  35342. fallthrough
  35343. case m.op.Is(OpUpdate | OpDelete):
  35344. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  35345. default:
  35346. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35347. }
  35348. }
  35349. // SetCreatedAt sets the "created_at" field.
  35350. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  35351. m.created_at = &t
  35352. }
  35353. // CreatedAt returns the value of the "created_at" field in the mutation.
  35354. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  35355. v := m.created_at
  35356. if v == nil {
  35357. return
  35358. }
  35359. return *v, true
  35360. }
  35361. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  35362. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35364. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35365. if !m.op.Is(OpUpdateOne) {
  35366. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35367. }
  35368. if m.id == nil || m.oldValue == nil {
  35369. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35370. }
  35371. oldValue, err := m.oldValue(ctx)
  35372. if err != nil {
  35373. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35374. }
  35375. return oldValue.CreatedAt, nil
  35376. }
  35377. // ResetCreatedAt resets all changes to the "created_at" field.
  35378. func (m *UsageTotalMutation) ResetCreatedAt() {
  35379. m.created_at = nil
  35380. }
  35381. // SetUpdatedAt sets the "updated_at" field.
  35382. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  35383. m.updated_at = &t
  35384. }
  35385. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35386. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  35387. v := m.updated_at
  35388. if v == nil {
  35389. return
  35390. }
  35391. return *v, true
  35392. }
  35393. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  35394. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35396. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35397. if !m.op.Is(OpUpdateOne) {
  35398. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35399. }
  35400. if m.id == nil || m.oldValue == nil {
  35401. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35402. }
  35403. oldValue, err := m.oldValue(ctx)
  35404. if err != nil {
  35405. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35406. }
  35407. return oldValue.UpdatedAt, nil
  35408. }
  35409. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35410. func (m *UsageTotalMutation) ResetUpdatedAt() {
  35411. m.updated_at = nil
  35412. }
  35413. // SetStatus sets the "status" field.
  35414. func (m *UsageTotalMutation) SetStatus(u uint8) {
  35415. m.status = &u
  35416. m.addstatus = nil
  35417. }
  35418. // Status returns the value of the "status" field in the mutation.
  35419. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  35420. v := m.status
  35421. if v == nil {
  35422. return
  35423. }
  35424. return *v, true
  35425. }
  35426. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  35427. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35429. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35430. if !m.op.Is(OpUpdateOne) {
  35431. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35432. }
  35433. if m.id == nil || m.oldValue == nil {
  35434. return v, errors.New("OldStatus requires an ID field in the mutation")
  35435. }
  35436. oldValue, err := m.oldValue(ctx)
  35437. if err != nil {
  35438. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35439. }
  35440. return oldValue.Status, nil
  35441. }
  35442. // AddStatus adds u to the "status" field.
  35443. func (m *UsageTotalMutation) AddStatus(u int8) {
  35444. if m.addstatus != nil {
  35445. *m.addstatus += u
  35446. } else {
  35447. m.addstatus = &u
  35448. }
  35449. }
  35450. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35451. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  35452. v := m.addstatus
  35453. if v == nil {
  35454. return
  35455. }
  35456. return *v, true
  35457. }
  35458. // ClearStatus clears the value of the "status" field.
  35459. func (m *UsageTotalMutation) ClearStatus() {
  35460. m.status = nil
  35461. m.addstatus = nil
  35462. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  35463. }
  35464. // StatusCleared returns if the "status" field was cleared in this mutation.
  35465. func (m *UsageTotalMutation) StatusCleared() bool {
  35466. _, ok := m.clearedFields[usagetotal.FieldStatus]
  35467. return ok
  35468. }
  35469. // ResetStatus resets all changes to the "status" field.
  35470. func (m *UsageTotalMutation) ResetStatus() {
  35471. m.status = nil
  35472. m.addstatus = nil
  35473. delete(m.clearedFields, usagetotal.FieldStatus)
  35474. }
  35475. // SetType sets the "type" field.
  35476. func (m *UsageTotalMutation) SetType(i int) {
  35477. m._type = &i
  35478. m.add_type = nil
  35479. }
  35480. // GetType returns the value of the "type" field in the mutation.
  35481. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  35482. v := m._type
  35483. if v == nil {
  35484. return
  35485. }
  35486. return *v, true
  35487. }
  35488. // OldType returns the old "type" field's value of the UsageTotal entity.
  35489. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35491. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  35492. if !m.op.Is(OpUpdateOne) {
  35493. return v, errors.New("OldType is only allowed on UpdateOne operations")
  35494. }
  35495. if m.id == nil || m.oldValue == nil {
  35496. return v, errors.New("OldType requires an ID field in the mutation")
  35497. }
  35498. oldValue, err := m.oldValue(ctx)
  35499. if err != nil {
  35500. return v, fmt.Errorf("querying old value for OldType: %w", err)
  35501. }
  35502. return oldValue.Type, nil
  35503. }
  35504. // AddType adds i to the "type" field.
  35505. func (m *UsageTotalMutation) AddType(i int) {
  35506. if m.add_type != nil {
  35507. *m.add_type += i
  35508. } else {
  35509. m.add_type = &i
  35510. }
  35511. }
  35512. // AddedType returns the value that was added to the "type" field in this mutation.
  35513. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  35514. v := m.add_type
  35515. if v == nil {
  35516. return
  35517. }
  35518. return *v, true
  35519. }
  35520. // ClearType clears the value of the "type" field.
  35521. func (m *UsageTotalMutation) ClearType() {
  35522. m._type = nil
  35523. m.add_type = nil
  35524. m.clearedFields[usagetotal.FieldType] = struct{}{}
  35525. }
  35526. // TypeCleared returns if the "type" field was cleared in this mutation.
  35527. func (m *UsageTotalMutation) TypeCleared() bool {
  35528. _, ok := m.clearedFields[usagetotal.FieldType]
  35529. return ok
  35530. }
  35531. // ResetType resets all changes to the "type" field.
  35532. func (m *UsageTotalMutation) ResetType() {
  35533. m._type = nil
  35534. m.add_type = nil
  35535. delete(m.clearedFields, usagetotal.FieldType)
  35536. }
  35537. // SetBotID sets the "bot_id" field.
  35538. func (m *UsageTotalMutation) SetBotID(s string) {
  35539. m.bot_id = &s
  35540. }
  35541. // BotID returns the value of the "bot_id" field in the mutation.
  35542. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  35543. v := m.bot_id
  35544. if v == nil {
  35545. return
  35546. }
  35547. return *v, true
  35548. }
  35549. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  35550. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35552. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  35553. if !m.op.Is(OpUpdateOne) {
  35554. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  35555. }
  35556. if m.id == nil || m.oldValue == nil {
  35557. return v, errors.New("OldBotID requires an ID field in the mutation")
  35558. }
  35559. oldValue, err := m.oldValue(ctx)
  35560. if err != nil {
  35561. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  35562. }
  35563. return oldValue.BotID, nil
  35564. }
  35565. // ResetBotID resets all changes to the "bot_id" field.
  35566. func (m *UsageTotalMutation) ResetBotID() {
  35567. m.bot_id = nil
  35568. }
  35569. // SetTotalTokens sets the "total_tokens" field.
  35570. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  35571. m.total_tokens = &u
  35572. m.addtotal_tokens = nil
  35573. }
  35574. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  35575. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  35576. v := m.total_tokens
  35577. if v == nil {
  35578. return
  35579. }
  35580. return *v, true
  35581. }
  35582. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  35583. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35585. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  35586. if !m.op.Is(OpUpdateOne) {
  35587. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  35588. }
  35589. if m.id == nil || m.oldValue == nil {
  35590. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  35591. }
  35592. oldValue, err := m.oldValue(ctx)
  35593. if err != nil {
  35594. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  35595. }
  35596. return oldValue.TotalTokens, nil
  35597. }
  35598. // AddTotalTokens adds u to the "total_tokens" field.
  35599. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  35600. if m.addtotal_tokens != nil {
  35601. *m.addtotal_tokens += u
  35602. } else {
  35603. m.addtotal_tokens = &u
  35604. }
  35605. }
  35606. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  35607. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  35608. v := m.addtotal_tokens
  35609. if v == nil {
  35610. return
  35611. }
  35612. return *v, true
  35613. }
  35614. // ClearTotalTokens clears the value of the "total_tokens" field.
  35615. func (m *UsageTotalMutation) ClearTotalTokens() {
  35616. m.total_tokens = nil
  35617. m.addtotal_tokens = nil
  35618. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  35619. }
  35620. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  35621. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  35622. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  35623. return ok
  35624. }
  35625. // ResetTotalTokens resets all changes to the "total_tokens" field.
  35626. func (m *UsageTotalMutation) ResetTotalTokens() {
  35627. m.total_tokens = nil
  35628. m.addtotal_tokens = nil
  35629. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  35630. }
  35631. // SetStartIndex sets the "start_index" field.
  35632. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  35633. m.start_index = &u
  35634. m.addstart_index = nil
  35635. }
  35636. // StartIndex returns the value of the "start_index" field in the mutation.
  35637. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  35638. v := m.start_index
  35639. if v == nil {
  35640. return
  35641. }
  35642. return *v, true
  35643. }
  35644. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  35645. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35647. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  35648. if !m.op.Is(OpUpdateOne) {
  35649. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  35650. }
  35651. if m.id == nil || m.oldValue == nil {
  35652. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  35653. }
  35654. oldValue, err := m.oldValue(ctx)
  35655. if err != nil {
  35656. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  35657. }
  35658. return oldValue.StartIndex, nil
  35659. }
  35660. // AddStartIndex adds u to the "start_index" field.
  35661. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  35662. if m.addstart_index != nil {
  35663. *m.addstart_index += u
  35664. } else {
  35665. m.addstart_index = &u
  35666. }
  35667. }
  35668. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  35669. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  35670. v := m.addstart_index
  35671. if v == nil {
  35672. return
  35673. }
  35674. return *v, true
  35675. }
  35676. // ClearStartIndex clears the value of the "start_index" field.
  35677. func (m *UsageTotalMutation) ClearStartIndex() {
  35678. m.start_index = nil
  35679. m.addstart_index = nil
  35680. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  35681. }
  35682. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  35683. func (m *UsageTotalMutation) StartIndexCleared() bool {
  35684. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  35685. return ok
  35686. }
  35687. // ResetStartIndex resets all changes to the "start_index" field.
  35688. func (m *UsageTotalMutation) ResetStartIndex() {
  35689. m.start_index = nil
  35690. m.addstart_index = nil
  35691. delete(m.clearedFields, usagetotal.FieldStartIndex)
  35692. }
  35693. // SetEndIndex sets the "end_index" field.
  35694. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  35695. m.end_index = &u
  35696. m.addend_index = nil
  35697. }
  35698. // EndIndex returns the value of the "end_index" field in the mutation.
  35699. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  35700. v := m.end_index
  35701. if v == nil {
  35702. return
  35703. }
  35704. return *v, true
  35705. }
  35706. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  35707. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35709. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  35710. if !m.op.Is(OpUpdateOne) {
  35711. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  35712. }
  35713. if m.id == nil || m.oldValue == nil {
  35714. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  35715. }
  35716. oldValue, err := m.oldValue(ctx)
  35717. if err != nil {
  35718. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  35719. }
  35720. return oldValue.EndIndex, nil
  35721. }
  35722. // AddEndIndex adds u to the "end_index" field.
  35723. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  35724. if m.addend_index != nil {
  35725. *m.addend_index += u
  35726. } else {
  35727. m.addend_index = &u
  35728. }
  35729. }
  35730. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  35731. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  35732. v := m.addend_index
  35733. if v == nil {
  35734. return
  35735. }
  35736. return *v, true
  35737. }
  35738. // ClearEndIndex clears the value of the "end_index" field.
  35739. func (m *UsageTotalMutation) ClearEndIndex() {
  35740. m.end_index = nil
  35741. m.addend_index = nil
  35742. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  35743. }
  35744. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  35745. func (m *UsageTotalMutation) EndIndexCleared() bool {
  35746. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  35747. return ok
  35748. }
  35749. // ResetEndIndex resets all changes to the "end_index" field.
  35750. func (m *UsageTotalMutation) ResetEndIndex() {
  35751. m.end_index = nil
  35752. m.addend_index = nil
  35753. delete(m.clearedFields, usagetotal.FieldEndIndex)
  35754. }
  35755. // SetOrganizationID sets the "organization_id" field.
  35756. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  35757. m.organization_id = &u
  35758. m.addorganization_id = nil
  35759. }
  35760. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35761. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  35762. v := m.organization_id
  35763. if v == nil {
  35764. return
  35765. }
  35766. return *v, true
  35767. }
  35768. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  35769. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  35770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35771. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35772. if !m.op.Is(OpUpdateOne) {
  35773. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35774. }
  35775. if m.id == nil || m.oldValue == nil {
  35776. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35777. }
  35778. oldValue, err := m.oldValue(ctx)
  35779. if err != nil {
  35780. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35781. }
  35782. return oldValue.OrganizationID, nil
  35783. }
  35784. // AddOrganizationID adds u to the "organization_id" field.
  35785. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  35786. if m.addorganization_id != nil {
  35787. *m.addorganization_id += u
  35788. } else {
  35789. m.addorganization_id = &u
  35790. }
  35791. }
  35792. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35793. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  35794. v := m.addorganization_id
  35795. if v == nil {
  35796. return
  35797. }
  35798. return *v, true
  35799. }
  35800. // ClearOrganizationID clears the value of the "organization_id" field.
  35801. func (m *UsageTotalMutation) ClearOrganizationID() {
  35802. m.organization_id = nil
  35803. m.addorganization_id = nil
  35804. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  35805. }
  35806. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35807. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  35808. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  35809. return ok
  35810. }
  35811. // ResetOrganizationID resets all changes to the "organization_id" field.
  35812. func (m *UsageTotalMutation) ResetOrganizationID() {
  35813. m.organization_id = nil
  35814. m.addorganization_id = nil
  35815. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  35816. }
  35817. // Where appends a list predicates to the UsageTotalMutation builder.
  35818. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  35819. m.predicates = append(m.predicates, ps...)
  35820. }
  35821. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  35822. // users can use type-assertion to append predicates that do not depend on any generated package.
  35823. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  35824. p := make([]predicate.UsageTotal, len(ps))
  35825. for i := range ps {
  35826. p[i] = ps[i]
  35827. }
  35828. m.Where(p...)
  35829. }
  35830. // Op returns the operation name.
  35831. func (m *UsageTotalMutation) Op() Op {
  35832. return m.op
  35833. }
  35834. // SetOp allows setting the mutation operation.
  35835. func (m *UsageTotalMutation) SetOp(op Op) {
  35836. m.op = op
  35837. }
  35838. // Type returns the node type of this mutation (UsageTotal).
  35839. func (m *UsageTotalMutation) Type() string {
  35840. return m.typ
  35841. }
  35842. // Fields returns all fields that were changed during this mutation. Note that in
  35843. // order to get all numeric fields that were incremented/decremented, call
  35844. // AddedFields().
  35845. func (m *UsageTotalMutation) Fields() []string {
  35846. fields := make([]string, 0, 9)
  35847. if m.created_at != nil {
  35848. fields = append(fields, usagetotal.FieldCreatedAt)
  35849. }
  35850. if m.updated_at != nil {
  35851. fields = append(fields, usagetotal.FieldUpdatedAt)
  35852. }
  35853. if m.status != nil {
  35854. fields = append(fields, usagetotal.FieldStatus)
  35855. }
  35856. if m._type != nil {
  35857. fields = append(fields, usagetotal.FieldType)
  35858. }
  35859. if m.bot_id != nil {
  35860. fields = append(fields, usagetotal.FieldBotID)
  35861. }
  35862. if m.total_tokens != nil {
  35863. fields = append(fields, usagetotal.FieldTotalTokens)
  35864. }
  35865. if m.start_index != nil {
  35866. fields = append(fields, usagetotal.FieldStartIndex)
  35867. }
  35868. if m.end_index != nil {
  35869. fields = append(fields, usagetotal.FieldEndIndex)
  35870. }
  35871. if m.organization_id != nil {
  35872. fields = append(fields, usagetotal.FieldOrganizationID)
  35873. }
  35874. return fields
  35875. }
  35876. // Field returns the value of a field with the given name. The second boolean
  35877. // return value indicates that this field was not set, or was not defined in the
  35878. // schema.
  35879. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  35880. switch name {
  35881. case usagetotal.FieldCreatedAt:
  35882. return m.CreatedAt()
  35883. case usagetotal.FieldUpdatedAt:
  35884. return m.UpdatedAt()
  35885. case usagetotal.FieldStatus:
  35886. return m.Status()
  35887. case usagetotal.FieldType:
  35888. return m.GetType()
  35889. case usagetotal.FieldBotID:
  35890. return m.BotID()
  35891. case usagetotal.FieldTotalTokens:
  35892. return m.TotalTokens()
  35893. case usagetotal.FieldStartIndex:
  35894. return m.StartIndex()
  35895. case usagetotal.FieldEndIndex:
  35896. return m.EndIndex()
  35897. case usagetotal.FieldOrganizationID:
  35898. return m.OrganizationID()
  35899. }
  35900. return nil, false
  35901. }
  35902. // OldField returns the old value of the field from the database. An error is
  35903. // returned if the mutation operation is not UpdateOne, or the query to the
  35904. // database failed.
  35905. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35906. switch name {
  35907. case usagetotal.FieldCreatedAt:
  35908. return m.OldCreatedAt(ctx)
  35909. case usagetotal.FieldUpdatedAt:
  35910. return m.OldUpdatedAt(ctx)
  35911. case usagetotal.FieldStatus:
  35912. return m.OldStatus(ctx)
  35913. case usagetotal.FieldType:
  35914. return m.OldType(ctx)
  35915. case usagetotal.FieldBotID:
  35916. return m.OldBotID(ctx)
  35917. case usagetotal.FieldTotalTokens:
  35918. return m.OldTotalTokens(ctx)
  35919. case usagetotal.FieldStartIndex:
  35920. return m.OldStartIndex(ctx)
  35921. case usagetotal.FieldEndIndex:
  35922. return m.OldEndIndex(ctx)
  35923. case usagetotal.FieldOrganizationID:
  35924. return m.OldOrganizationID(ctx)
  35925. }
  35926. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  35927. }
  35928. // SetField sets the value of a field with the given name. It returns an error if
  35929. // the field is not defined in the schema, or if the type mismatched the field
  35930. // type.
  35931. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  35932. switch name {
  35933. case usagetotal.FieldCreatedAt:
  35934. v, ok := value.(time.Time)
  35935. if !ok {
  35936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35937. }
  35938. m.SetCreatedAt(v)
  35939. return nil
  35940. case usagetotal.FieldUpdatedAt:
  35941. v, ok := value.(time.Time)
  35942. if !ok {
  35943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35944. }
  35945. m.SetUpdatedAt(v)
  35946. return nil
  35947. case usagetotal.FieldStatus:
  35948. v, ok := value.(uint8)
  35949. if !ok {
  35950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35951. }
  35952. m.SetStatus(v)
  35953. return nil
  35954. case usagetotal.FieldType:
  35955. v, ok := value.(int)
  35956. if !ok {
  35957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35958. }
  35959. m.SetType(v)
  35960. return nil
  35961. case usagetotal.FieldBotID:
  35962. v, ok := value.(string)
  35963. if !ok {
  35964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35965. }
  35966. m.SetBotID(v)
  35967. return nil
  35968. case usagetotal.FieldTotalTokens:
  35969. v, ok := value.(uint64)
  35970. if !ok {
  35971. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35972. }
  35973. m.SetTotalTokens(v)
  35974. return nil
  35975. case usagetotal.FieldStartIndex:
  35976. v, ok := value.(uint64)
  35977. if !ok {
  35978. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35979. }
  35980. m.SetStartIndex(v)
  35981. return nil
  35982. case usagetotal.FieldEndIndex:
  35983. v, ok := value.(uint64)
  35984. if !ok {
  35985. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35986. }
  35987. m.SetEndIndex(v)
  35988. return nil
  35989. case usagetotal.FieldOrganizationID:
  35990. v, ok := value.(uint64)
  35991. if !ok {
  35992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35993. }
  35994. m.SetOrganizationID(v)
  35995. return nil
  35996. }
  35997. return fmt.Errorf("unknown UsageTotal field %s", name)
  35998. }
  35999. // AddedFields returns all numeric fields that were incremented/decremented during
  36000. // this mutation.
  36001. func (m *UsageTotalMutation) AddedFields() []string {
  36002. var fields []string
  36003. if m.addstatus != nil {
  36004. fields = append(fields, usagetotal.FieldStatus)
  36005. }
  36006. if m.add_type != nil {
  36007. fields = append(fields, usagetotal.FieldType)
  36008. }
  36009. if m.addtotal_tokens != nil {
  36010. fields = append(fields, usagetotal.FieldTotalTokens)
  36011. }
  36012. if m.addstart_index != nil {
  36013. fields = append(fields, usagetotal.FieldStartIndex)
  36014. }
  36015. if m.addend_index != nil {
  36016. fields = append(fields, usagetotal.FieldEndIndex)
  36017. }
  36018. if m.addorganization_id != nil {
  36019. fields = append(fields, usagetotal.FieldOrganizationID)
  36020. }
  36021. return fields
  36022. }
  36023. // AddedField returns the numeric value that was incremented/decremented on a field
  36024. // with the given name. The second boolean return value indicates that this field
  36025. // was not set, or was not defined in the schema.
  36026. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  36027. switch name {
  36028. case usagetotal.FieldStatus:
  36029. return m.AddedStatus()
  36030. case usagetotal.FieldType:
  36031. return m.AddedType()
  36032. case usagetotal.FieldTotalTokens:
  36033. return m.AddedTotalTokens()
  36034. case usagetotal.FieldStartIndex:
  36035. return m.AddedStartIndex()
  36036. case usagetotal.FieldEndIndex:
  36037. return m.AddedEndIndex()
  36038. case usagetotal.FieldOrganizationID:
  36039. return m.AddedOrganizationID()
  36040. }
  36041. return nil, false
  36042. }
  36043. // AddField adds the value to the field with the given name. It returns an error if
  36044. // the field is not defined in the schema, or if the type mismatched the field
  36045. // type.
  36046. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  36047. switch name {
  36048. case usagetotal.FieldStatus:
  36049. v, ok := value.(int8)
  36050. if !ok {
  36051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36052. }
  36053. m.AddStatus(v)
  36054. return nil
  36055. case usagetotal.FieldType:
  36056. v, ok := value.(int)
  36057. if !ok {
  36058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36059. }
  36060. m.AddType(v)
  36061. return nil
  36062. case usagetotal.FieldTotalTokens:
  36063. v, ok := value.(int64)
  36064. if !ok {
  36065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36066. }
  36067. m.AddTotalTokens(v)
  36068. return nil
  36069. case usagetotal.FieldStartIndex:
  36070. v, ok := value.(int64)
  36071. if !ok {
  36072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36073. }
  36074. m.AddStartIndex(v)
  36075. return nil
  36076. case usagetotal.FieldEndIndex:
  36077. v, ok := value.(int64)
  36078. if !ok {
  36079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36080. }
  36081. m.AddEndIndex(v)
  36082. return nil
  36083. case usagetotal.FieldOrganizationID:
  36084. v, ok := value.(int64)
  36085. if !ok {
  36086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36087. }
  36088. m.AddOrganizationID(v)
  36089. return nil
  36090. }
  36091. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  36092. }
  36093. // ClearedFields returns all nullable fields that were cleared during this
  36094. // mutation.
  36095. func (m *UsageTotalMutation) ClearedFields() []string {
  36096. var fields []string
  36097. if m.FieldCleared(usagetotal.FieldStatus) {
  36098. fields = append(fields, usagetotal.FieldStatus)
  36099. }
  36100. if m.FieldCleared(usagetotal.FieldType) {
  36101. fields = append(fields, usagetotal.FieldType)
  36102. }
  36103. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  36104. fields = append(fields, usagetotal.FieldTotalTokens)
  36105. }
  36106. if m.FieldCleared(usagetotal.FieldStartIndex) {
  36107. fields = append(fields, usagetotal.FieldStartIndex)
  36108. }
  36109. if m.FieldCleared(usagetotal.FieldEndIndex) {
  36110. fields = append(fields, usagetotal.FieldEndIndex)
  36111. }
  36112. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  36113. fields = append(fields, usagetotal.FieldOrganizationID)
  36114. }
  36115. return fields
  36116. }
  36117. // FieldCleared returns a boolean indicating if a field with the given name was
  36118. // cleared in this mutation.
  36119. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  36120. _, ok := m.clearedFields[name]
  36121. return ok
  36122. }
  36123. // ClearField clears the value of the field with the given name. It returns an
  36124. // error if the field is not defined in the schema.
  36125. func (m *UsageTotalMutation) ClearField(name string) error {
  36126. switch name {
  36127. case usagetotal.FieldStatus:
  36128. m.ClearStatus()
  36129. return nil
  36130. case usagetotal.FieldType:
  36131. m.ClearType()
  36132. return nil
  36133. case usagetotal.FieldTotalTokens:
  36134. m.ClearTotalTokens()
  36135. return nil
  36136. case usagetotal.FieldStartIndex:
  36137. m.ClearStartIndex()
  36138. return nil
  36139. case usagetotal.FieldEndIndex:
  36140. m.ClearEndIndex()
  36141. return nil
  36142. case usagetotal.FieldOrganizationID:
  36143. m.ClearOrganizationID()
  36144. return nil
  36145. }
  36146. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  36147. }
  36148. // ResetField resets all changes in the mutation for the field with the given name.
  36149. // It returns an error if the field is not defined in the schema.
  36150. func (m *UsageTotalMutation) ResetField(name string) error {
  36151. switch name {
  36152. case usagetotal.FieldCreatedAt:
  36153. m.ResetCreatedAt()
  36154. return nil
  36155. case usagetotal.FieldUpdatedAt:
  36156. m.ResetUpdatedAt()
  36157. return nil
  36158. case usagetotal.FieldStatus:
  36159. m.ResetStatus()
  36160. return nil
  36161. case usagetotal.FieldType:
  36162. m.ResetType()
  36163. return nil
  36164. case usagetotal.FieldBotID:
  36165. m.ResetBotID()
  36166. return nil
  36167. case usagetotal.FieldTotalTokens:
  36168. m.ResetTotalTokens()
  36169. return nil
  36170. case usagetotal.FieldStartIndex:
  36171. m.ResetStartIndex()
  36172. return nil
  36173. case usagetotal.FieldEndIndex:
  36174. m.ResetEndIndex()
  36175. return nil
  36176. case usagetotal.FieldOrganizationID:
  36177. m.ResetOrganizationID()
  36178. return nil
  36179. }
  36180. return fmt.Errorf("unknown UsageTotal field %s", name)
  36181. }
  36182. // AddedEdges returns all edge names that were set/added in this mutation.
  36183. func (m *UsageTotalMutation) AddedEdges() []string {
  36184. edges := make([]string, 0, 0)
  36185. return edges
  36186. }
  36187. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36188. // name in this mutation.
  36189. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  36190. return nil
  36191. }
  36192. // RemovedEdges returns all edge names that were removed in this mutation.
  36193. func (m *UsageTotalMutation) RemovedEdges() []string {
  36194. edges := make([]string, 0, 0)
  36195. return edges
  36196. }
  36197. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36198. // the given name in this mutation.
  36199. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  36200. return nil
  36201. }
  36202. // ClearedEdges returns all edge names that were cleared in this mutation.
  36203. func (m *UsageTotalMutation) ClearedEdges() []string {
  36204. edges := make([]string, 0, 0)
  36205. return edges
  36206. }
  36207. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36208. // was cleared in this mutation.
  36209. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  36210. return false
  36211. }
  36212. // ClearEdge clears the value of the edge with the given name. It returns an error
  36213. // if that edge is not defined in the schema.
  36214. func (m *UsageTotalMutation) ClearEdge(name string) error {
  36215. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  36216. }
  36217. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36218. // It returns an error if the edge is not defined in the schema.
  36219. func (m *UsageTotalMutation) ResetEdge(name string) error {
  36220. return fmt.Errorf("unknown UsageTotal edge %s", name)
  36221. }
  36222. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  36223. type WhatsappMutation struct {
  36224. config
  36225. op Op
  36226. typ string
  36227. id *uint64
  36228. created_at *time.Time
  36229. updated_at *time.Time
  36230. status *uint8
  36231. addstatus *int8
  36232. deleted_at *time.Time
  36233. wa_id *string
  36234. wa_name *string
  36235. callback *string
  36236. account *string
  36237. cc *string
  36238. phone *string
  36239. cc_phone *string
  36240. phone_name *string
  36241. phone_status *int8
  36242. addphone_status *int8
  36243. organization_id *uint64
  36244. addorganization_id *int64
  36245. api_base *string
  36246. api_key *string
  36247. allow_list *[]string
  36248. appendallow_list []string
  36249. group_allow_list *[]string
  36250. appendgroup_allow_list []string
  36251. block_list *[]string
  36252. appendblock_list []string
  36253. group_block_list *[]string
  36254. appendgroup_block_list []string
  36255. clearedFields map[string]struct{}
  36256. agent *uint64
  36257. clearedagent bool
  36258. done bool
  36259. oldValue func(context.Context) (*Whatsapp, error)
  36260. predicates []predicate.Whatsapp
  36261. }
  36262. var _ ent.Mutation = (*WhatsappMutation)(nil)
  36263. // whatsappOption allows management of the mutation configuration using functional options.
  36264. type whatsappOption func(*WhatsappMutation)
  36265. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  36266. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  36267. m := &WhatsappMutation{
  36268. config: c,
  36269. op: op,
  36270. typ: TypeWhatsapp,
  36271. clearedFields: make(map[string]struct{}),
  36272. }
  36273. for _, opt := range opts {
  36274. opt(m)
  36275. }
  36276. return m
  36277. }
  36278. // withWhatsappID sets the ID field of the mutation.
  36279. func withWhatsappID(id uint64) whatsappOption {
  36280. return func(m *WhatsappMutation) {
  36281. var (
  36282. err error
  36283. once sync.Once
  36284. value *Whatsapp
  36285. )
  36286. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  36287. once.Do(func() {
  36288. if m.done {
  36289. err = errors.New("querying old values post mutation is not allowed")
  36290. } else {
  36291. value, err = m.Client().Whatsapp.Get(ctx, id)
  36292. }
  36293. })
  36294. return value, err
  36295. }
  36296. m.id = &id
  36297. }
  36298. }
  36299. // withWhatsapp sets the old Whatsapp of the mutation.
  36300. func withWhatsapp(node *Whatsapp) whatsappOption {
  36301. return func(m *WhatsappMutation) {
  36302. m.oldValue = func(context.Context) (*Whatsapp, error) {
  36303. return node, nil
  36304. }
  36305. m.id = &node.ID
  36306. }
  36307. }
  36308. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36309. // executed in a transaction (ent.Tx), a transactional client is returned.
  36310. func (m WhatsappMutation) Client() *Client {
  36311. client := &Client{config: m.config}
  36312. client.init()
  36313. return client
  36314. }
  36315. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36316. // it returns an error otherwise.
  36317. func (m WhatsappMutation) Tx() (*Tx, error) {
  36318. if _, ok := m.driver.(*txDriver); !ok {
  36319. return nil, errors.New("ent: mutation is not running in a transaction")
  36320. }
  36321. tx := &Tx{config: m.config}
  36322. tx.init()
  36323. return tx, nil
  36324. }
  36325. // SetID sets the value of the id field. Note that this
  36326. // operation is only accepted on creation of Whatsapp entities.
  36327. func (m *WhatsappMutation) SetID(id uint64) {
  36328. m.id = &id
  36329. }
  36330. // ID returns the ID value in the mutation. Note that the ID is only available
  36331. // if it was provided to the builder or after it was returned from the database.
  36332. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  36333. if m.id == nil {
  36334. return
  36335. }
  36336. return *m.id, true
  36337. }
  36338. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36339. // That means, if the mutation is applied within a transaction with an isolation level such
  36340. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36341. // or updated by the mutation.
  36342. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  36343. switch {
  36344. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36345. id, exists := m.ID()
  36346. if exists {
  36347. return []uint64{id}, nil
  36348. }
  36349. fallthrough
  36350. case m.op.Is(OpUpdate | OpDelete):
  36351. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  36352. default:
  36353. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36354. }
  36355. }
  36356. // SetCreatedAt sets the "created_at" field.
  36357. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  36358. m.created_at = &t
  36359. }
  36360. // CreatedAt returns the value of the "created_at" field in the mutation.
  36361. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  36362. v := m.created_at
  36363. if v == nil {
  36364. return
  36365. }
  36366. return *v, true
  36367. }
  36368. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  36369. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36371. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36372. if !m.op.Is(OpUpdateOne) {
  36373. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36374. }
  36375. if m.id == nil || m.oldValue == nil {
  36376. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36377. }
  36378. oldValue, err := m.oldValue(ctx)
  36379. if err != nil {
  36380. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36381. }
  36382. return oldValue.CreatedAt, nil
  36383. }
  36384. // ResetCreatedAt resets all changes to the "created_at" field.
  36385. func (m *WhatsappMutation) ResetCreatedAt() {
  36386. m.created_at = nil
  36387. }
  36388. // SetUpdatedAt sets the "updated_at" field.
  36389. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  36390. m.updated_at = &t
  36391. }
  36392. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36393. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  36394. v := m.updated_at
  36395. if v == nil {
  36396. return
  36397. }
  36398. return *v, true
  36399. }
  36400. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  36401. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36403. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36404. if !m.op.Is(OpUpdateOne) {
  36405. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36406. }
  36407. if m.id == nil || m.oldValue == nil {
  36408. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36409. }
  36410. oldValue, err := m.oldValue(ctx)
  36411. if err != nil {
  36412. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36413. }
  36414. return oldValue.UpdatedAt, nil
  36415. }
  36416. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36417. func (m *WhatsappMutation) ResetUpdatedAt() {
  36418. m.updated_at = nil
  36419. }
  36420. // SetStatus sets the "status" field.
  36421. func (m *WhatsappMutation) SetStatus(u uint8) {
  36422. m.status = &u
  36423. m.addstatus = nil
  36424. }
  36425. // Status returns the value of the "status" field in the mutation.
  36426. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  36427. v := m.status
  36428. if v == nil {
  36429. return
  36430. }
  36431. return *v, true
  36432. }
  36433. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  36434. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36436. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36437. if !m.op.Is(OpUpdateOne) {
  36438. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36439. }
  36440. if m.id == nil || m.oldValue == nil {
  36441. return v, errors.New("OldStatus requires an ID field in the mutation")
  36442. }
  36443. oldValue, err := m.oldValue(ctx)
  36444. if err != nil {
  36445. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36446. }
  36447. return oldValue.Status, nil
  36448. }
  36449. // AddStatus adds u to the "status" field.
  36450. func (m *WhatsappMutation) AddStatus(u int8) {
  36451. if m.addstatus != nil {
  36452. *m.addstatus += u
  36453. } else {
  36454. m.addstatus = &u
  36455. }
  36456. }
  36457. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36458. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  36459. v := m.addstatus
  36460. if v == nil {
  36461. return
  36462. }
  36463. return *v, true
  36464. }
  36465. // ClearStatus clears the value of the "status" field.
  36466. func (m *WhatsappMutation) ClearStatus() {
  36467. m.status = nil
  36468. m.addstatus = nil
  36469. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  36470. }
  36471. // StatusCleared returns if the "status" field was cleared in this mutation.
  36472. func (m *WhatsappMutation) StatusCleared() bool {
  36473. _, ok := m.clearedFields[whatsapp.FieldStatus]
  36474. return ok
  36475. }
  36476. // ResetStatus resets all changes to the "status" field.
  36477. func (m *WhatsappMutation) ResetStatus() {
  36478. m.status = nil
  36479. m.addstatus = nil
  36480. delete(m.clearedFields, whatsapp.FieldStatus)
  36481. }
  36482. // SetDeletedAt sets the "deleted_at" field.
  36483. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  36484. m.deleted_at = &t
  36485. }
  36486. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36487. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  36488. v := m.deleted_at
  36489. if v == nil {
  36490. return
  36491. }
  36492. return *v, true
  36493. }
  36494. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  36495. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36497. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36498. if !m.op.Is(OpUpdateOne) {
  36499. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36500. }
  36501. if m.id == nil || m.oldValue == nil {
  36502. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36503. }
  36504. oldValue, err := m.oldValue(ctx)
  36505. if err != nil {
  36506. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36507. }
  36508. return oldValue.DeletedAt, nil
  36509. }
  36510. // ClearDeletedAt clears the value of the "deleted_at" field.
  36511. func (m *WhatsappMutation) ClearDeletedAt() {
  36512. m.deleted_at = nil
  36513. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  36514. }
  36515. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36516. func (m *WhatsappMutation) DeletedAtCleared() bool {
  36517. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  36518. return ok
  36519. }
  36520. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36521. func (m *WhatsappMutation) ResetDeletedAt() {
  36522. m.deleted_at = nil
  36523. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  36524. }
  36525. // SetWaID sets the "wa_id" field.
  36526. func (m *WhatsappMutation) SetWaID(s string) {
  36527. m.wa_id = &s
  36528. }
  36529. // WaID returns the value of the "wa_id" field in the mutation.
  36530. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  36531. v := m.wa_id
  36532. if v == nil {
  36533. return
  36534. }
  36535. return *v, true
  36536. }
  36537. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  36538. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36540. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  36541. if !m.op.Is(OpUpdateOne) {
  36542. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  36543. }
  36544. if m.id == nil || m.oldValue == nil {
  36545. return v, errors.New("OldWaID requires an ID field in the mutation")
  36546. }
  36547. oldValue, err := m.oldValue(ctx)
  36548. if err != nil {
  36549. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  36550. }
  36551. return oldValue.WaID, nil
  36552. }
  36553. // ClearWaID clears the value of the "wa_id" field.
  36554. func (m *WhatsappMutation) ClearWaID() {
  36555. m.wa_id = nil
  36556. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  36557. }
  36558. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  36559. func (m *WhatsappMutation) WaIDCleared() bool {
  36560. _, ok := m.clearedFields[whatsapp.FieldWaID]
  36561. return ok
  36562. }
  36563. // ResetWaID resets all changes to the "wa_id" field.
  36564. func (m *WhatsappMutation) ResetWaID() {
  36565. m.wa_id = nil
  36566. delete(m.clearedFields, whatsapp.FieldWaID)
  36567. }
  36568. // SetWaName sets the "wa_name" field.
  36569. func (m *WhatsappMutation) SetWaName(s string) {
  36570. m.wa_name = &s
  36571. }
  36572. // WaName returns the value of the "wa_name" field in the mutation.
  36573. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  36574. v := m.wa_name
  36575. if v == nil {
  36576. return
  36577. }
  36578. return *v, true
  36579. }
  36580. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  36581. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36583. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  36584. if !m.op.Is(OpUpdateOne) {
  36585. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  36586. }
  36587. if m.id == nil || m.oldValue == nil {
  36588. return v, errors.New("OldWaName requires an ID field in the mutation")
  36589. }
  36590. oldValue, err := m.oldValue(ctx)
  36591. if err != nil {
  36592. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  36593. }
  36594. return oldValue.WaName, nil
  36595. }
  36596. // ClearWaName clears the value of the "wa_name" field.
  36597. func (m *WhatsappMutation) ClearWaName() {
  36598. m.wa_name = nil
  36599. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  36600. }
  36601. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  36602. func (m *WhatsappMutation) WaNameCleared() bool {
  36603. _, ok := m.clearedFields[whatsapp.FieldWaName]
  36604. return ok
  36605. }
  36606. // ResetWaName resets all changes to the "wa_name" field.
  36607. func (m *WhatsappMutation) ResetWaName() {
  36608. m.wa_name = nil
  36609. delete(m.clearedFields, whatsapp.FieldWaName)
  36610. }
  36611. // SetCallback sets the "callback" field.
  36612. func (m *WhatsappMutation) SetCallback(s string) {
  36613. m.callback = &s
  36614. }
  36615. // Callback returns the value of the "callback" field in the mutation.
  36616. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  36617. v := m.callback
  36618. if v == nil {
  36619. return
  36620. }
  36621. return *v, true
  36622. }
  36623. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  36624. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36626. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  36627. if !m.op.Is(OpUpdateOne) {
  36628. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36629. }
  36630. if m.id == nil || m.oldValue == nil {
  36631. return v, errors.New("OldCallback requires an ID field in the mutation")
  36632. }
  36633. oldValue, err := m.oldValue(ctx)
  36634. if err != nil {
  36635. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36636. }
  36637. return oldValue.Callback, nil
  36638. }
  36639. // ClearCallback clears the value of the "callback" field.
  36640. func (m *WhatsappMutation) ClearCallback() {
  36641. m.callback = nil
  36642. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  36643. }
  36644. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  36645. func (m *WhatsappMutation) CallbackCleared() bool {
  36646. _, ok := m.clearedFields[whatsapp.FieldCallback]
  36647. return ok
  36648. }
  36649. // ResetCallback resets all changes to the "callback" field.
  36650. func (m *WhatsappMutation) ResetCallback() {
  36651. m.callback = nil
  36652. delete(m.clearedFields, whatsapp.FieldCallback)
  36653. }
  36654. // SetAgentID sets the "agent_id" field.
  36655. func (m *WhatsappMutation) SetAgentID(u uint64) {
  36656. m.agent = &u
  36657. }
  36658. // AgentID returns the value of the "agent_id" field in the mutation.
  36659. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  36660. v := m.agent
  36661. if v == nil {
  36662. return
  36663. }
  36664. return *v, true
  36665. }
  36666. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  36667. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36669. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36670. if !m.op.Is(OpUpdateOne) {
  36671. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36672. }
  36673. if m.id == nil || m.oldValue == nil {
  36674. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36675. }
  36676. oldValue, err := m.oldValue(ctx)
  36677. if err != nil {
  36678. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36679. }
  36680. return oldValue.AgentID, nil
  36681. }
  36682. // ResetAgentID resets all changes to the "agent_id" field.
  36683. func (m *WhatsappMutation) ResetAgentID() {
  36684. m.agent = nil
  36685. }
  36686. // SetAccount sets the "account" field.
  36687. func (m *WhatsappMutation) SetAccount(s string) {
  36688. m.account = &s
  36689. }
  36690. // Account returns the value of the "account" field in the mutation.
  36691. func (m *WhatsappMutation) Account() (r string, exists bool) {
  36692. v := m.account
  36693. if v == nil {
  36694. return
  36695. }
  36696. return *v, true
  36697. }
  36698. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  36699. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36701. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  36702. if !m.op.Is(OpUpdateOne) {
  36703. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36704. }
  36705. if m.id == nil || m.oldValue == nil {
  36706. return v, errors.New("OldAccount requires an ID field in the mutation")
  36707. }
  36708. oldValue, err := m.oldValue(ctx)
  36709. if err != nil {
  36710. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36711. }
  36712. return oldValue.Account, nil
  36713. }
  36714. // ClearAccount clears the value of the "account" field.
  36715. func (m *WhatsappMutation) ClearAccount() {
  36716. m.account = nil
  36717. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  36718. }
  36719. // AccountCleared returns if the "account" field was cleared in this mutation.
  36720. func (m *WhatsappMutation) AccountCleared() bool {
  36721. _, ok := m.clearedFields[whatsapp.FieldAccount]
  36722. return ok
  36723. }
  36724. // ResetAccount resets all changes to the "account" field.
  36725. func (m *WhatsappMutation) ResetAccount() {
  36726. m.account = nil
  36727. delete(m.clearedFields, whatsapp.FieldAccount)
  36728. }
  36729. // SetCc sets the "cc" field.
  36730. func (m *WhatsappMutation) SetCc(s string) {
  36731. m.cc = &s
  36732. }
  36733. // Cc returns the value of the "cc" field in the mutation.
  36734. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  36735. v := m.cc
  36736. if v == nil {
  36737. return
  36738. }
  36739. return *v, true
  36740. }
  36741. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  36742. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36744. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  36745. if !m.op.Is(OpUpdateOne) {
  36746. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  36747. }
  36748. if m.id == nil || m.oldValue == nil {
  36749. return v, errors.New("OldCc requires an ID field in the mutation")
  36750. }
  36751. oldValue, err := m.oldValue(ctx)
  36752. if err != nil {
  36753. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  36754. }
  36755. return oldValue.Cc, nil
  36756. }
  36757. // ResetCc resets all changes to the "cc" field.
  36758. func (m *WhatsappMutation) ResetCc() {
  36759. m.cc = nil
  36760. }
  36761. // SetPhone sets the "phone" field.
  36762. func (m *WhatsappMutation) SetPhone(s string) {
  36763. m.phone = &s
  36764. }
  36765. // Phone returns the value of the "phone" field in the mutation.
  36766. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  36767. v := m.phone
  36768. if v == nil {
  36769. return
  36770. }
  36771. return *v, true
  36772. }
  36773. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  36774. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36776. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  36777. if !m.op.Is(OpUpdateOne) {
  36778. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  36779. }
  36780. if m.id == nil || m.oldValue == nil {
  36781. return v, errors.New("OldPhone requires an ID field in the mutation")
  36782. }
  36783. oldValue, err := m.oldValue(ctx)
  36784. if err != nil {
  36785. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  36786. }
  36787. return oldValue.Phone, nil
  36788. }
  36789. // ResetPhone resets all changes to the "phone" field.
  36790. func (m *WhatsappMutation) ResetPhone() {
  36791. m.phone = nil
  36792. }
  36793. // SetCcPhone sets the "cc_phone" field.
  36794. func (m *WhatsappMutation) SetCcPhone(s string) {
  36795. m.cc_phone = &s
  36796. }
  36797. // CcPhone returns the value of the "cc_phone" field in the mutation.
  36798. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  36799. v := m.cc_phone
  36800. if v == nil {
  36801. return
  36802. }
  36803. return *v, true
  36804. }
  36805. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  36806. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36808. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  36809. if !m.op.Is(OpUpdateOne) {
  36810. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  36811. }
  36812. if m.id == nil || m.oldValue == nil {
  36813. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  36814. }
  36815. oldValue, err := m.oldValue(ctx)
  36816. if err != nil {
  36817. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  36818. }
  36819. return oldValue.CcPhone, nil
  36820. }
  36821. // ResetCcPhone resets all changes to the "cc_phone" field.
  36822. func (m *WhatsappMutation) ResetCcPhone() {
  36823. m.cc_phone = nil
  36824. }
  36825. // SetPhoneName sets the "phone_name" field.
  36826. func (m *WhatsappMutation) SetPhoneName(s string) {
  36827. m.phone_name = &s
  36828. }
  36829. // PhoneName returns the value of the "phone_name" field in the mutation.
  36830. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  36831. v := m.phone_name
  36832. if v == nil {
  36833. return
  36834. }
  36835. return *v, true
  36836. }
  36837. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  36838. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36840. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  36841. if !m.op.Is(OpUpdateOne) {
  36842. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  36843. }
  36844. if m.id == nil || m.oldValue == nil {
  36845. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  36846. }
  36847. oldValue, err := m.oldValue(ctx)
  36848. if err != nil {
  36849. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  36850. }
  36851. return oldValue.PhoneName, nil
  36852. }
  36853. // ResetPhoneName resets all changes to the "phone_name" field.
  36854. func (m *WhatsappMutation) ResetPhoneName() {
  36855. m.phone_name = nil
  36856. }
  36857. // SetPhoneStatus sets the "phone_status" field.
  36858. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  36859. m.phone_status = &i
  36860. m.addphone_status = nil
  36861. }
  36862. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  36863. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  36864. v := m.phone_status
  36865. if v == nil {
  36866. return
  36867. }
  36868. return *v, true
  36869. }
  36870. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  36871. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36873. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  36874. if !m.op.Is(OpUpdateOne) {
  36875. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  36876. }
  36877. if m.id == nil || m.oldValue == nil {
  36878. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  36879. }
  36880. oldValue, err := m.oldValue(ctx)
  36881. if err != nil {
  36882. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  36883. }
  36884. return oldValue.PhoneStatus, nil
  36885. }
  36886. // AddPhoneStatus adds i to the "phone_status" field.
  36887. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  36888. if m.addphone_status != nil {
  36889. *m.addphone_status += i
  36890. } else {
  36891. m.addphone_status = &i
  36892. }
  36893. }
  36894. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  36895. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  36896. v := m.addphone_status
  36897. if v == nil {
  36898. return
  36899. }
  36900. return *v, true
  36901. }
  36902. // ResetPhoneStatus resets all changes to the "phone_status" field.
  36903. func (m *WhatsappMutation) ResetPhoneStatus() {
  36904. m.phone_status = nil
  36905. m.addphone_status = nil
  36906. }
  36907. // SetOrganizationID sets the "organization_id" field.
  36908. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  36909. m.organization_id = &u
  36910. m.addorganization_id = nil
  36911. }
  36912. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36913. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  36914. v := m.organization_id
  36915. if v == nil {
  36916. return
  36917. }
  36918. return *v, true
  36919. }
  36920. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  36921. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36923. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36924. if !m.op.Is(OpUpdateOne) {
  36925. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36926. }
  36927. if m.id == nil || m.oldValue == nil {
  36928. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36929. }
  36930. oldValue, err := m.oldValue(ctx)
  36931. if err != nil {
  36932. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36933. }
  36934. return oldValue.OrganizationID, nil
  36935. }
  36936. // AddOrganizationID adds u to the "organization_id" field.
  36937. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  36938. if m.addorganization_id != nil {
  36939. *m.addorganization_id += u
  36940. } else {
  36941. m.addorganization_id = &u
  36942. }
  36943. }
  36944. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36945. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  36946. v := m.addorganization_id
  36947. if v == nil {
  36948. return
  36949. }
  36950. return *v, true
  36951. }
  36952. // ClearOrganizationID clears the value of the "organization_id" field.
  36953. func (m *WhatsappMutation) ClearOrganizationID() {
  36954. m.organization_id = nil
  36955. m.addorganization_id = nil
  36956. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  36957. }
  36958. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36959. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  36960. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  36961. return ok
  36962. }
  36963. // ResetOrganizationID resets all changes to the "organization_id" field.
  36964. func (m *WhatsappMutation) ResetOrganizationID() {
  36965. m.organization_id = nil
  36966. m.addorganization_id = nil
  36967. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  36968. }
  36969. // SetAPIBase sets the "api_base" field.
  36970. func (m *WhatsappMutation) SetAPIBase(s string) {
  36971. m.api_base = &s
  36972. }
  36973. // APIBase returns the value of the "api_base" field in the mutation.
  36974. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  36975. v := m.api_base
  36976. if v == nil {
  36977. return
  36978. }
  36979. return *v, true
  36980. }
  36981. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  36982. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  36983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36984. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36985. if !m.op.Is(OpUpdateOne) {
  36986. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36987. }
  36988. if m.id == nil || m.oldValue == nil {
  36989. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  36990. }
  36991. oldValue, err := m.oldValue(ctx)
  36992. if err != nil {
  36993. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  36994. }
  36995. return oldValue.APIBase, nil
  36996. }
  36997. // ClearAPIBase clears the value of the "api_base" field.
  36998. func (m *WhatsappMutation) ClearAPIBase() {
  36999. m.api_base = nil
  37000. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  37001. }
  37002. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  37003. func (m *WhatsappMutation) APIBaseCleared() bool {
  37004. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  37005. return ok
  37006. }
  37007. // ResetAPIBase resets all changes to the "api_base" field.
  37008. func (m *WhatsappMutation) ResetAPIBase() {
  37009. m.api_base = nil
  37010. delete(m.clearedFields, whatsapp.FieldAPIBase)
  37011. }
  37012. // SetAPIKey sets the "api_key" field.
  37013. func (m *WhatsappMutation) SetAPIKey(s string) {
  37014. m.api_key = &s
  37015. }
  37016. // APIKey returns the value of the "api_key" field in the mutation.
  37017. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  37018. v := m.api_key
  37019. if v == nil {
  37020. return
  37021. }
  37022. return *v, true
  37023. }
  37024. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  37025. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37027. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  37028. if !m.op.Is(OpUpdateOne) {
  37029. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  37030. }
  37031. if m.id == nil || m.oldValue == nil {
  37032. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  37033. }
  37034. oldValue, err := m.oldValue(ctx)
  37035. if err != nil {
  37036. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  37037. }
  37038. return oldValue.APIKey, nil
  37039. }
  37040. // ClearAPIKey clears the value of the "api_key" field.
  37041. func (m *WhatsappMutation) ClearAPIKey() {
  37042. m.api_key = nil
  37043. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  37044. }
  37045. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  37046. func (m *WhatsappMutation) APIKeyCleared() bool {
  37047. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  37048. return ok
  37049. }
  37050. // ResetAPIKey resets all changes to the "api_key" field.
  37051. func (m *WhatsappMutation) ResetAPIKey() {
  37052. m.api_key = nil
  37053. delete(m.clearedFields, whatsapp.FieldAPIKey)
  37054. }
  37055. // SetAllowList sets the "allow_list" field.
  37056. func (m *WhatsappMutation) SetAllowList(s []string) {
  37057. m.allow_list = &s
  37058. m.appendallow_list = nil
  37059. }
  37060. // AllowList returns the value of the "allow_list" field in the mutation.
  37061. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  37062. v := m.allow_list
  37063. if v == nil {
  37064. return
  37065. }
  37066. return *v, true
  37067. }
  37068. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  37069. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37071. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  37072. if !m.op.Is(OpUpdateOne) {
  37073. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  37074. }
  37075. if m.id == nil || m.oldValue == nil {
  37076. return v, errors.New("OldAllowList requires an ID field in the mutation")
  37077. }
  37078. oldValue, err := m.oldValue(ctx)
  37079. if err != nil {
  37080. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  37081. }
  37082. return oldValue.AllowList, nil
  37083. }
  37084. // AppendAllowList adds s to the "allow_list" field.
  37085. func (m *WhatsappMutation) AppendAllowList(s []string) {
  37086. m.appendallow_list = append(m.appendallow_list, s...)
  37087. }
  37088. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  37089. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  37090. if len(m.appendallow_list) == 0 {
  37091. return nil, false
  37092. }
  37093. return m.appendallow_list, true
  37094. }
  37095. // ClearAllowList clears the value of the "allow_list" field.
  37096. func (m *WhatsappMutation) ClearAllowList() {
  37097. m.allow_list = nil
  37098. m.appendallow_list = nil
  37099. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  37100. }
  37101. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  37102. func (m *WhatsappMutation) AllowListCleared() bool {
  37103. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  37104. return ok
  37105. }
  37106. // ResetAllowList resets all changes to the "allow_list" field.
  37107. func (m *WhatsappMutation) ResetAllowList() {
  37108. m.allow_list = nil
  37109. m.appendallow_list = nil
  37110. delete(m.clearedFields, whatsapp.FieldAllowList)
  37111. }
  37112. // SetGroupAllowList sets the "group_allow_list" field.
  37113. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  37114. m.group_allow_list = &s
  37115. m.appendgroup_allow_list = nil
  37116. }
  37117. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  37118. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  37119. v := m.group_allow_list
  37120. if v == nil {
  37121. return
  37122. }
  37123. return *v, true
  37124. }
  37125. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  37126. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37128. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  37129. if !m.op.Is(OpUpdateOne) {
  37130. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  37131. }
  37132. if m.id == nil || m.oldValue == nil {
  37133. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  37134. }
  37135. oldValue, err := m.oldValue(ctx)
  37136. if err != nil {
  37137. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  37138. }
  37139. return oldValue.GroupAllowList, nil
  37140. }
  37141. // AppendGroupAllowList adds s to the "group_allow_list" field.
  37142. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  37143. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  37144. }
  37145. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  37146. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  37147. if len(m.appendgroup_allow_list) == 0 {
  37148. return nil, false
  37149. }
  37150. return m.appendgroup_allow_list, true
  37151. }
  37152. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  37153. func (m *WhatsappMutation) ClearGroupAllowList() {
  37154. m.group_allow_list = nil
  37155. m.appendgroup_allow_list = nil
  37156. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  37157. }
  37158. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  37159. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  37160. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  37161. return ok
  37162. }
  37163. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  37164. func (m *WhatsappMutation) ResetGroupAllowList() {
  37165. m.group_allow_list = nil
  37166. m.appendgroup_allow_list = nil
  37167. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  37168. }
  37169. // SetBlockList sets the "block_list" field.
  37170. func (m *WhatsappMutation) SetBlockList(s []string) {
  37171. m.block_list = &s
  37172. m.appendblock_list = nil
  37173. }
  37174. // BlockList returns the value of the "block_list" field in the mutation.
  37175. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  37176. v := m.block_list
  37177. if v == nil {
  37178. return
  37179. }
  37180. return *v, true
  37181. }
  37182. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  37183. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37185. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  37186. if !m.op.Is(OpUpdateOne) {
  37187. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  37188. }
  37189. if m.id == nil || m.oldValue == nil {
  37190. return v, errors.New("OldBlockList requires an ID field in the mutation")
  37191. }
  37192. oldValue, err := m.oldValue(ctx)
  37193. if err != nil {
  37194. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  37195. }
  37196. return oldValue.BlockList, nil
  37197. }
  37198. // AppendBlockList adds s to the "block_list" field.
  37199. func (m *WhatsappMutation) AppendBlockList(s []string) {
  37200. m.appendblock_list = append(m.appendblock_list, s...)
  37201. }
  37202. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  37203. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  37204. if len(m.appendblock_list) == 0 {
  37205. return nil, false
  37206. }
  37207. return m.appendblock_list, true
  37208. }
  37209. // ClearBlockList clears the value of the "block_list" field.
  37210. func (m *WhatsappMutation) ClearBlockList() {
  37211. m.block_list = nil
  37212. m.appendblock_list = nil
  37213. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  37214. }
  37215. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  37216. func (m *WhatsappMutation) BlockListCleared() bool {
  37217. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  37218. return ok
  37219. }
  37220. // ResetBlockList resets all changes to the "block_list" field.
  37221. func (m *WhatsappMutation) ResetBlockList() {
  37222. m.block_list = nil
  37223. m.appendblock_list = nil
  37224. delete(m.clearedFields, whatsapp.FieldBlockList)
  37225. }
  37226. // SetGroupBlockList sets the "group_block_list" field.
  37227. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  37228. m.group_block_list = &s
  37229. m.appendgroup_block_list = nil
  37230. }
  37231. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  37232. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  37233. v := m.group_block_list
  37234. if v == nil {
  37235. return
  37236. }
  37237. return *v, true
  37238. }
  37239. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  37240. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37242. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  37243. if !m.op.Is(OpUpdateOne) {
  37244. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  37245. }
  37246. if m.id == nil || m.oldValue == nil {
  37247. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  37248. }
  37249. oldValue, err := m.oldValue(ctx)
  37250. if err != nil {
  37251. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  37252. }
  37253. return oldValue.GroupBlockList, nil
  37254. }
  37255. // AppendGroupBlockList adds s to the "group_block_list" field.
  37256. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  37257. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  37258. }
  37259. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  37260. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  37261. if len(m.appendgroup_block_list) == 0 {
  37262. return nil, false
  37263. }
  37264. return m.appendgroup_block_list, true
  37265. }
  37266. // ClearGroupBlockList clears the value of the "group_block_list" field.
  37267. func (m *WhatsappMutation) ClearGroupBlockList() {
  37268. m.group_block_list = nil
  37269. m.appendgroup_block_list = nil
  37270. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  37271. }
  37272. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  37273. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  37274. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  37275. return ok
  37276. }
  37277. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  37278. func (m *WhatsappMutation) ResetGroupBlockList() {
  37279. m.group_block_list = nil
  37280. m.appendgroup_block_list = nil
  37281. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  37282. }
  37283. // ClearAgent clears the "agent" edge to the Agent entity.
  37284. func (m *WhatsappMutation) ClearAgent() {
  37285. m.clearedagent = true
  37286. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  37287. }
  37288. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  37289. func (m *WhatsappMutation) AgentCleared() bool {
  37290. return m.clearedagent
  37291. }
  37292. // AgentIDs returns the "agent" edge IDs in the mutation.
  37293. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  37294. // AgentID instead. It exists only for internal usage by the builders.
  37295. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  37296. if id := m.agent; id != nil {
  37297. ids = append(ids, *id)
  37298. }
  37299. return
  37300. }
  37301. // ResetAgent resets all changes to the "agent" edge.
  37302. func (m *WhatsappMutation) ResetAgent() {
  37303. m.agent = nil
  37304. m.clearedagent = false
  37305. }
  37306. // Where appends a list predicates to the WhatsappMutation builder.
  37307. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  37308. m.predicates = append(m.predicates, ps...)
  37309. }
  37310. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  37311. // users can use type-assertion to append predicates that do not depend on any generated package.
  37312. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  37313. p := make([]predicate.Whatsapp, len(ps))
  37314. for i := range ps {
  37315. p[i] = ps[i]
  37316. }
  37317. m.Where(p...)
  37318. }
  37319. // Op returns the operation name.
  37320. func (m *WhatsappMutation) Op() Op {
  37321. return m.op
  37322. }
  37323. // SetOp allows setting the mutation operation.
  37324. func (m *WhatsappMutation) SetOp(op Op) {
  37325. m.op = op
  37326. }
  37327. // Type returns the node type of this mutation (Whatsapp).
  37328. func (m *WhatsappMutation) Type() string {
  37329. return m.typ
  37330. }
  37331. // Fields returns all fields that were changed during this mutation. Note that in
  37332. // order to get all numeric fields that were incremented/decremented, call
  37333. // AddedFields().
  37334. func (m *WhatsappMutation) Fields() []string {
  37335. fields := make([]string, 0, 21)
  37336. if m.created_at != nil {
  37337. fields = append(fields, whatsapp.FieldCreatedAt)
  37338. }
  37339. if m.updated_at != nil {
  37340. fields = append(fields, whatsapp.FieldUpdatedAt)
  37341. }
  37342. if m.status != nil {
  37343. fields = append(fields, whatsapp.FieldStatus)
  37344. }
  37345. if m.deleted_at != nil {
  37346. fields = append(fields, whatsapp.FieldDeletedAt)
  37347. }
  37348. if m.wa_id != nil {
  37349. fields = append(fields, whatsapp.FieldWaID)
  37350. }
  37351. if m.wa_name != nil {
  37352. fields = append(fields, whatsapp.FieldWaName)
  37353. }
  37354. if m.callback != nil {
  37355. fields = append(fields, whatsapp.FieldCallback)
  37356. }
  37357. if m.agent != nil {
  37358. fields = append(fields, whatsapp.FieldAgentID)
  37359. }
  37360. if m.account != nil {
  37361. fields = append(fields, whatsapp.FieldAccount)
  37362. }
  37363. if m.cc != nil {
  37364. fields = append(fields, whatsapp.FieldCc)
  37365. }
  37366. if m.phone != nil {
  37367. fields = append(fields, whatsapp.FieldPhone)
  37368. }
  37369. if m.cc_phone != nil {
  37370. fields = append(fields, whatsapp.FieldCcPhone)
  37371. }
  37372. if m.phone_name != nil {
  37373. fields = append(fields, whatsapp.FieldPhoneName)
  37374. }
  37375. if m.phone_status != nil {
  37376. fields = append(fields, whatsapp.FieldPhoneStatus)
  37377. }
  37378. if m.organization_id != nil {
  37379. fields = append(fields, whatsapp.FieldOrganizationID)
  37380. }
  37381. if m.api_base != nil {
  37382. fields = append(fields, whatsapp.FieldAPIBase)
  37383. }
  37384. if m.api_key != nil {
  37385. fields = append(fields, whatsapp.FieldAPIKey)
  37386. }
  37387. if m.allow_list != nil {
  37388. fields = append(fields, whatsapp.FieldAllowList)
  37389. }
  37390. if m.group_allow_list != nil {
  37391. fields = append(fields, whatsapp.FieldGroupAllowList)
  37392. }
  37393. if m.block_list != nil {
  37394. fields = append(fields, whatsapp.FieldBlockList)
  37395. }
  37396. if m.group_block_list != nil {
  37397. fields = append(fields, whatsapp.FieldGroupBlockList)
  37398. }
  37399. return fields
  37400. }
  37401. // Field returns the value of a field with the given name. The second boolean
  37402. // return value indicates that this field was not set, or was not defined in the
  37403. // schema.
  37404. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  37405. switch name {
  37406. case whatsapp.FieldCreatedAt:
  37407. return m.CreatedAt()
  37408. case whatsapp.FieldUpdatedAt:
  37409. return m.UpdatedAt()
  37410. case whatsapp.FieldStatus:
  37411. return m.Status()
  37412. case whatsapp.FieldDeletedAt:
  37413. return m.DeletedAt()
  37414. case whatsapp.FieldWaID:
  37415. return m.WaID()
  37416. case whatsapp.FieldWaName:
  37417. return m.WaName()
  37418. case whatsapp.FieldCallback:
  37419. return m.Callback()
  37420. case whatsapp.FieldAgentID:
  37421. return m.AgentID()
  37422. case whatsapp.FieldAccount:
  37423. return m.Account()
  37424. case whatsapp.FieldCc:
  37425. return m.Cc()
  37426. case whatsapp.FieldPhone:
  37427. return m.Phone()
  37428. case whatsapp.FieldCcPhone:
  37429. return m.CcPhone()
  37430. case whatsapp.FieldPhoneName:
  37431. return m.PhoneName()
  37432. case whatsapp.FieldPhoneStatus:
  37433. return m.PhoneStatus()
  37434. case whatsapp.FieldOrganizationID:
  37435. return m.OrganizationID()
  37436. case whatsapp.FieldAPIBase:
  37437. return m.APIBase()
  37438. case whatsapp.FieldAPIKey:
  37439. return m.APIKey()
  37440. case whatsapp.FieldAllowList:
  37441. return m.AllowList()
  37442. case whatsapp.FieldGroupAllowList:
  37443. return m.GroupAllowList()
  37444. case whatsapp.FieldBlockList:
  37445. return m.BlockList()
  37446. case whatsapp.FieldGroupBlockList:
  37447. return m.GroupBlockList()
  37448. }
  37449. return nil, false
  37450. }
  37451. // OldField returns the old value of the field from the database. An error is
  37452. // returned if the mutation operation is not UpdateOne, or the query to the
  37453. // database failed.
  37454. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37455. switch name {
  37456. case whatsapp.FieldCreatedAt:
  37457. return m.OldCreatedAt(ctx)
  37458. case whatsapp.FieldUpdatedAt:
  37459. return m.OldUpdatedAt(ctx)
  37460. case whatsapp.FieldStatus:
  37461. return m.OldStatus(ctx)
  37462. case whatsapp.FieldDeletedAt:
  37463. return m.OldDeletedAt(ctx)
  37464. case whatsapp.FieldWaID:
  37465. return m.OldWaID(ctx)
  37466. case whatsapp.FieldWaName:
  37467. return m.OldWaName(ctx)
  37468. case whatsapp.FieldCallback:
  37469. return m.OldCallback(ctx)
  37470. case whatsapp.FieldAgentID:
  37471. return m.OldAgentID(ctx)
  37472. case whatsapp.FieldAccount:
  37473. return m.OldAccount(ctx)
  37474. case whatsapp.FieldCc:
  37475. return m.OldCc(ctx)
  37476. case whatsapp.FieldPhone:
  37477. return m.OldPhone(ctx)
  37478. case whatsapp.FieldCcPhone:
  37479. return m.OldCcPhone(ctx)
  37480. case whatsapp.FieldPhoneName:
  37481. return m.OldPhoneName(ctx)
  37482. case whatsapp.FieldPhoneStatus:
  37483. return m.OldPhoneStatus(ctx)
  37484. case whatsapp.FieldOrganizationID:
  37485. return m.OldOrganizationID(ctx)
  37486. case whatsapp.FieldAPIBase:
  37487. return m.OldAPIBase(ctx)
  37488. case whatsapp.FieldAPIKey:
  37489. return m.OldAPIKey(ctx)
  37490. case whatsapp.FieldAllowList:
  37491. return m.OldAllowList(ctx)
  37492. case whatsapp.FieldGroupAllowList:
  37493. return m.OldGroupAllowList(ctx)
  37494. case whatsapp.FieldBlockList:
  37495. return m.OldBlockList(ctx)
  37496. case whatsapp.FieldGroupBlockList:
  37497. return m.OldGroupBlockList(ctx)
  37498. }
  37499. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  37500. }
  37501. // SetField sets the value of a field with the given name. It returns an error if
  37502. // the field is not defined in the schema, or if the type mismatched the field
  37503. // type.
  37504. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  37505. switch name {
  37506. case whatsapp.FieldCreatedAt:
  37507. v, ok := value.(time.Time)
  37508. if !ok {
  37509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37510. }
  37511. m.SetCreatedAt(v)
  37512. return nil
  37513. case whatsapp.FieldUpdatedAt:
  37514. v, ok := value.(time.Time)
  37515. if !ok {
  37516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37517. }
  37518. m.SetUpdatedAt(v)
  37519. return nil
  37520. case whatsapp.FieldStatus:
  37521. v, ok := value.(uint8)
  37522. if !ok {
  37523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37524. }
  37525. m.SetStatus(v)
  37526. return nil
  37527. case whatsapp.FieldDeletedAt:
  37528. v, ok := value.(time.Time)
  37529. if !ok {
  37530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37531. }
  37532. m.SetDeletedAt(v)
  37533. return nil
  37534. case whatsapp.FieldWaID:
  37535. v, ok := value.(string)
  37536. if !ok {
  37537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37538. }
  37539. m.SetWaID(v)
  37540. return nil
  37541. case whatsapp.FieldWaName:
  37542. v, ok := value.(string)
  37543. if !ok {
  37544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37545. }
  37546. m.SetWaName(v)
  37547. return nil
  37548. case whatsapp.FieldCallback:
  37549. v, ok := value.(string)
  37550. if !ok {
  37551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37552. }
  37553. m.SetCallback(v)
  37554. return nil
  37555. case whatsapp.FieldAgentID:
  37556. v, ok := value.(uint64)
  37557. if !ok {
  37558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37559. }
  37560. m.SetAgentID(v)
  37561. return nil
  37562. case whatsapp.FieldAccount:
  37563. v, ok := value.(string)
  37564. if !ok {
  37565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37566. }
  37567. m.SetAccount(v)
  37568. return nil
  37569. case whatsapp.FieldCc:
  37570. v, ok := value.(string)
  37571. if !ok {
  37572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37573. }
  37574. m.SetCc(v)
  37575. return nil
  37576. case whatsapp.FieldPhone:
  37577. v, ok := value.(string)
  37578. if !ok {
  37579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37580. }
  37581. m.SetPhone(v)
  37582. return nil
  37583. case whatsapp.FieldCcPhone:
  37584. v, ok := value.(string)
  37585. if !ok {
  37586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37587. }
  37588. m.SetCcPhone(v)
  37589. return nil
  37590. case whatsapp.FieldPhoneName:
  37591. v, ok := value.(string)
  37592. if !ok {
  37593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37594. }
  37595. m.SetPhoneName(v)
  37596. return nil
  37597. case whatsapp.FieldPhoneStatus:
  37598. v, ok := value.(int8)
  37599. if !ok {
  37600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37601. }
  37602. m.SetPhoneStatus(v)
  37603. return nil
  37604. case whatsapp.FieldOrganizationID:
  37605. v, ok := value.(uint64)
  37606. if !ok {
  37607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37608. }
  37609. m.SetOrganizationID(v)
  37610. return nil
  37611. case whatsapp.FieldAPIBase:
  37612. v, ok := value.(string)
  37613. if !ok {
  37614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37615. }
  37616. m.SetAPIBase(v)
  37617. return nil
  37618. case whatsapp.FieldAPIKey:
  37619. v, ok := value.(string)
  37620. if !ok {
  37621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37622. }
  37623. m.SetAPIKey(v)
  37624. return nil
  37625. case whatsapp.FieldAllowList:
  37626. v, ok := value.([]string)
  37627. if !ok {
  37628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37629. }
  37630. m.SetAllowList(v)
  37631. return nil
  37632. case whatsapp.FieldGroupAllowList:
  37633. v, ok := value.([]string)
  37634. if !ok {
  37635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37636. }
  37637. m.SetGroupAllowList(v)
  37638. return nil
  37639. case whatsapp.FieldBlockList:
  37640. v, ok := value.([]string)
  37641. if !ok {
  37642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37643. }
  37644. m.SetBlockList(v)
  37645. return nil
  37646. case whatsapp.FieldGroupBlockList:
  37647. v, ok := value.([]string)
  37648. if !ok {
  37649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37650. }
  37651. m.SetGroupBlockList(v)
  37652. return nil
  37653. }
  37654. return fmt.Errorf("unknown Whatsapp field %s", name)
  37655. }
  37656. // AddedFields returns all numeric fields that were incremented/decremented during
  37657. // this mutation.
  37658. func (m *WhatsappMutation) AddedFields() []string {
  37659. var fields []string
  37660. if m.addstatus != nil {
  37661. fields = append(fields, whatsapp.FieldStatus)
  37662. }
  37663. if m.addphone_status != nil {
  37664. fields = append(fields, whatsapp.FieldPhoneStatus)
  37665. }
  37666. if m.addorganization_id != nil {
  37667. fields = append(fields, whatsapp.FieldOrganizationID)
  37668. }
  37669. return fields
  37670. }
  37671. // AddedField returns the numeric value that was incremented/decremented on a field
  37672. // with the given name. The second boolean return value indicates that this field
  37673. // was not set, or was not defined in the schema.
  37674. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  37675. switch name {
  37676. case whatsapp.FieldStatus:
  37677. return m.AddedStatus()
  37678. case whatsapp.FieldPhoneStatus:
  37679. return m.AddedPhoneStatus()
  37680. case whatsapp.FieldOrganizationID:
  37681. return m.AddedOrganizationID()
  37682. }
  37683. return nil, false
  37684. }
  37685. // AddField adds the value to the field with the given name. It returns an error if
  37686. // the field is not defined in the schema, or if the type mismatched the field
  37687. // type.
  37688. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  37689. switch name {
  37690. case whatsapp.FieldStatus:
  37691. v, ok := value.(int8)
  37692. if !ok {
  37693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37694. }
  37695. m.AddStatus(v)
  37696. return nil
  37697. case whatsapp.FieldPhoneStatus:
  37698. v, ok := value.(int8)
  37699. if !ok {
  37700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37701. }
  37702. m.AddPhoneStatus(v)
  37703. return nil
  37704. case whatsapp.FieldOrganizationID:
  37705. v, ok := value.(int64)
  37706. if !ok {
  37707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37708. }
  37709. m.AddOrganizationID(v)
  37710. return nil
  37711. }
  37712. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  37713. }
  37714. // ClearedFields returns all nullable fields that were cleared during this
  37715. // mutation.
  37716. func (m *WhatsappMutation) ClearedFields() []string {
  37717. var fields []string
  37718. if m.FieldCleared(whatsapp.FieldStatus) {
  37719. fields = append(fields, whatsapp.FieldStatus)
  37720. }
  37721. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  37722. fields = append(fields, whatsapp.FieldDeletedAt)
  37723. }
  37724. if m.FieldCleared(whatsapp.FieldWaID) {
  37725. fields = append(fields, whatsapp.FieldWaID)
  37726. }
  37727. if m.FieldCleared(whatsapp.FieldWaName) {
  37728. fields = append(fields, whatsapp.FieldWaName)
  37729. }
  37730. if m.FieldCleared(whatsapp.FieldCallback) {
  37731. fields = append(fields, whatsapp.FieldCallback)
  37732. }
  37733. if m.FieldCleared(whatsapp.FieldAccount) {
  37734. fields = append(fields, whatsapp.FieldAccount)
  37735. }
  37736. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  37737. fields = append(fields, whatsapp.FieldOrganizationID)
  37738. }
  37739. if m.FieldCleared(whatsapp.FieldAPIBase) {
  37740. fields = append(fields, whatsapp.FieldAPIBase)
  37741. }
  37742. if m.FieldCleared(whatsapp.FieldAPIKey) {
  37743. fields = append(fields, whatsapp.FieldAPIKey)
  37744. }
  37745. if m.FieldCleared(whatsapp.FieldAllowList) {
  37746. fields = append(fields, whatsapp.FieldAllowList)
  37747. }
  37748. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  37749. fields = append(fields, whatsapp.FieldGroupAllowList)
  37750. }
  37751. if m.FieldCleared(whatsapp.FieldBlockList) {
  37752. fields = append(fields, whatsapp.FieldBlockList)
  37753. }
  37754. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  37755. fields = append(fields, whatsapp.FieldGroupBlockList)
  37756. }
  37757. return fields
  37758. }
  37759. // FieldCleared returns a boolean indicating if a field with the given name was
  37760. // cleared in this mutation.
  37761. func (m *WhatsappMutation) FieldCleared(name string) bool {
  37762. _, ok := m.clearedFields[name]
  37763. return ok
  37764. }
  37765. // ClearField clears the value of the field with the given name. It returns an
  37766. // error if the field is not defined in the schema.
  37767. func (m *WhatsappMutation) ClearField(name string) error {
  37768. switch name {
  37769. case whatsapp.FieldStatus:
  37770. m.ClearStatus()
  37771. return nil
  37772. case whatsapp.FieldDeletedAt:
  37773. m.ClearDeletedAt()
  37774. return nil
  37775. case whatsapp.FieldWaID:
  37776. m.ClearWaID()
  37777. return nil
  37778. case whatsapp.FieldWaName:
  37779. m.ClearWaName()
  37780. return nil
  37781. case whatsapp.FieldCallback:
  37782. m.ClearCallback()
  37783. return nil
  37784. case whatsapp.FieldAccount:
  37785. m.ClearAccount()
  37786. return nil
  37787. case whatsapp.FieldOrganizationID:
  37788. m.ClearOrganizationID()
  37789. return nil
  37790. case whatsapp.FieldAPIBase:
  37791. m.ClearAPIBase()
  37792. return nil
  37793. case whatsapp.FieldAPIKey:
  37794. m.ClearAPIKey()
  37795. return nil
  37796. case whatsapp.FieldAllowList:
  37797. m.ClearAllowList()
  37798. return nil
  37799. case whatsapp.FieldGroupAllowList:
  37800. m.ClearGroupAllowList()
  37801. return nil
  37802. case whatsapp.FieldBlockList:
  37803. m.ClearBlockList()
  37804. return nil
  37805. case whatsapp.FieldGroupBlockList:
  37806. m.ClearGroupBlockList()
  37807. return nil
  37808. }
  37809. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  37810. }
  37811. // ResetField resets all changes in the mutation for the field with the given name.
  37812. // It returns an error if the field is not defined in the schema.
  37813. func (m *WhatsappMutation) ResetField(name string) error {
  37814. switch name {
  37815. case whatsapp.FieldCreatedAt:
  37816. m.ResetCreatedAt()
  37817. return nil
  37818. case whatsapp.FieldUpdatedAt:
  37819. m.ResetUpdatedAt()
  37820. return nil
  37821. case whatsapp.FieldStatus:
  37822. m.ResetStatus()
  37823. return nil
  37824. case whatsapp.FieldDeletedAt:
  37825. m.ResetDeletedAt()
  37826. return nil
  37827. case whatsapp.FieldWaID:
  37828. m.ResetWaID()
  37829. return nil
  37830. case whatsapp.FieldWaName:
  37831. m.ResetWaName()
  37832. return nil
  37833. case whatsapp.FieldCallback:
  37834. m.ResetCallback()
  37835. return nil
  37836. case whatsapp.FieldAgentID:
  37837. m.ResetAgentID()
  37838. return nil
  37839. case whatsapp.FieldAccount:
  37840. m.ResetAccount()
  37841. return nil
  37842. case whatsapp.FieldCc:
  37843. m.ResetCc()
  37844. return nil
  37845. case whatsapp.FieldPhone:
  37846. m.ResetPhone()
  37847. return nil
  37848. case whatsapp.FieldCcPhone:
  37849. m.ResetCcPhone()
  37850. return nil
  37851. case whatsapp.FieldPhoneName:
  37852. m.ResetPhoneName()
  37853. return nil
  37854. case whatsapp.FieldPhoneStatus:
  37855. m.ResetPhoneStatus()
  37856. return nil
  37857. case whatsapp.FieldOrganizationID:
  37858. m.ResetOrganizationID()
  37859. return nil
  37860. case whatsapp.FieldAPIBase:
  37861. m.ResetAPIBase()
  37862. return nil
  37863. case whatsapp.FieldAPIKey:
  37864. m.ResetAPIKey()
  37865. return nil
  37866. case whatsapp.FieldAllowList:
  37867. m.ResetAllowList()
  37868. return nil
  37869. case whatsapp.FieldGroupAllowList:
  37870. m.ResetGroupAllowList()
  37871. return nil
  37872. case whatsapp.FieldBlockList:
  37873. m.ResetBlockList()
  37874. return nil
  37875. case whatsapp.FieldGroupBlockList:
  37876. m.ResetGroupBlockList()
  37877. return nil
  37878. }
  37879. return fmt.Errorf("unknown Whatsapp field %s", name)
  37880. }
  37881. // AddedEdges returns all edge names that were set/added in this mutation.
  37882. func (m *WhatsappMutation) AddedEdges() []string {
  37883. edges := make([]string, 0, 1)
  37884. if m.agent != nil {
  37885. edges = append(edges, whatsapp.EdgeAgent)
  37886. }
  37887. return edges
  37888. }
  37889. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37890. // name in this mutation.
  37891. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  37892. switch name {
  37893. case whatsapp.EdgeAgent:
  37894. if id := m.agent; id != nil {
  37895. return []ent.Value{*id}
  37896. }
  37897. }
  37898. return nil
  37899. }
  37900. // RemovedEdges returns all edge names that were removed in this mutation.
  37901. func (m *WhatsappMutation) RemovedEdges() []string {
  37902. edges := make([]string, 0, 1)
  37903. return edges
  37904. }
  37905. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37906. // the given name in this mutation.
  37907. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  37908. return nil
  37909. }
  37910. // ClearedEdges returns all edge names that were cleared in this mutation.
  37911. func (m *WhatsappMutation) ClearedEdges() []string {
  37912. edges := make([]string, 0, 1)
  37913. if m.clearedagent {
  37914. edges = append(edges, whatsapp.EdgeAgent)
  37915. }
  37916. return edges
  37917. }
  37918. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37919. // was cleared in this mutation.
  37920. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  37921. switch name {
  37922. case whatsapp.EdgeAgent:
  37923. return m.clearedagent
  37924. }
  37925. return false
  37926. }
  37927. // ClearEdge clears the value of the edge with the given name. It returns an error
  37928. // if that edge is not defined in the schema.
  37929. func (m *WhatsappMutation) ClearEdge(name string) error {
  37930. switch name {
  37931. case whatsapp.EdgeAgent:
  37932. m.ClearAgent()
  37933. return nil
  37934. }
  37935. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  37936. }
  37937. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37938. // It returns an error if the edge is not defined in the schema.
  37939. func (m *WhatsappMutation) ResetEdge(name string) error {
  37940. switch name {
  37941. case whatsapp.EdgeAgent:
  37942. m.ResetAgent()
  37943. return nil
  37944. }
  37945. return fmt.Errorf("unknown Whatsapp edge %s", name)
  37946. }
  37947. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  37948. type WhatsappChannelMutation struct {
  37949. config
  37950. op Op
  37951. typ string
  37952. id *uint64
  37953. created_at *time.Time
  37954. updated_at *time.Time
  37955. status *uint8
  37956. addstatus *int8
  37957. deleted_at *time.Time
  37958. ak *string
  37959. sk *string
  37960. wa_id *string
  37961. wa_name *string
  37962. waba_id *uint64
  37963. addwaba_id *int64
  37964. business_id *uint64
  37965. addbusiness_id *int64
  37966. organization_id *uint64
  37967. addorganization_id *int64
  37968. verify_account *string
  37969. clearedFields map[string]struct{}
  37970. done bool
  37971. oldValue func(context.Context) (*WhatsappChannel, error)
  37972. predicates []predicate.WhatsappChannel
  37973. }
  37974. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  37975. // whatsappchannelOption allows management of the mutation configuration using functional options.
  37976. type whatsappchannelOption func(*WhatsappChannelMutation)
  37977. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  37978. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  37979. m := &WhatsappChannelMutation{
  37980. config: c,
  37981. op: op,
  37982. typ: TypeWhatsappChannel,
  37983. clearedFields: make(map[string]struct{}),
  37984. }
  37985. for _, opt := range opts {
  37986. opt(m)
  37987. }
  37988. return m
  37989. }
  37990. // withWhatsappChannelID sets the ID field of the mutation.
  37991. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  37992. return func(m *WhatsappChannelMutation) {
  37993. var (
  37994. err error
  37995. once sync.Once
  37996. value *WhatsappChannel
  37997. )
  37998. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  37999. once.Do(func() {
  38000. if m.done {
  38001. err = errors.New("querying old values post mutation is not allowed")
  38002. } else {
  38003. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  38004. }
  38005. })
  38006. return value, err
  38007. }
  38008. m.id = &id
  38009. }
  38010. }
  38011. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  38012. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  38013. return func(m *WhatsappChannelMutation) {
  38014. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  38015. return node, nil
  38016. }
  38017. m.id = &node.ID
  38018. }
  38019. }
  38020. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38021. // executed in a transaction (ent.Tx), a transactional client is returned.
  38022. func (m WhatsappChannelMutation) Client() *Client {
  38023. client := &Client{config: m.config}
  38024. client.init()
  38025. return client
  38026. }
  38027. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38028. // it returns an error otherwise.
  38029. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  38030. if _, ok := m.driver.(*txDriver); !ok {
  38031. return nil, errors.New("ent: mutation is not running in a transaction")
  38032. }
  38033. tx := &Tx{config: m.config}
  38034. tx.init()
  38035. return tx, nil
  38036. }
  38037. // SetID sets the value of the id field. Note that this
  38038. // operation is only accepted on creation of WhatsappChannel entities.
  38039. func (m *WhatsappChannelMutation) SetID(id uint64) {
  38040. m.id = &id
  38041. }
  38042. // ID returns the ID value in the mutation. Note that the ID is only available
  38043. // if it was provided to the builder or after it was returned from the database.
  38044. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  38045. if m.id == nil {
  38046. return
  38047. }
  38048. return *m.id, true
  38049. }
  38050. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38051. // That means, if the mutation is applied within a transaction with an isolation level such
  38052. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38053. // or updated by the mutation.
  38054. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  38055. switch {
  38056. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38057. id, exists := m.ID()
  38058. if exists {
  38059. return []uint64{id}, nil
  38060. }
  38061. fallthrough
  38062. case m.op.Is(OpUpdate | OpDelete):
  38063. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  38064. default:
  38065. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38066. }
  38067. }
  38068. // SetCreatedAt sets the "created_at" field.
  38069. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  38070. m.created_at = &t
  38071. }
  38072. // CreatedAt returns the value of the "created_at" field in the mutation.
  38073. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  38074. v := m.created_at
  38075. if v == nil {
  38076. return
  38077. }
  38078. return *v, true
  38079. }
  38080. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  38081. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38083. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38084. if !m.op.Is(OpUpdateOne) {
  38085. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38086. }
  38087. if m.id == nil || m.oldValue == nil {
  38088. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38089. }
  38090. oldValue, err := m.oldValue(ctx)
  38091. if err != nil {
  38092. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38093. }
  38094. return oldValue.CreatedAt, nil
  38095. }
  38096. // ResetCreatedAt resets all changes to the "created_at" field.
  38097. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  38098. m.created_at = nil
  38099. }
  38100. // SetUpdatedAt sets the "updated_at" field.
  38101. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  38102. m.updated_at = &t
  38103. }
  38104. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38105. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  38106. v := m.updated_at
  38107. if v == nil {
  38108. return
  38109. }
  38110. return *v, true
  38111. }
  38112. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  38113. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38115. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38116. if !m.op.Is(OpUpdateOne) {
  38117. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38118. }
  38119. if m.id == nil || m.oldValue == nil {
  38120. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38121. }
  38122. oldValue, err := m.oldValue(ctx)
  38123. if err != nil {
  38124. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38125. }
  38126. return oldValue.UpdatedAt, nil
  38127. }
  38128. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38129. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  38130. m.updated_at = nil
  38131. }
  38132. // SetStatus sets the "status" field.
  38133. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  38134. m.status = &u
  38135. m.addstatus = nil
  38136. }
  38137. // Status returns the value of the "status" field in the mutation.
  38138. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  38139. v := m.status
  38140. if v == nil {
  38141. return
  38142. }
  38143. return *v, true
  38144. }
  38145. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  38146. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38148. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38149. if !m.op.Is(OpUpdateOne) {
  38150. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38151. }
  38152. if m.id == nil || m.oldValue == nil {
  38153. return v, errors.New("OldStatus requires an ID field in the mutation")
  38154. }
  38155. oldValue, err := m.oldValue(ctx)
  38156. if err != nil {
  38157. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38158. }
  38159. return oldValue.Status, nil
  38160. }
  38161. // AddStatus adds u to the "status" field.
  38162. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  38163. if m.addstatus != nil {
  38164. *m.addstatus += u
  38165. } else {
  38166. m.addstatus = &u
  38167. }
  38168. }
  38169. // AddedStatus returns the value that was added to the "status" field in this mutation.
  38170. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  38171. v := m.addstatus
  38172. if v == nil {
  38173. return
  38174. }
  38175. return *v, true
  38176. }
  38177. // ClearStatus clears the value of the "status" field.
  38178. func (m *WhatsappChannelMutation) ClearStatus() {
  38179. m.status = nil
  38180. m.addstatus = nil
  38181. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  38182. }
  38183. // StatusCleared returns if the "status" field was cleared in this mutation.
  38184. func (m *WhatsappChannelMutation) StatusCleared() bool {
  38185. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  38186. return ok
  38187. }
  38188. // ResetStatus resets all changes to the "status" field.
  38189. func (m *WhatsappChannelMutation) ResetStatus() {
  38190. m.status = nil
  38191. m.addstatus = nil
  38192. delete(m.clearedFields, whatsappchannel.FieldStatus)
  38193. }
  38194. // SetDeletedAt sets the "deleted_at" field.
  38195. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  38196. m.deleted_at = &t
  38197. }
  38198. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38199. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  38200. v := m.deleted_at
  38201. if v == nil {
  38202. return
  38203. }
  38204. return *v, true
  38205. }
  38206. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  38207. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38209. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38210. if !m.op.Is(OpUpdateOne) {
  38211. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38212. }
  38213. if m.id == nil || m.oldValue == nil {
  38214. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38215. }
  38216. oldValue, err := m.oldValue(ctx)
  38217. if err != nil {
  38218. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38219. }
  38220. return oldValue.DeletedAt, nil
  38221. }
  38222. // ClearDeletedAt clears the value of the "deleted_at" field.
  38223. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  38224. m.deleted_at = nil
  38225. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  38226. }
  38227. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38228. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  38229. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  38230. return ok
  38231. }
  38232. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38233. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  38234. m.deleted_at = nil
  38235. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  38236. }
  38237. // SetAk sets the "ak" field.
  38238. func (m *WhatsappChannelMutation) SetAk(s string) {
  38239. m.ak = &s
  38240. }
  38241. // Ak returns the value of the "ak" field in the mutation.
  38242. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  38243. v := m.ak
  38244. if v == nil {
  38245. return
  38246. }
  38247. return *v, true
  38248. }
  38249. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  38250. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38252. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  38253. if !m.op.Is(OpUpdateOne) {
  38254. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  38255. }
  38256. if m.id == nil || m.oldValue == nil {
  38257. return v, errors.New("OldAk requires an ID field in the mutation")
  38258. }
  38259. oldValue, err := m.oldValue(ctx)
  38260. if err != nil {
  38261. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  38262. }
  38263. return oldValue.Ak, nil
  38264. }
  38265. // ClearAk clears the value of the "ak" field.
  38266. func (m *WhatsappChannelMutation) ClearAk() {
  38267. m.ak = nil
  38268. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  38269. }
  38270. // AkCleared returns if the "ak" field was cleared in this mutation.
  38271. func (m *WhatsappChannelMutation) AkCleared() bool {
  38272. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  38273. return ok
  38274. }
  38275. // ResetAk resets all changes to the "ak" field.
  38276. func (m *WhatsappChannelMutation) ResetAk() {
  38277. m.ak = nil
  38278. delete(m.clearedFields, whatsappchannel.FieldAk)
  38279. }
  38280. // SetSk sets the "sk" field.
  38281. func (m *WhatsappChannelMutation) SetSk(s string) {
  38282. m.sk = &s
  38283. }
  38284. // Sk returns the value of the "sk" field in the mutation.
  38285. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  38286. v := m.sk
  38287. if v == nil {
  38288. return
  38289. }
  38290. return *v, true
  38291. }
  38292. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  38293. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38295. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  38296. if !m.op.Is(OpUpdateOne) {
  38297. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  38298. }
  38299. if m.id == nil || m.oldValue == nil {
  38300. return v, errors.New("OldSk requires an ID field in the mutation")
  38301. }
  38302. oldValue, err := m.oldValue(ctx)
  38303. if err != nil {
  38304. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  38305. }
  38306. return oldValue.Sk, nil
  38307. }
  38308. // ResetSk resets all changes to the "sk" field.
  38309. func (m *WhatsappChannelMutation) ResetSk() {
  38310. m.sk = nil
  38311. }
  38312. // SetWaID sets the "wa_id" field.
  38313. func (m *WhatsappChannelMutation) SetWaID(s string) {
  38314. m.wa_id = &s
  38315. }
  38316. // WaID returns the value of the "wa_id" field in the mutation.
  38317. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  38318. v := m.wa_id
  38319. if v == nil {
  38320. return
  38321. }
  38322. return *v, true
  38323. }
  38324. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  38325. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38327. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  38328. if !m.op.Is(OpUpdateOne) {
  38329. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  38330. }
  38331. if m.id == nil || m.oldValue == nil {
  38332. return v, errors.New("OldWaID requires an ID field in the mutation")
  38333. }
  38334. oldValue, err := m.oldValue(ctx)
  38335. if err != nil {
  38336. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  38337. }
  38338. return oldValue.WaID, nil
  38339. }
  38340. // ClearWaID clears the value of the "wa_id" field.
  38341. func (m *WhatsappChannelMutation) ClearWaID() {
  38342. m.wa_id = nil
  38343. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  38344. }
  38345. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  38346. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  38347. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  38348. return ok
  38349. }
  38350. // ResetWaID resets all changes to the "wa_id" field.
  38351. func (m *WhatsappChannelMutation) ResetWaID() {
  38352. m.wa_id = nil
  38353. delete(m.clearedFields, whatsappchannel.FieldWaID)
  38354. }
  38355. // SetWaName sets the "wa_name" field.
  38356. func (m *WhatsappChannelMutation) SetWaName(s string) {
  38357. m.wa_name = &s
  38358. }
  38359. // WaName returns the value of the "wa_name" field in the mutation.
  38360. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  38361. v := m.wa_name
  38362. if v == nil {
  38363. return
  38364. }
  38365. return *v, true
  38366. }
  38367. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  38368. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38370. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  38371. if !m.op.Is(OpUpdateOne) {
  38372. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  38373. }
  38374. if m.id == nil || m.oldValue == nil {
  38375. return v, errors.New("OldWaName requires an ID field in the mutation")
  38376. }
  38377. oldValue, err := m.oldValue(ctx)
  38378. if err != nil {
  38379. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  38380. }
  38381. return oldValue.WaName, nil
  38382. }
  38383. // ClearWaName clears the value of the "wa_name" field.
  38384. func (m *WhatsappChannelMutation) ClearWaName() {
  38385. m.wa_name = nil
  38386. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  38387. }
  38388. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  38389. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  38390. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  38391. return ok
  38392. }
  38393. // ResetWaName resets all changes to the "wa_name" field.
  38394. func (m *WhatsappChannelMutation) ResetWaName() {
  38395. m.wa_name = nil
  38396. delete(m.clearedFields, whatsappchannel.FieldWaName)
  38397. }
  38398. // SetWabaID sets the "waba_id" field.
  38399. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  38400. m.waba_id = &u
  38401. m.addwaba_id = nil
  38402. }
  38403. // WabaID returns the value of the "waba_id" field in the mutation.
  38404. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  38405. v := m.waba_id
  38406. if v == nil {
  38407. return
  38408. }
  38409. return *v, true
  38410. }
  38411. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  38412. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38414. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  38415. if !m.op.Is(OpUpdateOne) {
  38416. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  38417. }
  38418. if m.id == nil || m.oldValue == nil {
  38419. return v, errors.New("OldWabaID requires an ID field in the mutation")
  38420. }
  38421. oldValue, err := m.oldValue(ctx)
  38422. if err != nil {
  38423. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  38424. }
  38425. return oldValue.WabaID, nil
  38426. }
  38427. // AddWabaID adds u to the "waba_id" field.
  38428. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  38429. if m.addwaba_id != nil {
  38430. *m.addwaba_id += u
  38431. } else {
  38432. m.addwaba_id = &u
  38433. }
  38434. }
  38435. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  38436. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  38437. v := m.addwaba_id
  38438. if v == nil {
  38439. return
  38440. }
  38441. return *v, true
  38442. }
  38443. // ResetWabaID resets all changes to the "waba_id" field.
  38444. func (m *WhatsappChannelMutation) ResetWabaID() {
  38445. m.waba_id = nil
  38446. m.addwaba_id = nil
  38447. }
  38448. // SetBusinessID sets the "business_id" field.
  38449. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  38450. m.business_id = &u
  38451. m.addbusiness_id = nil
  38452. }
  38453. // BusinessID returns the value of the "business_id" field in the mutation.
  38454. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  38455. v := m.business_id
  38456. if v == nil {
  38457. return
  38458. }
  38459. return *v, true
  38460. }
  38461. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  38462. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38464. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  38465. if !m.op.Is(OpUpdateOne) {
  38466. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  38467. }
  38468. if m.id == nil || m.oldValue == nil {
  38469. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  38470. }
  38471. oldValue, err := m.oldValue(ctx)
  38472. if err != nil {
  38473. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  38474. }
  38475. return oldValue.BusinessID, nil
  38476. }
  38477. // AddBusinessID adds u to the "business_id" field.
  38478. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  38479. if m.addbusiness_id != nil {
  38480. *m.addbusiness_id += u
  38481. } else {
  38482. m.addbusiness_id = &u
  38483. }
  38484. }
  38485. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  38486. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  38487. v := m.addbusiness_id
  38488. if v == nil {
  38489. return
  38490. }
  38491. return *v, true
  38492. }
  38493. // ResetBusinessID resets all changes to the "business_id" field.
  38494. func (m *WhatsappChannelMutation) ResetBusinessID() {
  38495. m.business_id = nil
  38496. m.addbusiness_id = nil
  38497. }
  38498. // SetOrganizationID sets the "organization_id" field.
  38499. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  38500. m.organization_id = &u
  38501. m.addorganization_id = nil
  38502. }
  38503. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38504. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  38505. v := m.organization_id
  38506. if v == nil {
  38507. return
  38508. }
  38509. return *v, true
  38510. }
  38511. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  38512. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38514. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38515. if !m.op.Is(OpUpdateOne) {
  38516. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38517. }
  38518. if m.id == nil || m.oldValue == nil {
  38519. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38520. }
  38521. oldValue, err := m.oldValue(ctx)
  38522. if err != nil {
  38523. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38524. }
  38525. return oldValue.OrganizationID, nil
  38526. }
  38527. // AddOrganizationID adds u to the "organization_id" field.
  38528. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  38529. if m.addorganization_id != nil {
  38530. *m.addorganization_id += u
  38531. } else {
  38532. m.addorganization_id = &u
  38533. }
  38534. }
  38535. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38536. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  38537. v := m.addorganization_id
  38538. if v == nil {
  38539. return
  38540. }
  38541. return *v, true
  38542. }
  38543. // ClearOrganizationID clears the value of the "organization_id" field.
  38544. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  38545. m.organization_id = nil
  38546. m.addorganization_id = nil
  38547. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  38548. }
  38549. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38550. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  38551. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  38552. return ok
  38553. }
  38554. // ResetOrganizationID resets all changes to the "organization_id" field.
  38555. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  38556. m.organization_id = nil
  38557. m.addorganization_id = nil
  38558. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  38559. }
  38560. // SetVerifyAccount sets the "verify_account" field.
  38561. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  38562. m.verify_account = &s
  38563. }
  38564. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  38565. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  38566. v := m.verify_account
  38567. if v == nil {
  38568. return
  38569. }
  38570. return *v, true
  38571. }
  38572. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  38573. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38575. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  38576. if !m.op.Is(OpUpdateOne) {
  38577. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  38578. }
  38579. if m.id == nil || m.oldValue == nil {
  38580. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  38581. }
  38582. oldValue, err := m.oldValue(ctx)
  38583. if err != nil {
  38584. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  38585. }
  38586. return oldValue.VerifyAccount, nil
  38587. }
  38588. // ResetVerifyAccount resets all changes to the "verify_account" field.
  38589. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  38590. m.verify_account = nil
  38591. }
  38592. // Where appends a list predicates to the WhatsappChannelMutation builder.
  38593. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  38594. m.predicates = append(m.predicates, ps...)
  38595. }
  38596. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  38597. // users can use type-assertion to append predicates that do not depend on any generated package.
  38598. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  38599. p := make([]predicate.WhatsappChannel, len(ps))
  38600. for i := range ps {
  38601. p[i] = ps[i]
  38602. }
  38603. m.Where(p...)
  38604. }
  38605. // Op returns the operation name.
  38606. func (m *WhatsappChannelMutation) Op() Op {
  38607. return m.op
  38608. }
  38609. // SetOp allows setting the mutation operation.
  38610. func (m *WhatsappChannelMutation) SetOp(op Op) {
  38611. m.op = op
  38612. }
  38613. // Type returns the node type of this mutation (WhatsappChannel).
  38614. func (m *WhatsappChannelMutation) Type() string {
  38615. return m.typ
  38616. }
  38617. // Fields returns all fields that were changed during this mutation. Note that in
  38618. // order to get all numeric fields that were incremented/decremented, call
  38619. // AddedFields().
  38620. func (m *WhatsappChannelMutation) Fields() []string {
  38621. fields := make([]string, 0, 12)
  38622. if m.created_at != nil {
  38623. fields = append(fields, whatsappchannel.FieldCreatedAt)
  38624. }
  38625. if m.updated_at != nil {
  38626. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  38627. }
  38628. if m.status != nil {
  38629. fields = append(fields, whatsappchannel.FieldStatus)
  38630. }
  38631. if m.deleted_at != nil {
  38632. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38633. }
  38634. if m.ak != nil {
  38635. fields = append(fields, whatsappchannel.FieldAk)
  38636. }
  38637. if m.sk != nil {
  38638. fields = append(fields, whatsappchannel.FieldSk)
  38639. }
  38640. if m.wa_id != nil {
  38641. fields = append(fields, whatsappchannel.FieldWaID)
  38642. }
  38643. if m.wa_name != nil {
  38644. fields = append(fields, whatsappchannel.FieldWaName)
  38645. }
  38646. if m.waba_id != nil {
  38647. fields = append(fields, whatsappchannel.FieldWabaID)
  38648. }
  38649. if m.business_id != nil {
  38650. fields = append(fields, whatsappchannel.FieldBusinessID)
  38651. }
  38652. if m.organization_id != nil {
  38653. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38654. }
  38655. if m.verify_account != nil {
  38656. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  38657. }
  38658. return fields
  38659. }
  38660. // Field returns the value of a field with the given name. The second boolean
  38661. // return value indicates that this field was not set, or was not defined in the
  38662. // schema.
  38663. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  38664. switch name {
  38665. case whatsappchannel.FieldCreatedAt:
  38666. return m.CreatedAt()
  38667. case whatsappchannel.FieldUpdatedAt:
  38668. return m.UpdatedAt()
  38669. case whatsappchannel.FieldStatus:
  38670. return m.Status()
  38671. case whatsappchannel.FieldDeletedAt:
  38672. return m.DeletedAt()
  38673. case whatsappchannel.FieldAk:
  38674. return m.Ak()
  38675. case whatsappchannel.FieldSk:
  38676. return m.Sk()
  38677. case whatsappchannel.FieldWaID:
  38678. return m.WaID()
  38679. case whatsappchannel.FieldWaName:
  38680. return m.WaName()
  38681. case whatsappchannel.FieldWabaID:
  38682. return m.WabaID()
  38683. case whatsappchannel.FieldBusinessID:
  38684. return m.BusinessID()
  38685. case whatsappchannel.FieldOrganizationID:
  38686. return m.OrganizationID()
  38687. case whatsappchannel.FieldVerifyAccount:
  38688. return m.VerifyAccount()
  38689. }
  38690. return nil, false
  38691. }
  38692. // OldField returns the old value of the field from the database. An error is
  38693. // returned if the mutation operation is not UpdateOne, or the query to the
  38694. // database failed.
  38695. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38696. switch name {
  38697. case whatsappchannel.FieldCreatedAt:
  38698. return m.OldCreatedAt(ctx)
  38699. case whatsappchannel.FieldUpdatedAt:
  38700. return m.OldUpdatedAt(ctx)
  38701. case whatsappchannel.FieldStatus:
  38702. return m.OldStatus(ctx)
  38703. case whatsappchannel.FieldDeletedAt:
  38704. return m.OldDeletedAt(ctx)
  38705. case whatsappchannel.FieldAk:
  38706. return m.OldAk(ctx)
  38707. case whatsappchannel.FieldSk:
  38708. return m.OldSk(ctx)
  38709. case whatsappchannel.FieldWaID:
  38710. return m.OldWaID(ctx)
  38711. case whatsappchannel.FieldWaName:
  38712. return m.OldWaName(ctx)
  38713. case whatsappchannel.FieldWabaID:
  38714. return m.OldWabaID(ctx)
  38715. case whatsappchannel.FieldBusinessID:
  38716. return m.OldBusinessID(ctx)
  38717. case whatsappchannel.FieldOrganizationID:
  38718. return m.OldOrganizationID(ctx)
  38719. case whatsappchannel.FieldVerifyAccount:
  38720. return m.OldVerifyAccount(ctx)
  38721. }
  38722. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  38723. }
  38724. // SetField sets the value of a field with the given name. It returns an error if
  38725. // the field is not defined in the schema, or if the type mismatched the field
  38726. // type.
  38727. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  38728. switch name {
  38729. case whatsappchannel.FieldCreatedAt:
  38730. v, ok := value.(time.Time)
  38731. if !ok {
  38732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38733. }
  38734. m.SetCreatedAt(v)
  38735. return nil
  38736. case whatsappchannel.FieldUpdatedAt:
  38737. v, ok := value.(time.Time)
  38738. if !ok {
  38739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38740. }
  38741. m.SetUpdatedAt(v)
  38742. return nil
  38743. case whatsappchannel.FieldStatus:
  38744. v, ok := value.(uint8)
  38745. if !ok {
  38746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38747. }
  38748. m.SetStatus(v)
  38749. return nil
  38750. case whatsappchannel.FieldDeletedAt:
  38751. v, ok := value.(time.Time)
  38752. if !ok {
  38753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38754. }
  38755. m.SetDeletedAt(v)
  38756. return nil
  38757. case whatsappchannel.FieldAk:
  38758. v, ok := value.(string)
  38759. if !ok {
  38760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38761. }
  38762. m.SetAk(v)
  38763. return nil
  38764. case whatsappchannel.FieldSk:
  38765. v, ok := value.(string)
  38766. if !ok {
  38767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38768. }
  38769. m.SetSk(v)
  38770. return nil
  38771. case whatsappchannel.FieldWaID:
  38772. v, ok := value.(string)
  38773. if !ok {
  38774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38775. }
  38776. m.SetWaID(v)
  38777. return nil
  38778. case whatsappchannel.FieldWaName:
  38779. v, ok := value.(string)
  38780. if !ok {
  38781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38782. }
  38783. m.SetWaName(v)
  38784. return nil
  38785. case whatsappchannel.FieldWabaID:
  38786. v, ok := value.(uint64)
  38787. if !ok {
  38788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38789. }
  38790. m.SetWabaID(v)
  38791. return nil
  38792. case whatsappchannel.FieldBusinessID:
  38793. v, ok := value.(uint64)
  38794. if !ok {
  38795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38796. }
  38797. m.SetBusinessID(v)
  38798. return nil
  38799. case whatsappchannel.FieldOrganizationID:
  38800. v, ok := value.(uint64)
  38801. if !ok {
  38802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38803. }
  38804. m.SetOrganizationID(v)
  38805. return nil
  38806. case whatsappchannel.FieldVerifyAccount:
  38807. v, ok := value.(string)
  38808. if !ok {
  38809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38810. }
  38811. m.SetVerifyAccount(v)
  38812. return nil
  38813. }
  38814. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38815. }
  38816. // AddedFields returns all numeric fields that were incremented/decremented during
  38817. // this mutation.
  38818. func (m *WhatsappChannelMutation) AddedFields() []string {
  38819. var fields []string
  38820. if m.addstatus != nil {
  38821. fields = append(fields, whatsappchannel.FieldStatus)
  38822. }
  38823. if m.addwaba_id != nil {
  38824. fields = append(fields, whatsappchannel.FieldWabaID)
  38825. }
  38826. if m.addbusiness_id != nil {
  38827. fields = append(fields, whatsappchannel.FieldBusinessID)
  38828. }
  38829. if m.addorganization_id != nil {
  38830. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38831. }
  38832. return fields
  38833. }
  38834. // AddedField returns the numeric value that was incremented/decremented on a field
  38835. // with the given name. The second boolean return value indicates that this field
  38836. // was not set, or was not defined in the schema.
  38837. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  38838. switch name {
  38839. case whatsappchannel.FieldStatus:
  38840. return m.AddedStatus()
  38841. case whatsappchannel.FieldWabaID:
  38842. return m.AddedWabaID()
  38843. case whatsappchannel.FieldBusinessID:
  38844. return m.AddedBusinessID()
  38845. case whatsappchannel.FieldOrganizationID:
  38846. return m.AddedOrganizationID()
  38847. }
  38848. return nil, false
  38849. }
  38850. // AddField adds the value to the field with the given name. It returns an error if
  38851. // the field is not defined in the schema, or if the type mismatched the field
  38852. // type.
  38853. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  38854. switch name {
  38855. case whatsappchannel.FieldStatus:
  38856. v, ok := value.(int8)
  38857. if !ok {
  38858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38859. }
  38860. m.AddStatus(v)
  38861. return nil
  38862. case whatsappchannel.FieldWabaID:
  38863. v, ok := value.(int64)
  38864. if !ok {
  38865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38866. }
  38867. m.AddWabaID(v)
  38868. return nil
  38869. case whatsappchannel.FieldBusinessID:
  38870. v, ok := value.(int64)
  38871. if !ok {
  38872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38873. }
  38874. m.AddBusinessID(v)
  38875. return nil
  38876. case whatsappchannel.FieldOrganizationID:
  38877. v, ok := value.(int64)
  38878. if !ok {
  38879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38880. }
  38881. m.AddOrganizationID(v)
  38882. return nil
  38883. }
  38884. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  38885. }
  38886. // ClearedFields returns all nullable fields that were cleared during this
  38887. // mutation.
  38888. func (m *WhatsappChannelMutation) ClearedFields() []string {
  38889. var fields []string
  38890. if m.FieldCleared(whatsappchannel.FieldStatus) {
  38891. fields = append(fields, whatsappchannel.FieldStatus)
  38892. }
  38893. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  38894. fields = append(fields, whatsappchannel.FieldDeletedAt)
  38895. }
  38896. if m.FieldCleared(whatsappchannel.FieldAk) {
  38897. fields = append(fields, whatsappchannel.FieldAk)
  38898. }
  38899. if m.FieldCleared(whatsappchannel.FieldWaID) {
  38900. fields = append(fields, whatsappchannel.FieldWaID)
  38901. }
  38902. if m.FieldCleared(whatsappchannel.FieldWaName) {
  38903. fields = append(fields, whatsappchannel.FieldWaName)
  38904. }
  38905. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  38906. fields = append(fields, whatsappchannel.FieldOrganizationID)
  38907. }
  38908. return fields
  38909. }
  38910. // FieldCleared returns a boolean indicating if a field with the given name was
  38911. // cleared in this mutation.
  38912. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  38913. _, ok := m.clearedFields[name]
  38914. return ok
  38915. }
  38916. // ClearField clears the value of the field with the given name. It returns an
  38917. // error if the field is not defined in the schema.
  38918. func (m *WhatsappChannelMutation) ClearField(name string) error {
  38919. switch name {
  38920. case whatsappchannel.FieldStatus:
  38921. m.ClearStatus()
  38922. return nil
  38923. case whatsappchannel.FieldDeletedAt:
  38924. m.ClearDeletedAt()
  38925. return nil
  38926. case whatsappchannel.FieldAk:
  38927. m.ClearAk()
  38928. return nil
  38929. case whatsappchannel.FieldWaID:
  38930. m.ClearWaID()
  38931. return nil
  38932. case whatsappchannel.FieldWaName:
  38933. m.ClearWaName()
  38934. return nil
  38935. case whatsappchannel.FieldOrganizationID:
  38936. m.ClearOrganizationID()
  38937. return nil
  38938. }
  38939. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  38940. }
  38941. // ResetField resets all changes in the mutation for the field with the given name.
  38942. // It returns an error if the field is not defined in the schema.
  38943. func (m *WhatsappChannelMutation) ResetField(name string) error {
  38944. switch name {
  38945. case whatsappchannel.FieldCreatedAt:
  38946. m.ResetCreatedAt()
  38947. return nil
  38948. case whatsappchannel.FieldUpdatedAt:
  38949. m.ResetUpdatedAt()
  38950. return nil
  38951. case whatsappchannel.FieldStatus:
  38952. m.ResetStatus()
  38953. return nil
  38954. case whatsappchannel.FieldDeletedAt:
  38955. m.ResetDeletedAt()
  38956. return nil
  38957. case whatsappchannel.FieldAk:
  38958. m.ResetAk()
  38959. return nil
  38960. case whatsappchannel.FieldSk:
  38961. m.ResetSk()
  38962. return nil
  38963. case whatsappchannel.FieldWaID:
  38964. m.ResetWaID()
  38965. return nil
  38966. case whatsappchannel.FieldWaName:
  38967. m.ResetWaName()
  38968. return nil
  38969. case whatsappchannel.FieldWabaID:
  38970. m.ResetWabaID()
  38971. return nil
  38972. case whatsappchannel.FieldBusinessID:
  38973. m.ResetBusinessID()
  38974. return nil
  38975. case whatsappchannel.FieldOrganizationID:
  38976. m.ResetOrganizationID()
  38977. return nil
  38978. case whatsappchannel.FieldVerifyAccount:
  38979. m.ResetVerifyAccount()
  38980. return nil
  38981. }
  38982. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  38983. }
  38984. // AddedEdges returns all edge names that were set/added in this mutation.
  38985. func (m *WhatsappChannelMutation) AddedEdges() []string {
  38986. edges := make([]string, 0, 0)
  38987. return edges
  38988. }
  38989. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38990. // name in this mutation.
  38991. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  38992. return nil
  38993. }
  38994. // RemovedEdges returns all edge names that were removed in this mutation.
  38995. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  38996. edges := make([]string, 0, 0)
  38997. return edges
  38998. }
  38999. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39000. // the given name in this mutation.
  39001. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  39002. return nil
  39003. }
  39004. // ClearedEdges returns all edge names that were cleared in this mutation.
  39005. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  39006. edges := make([]string, 0, 0)
  39007. return edges
  39008. }
  39009. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39010. // was cleared in this mutation.
  39011. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  39012. return false
  39013. }
  39014. // ClearEdge clears the value of the edge with the given name. It returns an error
  39015. // if that edge is not defined in the schema.
  39016. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  39017. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  39018. }
  39019. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39020. // It returns an error if the edge is not defined in the schema.
  39021. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  39022. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  39023. }
  39024. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  39025. type WorkExperienceMutation struct {
  39026. config
  39027. op Op
  39028. typ string
  39029. id *uint64
  39030. created_at *time.Time
  39031. updated_at *time.Time
  39032. deleted_at *time.Time
  39033. start_date *time.Time
  39034. end_date *time.Time
  39035. company *string
  39036. experience *string
  39037. organization_id *uint64
  39038. addorganization_id *int64
  39039. clearedFields map[string]struct{}
  39040. employee *uint64
  39041. clearedemployee bool
  39042. done bool
  39043. oldValue func(context.Context) (*WorkExperience, error)
  39044. predicates []predicate.WorkExperience
  39045. }
  39046. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  39047. // workexperienceOption allows management of the mutation configuration using functional options.
  39048. type workexperienceOption func(*WorkExperienceMutation)
  39049. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  39050. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  39051. m := &WorkExperienceMutation{
  39052. config: c,
  39053. op: op,
  39054. typ: TypeWorkExperience,
  39055. clearedFields: make(map[string]struct{}),
  39056. }
  39057. for _, opt := range opts {
  39058. opt(m)
  39059. }
  39060. return m
  39061. }
  39062. // withWorkExperienceID sets the ID field of the mutation.
  39063. func withWorkExperienceID(id uint64) workexperienceOption {
  39064. return func(m *WorkExperienceMutation) {
  39065. var (
  39066. err error
  39067. once sync.Once
  39068. value *WorkExperience
  39069. )
  39070. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  39071. once.Do(func() {
  39072. if m.done {
  39073. err = errors.New("querying old values post mutation is not allowed")
  39074. } else {
  39075. value, err = m.Client().WorkExperience.Get(ctx, id)
  39076. }
  39077. })
  39078. return value, err
  39079. }
  39080. m.id = &id
  39081. }
  39082. }
  39083. // withWorkExperience sets the old WorkExperience of the mutation.
  39084. func withWorkExperience(node *WorkExperience) workexperienceOption {
  39085. return func(m *WorkExperienceMutation) {
  39086. m.oldValue = func(context.Context) (*WorkExperience, error) {
  39087. return node, nil
  39088. }
  39089. m.id = &node.ID
  39090. }
  39091. }
  39092. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39093. // executed in a transaction (ent.Tx), a transactional client is returned.
  39094. func (m WorkExperienceMutation) Client() *Client {
  39095. client := &Client{config: m.config}
  39096. client.init()
  39097. return client
  39098. }
  39099. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39100. // it returns an error otherwise.
  39101. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  39102. if _, ok := m.driver.(*txDriver); !ok {
  39103. return nil, errors.New("ent: mutation is not running in a transaction")
  39104. }
  39105. tx := &Tx{config: m.config}
  39106. tx.init()
  39107. return tx, nil
  39108. }
  39109. // SetID sets the value of the id field. Note that this
  39110. // operation is only accepted on creation of WorkExperience entities.
  39111. func (m *WorkExperienceMutation) SetID(id uint64) {
  39112. m.id = &id
  39113. }
  39114. // ID returns the ID value in the mutation. Note that the ID is only available
  39115. // if it was provided to the builder or after it was returned from the database.
  39116. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  39117. if m.id == nil {
  39118. return
  39119. }
  39120. return *m.id, true
  39121. }
  39122. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39123. // That means, if the mutation is applied within a transaction with an isolation level such
  39124. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39125. // or updated by the mutation.
  39126. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  39127. switch {
  39128. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39129. id, exists := m.ID()
  39130. if exists {
  39131. return []uint64{id}, nil
  39132. }
  39133. fallthrough
  39134. case m.op.Is(OpUpdate | OpDelete):
  39135. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  39136. default:
  39137. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39138. }
  39139. }
  39140. // SetCreatedAt sets the "created_at" field.
  39141. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  39142. m.created_at = &t
  39143. }
  39144. // CreatedAt returns the value of the "created_at" field in the mutation.
  39145. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  39146. v := m.created_at
  39147. if v == nil {
  39148. return
  39149. }
  39150. return *v, true
  39151. }
  39152. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  39153. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39155. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39156. if !m.op.Is(OpUpdateOne) {
  39157. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39158. }
  39159. if m.id == nil || m.oldValue == nil {
  39160. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39161. }
  39162. oldValue, err := m.oldValue(ctx)
  39163. if err != nil {
  39164. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39165. }
  39166. return oldValue.CreatedAt, nil
  39167. }
  39168. // ResetCreatedAt resets all changes to the "created_at" field.
  39169. func (m *WorkExperienceMutation) ResetCreatedAt() {
  39170. m.created_at = nil
  39171. }
  39172. // SetUpdatedAt sets the "updated_at" field.
  39173. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  39174. m.updated_at = &t
  39175. }
  39176. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39177. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  39178. v := m.updated_at
  39179. if v == nil {
  39180. return
  39181. }
  39182. return *v, true
  39183. }
  39184. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  39185. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39187. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39188. if !m.op.Is(OpUpdateOne) {
  39189. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39190. }
  39191. if m.id == nil || m.oldValue == nil {
  39192. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39193. }
  39194. oldValue, err := m.oldValue(ctx)
  39195. if err != nil {
  39196. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39197. }
  39198. return oldValue.UpdatedAt, nil
  39199. }
  39200. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39201. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  39202. m.updated_at = nil
  39203. }
  39204. // SetDeletedAt sets the "deleted_at" field.
  39205. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  39206. m.deleted_at = &t
  39207. }
  39208. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39209. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  39210. v := m.deleted_at
  39211. if v == nil {
  39212. return
  39213. }
  39214. return *v, true
  39215. }
  39216. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  39217. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39219. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39220. if !m.op.Is(OpUpdateOne) {
  39221. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39222. }
  39223. if m.id == nil || m.oldValue == nil {
  39224. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39225. }
  39226. oldValue, err := m.oldValue(ctx)
  39227. if err != nil {
  39228. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39229. }
  39230. return oldValue.DeletedAt, nil
  39231. }
  39232. // ClearDeletedAt clears the value of the "deleted_at" field.
  39233. func (m *WorkExperienceMutation) ClearDeletedAt() {
  39234. m.deleted_at = nil
  39235. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  39236. }
  39237. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39238. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  39239. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  39240. return ok
  39241. }
  39242. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39243. func (m *WorkExperienceMutation) ResetDeletedAt() {
  39244. m.deleted_at = nil
  39245. delete(m.clearedFields, workexperience.FieldDeletedAt)
  39246. }
  39247. // SetEmployeeID sets the "employee_id" field.
  39248. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  39249. m.employee = &u
  39250. }
  39251. // EmployeeID returns the value of the "employee_id" field in the mutation.
  39252. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  39253. v := m.employee
  39254. if v == nil {
  39255. return
  39256. }
  39257. return *v, true
  39258. }
  39259. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  39260. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39262. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  39263. if !m.op.Is(OpUpdateOne) {
  39264. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  39265. }
  39266. if m.id == nil || m.oldValue == nil {
  39267. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  39268. }
  39269. oldValue, err := m.oldValue(ctx)
  39270. if err != nil {
  39271. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  39272. }
  39273. return oldValue.EmployeeID, nil
  39274. }
  39275. // ResetEmployeeID resets all changes to the "employee_id" field.
  39276. func (m *WorkExperienceMutation) ResetEmployeeID() {
  39277. m.employee = nil
  39278. }
  39279. // SetStartDate sets the "start_date" field.
  39280. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  39281. m.start_date = &t
  39282. }
  39283. // StartDate returns the value of the "start_date" field in the mutation.
  39284. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  39285. v := m.start_date
  39286. if v == nil {
  39287. return
  39288. }
  39289. return *v, true
  39290. }
  39291. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  39292. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39294. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  39295. if !m.op.Is(OpUpdateOne) {
  39296. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  39297. }
  39298. if m.id == nil || m.oldValue == nil {
  39299. return v, errors.New("OldStartDate requires an ID field in the mutation")
  39300. }
  39301. oldValue, err := m.oldValue(ctx)
  39302. if err != nil {
  39303. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  39304. }
  39305. return oldValue.StartDate, nil
  39306. }
  39307. // ResetStartDate resets all changes to the "start_date" field.
  39308. func (m *WorkExperienceMutation) ResetStartDate() {
  39309. m.start_date = nil
  39310. }
  39311. // SetEndDate sets the "end_date" field.
  39312. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  39313. m.end_date = &t
  39314. }
  39315. // EndDate returns the value of the "end_date" field in the mutation.
  39316. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  39317. v := m.end_date
  39318. if v == nil {
  39319. return
  39320. }
  39321. return *v, true
  39322. }
  39323. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  39324. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39326. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  39327. if !m.op.Is(OpUpdateOne) {
  39328. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  39329. }
  39330. if m.id == nil || m.oldValue == nil {
  39331. return v, errors.New("OldEndDate requires an ID field in the mutation")
  39332. }
  39333. oldValue, err := m.oldValue(ctx)
  39334. if err != nil {
  39335. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  39336. }
  39337. return oldValue.EndDate, nil
  39338. }
  39339. // ResetEndDate resets all changes to the "end_date" field.
  39340. func (m *WorkExperienceMutation) ResetEndDate() {
  39341. m.end_date = nil
  39342. }
  39343. // SetCompany sets the "company" field.
  39344. func (m *WorkExperienceMutation) SetCompany(s string) {
  39345. m.company = &s
  39346. }
  39347. // Company returns the value of the "company" field in the mutation.
  39348. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  39349. v := m.company
  39350. if v == nil {
  39351. return
  39352. }
  39353. return *v, true
  39354. }
  39355. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  39356. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39358. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  39359. if !m.op.Is(OpUpdateOne) {
  39360. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39361. }
  39362. if m.id == nil || m.oldValue == nil {
  39363. return v, errors.New("OldCompany requires an ID field in the mutation")
  39364. }
  39365. oldValue, err := m.oldValue(ctx)
  39366. if err != nil {
  39367. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39368. }
  39369. return oldValue.Company, nil
  39370. }
  39371. // ResetCompany resets all changes to the "company" field.
  39372. func (m *WorkExperienceMutation) ResetCompany() {
  39373. m.company = nil
  39374. }
  39375. // SetExperience sets the "experience" field.
  39376. func (m *WorkExperienceMutation) SetExperience(s string) {
  39377. m.experience = &s
  39378. }
  39379. // Experience returns the value of the "experience" field in the mutation.
  39380. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  39381. v := m.experience
  39382. if v == nil {
  39383. return
  39384. }
  39385. return *v, true
  39386. }
  39387. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  39388. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39390. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  39391. if !m.op.Is(OpUpdateOne) {
  39392. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  39393. }
  39394. if m.id == nil || m.oldValue == nil {
  39395. return v, errors.New("OldExperience requires an ID field in the mutation")
  39396. }
  39397. oldValue, err := m.oldValue(ctx)
  39398. if err != nil {
  39399. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  39400. }
  39401. return oldValue.Experience, nil
  39402. }
  39403. // ResetExperience resets all changes to the "experience" field.
  39404. func (m *WorkExperienceMutation) ResetExperience() {
  39405. m.experience = nil
  39406. }
  39407. // SetOrganizationID sets the "organization_id" field.
  39408. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  39409. m.organization_id = &u
  39410. m.addorganization_id = nil
  39411. }
  39412. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39413. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  39414. v := m.organization_id
  39415. if v == nil {
  39416. return
  39417. }
  39418. return *v, true
  39419. }
  39420. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  39421. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39423. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39424. if !m.op.Is(OpUpdateOne) {
  39425. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39426. }
  39427. if m.id == nil || m.oldValue == nil {
  39428. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39429. }
  39430. oldValue, err := m.oldValue(ctx)
  39431. if err != nil {
  39432. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39433. }
  39434. return oldValue.OrganizationID, nil
  39435. }
  39436. // AddOrganizationID adds u to the "organization_id" field.
  39437. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  39438. if m.addorganization_id != nil {
  39439. *m.addorganization_id += u
  39440. } else {
  39441. m.addorganization_id = &u
  39442. }
  39443. }
  39444. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39445. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  39446. v := m.addorganization_id
  39447. if v == nil {
  39448. return
  39449. }
  39450. return *v, true
  39451. }
  39452. // ResetOrganizationID resets all changes to the "organization_id" field.
  39453. func (m *WorkExperienceMutation) ResetOrganizationID() {
  39454. m.organization_id = nil
  39455. m.addorganization_id = nil
  39456. }
  39457. // ClearEmployee clears the "employee" edge to the Employee entity.
  39458. func (m *WorkExperienceMutation) ClearEmployee() {
  39459. m.clearedemployee = true
  39460. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  39461. }
  39462. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  39463. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  39464. return m.clearedemployee
  39465. }
  39466. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  39467. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  39468. // EmployeeID instead. It exists only for internal usage by the builders.
  39469. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  39470. if id := m.employee; id != nil {
  39471. ids = append(ids, *id)
  39472. }
  39473. return
  39474. }
  39475. // ResetEmployee resets all changes to the "employee" edge.
  39476. func (m *WorkExperienceMutation) ResetEmployee() {
  39477. m.employee = nil
  39478. m.clearedemployee = false
  39479. }
  39480. // Where appends a list predicates to the WorkExperienceMutation builder.
  39481. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  39482. m.predicates = append(m.predicates, ps...)
  39483. }
  39484. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  39485. // users can use type-assertion to append predicates that do not depend on any generated package.
  39486. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  39487. p := make([]predicate.WorkExperience, len(ps))
  39488. for i := range ps {
  39489. p[i] = ps[i]
  39490. }
  39491. m.Where(p...)
  39492. }
  39493. // Op returns the operation name.
  39494. func (m *WorkExperienceMutation) Op() Op {
  39495. return m.op
  39496. }
  39497. // SetOp allows setting the mutation operation.
  39498. func (m *WorkExperienceMutation) SetOp(op Op) {
  39499. m.op = op
  39500. }
  39501. // Type returns the node type of this mutation (WorkExperience).
  39502. func (m *WorkExperienceMutation) Type() string {
  39503. return m.typ
  39504. }
  39505. // Fields returns all fields that were changed during this mutation. Note that in
  39506. // order to get all numeric fields that were incremented/decremented, call
  39507. // AddedFields().
  39508. func (m *WorkExperienceMutation) Fields() []string {
  39509. fields := make([]string, 0, 9)
  39510. if m.created_at != nil {
  39511. fields = append(fields, workexperience.FieldCreatedAt)
  39512. }
  39513. if m.updated_at != nil {
  39514. fields = append(fields, workexperience.FieldUpdatedAt)
  39515. }
  39516. if m.deleted_at != nil {
  39517. fields = append(fields, workexperience.FieldDeletedAt)
  39518. }
  39519. if m.employee != nil {
  39520. fields = append(fields, workexperience.FieldEmployeeID)
  39521. }
  39522. if m.start_date != nil {
  39523. fields = append(fields, workexperience.FieldStartDate)
  39524. }
  39525. if m.end_date != nil {
  39526. fields = append(fields, workexperience.FieldEndDate)
  39527. }
  39528. if m.company != nil {
  39529. fields = append(fields, workexperience.FieldCompany)
  39530. }
  39531. if m.experience != nil {
  39532. fields = append(fields, workexperience.FieldExperience)
  39533. }
  39534. if m.organization_id != nil {
  39535. fields = append(fields, workexperience.FieldOrganizationID)
  39536. }
  39537. return fields
  39538. }
  39539. // Field returns the value of a field with the given name. The second boolean
  39540. // return value indicates that this field was not set, or was not defined in the
  39541. // schema.
  39542. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  39543. switch name {
  39544. case workexperience.FieldCreatedAt:
  39545. return m.CreatedAt()
  39546. case workexperience.FieldUpdatedAt:
  39547. return m.UpdatedAt()
  39548. case workexperience.FieldDeletedAt:
  39549. return m.DeletedAt()
  39550. case workexperience.FieldEmployeeID:
  39551. return m.EmployeeID()
  39552. case workexperience.FieldStartDate:
  39553. return m.StartDate()
  39554. case workexperience.FieldEndDate:
  39555. return m.EndDate()
  39556. case workexperience.FieldCompany:
  39557. return m.Company()
  39558. case workexperience.FieldExperience:
  39559. return m.Experience()
  39560. case workexperience.FieldOrganizationID:
  39561. return m.OrganizationID()
  39562. }
  39563. return nil, false
  39564. }
  39565. // OldField returns the old value of the field from the database. An error is
  39566. // returned if the mutation operation is not UpdateOne, or the query to the
  39567. // database failed.
  39568. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39569. switch name {
  39570. case workexperience.FieldCreatedAt:
  39571. return m.OldCreatedAt(ctx)
  39572. case workexperience.FieldUpdatedAt:
  39573. return m.OldUpdatedAt(ctx)
  39574. case workexperience.FieldDeletedAt:
  39575. return m.OldDeletedAt(ctx)
  39576. case workexperience.FieldEmployeeID:
  39577. return m.OldEmployeeID(ctx)
  39578. case workexperience.FieldStartDate:
  39579. return m.OldStartDate(ctx)
  39580. case workexperience.FieldEndDate:
  39581. return m.OldEndDate(ctx)
  39582. case workexperience.FieldCompany:
  39583. return m.OldCompany(ctx)
  39584. case workexperience.FieldExperience:
  39585. return m.OldExperience(ctx)
  39586. case workexperience.FieldOrganizationID:
  39587. return m.OldOrganizationID(ctx)
  39588. }
  39589. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  39590. }
  39591. // SetField sets the value of a field with the given name. It returns an error if
  39592. // the field is not defined in the schema, or if the type mismatched the field
  39593. // type.
  39594. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  39595. switch name {
  39596. case workexperience.FieldCreatedAt:
  39597. v, ok := value.(time.Time)
  39598. if !ok {
  39599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39600. }
  39601. m.SetCreatedAt(v)
  39602. return nil
  39603. case workexperience.FieldUpdatedAt:
  39604. v, ok := value.(time.Time)
  39605. if !ok {
  39606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39607. }
  39608. m.SetUpdatedAt(v)
  39609. return nil
  39610. case workexperience.FieldDeletedAt:
  39611. v, ok := value.(time.Time)
  39612. if !ok {
  39613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39614. }
  39615. m.SetDeletedAt(v)
  39616. return nil
  39617. case workexperience.FieldEmployeeID:
  39618. v, ok := value.(uint64)
  39619. if !ok {
  39620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39621. }
  39622. m.SetEmployeeID(v)
  39623. return nil
  39624. case workexperience.FieldStartDate:
  39625. v, ok := value.(time.Time)
  39626. if !ok {
  39627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39628. }
  39629. m.SetStartDate(v)
  39630. return nil
  39631. case workexperience.FieldEndDate:
  39632. v, ok := value.(time.Time)
  39633. if !ok {
  39634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39635. }
  39636. m.SetEndDate(v)
  39637. return nil
  39638. case workexperience.FieldCompany:
  39639. v, ok := value.(string)
  39640. if !ok {
  39641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39642. }
  39643. m.SetCompany(v)
  39644. return nil
  39645. case workexperience.FieldExperience:
  39646. v, ok := value.(string)
  39647. if !ok {
  39648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39649. }
  39650. m.SetExperience(v)
  39651. return nil
  39652. case workexperience.FieldOrganizationID:
  39653. v, ok := value.(uint64)
  39654. if !ok {
  39655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39656. }
  39657. m.SetOrganizationID(v)
  39658. return nil
  39659. }
  39660. return fmt.Errorf("unknown WorkExperience field %s", name)
  39661. }
  39662. // AddedFields returns all numeric fields that were incremented/decremented during
  39663. // this mutation.
  39664. func (m *WorkExperienceMutation) AddedFields() []string {
  39665. var fields []string
  39666. if m.addorganization_id != nil {
  39667. fields = append(fields, workexperience.FieldOrganizationID)
  39668. }
  39669. return fields
  39670. }
  39671. // AddedField returns the numeric value that was incremented/decremented on a field
  39672. // with the given name. The second boolean return value indicates that this field
  39673. // was not set, or was not defined in the schema.
  39674. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  39675. switch name {
  39676. case workexperience.FieldOrganizationID:
  39677. return m.AddedOrganizationID()
  39678. }
  39679. return nil, false
  39680. }
  39681. // AddField adds the value to the field with the given name. It returns an error if
  39682. // the field is not defined in the schema, or if the type mismatched the field
  39683. // type.
  39684. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  39685. switch name {
  39686. case workexperience.FieldOrganizationID:
  39687. v, ok := value.(int64)
  39688. if !ok {
  39689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39690. }
  39691. m.AddOrganizationID(v)
  39692. return nil
  39693. }
  39694. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  39695. }
  39696. // ClearedFields returns all nullable fields that were cleared during this
  39697. // mutation.
  39698. func (m *WorkExperienceMutation) ClearedFields() []string {
  39699. var fields []string
  39700. if m.FieldCleared(workexperience.FieldDeletedAt) {
  39701. fields = append(fields, workexperience.FieldDeletedAt)
  39702. }
  39703. return fields
  39704. }
  39705. // FieldCleared returns a boolean indicating if a field with the given name was
  39706. // cleared in this mutation.
  39707. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  39708. _, ok := m.clearedFields[name]
  39709. return ok
  39710. }
  39711. // ClearField clears the value of the field with the given name. It returns an
  39712. // error if the field is not defined in the schema.
  39713. func (m *WorkExperienceMutation) ClearField(name string) error {
  39714. switch name {
  39715. case workexperience.FieldDeletedAt:
  39716. m.ClearDeletedAt()
  39717. return nil
  39718. }
  39719. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  39720. }
  39721. // ResetField resets all changes in the mutation for the field with the given name.
  39722. // It returns an error if the field is not defined in the schema.
  39723. func (m *WorkExperienceMutation) ResetField(name string) error {
  39724. switch name {
  39725. case workexperience.FieldCreatedAt:
  39726. m.ResetCreatedAt()
  39727. return nil
  39728. case workexperience.FieldUpdatedAt:
  39729. m.ResetUpdatedAt()
  39730. return nil
  39731. case workexperience.FieldDeletedAt:
  39732. m.ResetDeletedAt()
  39733. return nil
  39734. case workexperience.FieldEmployeeID:
  39735. m.ResetEmployeeID()
  39736. return nil
  39737. case workexperience.FieldStartDate:
  39738. m.ResetStartDate()
  39739. return nil
  39740. case workexperience.FieldEndDate:
  39741. m.ResetEndDate()
  39742. return nil
  39743. case workexperience.FieldCompany:
  39744. m.ResetCompany()
  39745. return nil
  39746. case workexperience.FieldExperience:
  39747. m.ResetExperience()
  39748. return nil
  39749. case workexperience.FieldOrganizationID:
  39750. m.ResetOrganizationID()
  39751. return nil
  39752. }
  39753. return fmt.Errorf("unknown WorkExperience field %s", name)
  39754. }
  39755. // AddedEdges returns all edge names that were set/added in this mutation.
  39756. func (m *WorkExperienceMutation) AddedEdges() []string {
  39757. edges := make([]string, 0, 1)
  39758. if m.employee != nil {
  39759. edges = append(edges, workexperience.EdgeEmployee)
  39760. }
  39761. return edges
  39762. }
  39763. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39764. // name in this mutation.
  39765. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  39766. switch name {
  39767. case workexperience.EdgeEmployee:
  39768. if id := m.employee; id != nil {
  39769. return []ent.Value{*id}
  39770. }
  39771. }
  39772. return nil
  39773. }
  39774. // RemovedEdges returns all edge names that were removed in this mutation.
  39775. func (m *WorkExperienceMutation) RemovedEdges() []string {
  39776. edges := make([]string, 0, 1)
  39777. return edges
  39778. }
  39779. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39780. // the given name in this mutation.
  39781. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  39782. return nil
  39783. }
  39784. // ClearedEdges returns all edge names that were cleared in this mutation.
  39785. func (m *WorkExperienceMutation) ClearedEdges() []string {
  39786. edges := make([]string, 0, 1)
  39787. if m.clearedemployee {
  39788. edges = append(edges, workexperience.EdgeEmployee)
  39789. }
  39790. return edges
  39791. }
  39792. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39793. // was cleared in this mutation.
  39794. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  39795. switch name {
  39796. case workexperience.EdgeEmployee:
  39797. return m.clearedemployee
  39798. }
  39799. return false
  39800. }
  39801. // ClearEdge clears the value of the edge with the given name. It returns an error
  39802. // if that edge is not defined in the schema.
  39803. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  39804. switch name {
  39805. case workexperience.EdgeEmployee:
  39806. m.ClearEmployee()
  39807. return nil
  39808. }
  39809. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  39810. }
  39811. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39812. // It returns an error if the edge is not defined in the schema.
  39813. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  39814. switch name {
  39815. case workexperience.EdgeEmployee:
  39816. m.ResetEmployee()
  39817. return nil
  39818. }
  39819. return fmt.Errorf("unknown WorkExperience edge %s", name)
  39820. }
  39821. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  39822. type WpChatroomMutation struct {
  39823. config
  39824. op Op
  39825. typ string
  39826. id *uint64
  39827. created_at *time.Time
  39828. updated_at *time.Time
  39829. status *uint8
  39830. addstatus *int8
  39831. wx_wxid *string
  39832. chatroom_id *string
  39833. nickname *string
  39834. owner *string
  39835. avatar *string
  39836. member_list *[]string
  39837. appendmember_list []string
  39838. clearedFields map[string]struct{}
  39839. done bool
  39840. oldValue func(context.Context) (*WpChatroom, error)
  39841. predicates []predicate.WpChatroom
  39842. }
  39843. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  39844. // wpchatroomOption allows management of the mutation configuration using functional options.
  39845. type wpchatroomOption func(*WpChatroomMutation)
  39846. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  39847. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  39848. m := &WpChatroomMutation{
  39849. config: c,
  39850. op: op,
  39851. typ: TypeWpChatroom,
  39852. clearedFields: make(map[string]struct{}),
  39853. }
  39854. for _, opt := range opts {
  39855. opt(m)
  39856. }
  39857. return m
  39858. }
  39859. // withWpChatroomID sets the ID field of the mutation.
  39860. func withWpChatroomID(id uint64) wpchatroomOption {
  39861. return func(m *WpChatroomMutation) {
  39862. var (
  39863. err error
  39864. once sync.Once
  39865. value *WpChatroom
  39866. )
  39867. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  39868. once.Do(func() {
  39869. if m.done {
  39870. err = errors.New("querying old values post mutation is not allowed")
  39871. } else {
  39872. value, err = m.Client().WpChatroom.Get(ctx, id)
  39873. }
  39874. })
  39875. return value, err
  39876. }
  39877. m.id = &id
  39878. }
  39879. }
  39880. // withWpChatroom sets the old WpChatroom of the mutation.
  39881. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  39882. return func(m *WpChatroomMutation) {
  39883. m.oldValue = func(context.Context) (*WpChatroom, error) {
  39884. return node, nil
  39885. }
  39886. m.id = &node.ID
  39887. }
  39888. }
  39889. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39890. // executed in a transaction (ent.Tx), a transactional client is returned.
  39891. func (m WpChatroomMutation) Client() *Client {
  39892. client := &Client{config: m.config}
  39893. client.init()
  39894. return client
  39895. }
  39896. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39897. // it returns an error otherwise.
  39898. func (m WpChatroomMutation) Tx() (*Tx, error) {
  39899. if _, ok := m.driver.(*txDriver); !ok {
  39900. return nil, errors.New("ent: mutation is not running in a transaction")
  39901. }
  39902. tx := &Tx{config: m.config}
  39903. tx.init()
  39904. return tx, nil
  39905. }
  39906. // SetID sets the value of the id field. Note that this
  39907. // operation is only accepted on creation of WpChatroom entities.
  39908. func (m *WpChatroomMutation) SetID(id uint64) {
  39909. m.id = &id
  39910. }
  39911. // ID returns the ID value in the mutation. Note that the ID is only available
  39912. // if it was provided to the builder or after it was returned from the database.
  39913. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  39914. if m.id == nil {
  39915. return
  39916. }
  39917. return *m.id, true
  39918. }
  39919. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39920. // That means, if the mutation is applied within a transaction with an isolation level such
  39921. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39922. // or updated by the mutation.
  39923. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  39924. switch {
  39925. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39926. id, exists := m.ID()
  39927. if exists {
  39928. return []uint64{id}, nil
  39929. }
  39930. fallthrough
  39931. case m.op.Is(OpUpdate | OpDelete):
  39932. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  39933. default:
  39934. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39935. }
  39936. }
  39937. // SetCreatedAt sets the "created_at" field.
  39938. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  39939. m.created_at = &t
  39940. }
  39941. // CreatedAt returns the value of the "created_at" field in the mutation.
  39942. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  39943. v := m.created_at
  39944. if v == nil {
  39945. return
  39946. }
  39947. return *v, true
  39948. }
  39949. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  39950. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39952. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39953. if !m.op.Is(OpUpdateOne) {
  39954. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39955. }
  39956. if m.id == nil || m.oldValue == nil {
  39957. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39958. }
  39959. oldValue, err := m.oldValue(ctx)
  39960. if err != nil {
  39961. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39962. }
  39963. return oldValue.CreatedAt, nil
  39964. }
  39965. // ResetCreatedAt resets all changes to the "created_at" field.
  39966. func (m *WpChatroomMutation) ResetCreatedAt() {
  39967. m.created_at = nil
  39968. }
  39969. // SetUpdatedAt sets the "updated_at" field.
  39970. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  39971. m.updated_at = &t
  39972. }
  39973. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39974. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  39975. v := m.updated_at
  39976. if v == nil {
  39977. return
  39978. }
  39979. return *v, true
  39980. }
  39981. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  39982. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  39983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39984. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39985. if !m.op.Is(OpUpdateOne) {
  39986. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39987. }
  39988. if m.id == nil || m.oldValue == nil {
  39989. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39990. }
  39991. oldValue, err := m.oldValue(ctx)
  39992. if err != nil {
  39993. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39994. }
  39995. return oldValue.UpdatedAt, nil
  39996. }
  39997. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39998. func (m *WpChatroomMutation) ResetUpdatedAt() {
  39999. m.updated_at = nil
  40000. }
  40001. // SetStatus sets the "status" field.
  40002. func (m *WpChatroomMutation) SetStatus(u uint8) {
  40003. m.status = &u
  40004. m.addstatus = nil
  40005. }
  40006. // Status returns the value of the "status" field in the mutation.
  40007. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  40008. v := m.status
  40009. if v == nil {
  40010. return
  40011. }
  40012. return *v, true
  40013. }
  40014. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  40015. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40017. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40018. if !m.op.Is(OpUpdateOne) {
  40019. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40020. }
  40021. if m.id == nil || m.oldValue == nil {
  40022. return v, errors.New("OldStatus requires an ID field in the mutation")
  40023. }
  40024. oldValue, err := m.oldValue(ctx)
  40025. if err != nil {
  40026. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40027. }
  40028. return oldValue.Status, nil
  40029. }
  40030. // AddStatus adds u to the "status" field.
  40031. func (m *WpChatroomMutation) AddStatus(u int8) {
  40032. if m.addstatus != nil {
  40033. *m.addstatus += u
  40034. } else {
  40035. m.addstatus = &u
  40036. }
  40037. }
  40038. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40039. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  40040. v := m.addstatus
  40041. if v == nil {
  40042. return
  40043. }
  40044. return *v, true
  40045. }
  40046. // ClearStatus clears the value of the "status" field.
  40047. func (m *WpChatroomMutation) ClearStatus() {
  40048. m.status = nil
  40049. m.addstatus = nil
  40050. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  40051. }
  40052. // StatusCleared returns if the "status" field was cleared in this mutation.
  40053. func (m *WpChatroomMutation) StatusCleared() bool {
  40054. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  40055. return ok
  40056. }
  40057. // ResetStatus resets all changes to the "status" field.
  40058. func (m *WpChatroomMutation) ResetStatus() {
  40059. m.status = nil
  40060. m.addstatus = nil
  40061. delete(m.clearedFields, wpchatroom.FieldStatus)
  40062. }
  40063. // SetWxWxid sets the "wx_wxid" field.
  40064. func (m *WpChatroomMutation) SetWxWxid(s string) {
  40065. m.wx_wxid = &s
  40066. }
  40067. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40068. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  40069. v := m.wx_wxid
  40070. if v == nil {
  40071. return
  40072. }
  40073. return *v, true
  40074. }
  40075. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  40076. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40078. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40079. if !m.op.Is(OpUpdateOne) {
  40080. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40081. }
  40082. if m.id == nil || m.oldValue == nil {
  40083. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40084. }
  40085. oldValue, err := m.oldValue(ctx)
  40086. if err != nil {
  40087. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40088. }
  40089. return oldValue.WxWxid, nil
  40090. }
  40091. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40092. func (m *WpChatroomMutation) ResetWxWxid() {
  40093. m.wx_wxid = nil
  40094. }
  40095. // SetChatroomID sets the "chatroom_id" field.
  40096. func (m *WpChatroomMutation) SetChatroomID(s string) {
  40097. m.chatroom_id = &s
  40098. }
  40099. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  40100. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  40101. v := m.chatroom_id
  40102. if v == nil {
  40103. return
  40104. }
  40105. return *v, true
  40106. }
  40107. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  40108. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40110. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  40111. if !m.op.Is(OpUpdateOne) {
  40112. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  40113. }
  40114. if m.id == nil || m.oldValue == nil {
  40115. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  40116. }
  40117. oldValue, err := m.oldValue(ctx)
  40118. if err != nil {
  40119. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  40120. }
  40121. return oldValue.ChatroomID, nil
  40122. }
  40123. // ResetChatroomID resets all changes to the "chatroom_id" field.
  40124. func (m *WpChatroomMutation) ResetChatroomID() {
  40125. m.chatroom_id = nil
  40126. }
  40127. // SetNickname sets the "nickname" field.
  40128. func (m *WpChatroomMutation) SetNickname(s string) {
  40129. m.nickname = &s
  40130. }
  40131. // Nickname returns the value of the "nickname" field in the mutation.
  40132. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  40133. v := m.nickname
  40134. if v == nil {
  40135. return
  40136. }
  40137. return *v, true
  40138. }
  40139. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  40140. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40142. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  40143. if !m.op.Is(OpUpdateOne) {
  40144. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40145. }
  40146. if m.id == nil || m.oldValue == nil {
  40147. return v, errors.New("OldNickname requires an ID field in the mutation")
  40148. }
  40149. oldValue, err := m.oldValue(ctx)
  40150. if err != nil {
  40151. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40152. }
  40153. return oldValue.Nickname, nil
  40154. }
  40155. // ResetNickname resets all changes to the "nickname" field.
  40156. func (m *WpChatroomMutation) ResetNickname() {
  40157. m.nickname = nil
  40158. }
  40159. // SetOwner sets the "owner" field.
  40160. func (m *WpChatroomMutation) SetOwner(s string) {
  40161. m.owner = &s
  40162. }
  40163. // Owner returns the value of the "owner" field in the mutation.
  40164. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  40165. v := m.owner
  40166. if v == nil {
  40167. return
  40168. }
  40169. return *v, true
  40170. }
  40171. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  40172. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40174. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  40175. if !m.op.Is(OpUpdateOne) {
  40176. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  40177. }
  40178. if m.id == nil || m.oldValue == nil {
  40179. return v, errors.New("OldOwner requires an ID field in the mutation")
  40180. }
  40181. oldValue, err := m.oldValue(ctx)
  40182. if err != nil {
  40183. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  40184. }
  40185. return oldValue.Owner, nil
  40186. }
  40187. // ResetOwner resets all changes to the "owner" field.
  40188. func (m *WpChatroomMutation) ResetOwner() {
  40189. m.owner = nil
  40190. }
  40191. // SetAvatar sets the "avatar" field.
  40192. func (m *WpChatroomMutation) SetAvatar(s string) {
  40193. m.avatar = &s
  40194. }
  40195. // Avatar returns the value of the "avatar" field in the mutation.
  40196. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  40197. v := m.avatar
  40198. if v == nil {
  40199. return
  40200. }
  40201. return *v, true
  40202. }
  40203. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  40204. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40206. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40207. if !m.op.Is(OpUpdateOne) {
  40208. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40209. }
  40210. if m.id == nil || m.oldValue == nil {
  40211. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40212. }
  40213. oldValue, err := m.oldValue(ctx)
  40214. if err != nil {
  40215. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40216. }
  40217. return oldValue.Avatar, nil
  40218. }
  40219. // ResetAvatar resets all changes to the "avatar" field.
  40220. func (m *WpChatroomMutation) ResetAvatar() {
  40221. m.avatar = nil
  40222. }
  40223. // SetMemberList sets the "member_list" field.
  40224. func (m *WpChatroomMutation) SetMemberList(s []string) {
  40225. m.member_list = &s
  40226. m.appendmember_list = nil
  40227. }
  40228. // MemberList returns the value of the "member_list" field in the mutation.
  40229. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  40230. v := m.member_list
  40231. if v == nil {
  40232. return
  40233. }
  40234. return *v, true
  40235. }
  40236. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  40237. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40239. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  40240. if !m.op.Is(OpUpdateOne) {
  40241. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  40242. }
  40243. if m.id == nil || m.oldValue == nil {
  40244. return v, errors.New("OldMemberList requires an ID field in the mutation")
  40245. }
  40246. oldValue, err := m.oldValue(ctx)
  40247. if err != nil {
  40248. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  40249. }
  40250. return oldValue.MemberList, nil
  40251. }
  40252. // AppendMemberList adds s to the "member_list" field.
  40253. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  40254. m.appendmember_list = append(m.appendmember_list, s...)
  40255. }
  40256. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  40257. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  40258. if len(m.appendmember_list) == 0 {
  40259. return nil, false
  40260. }
  40261. return m.appendmember_list, true
  40262. }
  40263. // ResetMemberList resets all changes to the "member_list" field.
  40264. func (m *WpChatroomMutation) ResetMemberList() {
  40265. m.member_list = nil
  40266. m.appendmember_list = nil
  40267. }
  40268. // Where appends a list predicates to the WpChatroomMutation builder.
  40269. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  40270. m.predicates = append(m.predicates, ps...)
  40271. }
  40272. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  40273. // users can use type-assertion to append predicates that do not depend on any generated package.
  40274. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  40275. p := make([]predicate.WpChatroom, len(ps))
  40276. for i := range ps {
  40277. p[i] = ps[i]
  40278. }
  40279. m.Where(p...)
  40280. }
  40281. // Op returns the operation name.
  40282. func (m *WpChatroomMutation) Op() Op {
  40283. return m.op
  40284. }
  40285. // SetOp allows setting the mutation operation.
  40286. func (m *WpChatroomMutation) SetOp(op Op) {
  40287. m.op = op
  40288. }
  40289. // Type returns the node type of this mutation (WpChatroom).
  40290. func (m *WpChatroomMutation) Type() string {
  40291. return m.typ
  40292. }
  40293. // Fields returns all fields that were changed during this mutation. Note that in
  40294. // order to get all numeric fields that were incremented/decremented, call
  40295. // AddedFields().
  40296. func (m *WpChatroomMutation) Fields() []string {
  40297. fields := make([]string, 0, 9)
  40298. if m.created_at != nil {
  40299. fields = append(fields, wpchatroom.FieldCreatedAt)
  40300. }
  40301. if m.updated_at != nil {
  40302. fields = append(fields, wpchatroom.FieldUpdatedAt)
  40303. }
  40304. if m.status != nil {
  40305. fields = append(fields, wpchatroom.FieldStatus)
  40306. }
  40307. if m.wx_wxid != nil {
  40308. fields = append(fields, wpchatroom.FieldWxWxid)
  40309. }
  40310. if m.chatroom_id != nil {
  40311. fields = append(fields, wpchatroom.FieldChatroomID)
  40312. }
  40313. if m.nickname != nil {
  40314. fields = append(fields, wpchatroom.FieldNickname)
  40315. }
  40316. if m.owner != nil {
  40317. fields = append(fields, wpchatroom.FieldOwner)
  40318. }
  40319. if m.avatar != nil {
  40320. fields = append(fields, wpchatroom.FieldAvatar)
  40321. }
  40322. if m.member_list != nil {
  40323. fields = append(fields, wpchatroom.FieldMemberList)
  40324. }
  40325. return fields
  40326. }
  40327. // Field returns the value of a field with the given name. The second boolean
  40328. // return value indicates that this field was not set, or was not defined in the
  40329. // schema.
  40330. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  40331. switch name {
  40332. case wpchatroom.FieldCreatedAt:
  40333. return m.CreatedAt()
  40334. case wpchatroom.FieldUpdatedAt:
  40335. return m.UpdatedAt()
  40336. case wpchatroom.FieldStatus:
  40337. return m.Status()
  40338. case wpchatroom.FieldWxWxid:
  40339. return m.WxWxid()
  40340. case wpchatroom.FieldChatroomID:
  40341. return m.ChatroomID()
  40342. case wpchatroom.FieldNickname:
  40343. return m.Nickname()
  40344. case wpchatroom.FieldOwner:
  40345. return m.Owner()
  40346. case wpchatroom.FieldAvatar:
  40347. return m.Avatar()
  40348. case wpchatroom.FieldMemberList:
  40349. return m.MemberList()
  40350. }
  40351. return nil, false
  40352. }
  40353. // OldField returns the old value of the field from the database. An error is
  40354. // returned if the mutation operation is not UpdateOne, or the query to the
  40355. // database failed.
  40356. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40357. switch name {
  40358. case wpchatroom.FieldCreatedAt:
  40359. return m.OldCreatedAt(ctx)
  40360. case wpchatroom.FieldUpdatedAt:
  40361. return m.OldUpdatedAt(ctx)
  40362. case wpchatroom.FieldStatus:
  40363. return m.OldStatus(ctx)
  40364. case wpchatroom.FieldWxWxid:
  40365. return m.OldWxWxid(ctx)
  40366. case wpchatroom.FieldChatroomID:
  40367. return m.OldChatroomID(ctx)
  40368. case wpchatroom.FieldNickname:
  40369. return m.OldNickname(ctx)
  40370. case wpchatroom.FieldOwner:
  40371. return m.OldOwner(ctx)
  40372. case wpchatroom.FieldAvatar:
  40373. return m.OldAvatar(ctx)
  40374. case wpchatroom.FieldMemberList:
  40375. return m.OldMemberList(ctx)
  40376. }
  40377. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  40378. }
  40379. // SetField sets the value of a field with the given name. It returns an error if
  40380. // the field is not defined in the schema, or if the type mismatched the field
  40381. // type.
  40382. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  40383. switch name {
  40384. case wpchatroom.FieldCreatedAt:
  40385. v, ok := value.(time.Time)
  40386. if !ok {
  40387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40388. }
  40389. m.SetCreatedAt(v)
  40390. return nil
  40391. case wpchatroom.FieldUpdatedAt:
  40392. v, ok := value.(time.Time)
  40393. if !ok {
  40394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40395. }
  40396. m.SetUpdatedAt(v)
  40397. return nil
  40398. case wpchatroom.FieldStatus:
  40399. v, ok := value.(uint8)
  40400. if !ok {
  40401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40402. }
  40403. m.SetStatus(v)
  40404. return nil
  40405. case wpchatroom.FieldWxWxid:
  40406. v, ok := value.(string)
  40407. if !ok {
  40408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40409. }
  40410. m.SetWxWxid(v)
  40411. return nil
  40412. case wpchatroom.FieldChatroomID:
  40413. v, ok := value.(string)
  40414. if !ok {
  40415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40416. }
  40417. m.SetChatroomID(v)
  40418. return nil
  40419. case wpchatroom.FieldNickname:
  40420. v, ok := value.(string)
  40421. if !ok {
  40422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40423. }
  40424. m.SetNickname(v)
  40425. return nil
  40426. case wpchatroom.FieldOwner:
  40427. v, ok := value.(string)
  40428. if !ok {
  40429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40430. }
  40431. m.SetOwner(v)
  40432. return nil
  40433. case wpchatroom.FieldAvatar:
  40434. v, ok := value.(string)
  40435. if !ok {
  40436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40437. }
  40438. m.SetAvatar(v)
  40439. return nil
  40440. case wpchatroom.FieldMemberList:
  40441. v, ok := value.([]string)
  40442. if !ok {
  40443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40444. }
  40445. m.SetMemberList(v)
  40446. return nil
  40447. }
  40448. return fmt.Errorf("unknown WpChatroom field %s", name)
  40449. }
  40450. // AddedFields returns all numeric fields that were incremented/decremented during
  40451. // this mutation.
  40452. func (m *WpChatroomMutation) AddedFields() []string {
  40453. var fields []string
  40454. if m.addstatus != nil {
  40455. fields = append(fields, wpchatroom.FieldStatus)
  40456. }
  40457. return fields
  40458. }
  40459. // AddedField returns the numeric value that was incremented/decremented on a field
  40460. // with the given name. The second boolean return value indicates that this field
  40461. // was not set, or was not defined in the schema.
  40462. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  40463. switch name {
  40464. case wpchatroom.FieldStatus:
  40465. return m.AddedStatus()
  40466. }
  40467. return nil, false
  40468. }
  40469. // AddField adds the value to the field with the given name. It returns an error if
  40470. // the field is not defined in the schema, or if the type mismatched the field
  40471. // type.
  40472. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  40473. switch name {
  40474. case wpchatroom.FieldStatus:
  40475. v, ok := value.(int8)
  40476. if !ok {
  40477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40478. }
  40479. m.AddStatus(v)
  40480. return nil
  40481. }
  40482. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  40483. }
  40484. // ClearedFields returns all nullable fields that were cleared during this
  40485. // mutation.
  40486. func (m *WpChatroomMutation) ClearedFields() []string {
  40487. var fields []string
  40488. if m.FieldCleared(wpchatroom.FieldStatus) {
  40489. fields = append(fields, wpchatroom.FieldStatus)
  40490. }
  40491. return fields
  40492. }
  40493. // FieldCleared returns a boolean indicating if a field with the given name was
  40494. // cleared in this mutation.
  40495. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  40496. _, ok := m.clearedFields[name]
  40497. return ok
  40498. }
  40499. // ClearField clears the value of the field with the given name. It returns an
  40500. // error if the field is not defined in the schema.
  40501. func (m *WpChatroomMutation) ClearField(name string) error {
  40502. switch name {
  40503. case wpchatroom.FieldStatus:
  40504. m.ClearStatus()
  40505. return nil
  40506. }
  40507. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  40508. }
  40509. // ResetField resets all changes in the mutation for the field with the given name.
  40510. // It returns an error if the field is not defined in the schema.
  40511. func (m *WpChatroomMutation) ResetField(name string) error {
  40512. switch name {
  40513. case wpchatroom.FieldCreatedAt:
  40514. m.ResetCreatedAt()
  40515. return nil
  40516. case wpchatroom.FieldUpdatedAt:
  40517. m.ResetUpdatedAt()
  40518. return nil
  40519. case wpchatroom.FieldStatus:
  40520. m.ResetStatus()
  40521. return nil
  40522. case wpchatroom.FieldWxWxid:
  40523. m.ResetWxWxid()
  40524. return nil
  40525. case wpchatroom.FieldChatroomID:
  40526. m.ResetChatroomID()
  40527. return nil
  40528. case wpchatroom.FieldNickname:
  40529. m.ResetNickname()
  40530. return nil
  40531. case wpchatroom.FieldOwner:
  40532. m.ResetOwner()
  40533. return nil
  40534. case wpchatroom.FieldAvatar:
  40535. m.ResetAvatar()
  40536. return nil
  40537. case wpchatroom.FieldMemberList:
  40538. m.ResetMemberList()
  40539. return nil
  40540. }
  40541. return fmt.Errorf("unknown WpChatroom field %s", name)
  40542. }
  40543. // AddedEdges returns all edge names that were set/added in this mutation.
  40544. func (m *WpChatroomMutation) AddedEdges() []string {
  40545. edges := make([]string, 0, 0)
  40546. return edges
  40547. }
  40548. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40549. // name in this mutation.
  40550. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  40551. return nil
  40552. }
  40553. // RemovedEdges returns all edge names that were removed in this mutation.
  40554. func (m *WpChatroomMutation) RemovedEdges() []string {
  40555. edges := make([]string, 0, 0)
  40556. return edges
  40557. }
  40558. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40559. // the given name in this mutation.
  40560. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  40561. return nil
  40562. }
  40563. // ClearedEdges returns all edge names that were cleared in this mutation.
  40564. func (m *WpChatroomMutation) ClearedEdges() []string {
  40565. edges := make([]string, 0, 0)
  40566. return edges
  40567. }
  40568. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40569. // was cleared in this mutation.
  40570. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  40571. return false
  40572. }
  40573. // ClearEdge clears the value of the edge with the given name. It returns an error
  40574. // if that edge is not defined in the schema.
  40575. func (m *WpChatroomMutation) ClearEdge(name string) error {
  40576. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  40577. }
  40578. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40579. // It returns an error if the edge is not defined in the schema.
  40580. func (m *WpChatroomMutation) ResetEdge(name string) error {
  40581. return fmt.Errorf("unknown WpChatroom edge %s", name)
  40582. }
  40583. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  40584. type WpChatroomMemberMutation struct {
  40585. config
  40586. op Op
  40587. typ string
  40588. id *uint64
  40589. created_at *time.Time
  40590. updated_at *time.Time
  40591. status *uint8
  40592. addstatus *int8
  40593. wx_wxid *string
  40594. wxid *string
  40595. nickname *string
  40596. avatar *string
  40597. clearedFields map[string]struct{}
  40598. done bool
  40599. oldValue func(context.Context) (*WpChatroomMember, error)
  40600. predicates []predicate.WpChatroomMember
  40601. }
  40602. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  40603. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  40604. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  40605. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  40606. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  40607. m := &WpChatroomMemberMutation{
  40608. config: c,
  40609. op: op,
  40610. typ: TypeWpChatroomMember,
  40611. clearedFields: make(map[string]struct{}),
  40612. }
  40613. for _, opt := range opts {
  40614. opt(m)
  40615. }
  40616. return m
  40617. }
  40618. // withWpChatroomMemberID sets the ID field of the mutation.
  40619. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  40620. return func(m *WpChatroomMemberMutation) {
  40621. var (
  40622. err error
  40623. once sync.Once
  40624. value *WpChatroomMember
  40625. )
  40626. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  40627. once.Do(func() {
  40628. if m.done {
  40629. err = errors.New("querying old values post mutation is not allowed")
  40630. } else {
  40631. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  40632. }
  40633. })
  40634. return value, err
  40635. }
  40636. m.id = &id
  40637. }
  40638. }
  40639. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  40640. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  40641. return func(m *WpChatroomMemberMutation) {
  40642. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  40643. return node, nil
  40644. }
  40645. m.id = &node.ID
  40646. }
  40647. }
  40648. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40649. // executed in a transaction (ent.Tx), a transactional client is returned.
  40650. func (m WpChatroomMemberMutation) Client() *Client {
  40651. client := &Client{config: m.config}
  40652. client.init()
  40653. return client
  40654. }
  40655. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40656. // it returns an error otherwise.
  40657. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  40658. if _, ok := m.driver.(*txDriver); !ok {
  40659. return nil, errors.New("ent: mutation is not running in a transaction")
  40660. }
  40661. tx := &Tx{config: m.config}
  40662. tx.init()
  40663. return tx, nil
  40664. }
  40665. // SetID sets the value of the id field. Note that this
  40666. // operation is only accepted on creation of WpChatroomMember entities.
  40667. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  40668. m.id = &id
  40669. }
  40670. // ID returns the ID value in the mutation. Note that the ID is only available
  40671. // if it was provided to the builder or after it was returned from the database.
  40672. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  40673. if m.id == nil {
  40674. return
  40675. }
  40676. return *m.id, true
  40677. }
  40678. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40679. // That means, if the mutation is applied within a transaction with an isolation level such
  40680. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40681. // or updated by the mutation.
  40682. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  40683. switch {
  40684. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40685. id, exists := m.ID()
  40686. if exists {
  40687. return []uint64{id}, nil
  40688. }
  40689. fallthrough
  40690. case m.op.Is(OpUpdate | OpDelete):
  40691. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  40692. default:
  40693. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40694. }
  40695. }
  40696. // SetCreatedAt sets the "created_at" field.
  40697. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  40698. m.created_at = &t
  40699. }
  40700. // CreatedAt returns the value of the "created_at" field in the mutation.
  40701. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  40702. v := m.created_at
  40703. if v == nil {
  40704. return
  40705. }
  40706. return *v, true
  40707. }
  40708. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  40709. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40711. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40712. if !m.op.Is(OpUpdateOne) {
  40713. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40714. }
  40715. if m.id == nil || m.oldValue == nil {
  40716. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40717. }
  40718. oldValue, err := m.oldValue(ctx)
  40719. if err != nil {
  40720. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40721. }
  40722. return oldValue.CreatedAt, nil
  40723. }
  40724. // ResetCreatedAt resets all changes to the "created_at" field.
  40725. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  40726. m.created_at = nil
  40727. }
  40728. // SetUpdatedAt sets the "updated_at" field.
  40729. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  40730. m.updated_at = &t
  40731. }
  40732. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40733. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  40734. v := m.updated_at
  40735. if v == nil {
  40736. return
  40737. }
  40738. return *v, true
  40739. }
  40740. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  40741. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40743. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40744. if !m.op.Is(OpUpdateOne) {
  40745. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40746. }
  40747. if m.id == nil || m.oldValue == nil {
  40748. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40749. }
  40750. oldValue, err := m.oldValue(ctx)
  40751. if err != nil {
  40752. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40753. }
  40754. return oldValue.UpdatedAt, nil
  40755. }
  40756. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40757. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  40758. m.updated_at = nil
  40759. }
  40760. // SetStatus sets the "status" field.
  40761. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  40762. m.status = &u
  40763. m.addstatus = nil
  40764. }
  40765. // Status returns the value of the "status" field in the mutation.
  40766. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  40767. v := m.status
  40768. if v == nil {
  40769. return
  40770. }
  40771. return *v, true
  40772. }
  40773. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  40774. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40776. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40777. if !m.op.Is(OpUpdateOne) {
  40778. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40779. }
  40780. if m.id == nil || m.oldValue == nil {
  40781. return v, errors.New("OldStatus requires an ID field in the mutation")
  40782. }
  40783. oldValue, err := m.oldValue(ctx)
  40784. if err != nil {
  40785. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40786. }
  40787. return oldValue.Status, nil
  40788. }
  40789. // AddStatus adds u to the "status" field.
  40790. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  40791. if m.addstatus != nil {
  40792. *m.addstatus += u
  40793. } else {
  40794. m.addstatus = &u
  40795. }
  40796. }
  40797. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40798. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  40799. v := m.addstatus
  40800. if v == nil {
  40801. return
  40802. }
  40803. return *v, true
  40804. }
  40805. // ClearStatus clears the value of the "status" field.
  40806. func (m *WpChatroomMemberMutation) ClearStatus() {
  40807. m.status = nil
  40808. m.addstatus = nil
  40809. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  40810. }
  40811. // StatusCleared returns if the "status" field was cleared in this mutation.
  40812. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  40813. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  40814. return ok
  40815. }
  40816. // ResetStatus resets all changes to the "status" field.
  40817. func (m *WpChatroomMemberMutation) ResetStatus() {
  40818. m.status = nil
  40819. m.addstatus = nil
  40820. delete(m.clearedFields, wpchatroommember.FieldStatus)
  40821. }
  40822. // SetWxWxid sets the "wx_wxid" field.
  40823. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  40824. m.wx_wxid = &s
  40825. }
  40826. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40827. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  40828. v := m.wx_wxid
  40829. if v == nil {
  40830. return
  40831. }
  40832. return *v, true
  40833. }
  40834. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  40835. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40837. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40838. if !m.op.Is(OpUpdateOne) {
  40839. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40840. }
  40841. if m.id == nil || m.oldValue == nil {
  40842. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40843. }
  40844. oldValue, err := m.oldValue(ctx)
  40845. if err != nil {
  40846. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40847. }
  40848. return oldValue.WxWxid, nil
  40849. }
  40850. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40851. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  40852. m.wx_wxid = nil
  40853. }
  40854. // SetWxid sets the "wxid" field.
  40855. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  40856. m.wxid = &s
  40857. }
  40858. // Wxid returns the value of the "wxid" field in the mutation.
  40859. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  40860. v := m.wxid
  40861. if v == nil {
  40862. return
  40863. }
  40864. return *v, true
  40865. }
  40866. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  40867. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40869. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  40870. if !m.op.Is(OpUpdateOne) {
  40871. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40872. }
  40873. if m.id == nil || m.oldValue == nil {
  40874. return v, errors.New("OldWxid requires an ID field in the mutation")
  40875. }
  40876. oldValue, err := m.oldValue(ctx)
  40877. if err != nil {
  40878. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40879. }
  40880. return oldValue.Wxid, nil
  40881. }
  40882. // ResetWxid resets all changes to the "wxid" field.
  40883. func (m *WpChatroomMemberMutation) ResetWxid() {
  40884. m.wxid = nil
  40885. }
  40886. // SetNickname sets the "nickname" field.
  40887. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  40888. m.nickname = &s
  40889. }
  40890. // Nickname returns the value of the "nickname" field in the mutation.
  40891. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  40892. v := m.nickname
  40893. if v == nil {
  40894. return
  40895. }
  40896. return *v, true
  40897. }
  40898. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  40899. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40901. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  40902. if !m.op.Is(OpUpdateOne) {
  40903. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40904. }
  40905. if m.id == nil || m.oldValue == nil {
  40906. return v, errors.New("OldNickname requires an ID field in the mutation")
  40907. }
  40908. oldValue, err := m.oldValue(ctx)
  40909. if err != nil {
  40910. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40911. }
  40912. return oldValue.Nickname, nil
  40913. }
  40914. // ResetNickname resets all changes to the "nickname" field.
  40915. func (m *WpChatroomMemberMutation) ResetNickname() {
  40916. m.nickname = nil
  40917. }
  40918. // SetAvatar sets the "avatar" field.
  40919. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  40920. m.avatar = &s
  40921. }
  40922. // Avatar returns the value of the "avatar" field in the mutation.
  40923. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  40924. v := m.avatar
  40925. if v == nil {
  40926. return
  40927. }
  40928. return *v, true
  40929. }
  40930. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  40931. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  40932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40933. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40934. if !m.op.Is(OpUpdateOne) {
  40935. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40936. }
  40937. if m.id == nil || m.oldValue == nil {
  40938. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40939. }
  40940. oldValue, err := m.oldValue(ctx)
  40941. if err != nil {
  40942. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40943. }
  40944. return oldValue.Avatar, nil
  40945. }
  40946. // ResetAvatar resets all changes to the "avatar" field.
  40947. func (m *WpChatroomMemberMutation) ResetAvatar() {
  40948. m.avatar = nil
  40949. }
  40950. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  40951. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  40952. m.predicates = append(m.predicates, ps...)
  40953. }
  40954. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  40955. // users can use type-assertion to append predicates that do not depend on any generated package.
  40956. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  40957. p := make([]predicate.WpChatroomMember, len(ps))
  40958. for i := range ps {
  40959. p[i] = ps[i]
  40960. }
  40961. m.Where(p...)
  40962. }
  40963. // Op returns the operation name.
  40964. func (m *WpChatroomMemberMutation) Op() Op {
  40965. return m.op
  40966. }
  40967. // SetOp allows setting the mutation operation.
  40968. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  40969. m.op = op
  40970. }
  40971. // Type returns the node type of this mutation (WpChatroomMember).
  40972. func (m *WpChatroomMemberMutation) Type() string {
  40973. return m.typ
  40974. }
  40975. // Fields returns all fields that were changed during this mutation. Note that in
  40976. // order to get all numeric fields that were incremented/decremented, call
  40977. // AddedFields().
  40978. func (m *WpChatroomMemberMutation) Fields() []string {
  40979. fields := make([]string, 0, 7)
  40980. if m.created_at != nil {
  40981. fields = append(fields, wpchatroommember.FieldCreatedAt)
  40982. }
  40983. if m.updated_at != nil {
  40984. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  40985. }
  40986. if m.status != nil {
  40987. fields = append(fields, wpchatroommember.FieldStatus)
  40988. }
  40989. if m.wx_wxid != nil {
  40990. fields = append(fields, wpchatroommember.FieldWxWxid)
  40991. }
  40992. if m.wxid != nil {
  40993. fields = append(fields, wpchatroommember.FieldWxid)
  40994. }
  40995. if m.nickname != nil {
  40996. fields = append(fields, wpchatroommember.FieldNickname)
  40997. }
  40998. if m.avatar != nil {
  40999. fields = append(fields, wpchatroommember.FieldAvatar)
  41000. }
  41001. return fields
  41002. }
  41003. // Field returns the value of a field with the given name. The second boolean
  41004. // return value indicates that this field was not set, or was not defined in the
  41005. // schema.
  41006. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  41007. switch name {
  41008. case wpchatroommember.FieldCreatedAt:
  41009. return m.CreatedAt()
  41010. case wpchatroommember.FieldUpdatedAt:
  41011. return m.UpdatedAt()
  41012. case wpchatroommember.FieldStatus:
  41013. return m.Status()
  41014. case wpchatroommember.FieldWxWxid:
  41015. return m.WxWxid()
  41016. case wpchatroommember.FieldWxid:
  41017. return m.Wxid()
  41018. case wpchatroommember.FieldNickname:
  41019. return m.Nickname()
  41020. case wpchatroommember.FieldAvatar:
  41021. return m.Avatar()
  41022. }
  41023. return nil, false
  41024. }
  41025. // OldField returns the old value of the field from the database. An error is
  41026. // returned if the mutation operation is not UpdateOne, or the query to the
  41027. // database failed.
  41028. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41029. switch name {
  41030. case wpchatroommember.FieldCreatedAt:
  41031. return m.OldCreatedAt(ctx)
  41032. case wpchatroommember.FieldUpdatedAt:
  41033. return m.OldUpdatedAt(ctx)
  41034. case wpchatroommember.FieldStatus:
  41035. return m.OldStatus(ctx)
  41036. case wpchatroommember.FieldWxWxid:
  41037. return m.OldWxWxid(ctx)
  41038. case wpchatroommember.FieldWxid:
  41039. return m.OldWxid(ctx)
  41040. case wpchatroommember.FieldNickname:
  41041. return m.OldNickname(ctx)
  41042. case wpchatroommember.FieldAvatar:
  41043. return m.OldAvatar(ctx)
  41044. }
  41045. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  41046. }
  41047. // SetField sets the value of a field with the given name. It returns an error if
  41048. // the field is not defined in the schema, or if the type mismatched the field
  41049. // type.
  41050. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  41051. switch name {
  41052. case wpchatroommember.FieldCreatedAt:
  41053. v, ok := value.(time.Time)
  41054. if !ok {
  41055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41056. }
  41057. m.SetCreatedAt(v)
  41058. return nil
  41059. case wpchatroommember.FieldUpdatedAt:
  41060. v, ok := value.(time.Time)
  41061. if !ok {
  41062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41063. }
  41064. m.SetUpdatedAt(v)
  41065. return nil
  41066. case wpchatroommember.FieldStatus:
  41067. v, ok := value.(uint8)
  41068. if !ok {
  41069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41070. }
  41071. m.SetStatus(v)
  41072. return nil
  41073. case wpchatroommember.FieldWxWxid:
  41074. v, ok := value.(string)
  41075. if !ok {
  41076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41077. }
  41078. m.SetWxWxid(v)
  41079. return nil
  41080. case wpchatroommember.FieldWxid:
  41081. v, ok := value.(string)
  41082. if !ok {
  41083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41084. }
  41085. m.SetWxid(v)
  41086. return nil
  41087. case wpchatroommember.FieldNickname:
  41088. v, ok := value.(string)
  41089. if !ok {
  41090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41091. }
  41092. m.SetNickname(v)
  41093. return nil
  41094. case wpchatroommember.FieldAvatar:
  41095. v, ok := value.(string)
  41096. if !ok {
  41097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41098. }
  41099. m.SetAvatar(v)
  41100. return nil
  41101. }
  41102. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41103. }
  41104. // AddedFields returns all numeric fields that were incremented/decremented during
  41105. // this mutation.
  41106. func (m *WpChatroomMemberMutation) AddedFields() []string {
  41107. var fields []string
  41108. if m.addstatus != nil {
  41109. fields = append(fields, wpchatroommember.FieldStatus)
  41110. }
  41111. return fields
  41112. }
  41113. // AddedField returns the numeric value that was incremented/decremented on a field
  41114. // with the given name. The second boolean return value indicates that this field
  41115. // was not set, or was not defined in the schema.
  41116. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  41117. switch name {
  41118. case wpchatroommember.FieldStatus:
  41119. return m.AddedStatus()
  41120. }
  41121. return nil, false
  41122. }
  41123. // AddField adds the value to the field with the given name. It returns an error if
  41124. // the field is not defined in the schema, or if the type mismatched the field
  41125. // type.
  41126. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  41127. switch name {
  41128. case wpchatroommember.FieldStatus:
  41129. v, ok := value.(int8)
  41130. if !ok {
  41131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41132. }
  41133. m.AddStatus(v)
  41134. return nil
  41135. }
  41136. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  41137. }
  41138. // ClearedFields returns all nullable fields that were cleared during this
  41139. // mutation.
  41140. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  41141. var fields []string
  41142. if m.FieldCleared(wpchatroommember.FieldStatus) {
  41143. fields = append(fields, wpchatroommember.FieldStatus)
  41144. }
  41145. return fields
  41146. }
  41147. // FieldCleared returns a boolean indicating if a field with the given name was
  41148. // cleared in this mutation.
  41149. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  41150. _, ok := m.clearedFields[name]
  41151. return ok
  41152. }
  41153. // ClearField clears the value of the field with the given name. It returns an
  41154. // error if the field is not defined in the schema.
  41155. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  41156. switch name {
  41157. case wpchatroommember.FieldStatus:
  41158. m.ClearStatus()
  41159. return nil
  41160. }
  41161. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  41162. }
  41163. // ResetField resets all changes in the mutation for the field with the given name.
  41164. // It returns an error if the field is not defined in the schema.
  41165. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  41166. switch name {
  41167. case wpchatroommember.FieldCreatedAt:
  41168. m.ResetCreatedAt()
  41169. return nil
  41170. case wpchatroommember.FieldUpdatedAt:
  41171. m.ResetUpdatedAt()
  41172. return nil
  41173. case wpchatroommember.FieldStatus:
  41174. m.ResetStatus()
  41175. return nil
  41176. case wpchatroommember.FieldWxWxid:
  41177. m.ResetWxWxid()
  41178. return nil
  41179. case wpchatroommember.FieldWxid:
  41180. m.ResetWxid()
  41181. return nil
  41182. case wpchatroommember.FieldNickname:
  41183. m.ResetNickname()
  41184. return nil
  41185. case wpchatroommember.FieldAvatar:
  41186. m.ResetAvatar()
  41187. return nil
  41188. }
  41189. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41190. }
  41191. // AddedEdges returns all edge names that were set/added in this mutation.
  41192. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  41193. edges := make([]string, 0, 0)
  41194. return edges
  41195. }
  41196. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41197. // name in this mutation.
  41198. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  41199. return nil
  41200. }
  41201. // RemovedEdges returns all edge names that were removed in this mutation.
  41202. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  41203. edges := make([]string, 0, 0)
  41204. return edges
  41205. }
  41206. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41207. // the given name in this mutation.
  41208. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  41209. return nil
  41210. }
  41211. // ClearedEdges returns all edge names that were cleared in this mutation.
  41212. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  41213. edges := make([]string, 0, 0)
  41214. return edges
  41215. }
  41216. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41217. // was cleared in this mutation.
  41218. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  41219. return false
  41220. }
  41221. // ClearEdge clears the value of the edge with the given name. It returns an error
  41222. // if that edge is not defined in the schema.
  41223. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  41224. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  41225. }
  41226. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41227. // It returns an error if the edge is not defined in the schema.
  41228. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  41229. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  41230. }
  41231. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  41232. type WxMutation struct {
  41233. config
  41234. op Op
  41235. typ string
  41236. id *uint64
  41237. created_at *time.Time
  41238. updated_at *time.Time
  41239. status *uint8
  41240. addstatus *int8
  41241. deleted_at *time.Time
  41242. port *string
  41243. process_id *string
  41244. callback *string
  41245. wxid *string
  41246. account *string
  41247. nickname *string
  41248. tel *string
  41249. head_big *string
  41250. organization_id *uint64
  41251. addorganization_id *int64
  41252. api_base *string
  41253. api_key *string
  41254. allow_list *[]string
  41255. appendallow_list []string
  41256. group_allow_list *[]string
  41257. appendgroup_allow_list []string
  41258. block_list *[]string
  41259. appendblock_list []string
  41260. group_block_list *[]string
  41261. appendgroup_block_list []string
  41262. ctype *uint64
  41263. addctype *int64
  41264. clearedFields map[string]struct{}
  41265. server *uint64
  41266. clearedserver bool
  41267. agent *uint64
  41268. clearedagent bool
  41269. done bool
  41270. oldValue func(context.Context) (*Wx, error)
  41271. predicates []predicate.Wx
  41272. }
  41273. var _ ent.Mutation = (*WxMutation)(nil)
  41274. // wxOption allows management of the mutation configuration using functional options.
  41275. type wxOption func(*WxMutation)
  41276. // newWxMutation creates new mutation for the Wx entity.
  41277. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  41278. m := &WxMutation{
  41279. config: c,
  41280. op: op,
  41281. typ: TypeWx,
  41282. clearedFields: make(map[string]struct{}),
  41283. }
  41284. for _, opt := range opts {
  41285. opt(m)
  41286. }
  41287. return m
  41288. }
  41289. // withWxID sets the ID field of the mutation.
  41290. func withWxID(id uint64) wxOption {
  41291. return func(m *WxMutation) {
  41292. var (
  41293. err error
  41294. once sync.Once
  41295. value *Wx
  41296. )
  41297. m.oldValue = func(ctx context.Context) (*Wx, error) {
  41298. once.Do(func() {
  41299. if m.done {
  41300. err = errors.New("querying old values post mutation is not allowed")
  41301. } else {
  41302. value, err = m.Client().Wx.Get(ctx, id)
  41303. }
  41304. })
  41305. return value, err
  41306. }
  41307. m.id = &id
  41308. }
  41309. }
  41310. // withWx sets the old Wx of the mutation.
  41311. func withWx(node *Wx) wxOption {
  41312. return func(m *WxMutation) {
  41313. m.oldValue = func(context.Context) (*Wx, error) {
  41314. return node, nil
  41315. }
  41316. m.id = &node.ID
  41317. }
  41318. }
  41319. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41320. // executed in a transaction (ent.Tx), a transactional client is returned.
  41321. func (m WxMutation) Client() *Client {
  41322. client := &Client{config: m.config}
  41323. client.init()
  41324. return client
  41325. }
  41326. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41327. // it returns an error otherwise.
  41328. func (m WxMutation) Tx() (*Tx, error) {
  41329. if _, ok := m.driver.(*txDriver); !ok {
  41330. return nil, errors.New("ent: mutation is not running in a transaction")
  41331. }
  41332. tx := &Tx{config: m.config}
  41333. tx.init()
  41334. return tx, nil
  41335. }
  41336. // SetID sets the value of the id field. Note that this
  41337. // operation is only accepted on creation of Wx entities.
  41338. func (m *WxMutation) SetID(id uint64) {
  41339. m.id = &id
  41340. }
  41341. // ID returns the ID value in the mutation. Note that the ID is only available
  41342. // if it was provided to the builder or after it was returned from the database.
  41343. func (m *WxMutation) ID() (id uint64, exists bool) {
  41344. if m.id == nil {
  41345. return
  41346. }
  41347. return *m.id, true
  41348. }
  41349. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41350. // That means, if the mutation is applied within a transaction with an isolation level such
  41351. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41352. // or updated by the mutation.
  41353. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  41354. switch {
  41355. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41356. id, exists := m.ID()
  41357. if exists {
  41358. return []uint64{id}, nil
  41359. }
  41360. fallthrough
  41361. case m.op.Is(OpUpdate | OpDelete):
  41362. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  41363. default:
  41364. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41365. }
  41366. }
  41367. // SetCreatedAt sets the "created_at" field.
  41368. func (m *WxMutation) SetCreatedAt(t time.Time) {
  41369. m.created_at = &t
  41370. }
  41371. // CreatedAt returns the value of the "created_at" field in the mutation.
  41372. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  41373. v := m.created_at
  41374. if v == nil {
  41375. return
  41376. }
  41377. return *v, true
  41378. }
  41379. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  41380. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41382. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41383. if !m.op.Is(OpUpdateOne) {
  41384. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41385. }
  41386. if m.id == nil || m.oldValue == nil {
  41387. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41388. }
  41389. oldValue, err := m.oldValue(ctx)
  41390. if err != nil {
  41391. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41392. }
  41393. return oldValue.CreatedAt, nil
  41394. }
  41395. // ResetCreatedAt resets all changes to the "created_at" field.
  41396. func (m *WxMutation) ResetCreatedAt() {
  41397. m.created_at = nil
  41398. }
  41399. // SetUpdatedAt sets the "updated_at" field.
  41400. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  41401. m.updated_at = &t
  41402. }
  41403. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41404. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  41405. v := m.updated_at
  41406. if v == nil {
  41407. return
  41408. }
  41409. return *v, true
  41410. }
  41411. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  41412. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41414. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41415. if !m.op.Is(OpUpdateOne) {
  41416. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41417. }
  41418. if m.id == nil || m.oldValue == nil {
  41419. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41420. }
  41421. oldValue, err := m.oldValue(ctx)
  41422. if err != nil {
  41423. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41424. }
  41425. return oldValue.UpdatedAt, nil
  41426. }
  41427. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41428. func (m *WxMutation) ResetUpdatedAt() {
  41429. m.updated_at = nil
  41430. }
  41431. // SetStatus sets the "status" field.
  41432. func (m *WxMutation) SetStatus(u uint8) {
  41433. m.status = &u
  41434. m.addstatus = nil
  41435. }
  41436. // Status returns the value of the "status" field in the mutation.
  41437. func (m *WxMutation) Status() (r uint8, exists bool) {
  41438. v := m.status
  41439. if v == nil {
  41440. return
  41441. }
  41442. return *v, true
  41443. }
  41444. // OldStatus returns the old "status" field's value of the Wx entity.
  41445. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41447. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41448. if !m.op.Is(OpUpdateOne) {
  41449. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41450. }
  41451. if m.id == nil || m.oldValue == nil {
  41452. return v, errors.New("OldStatus requires an ID field in the mutation")
  41453. }
  41454. oldValue, err := m.oldValue(ctx)
  41455. if err != nil {
  41456. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41457. }
  41458. return oldValue.Status, nil
  41459. }
  41460. // AddStatus adds u to the "status" field.
  41461. func (m *WxMutation) AddStatus(u int8) {
  41462. if m.addstatus != nil {
  41463. *m.addstatus += u
  41464. } else {
  41465. m.addstatus = &u
  41466. }
  41467. }
  41468. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41469. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  41470. v := m.addstatus
  41471. if v == nil {
  41472. return
  41473. }
  41474. return *v, true
  41475. }
  41476. // ClearStatus clears the value of the "status" field.
  41477. func (m *WxMutation) ClearStatus() {
  41478. m.status = nil
  41479. m.addstatus = nil
  41480. m.clearedFields[wx.FieldStatus] = struct{}{}
  41481. }
  41482. // StatusCleared returns if the "status" field was cleared in this mutation.
  41483. func (m *WxMutation) StatusCleared() bool {
  41484. _, ok := m.clearedFields[wx.FieldStatus]
  41485. return ok
  41486. }
  41487. // ResetStatus resets all changes to the "status" field.
  41488. func (m *WxMutation) ResetStatus() {
  41489. m.status = nil
  41490. m.addstatus = nil
  41491. delete(m.clearedFields, wx.FieldStatus)
  41492. }
  41493. // SetDeletedAt sets the "deleted_at" field.
  41494. func (m *WxMutation) SetDeletedAt(t time.Time) {
  41495. m.deleted_at = &t
  41496. }
  41497. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41498. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  41499. v := m.deleted_at
  41500. if v == nil {
  41501. return
  41502. }
  41503. return *v, true
  41504. }
  41505. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  41506. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41508. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41509. if !m.op.Is(OpUpdateOne) {
  41510. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41511. }
  41512. if m.id == nil || m.oldValue == nil {
  41513. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41514. }
  41515. oldValue, err := m.oldValue(ctx)
  41516. if err != nil {
  41517. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41518. }
  41519. return oldValue.DeletedAt, nil
  41520. }
  41521. // ClearDeletedAt clears the value of the "deleted_at" field.
  41522. func (m *WxMutation) ClearDeletedAt() {
  41523. m.deleted_at = nil
  41524. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  41525. }
  41526. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41527. func (m *WxMutation) DeletedAtCleared() bool {
  41528. _, ok := m.clearedFields[wx.FieldDeletedAt]
  41529. return ok
  41530. }
  41531. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41532. func (m *WxMutation) ResetDeletedAt() {
  41533. m.deleted_at = nil
  41534. delete(m.clearedFields, wx.FieldDeletedAt)
  41535. }
  41536. // SetServerID sets the "server_id" field.
  41537. func (m *WxMutation) SetServerID(u uint64) {
  41538. m.server = &u
  41539. }
  41540. // ServerID returns the value of the "server_id" field in the mutation.
  41541. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  41542. v := m.server
  41543. if v == nil {
  41544. return
  41545. }
  41546. return *v, true
  41547. }
  41548. // OldServerID returns the old "server_id" field's value of the Wx entity.
  41549. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41551. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  41552. if !m.op.Is(OpUpdateOne) {
  41553. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  41554. }
  41555. if m.id == nil || m.oldValue == nil {
  41556. return v, errors.New("OldServerID requires an ID field in the mutation")
  41557. }
  41558. oldValue, err := m.oldValue(ctx)
  41559. if err != nil {
  41560. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  41561. }
  41562. return oldValue.ServerID, nil
  41563. }
  41564. // ClearServerID clears the value of the "server_id" field.
  41565. func (m *WxMutation) ClearServerID() {
  41566. m.server = nil
  41567. m.clearedFields[wx.FieldServerID] = struct{}{}
  41568. }
  41569. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  41570. func (m *WxMutation) ServerIDCleared() bool {
  41571. _, ok := m.clearedFields[wx.FieldServerID]
  41572. return ok
  41573. }
  41574. // ResetServerID resets all changes to the "server_id" field.
  41575. func (m *WxMutation) ResetServerID() {
  41576. m.server = nil
  41577. delete(m.clearedFields, wx.FieldServerID)
  41578. }
  41579. // SetPort sets the "port" field.
  41580. func (m *WxMutation) SetPort(s string) {
  41581. m.port = &s
  41582. }
  41583. // Port returns the value of the "port" field in the mutation.
  41584. func (m *WxMutation) Port() (r string, exists bool) {
  41585. v := m.port
  41586. if v == nil {
  41587. return
  41588. }
  41589. return *v, true
  41590. }
  41591. // OldPort returns the old "port" field's value of the Wx entity.
  41592. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41594. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  41595. if !m.op.Is(OpUpdateOne) {
  41596. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  41597. }
  41598. if m.id == nil || m.oldValue == nil {
  41599. return v, errors.New("OldPort requires an ID field in the mutation")
  41600. }
  41601. oldValue, err := m.oldValue(ctx)
  41602. if err != nil {
  41603. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  41604. }
  41605. return oldValue.Port, nil
  41606. }
  41607. // ResetPort resets all changes to the "port" field.
  41608. func (m *WxMutation) ResetPort() {
  41609. m.port = nil
  41610. }
  41611. // SetProcessID sets the "process_id" field.
  41612. func (m *WxMutation) SetProcessID(s string) {
  41613. m.process_id = &s
  41614. }
  41615. // ProcessID returns the value of the "process_id" field in the mutation.
  41616. func (m *WxMutation) ProcessID() (r string, exists bool) {
  41617. v := m.process_id
  41618. if v == nil {
  41619. return
  41620. }
  41621. return *v, true
  41622. }
  41623. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  41624. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41626. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  41627. if !m.op.Is(OpUpdateOne) {
  41628. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  41629. }
  41630. if m.id == nil || m.oldValue == nil {
  41631. return v, errors.New("OldProcessID requires an ID field in the mutation")
  41632. }
  41633. oldValue, err := m.oldValue(ctx)
  41634. if err != nil {
  41635. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  41636. }
  41637. return oldValue.ProcessID, nil
  41638. }
  41639. // ResetProcessID resets all changes to the "process_id" field.
  41640. func (m *WxMutation) ResetProcessID() {
  41641. m.process_id = nil
  41642. }
  41643. // SetCallback sets the "callback" field.
  41644. func (m *WxMutation) SetCallback(s string) {
  41645. m.callback = &s
  41646. }
  41647. // Callback returns the value of the "callback" field in the mutation.
  41648. func (m *WxMutation) Callback() (r string, exists bool) {
  41649. v := m.callback
  41650. if v == nil {
  41651. return
  41652. }
  41653. return *v, true
  41654. }
  41655. // OldCallback returns the old "callback" field's value of the Wx entity.
  41656. // If the Wx 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 *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  41659. if !m.op.Is(OpUpdateOne) {
  41660. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  41661. }
  41662. if m.id == nil || m.oldValue == nil {
  41663. return v, errors.New("OldCallback 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 OldCallback: %w", err)
  41668. }
  41669. return oldValue.Callback, nil
  41670. }
  41671. // ResetCallback resets all changes to the "callback" field.
  41672. func (m *WxMutation) ResetCallback() {
  41673. m.callback = nil
  41674. }
  41675. // SetWxid sets the "wxid" field.
  41676. func (m *WxMutation) SetWxid(s string) {
  41677. m.wxid = &s
  41678. }
  41679. // Wxid returns the value of the "wxid" field in the mutation.
  41680. func (m *WxMutation) Wxid() (r string, exists bool) {
  41681. v := m.wxid
  41682. if v == nil {
  41683. return
  41684. }
  41685. return *v, true
  41686. }
  41687. // OldWxid returns the old "wxid" field's value of the Wx entity.
  41688. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41690. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  41691. if !m.op.Is(OpUpdateOne) {
  41692. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41693. }
  41694. if m.id == nil || m.oldValue == nil {
  41695. return v, errors.New("OldWxid requires an ID field in the mutation")
  41696. }
  41697. oldValue, err := m.oldValue(ctx)
  41698. if err != nil {
  41699. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41700. }
  41701. return oldValue.Wxid, nil
  41702. }
  41703. // ResetWxid resets all changes to the "wxid" field.
  41704. func (m *WxMutation) ResetWxid() {
  41705. m.wxid = nil
  41706. }
  41707. // SetAccount sets the "account" field.
  41708. func (m *WxMutation) SetAccount(s string) {
  41709. m.account = &s
  41710. }
  41711. // Account returns the value of the "account" field in the mutation.
  41712. func (m *WxMutation) Account() (r string, exists bool) {
  41713. v := m.account
  41714. if v == nil {
  41715. return
  41716. }
  41717. return *v, true
  41718. }
  41719. // OldAccount returns the old "account" field's value of the Wx entity.
  41720. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41722. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  41723. if !m.op.Is(OpUpdateOne) {
  41724. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  41725. }
  41726. if m.id == nil || m.oldValue == nil {
  41727. return v, errors.New("OldAccount requires an ID field in the mutation")
  41728. }
  41729. oldValue, err := m.oldValue(ctx)
  41730. if err != nil {
  41731. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  41732. }
  41733. return oldValue.Account, nil
  41734. }
  41735. // ResetAccount resets all changes to the "account" field.
  41736. func (m *WxMutation) ResetAccount() {
  41737. m.account = nil
  41738. }
  41739. // SetNickname sets the "nickname" field.
  41740. func (m *WxMutation) SetNickname(s string) {
  41741. m.nickname = &s
  41742. }
  41743. // Nickname returns the value of the "nickname" field in the mutation.
  41744. func (m *WxMutation) Nickname() (r string, exists bool) {
  41745. v := m.nickname
  41746. if v == nil {
  41747. return
  41748. }
  41749. return *v, true
  41750. }
  41751. // OldNickname returns the old "nickname" field's value of the Wx entity.
  41752. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41754. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  41755. if !m.op.Is(OpUpdateOne) {
  41756. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41757. }
  41758. if m.id == nil || m.oldValue == nil {
  41759. return v, errors.New("OldNickname requires an ID field in the mutation")
  41760. }
  41761. oldValue, err := m.oldValue(ctx)
  41762. if err != nil {
  41763. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41764. }
  41765. return oldValue.Nickname, nil
  41766. }
  41767. // ResetNickname resets all changes to the "nickname" field.
  41768. func (m *WxMutation) ResetNickname() {
  41769. m.nickname = nil
  41770. }
  41771. // SetTel sets the "tel" field.
  41772. func (m *WxMutation) SetTel(s string) {
  41773. m.tel = &s
  41774. }
  41775. // Tel returns the value of the "tel" field in the mutation.
  41776. func (m *WxMutation) Tel() (r string, exists bool) {
  41777. v := m.tel
  41778. if v == nil {
  41779. return
  41780. }
  41781. return *v, true
  41782. }
  41783. // OldTel returns the old "tel" field's value of the Wx entity.
  41784. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41786. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  41787. if !m.op.Is(OpUpdateOne) {
  41788. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  41789. }
  41790. if m.id == nil || m.oldValue == nil {
  41791. return v, errors.New("OldTel requires an ID field in the mutation")
  41792. }
  41793. oldValue, err := m.oldValue(ctx)
  41794. if err != nil {
  41795. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  41796. }
  41797. return oldValue.Tel, nil
  41798. }
  41799. // ResetTel resets all changes to the "tel" field.
  41800. func (m *WxMutation) ResetTel() {
  41801. m.tel = nil
  41802. }
  41803. // SetHeadBig sets the "head_big" field.
  41804. func (m *WxMutation) SetHeadBig(s string) {
  41805. m.head_big = &s
  41806. }
  41807. // HeadBig returns the value of the "head_big" field in the mutation.
  41808. func (m *WxMutation) HeadBig() (r string, exists bool) {
  41809. v := m.head_big
  41810. if v == nil {
  41811. return
  41812. }
  41813. return *v, true
  41814. }
  41815. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  41816. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41818. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  41819. if !m.op.Is(OpUpdateOne) {
  41820. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  41821. }
  41822. if m.id == nil || m.oldValue == nil {
  41823. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  41824. }
  41825. oldValue, err := m.oldValue(ctx)
  41826. if err != nil {
  41827. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  41828. }
  41829. return oldValue.HeadBig, nil
  41830. }
  41831. // ResetHeadBig resets all changes to the "head_big" field.
  41832. func (m *WxMutation) ResetHeadBig() {
  41833. m.head_big = nil
  41834. }
  41835. // SetOrganizationID sets the "organization_id" field.
  41836. func (m *WxMutation) SetOrganizationID(u uint64) {
  41837. m.organization_id = &u
  41838. m.addorganization_id = nil
  41839. }
  41840. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41841. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  41842. v := m.organization_id
  41843. if v == nil {
  41844. return
  41845. }
  41846. return *v, true
  41847. }
  41848. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  41849. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41851. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41852. if !m.op.Is(OpUpdateOne) {
  41853. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41854. }
  41855. if m.id == nil || m.oldValue == nil {
  41856. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41857. }
  41858. oldValue, err := m.oldValue(ctx)
  41859. if err != nil {
  41860. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41861. }
  41862. return oldValue.OrganizationID, nil
  41863. }
  41864. // AddOrganizationID adds u to the "organization_id" field.
  41865. func (m *WxMutation) AddOrganizationID(u int64) {
  41866. if m.addorganization_id != nil {
  41867. *m.addorganization_id += u
  41868. } else {
  41869. m.addorganization_id = &u
  41870. }
  41871. }
  41872. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41873. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  41874. v := m.addorganization_id
  41875. if v == nil {
  41876. return
  41877. }
  41878. return *v, true
  41879. }
  41880. // ClearOrganizationID clears the value of the "organization_id" field.
  41881. func (m *WxMutation) ClearOrganizationID() {
  41882. m.organization_id = nil
  41883. m.addorganization_id = nil
  41884. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  41885. }
  41886. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41887. func (m *WxMutation) OrganizationIDCleared() bool {
  41888. _, ok := m.clearedFields[wx.FieldOrganizationID]
  41889. return ok
  41890. }
  41891. // ResetOrganizationID resets all changes to the "organization_id" field.
  41892. func (m *WxMutation) ResetOrganizationID() {
  41893. m.organization_id = nil
  41894. m.addorganization_id = nil
  41895. delete(m.clearedFields, wx.FieldOrganizationID)
  41896. }
  41897. // SetAgentID sets the "agent_id" field.
  41898. func (m *WxMutation) SetAgentID(u uint64) {
  41899. m.agent = &u
  41900. }
  41901. // AgentID returns the value of the "agent_id" field in the mutation.
  41902. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  41903. v := m.agent
  41904. if v == nil {
  41905. return
  41906. }
  41907. return *v, true
  41908. }
  41909. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  41910. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41912. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  41913. if !m.op.Is(OpUpdateOne) {
  41914. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  41915. }
  41916. if m.id == nil || m.oldValue == nil {
  41917. return v, errors.New("OldAgentID requires an ID field in the mutation")
  41918. }
  41919. oldValue, err := m.oldValue(ctx)
  41920. if err != nil {
  41921. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  41922. }
  41923. return oldValue.AgentID, nil
  41924. }
  41925. // ResetAgentID resets all changes to the "agent_id" field.
  41926. func (m *WxMutation) ResetAgentID() {
  41927. m.agent = nil
  41928. }
  41929. // SetAPIBase sets the "api_base" field.
  41930. func (m *WxMutation) SetAPIBase(s string) {
  41931. m.api_base = &s
  41932. }
  41933. // APIBase returns the value of the "api_base" field in the mutation.
  41934. func (m *WxMutation) APIBase() (r string, exists bool) {
  41935. v := m.api_base
  41936. if v == nil {
  41937. return
  41938. }
  41939. return *v, true
  41940. }
  41941. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  41942. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41943. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41944. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  41945. if !m.op.Is(OpUpdateOne) {
  41946. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  41947. }
  41948. if m.id == nil || m.oldValue == nil {
  41949. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  41950. }
  41951. oldValue, err := m.oldValue(ctx)
  41952. if err != nil {
  41953. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  41954. }
  41955. return oldValue.APIBase, nil
  41956. }
  41957. // ClearAPIBase clears the value of the "api_base" field.
  41958. func (m *WxMutation) ClearAPIBase() {
  41959. m.api_base = nil
  41960. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  41961. }
  41962. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  41963. func (m *WxMutation) APIBaseCleared() bool {
  41964. _, ok := m.clearedFields[wx.FieldAPIBase]
  41965. return ok
  41966. }
  41967. // ResetAPIBase resets all changes to the "api_base" field.
  41968. func (m *WxMutation) ResetAPIBase() {
  41969. m.api_base = nil
  41970. delete(m.clearedFields, wx.FieldAPIBase)
  41971. }
  41972. // SetAPIKey sets the "api_key" field.
  41973. func (m *WxMutation) SetAPIKey(s string) {
  41974. m.api_key = &s
  41975. }
  41976. // APIKey returns the value of the "api_key" field in the mutation.
  41977. func (m *WxMutation) APIKey() (r string, exists bool) {
  41978. v := m.api_key
  41979. if v == nil {
  41980. return
  41981. }
  41982. return *v, true
  41983. }
  41984. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  41985. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  41986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41987. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  41988. if !m.op.Is(OpUpdateOne) {
  41989. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  41990. }
  41991. if m.id == nil || m.oldValue == nil {
  41992. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  41993. }
  41994. oldValue, err := m.oldValue(ctx)
  41995. if err != nil {
  41996. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  41997. }
  41998. return oldValue.APIKey, nil
  41999. }
  42000. // ClearAPIKey clears the value of the "api_key" field.
  42001. func (m *WxMutation) ClearAPIKey() {
  42002. m.api_key = nil
  42003. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  42004. }
  42005. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42006. func (m *WxMutation) APIKeyCleared() bool {
  42007. _, ok := m.clearedFields[wx.FieldAPIKey]
  42008. return ok
  42009. }
  42010. // ResetAPIKey resets all changes to the "api_key" field.
  42011. func (m *WxMutation) ResetAPIKey() {
  42012. m.api_key = nil
  42013. delete(m.clearedFields, wx.FieldAPIKey)
  42014. }
  42015. // SetAllowList sets the "allow_list" field.
  42016. func (m *WxMutation) SetAllowList(s []string) {
  42017. m.allow_list = &s
  42018. m.appendallow_list = nil
  42019. }
  42020. // AllowList returns the value of the "allow_list" field in the mutation.
  42021. func (m *WxMutation) AllowList() (r []string, exists bool) {
  42022. v := m.allow_list
  42023. if v == nil {
  42024. return
  42025. }
  42026. return *v, true
  42027. }
  42028. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  42029. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42031. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42032. if !m.op.Is(OpUpdateOne) {
  42033. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42034. }
  42035. if m.id == nil || m.oldValue == nil {
  42036. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42037. }
  42038. oldValue, err := m.oldValue(ctx)
  42039. if err != nil {
  42040. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42041. }
  42042. return oldValue.AllowList, nil
  42043. }
  42044. // AppendAllowList adds s to the "allow_list" field.
  42045. func (m *WxMutation) AppendAllowList(s []string) {
  42046. m.appendallow_list = append(m.appendallow_list, s...)
  42047. }
  42048. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42049. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  42050. if len(m.appendallow_list) == 0 {
  42051. return nil, false
  42052. }
  42053. return m.appendallow_list, true
  42054. }
  42055. // ResetAllowList resets all changes to the "allow_list" field.
  42056. func (m *WxMutation) ResetAllowList() {
  42057. m.allow_list = nil
  42058. m.appendallow_list = nil
  42059. }
  42060. // SetGroupAllowList sets the "group_allow_list" field.
  42061. func (m *WxMutation) SetGroupAllowList(s []string) {
  42062. m.group_allow_list = &s
  42063. m.appendgroup_allow_list = nil
  42064. }
  42065. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42066. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  42067. v := m.group_allow_list
  42068. if v == nil {
  42069. return
  42070. }
  42071. return *v, true
  42072. }
  42073. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  42074. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42076. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42077. if !m.op.Is(OpUpdateOne) {
  42078. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42079. }
  42080. if m.id == nil || m.oldValue == nil {
  42081. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42082. }
  42083. oldValue, err := m.oldValue(ctx)
  42084. if err != nil {
  42085. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42086. }
  42087. return oldValue.GroupAllowList, nil
  42088. }
  42089. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42090. func (m *WxMutation) AppendGroupAllowList(s []string) {
  42091. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42092. }
  42093. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42094. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  42095. if len(m.appendgroup_allow_list) == 0 {
  42096. return nil, false
  42097. }
  42098. return m.appendgroup_allow_list, true
  42099. }
  42100. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42101. func (m *WxMutation) ResetGroupAllowList() {
  42102. m.group_allow_list = nil
  42103. m.appendgroup_allow_list = nil
  42104. }
  42105. // SetBlockList sets the "block_list" field.
  42106. func (m *WxMutation) SetBlockList(s []string) {
  42107. m.block_list = &s
  42108. m.appendblock_list = nil
  42109. }
  42110. // BlockList returns the value of the "block_list" field in the mutation.
  42111. func (m *WxMutation) BlockList() (r []string, exists bool) {
  42112. v := m.block_list
  42113. if v == nil {
  42114. return
  42115. }
  42116. return *v, true
  42117. }
  42118. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  42119. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42121. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42122. if !m.op.Is(OpUpdateOne) {
  42123. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42124. }
  42125. if m.id == nil || m.oldValue == nil {
  42126. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42127. }
  42128. oldValue, err := m.oldValue(ctx)
  42129. if err != nil {
  42130. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42131. }
  42132. return oldValue.BlockList, nil
  42133. }
  42134. // AppendBlockList adds s to the "block_list" field.
  42135. func (m *WxMutation) AppendBlockList(s []string) {
  42136. m.appendblock_list = append(m.appendblock_list, s...)
  42137. }
  42138. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42139. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  42140. if len(m.appendblock_list) == 0 {
  42141. return nil, false
  42142. }
  42143. return m.appendblock_list, true
  42144. }
  42145. // ResetBlockList resets all changes to the "block_list" field.
  42146. func (m *WxMutation) ResetBlockList() {
  42147. m.block_list = nil
  42148. m.appendblock_list = nil
  42149. }
  42150. // SetGroupBlockList sets the "group_block_list" field.
  42151. func (m *WxMutation) SetGroupBlockList(s []string) {
  42152. m.group_block_list = &s
  42153. m.appendgroup_block_list = nil
  42154. }
  42155. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42156. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  42157. v := m.group_block_list
  42158. if v == nil {
  42159. return
  42160. }
  42161. return *v, true
  42162. }
  42163. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  42164. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42166. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42167. if !m.op.Is(OpUpdateOne) {
  42168. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42169. }
  42170. if m.id == nil || m.oldValue == nil {
  42171. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42172. }
  42173. oldValue, err := m.oldValue(ctx)
  42174. if err != nil {
  42175. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42176. }
  42177. return oldValue.GroupBlockList, nil
  42178. }
  42179. // AppendGroupBlockList adds s to the "group_block_list" field.
  42180. func (m *WxMutation) AppendGroupBlockList(s []string) {
  42181. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42182. }
  42183. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42184. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  42185. if len(m.appendgroup_block_list) == 0 {
  42186. return nil, false
  42187. }
  42188. return m.appendgroup_block_list, true
  42189. }
  42190. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42191. func (m *WxMutation) ResetGroupBlockList() {
  42192. m.group_block_list = nil
  42193. m.appendgroup_block_list = nil
  42194. }
  42195. // SetCtype sets the "ctype" field.
  42196. func (m *WxMutation) SetCtype(u uint64) {
  42197. m.ctype = &u
  42198. m.addctype = nil
  42199. }
  42200. // Ctype returns the value of the "ctype" field in the mutation.
  42201. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  42202. v := m.ctype
  42203. if v == nil {
  42204. return
  42205. }
  42206. return *v, true
  42207. }
  42208. // OldCtype returns the old "ctype" field's value of the Wx entity.
  42209. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42211. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  42212. if !m.op.Is(OpUpdateOne) {
  42213. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  42214. }
  42215. if m.id == nil || m.oldValue == nil {
  42216. return v, errors.New("OldCtype requires an ID field in the mutation")
  42217. }
  42218. oldValue, err := m.oldValue(ctx)
  42219. if err != nil {
  42220. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  42221. }
  42222. return oldValue.Ctype, nil
  42223. }
  42224. // AddCtype adds u to the "ctype" field.
  42225. func (m *WxMutation) AddCtype(u int64) {
  42226. if m.addctype != nil {
  42227. *m.addctype += u
  42228. } else {
  42229. m.addctype = &u
  42230. }
  42231. }
  42232. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  42233. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  42234. v := m.addctype
  42235. if v == nil {
  42236. return
  42237. }
  42238. return *v, true
  42239. }
  42240. // ClearCtype clears the value of the "ctype" field.
  42241. func (m *WxMutation) ClearCtype() {
  42242. m.ctype = nil
  42243. m.addctype = nil
  42244. m.clearedFields[wx.FieldCtype] = struct{}{}
  42245. }
  42246. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  42247. func (m *WxMutation) CtypeCleared() bool {
  42248. _, ok := m.clearedFields[wx.FieldCtype]
  42249. return ok
  42250. }
  42251. // ResetCtype resets all changes to the "ctype" field.
  42252. func (m *WxMutation) ResetCtype() {
  42253. m.ctype = nil
  42254. m.addctype = nil
  42255. delete(m.clearedFields, wx.FieldCtype)
  42256. }
  42257. // ClearServer clears the "server" edge to the Server entity.
  42258. func (m *WxMutation) ClearServer() {
  42259. m.clearedserver = true
  42260. m.clearedFields[wx.FieldServerID] = struct{}{}
  42261. }
  42262. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  42263. func (m *WxMutation) ServerCleared() bool {
  42264. return m.ServerIDCleared() || m.clearedserver
  42265. }
  42266. // ServerIDs returns the "server" edge IDs in the mutation.
  42267. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42268. // ServerID instead. It exists only for internal usage by the builders.
  42269. func (m *WxMutation) ServerIDs() (ids []uint64) {
  42270. if id := m.server; id != nil {
  42271. ids = append(ids, *id)
  42272. }
  42273. return
  42274. }
  42275. // ResetServer resets all changes to the "server" edge.
  42276. func (m *WxMutation) ResetServer() {
  42277. m.server = nil
  42278. m.clearedserver = false
  42279. }
  42280. // ClearAgent clears the "agent" edge to the Agent entity.
  42281. func (m *WxMutation) ClearAgent() {
  42282. m.clearedagent = true
  42283. m.clearedFields[wx.FieldAgentID] = struct{}{}
  42284. }
  42285. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42286. func (m *WxMutation) AgentCleared() bool {
  42287. return m.clearedagent
  42288. }
  42289. // AgentIDs returns the "agent" edge IDs in the mutation.
  42290. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42291. // AgentID instead. It exists only for internal usage by the builders.
  42292. func (m *WxMutation) AgentIDs() (ids []uint64) {
  42293. if id := m.agent; id != nil {
  42294. ids = append(ids, *id)
  42295. }
  42296. return
  42297. }
  42298. // ResetAgent resets all changes to the "agent" edge.
  42299. func (m *WxMutation) ResetAgent() {
  42300. m.agent = nil
  42301. m.clearedagent = false
  42302. }
  42303. // Where appends a list predicates to the WxMutation builder.
  42304. func (m *WxMutation) Where(ps ...predicate.Wx) {
  42305. m.predicates = append(m.predicates, ps...)
  42306. }
  42307. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  42308. // users can use type-assertion to append predicates that do not depend on any generated package.
  42309. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  42310. p := make([]predicate.Wx, len(ps))
  42311. for i := range ps {
  42312. p[i] = ps[i]
  42313. }
  42314. m.Where(p...)
  42315. }
  42316. // Op returns the operation name.
  42317. func (m *WxMutation) Op() Op {
  42318. return m.op
  42319. }
  42320. // SetOp allows setting the mutation operation.
  42321. func (m *WxMutation) SetOp(op Op) {
  42322. m.op = op
  42323. }
  42324. // Type returns the node type of this mutation (Wx).
  42325. func (m *WxMutation) Type() string {
  42326. return m.typ
  42327. }
  42328. // Fields returns all fields that were changed during this mutation. Note that in
  42329. // order to get all numeric fields that were incremented/decremented, call
  42330. // AddedFields().
  42331. func (m *WxMutation) Fields() []string {
  42332. fields := make([]string, 0, 22)
  42333. if m.created_at != nil {
  42334. fields = append(fields, wx.FieldCreatedAt)
  42335. }
  42336. if m.updated_at != nil {
  42337. fields = append(fields, wx.FieldUpdatedAt)
  42338. }
  42339. if m.status != nil {
  42340. fields = append(fields, wx.FieldStatus)
  42341. }
  42342. if m.deleted_at != nil {
  42343. fields = append(fields, wx.FieldDeletedAt)
  42344. }
  42345. if m.server != nil {
  42346. fields = append(fields, wx.FieldServerID)
  42347. }
  42348. if m.port != nil {
  42349. fields = append(fields, wx.FieldPort)
  42350. }
  42351. if m.process_id != nil {
  42352. fields = append(fields, wx.FieldProcessID)
  42353. }
  42354. if m.callback != nil {
  42355. fields = append(fields, wx.FieldCallback)
  42356. }
  42357. if m.wxid != nil {
  42358. fields = append(fields, wx.FieldWxid)
  42359. }
  42360. if m.account != nil {
  42361. fields = append(fields, wx.FieldAccount)
  42362. }
  42363. if m.nickname != nil {
  42364. fields = append(fields, wx.FieldNickname)
  42365. }
  42366. if m.tel != nil {
  42367. fields = append(fields, wx.FieldTel)
  42368. }
  42369. if m.head_big != nil {
  42370. fields = append(fields, wx.FieldHeadBig)
  42371. }
  42372. if m.organization_id != nil {
  42373. fields = append(fields, wx.FieldOrganizationID)
  42374. }
  42375. if m.agent != nil {
  42376. fields = append(fields, wx.FieldAgentID)
  42377. }
  42378. if m.api_base != nil {
  42379. fields = append(fields, wx.FieldAPIBase)
  42380. }
  42381. if m.api_key != nil {
  42382. fields = append(fields, wx.FieldAPIKey)
  42383. }
  42384. if m.allow_list != nil {
  42385. fields = append(fields, wx.FieldAllowList)
  42386. }
  42387. if m.group_allow_list != nil {
  42388. fields = append(fields, wx.FieldGroupAllowList)
  42389. }
  42390. if m.block_list != nil {
  42391. fields = append(fields, wx.FieldBlockList)
  42392. }
  42393. if m.group_block_list != nil {
  42394. fields = append(fields, wx.FieldGroupBlockList)
  42395. }
  42396. if m.ctype != nil {
  42397. fields = append(fields, wx.FieldCtype)
  42398. }
  42399. return fields
  42400. }
  42401. // Field returns the value of a field with the given name. The second boolean
  42402. // return value indicates that this field was not set, or was not defined in the
  42403. // schema.
  42404. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  42405. switch name {
  42406. case wx.FieldCreatedAt:
  42407. return m.CreatedAt()
  42408. case wx.FieldUpdatedAt:
  42409. return m.UpdatedAt()
  42410. case wx.FieldStatus:
  42411. return m.Status()
  42412. case wx.FieldDeletedAt:
  42413. return m.DeletedAt()
  42414. case wx.FieldServerID:
  42415. return m.ServerID()
  42416. case wx.FieldPort:
  42417. return m.Port()
  42418. case wx.FieldProcessID:
  42419. return m.ProcessID()
  42420. case wx.FieldCallback:
  42421. return m.Callback()
  42422. case wx.FieldWxid:
  42423. return m.Wxid()
  42424. case wx.FieldAccount:
  42425. return m.Account()
  42426. case wx.FieldNickname:
  42427. return m.Nickname()
  42428. case wx.FieldTel:
  42429. return m.Tel()
  42430. case wx.FieldHeadBig:
  42431. return m.HeadBig()
  42432. case wx.FieldOrganizationID:
  42433. return m.OrganizationID()
  42434. case wx.FieldAgentID:
  42435. return m.AgentID()
  42436. case wx.FieldAPIBase:
  42437. return m.APIBase()
  42438. case wx.FieldAPIKey:
  42439. return m.APIKey()
  42440. case wx.FieldAllowList:
  42441. return m.AllowList()
  42442. case wx.FieldGroupAllowList:
  42443. return m.GroupAllowList()
  42444. case wx.FieldBlockList:
  42445. return m.BlockList()
  42446. case wx.FieldGroupBlockList:
  42447. return m.GroupBlockList()
  42448. case wx.FieldCtype:
  42449. return m.Ctype()
  42450. }
  42451. return nil, false
  42452. }
  42453. // OldField returns the old value of the field from the database. An error is
  42454. // returned if the mutation operation is not UpdateOne, or the query to the
  42455. // database failed.
  42456. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  42457. switch name {
  42458. case wx.FieldCreatedAt:
  42459. return m.OldCreatedAt(ctx)
  42460. case wx.FieldUpdatedAt:
  42461. return m.OldUpdatedAt(ctx)
  42462. case wx.FieldStatus:
  42463. return m.OldStatus(ctx)
  42464. case wx.FieldDeletedAt:
  42465. return m.OldDeletedAt(ctx)
  42466. case wx.FieldServerID:
  42467. return m.OldServerID(ctx)
  42468. case wx.FieldPort:
  42469. return m.OldPort(ctx)
  42470. case wx.FieldProcessID:
  42471. return m.OldProcessID(ctx)
  42472. case wx.FieldCallback:
  42473. return m.OldCallback(ctx)
  42474. case wx.FieldWxid:
  42475. return m.OldWxid(ctx)
  42476. case wx.FieldAccount:
  42477. return m.OldAccount(ctx)
  42478. case wx.FieldNickname:
  42479. return m.OldNickname(ctx)
  42480. case wx.FieldTel:
  42481. return m.OldTel(ctx)
  42482. case wx.FieldHeadBig:
  42483. return m.OldHeadBig(ctx)
  42484. case wx.FieldOrganizationID:
  42485. return m.OldOrganizationID(ctx)
  42486. case wx.FieldAgentID:
  42487. return m.OldAgentID(ctx)
  42488. case wx.FieldAPIBase:
  42489. return m.OldAPIBase(ctx)
  42490. case wx.FieldAPIKey:
  42491. return m.OldAPIKey(ctx)
  42492. case wx.FieldAllowList:
  42493. return m.OldAllowList(ctx)
  42494. case wx.FieldGroupAllowList:
  42495. return m.OldGroupAllowList(ctx)
  42496. case wx.FieldBlockList:
  42497. return m.OldBlockList(ctx)
  42498. case wx.FieldGroupBlockList:
  42499. return m.OldGroupBlockList(ctx)
  42500. case wx.FieldCtype:
  42501. return m.OldCtype(ctx)
  42502. }
  42503. return nil, fmt.Errorf("unknown Wx field %s", name)
  42504. }
  42505. // SetField sets the value of a field with the given name. It returns an error if
  42506. // the field is not defined in the schema, or if the type mismatched the field
  42507. // type.
  42508. func (m *WxMutation) SetField(name string, value ent.Value) error {
  42509. switch name {
  42510. case wx.FieldCreatedAt:
  42511. v, ok := value.(time.Time)
  42512. if !ok {
  42513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42514. }
  42515. m.SetCreatedAt(v)
  42516. return nil
  42517. case wx.FieldUpdatedAt:
  42518. v, ok := value.(time.Time)
  42519. if !ok {
  42520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42521. }
  42522. m.SetUpdatedAt(v)
  42523. return nil
  42524. case wx.FieldStatus:
  42525. v, ok := value.(uint8)
  42526. if !ok {
  42527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42528. }
  42529. m.SetStatus(v)
  42530. return nil
  42531. case wx.FieldDeletedAt:
  42532. v, ok := value.(time.Time)
  42533. if !ok {
  42534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42535. }
  42536. m.SetDeletedAt(v)
  42537. return nil
  42538. case wx.FieldServerID:
  42539. v, ok := value.(uint64)
  42540. if !ok {
  42541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42542. }
  42543. m.SetServerID(v)
  42544. return nil
  42545. case wx.FieldPort:
  42546. v, ok := value.(string)
  42547. if !ok {
  42548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42549. }
  42550. m.SetPort(v)
  42551. return nil
  42552. case wx.FieldProcessID:
  42553. v, ok := value.(string)
  42554. if !ok {
  42555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42556. }
  42557. m.SetProcessID(v)
  42558. return nil
  42559. case wx.FieldCallback:
  42560. v, ok := value.(string)
  42561. if !ok {
  42562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42563. }
  42564. m.SetCallback(v)
  42565. return nil
  42566. case wx.FieldWxid:
  42567. v, ok := value.(string)
  42568. if !ok {
  42569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42570. }
  42571. m.SetWxid(v)
  42572. return nil
  42573. case wx.FieldAccount:
  42574. v, ok := value.(string)
  42575. if !ok {
  42576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42577. }
  42578. m.SetAccount(v)
  42579. return nil
  42580. case wx.FieldNickname:
  42581. v, ok := value.(string)
  42582. if !ok {
  42583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42584. }
  42585. m.SetNickname(v)
  42586. return nil
  42587. case wx.FieldTel:
  42588. v, ok := value.(string)
  42589. if !ok {
  42590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42591. }
  42592. m.SetTel(v)
  42593. return nil
  42594. case wx.FieldHeadBig:
  42595. v, ok := value.(string)
  42596. if !ok {
  42597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42598. }
  42599. m.SetHeadBig(v)
  42600. return nil
  42601. case wx.FieldOrganizationID:
  42602. v, ok := value.(uint64)
  42603. if !ok {
  42604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42605. }
  42606. m.SetOrganizationID(v)
  42607. return nil
  42608. case wx.FieldAgentID:
  42609. v, ok := value.(uint64)
  42610. if !ok {
  42611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42612. }
  42613. m.SetAgentID(v)
  42614. return nil
  42615. case wx.FieldAPIBase:
  42616. v, ok := value.(string)
  42617. if !ok {
  42618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42619. }
  42620. m.SetAPIBase(v)
  42621. return nil
  42622. case wx.FieldAPIKey:
  42623. v, ok := value.(string)
  42624. if !ok {
  42625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42626. }
  42627. m.SetAPIKey(v)
  42628. return nil
  42629. case wx.FieldAllowList:
  42630. v, ok := value.([]string)
  42631. if !ok {
  42632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42633. }
  42634. m.SetAllowList(v)
  42635. return nil
  42636. case wx.FieldGroupAllowList:
  42637. v, ok := value.([]string)
  42638. if !ok {
  42639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42640. }
  42641. m.SetGroupAllowList(v)
  42642. return nil
  42643. case wx.FieldBlockList:
  42644. v, ok := value.([]string)
  42645. if !ok {
  42646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42647. }
  42648. m.SetBlockList(v)
  42649. return nil
  42650. case wx.FieldGroupBlockList:
  42651. v, ok := value.([]string)
  42652. if !ok {
  42653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42654. }
  42655. m.SetGroupBlockList(v)
  42656. return nil
  42657. case wx.FieldCtype:
  42658. v, ok := value.(uint64)
  42659. if !ok {
  42660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42661. }
  42662. m.SetCtype(v)
  42663. return nil
  42664. }
  42665. return fmt.Errorf("unknown Wx field %s", name)
  42666. }
  42667. // AddedFields returns all numeric fields that were incremented/decremented during
  42668. // this mutation.
  42669. func (m *WxMutation) AddedFields() []string {
  42670. var fields []string
  42671. if m.addstatus != nil {
  42672. fields = append(fields, wx.FieldStatus)
  42673. }
  42674. if m.addorganization_id != nil {
  42675. fields = append(fields, wx.FieldOrganizationID)
  42676. }
  42677. if m.addctype != nil {
  42678. fields = append(fields, wx.FieldCtype)
  42679. }
  42680. return fields
  42681. }
  42682. // AddedField returns the numeric value that was incremented/decremented on a field
  42683. // with the given name. The second boolean return value indicates that this field
  42684. // was not set, or was not defined in the schema.
  42685. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  42686. switch name {
  42687. case wx.FieldStatus:
  42688. return m.AddedStatus()
  42689. case wx.FieldOrganizationID:
  42690. return m.AddedOrganizationID()
  42691. case wx.FieldCtype:
  42692. return m.AddedCtype()
  42693. }
  42694. return nil, false
  42695. }
  42696. // AddField adds the value to the field with the given name. It returns an error if
  42697. // the field is not defined in the schema, or if the type mismatched the field
  42698. // type.
  42699. func (m *WxMutation) AddField(name string, value ent.Value) error {
  42700. switch name {
  42701. case wx.FieldStatus:
  42702. v, ok := value.(int8)
  42703. if !ok {
  42704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42705. }
  42706. m.AddStatus(v)
  42707. return nil
  42708. case wx.FieldOrganizationID:
  42709. v, ok := value.(int64)
  42710. if !ok {
  42711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42712. }
  42713. m.AddOrganizationID(v)
  42714. return nil
  42715. case wx.FieldCtype:
  42716. v, ok := value.(int64)
  42717. if !ok {
  42718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  42719. }
  42720. m.AddCtype(v)
  42721. return nil
  42722. }
  42723. return fmt.Errorf("unknown Wx numeric field %s", name)
  42724. }
  42725. // ClearedFields returns all nullable fields that were cleared during this
  42726. // mutation.
  42727. func (m *WxMutation) ClearedFields() []string {
  42728. var fields []string
  42729. if m.FieldCleared(wx.FieldStatus) {
  42730. fields = append(fields, wx.FieldStatus)
  42731. }
  42732. if m.FieldCleared(wx.FieldDeletedAt) {
  42733. fields = append(fields, wx.FieldDeletedAt)
  42734. }
  42735. if m.FieldCleared(wx.FieldServerID) {
  42736. fields = append(fields, wx.FieldServerID)
  42737. }
  42738. if m.FieldCleared(wx.FieldOrganizationID) {
  42739. fields = append(fields, wx.FieldOrganizationID)
  42740. }
  42741. if m.FieldCleared(wx.FieldAPIBase) {
  42742. fields = append(fields, wx.FieldAPIBase)
  42743. }
  42744. if m.FieldCleared(wx.FieldAPIKey) {
  42745. fields = append(fields, wx.FieldAPIKey)
  42746. }
  42747. if m.FieldCleared(wx.FieldCtype) {
  42748. fields = append(fields, wx.FieldCtype)
  42749. }
  42750. return fields
  42751. }
  42752. // FieldCleared returns a boolean indicating if a field with the given name was
  42753. // cleared in this mutation.
  42754. func (m *WxMutation) FieldCleared(name string) bool {
  42755. _, ok := m.clearedFields[name]
  42756. return ok
  42757. }
  42758. // ClearField clears the value of the field with the given name. It returns an
  42759. // error if the field is not defined in the schema.
  42760. func (m *WxMutation) ClearField(name string) error {
  42761. switch name {
  42762. case wx.FieldStatus:
  42763. m.ClearStatus()
  42764. return nil
  42765. case wx.FieldDeletedAt:
  42766. m.ClearDeletedAt()
  42767. return nil
  42768. case wx.FieldServerID:
  42769. m.ClearServerID()
  42770. return nil
  42771. case wx.FieldOrganizationID:
  42772. m.ClearOrganizationID()
  42773. return nil
  42774. case wx.FieldAPIBase:
  42775. m.ClearAPIBase()
  42776. return nil
  42777. case wx.FieldAPIKey:
  42778. m.ClearAPIKey()
  42779. return nil
  42780. case wx.FieldCtype:
  42781. m.ClearCtype()
  42782. return nil
  42783. }
  42784. return fmt.Errorf("unknown Wx nullable field %s", name)
  42785. }
  42786. // ResetField resets all changes in the mutation for the field with the given name.
  42787. // It returns an error if the field is not defined in the schema.
  42788. func (m *WxMutation) ResetField(name string) error {
  42789. switch name {
  42790. case wx.FieldCreatedAt:
  42791. m.ResetCreatedAt()
  42792. return nil
  42793. case wx.FieldUpdatedAt:
  42794. m.ResetUpdatedAt()
  42795. return nil
  42796. case wx.FieldStatus:
  42797. m.ResetStatus()
  42798. return nil
  42799. case wx.FieldDeletedAt:
  42800. m.ResetDeletedAt()
  42801. return nil
  42802. case wx.FieldServerID:
  42803. m.ResetServerID()
  42804. return nil
  42805. case wx.FieldPort:
  42806. m.ResetPort()
  42807. return nil
  42808. case wx.FieldProcessID:
  42809. m.ResetProcessID()
  42810. return nil
  42811. case wx.FieldCallback:
  42812. m.ResetCallback()
  42813. return nil
  42814. case wx.FieldWxid:
  42815. m.ResetWxid()
  42816. return nil
  42817. case wx.FieldAccount:
  42818. m.ResetAccount()
  42819. return nil
  42820. case wx.FieldNickname:
  42821. m.ResetNickname()
  42822. return nil
  42823. case wx.FieldTel:
  42824. m.ResetTel()
  42825. return nil
  42826. case wx.FieldHeadBig:
  42827. m.ResetHeadBig()
  42828. return nil
  42829. case wx.FieldOrganizationID:
  42830. m.ResetOrganizationID()
  42831. return nil
  42832. case wx.FieldAgentID:
  42833. m.ResetAgentID()
  42834. return nil
  42835. case wx.FieldAPIBase:
  42836. m.ResetAPIBase()
  42837. return nil
  42838. case wx.FieldAPIKey:
  42839. m.ResetAPIKey()
  42840. return nil
  42841. case wx.FieldAllowList:
  42842. m.ResetAllowList()
  42843. return nil
  42844. case wx.FieldGroupAllowList:
  42845. m.ResetGroupAllowList()
  42846. return nil
  42847. case wx.FieldBlockList:
  42848. m.ResetBlockList()
  42849. return nil
  42850. case wx.FieldGroupBlockList:
  42851. m.ResetGroupBlockList()
  42852. return nil
  42853. case wx.FieldCtype:
  42854. m.ResetCtype()
  42855. return nil
  42856. }
  42857. return fmt.Errorf("unknown Wx field %s", name)
  42858. }
  42859. // AddedEdges returns all edge names that were set/added in this mutation.
  42860. func (m *WxMutation) AddedEdges() []string {
  42861. edges := make([]string, 0, 2)
  42862. if m.server != nil {
  42863. edges = append(edges, wx.EdgeServer)
  42864. }
  42865. if m.agent != nil {
  42866. edges = append(edges, wx.EdgeAgent)
  42867. }
  42868. return edges
  42869. }
  42870. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42871. // name in this mutation.
  42872. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  42873. switch name {
  42874. case wx.EdgeServer:
  42875. if id := m.server; id != nil {
  42876. return []ent.Value{*id}
  42877. }
  42878. case wx.EdgeAgent:
  42879. if id := m.agent; id != nil {
  42880. return []ent.Value{*id}
  42881. }
  42882. }
  42883. return nil
  42884. }
  42885. // RemovedEdges returns all edge names that were removed in this mutation.
  42886. func (m *WxMutation) RemovedEdges() []string {
  42887. edges := make([]string, 0, 2)
  42888. return edges
  42889. }
  42890. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42891. // the given name in this mutation.
  42892. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  42893. return nil
  42894. }
  42895. // ClearedEdges returns all edge names that were cleared in this mutation.
  42896. func (m *WxMutation) ClearedEdges() []string {
  42897. edges := make([]string, 0, 2)
  42898. if m.clearedserver {
  42899. edges = append(edges, wx.EdgeServer)
  42900. }
  42901. if m.clearedagent {
  42902. edges = append(edges, wx.EdgeAgent)
  42903. }
  42904. return edges
  42905. }
  42906. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42907. // was cleared in this mutation.
  42908. func (m *WxMutation) EdgeCleared(name string) bool {
  42909. switch name {
  42910. case wx.EdgeServer:
  42911. return m.clearedserver
  42912. case wx.EdgeAgent:
  42913. return m.clearedagent
  42914. }
  42915. return false
  42916. }
  42917. // ClearEdge clears the value of the edge with the given name. It returns an error
  42918. // if that edge is not defined in the schema.
  42919. func (m *WxMutation) ClearEdge(name string) error {
  42920. switch name {
  42921. case wx.EdgeServer:
  42922. m.ClearServer()
  42923. return nil
  42924. case wx.EdgeAgent:
  42925. m.ClearAgent()
  42926. return nil
  42927. }
  42928. return fmt.Errorf("unknown Wx unique edge %s", name)
  42929. }
  42930. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42931. // It returns an error if the edge is not defined in the schema.
  42932. func (m *WxMutation) ResetEdge(name string) error {
  42933. switch name {
  42934. case wx.EdgeServer:
  42935. m.ResetServer()
  42936. return nil
  42937. case wx.EdgeAgent:
  42938. m.ResetAgent()
  42939. return nil
  42940. }
  42941. return fmt.Errorf("unknown Wx edge %s", name)
  42942. }
  42943. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  42944. type WxCardMutation struct {
  42945. config
  42946. op Op
  42947. typ string
  42948. id *uint64
  42949. created_at *time.Time
  42950. updated_at *time.Time
  42951. deleted_at *time.Time
  42952. user_id *uint64
  42953. adduser_id *int64
  42954. wx_user_id *uint64
  42955. addwx_user_id *int64
  42956. avatar *string
  42957. logo *string
  42958. name *string
  42959. company *string
  42960. address *string
  42961. phone *string
  42962. official_account *string
  42963. wechat_account *string
  42964. email *string
  42965. api_base *string
  42966. api_key *string
  42967. ai_info *string
  42968. intro *string
  42969. clearedFields map[string]struct{}
  42970. done bool
  42971. oldValue func(context.Context) (*WxCard, error)
  42972. predicates []predicate.WxCard
  42973. }
  42974. var _ ent.Mutation = (*WxCardMutation)(nil)
  42975. // wxcardOption allows management of the mutation configuration using functional options.
  42976. type wxcardOption func(*WxCardMutation)
  42977. // newWxCardMutation creates new mutation for the WxCard entity.
  42978. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  42979. m := &WxCardMutation{
  42980. config: c,
  42981. op: op,
  42982. typ: TypeWxCard,
  42983. clearedFields: make(map[string]struct{}),
  42984. }
  42985. for _, opt := range opts {
  42986. opt(m)
  42987. }
  42988. return m
  42989. }
  42990. // withWxCardID sets the ID field of the mutation.
  42991. func withWxCardID(id uint64) wxcardOption {
  42992. return func(m *WxCardMutation) {
  42993. var (
  42994. err error
  42995. once sync.Once
  42996. value *WxCard
  42997. )
  42998. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  42999. once.Do(func() {
  43000. if m.done {
  43001. err = errors.New("querying old values post mutation is not allowed")
  43002. } else {
  43003. value, err = m.Client().WxCard.Get(ctx, id)
  43004. }
  43005. })
  43006. return value, err
  43007. }
  43008. m.id = &id
  43009. }
  43010. }
  43011. // withWxCard sets the old WxCard of the mutation.
  43012. func withWxCard(node *WxCard) wxcardOption {
  43013. return func(m *WxCardMutation) {
  43014. m.oldValue = func(context.Context) (*WxCard, error) {
  43015. return node, nil
  43016. }
  43017. m.id = &node.ID
  43018. }
  43019. }
  43020. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43021. // executed in a transaction (ent.Tx), a transactional client is returned.
  43022. func (m WxCardMutation) Client() *Client {
  43023. client := &Client{config: m.config}
  43024. client.init()
  43025. return client
  43026. }
  43027. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43028. // it returns an error otherwise.
  43029. func (m WxCardMutation) Tx() (*Tx, error) {
  43030. if _, ok := m.driver.(*txDriver); !ok {
  43031. return nil, errors.New("ent: mutation is not running in a transaction")
  43032. }
  43033. tx := &Tx{config: m.config}
  43034. tx.init()
  43035. return tx, nil
  43036. }
  43037. // SetID sets the value of the id field. Note that this
  43038. // operation is only accepted on creation of WxCard entities.
  43039. func (m *WxCardMutation) SetID(id uint64) {
  43040. m.id = &id
  43041. }
  43042. // ID returns the ID value in the mutation. Note that the ID is only available
  43043. // if it was provided to the builder or after it was returned from the database.
  43044. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  43045. if m.id == nil {
  43046. return
  43047. }
  43048. return *m.id, true
  43049. }
  43050. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43051. // That means, if the mutation is applied within a transaction with an isolation level such
  43052. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43053. // or updated by the mutation.
  43054. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  43055. switch {
  43056. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43057. id, exists := m.ID()
  43058. if exists {
  43059. return []uint64{id}, nil
  43060. }
  43061. fallthrough
  43062. case m.op.Is(OpUpdate | OpDelete):
  43063. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  43064. default:
  43065. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43066. }
  43067. }
  43068. // SetCreatedAt sets the "created_at" field.
  43069. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  43070. m.created_at = &t
  43071. }
  43072. // CreatedAt returns the value of the "created_at" field in the mutation.
  43073. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  43074. v := m.created_at
  43075. if v == nil {
  43076. return
  43077. }
  43078. return *v, true
  43079. }
  43080. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  43081. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43083. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43084. if !m.op.Is(OpUpdateOne) {
  43085. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43086. }
  43087. if m.id == nil || m.oldValue == nil {
  43088. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43089. }
  43090. oldValue, err := m.oldValue(ctx)
  43091. if err != nil {
  43092. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43093. }
  43094. return oldValue.CreatedAt, nil
  43095. }
  43096. // ResetCreatedAt resets all changes to the "created_at" field.
  43097. func (m *WxCardMutation) ResetCreatedAt() {
  43098. m.created_at = nil
  43099. }
  43100. // SetUpdatedAt sets the "updated_at" field.
  43101. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  43102. m.updated_at = &t
  43103. }
  43104. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43105. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  43106. v := m.updated_at
  43107. if v == nil {
  43108. return
  43109. }
  43110. return *v, true
  43111. }
  43112. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  43113. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43115. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43116. if !m.op.Is(OpUpdateOne) {
  43117. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43118. }
  43119. if m.id == nil || m.oldValue == nil {
  43120. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43121. }
  43122. oldValue, err := m.oldValue(ctx)
  43123. if err != nil {
  43124. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43125. }
  43126. return oldValue.UpdatedAt, nil
  43127. }
  43128. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43129. func (m *WxCardMutation) ResetUpdatedAt() {
  43130. m.updated_at = nil
  43131. }
  43132. // SetDeletedAt sets the "deleted_at" field.
  43133. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  43134. m.deleted_at = &t
  43135. }
  43136. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43137. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  43138. v := m.deleted_at
  43139. if v == nil {
  43140. return
  43141. }
  43142. return *v, true
  43143. }
  43144. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  43145. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43147. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43148. if !m.op.Is(OpUpdateOne) {
  43149. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43150. }
  43151. if m.id == nil || m.oldValue == nil {
  43152. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43153. }
  43154. oldValue, err := m.oldValue(ctx)
  43155. if err != nil {
  43156. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43157. }
  43158. return oldValue.DeletedAt, nil
  43159. }
  43160. // ClearDeletedAt clears the value of the "deleted_at" field.
  43161. func (m *WxCardMutation) ClearDeletedAt() {
  43162. m.deleted_at = nil
  43163. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  43164. }
  43165. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43166. func (m *WxCardMutation) DeletedAtCleared() bool {
  43167. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  43168. return ok
  43169. }
  43170. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43171. func (m *WxCardMutation) ResetDeletedAt() {
  43172. m.deleted_at = nil
  43173. delete(m.clearedFields, wxcard.FieldDeletedAt)
  43174. }
  43175. // SetUserID sets the "user_id" field.
  43176. func (m *WxCardMutation) SetUserID(u uint64) {
  43177. m.user_id = &u
  43178. m.adduser_id = nil
  43179. }
  43180. // UserID returns the value of the "user_id" field in the mutation.
  43181. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  43182. v := m.user_id
  43183. if v == nil {
  43184. return
  43185. }
  43186. return *v, true
  43187. }
  43188. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  43189. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43191. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  43192. if !m.op.Is(OpUpdateOne) {
  43193. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  43194. }
  43195. if m.id == nil || m.oldValue == nil {
  43196. return v, errors.New("OldUserID requires an ID field in the mutation")
  43197. }
  43198. oldValue, err := m.oldValue(ctx)
  43199. if err != nil {
  43200. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  43201. }
  43202. return oldValue.UserID, nil
  43203. }
  43204. // AddUserID adds u to the "user_id" field.
  43205. func (m *WxCardMutation) AddUserID(u int64) {
  43206. if m.adduser_id != nil {
  43207. *m.adduser_id += u
  43208. } else {
  43209. m.adduser_id = &u
  43210. }
  43211. }
  43212. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  43213. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  43214. v := m.adduser_id
  43215. if v == nil {
  43216. return
  43217. }
  43218. return *v, true
  43219. }
  43220. // ClearUserID clears the value of the "user_id" field.
  43221. func (m *WxCardMutation) ClearUserID() {
  43222. m.user_id = nil
  43223. m.adduser_id = nil
  43224. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  43225. }
  43226. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  43227. func (m *WxCardMutation) UserIDCleared() bool {
  43228. _, ok := m.clearedFields[wxcard.FieldUserID]
  43229. return ok
  43230. }
  43231. // ResetUserID resets all changes to the "user_id" field.
  43232. func (m *WxCardMutation) ResetUserID() {
  43233. m.user_id = nil
  43234. m.adduser_id = nil
  43235. delete(m.clearedFields, wxcard.FieldUserID)
  43236. }
  43237. // SetWxUserID sets the "wx_user_id" field.
  43238. func (m *WxCardMutation) SetWxUserID(u uint64) {
  43239. m.wx_user_id = &u
  43240. m.addwx_user_id = nil
  43241. }
  43242. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  43243. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  43244. v := m.wx_user_id
  43245. if v == nil {
  43246. return
  43247. }
  43248. return *v, true
  43249. }
  43250. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  43251. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43253. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  43254. if !m.op.Is(OpUpdateOne) {
  43255. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  43256. }
  43257. if m.id == nil || m.oldValue == nil {
  43258. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  43259. }
  43260. oldValue, err := m.oldValue(ctx)
  43261. if err != nil {
  43262. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  43263. }
  43264. return oldValue.WxUserID, nil
  43265. }
  43266. // AddWxUserID adds u to the "wx_user_id" field.
  43267. func (m *WxCardMutation) AddWxUserID(u int64) {
  43268. if m.addwx_user_id != nil {
  43269. *m.addwx_user_id += u
  43270. } else {
  43271. m.addwx_user_id = &u
  43272. }
  43273. }
  43274. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  43275. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  43276. v := m.addwx_user_id
  43277. if v == nil {
  43278. return
  43279. }
  43280. return *v, true
  43281. }
  43282. // ClearWxUserID clears the value of the "wx_user_id" field.
  43283. func (m *WxCardMutation) ClearWxUserID() {
  43284. m.wx_user_id = nil
  43285. m.addwx_user_id = nil
  43286. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  43287. }
  43288. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  43289. func (m *WxCardMutation) WxUserIDCleared() bool {
  43290. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  43291. return ok
  43292. }
  43293. // ResetWxUserID resets all changes to the "wx_user_id" field.
  43294. func (m *WxCardMutation) ResetWxUserID() {
  43295. m.wx_user_id = nil
  43296. m.addwx_user_id = nil
  43297. delete(m.clearedFields, wxcard.FieldWxUserID)
  43298. }
  43299. // SetAvatar sets the "avatar" field.
  43300. func (m *WxCardMutation) SetAvatar(s string) {
  43301. m.avatar = &s
  43302. }
  43303. // Avatar returns the value of the "avatar" field in the mutation.
  43304. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  43305. v := m.avatar
  43306. if v == nil {
  43307. return
  43308. }
  43309. return *v, true
  43310. }
  43311. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  43312. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43314. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  43315. if !m.op.Is(OpUpdateOne) {
  43316. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  43317. }
  43318. if m.id == nil || m.oldValue == nil {
  43319. return v, errors.New("OldAvatar requires an ID field in the mutation")
  43320. }
  43321. oldValue, err := m.oldValue(ctx)
  43322. if err != nil {
  43323. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  43324. }
  43325. return oldValue.Avatar, nil
  43326. }
  43327. // ResetAvatar resets all changes to the "avatar" field.
  43328. func (m *WxCardMutation) ResetAvatar() {
  43329. m.avatar = nil
  43330. }
  43331. // SetLogo sets the "logo" field.
  43332. func (m *WxCardMutation) SetLogo(s string) {
  43333. m.logo = &s
  43334. }
  43335. // Logo returns the value of the "logo" field in the mutation.
  43336. func (m *WxCardMutation) Logo() (r string, exists bool) {
  43337. v := m.logo
  43338. if v == nil {
  43339. return
  43340. }
  43341. return *v, true
  43342. }
  43343. // OldLogo returns the old "logo" field's value of the WxCard entity.
  43344. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43346. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  43347. if !m.op.Is(OpUpdateOne) {
  43348. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  43349. }
  43350. if m.id == nil || m.oldValue == nil {
  43351. return v, errors.New("OldLogo requires an ID field in the mutation")
  43352. }
  43353. oldValue, err := m.oldValue(ctx)
  43354. if err != nil {
  43355. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  43356. }
  43357. return oldValue.Logo, nil
  43358. }
  43359. // ResetLogo resets all changes to the "logo" field.
  43360. func (m *WxCardMutation) ResetLogo() {
  43361. m.logo = nil
  43362. }
  43363. // SetName sets the "name" field.
  43364. func (m *WxCardMutation) SetName(s string) {
  43365. m.name = &s
  43366. }
  43367. // Name returns the value of the "name" field in the mutation.
  43368. func (m *WxCardMutation) Name() (r string, exists bool) {
  43369. v := m.name
  43370. if v == nil {
  43371. return
  43372. }
  43373. return *v, true
  43374. }
  43375. // OldName returns the old "name" field's value of the WxCard entity.
  43376. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43378. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  43379. if !m.op.Is(OpUpdateOne) {
  43380. return v, errors.New("OldName is only allowed on UpdateOne operations")
  43381. }
  43382. if m.id == nil || m.oldValue == nil {
  43383. return v, errors.New("OldName requires an ID field in the mutation")
  43384. }
  43385. oldValue, err := m.oldValue(ctx)
  43386. if err != nil {
  43387. return v, fmt.Errorf("querying old value for OldName: %w", err)
  43388. }
  43389. return oldValue.Name, nil
  43390. }
  43391. // ResetName resets all changes to the "name" field.
  43392. func (m *WxCardMutation) ResetName() {
  43393. m.name = nil
  43394. }
  43395. // SetCompany sets the "company" field.
  43396. func (m *WxCardMutation) SetCompany(s string) {
  43397. m.company = &s
  43398. }
  43399. // Company returns the value of the "company" field in the mutation.
  43400. func (m *WxCardMutation) Company() (r string, exists bool) {
  43401. v := m.company
  43402. if v == nil {
  43403. return
  43404. }
  43405. return *v, true
  43406. }
  43407. // OldCompany returns the old "company" field's value of the WxCard entity.
  43408. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43410. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  43411. if !m.op.Is(OpUpdateOne) {
  43412. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  43413. }
  43414. if m.id == nil || m.oldValue == nil {
  43415. return v, errors.New("OldCompany requires an ID field in the mutation")
  43416. }
  43417. oldValue, err := m.oldValue(ctx)
  43418. if err != nil {
  43419. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  43420. }
  43421. return oldValue.Company, nil
  43422. }
  43423. // ResetCompany resets all changes to the "company" field.
  43424. func (m *WxCardMutation) ResetCompany() {
  43425. m.company = nil
  43426. }
  43427. // SetAddress sets the "address" field.
  43428. func (m *WxCardMutation) SetAddress(s string) {
  43429. m.address = &s
  43430. }
  43431. // Address returns the value of the "address" field in the mutation.
  43432. func (m *WxCardMutation) Address() (r string, exists bool) {
  43433. v := m.address
  43434. if v == nil {
  43435. return
  43436. }
  43437. return *v, true
  43438. }
  43439. // OldAddress returns the old "address" field's value of the WxCard entity.
  43440. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43442. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  43443. if !m.op.Is(OpUpdateOne) {
  43444. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  43445. }
  43446. if m.id == nil || m.oldValue == nil {
  43447. return v, errors.New("OldAddress requires an ID field in the mutation")
  43448. }
  43449. oldValue, err := m.oldValue(ctx)
  43450. if err != nil {
  43451. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  43452. }
  43453. return oldValue.Address, nil
  43454. }
  43455. // ResetAddress resets all changes to the "address" field.
  43456. func (m *WxCardMutation) ResetAddress() {
  43457. m.address = nil
  43458. }
  43459. // SetPhone sets the "phone" field.
  43460. func (m *WxCardMutation) SetPhone(s string) {
  43461. m.phone = &s
  43462. }
  43463. // Phone returns the value of the "phone" field in the mutation.
  43464. func (m *WxCardMutation) Phone() (r string, exists bool) {
  43465. v := m.phone
  43466. if v == nil {
  43467. return
  43468. }
  43469. return *v, true
  43470. }
  43471. // OldPhone returns the old "phone" field's value of the WxCard entity.
  43472. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43474. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  43475. if !m.op.Is(OpUpdateOne) {
  43476. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  43477. }
  43478. if m.id == nil || m.oldValue == nil {
  43479. return v, errors.New("OldPhone requires an ID field in the mutation")
  43480. }
  43481. oldValue, err := m.oldValue(ctx)
  43482. if err != nil {
  43483. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  43484. }
  43485. return oldValue.Phone, nil
  43486. }
  43487. // ResetPhone resets all changes to the "phone" field.
  43488. func (m *WxCardMutation) ResetPhone() {
  43489. m.phone = nil
  43490. }
  43491. // SetOfficialAccount sets the "official_account" field.
  43492. func (m *WxCardMutation) SetOfficialAccount(s string) {
  43493. m.official_account = &s
  43494. }
  43495. // OfficialAccount returns the value of the "official_account" field in the mutation.
  43496. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  43497. v := m.official_account
  43498. if v == nil {
  43499. return
  43500. }
  43501. return *v, true
  43502. }
  43503. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  43504. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43506. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  43507. if !m.op.Is(OpUpdateOne) {
  43508. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  43509. }
  43510. if m.id == nil || m.oldValue == nil {
  43511. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  43512. }
  43513. oldValue, err := m.oldValue(ctx)
  43514. if err != nil {
  43515. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  43516. }
  43517. return oldValue.OfficialAccount, nil
  43518. }
  43519. // ResetOfficialAccount resets all changes to the "official_account" field.
  43520. func (m *WxCardMutation) ResetOfficialAccount() {
  43521. m.official_account = nil
  43522. }
  43523. // SetWechatAccount sets the "wechat_account" field.
  43524. func (m *WxCardMutation) SetWechatAccount(s string) {
  43525. m.wechat_account = &s
  43526. }
  43527. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  43528. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  43529. v := m.wechat_account
  43530. if v == nil {
  43531. return
  43532. }
  43533. return *v, true
  43534. }
  43535. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  43536. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43538. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  43539. if !m.op.Is(OpUpdateOne) {
  43540. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  43541. }
  43542. if m.id == nil || m.oldValue == nil {
  43543. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  43544. }
  43545. oldValue, err := m.oldValue(ctx)
  43546. if err != nil {
  43547. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  43548. }
  43549. return oldValue.WechatAccount, nil
  43550. }
  43551. // ResetWechatAccount resets all changes to the "wechat_account" field.
  43552. func (m *WxCardMutation) ResetWechatAccount() {
  43553. m.wechat_account = nil
  43554. }
  43555. // SetEmail sets the "email" field.
  43556. func (m *WxCardMutation) SetEmail(s string) {
  43557. m.email = &s
  43558. }
  43559. // Email returns the value of the "email" field in the mutation.
  43560. func (m *WxCardMutation) Email() (r string, exists bool) {
  43561. v := m.email
  43562. if v == nil {
  43563. return
  43564. }
  43565. return *v, true
  43566. }
  43567. // OldEmail returns the old "email" field's value of the WxCard entity.
  43568. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43570. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  43571. if !m.op.Is(OpUpdateOne) {
  43572. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  43573. }
  43574. if m.id == nil || m.oldValue == nil {
  43575. return v, errors.New("OldEmail requires an ID field in the mutation")
  43576. }
  43577. oldValue, err := m.oldValue(ctx)
  43578. if err != nil {
  43579. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  43580. }
  43581. return oldValue.Email, nil
  43582. }
  43583. // ClearEmail clears the value of the "email" field.
  43584. func (m *WxCardMutation) ClearEmail() {
  43585. m.email = nil
  43586. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  43587. }
  43588. // EmailCleared returns if the "email" field was cleared in this mutation.
  43589. func (m *WxCardMutation) EmailCleared() bool {
  43590. _, ok := m.clearedFields[wxcard.FieldEmail]
  43591. return ok
  43592. }
  43593. // ResetEmail resets all changes to the "email" field.
  43594. func (m *WxCardMutation) ResetEmail() {
  43595. m.email = nil
  43596. delete(m.clearedFields, wxcard.FieldEmail)
  43597. }
  43598. // SetAPIBase sets the "api_base" field.
  43599. func (m *WxCardMutation) SetAPIBase(s string) {
  43600. m.api_base = &s
  43601. }
  43602. // APIBase returns the value of the "api_base" field in the mutation.
  43603. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  43604. v := m.api_base
  43605. if v == nil {
  43606. return
  43607. }
  43608. return *v, true
  43609. }
  43610. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  43611. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43613. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  43614. if !m.op.Is(OpUpdateOne) {
  43615. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  43616. }
  43617. if m.id == nil || m.oldValue == nil {
  43618. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  43619. }
  43620. oldValue, err := m.oldValue(ctx)
  43621. if err != nil {
  43622. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  43623. }
  43624. return oldValue.APIBase, nil
  43625. }
  43626. // ClearAPIBase clears the value of the "api_base" field.
  43627. func (m *WxCardMutation) ClearAPIBase() {
  43628. m.api_base = nil
  43629. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  43630. }
  43631. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  43632. func (m *WxCardMutation) APIBaseCleared() bool {
  43633. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  43634. return ok
  43635. }
  43636. // ResetAPIBase resets all changes to the "api_base" field.
  43637. func (m *WxCardMutation) ResetAPIBase() {
  43638. m.api_base = nil
  43639. delete(m.clearedFields, wxcard.FieldAPIBase)
  43640. }
  43641. // SetAPIKey sets the "api_key" field.
  43642. func (m *WxCardMutation) SetAPIKey(s string) {
  43643. m.api_key = &s
  43644. }
  43645. // APIKey returns the value of the "api_key" field in the mutation.
  43646. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  43647. v := m.api_key
  43648. if v == nil {
  43649. return
  43650. }
  43651. return *v, true
  43652. }
  43653. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  43654. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43656. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  43657. if !m.op.Is(OpUpdateOne) {
  43658. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  43659. }
  43660. if m.id == nil || m.oldValue == nil {
  43661. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  43662. }
  43663. oldValue, err := m.oldValue(ctx)
  43664. if err != nil {
  43665. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  43666. }
  43667. return oldValue.APIKey, nil
  43668. }
  43669. // ClearAPIKey clears the value of the "api_key" field.
  43670. func (m *WxCardMutation) ClearAPIKey() {
  43671. m.api_key = nil
  43672. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  43673. }
  43674. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  43675. func (m *WxCardMutation) APIKeyCleared() bool {
  43676. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  43677. return ok
  43678. }
  43679. // ResetAPIKey resets all changes to the "api_key" field.
  43680. func (m *WxCardMutation) ResetAPIKey() {
  43681. m.api_key = nil
  43682. delete(m.clearedFields, wxcard.FieldAPIKey)
  43683. }
  43684. // SetAiInfo sets the "ai_info" field.
  43685. func (m *WxCardMutation) SetAiInfo(s string) {
  43686. m.ai_info = &s
  43687. }
  43688. // AiInfo returns the value of the "ai_info" field in the mutation.
  43689. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  43690. v := m.ai_info
  43691. if v == nil {
  43692. return
  43693. }
  43694. return *v, true
  43695. }
  43696. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  43697. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43699. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  43700. if !m.op.Is(OpUpdateOne) {
  43701. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  43702. }
  43703. if m.id == nil || m.oldValue == nil {
  43704. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  43705. }
  43706. oldValue, err := m.oldValue(ctx)
  43707. if err != nil {
  43708. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  43709. }
  43710. return oldValue.AiInfo, nil
  43711. }
  43712. // ClearAiInfo clears the value of the "ai_info" field.
  43713. func (m *WxCardMutation) ClearAiInfo() {
  43714. m.ai_info = nil
  43715. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  43716. }
  43717. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  43718. func (m *WxCardMutation) AiInfoCleared() bool {
  43719. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  43720. return ok
  43721. }
  43722. // ResetAiInfo resets all changes to the "ai_info" field.
  43723. func (m *WxCardMutation) ResetAiInfo() {
  43724. m.ai_info = nil
  43725. delete(m.clearedFields, wxcard.FieldAiInfo)
  43726. }
  43727. // SetIntro sets the "intro" field.
  43728. func (m *WxCardMutation) SetIntro(s string) {
  43729. m.intro = &s
  43730. }
  43731. // Intro returns the value of the "intro" field in the mutation.
  43732. func (m *WxCardMutation) Intro() (r string, exists bool) {
  43733. v := m.intro
  43734. if v == nil {
  43735. return
  43736. }
  43737. return *v, true
  43738. }
  43739. // OldIntro returns the old "intro" field's value of the WxCard entity.
  43740. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43742. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  43743. if !m.op.Is(OpUpdateOne) {
  43744. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  43745. }
  43746. if m.id == nil || m.oldValue == nil {
  43747. return v, errors.New("OldIntro requires an ID field in the mutation")
  43748. }
  43749. oldValue, err := m.oldValue(ctx)
  43750. if err != nil {
  43751. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  43752. }
  43753. return oldValue.Intro, nil
  43754. }
  43755. // ClearIntro clears the value of the "intro" field.
  43756. func (m *WxCardMutation) ClearIntro() {
  43757. m.intro = nil
  43758. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  43759. }
  43760. // IntroCleared returns if the "intro" field was cleared in this mutation.
  43761. func (m *WxCardMutation) IntroCleared() bool {
  43762. _, ok := m.clearedFields[wxcard.FieldIntro]
  43763. return ok
  43764. }
  43765. // ResetIntro resets all changes to the "intro" field.
  43766. func (m *WxCardMutation) ResetIntro() {
  43767. m.intro = nil
  43768. delete(m.clearedFields, wxcard.FieldIntro)
  43769. }
  43770. // Where appends a list predicates to the WxCardMutation builder.
  43771. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  43772. m.predicates = append(m.predicates, ps...)
  43773. }
  43774. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  43775. // users can use type-assertion to append predicates that do not depend on any generated package.
  43776. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  43777. p := make([]predicate.WxCard, len(ps))
  43778. for i := range ps {
  43779. p[i] = ps[i]
  43780. }
  43781. m.Where(p...)
  43782. }
  43783. // Op returns the operation name.
  43784. func (m *WxCardMutation) Op() Op {
  43785. return m.op
  43786. }
  43787. // SetOp allows setting the mutation operation.
  43788. func (m *WxCardMutation) SetOp(op Op) {
  43789. m.op = op
  43790. }
  43791. // Type returns the node type of this mutation (WxCard).
  43792. func (m *WxCardMutation) Type() string {
  43793. return m.typ
  43794. }
  43795. // Fields returns all fields that were changed during this mutation. Note that in
  43796. // order to get all numeric fields that were incremented/decremented, call
  43797. // AddedFields().
  43798. func (m *WxCardMutation) Fields() []string {
  43799. fields := make([]string, 0, 18)
  43800. if m.created_at != nil {
  43801. fields = append(fields, wxcard.FieldCreatedAt)
  43802. }
  43803. if m.updated_at != nil {
  43804. fields = append(fields, wxcard.FieldUpdatedAt)
  43805. }
  43806. if m.deleted_at != nil {
  43807. fields = append(fields, wxcard.FieldDeletedAt)
  43808. }
  43809. if m.user_id != nil {
  43810. fields = append(fields, wxcard.FieldUserID)
  43811. }
  43812. if m.wx_user_id != nil {
  43813. fields = append(fields, wxcard.FieldWxUserID)
  43814. }
  43815. if m.avatar != nil {
  43816. fields = append(fields, wxcard.FieldAvatar)
  43817. }
  43818. if m.logo != nil {
  43819. fields = append(fields, wxcard.FieldLogo)
  43820. }
  43821. if m.name != nil {
  43822. fields = append(fields, wxcard.FieldName)
  43823. }
  43824. if m.company != nil {
  43825. fields = append(fields, wxcard.FieldCompany)
  43826. }
  43827. if m.address != nil {
  43828. fields = append(fields, wxcard.FieldAddress)
  43829. }
  43830. if m.phone != nil {
  43831. fields = append(fields, wxcard.FieldPhone)
  43832. }
  43833. if m.official_account != nil {
  43834. fields = append(fields, wxcard.FieldOfficialAccount)
  43835. }
  43836. if m.wechat_account != nil {
  43837. fields = append(fields, wxcard.FieldWechatAccount)
  43838. }
  43839. if m.email != nil {
  43840. fields = append(fields, wxcard.FieldEmail)
  43841. }
  43842. if m.api_base != nil {
  43843. fields = append(fields, wxcard.FieldAPIBase)
  43844. }
  43845. if m.api_key != nil {
  43846. fields = append(fields, wxcard.FieldAPIKey)
  43847. }
  43848. if m.ai_info != nil {
  43849. fields = append(fields, wxcard.FieldAiInfo)
  43850. }
  43851. if m.intro != nil {
  43852. fields = append(fields, wxcard.FieldIntro)
  43853. }
  43854. return fields
  43855. }
  43856. // Field returns the value of a field with the given name. The second boolean
  43857. // return value indicates that this field was not set, or was not defined in the
  43858. // schema.
  43859. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  43860. switch name {
  43861. case wxcard.FieldCreatedAt:
  43862. return m.CreatedAt()
  43863. case wxcard.FieldUpdatedAt:
  43864. return m.UpdatedAt()
  43865. case wxcard.FieldDeletedAt:
  43866. return m.DeletedAt()
  43867. case wxcard.FieldUserID:
  43868. return m.UserID()
  43869. case wxcard.FieldWxUserID:
  43870. return m.WxUserID()
  43871. case wxcard.FieldAvatar:
  43872. return m.Avatar()
  43873. case wxcard.FieldLogo:
  43874. return m.Logo()
  43875. case wxcard.FieldName:
  43876. return m.Name()
  43877. case wxcard.FieldCompany:
  43878. return m.Company()
  43879. case wxcard.FieldAddress:
  43880. return m.Address()
  43881. case wxcard.FieldPhone:
  43882. return m.Phone()
  43883. case wxcard.FieldOfficialAccount:
  43884. return m.OfficialAccount()
  43885. case wxcard.FieldWechatAccount:
  43886. return m.WechatAccount()
  43887. case wxcard.FieldEmail:
  43888. return m.Email()
  43889. case wxcard.FieldAPIBase:
  43890. return m.APIBase()
  43891. case wxcard.FieldAPIKey:
  43892. return m.APIKey()
  43893. case wxcard.FieldAiInfo:
  43894. return m.AiInfo()
  43895. case wxcard.FieldIntro:
  43896. return m.Intro()
  43897. }
  43898. return nil, false
  43899. }
  43900. // OldField returns the old value of the field from the database. An error is
  43901. // returned if the mutation operation is not UpdateOne, or the query to the
  43902. // database failed.
  43903. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43904. switch name {
  43905. case wxcard.FieldCreatedAt:
  43906. return m.OldCreatedAt(ctx)
  43907. case wxcard.FieldUpdatedAt:
  43908. return m.OldUpdatedAt(ctx)
  43909. case wxcard.FieldDeletedAt:
  43910. return m.OldDeletedAt(ctx)
  43911. case wxcard.FieldUserID:
  43912. return m.OldUserID(ctx)
  43913. case wxcard.FieldWxUserID:
  43914. return m.OldWxUserID(ctx)
  43915. case wxcard.FieldAvatar:
  43916. return m.OldAvatar(ctx)
  43917. case wxcard.FieldLogo:
  43918. return m.OldLogo(ctx)
  43919. case wxcard.FieldName:
  43920. return m.OldName(ctx)
  43921. case wxcard.FieldCompany:
  43922. return m.OldCompany(ctx)
  43923. case wxcard.FieldAddress:
  43924. return m.OldAddress(ctx)
  43925. case wxcard.FieldPhone:
  43926. return m.OldPhone(ctx)
  43927. case wxcard.FieldOfficialAccount:
  43928. return m.OldOfficialAccount(ctx)
  43929. case wxcard.FieldWechatAccount:
  43930. return m.OldWechatAccount(ctx)
  43931. case wxcard.FieldEmail:
  43932. return m.OldEmail(ctx)
  43933. case wxcard.FieldAPIBase:
  43934. return m.OldAPIBase(ctx)
  43935. case wxcard.FieldAPIKey:
  43936. return m.OldAPIKey(ctx)
  43937. case wxcard.FieldAiInfo:
  43938. return m.OldAiInfo(ctx)
  43939. case wxcard.FieldIntro:
  43940. return m.OldIntro(ctx)
  43941. }
  43942. return nil, fmt.Errorf("unknown WxCard field %s", name)
  43943. }
  43944. // SetField sets the value of a field with the given name. It returns an error if
  43945. // the field is not defined in the schema, or if the type mismatched the field
  43946. // type.
  43947. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  43948. switch name {
  43949. case wxcard.FieldCreatedAt:
  43950. v, ok := value.(time.Time)
  43951. if !ok {
  43952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43953. }
  43954. m.SetCreatedAt(v)
  43955. return nil
  43956. case wxcard.FieldUpdatedAt:
  43957. v, ok := value.(time.Time)
  43958. if !ok {
  43959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43960. }
  43961. m.SetUpdatedAt(v)
  43962. return nil
  43963. case wxcard.FieldDeletedAt:
  43964. v, ok := value.(time.Time)
  43965. if !ok {
  43966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43967. }
  43968. m.SetDeletedAt(v)
  43969. return nil
  43970. case wxcard.FieldUserID:
  43971. v, ok := value.(uint64)
  43972. if !ok {
  43973. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43974. }
  43975. m.SetUserID(v)
  43976. return nil
  43977. case wxcard.FieldWxUserID:
  43978. v, ok := value.(uint64)
  43979. if !ok {
  43980. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43981. }
  43982. m.SetWxUserID(v)
  43983. return nil
  43984. case wxcard.FieldAvatar:
  43985. v, ok := value.(string)
  43986. if !ok {
  43987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43988. }
  43989. m.SetAvatar(v)
  43990. return nil
  43991. case wxcard.FieldLogo:
  43992. v, ok := value.(string)
  43993. if !ok {
  43994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43995. }
  43996. m.SetLogo(v)
  43997. return nil
  43998. case wxcard.FieldName:
  43999. v, ok := value.(string)
  44000. if !ok {
  44001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44002. }
  44003. m.SetName(v)
  44004. return nil
  44005. case wxcard.FieldCompany:
  44006. v, ok := value.(string)
  44007. if !ok {
  44008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44009. }
  44010. m.SetCompany(v)
  44011. return nil
  44012. case wxcard.FieldAddress:
  44013. v, ok := value.(string)
  44014. if !ok {
  44015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44016. }
  44017. m.SetAddress(v)
  44018. return nil
  44019. case wxcard.FieldPhone:
  44020. v, ok := value.(string)
  44021. if !ok {
  44022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44023. }
  44024. m.SetPhone(v)
  44025. return nil
  44026. case wxcard.FieldOfficialAccount:
  44027. v, ok := value.(string)
  44028. if !ok {
  44029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44030. }
  44031. m.SetOfficialAccount(v)
  44032. return nil
  44033. case wxcard.FieldWechatAccount:
  44034. v, ok := value.(string)
  44035. if !ok {
  44036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44037. }
  44038. m.SetWechatAccount(v)
  44039. return nil
  44040. case wxcard.FieldEmail:
  44041. v, ok := value.(string)
  44042. if !ok {
  44043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44044. }
  44045. m.SetEmail(v)
  44046. return nil
  44047. case wxcard.FieldAPIBase:
  44048. v, ok := value.(string)
  44049. if !ok {
  44050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44051. }
  44052. m.SetAPIBase(v)
  44053. return nil
  44054. case wxcard.FieldAPIKey:
  44055. v, ok := value.(string)
  44056. if !ok {
  44057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44058. }
  44059. m.SetAPIKey(v)
  44060. return nil
  44061. case wxcard.FieldAiInfo:
  44062. v, ok := value.(string)
  44063. if !ok {
  44064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44065. }
  44066. m.SetAiInfo(v)
  44067. return nil
  44068. case wxcard.FieldIntro:
  44069. v, ok := value.(string)
  44070. if !ok {
  44071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44072. }
  44073. m.SetIntro(v)
  44074. return nil
  44075. }
  44076. return fmt.Errorf("unknown WxCard field %s", name)
  44077. }
  44078. // AddedFields returns all numeric fields that were incremented/decremented during
  44079. // this mutation.
  44080. func (m *WxCardMutation) AddedFields() []string {
  44081. var fields []string
  44082. if m.adduser_id != nil {
  44083. fields = append(fields, wxcard.FieldUserID)
  44084. }
  44085. if m.addwx_user_id != nil {
  44086. fields = append(fields, wxcard.FieldWxUserID)
  44087. }
  44088. return fields
  44089. }
  44090. // AddedField returns the numeric value that was incremented/decremented on a field
  44091. // with the given name. The second boolean return value indicates that this field
  44092. // was not set, or was not defined in the schema.
  44093. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  44094. switch name {
  44095. case wxcard.FieldUserID:
  44096. return m.AddedUserID()
  44097. case wxcard.FieldWxUserID:
  44098. return m.AddedWxUserID()
  44099. }
  44100. return nil, false
  44101. }
  44102. // AddField adds the value to the field with the given name. It returns an error if
  44103. // the field is not defined in the schema, or if the type mismatched the field
  44104. // type.
  44105. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  44106. switch name {
  44107. case wxcard.FieldUserID:
  44108. v, ok := value.(int64)
  44109. if !ok {
  44110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44111. }
  44112. m.AddUserID(v)
  44113. return nil
  44114. case wxcard.FieldWxUserID:
  44115. v, ok := value.(int64)
  44116. if !ok {
  44117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44118. }
  44119. m.AddWxUserID(v)
  44120. return nil
  44121. }
  44122. return fmt.Errorf("unknown WxCard numeric field %s", name)
  44123. }
  44124. // ClearedFields returns all nullable fields that were cleared during this
  44125. // mutation.
  44126. func (m *WxCardMutation) ClearedFields() []string {
  44127. var fields []string
  44128. if m.FieldCleared(wxcard.FieldDeletedAt) {
  44129. fields = append(fields, wxcard.FieldDeletedAt)
  44130. }
  44131. if m.FieldCleared(wxcard.FieldUserID) {
  44132. fields = append(fields, wxcard.FieldUserID)
  44133. }
  44134. if m.FieldCleared(wxcard.FieldWxUserID) {
  44135. fields = append(fields, wxcard.FieldWxUserID)
  44136. }
  44137. if m.FieldCleared(wxcard.FieldEmail) {
  44138. fields = append(fields, wxcard.FieldEmail)
  44139. }
  44140. if m.FieldCleared(wxcard.FieldAPIBase) {
  44141. fields = append(fields, wxcard.FieldAPIBase)
  44142. }
  44143. if m.FieldCleared(wxcard.FieldAPIKey) {
  44144. fields = append(fields, wxcard.FieldAPIKey)
  44145. }
  44146. if m.FieldCleared(wxcard.FieldAiInfo) {
  44147. fields = append(fields, wxcard.FieldAiInfo)
  44148. }
  44149. if m.FieldCleared(wxcard.FieldIntro) {
  44150. fields = append(fields, wxcard.FieldIntro)
  44151. }
  44152. return fields
  44153. }
  44154. // FieldCleared returns a boolean indicating if a field with the given name was
  44155. // cleared in this mutation.
  44156. func (m *WxCardMutation) FieldCleared(name string) bool {
  44157. _, ok := m.clearedFields[name]
  44158. return ok
  44159. }
  44160. // ClearField clears the value of the field with the given name. It returns an
  44161. // error if the field is not defined in the schema.
  44162. func (m *WxCardMutation) ClearField(name string) error {
  44163. switch name {
  44164. case wxcard.FieldDeletedAt:
  44165. m.ClearDeletedAt()
  44166. return nil
  44167. case wxcard.FieldUserID:
  44168. m.ClearUserID()
  44169. return nil
  44170. case wxcard.FieldWxUserID:
  44171. m.ClearWxUserID()
  44172. return nil
  44173. case wxcard.FieldEmail:
  44174. m.ClearEmail()
  44175. return nil
  44176. case wxcard.FieldAPIBase:
  44177. m.ClearAPIBase()
  44178. return nil
  44179. case wxcard.FieldAPIKey:
  44180. m.ClearAPIKey()
  44181. return nil
  44182. case wxcard.FieldAiInfo:
  44183. m.ClearAiInfo()
  44184. return nil
  44185. case wxcard.FieldIntro:
  44186. m.ClearIntro()
  44187. return nil
  44188. }
  44189. return fmt.Errorf("unknown WxCard nullable field %s", name)
  44190. }
  44191. // ResetField resets all changes in the mutation for the field with the given name.
  44192. // It returns an error if the field is not defined in the schema.
  44193. func (m *WxCardMutation) ResetField(name string) error {
  44194. switch name {
  44195. case wxcard.FieldCreatedAt:
  44196. m.ResetCreatedAt()
  44197. return nil
  44198. case wxcard.FieldUpdatedAt:
  44199. m.ResetUpdatedAt()
  44200. return nil
  44201. case wxcard.FieldDeletedAt:
  44202. m.ResetDeletedAt()
  44203. return nil
  44204. case wxcard.FieldUserID:
  44205. m.ResetUserID()
  44206. return nil
  44207. case wxcard.FieldWxUserID:
  44208. m.ResetWxUserID()
  44209. return nil
  44210. case wxcard.FieldAvatar:
  44211. m.ResetAvatar()
  44212. return nil
  44213. case wxcard.FieldLogo:
  44214. m.ResetLogo()
  44215. return nil
  44216. case wxcard.FieldName:
  44217. m.ResetName()
  44218. return nil
  44219. case wxcard.FieldCompany:
  44220. m.ResetCompany()
  44221. return nil
  44222. case wxcard.FieldAddress:
  44223. m.ResetAddress()
  44224. return nil
  44225. case wxcard.FieldPhone:
  44226. m.ResetPhone()
  44227. return nil
  44228. case wxcard.FieldOfficialAccount:
  44229. m.ResetOfficialAccount()
  44230. return nil
  44231. case wxcard.FieldWechatAccount:
  44232. m.ResetWechatAccount()
  44233. return nil
  44234. case wxcard.FieldEmail:
  44235. m.ResetEmail()
  44236. return nil
  44237. case wxcard.FieldAPIBase:
  44238. m.ResetAPIBase()
  44239. return nil
  44240. case wxcard.FieldAPIKey:
  44241. m.ResetAPIKey()
  44242. return nil
  44243. case wxcard.FieldAiInfo:
  44244. m.ResetAiInfo()
  44245. return nil
  44246. case wxcard.FieldIntro:
  44247. m.ResetIntro()
  44248. return nil
  44249. }
  44250. return fmt.Errorf("unknown WxCard field %s", name)
  44251. }
  44252. // AddedEdges returns all edge names that were set/added in this mutation.
  44253. func (m *WxCardMutation) AddedEdges() []string {
  44254. edges := make([]string, 0, 0)
  44255. return edges
  44256. }
  44257. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44258. // name in this mutation.
  44259. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  44260. return nil
  44261. }
  44262. // RemovedEdges returns all edge names that were removed in this mutation.
  44263. func (m *WxCardMutation) RemovedEdges() []string {
  44264. edges := make([]string, 0, 0)
  44265. return edges
  44266. }
  44267. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44268. // the given name in this mutation.
  44269. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  44270. return nil
  44271. }
  44272. // ClearedEdges returns all edge names that were cleared in this mutation.
  44273. func (m *WxCardMutation) ClearedEdges() []string {
  44274. edges := make([]string, 0, 0)
  44275. return edges
  44276. }
  44277. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44278. // was cleared in this mutation.
  44279. func (m *WxCardMutation) EdgeCleared(name string) bool {
  44280. return false
  44281. }
  44282. // ClearEdge clears the value of the edge with the given name. It returns an error
  44283. // if that edge is not defined in the schema.
  44284. func (m *WxCardMutation) ClearEdge(name string) error {
  44285. return fmt.Errorf("unknown WxCard unique edge %s", name)
  44286. }
  44287. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44288. // It returns an error if the edge is not defined in the schema.
  44289. func (m *WxCardMutation) ResetEdge(name string) error {
  44290. return fmt.Errorf("unknown WxCard edge %s", name)
  44291. }
  44292. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  44293. type WxCardUserMutation struct {
  44294. config
  44295. op Op
  44296. typ string
  44297. id *uint64
  44298. created_at *time.Time
  44299. updated_at *time.Time
  44300. deleted_at *time.Time
  44301. wxid *string
  44302. account *string
  44303. avatar *string
  44304. nickname *string
  44305. remark *string
  44306. phone *string
  44307. open_id *string
  44308. union_id *string
  44309. session_key *string
  44310. is_vip *int
  44311. addis_vip *int
  44312. clearedFields map[string]struct{}
  44313. done bool
  44314. oldValue func(context.Context) (*WxCardUser, error)
  44315. predicates []predicate.WxCardUser
  44316. }
  44317. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  44318. // wxcarduserOption allows management of the mutation configuration using functional options.
  44319. type wxcarduserOption func(*WxCardUserMutation)
  44320. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  44321. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  44322. m := &WxCardUserMutation{
  44323. config: c,
  44324. op: op,
  44325. typ: TypeWxCardUser,
  44326. clearedFields: make(map[string]struct{}),
  44327. }
  44328. for _, opt := range opts {
  44329. opt(m)
  44330. }
  44331. return m
  44332. }
  44333. // withWxCardUserID sets the ID field of the mutation.
  44334. func withWxCardUserID(id uint64) wxcarduserOption {
  44335. return func(m *WxCardUserMutation) {
  44336. var (
  44337. err error
  44338. once sync.Once
  44339. value *WxCardUser
  44340. )
  44341. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  44342. once.Do(func() {
  44343. if m.done {
  44344. err = errors.New("querying old values post mutation is not allowed")
  44345. } else {
  44346. value, err = m.Client().WxCardUser.Get(ctx, id)
  44347. }
  44348. })
  44349. return value, err
  44350. }
  44351. m.id = &id
  44352. }
  44353. }
  44354. // withWxCardUser sets the old WxCardUser of the mutation.
  44355. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  44356. return func(m *WxCardUserMutation) {
  44357. m.oldValue = func(context.Context) (*WxCardUser, error) {
  44358. return node, nil
  44359. }
  44360. m.id = &node.ID
  44361. }
  44362. }
  44363. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44364. // executed in a transaction (ent.Tx), a transactional client is returned.
  44365. func (m WxCardUserMutation) Client() *Client {
  44366. client := &Client{config: m.config}
  44367. client.init()
  44368. return client
  44369. }
  44370. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44371. // it returns an error otherwise.
  44372. func (m WxCardUserMutation) Tx() (*Tx, error) {
  44373. if _, ok := m.driver.(*txDriver); !ok {
  44374. return nil, errors.New("ent: mutation is not running in a transaction")
  44375. }
  44376. tx := &Tx{config: m.config}
  44377. tx.init()
  44378. return tx, nil
  44379. }
  44380. // SetID sets the value of the id field. Note that this
  44381. // operation is only accepted on creation of WxCardUser entities.
  44382. func (m *WxCardUserMutation) SetID(id uint64) {
  44383. m.id = &id
  44384. }
  44385. // ID returns the ID value in the mutation. Note that the ID is only available
  44386. // if it was provided to the builder or after it was returned from the database.
  44387. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  44388. if m.id == nil {
  44389. return
  44390. }
  44391. return *m.id, true
  44392. }
  44393. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44394. // That means, if the mutation is applied within a transaction with an isolation level such
  44395. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44396. // or updated by the mutation.
  44397. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  44398. switch {
  44399. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44400. id, exists := m.ID()
  44401. if exists {
  44402. return []uint64{id}, nil
  44403. }
  44404. fallthrough
  44405. case m.op.Is(OpUpdate | OpDelete):
  44406. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  44407. default:
  44408. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44409. }
  44410. }
  44411. // SetCreatedAt sets the "created_at" field.
  44412. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  44413. m.created_at = &t
  44414. }
  44415. // CreatedAt returns the value of the "created_at" field in the mutation.
  44416. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  44417. v := m.created_at
  44418. if v == nil {
  44419. return
  44420. }
  44421. return *v, true
  44422. }
  44423. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  44424. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44426. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44427. if !m.op.Is(OpUpdateOne) {
  44428. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44429. }
  44430. if m.id == nil || m.oldValue == nil {
  44431. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44432. }
  44433. oldValue, err := m.oldValue(ctx)
  44434. if err != nil {
  44435. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44436. }
  44437. return oldValue.CreatedAt, nil
  44438. }
  44439. // ResetCreatedAt resets all changes to the "created_at" field.
  44440. func (m *WxCardUserMutation) ResetCreatedAt() {
  44441. m.created_at = nil
  44442. }
  44443. // SetUpdatedAt sets the "updated_at" field.
  44444. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  44445. m.updated_at = &t
  44446. }
  44447. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44448. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  44449. v := m.updated_at
  44450. if v == nil {
  44451. return
  44452. }
  44453. return *v, true
  44454. }
  44455. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  44456. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44458. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44459. if !m.op.Is(OpUpdateOne) {
  44460. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44461. }
  44462. if m.id == nil || m.oldValue == nil {
  44463. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44464. }
  44465. oldValue, err := m.oldValue(ctx)
  44466. if err != nil {
  44467. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44468. }
  44469. return oldValue.UpdatedAt, nil
  44470. }
  44471. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44472. func (m *WxCardUserMutation) ResetUpdatedAt() {
  44473. m.updated_at = nil
  44474. }
  44475. // SetDeletedAt sets the "deleted_at" field.
  44476. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  44477. m.deleted_at = &t
  44478. }
  44479. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44480. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  44481. v := m.deleted_at
  44482. if v == nil {
  44483. return
  44484. }
  44485. return *v, true
  44486. }
  44487. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  44488. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44490. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44491. if !m.op.Is(OpUpdateOne) {
  44492. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44493. }
  44494. if m.id == nil || m.oldValue == nil {
  44495. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44496. }
  44497. oldValue, err := m.oldValue(ctx)
  44498. if err != nil {
  44499. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44500. }
  44501. return oldValue.DeletedAt, nil
  44502. }
  44503. // ClearDeletedAt clears the value of the "deleted_at" field.
  44504. func (m *WxCardUserMutation) ClearDeletedAt() {
  44505. m.deleted_at = nil
  44506. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  44507. }
  44508. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44509. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  44510. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  44511. return ok
  44512. }
  44513. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44514. func (m *WxCardUserMutation) ResetDeletedAt() {
  44515. m.deleted_at = nil
  44516. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  44517. }
  44518. // SetWxid sets the "wxid" field.
  44519. func (m *WxCardUserMutation) SetWxid(s string) {
  44520. m.wxid = &s
  44521. }
  44522. // Wxid returns the value of the "wxid" field in the mutation.
  44523. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  44524. v := m.wxid
  44525. if v == nil {
  44526. return
  44527. }
  44528. return *v, true
  44529. }
  44530. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  44531. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44533. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  44534. if !m.op.Is(OpUpdateOne) {
  44535. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  44536. }
  44537. if m.id == nil || m.oldValue == nil {
  44538. return v, errors.New("OldWxid requires an ID field in the mutation")
  44539. }
  44540. oldValue, err := m.oldValue(ctx)
  44541. if err != nil {
  44542. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  44543. }
  44544. return oldValue.Wxid, nil
  44545. }
  44546. // ResetWxid resets all changes to the "wxid" field.
  44547. func (m *WxCardUserMutation) ResetWxid() {
  44548. m.wxid = nil
  44549. }
  44550. // SetAccount sets the "account" field.
  44551. func (m *WxCardUserMutation) SetAccount(s string) {
  44552. m.account = &s
  44553. }
  44554. // Account returns the value of the "account" field in the mutation.
  44555. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  44556. v := m.account
  44557. if v == nil {
  44558. return
  44559. }
  44560. return *v, true
  44561. }
  44562. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  44563. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44565. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  44566. if !m.op.Is(OpUpdateOne) {
  44567. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  44568. }
  44569. if m.id == nil || m.oldValue == nil {
  44570. return v, errors.New("OldAccount requires an ID field in the mutation")
  44571. }
  44572. oldValue, err := m.oldValue(ctx)
  44573. if err != nil {
  44574. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  44575. }
  44576. return oldValue.Account, nil
  44577. }
  44578. // ResetAccount resets all changes to the "account" field.
  44579. func (m *WxCardUserMutation) ResetAccount() {
  44580. m.account = nil
  44581. }
  44582. // SetAvatar sets the "avatar" field.
  44583. func (m *WxCardUserMutation) SetAvatar(s string) {
  44584. m.avatar = &s
  44585. }
  44586. // Avatar returns the value of the "avatar" field in the mutation.
  44587. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  44588. v := m.avatar
  44589. if v == nil {
  44590. return
  44591. }
  44592. return *v, true
  44593. }
  44594. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  44595. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44597. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44598. if !m.op.Is(OpUpdateOne) {
  44599. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44600. }
  44601. if m.id == nil || m.oldValue == nil {
  44602. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44603. }
  44604. oldValue, err := m.oldValue(ctx)
  44605. if err != nil {
  44606. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44607. }
  44608. return oldValue.Avatar, nil
  44609. }
  44610. // ResetAvatar resets all changes to the "avatar" field.
  44611. func (m *WxCardUserMutation) ResetAvatar() {
  44612. m.avatar = nil
  44613. }
  44614. // SetNickname sets the "nickname" field.
  44615. func (m *WxCardUserMutation) SetNickname(s string) {
  44616. m.nickname = &s
  44617. }
  44618. // Nickname returns the value of the "nickname" field in the mutation.
  44619. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  44620. v := m.nickname
  44621. if v == nil {
  44622. return
  44623. }
  44624. return *v, true
  44625. }
  44626. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  44627. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44629. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  44630. if !m.op.Is(OpUpdateOne) {
  44631. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  44632. }
  44633. if m.id == nil || m.oldValue == nil {
  44634. return v, errors.New("OldNickname requires an ID field in the mutation")
  44635. }
  44636. oldValue, err := m.oldValue(ctx)
  44637. if err != nil {
  44638. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  44639. }
  44640. return oldValue.Nickname, nil
  44641. }
  44642. // ResetNickname resets all changes to the "nickname" field.
  44643. func (m *WxCardUserMutation) ResetNickname() {
  44644. m.nickname = nil
  44645. }
  44646. // SetRemark sets the "remark" field.
  44647. func (m *WxCardUserMutation) SetRemark(s string) {
  44648. m.remark = &s
  44649. }
  44650. // Remark returns the value of the "remark" field in the mutation.
  44651. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  44652. v := m.remark
  44653. if v == nil {
  44654. return
  44655. }
  44656. return *v, true
  44657. }
  44658. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  44659. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44661. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  44662. if !m.op.Is(OpUpdateOne) {
  44663. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  44664. }
  44665. if m.id == nil || m.oldValue == nil {
  44666. return v, errors.New("OldRemark requires an ID field in the mutation")
  44667. }
  44668. oldValue, err := m.oldValue(ctx)
  44669. if err != nil {
  44670. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  44671. }
  44672. return oldValue.Remark, nil
  44673. }
  44674. // ResetRemark resets all changes to the "remark" field.
  44675. func (m *WxCardUserMutation) ResetRemark() {
  44676. m.remark = nil
  44677. }
  44678. // SetPhone sets the "phone" field.
  44679. func (m *WxCardUserMutation) SetPhone(s string) {
  44680. m.phone = &s
  44681. }
  44682. // Phone returns the value of the "phone" field in the mutation.
  44683. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  44684. v := m.phone
  44685. if v == nil {
  44686. return
  44687. }
  44688. return *v, true
  44689. }
  44690. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  44691. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44693. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  44694. if !m.op.Is(OpUpdateOne) {
  44695. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44696. }
  44697. if m.id == nil || m.oldValue == nil {
  44698. return v, errors.New("OldPhone requires an ID field in the mutation")
  44699. }
  44700. oldValue, err := m.oldValue(ctx)
  44701. if err != nil {
  44702. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44703. }
  44704. return oldValue.Phone, nil
  44705. }
  44706. // ResetPhone resets all changes to the "phone" field.
  44707. func (m *WxCardUserMutation) ResetPhone() {
  44708. m.phone = nil
  44709. }
  44710. // SetOpenID sets the "open_id" field.
  44711. func (m *WxCardUserMutation) SetOpenID(s string) {
  44712. m.open_id = &s
  44713. }
  44714. // OpenID returns the value of the "open_id" field in the mutation.
  44715. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  44716. v := m.open_id
  44717. if v == nil {
  44718. return
  44719. }
  44720. return *v, true
  44721. }
  44722. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  44723. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44724. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44725. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  44726. if !m.op.Is(OpUpdateOne) {
  44727. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  44728. }
  44729. if m.id == nil || m.oldValue == nil {
  44730. return v, errors.New("OldOpenID requires an ID field in the mutation")
  44731. }
  44732. oldValue, err := m.oldValue(ctx)
  44733. if err != nil {
  44734. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  44735. }
  44736. return oldValue.OpenID, nil
  44737. }
  44738. // ResetOpenID resets all changes to the "open_id" field.
  44739. func (m *WxCardUserMutation) ResetOpenID() {
  44740. m.open_id = nil
  44741. }
  44742. // SetUnionID sets the "union_id" field.
  44743. func (m *WxCardUserMutation) SetUnionID(s string) {
  44744. m.union_id = &s
  44745. }
  44746. // UnionID returns the value of the "union_id" field in the mutation.
  44747. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  44748. v := m.union_id
  44749. if v == nil {
  44750. return
  44751. }
  44752. return *v, true
  44753. }
  44754. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  44755. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44757. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  44758. if !m.op.Is(OpUpdateOne) {
  44759. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  44760. }
  44761. if m.id == nil || m.oldValue == nil {
  44762. return v, errors.New("OldUnionID requires an ID field in the mutation")
  44763. }
  44764. oldValue, err := m.oldValue(ctx)
  44765. if err != nil {
  44766. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  44767. }
  44768. return oldValue.UnionID, nil
  44769. }
  44770. // ResetUnionID resets all changes to the "union_id" field.
  44771. func (m *WxCardUserMutation) ResetUnionID() {
  44772. m.union_id = nil
  44773. }
  44774. // SetSessionKey sets the "session_key" field.
  44775. func (m *WxCardUserMutation) SetSessionKey(s string) {
  44776. m.session_key = &s
  44777. }
  44778. // SessionKey returns the value of the "session_key" field in the mutation.
  44779. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  44780. v := m.session_key
  44781. if v == nil {
  44782. return
  44783. }
  44784. return *v, true
  44785. }
  44786. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  44787. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44789. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  44790. if !m.op.Is(OpUpdateOne) {
  44791. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  44792. }
  44793. if m.id == nil || m.oldValue == nil {
  44794. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  44795. }
  44796. oldValue, err := m.oldValue(ctx)
  44797. if err != nil {
  44798. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  44799. }
  44800. return oldValue.SessionKey, nil
  44801. }
  44802. // ResetSessionKey resets all changes to the "session_key" field.
  44803. func (m *WxCardUserMutation) ResetSessionKey() {
  44804. m.session_key = nil
  44805. }
  44806. // SetIsVip sets the "is_vip" field.
  44807. func (m *WxCardUserMutation) SetIsVip(i int) {
  44808. m.is_vip = &i
  44809. m.addis_vip = nil
  44810. }
  44811. // IsVip returns the value of the "is_vip" field in the mutation.
  44812. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  44813. v := m.is_vip
  44814. if v == nil {
  44815. return
  44816. }
  44817. return *v, true
  44818. }
  44819. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  44820. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  44821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44822. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  44823. if !m.op.Is(OpUpdateOne) {
  44824. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  44825. }
  44826. if m.id == nil || m.oldValue == nil {
  44827. return v, errors.New("OldIsVip requires an ID field in the mutation")
  44828. }
  44829. oldValue, err := m.oldValue(ctx)
  44830. if err != nil {
  44831. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  44832. }
  44833. return oldValue.IsVip, nil
  44834. }
  44835. // AddIsVip adds i to the "is_vip" field.
  44836. func (m *WxCardUserMutation) AddIsVip(i int) {
  44837. if m.addis_vip != nil {
  44838. *m.addis_vip += i
  44839. } else {
  44840. m.addis_vip = &i
  44841. }
  44842. }
  44843. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  44844. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  44845. v := m.addis_vip
  44846. if v == nil {
  44847. return
  44848. }
  44849. return *v, true
  44850. }
  44851. // ResetIsVip resets all changes to the "is_vip" field.
  44852. func (m *WxCardUserMutation) ResetIsVip() {
  44853. m.is_vip = nil
  44854. m.addis_vip = nil
  44855. }
  44856. // Where appends a list predicates to the WxCardUserMutation builder.
  44857. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  44858. m.predicates = append(m.predicates, ps...)
  44859. }
  44860. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  44861. // users can use type-assertion to append predicates that do not depend on any generated package.
  44862. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  44863. p := make([]predicate.WxCardUser, len(ps))
  44864. for i := range ps {
  44865. p[i] = ps[i]
  44866. }
  44867. m.Where(p...)
  44868. }
  44869. // Op returns the operation name.
  44870. func (m *WxCardUserMutation) Op() Op {
  44871. return m.op
  44872. }
  44873. // SetOp allows setting the mutation operation.
  44874. func (m *WxCardUserMutation) SetOp(op Op) {
  44875. m.op = op
  44876. }
  44877. // Type returns the node type of this mutation (WxCardUser).
  44878. func (m *WxCardUserMutation) Type() string {
  44879. return m.typ
  44880. }
  44881. // Fields returns all fields that were changed during this mutation. Note that in
  44882. // order to get all numeric fields that were incremented/decremented, call
  44883. // AddedFields().
  44884. func (m *WxCardUserMutation) Fields() []string {
  44885. fields := make([]string, 0, 13)
  44886. if m.created_at != nil {
  44887. fields = append(fields, wxcarduser.FieldCreatedAt)
  44888. }
  44889. if m.updated_at != nil {
  44890. fields = append(fields, wxcarduser.FieldUpdatedAt)
  44891. }
  44892. if m.deleted_at != nil {
  44893. fields = append(fields, wxcarduser.FieldDeletedAt)
  44894. }
  44895. if m.wxid != nil {
  44896. fields = append(fields, wxcarduser.FieldWxid)
  44897. }
  44898. if m.account != nil {
  44899. fields = append(fields, wxcarduser.FieldAccount)
  44900. }
  44901. if m.avatar != nil {
  44902. fields = append(fields, wxcarduser.FieldAvatar)
  44903. }
  44904. if m.nickname != nil {
  44905. fields = append(fields, wxcarduser.FieldNickname)
  44906. }
  44907. if m.remark != nil {
  44908. fields = append(fields, wxcarduser.FieldRemark)
  44909. }
  44910. if m.phone != nil {
  44911. fields = append(fields, wxcarduser.FieldPhone)
  44912. }
  44913. if m.open_id != nil {
  44914. fields = append(fields, wxcarduser.FieldOpenID)
  44915. }
  44916. if m.union_id != nil {
  44917. fields = append(fields, wxcarduser.FieldUnionID)
  44918. }
  44919. if m.session_key != nil {
  44920. fields = append(fields, wxcarduser.FieldSessionKey)
  44921. }
  44922. if m.is_vip != nil {
  44923. fields = append(fields, wxcarduser.FieldIsVip)
  44924. }
  44925. return fields
  44926. }
  44927. // Field returns the value of a field with the given name. The second boolean
  44928. // return value indicates that this field was not set, or was not defined in the
  44929. // schema.
  44930. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  44931. switch name {
  44932. case wxcarduser.FieldCreatedAt:
  44933. return m.CreatedAt()
  44934. case wxcarduser.FieldUpdatedAt:
  44935. return m.UpdatedAt()
  44936. case wxcarduser.FieldDeletedAt:
  44937. return m.DeletedAt()
  44938. case wxcarduser.FieldWxid:
  44939. return m.Wxid()
  44940. case wxcarduser.FieldAccount:
  44941. return m.Account()
  44942. case wxcarduser.FieldAvatar:
  44943. return m.Avatar()
  44944. case wxcarduser.FieldNickname:
  44945. return m.Nickname()
  44946. case wxcarduser.FieldRemark:
  44947. return m.Remark()
  44948. case wxcarduser.FieldPhone:
  44949. return m.Phone()
  44950. case wxcarduser.FieldOpenID:
  44951. return m.OpenID()
  44952. case wxcarduser.FieldUnionID:
  44953. return m.UnionID()
  44954. case wxcarduser.FieldSessionKey:
  44955. return m.SessionKey()
  44956. case wxcarduser.FieldIsVip:
  44957. return m.IsVip()
  44958. }
  44959. return nil, false
  44960. }
  44961. // OldField returns the old value of the field from the database. An error is
  44962. // returned if the mutation operation is not UpdateOne, or the query to the
  44963. // database failed.
  44964. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44965. switch name {
  44966. case wxcarduser.FieldCreatedAt:
  44967. return m.OldCreatedAt(ctx)
  44968. case wxcarduser.FieldUpdatedAt:
  44969. return m.OldUpdatedAt(ctx)
  44970. case wxcarduser.FieldDeletedAt:
  44971. return m.OldDeletedAt(ctx)
  44972. case wxcarduser.FieldWxid:
  44973. return m.OldWxid(ctx)
  44974. case wxcarduser.FieldAccount:
  44975. return m.OldAccount(ctx)
  44976. case wxcarduser.FieldAvatar:
  44977. return m.OldAvatar(ctx)
  44978. case wxcarduser.FieldNickname:
  44979. return m.OldNickname(ctx)
  44980. case wxcarduser.FieldRemark:
  44981. return m.OldRemark(ctx)
  44982. case wxcarduser.FieldPhone:
  44983. return m.OldPhone(ctx)
  44984. case wxcarduser.FieldOpenID:
  44985. return m.OldOpenID(ctx)
  44986. case wxcarduser.FieldUnionID:
  44987. return m.OldUnionID(ctx)
  44988. case wxcarduser.FieldSessionKey:
  44989. return m.OldSessionKey(ctx)
  44990. case wxcarduser.FieldIsVip:
  44991. return m.OldIsVip(ctx)
  44992. }
  44993. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  44994. }
  44995. // SetField sets the value of a field with the given name. It returns an error if
  44996. // the field is not defined in the schema, or if the type mismatched the field
  44997. // type.
  44998. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  44999. switch name {
  45000. case wxcarduser.FieldCreatedAt:
  45001. v, ok := value.(time.Time)
  45002. if !ok {
  45003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45004. }
  45005. m.SetCreatedAt(v)
  45006. return nil
  45007. case wxcarduser.FieldUpdatedAt:
  45008. v, ok := value.(time.Time)
  45009. if !ok {
  45010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45011. }
  45012. m.SetUpdatedAt(v)
  45013. return nil
  45014. case wxcarduser.FieldDeletedAt:
  45015. v, ok := value.(time.Time)
  45016. if !ok {
  45017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45018. }
  45019. m.SetDeletedAt(v)
  45020. return nil
  45021. case wxcarduser.FieldWxid:
  45022. v, ok := value.(string)
  45023. if !ok {
  45024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45025. }
  45026. m.SetWxid(v)
  45027. return nil
  45028. case wxcarduser.FieldAccount:
  45029. v, ok := value.(string)
  45030. if !ok {
  45031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45032. }
  45033. m.SetAccount(v)
  45034. return nil
  45035. case wxcarduser.FieldAvatar:
  45036. v, ok := value.(string)
  45037. if !ok {
  45038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45039. }
  45040. m.SetAvatar(v)
  45041. return nil
  45042. case wxcarduser.FieldNickname:
  45043. v, ok := value.(string)
  45044. if !ok {
  45045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45046. }
  45047. m.SetNickname(v)
  45048. return nil
  45049. case wxcarduser.FieldRemark:
  45050. v, ok := value.(string)
  45051. if !ok {
  45052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45053. }
  45054. m.SetRemark(v)
  45055. return nil
  45056. case wxcarduser.FieldPhone:
  45057. v, ok := value.(string)
  45058. if !ok {
  45059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45060. }
  45061. m.SetPhone(v)
  45062. return nil
  45063. case wxcarduser.FieldOpenID:
  45064. v, ok := value.(string)
  45065. if !ok {
  45066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45067. }
  45068. m.SetOpenID(v)
  45069. return nil
  45070. case wxcarduser.FieldUnionID:
  45071. v, ok := value.(string)
  45072. if !ok {
  45073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45074. }
  45075. m.SetUnionID(v)
  45076. return nil
  45077. case wxcarduser.FieldSessionKey:
  45078. v, ok := value.(string)
  45079. if !ok {
  45080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45081. }
  45082. m.SetSessionKey(v)
  45083. return nil
  45084. case wxcarduser.FieldIsVip:
  45085. v, ok := value.(int)
  45086. if !ok {
  45087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45088. }
  45089. m.SetIsVip(v)
  45090. return nil
  45091. }
  45092. return fmt.Errorf("unknown WxCardUser field %s", name)
  45093. }
  45094. // AddedFields returns all numeric fields that were incremented/decremented during
  45095. // this mutation.
  45096. func (m *WxCardUserMutation) AddedFields() []string {
  45097. var fields []string
  45098. if m.addis_vip != nil {
  45099. fields = append(fields, wxcarduser.FieldIsVip)
  45100. }
  45101. return fields
  45102. }
  45103. // AddedField returns the numeric value that was incremented/decremented on a field
  45104. // with the given name. The second boolean return value indicates that this field
  45105. // was not set, or was not defined in the schema.
  45106. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  45107. switch name {
  45108. case wxcarduser.FieldIsVip:
  45109. return m.AddedIsVip()
  45110. }
  45111. return nil, false
  45112. }
  45113. // AddField adds the value to the field with the given name. It returns an error if
  45114. // the field is not defined in the schema, or if the type mismatched the field
  45115. // type.
  45116. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  45117. switch name {
  45118. case wxcarduser.FieldIsVip:
  45119. v, ok := value.(int)
  45120. if !ok {
  45121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45122. }
  45123. m.AddIsVip(v)
  45124. return nil
  45125. }
  45126. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  45127. }
  45128. // ClearedFields returns all nullable fields that were cleared during this
  45129. // mutation.
  45130. func (m *WxCardUserMutation) ClearedFields() []string {
  45131. var fields []string
  45132. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  45133. fields = append(fields, wxcarduser.FieldDeletedAt)
  45134. }
  45135. return fields
  45136. }
  45137. // FieldCleared returns a boolean indicating if a field with the given name was
  45138. // cleared in this mutation.
  45139. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  45140. _, ok := m.clearedFields[name]
  45141. return ok
  45142. }
  45143. // ClearField clears the value of the field with the given name. It returns an
  45144. // error if the field is not defined in the schema.
  45145. func (m *WxCardUserMutation) ClearField(name string) error {
  45146. switch name {
  45147. case wxcarduser.FieldDeletedAt:
  45148. m.ClearDeletedAt()
  45149. return nil
  45150. }
  45151. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  45152. }
  45153. // ResetField resets all changes in the mutation for the field with the given name.
  45154. // It returns an error if the field is not defined in the schema.
  45155. func (m *WxCardUserMutation) ResetField(name string) error {
  45156. switch name {
  45157. case wxcarduser.FieldCreatedAt:
  45158. m.ResetCreatedAt()
  45159. return nil
  45160. case wxcarduser.FieldUpdatedAt:
  45161. m.ResetUpdatedAt()
  45162. return nil
  45163. case wxcarduser.FieldDeletedAt:
  45164. m.ResetDeletedAt()
  45165. return nil
  45166. case wxcarduser.FieldWxid:
  45167. m.ResetWxid()
  45168. return nil
  45169. case wxcarduser.FieldAccount:
  45170. m.ResetAccount()
  45171. return nil
  45172. case wxcarduser.FieldAvatar:
  45173. m.ResetAvatar()
  45174. return nil
  45175. case wxcarduser.FieldNickname:
  45176. m.ResetNickname()
  45177. return nil
  45178. case wxcarduser.FieldRemark:
  45179. m.ResetRemark()
  45180. return nil
  45181. case wxcarduser.FieldPhone:
  45182. m.ResetPhone()
  45183. return nil
  45184. case wxcarduser.FieldOpenID:
  45185. m.ResetOpenID()
  45186. return nil
  45187. case wxcarduser.FieldUnionID:
  45188. m.ResetUnionID()
  45189. return nil
  45190. case wxcarduser.FieldSessionKey:
  45191. m.ResetSessionKey()
  45192. return nil
  45193. case wxcarduser.FieldIsVip:
  45194. m.ResetIsVip()
  45195. return nil
  45196. }
  45197. return fmt.Errorf("unknown WxCardUser field %s", name)
  45198. }
  45199. // AddedEdges returns all edge names that were set/added in this mutation.
  45200. func (m *WxCardUserMutation) AddedEdges() []string {
  45201. edges := make([]string, 0, 0)
  45202. return edges
  45203. }
  45204. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45205. // name in this mutation.
  45206. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  45207. return nil
  45208. }
  45209. // RemovedEdges returns all edge names that were removed in this mutation.
  45210. func (m *WxCardUserMutation) RemovedEdges() []string {
  45211. edges := make([]string, 0, 0)
  45212. return edges
  45213. }
  45214. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45215. // the given name in this mutation.
  45216. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  45217. return nil
  45218. }
  45219. // ClearedEdges returns all edge names that were cleared in this mutation.
  45220. func (m *WxCardUserMutation) ClearedEdges() []string {
  45221. edges := make([]string, 0, 0)
  45222. return edges
  45223. }
  45224. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45225. // was cleared in this mutation.
  45226. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  45227. return false
  45228. }
  45229. // ClearEdge clears the value of the edge with the given name. It returns an error
  45230. // if that edge is not defined in the schema.
  45231. func (m *WxCardUserMutation) ClearEdge(name string) error {
  45232. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  45233. }
  45234. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45235. // It returns an error if the edge is not defined in the schema.
  45236. func (m *WxCardUserMutation) ResetEdge(name string) error {
  45237. return fmt.Errorf("unknown WxCardUser edge %s", name)
  45238. }
  45239. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  45240. type WxCardVisitMutation struct {
  45241. config
  45242. op Op
  45243. typ string
  45244. id *uint64
  45245. created_at *time.Time
  45246. updated_at *time.Time
  45247. deleted_at *time.Time
  45248. user_id *uint64
  45249. adduser_id *int64
  45250. bot_id *uint64
  45251. addbot_id *int64
  45252. bot_type *uint8
  45253. addbot_type *int8
  45254. clearedFields map[string]struct{}
  45255. done bool
  45256. oldValue func(context.Context) (*WxCardVisit, error)
  45257. predicates []predicate.WxCardVisit
  45258. }
  45259. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  45260. // wxcardvisitOption allows management of the mutation configuration using functional options.
  45261. type wxcardvisitOption func(*WxCardVisitMutation)
  45262. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  45263. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  45264. m := &WxCardVisitMutation{
  45265. config: c,
  45266. op: op,
  45267. typ: TypeWxCardVisit,
  45268. clearedFields: make(map[string]struct{}),
  45269. }
  45270. for _, opt := range opts {
  45271. opt(m)
  45272. }
  45273. return m
  45274. }
  45275. // withWxCardVisitID sets the ID field of the mutation.
  45276. func withWxCardVisitID(id uint64) wxcardvisitOption {
  45277. return func(m *WxCardVisitMutation) {
  45278. var (
  45279. err error
  45280. once sync.Once
  45281. value *WxCardVisit
  45282. )
  45283. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  45284. once.Do(func() {
  45285. if m.done {
  45286. err = errors.New("querying old values post mutation is not allowed")
  45287. } else {
  45288. value, err = m.Client().WxCardVisit.Get(ctx, id)
  45289. }
  45290. })
  45291. return value, err
  45292. }
  45293. m.id = &id
  45294. }
  45295. }
  45296. // withWxCardVisit sets the old WxCardVisit of the mutation.
  45297. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  45298. return func(m *WxCardVisitMutation) {
  45299. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  45300. return node, nil
  45301. }
  45302. m.id = &node.ID
  45303. }
  45304. }
  45305. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45306. // executed in a transaction (ent.Tx), a transactional client is returned.
  45307. func (m WxCardVisitMutation) Client() *Client {
  45308. client := &Client{config: m.config}
  45309. client.init()
  45310. return client
  45311. }
  45312. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45313. // it returns an error otherwise.
  45314. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  45315. if _, ok := m.driver.(*txDriver); !ok {
  45316. return nil, errors.New("ent: mutation is not running in a transaction")
  45317. }
  45318. tx := &Tx{config: m.config}
  45319. tx.init()
  45320. return tx, nil
  45321. }
  45322. // SetID sets the value of the id field. Note that this
  45323. // operation is only accepted on creation of WxCardVisit entities.
  45324. func (m *WxCardVisitMutation) SetID(id uint64) {
  45325. m.id = &id
  45326. }
  45327. // ID returns the ID value in the mutation. Note that the ID is only available
  45328. // if it was provided to the builder or after it was returned from the database.
  45329. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  45330. if m.id == nil {
  45331. return
  45332. }
  45333. return *m.id, true
  45334. }
  45335. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45336. // That means, if the mutation is applied within a transaction with an isolation level such
  45337. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45338. // or updated by the mutation.
  45339. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  45340. switch {
  45341. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45342. id, exists := m.ID()
  45343. if exists {
  45344. return []uint64{id}, nil
  45345. }
  45346. fallthrough
  45347. case m.op.Is(OpUpdate | OpDelete):
  45348. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  45349. default:
  45350. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45351. }
  45352. }
  45353. // SetCreatedAt sets the "created_at" field.
  45354. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  45355. m.created_at = &t
  45356. }
  45357. // CreatedAt returns the value of the "created_at" field in the mutation.
  45358. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  45359. v := m.created_at
  45360. if v == nil {
  45361. return
  45362. }
  45363. return *v, true
  45364. }
  45365. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  45366. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45368. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45369. if !m.op.Is(OpUpdateOne) {
  45370. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45371. }
  45372. if m.id == nil || m.oldValue == nil {
  45373. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45374. }
  45375. oldValue, err := m.oldValue(ctx)
  45376. if err != nil {
  45377. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45378. }
  45379. return oldValue.CreatedAt, nil
  45380. }
  45381. // ResetCreatedAt resets all changes to the "created_at" field.
  45382. func (m *WxCardVisitMutation) ResetCreatedAt() {
  45383. m.created_at = nil
  45384. }
  45385. // SetUpdatedAt sets the "updated_at" field.
  45386. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  45387. m.updated_at = &t
  45388. }
  45389. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45390. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  45391. v := m.updated_at
  45392. if v == nil {
  45393. return
  45394. }
  45395. return *v, true
  45396. }
  45397. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  45398. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45400. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45401. if !m.op.Is(OpUpdateOne) {
  45402. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45403. }
  45404. if m.id == nil || m.oldValue == nil {
  45405. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45406. }
  45407. oldValue, err := m.oldValue(ctx)
  45408. if err != nil {
  45409. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45410. }
  45411. return oldValue.UpdatedAt, nil
  45412. }
  45413. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45414. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  45415. m.updated_at = nil
  45416. }
  45417. // SetDeletedAt sets the "deleted_at" field.
  45418. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  45419. m.deleted_at = &t
  45420. }
  45421. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45422. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  45423. v := m.deleted_at
  45424. if v == nil {
  45425. return
  45426. }
  45427. return *v, true
  45428. }
  45429. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  45430. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45432. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45433. if !m.op.Is(OpUpdateOne) {
  45434. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45435. }
  45436. if m.id == nil || m.oldValue == nil {
  45437. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45438. }
  45439. oldValue, err := m.oldValue(ctx)
  45440. if err != nil {
  45441. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45442. }
  45443. return oldValue.DeletedAt, nil
  45444. }
  45445. // ClearDeletedAt clears the value of the "deleted_at" field.
  45446. func (m *WxCardVisitMutation) ClearDeletedAt() {
  45447. m.deleted_at = nil
  45448. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  45449. }
  45450. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45451. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  45452. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  45453. return ok
  45454. }
  45455. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45456. func (m *WxCardVisitMutation) ResetDeletedAt() {
  45457. m.deleted_at = nil
  45458. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  45459. }
  45460. // SetUserID sets the "user_id" field.
  45461. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  45462. m.user_id = &u
  45463. m.adduser_id = nil
  45464. }
  45465. // UserID returns the value of the "user_id" field in the mutation.
  45466. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  45467. v := m.user_id
  45468. if v == nil {
  45469. return
  45470. }
  45471. return *v, true
  45472. }
  45473. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  45474. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45476. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  45477. if !m.op.Is(OpUpdateOne) {
  45478. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  45479. }
  45480. if m.id == nil || m.oldValue == nil {
  45481. return v, errors.New("OldUserID requires an ID field in the mutation")
  45482. }
  45483. oldValue, err := m.oldValue(ctx)
  45484. if err != nil {
  45485. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  45486. }
  45487. return oldValue.UserID, nil
  45488. }
  45489. // AddUserID adds u to the "user_id" field.
  45490. func (m *WxCardVisitMutation) AddUserID(u int64) {
  45491. if m.adduser_id != nil {
  45492. *m.adduser_id += u
  45493. } else {
  45494. m.adduser_id = &u
  45495. }
  45496. }
  45497. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  45498. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  45499. v := m.adduser_id
  45500. if v == nil {
  45501. return
  45502. }
  45503. return *v, true
  45504. }
  45505. // ClearUserID clears the value of the "user_id" field.
  45506. func (m *WxCardVisitMutation) ClearUserID() {
  45507. m.user_id = nil
  45508. m.adduser_id = nil
  45509. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  45510. }
  45511. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  45512. func (m *WxCardVisitMutation) UserIDCleared() bool {
  45513. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  45514. return ok
  45515. }
  45516. // ResetUserID resets all changes to the "user_id" field.
  45517. func (m *WxCardVisitMutation) ResetUserID() {
  45518. m.user_id = nil
  45519. m.adduser_id = nil
  45520. delete(m.clearedFields, wxcardvisit.FieldUserID)
  45521. }
  45522. // SetBotID sets the "bot_id" field.
  45523. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  45524. m.bot_id = &u
  45525. m.addbot_id = nil
  45526. }
  45527. // BotID returns the value of the "bot_id" field in the mutation.
  45528. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  45529. v := m.bot_id
  45530. if v == nil {
  45531. return
  45532. }
  45533. return *v, true
  45534. }
  45535. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  45536. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45538. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  45539. if !m.op.Is(OpUpdateOne) {
  45540. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  45541. }
  45542. if m.id == nil || m.oldValue == nil {
  45543. return v, errors.New("OldBotID requires an ID field in the mutation")
  45544. }
  45545. oldValue, err := m.oldValue(ctx)
  45546. if err != nil {
  45547. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  45548. }
  45549. return oldValue.BotID, nil
  45550. }
  45551. // AddBotID adds u to the "bot_id" field.
  45552. func (m *WxCardVisitMutation) AddBotID(u int64) {
  45553. if m.addbot_id != nil {
  45554. *m.addbot_id += u
  45555. } else {
  45556. m.addbot_id = &u
  45557. }
  45558. }
  45559. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  45560. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  45561. v := m.addbot_id
  45562. if v == nil {
  45563. return
  45564. }
  45565. return *v, true
  45566. }
  45567. // ResetBotID resets all changes to the "bot_id" field.
  45568. func (m *WxCardVisitMutation) ResetBotID() {
  45569. m.bot_id = nil
  45570. m.addbot_id = nil
  45571. }
  45572. // SetBotType sets the "bot_type" field.
  45573. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  45574. m.bot_type = &u
  45575. m.addbot_type = nil
  45576. }
  45577. // BotType returns the value of the "bot_type" field in the mutation.
  45578. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  45579. v := m.bot_type
  45580. if v == nil {
  45581. return
  45582. }
  45583. return *v, true
  45584. }
  45585. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  45586. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  45587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45588. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  45589. if !m.op.Is(OpUpdateOne) {
  45590. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  45591. }
  45592. if m.id == nil || m.oldValue == nil {
  45593. return v, errors.New("OldBotType requires an ID field in the mutation")
  45594. }
  45595. oldValue, err := m.oldValue(ctx)
  45596. if err != nil {
  45597. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  45598. }
  45599. return oldValue.BotType, nil
  45600. }
  45601. // AddBotType adds u to the "bot_type" field.
  45602. func (m *WxCardVisitMutation) AddBotType(u int8) {
  45603. if m.addbot_type != nil {
  45604. *m.addbot_type += u
  45605. } else {
  45606. m.addbot_type = &u
  45607. }
  45608. }
  45609. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  45610. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  45611. v := m.addbot_type
  45612. if v == nil {
  45613. return
  45614. }
  45615. return *v, true
  45616. }
  45617. // ResetBotType resets all changes to the "bot_type" field.
  45618. func (m *WxCardVisitMutation) ResetBotType() {
  45619. m.bot_type = nil
  45620. m.addbot_type = nil
  45621. }
  45622. // Where appends a list predicates to the WxCardVisitMutation builder.
  45623. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  45624. m.predicates = append(m.predicates, ps...)
  45625. }
  45626. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  45627. // users can use type-assertion to append predicates that do not depend on any generated package.
  45628. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  45629. p := make([]predicate.WxCardVisit, len(ps))
  45630. for i := range ps {
  45631. p[i] = ps[i]
  45632. }
  45633. m.Where(p...)
  45634. }
  45635. // Op returns the operation name.
  45636. func (m *WxCardVisitMutation) Op() Op {
  45637. return m.op
  45638. }
  45639. // SetOp allows setting the mutation operation.
  45640. func (m *WxCardVisitMutation) SetOp(op Op) {
  45641. m.op = op
  45642. }
  45643. // Type returns the node type of this mutation (WxCardVisit).
  45644. func (m *WxCardVisitMutation) Type() string {
  45645. return m.typ
  45646. }
  45647. // Fields returns all fields that were changed during this mutation. Note that in
  45648. // order to get all numeric fields that were incremented/decremented, call
  45649. // AddedFields().
  45650. func (m *WxCardVisitMutation) Fields() []string {
  45651. fields := make([]string, 0, 6)
  45652. if m.created_at != nil {
  45653. fields = append(fields, wxcardvisit.FieldCreatedAt)
  45654. }
  45655. if m.updated_at != nil {
  45656. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  45657. }
  45658. if m.deleted_at != nil {
  45659. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45660. }
  45661. if m.user_id != nil {
  45662. fields = append(fields, wxcardvisit.FieldUserID)
  45663. }
  45664. if m.bot_id != nil {
  45665. fields = append(fields, wxcardvisit.FieldBotID)
  45666. }
  45667. if m.bot_type != nil {
  45668. fields = append(fields, wxcardvisit.FieldBotType)
  45669. }
  45670. return fields
  45671. }
  45672. // Field returns the value of a field with the given name. The second boolean
  45673. // return value indicates that this field was not set, or was not defined in the
  45674. // schema.
  45675. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  45676. switch name {
  45677. case wxcardvisit.FieldCreatedAt:
  45678. return m.CreatedAt()
  45679. case wxcardvisit.FieldUpdatedAt:
  45680. return m.UpdatedAt()
  45681. case wxcardvisit.FieldDeletedAt:
  45682. return m.DeletedAt()
  45683. case wxcardvisit.FieldUserID:
  45684. return m.UserID()
  45685. case wxcardvisit.FieldBotID:
  45686. return m.BotID()
  45687. case wxcardvisit.FieldBotType:
  45688. return m.BotType()
  45689. }
  45690. return nil, false
  45691. }
  45692. // OldField returns the old value of the field from the database. An error is
  45693. // returned if the mutation operation is not UpdateOne, or the query to the
  45694. // database failed.
  45695. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45696. switch name {
  45697. case wxcardvisit.FieldCreatedAt:
  45698. return m.OldCreatedAt(ctx)
  45699. case wxcardvisit.FieldUpdatedAt:
  45700. return m.OldUpdatedAt(ctx)
  45701. case wxcardvisit.FieldDeletedAt:
  45702. return m.OldDeletedAt(ctx)
  45703. case wxcardvisit.FieldUserID:
  45704. return m.OldUserID(ctx)
  45705. case wxcardvisit.FieldBotID:
  45706. return m.OldBotID(ctx)
  45707. case wxcardvisit.FieldBotType:
  45708. return m.OldBotType(ctx)
  45709. }
  45710. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  45711. }
  45712. // SetField sets the value of a field with the given name. It returns an error if
  45713. // the field is not defined in the schema, or if the type mismatched the field
  45714. // type.
  45715. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  45716. switch name {
  45717. case wxcardvisit.FieldCreatedAt:
  45718. v, ok := value.(time.Time)
  45719. if !ok {
  45720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45721. }
  45722. m.SetCreatedAt(v)
  45723. return nil
  45724. case wxcardvisit.FieldUpdatedAt:
  45725. v, ok := value.(time.Time)
  45726. if !ok {
  45727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45728. }
  45729. m.SetUpdatedAt(v)
  45730. return nil
  45731. case wxcardvisit.FieldDeletedAt:
  45732. v, ok := value.(time.Time)
  45733. if !ok {
  45734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45735. }
  45736. m.SetDeletedAt(v)
  45737. return nil
  45738. case wxcardvisit.FieldUserID:
  45739. v, ok := value.(uint64)
  45740. if !ok {
  45741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45742. }
  45743. m.SetUserID(v)
  45744. return nil
  45745. case wxcardvisit.FieldBotID:
  45746. v, ok := value.(uint64)
  45747. if !ok {
  45748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45749. }
  45750. m.SetBotID(v)
  45751. return nil
  45752. case wxcardvisit.FieldBotType:
  45753. v, ok := value.(uint8)
  45754. if !ok {
  45755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45756. }
  45757. m.SetBotType(v)
  45758. return nil
  45759. }
  45760. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45761. }
  45762. // AddedFields returns all numeric fields that were incremented/decremented during
  45763. // this mutation.
  45764. func (m *WxCardVisitMutation) AddedFields() []string {
  45765. var fields []string
  45766. if m.adduser_id != nil {
  45767. fields = append(fields, wxcardvisit.FieldUserID)
  45768. }
  45769. if m.addbot_id != nil {
  45770. fields = append(fields, wxcardvisit.FieldBotID)
  45771. }
  45772. if m.addbot_type != nil {
  45773. fields = append(fields, wxcardvisit.FieldBotType)
  45774. }
  45775. return fields
  45776. }
  45777. // AddedField returns the numeric value that was incremented/decremented on a field
  45778. // with the given name. The second boolean return value indicates that this field
  45779. // was not set, or was not defined in the schema.
  45780. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  45781. switch name {
  45782. case wxcardvisit.FieldUserID:
  45783. return m.AddedUserID()
  45784. case wxcardvisit.FieldBotID:
  45785. return m.AddedBotID()
  45786. case wxcardvisit.FieldBotType:
  45787. return m.AddedBotType()
  45788. }
  45789. return nil, false
  45790. }
  45791. // AddField adds the value to the field with the given name. It returns an error if
  45792. // the field is not defined in the schema, or if the type mismatched the field
  45793. // type.
  45794. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  45795. switch name {
  45796. case wxcardvisit.FieldUserID:
  45797. v, ok := value.(int64)
  45798. if !ok {
  45799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45800. }
  45801. m.AddUserID(v)
  45802. return nil
  45803. case wxcardvisit.FieldBotID:
  45804. v, ok := value.(int64)
  45805. if !ok {
  45806. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45807. }
  45808. m.AddBotID(v)
  45809. return nil
  45810. case wxcardvisit.FieldBotType:
  45811. v, ok := value.(int8)
  45812. if !ok {
  45813. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45814. }
  45815. m.AddBotType(v)
  45816. return nil
  45817. }
  45818. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  45819. }
  45820. // ClearedFields returns all nullable fields that were cleared during this
  45821. // mutation.
  45822. func (m *WxCardVisitMutation) ClearedFields() []string {
  45823. var fields []string
  45824. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  45825. fields = append(fields, wxcardvisit.FieldDeletedAt)
  45826. }
  45827. if m.FieldCleared(wxcardvisit.FieldUserID) {
  45828. fields = append(fields, wxcardvisit.FieldUserID)
  45829. }
  45830. return fields
  45831. }
  45832. // FieldCleared returns a boolean indicating if a field with the given name was
  45833. // cleared in this mutation.
  45834. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  45835. _, ok := m.clearedFields[name]
  45836. return ok
  45837. }
  45838. // ClearField clears the value of the field with the given name. It returns an
  45839. // error if the field is not defined in the schema.
  45840. func (m *WxCardVisitMutation) ClearField(name string) error {
  45841. switch name {
  45842. case wxcardvisit.FieldDeletedAt:
  45843. m.ClearDeletedAt()
  45844. return nil
  45845. case wxcardvisit.FieldUserID:
  45846. m.ClearUserID()
  45847. return nil
  45848. }
  45849. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  45850. }
  45851. // ResetField resets all changes in the mutation for the field with the given name.
  45852. // It returns an error if the field is not defined in the schema.
  45853. func (m *WxCardVisitMutation) ResetField(name string) error {
  45854. switch name {
  45855. case wxcardvisit.FieldCreatedAt:
  45856. m.ResetCreatedAt()
  45857. return nil
  45858. case wxcardvisit.FieldUpdatedAt:
  45859. m.ResetUpdatedAt()
  45860. return nil
  45861. case wxcardvisit.FieldDeletedAt:
  45862. m.ResetDeletedAt()
  45863. return nil
  45864. case wxcardvisit.FieldUserID:
  45865. m.ResetUserID()
  45866. return nil
  45867. case wxcardvisit.FieldBotID:
  45868. m.ResetBotID()
  45869. return nil
  45870. case wxcardvisit.FieldBotType:
  45871. m.ResetBotType()
  45872. return nil
  45873. }
  45874. return fmt.Errorf("unknown WxCardVisit field %s", name)
  45875. }
  45876. // AddedEdges returns all edge names that were set/added in this mutation.
  45877. func (m *WxCardVisitMutation) AddedEdges() []string {
  45878. edges := make([]string, 0, 0)
  45879. return edges
  45880. }
  45881. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45882. // name in this mutation.
  45883. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  45884. return nil
  45885. }
  45886. // RemovedEdges returns all edge names that were removed in this mutation.
  45887. func (m *WxCardVisitMutation) RemovedEdges() []string {
  45888. edges := make([]string, 0, 0)
  45889. return edges
  45890. }
  45891. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45892. // the given name in this mutation.
  45893. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  45894. return nil
  45895. }
  45896. // ClearedEdges returns all edge names that were cleared in this mutation.
  45897. func (m *WxCardVisitMutation) ClearedEdges() []string {
  45898. edges := make([]string, 0, 0)
  45899. return edges
  45900. }
  45901. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45902. // was cleared in this mutation.
  45903. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  45904. return false
  45905. }
  45906. // ClearEdge clears the value of the edge with the given name. It returns an error
  45907. // if that edge is not defined in the schema.
  45908. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  45909. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  45910. }
  45911. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45912. // It returns an error if the edge is not defined in the schema.
  45913. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  45914. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  45915. }