mutation.go 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/apikey"
  14. "wechat-api/ent/batchmsg"
  15. "wechat-api/ent/category"
  16. "wechat-api/ent/chatrecords"
  17. "wechat-api/ent/chatsession"
  18. "wechat-api/ent/compapiasynctask"
  19. "wechat-api/ent/contact"
  20. "wechat-api/ent/creditbalance"
  21. "wechat-api/ent/creditusage"
  22. "wechat-api/ent/custom_types"
  23. "wechat-api/ent/employee"
  24. "wechat-api/ent/employeeconfig"
  25. "wechat-api/ent/label"
  26. "wechat-api/ent/labelrelationship"
  27. "wechat-api/ent/labeltagging"
  28. "wechat-api/ent/message"
  29. "wechat-api/ent/messagerecords"
  30. "wechat-api/ent/msg"
  31. "wechat-api/ent/payrecharge"
  32. "wechat-api/ent/predicate"
  33. "wechat-api/ent/server"
  34. "wechat-api/ent/sopnode"
  35. "wechat-api/ent/sopstage"
  36. "wechat-api/ent/soptask"
  37. "wechat-api/ent/token"
  38. "wechat-api/ent/tutorial"
  39. "wechat-api/ent/usagedetail"
  40. "wechat-api/ent/usagestatisticday"
  41. "wechat-api/ent/usagestatistichour"
  42. "wechat-api/ent/usagestatisticmonth"
  43. "wechat-api/ent/usagetotal"
  44. "wechat-api/ent/whatsapp"
  45. "wechat-api/ent/whatsappchannel"
  46. "wechat-api/ent/workexperience"
  47. "wechat-api/ent/wpchatroom"
  48. "wechat-api/ent/wpchatroommember"
  49. "wechat-api/ent/wx"
  50. "wechat-api/ent/wxcard"
  51. "wechat-api/ent/wxcarduser"
  52. "wechat-api/ent/wxcardvisit"
  53. "entgo.io/ent"
  54. "entgo.io/ent/dialect/sql"
  55. )
  56. const (
  57. // Operation types.
  58. OpCreate = ent.OpCreate
  59. OpDelete = ent.OpDelete
  60. OpDeleteOne = ent.OpDeleteOne
  61. OpUpdate = ent.OpUpdate
  62. OpUpdateOne = ent.OpUpdateOne
  63. // Node types.
  64. TypeAgent = "Agent"
  65. TypeAgentBase = "AgentBase"
  66. TypeAliyunAvatar = "AliyunAvatar"
  67. TypeAllocAgent = "AllocAgent"
  68. TypeApiKey = "ApiKey"
  69. TypeBatchMsg = "BatchMsg"
  70. TypeCategory = "Category"
  71. TypeChatRecords = "ChatRecords"
  72. TypeChatSession = "ChatSession"
  73. TypeCompapiAsynctask = "CompapiAsynctask"
  74. TypeContact = "Contact"
  75. TypeCreditBalance = "CreditBalance"
  76. TypeCreditUsage = "CreditUsage"
  77. TypeEmployee = "Employee"
  78. TypeEmployeeConfig = "EmployeeConfig"
  79. TypeLabel = "Label"
  80. TypeLabelRelationship = "LabelRelationship"
  81. TypeLabelTagging = "LabelTagging"
  82. TypeMessage = "Message"
  83. TypeMessageRecords = "MessageRecords"
  84. TypeMsg = "Msg"
  85. TypePayRecharge = "PayRecharge"
  86. TypeServer = "Server"
  87. TypeSopNode = "SopNode"
  88. TypeSopStage = "SopStage"
  89. TypeSopTask = "SopTask"
  90. TypeToken = "Token"
  91. TypeTutorial = "Tutorial"
  92. TypeUsageDetail = "UsageDetail"
  93. TypeUsageStatisticDay = "UsageStatisticDay"
  94. TypeUsageStatisticHour = "UsageStatisticHour"
  95. TypeUsageStatisticMonth = "UsageStatisticMonth"
  96. TypeUsageTotal = "UsageTotal"
  97. TypeWhatsapp = "Whatsapp"
  98. TypeWhatsappChannel = "WhatsappChannel"
  99. TypeWorkExperience = "WorkExperience"
  100. TypeWpChatroom = "WpChatroom"
  101. TypeWpChatroomMember = "WpChatroomMember"
  102. TypeWx = "Wx"
  103. TypeWxCard = "WxCard"
  104. TypeWxCardUser = "WxCardUser"
  105. TypeWxCardVisit = "WxCardVisit"
  106. )
  107. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  108. type AgentMutation struct {
  109. config
  110. op Op
  111. typ string
  112. id *uint64
  113. created_at *time.Time
  114. updated_at *time.Time
  115. deleted_at *time.Time
  116. name *string
  117. role *string
  118. status *int
  119. addstatus *int
  120. background *string
  121. examples *string
  122. organization_id *uint64
  123. addorganization_id *int64
  124. dataset_id *string
  125. collection_id *string
  126. clearedFields map[string]struct{}
  127. wx_agent map[uint64]struct{}
  128. removedwx_agent map[uint64]struct{}
  129. clearedwx_agent bool
  130. token_agent map[uint64]struct{}
  131. removedtoken_agent map[uint64]struct{}
  132. clearedtoken_agent bool
  133. wa_agent map[uint64]struct{}
  134. removedwa_agent map[uint64]struct{}
  135. clearedwa_agent bool
  136. key_agent map[uint64]struct{}
  137. removedkey_agent map[uint64]struct{}
  138. clearedkey_agent bool
  139. done bool
  140. oldValue func(context.Context) (*Agent, error)
  141. predicates []predicate.Agent
  142. }
  143. var _ ent.Mutation = (*AgentMutation)(nil)
  144. // agentOption allows management of the mutation configuration using functional options.
  145. type agentOption func(*AgentMutation)
  146. // newAgentMutation creates new mutation for the Agent entity.
  147. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  148. m := &AgentMutation{
  149. config: c,
  150. op: op,
  151. typ: TypeAgent,
  152. clearedFields: make(map[string]struct{}),
  153. }
  154. for _, opt := range opts {
  155. opt(m)
  156. }
  157. return m
  158. }
  159. // withAgentID sets the ID field of the mutation.
  160. func withAgentID(id uint64) agentOption {
  161. return func(m *AgentMutation) {
  162. var (
  163. err error
  164. once sync.Once
  165. value *Agent
  166. )
  167. m.oldValue = func(ctx context.Context) (*Agent, error) {
  168. once.Do(func() {
  169. if m.done {
  170. err = errors.New("querying old values post mutation is not allowed")
  171. } else {
  172. value, err = m.Client().Agent.Get(ctx, id)
  173. }
  174. })
  175. return value, err
  176. }
  177. m.id = &id
  178. }
  179. }
  180. // withAgent sets the old Agent of the mutation.
  181. func withAgent(node *Agent) agentOption {
  182. return func(m *AgentMutation) {
  183. m.oldValue = func(context.Context) (*Agent, error) {
  184. return node, nil
  185. }
  186. m.id = &node.ID
  187. }
  188. }
  189. // Client returns a new `ent.Client` from the mutation. If the mutation was
  190. // executed in a transaction (ent.Tx), a transactional client is returned.
  191. func (m AgentMutation) Client() *Client {
  192. client := &Client{config: m.config}
  193. client.init()
  194. return client
  195. }
  196. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  197. // it returns an error otherwise.
  198. func (m AgentMutation) Tx() (*Tx, error) {
  199. if _, ok := m.driver.(*txDriver); !ok {
  200. return nil, errors.New("ent: mutation is not running in a transaction")
  201. }
  202. tx := &Tx{config: m.config}
  203. tx.init()
  204. return tx, nil
  205. }
  206. // SetID sets the value of the id field. Note that this
  207. // operation is only accepted on creation of Agent entities.
  208. func (m *AgentMutation) SetID(id uint64) {
  209. m.id = &id
  210. }
  211. // ID returns the ID value in the mutation. Note that the ID is only available
  212. // if it was provided to the builder or after it was returned from the database.
  213. func (m *AgentMutation) ID() (id uint64, exists bool) {
  214. if m.id == nil {
  215. return
  216. }
  217. return *m.id, true
  218. }
  219. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  220. // That means, if the mutation is applied within a transaction with an isolation level such
  221. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  222. // or updated by the mutation.
  223. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  224. switch {
  225. case m.op.Is(OpUpdateOne | OpDeleteOne):
  226. id, exists := m.ID()
  227. if exists {
  228. return []uint64{id}, nil
  229. }
  230. fallthrough
  231. case m.op.Is(OpUpdate | OpDelete):
  232. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  233. default:
  234. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  235. }
  236. }
  237. // SetCreatedAt sets the "created_at" field.
  238. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  239. m.created_at = &t
  240. }
  241. // CreatedAt returns the value of the "created_at" field in the mutation.
  242. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  243. v := m.created_at
  244. if v == nil {
  245. return
  246. }
  247. return *v, true
  248. }
  249. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  250. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  252. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  253. if !m.op.Is(OpUpdateOne) {
  254. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  255. }
  256. if m.id == nil || m.oldValue == nil {
  257. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  258. }
  259. oldValue, err := m.oldValue(ctx)
  260. if err != nil {
  261. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  262. }
  263. return oldValue.CreatedAt, nil
  264. }
  265. // ResetCreatedAt resets all changes to the "created_at" field.
  266. func (m *AgentMutation) ResetCreatedAt() {
  267. m.created_at = nil
  268. }
  269. // SetUpdatedAt sets the "updated_at" field.
  270. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  271. m.updated_at = &t
  272. }
  273. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  274. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  275. v := m.updated_at
  276. if v == nil {
  277. return
  278. }
  279. return *v, true
  280. }
  281. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  282. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  284. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  285. if !m.op.Is(OpUpdateOne) {
  286. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  287. }
  288. if m.id == nil || m.oldValue == nil {
  289. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  290. }
  291. oldValue, err := m.oldValue(ctx)
  292. if err != nil {
  293. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  294. }
  295. return oldValue.UpdatedAt, nil
  296. }
  297. // ResetUpdatedAt resets all changes to the "updated_at" field.
  298. func (m *AgentMutation) ResetUpdatedAt() {
  299. m.updated_at = nil
  300. }
  301. // SetDeletedAt sets the "deleted_at" field.
  302. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  303. m.deleted_at = &t
  304. }
  305. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  306. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  307. v := m.deleted_at
  308. if v == nil {
  309. return
  310. }
  311. return *v, true
  312. }
  313. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  314. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  316. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  317. if !m.op.Is(OpUpdateOne) {
  318. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  319. }
  320. if m.id == nil || m.oldValue == nil {
  321. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  322. }
  323. oldValue, err := m.oldValue(ctx)
  324. if err != nil {
  325. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  326. }
  327. return oldValue.DeletedAt, nil
  328. }
  329. // ClearDeletedAt clears the value of the "deleted_at" field.
  330. func (m *AgentMutation) ClearDeletedAt() {
  331. m.deleted_at = nil
  332. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  333. }
  334. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  335. func (m *AgentMutation) DeletedAtCleared() bool {
  336. _, ok := m.clearedFields[agent.FieldDeletedAt]
  337. return ok
  338. }
  339. // ResetDeletedAt resets all changes to the "deleted_at" field.
  340. func (m *AgentMutation) ResetDeletedAt() {
  341. m.deleted_at = nil
  342. delete(m.clearedFields, agent.FieldDeletedAt)
  343. }
  344. // SetName sets the "name" field.
  345. func (m *AgentMutation) SetName(s string) {
  346. m.name = &s
  347. }
  348. // Name returns the value of the "name" field in the mutation.
  349. func (m *AgentMutation) Name() (r string, exists bool) {
  350. v := m.name
  351. if v == nil {
  352. return
  353. }
  354. return *v, true
  355. }
  356. // OldName returns the old "name" field's value of the Agent entity.
  357. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  359. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  360. if !m.op.Is(OpUpdateOne) {
  361. return v, errors.New("OldName is only allowed on UpdateOne operations")
  362. }
  363. if m.id == nil || m.oldValue == nil {
  364. return v, errors.New("OldName requires an ID field in the mutation")
  365. }
  366. oldValue, err := m.oldValue(ctx)
  367. if err != nil {
  368. return v, fmt.Errorf("querying old value for OldName: %w", err)
  369. }
  370. return oldValue.Name, nil
  371. }
  372. // ResetName resets all changes to the "name" field.
  373. func (m *AgentMutation) ResetName() {
  374. m.name = nil
  375. }
  376. // SetRole sets the "role" field.
  377. func (m *AgentMutation) SetRole(s string) {
  378. m.role = &s
  379. }
  380. // Role returns the value of the "role" field in the mutation.
  381. func (m *AgentMutation) Role() (r string, exists bool) {
  382. v := m.role
  383. if v == nil {
  384. return
  385. }
  386. return *v, true
  387. }
  388. // OldRole returns the old "role" field's value of the Agent entity.
  389. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  391. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  392. if !m.op.Is(OpUpdateOne) {
  393. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  394. }
  395. if m.id == nil || m.oldValue == nil {
  396. return v, errors.New("OldRole requires an ID field in the mutation")
  397. }
  398. oldValue, err := m.oldValue(ctx)
  399. if err != nil {
  400. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  401. }
  402. return oldValue.Role, nil
  403. }
  404. // ResetRole resets all changes to the "role" field.
  405. func (m *AgentMutation) ResetRole() {
  406. m.role = nil
  407. }
  408. // SetStatus sets the "status" field.
  409. func (m *AgentMutation) SetStatus(i int) {
  410. m.status = &i
  411. m.addstatus = nil
  412. }
  413. // Status returns the value of the "status" field in the mutation.
  414. func (m *AgentMutation) Status() (r int, exists bool) {
  415. v := m.status
  416. if v == nil {
  417. return
  418. }
  419. return *v, true
  420. }
  421. // OldStatus returns the old "status" field's value of the Agent entity.
  422. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  424. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  425. if !m.op.Is(OpUpdateOne) {
  426. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  427. }
  428. if m.id == nil || m.oldValue == nil {
  429. return v, errors.New("OldStatus requires an ID field in the mutation")
  430. }
  431. oldValue, err := m.oldValue(ctx)
  432. if err != nil {
  433. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  434. }
  435. return oldValue.Status, nil
  436. }
  437. // AddStatus adds i to the "status" field.
  438. func (m *AgentMutation) AddStatus(i int) {
  439. if m.addstatus != nil {
  440. *m.addstatus += i
  441. } else {
  442. m.addstatus = &i
  443. }
  444. }
  445. // AddedStatus returns the value that was added to the "status" field in this mutation.
  446. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  447. v := m.addstatus
  448. if v == nil {
  449. return
  450. }
  451. return *v, true
  452. }
  453. // ClearStatus clears the value of the "status" field.
  454. func (m *AgentMutation) ClearStatus() {
  455. m.status = nil
  456. m.addstatus = nil
  457. m.clearedFields[agent.FieldStatus] = struct{}{}
  458. }
  459. // StatusCleared returns if the "status" field was cleared in this mutation.
  460. func (m *AgentMutation) StatusCleared() bool {
  461. _, ok := m.clearedFields[agent.FieldStatus]
  462. return ok
  463. }
  464. // ResetStatus resets all changes to the "status" field.
  465. func (m *AgentMutation) ResetStatus() {
  466. m.status = nil
  467. m.addstatus = nil
  468. delete(m.clearedFields, agent.FieldStatus)
  469. }
  470. // SetBackground sets the "background" field.
  471. func (m *AgentMutation) SetBackground(s string) {
  472. m.background = &s
  473. }
  474. // Background returns the value of the "background" field in the mutation.
  475. func (m *AgentMutation) Background() (r string, exists bool) {
  476. v := m.background
  477. if v == nil {
  478. return
  479. }
  480. return *v, true
  481. }
  482. // OldBackground returns the old "background" field's value of the Agent entity.
  483. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  484. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  485. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  486. if !m.op.Is(OpUpdateOne) {
  487. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  488. }
  489. if m.id == nil || m.oldValue == nil {
  490. return v, errors.New("OldBackground requires an ID field in the mutation")
  491. }
  492. oldValue, err := m.oldValue(ctx)
  493. if err != nil {
  494. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  495. }
  496. return oldValue.Background, nil
  497. }
  498. // ClearBackground clears the value of the "background" field.
  499. func (m *AgentMutation) ClearBackground() {
  500. m.background = nil
  501. m.clearedFields[agent.FieldBackground] = struct{}{}
  502. }
  503. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  504. func (m *AgentMutation) BackgroundCleared() bool {
  505. _, ok := m.clearedFields[agent.FieldBackground]
  506. return ok
  507. }
  508. // ResetBackground resets all changes to the "background" field.
  509. func (m *AgentMutation) ResetBackground() {
  510. m.background = nil
  511. delete(m.clearedFields, agent.FieldBackground)
  512. }
  513. // SetExamples sets the "examples" field.
  514. func (m *AgentMutation) SetExamples(s string) {
  515. m.examples = &s
  516. }
  517. // Examples returns the value of the "examples" field in the mutation.
  518. func (m *AgentMutation) Examples() (r string, exists bool) {
  519. v := m.examples
  520. if v == nil {
  521. return
  522. }
  523. return *v, true
  524. }
  525. // OldExamples returns the old "examples" field's value of the Agent entity.
  526. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  528. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  529. if !m.op.Is(OpUpdateOne) {
  530. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  531. }
  532. if m.id == nil || m.oldValue == nil {
  533. return v, errors.New("OldExamples requires an ID field in the mutation")
  534. }
  535. oldValue, err := m.oldValue(ctx)
  536. if err != nil {
  537. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  538. }
  539. return oldValue.Examples, nil
  540. }
  541. // ClearExamples clears the value of the "examples" field.
  542. func (m *AgentMutation) ClearExamples() {
  543. m.examples = nil
  544. m.clearedFields[agent.FieldExamples] = struct{}{}
  545. }
  546. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  547. func (m *AgentMutation) ExamplesCleared() bool {
  548. _, ok := m.clearedFields[agent.FieldExamples]
  549. return ok
  550. }
  551. // ResetExamples resets all changes to the "examples" field.
  552. func (m *AgentMutation) ResetExamples() {
  553. m.examples = nil
  554. delete(m.clearedFields, agent.FieldExamples)
  555. }
  556. // SetOrganizationID sets the "organization_id" field.
  557. func (m *AgentMutation) SetOrganizationID(u uint64) {
  558. m.organization_id = &u
  559. m.addorganization_id = nil
  560. }
  561. // OrganizationID returns the value of the "organization_id" field in the mutation.
  562. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  563. v := m.organization_id
  564. if v == nil {
  565. return
  566. }
  567. return *v, true
  568. }
  569. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  570. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  572. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  573. if !m.op.Is(OpUpdateOne) {
  574. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  575. }
  576. if m.id == nil || m.oldValue == nil {
  577. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  578. }
  579. oldValue, err := m.oldValue(ctx)
  580. if err != nil {
  581. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  582. }
  583. return oldValue.OrganizationID, nil
  584. }
  585. // AddOrganizationID adds u to the "organization_id" field.
  586. func (m *AgentMutation) AddOrganizationID(u int64) {
  587. if m.addorganization_id != nil {
  588. *m.addorganization_id += u
  589. } else {
  590. m.addorganization_id = &u
  591. }
  592. }
  593. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  594. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  595. v := m.addorganization_id
  596. if v == nil {
  597. return
  598. }
  599. return *v, true
  600. }
  601. // ResetOrganizationID resets all changes to the "organization_id" field.
  602. func (m *AgentMutation) ResetOrganizationID() {
  603. m.organization_id = nil
  604. m.addorganization_id = nil
  605. }
  606. // SetDatasetID sets the "dataset_id" field.
  607. func (m *AgentMutation) SetDatasetID(s string) {
  608. m.dataset_id = &s
  609. }
  610. // DatasetID returns the value of the "dataset_id" field in the mutation.
  611. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  612. v := m.dataset_id
  613. if v == nil {
  614. return
  615. }
  616. return *v, true
  617. }
  618. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  619. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  621. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  622. if !m.op.Is(OpUpdateOne) {
  623. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  624. }
  625. if m.id == nil || m.oldValue == nil {
  626. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  627. }
  628. oldValue, err := m.oldValue(ctx)
  629. if err != nil {
  630. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  631. }
  632. return oldValue.DatasetID, nil
  633. }
  634. // ResetDatasetID resets all changes to the "dataset_id" field.
  635. func (m *AgentMutation) ResetDatasetID() {
  636. m.dataset_id = nil
  637. }
  638. // SetCollectionID sets the "collection_id" field.
  639. func (m *AgentMutation) SetCollectionID(s string) {
  640. m.collection_id = &s
  641. }
  642. // CollectionID returns the value of the "collection_id" field in the mutation.
  643. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  644. v := m.collection_id
  645. if v == nil {
  646. return
  647. }
  648. return *v, true
  649. }
  650. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  651. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  653. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  654. if !m.op.Is(OpUpdateOne) {
  655. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  656. }
  657. if m.id == nil || m.oldValue == nil {
  658. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  659. }
  660. oldValue, err := m.oldValue(ctx)
  661. if err != nil {
  662. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  663. }
  664. return oldValue.CollectionID, nil
  665. }
  666. // ResetCollectionID resets all changes to the "collection_id" field.
  667. func (m *AgentMutation) ResetCollectionID() {
  668. m.collection_id = nil
  669. }
  670. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  671. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  672. if m.wx_agent == nil {
  673. m.wx_agent = make(map[uint64]struct{})
  674. }
  675. for i := range ids {
  676. m.wx_agent[ids[i]] = struct{}{}
  677. }
  678. }
  679. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  680. func (m *AgentMutation) ClearWxAgent() {
  681. m.clearedwx_agent = true
  682. }
  683. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  684. func (m *AgentMutation) WxAgentCleared() bool {
  685. return m.clearedwx_agent
  686. }
  687. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  688. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  689. if m.removedwx_agent == nil {
  690. m.removedwx_agent = make(map[uint64]struct{})
  691. }
  692. for i := range ids {
  693. delete(m.wx_agent, ids[i])
  694. m.removedwx_agent[ids[i]] = struct{}{}
  695. }
  696. }
  697. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  698. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  699. for id := range m.removedwx_agent {
  700. ids = append(ids, id)
  701. }
  702. return
  703. }
  704. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  705. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  706. for id := range m.wx_agent {
  707. ids = append(ids, id)
  708. }
  709. return
  710. }
  711. // ResetWxAgent resets all changes to the "wx_agent" edge.
  712. func (m *AgentMutation) ResetWxAgent() {
  713. m.wx_agent = nil
  714. m.clearedwx_agent = false
  715. m.removedwx_agent = nil
  716. }
  717. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  718. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  719. if m.token_agent == nil {
  720. m.token_agent = make(map[uint64]struct{})
  721. }
  722. for i := range ids {
  723. m.token_agent[ids[i]] = struct{}{}
  724. }
  725. }
  726. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  727. func (m *AgentMutation) ClearTokenAgent() {
  728. m.clearedtoken_agent = true
  729. }
  730. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  731. func (m *AgentMutation) TokenAgentCleared() bool {
  732. return m.clearedtoken_agent
  733. }
  734. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  735. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  736. if m.removedtoken_agent == nil {
  737. m.removedtoken_agent = make(map[uint64]struct{})
  738. }
  739. for i := range ids {
  740. delete(m.token_agent, ids[i])
  741. m.removedtoken_agent[ids[i]] = struct{}{}
  742. }
  743. }
  744. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  745. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  746. for id := range m.removedtoken_agent {
  747. ids = append(ids, id)
  748. }
  749. return
  750. }
  751. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  752. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  753. for id := range m.token_agent {
  754. ids = append(ids, id)
  755. }
  756. return
  757. }
  758. // ResetTokenAgent resets all changes to the "token_agent" edge.
  759. func (m *AgentMutation) ResetTokenAgent() {
  760. m.token_agent = nil
  761. m.clearedtoken_agent = false
  762. m.removedtoken_agent = nil
  763. }
  764. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  765. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  766. if m.wa_agent == nil {
  767. m.wa_agent = make(map[uint64]struct{})
  768. }
  769. for i := range ids {
  770. m.wa_agent[ids[i]] = struct{}{}
  771. }
  772. }
  773. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  774. func (m *AgentMutation) ClearWaAgent() {
  775. m.clearedwa_agent = true
  776. }
  777. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  778. func (m *AgentMutation) WaAgentCleared() bool {
  779. return m.clearedwa_agent
  780. }
  781. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  782. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  783. if m.removedwa_agent == nil {
  784. m.removedwa_agent = make(map[uint64]struct{})
  785. }
  786. for i := range ids {
  787. delete(m.wa_agent, ids[i])
  788. m.removedwa_agent[ids[i]] = struct{}{}
  789. }
  790. }
  791. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  792. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  793. for id := range m.removedwa_agent {
  794. ids = append(ids, id)
  795. }
  796. return
  797. }
  798. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  799. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  800. for id := range m.wa_agent {
  801. ids = append(ids, id)
  802. }
  803. return
  804. }
  805. // ResetWaAgent resets all changes to the "wa_agent" edge.
  806. func (m *AgentMutation) ResetWaAgent() {
  807. m.wa_agent = nil
  808. m.clearedwa_agent = false
  809. m.removedwa_agent = nil
  810. }
  811. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  812. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  813. if m.key_agent == nil {
  814. m.key_agent = make(map[uint64]struct{})
  815. }
  816. for i := range ids {
  817. m.key_agent[ids[i]] = struct{}{}
  818. }
  819. }
  820. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  821. func (m *AgentMutation) ClearKeyAgent() {
  822. m.clearedkey_agent = true
  823. }
  824. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  825. func (m *AgentMutation) KeyAgentCleared() bool {
  826. return m.clearedkey_agent
  827. }
  828. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  829. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  830. if m.removedkey_agent == nil {
  831. m.removedkey_agent = make(map[uint64]struct{})
  832. }
  833. for i := range ids {
  834. delete(m.key_agent, ids[i])
  835. m.removedkey_agent[ids[i]] = struct{}{}
  836. }
  837. }
  838. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  839. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  840. for id := range m.removedkey_agent {
  841. ids = append(ids, id)
  842. }
  843. return
  844. }
  845. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  846. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  847. for id := range m.key_agent {
  848. ids = append(ids, id)
  849. }
  850. return
  851. }
  852. // ResetKeyAgent resets all changes to the "key_agent" edge.
  853. func (m *AgentMutation) ResetKeyAgent() {
  854. m.key_agent = nil
  855. m.clearedkey_agent = false
  856. m.removedkey_agent = nil
  857. }
  858. // Where appends a list predicates to the AgentMutation builder.
  859. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  860. m.predicates = append(m.predicates, ps...)
  861. }
  862. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  863. // users can use type-assertion to append predicates that do not depend on any generated package.
  864. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  865. p := make([]predicate.Agent, len(ps))
  866. for i := range ps {
  867. p[i] = ps[i]
  868. }
  869. m.Where(p...)
  870. }
  871. // Op returns the operation name.
  872. func (m *AgentMutation) Op() Op {
  873. return m.op
  874. }
  875. // SetOp allows setting the mutation operation.
  876. func (m *AgentMutation) SetOp(op Op) {
  877. m.op = op
  878. }
  879. // Type returns the node type of this mutation (Agent).
  880. func (m *AgentMutation) Type() string {
  881. return m.typ
  882. }
  883. // Fields returns all fields that were changed during this mutation. Note that in
  884. // order to get all numeric fields that were incremented/decremented, call
  885. // AddedFields().
  886. func (m *AgentMutation) Fields() []string {
  887. fields := make([]string, 0, 11)
  888. if m.created_at != nil {
  889. fields = append(fields, agent.FieldCreatedAt)
  890. }
  891. if m.updated_at != nil {
  892. fields = append(fields, agent.FieldUpdatedAt)
  893. }
  894. if m.deleted_at != nil {
  895. fields = append(fields, agent.FieldDeletedAt)
  896. }
  897. if m.name != nil {
  898. fields = append(fields, agent.FieldName)
  899. }
  900. if m.role != nil {
  901. fields = append(fields, agent.FieldRole)
  902. }
  903. if m.status != nil {
  904. fields = append(fields, agent.FieldStatus)
  905. }
  906. if m.background != nil {
  907. fields = append(fields, agent.FieldBackground)
  908. }
  909. if m.examples != nil {
  910. fields = append(fields, agent.FieldExamples)
  911. }
  912. if m.organization_id != nil {
  913. fields = append(fields, agent.FieldOrganizationID)
  914. }
  915. if m.dataset_id != nil {
  916. fields = append(fields, agent.FieldDatasetID)
  917. }
  918. if m.collection_id != nil {
  919. fields = append(fields, agent.FieldCollectionID)
  920. }
  921. return fields
  922. }
  923. // Field returns the value of a field with the given name. The second boolean
  924. // return value indicates that this field was not set, or was not defined in the
  925. // schema.
  926. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  927. switch name {
  928. case agent.FieldCreatedAt:
  929. return m.CreatedAt()
  930. case agent.FieldUpdatedAt:
  931. return m.UpdatedAt()
  932. case agent.FieldDeletedAt:
  933. return m.DeletedAt()
  934. case agent.FieldName:
  935. return m.Name()
  936. case agent.FieldRole:
  937. return m.Role()
  938. case agent.FieldStatus:
  939. return m.Status()
  940. case agent.FieldBackground:
  941. return m.Background()
  942. case agent.FieldExamples:
  943. return m.Examples()
  944. case agent.FieldOrganizationID:
  945. return m.OrganizationID()
  946. case agent.FieldDatasetID:
  947. return m.DatasetID()
  948. case agent.FieldCollectionID:
  949. return m.CollectionID()
  950. }
  951. return nil, false
  952. }
  953. // OldField returns the old value of the field from the database. An error is
  954. // returned if the mutation operation is not UpdateOne, or the query to the
  955. // database failed.
  956. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  957. switch name {
  958. case agent.FieldCreatedAt:
  959. return m.OldCreatedAt(ctx)
  960. case agent.FieldUpdatedAt:
  961. return m.OldUpdatedAt(ctx)
  962. case agent.FieldDeletedAt:
  963. return m.OldDeletedAt(ctx)
  964. case agent.FieldName:
  965. return m.OldName(ctx)
  966. case agent.FieldRole:
  967. return m.OldRole(ctx)
  968. case agent.FieldStatus:
  969. return m.OldStatus(ctx)
  970. case agent.FieldBackground:
  971. return m.OldBackground(ctx)
  972. case agent.FieldExamples:
  973. return m.OldExamples(ctx)
  974. case agent.FieldOrganizationID:
  975. return m.OldOrganizationID(ctx)
  976. case agent.FieldDatasetID:
  977. return m.OldDatasetID(ctx)
  978. case agent.FieldCollectionID:
  979. return m.OldCollectionID(ctx)
  980. }
  981. return nil, fmt.Errorf("unknown Agent field %s", name)
  982. }
  983. // SetField sets the value of a field with the given name. It returns an error if
  984. // the field is not defined in the schema, or if the type mismatched the field
  985. // type.
  986. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  987. switch name {
  988. case agent.FieldCreatedAt:
  989. v, ok := value.(time.Time)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.SetCreatedAt(v)
  994. return nil
  995. case agent.FieldUpdatedAt:
  996. v, ok := value.(time.Time)
  997. if !ok {
  998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  999. }
  1000. m.SetUpdatedAt(v)
  1001. return nil
  1002. case agent.FieldDeletedAt:
  1003. v, ok := value.(time.Time)
  1004. if !ok {
  1005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1006. }
  1007. m.SetDeletedAt(v)
  1008. return nil
  1009. case agent.FieldName:
  1010. v, ok := value.(string)
  1011. if !ok {
  1012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1013. }
  1014. m.SetName(v)
  1015. return nil
  1016. case agent.FieldRole:
  1017. v, ok := value.(string)
  1018. if !ok {
  1019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1020. }
  1021. m.SetRole(v)
  1022. return nil
  1023. case agent.FieldStatus:
  1024. v, ok := value.(int)
  1025. if !ok {
  1026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1027. }
  1028. m.SetStatus(v)
  1029. return nil
  1030. case agent.FieldBackground:
  1031. v, ok := value.(string)
  1032. if !ok {
  1033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1034. }
  1035. m.SetBackground(v)
  1036. return nil
  1037. case agent.FieldExamples:
  1038. v, ok := value.(string)
  1039. if !ok {
  1040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1041. }
  1042. m.SetExamples(v)
  1043. return nil
  1044. case agent.FieldOrganizationID:
  1045. v, ok := value.(uint64)
  1046. if !ok {
  1047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1048. }
  1049. m.SetOrganizationID(v)
  1050. return nil
  1051. case agent.FieldDatasetID:
  1052. v, ok := value.(string)
  1053. if !ok {
  1054. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1055. }
  1056. m.SetDatasetID(v)
  1057. return nil
  1058. case agent.FieldCollectionID:
  1059. v, ok := value.(string)
  1060. if !ok {
  1061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1062. }
  1063. m.SetCollectionID(v)
  1064. return nil
  1065. }
  1066. return fmt.Errorf("unknown Agent field %s", name)
  1067. }
  1068. // AddedFields returns all numeric fields that were incremented/decremented during
  1069. // this mutation.
  1070. func (m *AgentMutation) AddedFields() []string {
  1071. var fields []string
  1072. if m.addstatus != nil {
  1073. fields = append(fields, agent.FieldStatus)
  1074. }
  1075. if m.addorganization_id != nil {
  1076. fields = append(fields, agent.FieldOrganizationID)
  1077. }
  1078. return fields
  1079. }
  1080. // AddedField returns the numeric value that was incremented/decremented on a field
  1081. // with the given name. The second boolean return value indicates that this field
  1082. // was not set, or was not defined in the schema.
  1083. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1084. switch name {
  1085. case agent.FieldStatus:
  1086. return m.AddedStatus()
  1087. case agent.FieldOrganizationID:
  1088. return m.AddedOrganizationID()
  1089. }
  1090. return nil, false
  1091. }
  1092. // AddField adds the value to the field with the given name. It returns an error if
  1093. // the field is not defined in the schema, or if the type mismatched the field
  1094. // type.
  1095. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1096. switch name {
  1097. case agent.FieldStatus:
  1098. v, ok := value.(int)
  1099. if !ok {
  1100. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1101. }
  1102. m.AddStatus(v)
  1103. return nil
  1104. case agent.FieldOrganizationID:
  1105. v, ok := value.(int64)
  1106. if !ok {
  1107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1108. }
  1109. m.AddOrganizationID(v)
  1110. return nil
  1111. }
  1112. return fmt.Errorf("unknown Agent numeric field %s", name)
  1113. }
  1114. // ClearedFields returns all nullable fields that were cleared during this
  1115. // mutation.
  1116. func (m *AgentMutation) ClearedFields() []string {
  1117. var fields []string
  1118. if m.FieldCleared(agent.FieldDeletedAt) {
  1119. fields = append(fields, agent.FieldDeletedAt)
  1120. }
  1121. if m.FieldCleared(agent.FieldStatus) {
  1122. fields = append(fields, agent.FieldStatus)
  1123. }
  1124. if m.FieldCleared(agent.FieldBackground) {
  1125. fields = append(fields, agent.FieldBackground)
  1126. }
  1127. if m.FieldCleared(agent.FieldExamples) {
  1128. fields = append(fields, agent.FieldExamples)
  1129. }
  1130. return fields
  1131. }
  1132. // FieldCleared returns a boolean indicating if a field with the given name was
  1133. // cleared in this mutation.
  1134. func (m *AgentMutation) FieldCleared(name string) bool {
  1135. _, ok := m.clearedFields[name]
  1136. return ok
  1137. }
  1138. // ClearField clears the value of the field with the given name. It returns an
  1139. // error if the field is not defined in the schema.
  1140. func (m *AgentMutation) ClearField(name string) error {
  1141. switch name {
  1142. case agent.FieldDeletedAt:
  1143. m.ClearDeletedAt()
  1144. return nil
  1145. case agent.FieldStatus:
  1146. m.ClearStatus()
  1147. return nil
  1148. case agent.FieldBackground:
  1149. m.ClearBackground()
  1150. return nil
  1151. case agent.FieldExamples:
  1152. m.ClearExamples()
  1153. return nil
  1154. }
  1155. return fmt.Errorf("unknown Agent nullable field %s", name)
  1156. }
  1157. // ResetField resets all changes in the mutation for the field with the given name.
  1158. // It returns an error if the field is not defined in the schema.
  1159. func (m *AgentMutation) ResetField(name string) error {
  1160. switch name {
  1161. case agent.FieldCreatedAt:
  1162. m.ResetCreatedAt()
  1163. return nil
  1164. case agent.FieldUpdatedAt:
  1165. m.ResetUpdatedAt()
  1166. return nil
  1167. case agent.FieldDeletedAt:
  1168. m.ResetDeletedAt()
  1169. return nil
  1170. case agent.FieldName:
  1171. m.ResetName()
  1172. return nil
  1173. case agent.FieldRole:
  1174. m.ResetRole()
  1175. return nil
  1176. case agent.FieldStatus:
  1177. m.ResetStatus()
  1178. return nil
  1179. case agent.FieldBackground:
  1180. m.ResetBackground()
  1181. return nil
  1182. case agent.FieldExamples:
  1183. m.ResetExamples()
  1184. return nil
  1185. case agent.FieldOrganizationID:
  1186. m.ResetOrganizationID()
  1187. return nil
  1188. case agent.FieldDatasetID:
  1189. m.ResetDatasetID()
  1190. return nil
  1191. case agent.FieldCollectionID:
  1192. m.ResetCollectionID()
  1193. return nil
  1194. }
  1195. return fmt.Errorf("unknown Agent field %s", name)
  1196. }
  1197. // AddedEdges returns all edge names that were set/added in this mutation.
  1198. func (m *AgentMutation) AddedEdges() []string {
  1199. edges := make([]string, 0, 4)
  1200. if m.wx_agent != nil {
  1201. edges = append(edges, agent.EdgeWxAgent)
  1202. }
  1203. if m.token_agent != nil {
  1204. edges = append(edges, agent.EdgeTokenAgent)
  1205. }
  1206. if m.wa_agent != nil {
  1207. edges = append(edges, agent.EdgeWaAgent)
  1208. }
  1209. if m.key_agent != nil {
  1210. edges = append(edges, agent.EdgeKeyAgent)
  1211. }
  1212. return edges
  1213. }
  1214. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1215. // name in this mutation.
  1216. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1217. switch name {
  1218. case agent.EdgeWxAgent:
  1219. ids := make([]ent.Value, 0, len(m.wx_agent))
  1220. for id := range m.wx_agent {
  1221. ids = append(ids, id)
  1222. }
  1223. return ids
  1224. case agent.EdgeTokenAgent:
  1225. ids := make([]ent.Value, 0, len(m.token_agent))
  1226. for id := range m.token_agent {
  1227. ids = append(ids, id)
  1228. }
  1229. return ids
  1230. case agent.EdgeWaAgent:
  1231. ids := make([]ent.Value, 0, len(m.wa_agent))
  1232. for id := range m.wa_agent {
  1233. ids = append(ids, id)
  1234. }
  1235. return ids
  1236. case agent.EdgeKeyAgent:
  1237. ids := make([]ent.Value, 0, len(m.key_agent))
  1238. for id := range m.key_agent {
  1239. ids = append(ids, id)
  1240. }
  1241. return ids
  1242. }
  1243. return nil
  1244. }
  1245. // RemovedEdges returns all edge names that were removed in this mutation.
  1246. func (m *AgentMutation) RemovedEdges() []string {
  1247. edges := make([]string, 0, 4)
  1248. if m.removedwx_agent != nil {
  1249. edges = append(edges, agent.EdgeWxAgent)
  1250. }
  1251. if m.removedtoken_agent != nil {
  1252. edges = append(edges, agent.EdgeTokenAgent)
  1253. }
  1254. if m.removedwa_agent != nil {
  1255. edges = append(edges, agent.EdgeWaAgent)
  1256. }
  1257. if m.removedkey_agent != nil {
  1258. edges = append(edges, agent.EdgeKeyAgent)
  1259. }
  1260. return edges
  1261. }
  1262. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1263. // the given name in this mutation.
  1264. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1265. switch name {
  1266. case agent.EdgeWxAgent:
  1267. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1268. for id := range m.removedwx_agent {
  1269. ids = append(ids, id)
  1270. }
  1271. return ids
  1272. case agent.EdgeTokenAgent:
  1273. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1274. for id := range m.removedtoken_agent {
  1275. ids = append(ids, id)
  1276. }
  1277. return ids
  1278. case agent.EdgeWaAgent:
  1279. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1280. for id := range m.removedwa_agent {
  1281. ids = append(ids, id)
  1282. }
  1283. return ids
  1284. case agent.EdgeKeyAgent:
  1285. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  1286. for id := range m.removedkey_agent {
  1287. ids = append(ids, id)
  1288. }
  1289. return ids
  1290. }
  1291. return nil
  1292. }
  1293. // ClearedEdges returns all edge names that were cleared in this mutation.
  1294. func (m *AgentMutation) ClearedEdges() []string {
  1295. edges := make([]string, 0, 4)
  1296. if m.clearedwx_agent {
  1297. edges = append(edges, agent.EdgeWxAgent)
  1298. }
  1299. if m.clearedtoken_agent {
  1300. edges = append(edges, agent.EdgeTokenAgent)
  1301. }
  1302. if m.clearedwa_agent {
  1303. edges = append(edges, agent.EdgeWaAgent)
  1304. }
  1305. if m.clearedkey_agent {
  1306. edges = append(edges, agent.EdgeKeyAgent)
  1307. }
  1308. return edges
  1309. }
  1310. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1311. // was cleared in this mutation.
  1312. func (m *AgentMutation) EdgeCleared(name string) bool {
  1313. switch name {
  1314. case agent.EdgeWxAgent:
  1315. return m.clearedwx_agent
  1316. case agent.EdgeTokenAgent:
  1317. return m.clearedtoken_agent
  1318. case agent.EdgeWaAgent:
  1319. return m.clearedwa_agent
  1320. case agent.EdgeKeyAgent:
  1321. return m.clearedkey_agent
  1322. }
  1323. return false
  1324. }
  1325. // ClearEdge clears the value of the edge with the given name. It returns an error
  1326. // if that edge is not defined in the schema.
  1327. func (m *AgentMutation) ClearEdge(name string) error {
  1328. switch name {
  1329. }
  1330. return fmt.Errorf("unknown Agent unique edge %s", name)
  1331. }
  1332. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1333. // It returns an error if the edge is not defined in the schema.
  1334. func (m *AgentMutation) ResetEdge(name string) error {
  1335. switch name {
  1336. case agent.EdgeWxAgent:
  1337. m.ResetWxAgent()
  1338. return nil
  1339. case agent.EdgeTokenAgent:
  1340. m.ResetTokenAgent()
  1341. return nil
  1342. case agent.EdgeWaAgent:
  1343. m.ResetWaAgent()
  1344. return nil
  1345. case agent.EdgeKeyAgent:
  1346. m.ResetKeyAgent()
  1347. return nil
  1348. }
  1349. return fmt.Errorf("unknown Agent edge %s", name)
  1350. }
  1351. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1352. type AgentBaseMutation struct {
  1353. config
  1354. op Op
  1355. typ string
  1356. id *string
  1357. q *string
  1358. a *string
  1359. chunk_index *uint64
  1360. addchunk_index *int64
  1361. indexes *[]string
  1362. appendindexes []string
  1363. dataset_id *string
  1364. collection_id *string
  1365. source_name *string
  1366. can_write *[]bool
  1367. appendcan_write []bool
  1368. is_owner *[]bool
  1369. appendis_owner []bool
  1370. clearedFields map[string]struct{}
  1371. wx_agent map[uint64]struct{}
  1372. removedwx_agent map[uint64]struct{}
  1373. clearedwx_agent bool
  1374. done bool
  1375. oldValue func(context.Context) (*AgentBase, error)
  1376. predicates []predicate.AgentBase
  1377. }
  1378. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1379. // agentbaseOption allows management of the mutation configuration using functional options.
  1380. type agentbaseOption func(*AgentBaseMutation)
  1381. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1382. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1383. m := &AgentBaseMutation{
  1384. config: c,
  1385. op: op,
  1386. typ: TypeAgentBase,
  1387. clearedFields: make(map[string]struct{}),
  1388. }
  1389. for _, opt := range opts {
  1390. opt(m)
  1391. }
  1392. return m
  1393. }
  1394. // withAgentBaseID sets the ID field of the mutation.
  1395. func withAgentBaseID(id string) agentbaseOption {
  1396. return func(m *AgentBaseMutation) {
  1397. var (
  1398. err error
  1399. once sync.Once
  1400. value *AgentBase
  1401. )
  1402. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1403. once.Do(func() {
  1404. if m.done {
  1405. err = errors.New("querying old values post mutation is not allowed")
  1406. } else {
  1407. value, err = m.Client().AgentBase.Get(ctx, id)
  1408. }
  1409. })
  1410. return value, err
  1411. }
  1412. m.id = &id
  1413. }
  1414. }
  1415. // withAgentBase sets the old AgentBase of the mutation.
  1416. func withAgentBase(node *AgentBase) agentbaseOption {
  1417. return func(m *AgentBaseMutation) {
  1418. m.oldValue = func(context.Context) (*AgentBase, error) {
  1419. return node, nil
  1420. }
  1421. m.id = &node.ID
  1422. }
  1423. }
  1424. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1425. // executed in a transaction (ent.Tx), a transactional client is returned.
  1426. func (m AgentBaseMutation) Client() *Client {
  1427. client := &Client{config: m.config}
  1428. client.init()
  1429. return client
  1430. }
  1431. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1432. // it returns an error otherwise.
  1433. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1434. if _, ok := m.driver.(*txDriver); !ok {
  1435. return nil, errors.New("ent: mutation is not running in a transaction")
  1436. }
  1437. tx := &Tx{config: m.config}
  1438. tx.init()
  1439. return tx, nil
  1440. }
  1441. // SetID sets the value of the id field. Note that this
  1442. // operation is only accepted on creation of AgentBase entities.
  1443. func (m *AgentBaseMutation) SetID(id string) {
  1444. m.id = &id
  1445. }
  1446. // ID returns the ID value in the mutation. Note that the ID is only available
  1447. // if it was provided to the builder or after it was returned from the database.
  1448. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1449. if m.id == nil {
  1450. return
  1451. }
  1452. return *m.id, true
  1453. }
  1454. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1455. // That means, if the mutation is applied within a transaction with an isolation level such
  1456. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1457. // or updated by the mutation.
  1458. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1459. switch {
  1460. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1461. id, exists := m.ID()
  1462. if exists {
  1463. return []string{id}, nil
  1464. }
  1465. fallthrough
  1466. case m.op.Is(OpUpdate | OpDelete):
  1467. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1468. default:
  1469. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1470. }
  1471. }
  1472. // SetQ sets the "q" field.
  1473. func (m *AgentBaseMutation) SetQ(s string) {
  1474. m.q = &s
  1475. }
  1476. // Q returns the value of the "q" field in the mutation.
  1477. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1478. v := m.q
  1479. if v == nil {
  1480. return
  1481. }
  1482. return *v, true
  1483. }
  1484. // OldQ returns the old "q" field's value of the AgentBase entity.
  1485. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1487. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1488. if !m.op.Is(OpUpdateOne) {
  1489. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1490. }
  1491. if m.id == nil || m.oldValue == nil {
  1492. return v, errors.New("OldQ requires an ID field in the mutation")
  1493. }
  1494. oldValue, err := m.oldValue(ctx)
  1495. if err != nil {
  1496. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1497. }
  1498. return oldValue.Q, nil
  1499. }
  1500. // ClearQ clears the value of the "q" field.
  1501. func (m *AgentBaseMutation) ClearQ() {
  1502. m.q = nil
  1503. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1504. }
  1505. // QCleared returns if the "q" field was cleared in this mutation.
  1506. func (m *AgentBaseMutation) QCleared() bool {
  1507. _, ok := m.clearedFields[agentbase.FieldQ]
  1508. return ok
  1509. }
  1510. // ResetQ resets all changes to the "q" field.
  1511. func (m *AgentBaseMutation) ResetQ() {
  1512. m.q = nil
  1513. delete(m.clearedFields, agentbase.FieldQ)
  1514. }
  1515. // SetA sets the "a" field.
  1516. func (m *AgentBaseMutation) SetA(s string) {
  1517. m.a = &s
  1518. }
  1519. // A returns the value of the "a" field in the mutation.
  1520. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1521. v := m.a
  1522. if v == nil {
  1523. return
  1524. }
  1525. return *v, true
  1526. }
  1527. // OldA returns the old "a" field's value of the AgentBase entity.
  1528. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1530. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1531. if !m.op.Is(OpUpdateOne) {
  1532. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1533. }
  1534. if m.id == nil || m.oldValue == nil {
  1535. return v, errors.New("OldA requires an ID field in the mutation")
  1536. }
  1537. oldValue, err := m.oldValue(ctx)
  1538. if err != nil {
  1539. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1540. }
  1541. return oldValue.A, nil
  1542. }
  1543. // ClearA clears the value of the "a" field.
  1544. func (m *AgentBaseMutation) ClearA() {
  1545. m.a = nil
  1546. m.clearedFields[agentbase.FieldA] = struct{}{}
  1547. }
  1548. // ACleared returns if the "a" field was cleared in this mutation.
  1549. func (m *AgentBaseMutation) ACleared() bool {
  1550. _, ok := m.clearedFields[agentbase.FieldA]
  1551. return ok
  1552. }
  1553. // ResetA resets all changes to the "a" field.
  1554. func (m *AgentBaseMutation) ResetA() {
  1555. m.a = nil
  1556. delete(m.clearedFields, agentbase.FieldA)
  1557. }
  1558. // SetChunkIndex sets the "chunk_index" field.
  1559. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1560. m.chunk_index = &u
  1561. m.addchunk_index = nil
  1562. }
  1563. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1564. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1565. v := m.chunk_index
  1566. if v == nil {
  1567. return
  1568. }
  1569. return *v, true
  1570. }
  1571. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1572. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1574. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1575. if !m.op.Is(OpUpdateOne) {
  1576. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1577. }
  1578. if m.id == nil || m.oldValue == nil {
  1579. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1580. }
  1581. oldValue, err := m.oldValue(ctx)
  1582. if err != nil {
  1583. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1584. }
  1585. return oldValue.ChunkIndex, nil
  1586. }
  1587. // AddChunkIndex adds u to the "chunk_index" field.
  1588. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1589. if m.addchunk_index != nil {
  1590. *m.addchunk_index += u
  1591. } else {
  1592. m.addchunk_index = &u
  1593. }
  1594. }
  1595. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1596. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1597. v := m.addchunk_index
  1598. if v == nil {
  1599. return
  1600. }
  1601. return *v, true
  1602. }
  1603. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1604. func (m *AgentBaseMutation) ResetChunkIndex() {
  1605. m.chunk_index = nil
  1606. m.addchunk_index = nil
  1607. }
  1608. // SetIndexes sets the "indexes" field.
  1609. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1610. m.indexes = &s
  1611. m.appendindexes = nil
  1612. }
  1613. // Indexes returns the value of the "indexes" field in the mutation.
  1614. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1615. v := m.indexes
  1616. if v == nil {
  1617. return
  1618. }
  1619. return *v, true
  1620. }
  1621. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1622. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1624. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1625. if !m.op.Is(OpUpdateOne) {
  1626. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1627. }
  1628. if m.id == nil || m.oldValue == nil {
  1629. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1630. }
  1631. oldValue, err := m.oldValue(ctx)
  1632. if err != nil {
  1633. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1634. }
  1635. return oldValue.Indexes, nil
  1636. }
  1637. // AppendIndexes adds s to the "indexes" field.
  1638. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1639. m.appendindexes = append(m.appendindexes, s...)
  1640. }
  1641. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1642. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1643. if len(m.appendindexes) == 0 {
  1644. return nil, false
  1645. }
  1646. return m.appendindexes, true
  1647. }
  1648. // ClearIndexes clears the value of the "indexes" field.
  1649. func (m *AgentBaseMutation) ClearIndexes() {
  1650. m.indexes = nil
  1651. m.appendindexes = nil
  1652. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1653. }
  1654. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1655. func (m *AgentBaseMutation) IndexesCleared() bool {
  1656. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1657. return ok
  1658. }
  1659. // ResetIndexes resets all changes to the "indexes" field.
  1660. func (m *AgentBaseMutation) ResetIndexes() {
  1661. m.indexes = nil
  1662. m.appendindexes = nil
  1663. delete(m.clearedFields, agentbase.FieldIndexes)
  1664. }
  1665. // SetDatasetID sets the "dataset_id" field.
  1666. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1667. m.dataset_id = &s
  1668. }
  1669. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1670. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1671. v := m.dataset_id
  1672. if v == nil {
  1673. return
  1674. }
  1675. return *v, true
  1676. }
  1677. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1678. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1680. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1681. if !m.op.Is(OpUpdateOne) {
  1682. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1683. }
  1684. if m.id == nil || m.oldValue == nil {
  1685. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1686. }
  1687. oldValue, err := m.oldValue(ctx)
  1688. if err != nil {
  1689. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1690. }
  1691. return oldValue.DatasetID, nil
  1692. }
  1693. // ClearDatasetID clears the value of the "dataset_id" field.
  1694. func (m *AgentBaseMutation) ClearDatasetID() {
  1695. m.dataset_id = nil
  1696. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1697. }
  1698. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1699. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1700. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1701. return ok
  1702. }
  1703. // ResetDatasetID resets all changes to the "dataset_id" field.
  1704. func (m *AgentBaseMutation) ResetDatasetID() {
  1705. m.dataset_id = nil
  1706. delete(m.clearedFields, agentbase.FieldDatasetID)
  1707. }
  1708. // SetCollectionID sets the "collection_id" field.
  1709. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1710. m.collection_id = &s
  1711. }
  1712. // CollectionID returns the value of the "collection_id" field in the mutation.
  1713. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1714. v := m.collection_id
  1715. if v == nil {
  1716. return
  1717. }
  1718. return *v, true
  1719. }
  1720. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1721. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1723. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1724. if !m.op.Is(OpUpdateOne) {
  1725. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1726. }
  1727. if m.id == nil || m.oldValue == nil {
  1728. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1729. }
  1730. oldValue, err := m.oldValue(ctx)
  1731. if err != nil {
  1732. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1733. }
  1734. return oldValue.CollectionID, nil
  1735. }
  1736. // ClearCollectionID clears the value of the "collection_id" field.
  1737. func (m *AgentBaseMutation) ClearCollectionID() {
  1738. m.collection_id = nil
  1739. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1740. }
  1741. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1742. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1743. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1744. return ok
  1745. }
  1746. // ResetCollectionID resets all changes to the "collection_id" field.
  1747. func (m *AgentBaseMutation) ResetCollectionID() {
  1748. m.collection_id = nil
  1749. delete(m.clearedFields, agentbase.FieldCollectionID)
  1750. }
  1751. // SetSourceName sets the "source_name" field.
  1752. func (m *AgentBaseMutation) SetSourceName(s string) {
  1753. m.source_name = &s
  1754. }
  1755. // SourceName returns the value of the "source_name" field in the mutation.
  1756. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1757. v := m.source_name
  1758. if v == nil {
  1759. return
  1760. }
  1761. return *v, true
  1762. }
  1763. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1764. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1766. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1767. if !m.op.Is(OpUpdateOne) {
  1768. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1769. }
  1770. if m.id == nil || m.oldValue == nil {
  1771. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1772. }
  1773. oldValue, err := m.oldValue(ctx)
  1774. if err != nil {
  1775. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1776. }
  1777. return oldValue.SourceName, nil
  1778. }
  1779. // ClearSourceName clears the value of the "source_name" field.
  1780. func (m *AgentBaseMutation) ClearSourceName() {
  1781. m.source_name = nil
  1782. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1783. }
  1784. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1785. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1786. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1787. return ok
  1788. }
  1789. // ResetSourceName resets all changes to the "source_name" field.
  1790. func (m *AgentBaseMutation) ResetSourceName() {
  1791. m.source_name = nil
  1792. delete(m.clearedFields, agentbase.FieldSourceName)
  1793. }
  1794. // SetCanWrite sets the "can_write" field.
  1795. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1796. m.can_write = &b
  1797. m.appendcan_write = nil
  1798. }
  1799. // CanWrite returns the value of the "can_write" field in the mutation.
  1800. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1801. v := m.can_write
  1802. if v == nil {
  1803. return
  1804. }
  1805. return *v, true
  1806. }
  1807. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1808. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1810. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1811. if !m.op.Is(OpUpdateOne) {
  1812. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1813. }
  1814. if m.id == nil || m.oldValue == nil {
  1815. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1816. }
  1817. oldValue, err := m.oldValue(ctx)
  1818. if err != nil {
  1819. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1820. }
  1821. return oldValue.CanWrite, nil
  1822. }
  1823. // AppendCanWrite adds b to the "can_write" field.
  1824. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1825. m.appendcan_write = append(m.appendcan_write, b...)
  1826. }
  1827. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1828. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1829. if len(m.appendcan_write) == 0 {
  1830. return nil, false
  1831. }
  1832. return m.appendcan_write, true
  1833. }
  1834. // ClearCanWrite clears the value of the "can_write" field.
  1835. func (m *AgentBaseMutation) ClearCanWrite() {
  1836. m.can_write = nil
  1837. m.appendcan_write = nil
  1838. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1839. }
  1840. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1841. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1842. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1843. return ok
  1844. }
  1845. // ResetCanWrite resets all changes to the "can_write" field.
  1846. func (m *AgentBaseMutation) ResetCanWrite() {
  1847. m.can_write = nil
  1848. m.appendcan_write = nil
  1849. delete(m.clearedFields, agentbase.FieldCanWrite)
  1850. }
  1851. // SetIsOwner sets the "is_owner" field.
  1852. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1853. m.is_owner = &b
  1854. m.appendis_owner = nil
  1855. }
  1856. // IsOwner returns the value of the "is_owner" field in the mutation.
  1857. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1858. v := m.is_owner
  1859. if v == nil {
  1860. return
  1861. }
  1862. return *v, true
  1863. }
  1864. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1865. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1867. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1868. if !m.op.Is(OpUpdateOne) {
  1869. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1870. }
  1871. if m.id == nil || m.oldValue == nil {
  1872. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1873. }
  1874. oldValue, err := m.oldValue(ctx)
  1875. if err != nil {
  1876. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1877. }
  1878. return oldValue.IsOwner, nil
  1879. }
  1880. // AppendIsOwner adds b to the "is_owner" field.
  1881. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1882. m.appendis_owner = append(m.appendis_owner, b...)
  1883. }
  1884. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1885. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1886. if len(m.appendis_owner) == 0 {
  1887. return nil, false
  1888. }
  1889. return m.appendis_owner, true
  1890. }
  1891. // ClearIsOwner clears the value of the "is_owner" field.
  1892. func (m *AgentBaseMutation) ClearIsOwner() {
  1893. m.is_owner = nil
  1894. m.appendis_owner = nil
  1895. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1896. }
  1897. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1898. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1899. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1900. return ok
  1901. }
  1902. // ResetIsOwner resets all changes to the "is_owner" field.
  1903. func (m *AgentBaseMutation) ResetIsOwner() {
  1904. m.is_owner = nil
  1905. m.appendis_owner = nil
  1906. delete(m.clearedFields, agentbase.FieldIsOwner)
  1907. }
  1908. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1909. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1910. if m.wx_agent == nil {
  1911. m.wx_agent = make(map[uint64]struct{})
  1912. }
  1913. for i := range ids {
  1914. m.wx_agent[ids[i]] = struct{}{}
  1915. }
  1916. }
  1917. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1918. func (m *AgentBaseMutation) ClearWxAgent() {
  1919. m.clearedwx_agent = true
  1920. }
  1921. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1922. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1923. return m.clearedwx_agent
  1924. }
  1925. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1926. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1927. if m.removedwx_agent == nil {
  1928. m.removedwx_agent = make(map[uint64]struct{})
  1929. }
  1930. for i := range ids {
  1931. delete(m.wx_agent, ids[i])
  1932. m.removedwx_agent[ids[i]] = struct{}{}
  1933. }
  1934. }
  1935. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1936. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1937. for id := range m.removedwx_agent {
  1938. ids = append(ids, id)
  1939. }
  1940. return
  1941. }
  1942. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1943. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1944. for id := range m.wx_agent {
  1945. ids = append(ids, id)
  1946. }
  1947. return
  1948. }
  1949. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1950. func (m *AgentBaseMutation) ResetWxAgent() {
  1951. m.wx_agent = nil
  1952. m.clearedwx_agent = false
  1953. m.removedwx_agent = nil
  1954. }
  1955. // Where appends a list predicates to the AgentBaseMutation builder.
  1956. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1957. m.predicates = append(m.predicates, ps...)
  1958. }
  1959. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1960. // users can use type-assertion to append predicates that do not depend on any generated package.
  1961. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1962. p := make([]predicate.AgentBase, len(ps))
  1963. for i := range ps {
  1964. p[i] = ps[i]
  1965. }
  1966. m.Where(p...)
  1967. }
  1968. // Op returns the operation name.
  1969. func (m *AgentBaseMutation) Op() Op {
  1970. return m.op
  1971. }
  1972. // SetOp allows setting the mutation operation.
  1973. func (m *AgentBaseMutation) SetOp(op Op) {
  1974. m.op = op
  1975. }
  1976. // Type returns the node type of this mutation (AgentBase).
  1977. func (m *AgentBaseMutation) Type() string {
  1978. return m.typ
  1979. }
  1980. // Fields returns all fields that were changed during this mutation. Note that in
  1981. // order to get all numeric fields that were incremented/decremented, call
  1982. // AddedFields().
  1983. func (m *AgentBaseMutation) Fields() []string {
  1984. fields := make([]string, 0, 9)
  1985. if m.q != nil {
  1986. fields = append(fields, agentbase.FieldQ)
  1987. }
  1988. if m.a != nil {
  1989. fields = append(fields, agentbase.FieldA)
  1990. }
  1991. if m.chunk_index != nil {
  1992. fields = append(fields, agentbase.FieldChunkIndex)
  1993. }
  1994. if m.indexes != nil {
  1995. fields = append(fields, agentbase.FieldIndexes)
  1996. }
  1997. if m.dataset_id != nil {
  1998. fields = append(fields, agentbase.FieldDatasetID)
  1999. }
  2000. if m.collection_id != nil {
  2001. fields = append(fields, agentbase.FieldCollectionID)
  2002. }
  2003. if m.source_name != nil {
  2004. fields = append(fields, agentbase.FieldSourceName)
  2005. }
  2006. if m.can_write != nil {
  2007. fields = append(fields, agentbase.FieldCanWrite)
  2008. }
  2009. if m.is_owner != nil {
  2010. fields = append(fields, agentbase.FieldIsOwner)
  2011. }
  2012. return fields
  2013. }
  2014. // Field returns the value of a field with the given name. The second boolean
  2015. // return value indicates that this field was not set, or was not defined in the
  2016. // schema.
  2017. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  2018. switch name {
  2019. case agentbase.FieldQ:
  2020. return m.Q()
  2021. case agentbase.FieldA:
  2022. return m.A()
  2023. case agentbase.FieldChunkIndex:
  2024. return m.ChunkIndex()
  2025. case agentbase.FieldIndexes:
  2026. return m.Indexes()
  2027. case agentbase.FieldDatasetID:
  2028. return m.DatasetID()
  2029. case agentbase.FieldCollectionID:
  2030. return m.CollectionID()
  2031. case agentbase.FieldSourceName:
  2032. return m.SourceName()
  2033. case agentbase.FieldCanWrite:
  2034. return m.CanWrite()
  2035. case agentbase.FieldIsOwner:
  2036. return m.IsOwner()
  2037. }
  2038. return nil, false
  2039. }
  2040. // OldField returns the old value of the field from the database. An error is
  2041. // returned if the mutation operation is not UpdateOne, or the query to the
  2042. // database failed.
  2043. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2044. switch name {
  2045. case agentbase.FieldQ:
  2046. return m.OldQ(ctx)
  2047. case agentbase.FieldA:
  2048. return m.OldA(ctx)
  2049. case agentbase.FieldChunkIndex:
  2050. return m.OldChunkIndex(ctx)
  2051. case agentbase.FieldIndexes:
  2052. return m.OldIndexes(ctx)
  2053. case agentbase.FieldDatasetID:
  2054. return m.OldDatasetID(ctx)
  2055. case agentbase.FieldCollectionID:
  2056. return m.OldCollectionID(ctx)
  2057. case agentbase.FieldSourceName:
  2058. return m.OldSourceName(ctx)
  2059. case agentbase.FieldCanWrite:
  2060. return m.OldCanWrite(ctx)
  2061. case agentbase.FieldIsOwner:
  2062. return m.OldIsOwner(ctx)
  2063. }
  2064. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  2065. }
  2066. // SetField sets the value of a field with the given name. It returns an error if
  2067. // the field is not defined in the schema, or if the type mismatched the field
  2068. // type.
  2069. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  2070. switch name {
  2071. case agentbase.FieldQ:
  2072. v, ok := value.(string)
  2073. if !ok {
  2074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2075. }
  2076. m.SetQ(v)
  2077. return nil
  2078. case agentbase.FieldA:
  2079. v, ok := value.(string)
  2080. if !ok {
  2081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2082. }
  2083. m.SetA(v)
  2084. return nil
  2085. case agentbase.FieldChunkIndex:
  2086. v, ok := value.(uint64)
  2087. if !ok {
  2088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2089. }
  2090. m.SetChunkIndex(v)
  2091. return nil
  2092. case agentbase.FieldIndexes:
  2093. v, ok := value.([]string)
  2094. if !ok {
  2095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2096. }
  2097. m.SetIndexes(v)
  2098. return nil
  2099. case agentbase.FieldDatasetID:
  2100. v, ok := value.(string)
  2101. if !ok {
  2102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2103. }
  2104. m.SetDatasetID(v)
  2105. return nil
  2106. case agentbase.FieldCollectionID:
  2107. v, ok := value.(string)
  2108. if !ok {
  2109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2110. }
  2111. m.SetCollectionID(v)
  2112. return nil
  2113. case agentbase.FieldSourceName:
  2114. v, ok := value.(string)
  2115. if !ok {
  2116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2117. }
  2118. m.SetSourceName(v)
  2119. return nil
  2120. case agentbase.FieldCanWrite:
  2121. v, ok := value.([]bool)
  2122. if !ok {
  2123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2124. }
  2125. m.SetCanWrite(v)
  2126. return nil
  2127. case agentbase.FieldIsOwner:
  2128. v, ok := value.([]bool)
  2129. if !ok {
  2130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2131. }
  2132. m.SetIsOwner(v)
  2133. return nil
  2134. }
  2135. return fmt.Errorf("unknown AgentBase field %s", name)
  2136. }
  2137. // AddedFields returns all numeric fields that were incremented/decremented during
  2138. // this mutation.
  2139. func (m *AgentBaseMutation) AddedFields() []string {
  2140. var fields []string
  2141. if m.addchunk_index != nil {
  2142. fields = append(fields, agentbase.FieldChunkIndex)
  2143. }
  2144. return fields
  2145. }
  2146. // AddedField returns the numeric value that was incremented/decremented on a field
  2147. // with the given name. The second boolean return value indicates that this field
  2148. // was not set, or was not defined in the schema.
  2149. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2150. switch name {
  2151. case agentbase.FieldChunkIndex:
  2152. return m.AddedChunkIndex()
  2153. }
  2154. return nil, false
  2155. }
  2156. // AddField adds the value to the field with the given name. It returns an error if
  2157. // the field is not defined in the schema, or if the type mismatched the field
  2158. // type.
  2159. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2160. switch name {
  2161. case agentbase.FieldChunkIndex:
  2162. v, ok := value.(int64)
  2163. if !ok {
  2164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2165. }
  2166. m.AddChunkIndex(v)
  2167. return nil
  2168. }
  2169. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2170. }
  2171. // ClearedFields returns all nullable fields that were cleared during this
  2172. // mutation.
  2173. func (m *AgentBaseMutation) ClearedFields() []string {
  2174. var fields []string
  2175. if m.FieldCleared(agentbase.FieldQ) {
  2176. fields = append(fields, agentbase.FieldQ)
  2177. }
  2178. if m.FieldCleared(agentbase.FieldA) {
  2179. fields = append(fields, agentbase.FieldA)
  2180. }
  2181. if m.FieldCleared(agentbase.FieldIndexes) {
  2182. fields = append(fields, agentbase.FieldIndexes)
  2183. }
  2184. if m.FieldCleared(agentbase.FieldDatasetID) {
  2185. fields = append(fields, agentbase.FieldDatasetID)
  2186. }
  2187. if m.FieldCleared(agentbase.FieldCollectionID) {
  2188. fields = append(fields, agentbase.FieldCollectionID)
  2189. }
  2190. if m.FieldCleared(agentbase.FieldSourceName) {
  2191. fields = append(fields, agentbase.FieldSourceName)
  2192. }
  2193. if m.FieldCleared(agentbase.FieldCanWrite) {
  2194. fields = append(fields, agentbase.FieldCanWrite)
  2195. }
  2196. if m.FieldCleared(agentbase.FieldIsOwner) {
  2197. fields = append(fields, agentbase.FieldIsOwner)
  2198. }
  2199. return fields
  2200. }
  2201. // FieldCleared returns a boolean indicating if a field with the given name was
  2202. // cleared in this mutation.
  2203. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2204. _, ok := m.clearedFields[name]
  2205. return ok
  2206. }
  2207. // ClearField clears the value of the field with the given name. It returns an
  2208. // error if the field is not defined in the schema.
  2209. func (m *AgentBaseMutation) ClearField(name string) error {
  2210. switch name {
  2211. case agentbase.FieldQ:
  2212. m.ClearQ()
  2213. return nil
  2214. case agentbase.FieldA:
  2215. m.ClearA()
  2216. return nil
  2217. case agentbase.FieldIndexes:
  2218. m.ClearIndexes()
  2219. return nil
  2220. case agentbase.FieldDatasetID:
  2221. m.ClearDatasetID()
  2222. return nil
  2223. case agentbase.FieldCollectionID:
  2224. m.ClearCollectionID()
  2225. return nil
  2226. case agentbase.FieldSourceName:
  2227. m.ClearSourceName()
  2228. return nil
  2229. case agentbase.FieldCanWrite:
  2230. m.ClearCanWrite()
  2231. return nil
  2232. case agentbase.FieldIsOwner:
  2233. m.ClearIsOwner()
  2234. return nil
  2235. }
  2236. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2237. }
  2238. // ResetField resets all changes in the mutation for the field with the given name.
  2239. // It returns an error if the field is not defined in the schema.
  2240. func (m *AgentBaseMutation) ResetField(name string) error {
  2241. switch name {
  2242. case agentbase.FieldQ:
  2243. m.ResetQ()
  2244. return nil
  2245. case agentbase.FieldA:
  2246. m.ResetA()
  2247. return nil
  2248. case agentbase.FieldChunkIndex:
  2249. m.ResetChunkIndex()
  2250. return nil
  2251. case agentbase.FieldIndexes:
  2252. m.ResetIndexes()
  2253. return nil
  2254. case agentbase.FieldDatasetID:
  2255. m.ResetDatasetID()
  2256. return nil
  2257. case agentbase.FieldCollectionID:
  2258. m.ResetCollectionID()
  2259. return nil
  2260. case agentbase.FieldSourceName:
  2261. m.ResetSourceName()
  2262. return nil
  2263. case agentbase.FieldCanWrite:
  2264. m.ResetCanWrite()
  2265. return nil
  2266. case agentbase.FieldIsOwner:
  2267. m.ResetIsOwner()
  2268. return nil
  2269. }
  2270. return fmt.Errorf("unknown AgentBase field %s", name)
  2271. }
  2272. // AddedEdges returns all edge names that were set/added in this mutation.
  2273. func (m *AgentBaseMutation) AddedEdges() []string {
  2274. edges := make([]string, 0, 1)
  2275. if m.wx_agent != nil {
  2276. edges = append(edges, agentbase.EdgeWxAgent)
  2277. }
  2278. return edges
  2279. }
  2280. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2281. // name in this mutation.
  2282. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2283. switch name {
  2284. case agentbase.EdgeWxAgent:
  2285. ids := make([]ent.Value, 0, len(m.wx_agent))
  2286. for id := range m.wx_agent {
  2287. ids = append(ids, id)
  2288. }
  2289. return ids
  2290. }
  2291. return nil
  2292. }
  2293. // RemovedEdges returns all edge names that were removed in this mutation.
  2294. func (m *AgentBaseMutation) RemovedEdges() []string {
  2295. edges := make([]string, 0, 1)
  2296. if m.removedwx_agent != nil {
  2297. edges = append(edges, agentbase.EdgeWxAgent)
  2298. }
  2299. return edges
  2300. }
  2301. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2302. // the given name in this mutation.
  2303. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2304. switch name {
  2305. case agentbase.EdgeWxAgent:
  2306. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2307. for id := range m.removedwx_agent {
  2308. ids = append(ids, id)
  2309. }
  2310. return ids
  2311. }
  2312. return nil
  2313. }
  2314. // ClearedEdges returns all edge names that were cleared in this mutation.
  2315. func (m *AgentBaseMutation) ClearedEdges() []string {
  2316. edges := make([]string, 0, 1)
  2317. if m.clearedwx_agent {
  2318. edges = append(edges, agentbase.EdgeWxAgent)
  2319. }
  2320. return edges
  2321. }
  2322. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2323. // was cleared in this mutation.
  2324. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2325. switch name {
  2326. case agentbase.EdgeWxAgent:
  2327. return m.clearedwx_agent
  2328. }
  2329. return false
  2330. }
  2331. // ClearEdge clears the value of the edge with the given name. It returns an error
  2332. // if that edge is not defined in the schema.
  2333. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2334. switch name {
  2335. }
  2336. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2337. }
  2338. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2339. // It returns an error if the edge is not defined in the schema.
  2340. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2341. switch name {
  2342. case agentbase.EdgeWxAgent:
  2343. m.ResetWxAgent()
  2344. return nil
  2345. }
  2346. return fmt.Errorf("unknown AgentBase edge %s", name)
  2347. }
  2348. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2349. type AliyunAvatarMutation struct {
  2350. config
  2351. op Op
  2352. typ string
  2353. id *uint64
  2354. created_at *time.Time
  2355. updated_at *time.Time
  2356. deleted_at *time.Time
  2357. user_id *uint64
  2358. adduser_id *int64
  2359. biz_id *string
  2360. access_key_id *string
  2361. access_key_secret *string
  2362. app_id *string
  2363. tenant_id *uint64
  2364. addtenant_id *int64
  2365. response *string
  2366. token *string
  2367. session_id *string
  2368. clearedFields map[string]struct{}
  2369. done bool
  2370. oldValue func(context.Context) (*AliyunAvatar, error)
  2371. predicates []predicate.AliyunAvatar
  2372. }
  2373. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2374. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2375. type aliyunavatarOption func(*AliyunAvatarMutation)
  2376. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2377. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2378. m := &AliyunAvatarMutation{
  2379. config: c,
  2380. op: op,
  2381. typ: TypeAliyunAvatar,
  2382. clearedFields: make(map[string]struct{}),
  2383. }
  2384. for _, opt := range opts {
  2385. opt(m)
  2386. }
  2387. return m
  2388. }
  2389. // withAliyunAvatarID sets the ID field of the mutation.
  2390. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2391. return func(m *AliyunAvatarMutation) {
  2392. var (
  2393. err error
  2394. once sync.Once
  2395. value *AliyunAvatar
  2396. )
  2397. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2398. once.Do(func() {
  2399. if m.done {
  2400. err = errors.New("querying old values post mutation is not allowed")
  2401. } else {
  2402. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2403. }
  2404. })
  2405. return value, err
  2406. }
  2407. m.id = &id
  2408. }
  2409. }
  2410. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2411. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2412. return func(m *AliyunAvatarMutation) {
  2413. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2414. return node, nil
  2415. }
  2416. m.id = &node.ID
  2417. }
  2418. }
  2419. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2420. // executed in a transaction (ent.Tx), a transactional client is returned.
  2421. func (m AliyunAvatarMutation) Client() *Client {
  2422. client := &Client{config: m.config}
  2423. client.init()
  2424. return client
  2425. }
  2426. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2427. // it returns an error otherwise.
  2428. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2429. if _, ok := m.driver.(*txDriver); !ok {
  2430. return nil, errors.New("ent: mutation is not running in a transaction")
  2431. }
  2432. tx := &Tx{config: m.config}
  2433. tx.init()
  2434. return tx, nil
  2435. }
  2436. // SetID sets the value of the id field. Note that this
  2437. // operation is only accepted on creation of AliyunAvatar entities.
  2438. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2439. m.id = &id
  2440. }
  2441. // ID returns the ID value in the mutation. Note that the ID is only available
  2442. // if it was provided to the builder or after it was returned from the database.
  2443. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2444. if m.id == nil {
  2445. return
  2446. }
  2447. return *m.id, true
  2448. }
  2449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2450. // That means, if the mutation is applied within a transaction with an isolation level such
  2451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2452. // or updated by the mutation.
  2453. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2454. switch {
  2455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2456. id, exists := m.ID()
  2457. if exists {
  2458. return []uint64{id}, nil
  2459. }
  2460. fallthrough
  2461. case m.op.Is(OpUpdate | OpDelete):
  2462. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2463. default:
  2464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2465. }
  2466. }
  2467. // SetCreatedAt sets the "created_at" field.
  2468. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2469. m.created_at = &t
  2470. }
  2471. // CreatedAt returns the value of the "created_at" field in the mutation.
  2472. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2473. v := m.created_at
  2474. if v == nil {
  2475. return
  2476. }
  2477. return *v, true
  2478. }
  2479. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2480. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2482. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2483. if !m.op.Is(OpUpdateOne) {
  2484. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2485. }
  2486. if m.id == nil || m.oldValue == nil {
  2487. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2488. }
  2489. oldValue, err := m.oldValue(ctx)
  2490. if err != nil {
  2491. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2492. }
  2493. return oldValue.CreatedAt, nil
  2494. }
  2495. // ResetCreatedAt resets all changes to the "created_at" field.
  2496. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2497. m.created_at = nil
  2498. }
  2499. // SetUpdatedAt sets the "updated_at" field.
  2500. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2501. m.updated_at = &t
  2502. }
  2503. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2504. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2505. v := m.updated_at
  2506. if v == nil {
  2507. return
  2508. }
  2509. return *v, true
  2510. }
  2511. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2512. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2514. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2515. if !m.op.Is(OpUpdateOne) {
  2516. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2517. }
  2518. if m.id == nil || m.oldValue == nil {
  2519. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2520. }
  2521. oldValue, err := m.oldValue(ctx)
  2522. if err != nil {
  2523. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2524. }
  2525. return oldValue.UpdatedAt, nil
  2526. }
  2527. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2528. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2529. m.updated_at = nil
  2530. }
  2531. // SetDeletedAt sets the "deleted_at" field.
  2532. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2533. m.deleted_at = &t
  2534. }
  2535. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2536. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2537. v := m.deleted_at
  2538. if v == nil {
  2539. return
  2540. }
  2541. return *v, true
  2542. }
  2543. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2544. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2546. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2547. if !m.op.Is(OpUpdateOne) {
  2548. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2549. }
  2550. if m.id == nil || m.oldValue == nil {
  2551. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2552. }
  2553. oldValue, err := m.oldValue(ctx)
  2554. if err != nil {
  2555. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2556. }
  2557. return oldValue.DeletedAt, nil
  2558. }
  2559. // ClearDeletedAt clears the value of the "deleted_at" field.
  2560. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2561. m.deleted_at = nil
  2562. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2563. }
  2564. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2565. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2566. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2567. return ok
  2568. }
  2569. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2570. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2571. m.deleted_at = nil
  2572. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2573. }
  2574. // SetUserID sets the "user_id" field.
  2575. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2576. m.user_id = &u
  2577. m.adduser_id = nil
  2578. }
  2579. // UserID returns the value of the "user_id" field in the mutation.
  2580. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2581. v := m.user_id
  2582. if v == nil {
  2583. return
  2584. }
  2585. return *v, true
  2586. }
  2587. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2588. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2590. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2591. if !m.op.Is(OpUpdateOne) {
  2592. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2593. }
  2594. if m.id == nil || m.oldValue == nil {
  2595. return v, errors.New("OldUserID requires an ID field in the mutation")
  2596. }
  2597. oldValue, err := m.oldValue(ctx)
  2598. if err != nil {
  2599. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2600. }
  2601. return oldValue.UserID, nil
  2602. }
  2603. // AddUserID adds u to the "user_id" field.
  2604. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2605. if m.adduser_id != nil {
  2606. *m.adduser_id += u
  2607. } else {
  2608. m.adduser_id = &u
  2609. }
  2610. }
  2611. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2612. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2613. v := m.adduser_id
  2614. if v == nil {
  2615. return
  2616. }
  2617. return *v, true
  2618. }
  2619. // ResetUserID resets all changes to the "user_id" field.
  2620. func (m *AliyunAvatarMutation) ResetUserID() {
  2621. m.user_id = nil
  2622. m.adduser_id = nil
  2623. }
  2624. // SetBizID sets the "biz_id" field.
  2625. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2626. m.biz_id = &s
  2627. }
  2628. // BizID returns the value of the "biz_id" field in the mutation.
  2629. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2630. v := m.biz_id
  2631. if v == nil {
  2632. return
  2633. }
  2634. return *v, true
  2635. }
  2636. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2637. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2639. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2640. if !m.op.Is(OpUpdateOne) {
  2641. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2642. }
  2643. if m.id == nil || m.oldValue == nil {
  2644. return v, errors.New("OldBizID requires an ID field in the mutation")
  2645. }
  2646. oldValue, err := m.oldValue(ctx)
  2647. if err != nil {
  2648. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2649. }
  2650. return oldValue.BizID, nil
  2651. }
  2652. // ResetBizID resets all changes to the "biz_id" field.
  2653. func (m *AliyunAvatarMutation) ResetBizID() {
  2654. m.biz_id = nil
  2655. }
  2656. // SetAccessKeyID sets the "access_key_id" field.
  2657. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2658. m.access_key_id = &s
  2659. }
  2660. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2661. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2662. v := m.access_key_id
  2663. if v == nil {
  2664. return
  2665. }
  2666. return *v, true
  2667. }
  2668. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2669. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2671. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2672. if !m.op.Is(OpUpdateOne) {
  2673. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2674. }
  2675. if m.id == nil || m.oldValue == nil {
  2676. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2677. }
  2678. oldValue, err := m.oldValue(ctx)
  2679. if err != nil {
  2680. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2681. }
  2682. return oldValue.AccessKeyID, nil
  2683. }
  2684. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2685. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2686. m.access_key_id = nil
  2687. }
  2688. // SetAccessKeySecret sets the "access_key_secret" field.
  2689. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2690. m.access_key_secret = &s
  2691. }
  2692. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2693. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2694. v := m.access_key_secret
  2695. if v == nil {
  2696. return
  2697. }
  2698. return *v, true
  2699. }
  2700. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2701. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2703. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2704. if !m.op.Is(OpUpdateOne) {
  2705. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2706. }
  2707. if m.id == nil || m.oldValue == nil {
  2708. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2709. }
  2710. oldValue, err := m.oldValue(ctx)
  2711. if err != nil {
  2712. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2713. }
  2714. return oldValue.AccessKeySecret, nil
  2715. }
  2716. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2717. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2718. m.access_key_secret = nil
  2719. }
  2720. // SetAppID sets the "app_id" field.
  2721. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2722. m.app_id = &s
  2723. }
  2724. // AppID returns the value of the "app_id" field in the mutation.
  2725. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2726. v := m.app_id
  2727. if v == nil {
  2728. return
  2729. }
  2730. return *v, true
  2731. }
  2732. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2733. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2735. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2736. if !m.op.Is(OpUpdateOne) {
  2737. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2738. }
  2739. if m.id == nil || m.oldValue == nil {
  2740. return v, errors.New("OldAppID requires an ID field in the mutation")
  2741. }
  2742. oldValue, err := m.oldValue(ctx)
  2743. if err != nil {
  2744. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2745. }
  2746. return oldValue.AppID, nil
  2747. }
  2748. // ClearAppID clears the value of the "app_id" field.
  2749. func (m *AliyunAvatarMutation) ClearAppID() {
  2750. m.app_id = nil
  2751. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2752. }
  2753. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2754. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2755. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2756. return ok
  2757. }
  2758. // ResetAppID resets all changes to the "app_id" field.
  2759. func (m *AliyunAvatarMutation) ResetAppID() {
  2760. m.app_id = nil
  2761. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2762. }
  2763. // SetTenantID sets the "tenant_id" field.
  2764. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2765. m.tenant_id = &u
  2766. m.addtenant_id = nil
  2767. }
  2768. // TenantID returns the value of the "tenant_id" field in the mutation.
  2769. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2770. v := m.tenant_id
  2771. if v == nil {
  2772. return
  2773. }
  2774. return *v, true
  2775. }
  2776. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2777. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2779. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2780. if !m.op.Is(OpUpdateOne) {
  2781. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2782. }
  2783. if m.id == nil || m.oldValue == nil {
  2784. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2785. }
  2786. oldValue, err := m.oldValue(ctx)
  2787. if err != nil {
  2788. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2789. }
  2790. return oldValue.TenantID, nil
  2791. }
  2792. // AddTenantID adds u to the "tenant_id" field.
  2793. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2794. if m.addtenant_id != nil {
  2795. *m.addtenant_id += u
  2796. } else {
  2797. m.addtenant_id = &u
  2798. }
  2799. }
  2800. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2801. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2802. v := m.addtenant_id
  2803. if v == nil {
  2804. return
  2805. }
  2806. return *v, true
  2807. }
  2808. // ResetTenantID resets all changes to the "tenant_id" field.
  2809. func (m *AliyunAvatarMutation) ResetTenantID() {
  2810. m.tenant_id = nil
  2811. m.addtenant_id = nil
  2812. }
  2813. // SetResponse sets the "response" field.
  2814. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2815. m.response = &s
  2816. }
  2817. // Response returns the value of the "response" field in the mutation.
  2818. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2819. v := m.response
  2820. if v == nil {
  2821. return
  2822. }
  2823. return *v, true
  2824. }
  2825. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2826. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2828. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2829. if !m.op.Is(OpUpdateOne) {
  2830. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2831. }
  2832. if m.id == nil || m.oldValue == nil {
  2833. return v, errors.New("OldResponse requires an ID field in the mutation")
  2834. }
  2835. oldValue, err := m.oldValue(ctx)
  2836. if err != nil {
  2837. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2838. }
  2839. return oldValue.Response, nil
  2840. }
  2841. // ResetResponse resets all changes to the "response" field.
  2842. func (m *AliyunAvatarMutation) ResetResponse() {
  2843. m.response = nil
  2844. }
  2845. // SetToken sets the "token" field.
  2846. func (m *AliyunAvatarMutation) SetToken(s string) {
  2847. m.token = &s
  2848. }
  2849. // Token returns the value of the "token" field in the mutation.
  2850. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2851. v := m.token
  2852. if v == nil {
  2853. return
  2854. }
  2855. return *v, true
  2856. }
  2857. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2858. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2860. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2861. if !m.op.Is(OpUpdateOne) {
  2862. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2863. }
  2864. if m.id == nil || m.oldValue == nil {
  2865. return v, errors.New("OldToken requires an ID field in the mutation")
  2866. }
  2867. oldValue, err := m.oldValue(ctx)
  2868. if err != nil {
  2869. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2870. }
  2871. return oldValue.Token, nil
  2872. }
  2873. // ResetToken resets all changes to the "token" field.
  2874. func (m *AliyunAvatarMutation) ResetToken() {
  2875. m.token = nil
  2876. }
  2877. // SetSessionID sets the "session_id" field.
  2878. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2879. m.session_id = &s
  2880. }
  2881. // SessionID returns the value of the "session_id" field in the mutation.
  2882. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2883. v := m.session_id
  2884. if v == nil {
  2885. return
  2886. }
  2887. return *v, true
  2888. }
  2889. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2890. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2892. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2893. if !m.op.Is(OpUpdateOne) {
  2894. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2895. }
  2896. if m.id == nil || m.oldValue == nil {
  2897. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2898. }
  2899. oldValue, err := m.oldValue(ctx)
  2900. if err != nil {
  2901. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2902. }
  2903. return oldValue.SessionID, nil
  2904. }
  2905. // ResetSessionID resets all changes to the "session_id" field.
  2906. func (m *AliyunAvatarMutation) ResetSessionID() {
  2907. m.session_id = nil
  2908. }
  2909. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2910. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2911. m.predicates = append(m.predicates, ps...)
  2912. }
  2913. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2914. // users can use type-assertion to append predicates that do not depend on any generated package.
  2915. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2916. p := make([]predicate.AliyunAvatar, len(ps))
  2917. for i := range ps {
  2918. p[i] = ps[i]
  2919. }
  2920. m.Where(p...)
  2921. }
  2922. // Op returns the operation name.
  2923. func (m *AliyunAvatarMutation) Op() Op {
  2924. return m.op
  2925. }
  2926. // SetOp allows setting the mutation operation.
  2927. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2928. m.op = op
  2929. }
  2930. // Type returns the node type of this mutation (AliyunAvatar).
  2931. func (m *AliyunAvatarMutation) Type() string {
  2932. return m.typ
  2933. }
  2934. // Fields returns all fields that were changed during this mutation. Note that in
  2935. // order to get all numeric fields that were incremented/decremented, call
  2936. // AddedFields().
  2937. func (m *AliyunAvatarMutation) Fields() []string {
  2938. fields := make([]string, 0, 12)
  2939. if m.created_at != nil {
  2940. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2941. }
  2942. if m.updated_at != nil {
  2943. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2944. }
  2945. if m.deleted_at != nil {
  2946. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2947. }
  2948. if m.user_id != nil {
  2949. fields = append(fields, aliyunavatar.FieldUserID)
  2950. }
  2951. if m.biz_id != nil {
  2952. fields = append(fields, aliyunavatar.FieldBizID)
  2953. }
  2954. if m.access_key_id != nil {
  2955. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2956. }
  2957. if m.access_key_secret != nil {
  2958. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2959. }
  2960. if m.app_id != nil {
  2961. fields = append(fields, aliyunavatar.FieldAppID)
  2962. }
  2963. if m.tenant_id != nil {
  2964. fields = append(fields, aliyunavatar.FieldTenantID)
  2965. }
  2966. if m.response != nil {
  2967. fields = append(fields, aliyunavatar.FieldResponse)
  2968. }
  2969. if m.token != nil {
  2970. fields = append(fields, aliyunavatar.FieldToken)
  2971. }
  2972. if m.session_id != nil {
  2973. fields = append(fields, aliyunavatar.FieldSessionID)
  2974. }
  2975. return fields
  2976. }
  2977. // Field returns the value of a field with the given name. The second boolean
  2978. // return value indicates that this field was not set, or was not defined in the
  2979. // schema.
  2980. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2981. switch name {
  2982. case aliyunavatar.FieldCreatedAt:
  2983. return m.CreatedAt()
  2984. case aliyunavatar.FieldUpdatedAt:
  2985. return m.UpdatedAt()
  2986. case aliyunavatar.FieldDeletedAt:
  2987. return m.DeletedAt()
  2988. case aliyunavatar.FieldUserID:
  2989. return m.UserID()
  2990. case aliyunavatar.FieldBizID:
  2991. return m.BizID()
  2992. case aliyunavatar.FieldAccessKeyID:
  2993. return m.AccessKeyID()
  2994. case aliyunavatar.FieldAccessKeySecret:
  2995. return m.AccessKeySecret()
  2996. case aliyunavatar.FieldAppID:
  2997. return m.AppID()
  2998. case aliyunavatar.FieldTenantID:
  2999. return m.TenantID()
  3000. case aliyunavatar.FieldResponse:
  3001. return m.Response()
  3002. case aliyunavatar.FieldToken:
  3003. return m.Token()
  3004. case aliyunavatar.FieldSessionID:
  3005. return m.SessionID()
  3006. }
  3007. return nil, false
  3008. }
  3009. // OldField returns the old value of the field from the database. An error is
  3010. // returned if the mutation operation is not UpdateOne, or the query to the
  3011. // database failed.
  3012. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3013. switch name {
  3014. case aliyunavatar.FieldCreatedAt:
  3015. return m.OldCreatedAt(ctx)
  3016. case aliyunavatar.FieldUpdatedAt:
  3017. return m.OldUpdatedAt(ctx)
  3018. case aliyunavatar.FieldDeletedAt:
  3019. return m.OldDeletedAt(ctx)
  3020. case aliyunavatar.FieldUserID:
  3021. return m.OldUserID(ctx)
  3022. case aliyunavatar.FieldBizID:
  3023. return m.OldBizID(ctx)
  3024. case aliyunavatar.FieldAccessKeyID:
  3025. return m.OldAccessKeyID(ctx)
  3026. case aliyunavatar.FieldAccessKeySecret:
  3027. return m.OldAccessKeySecret(ctx)
  3028. case aliyunavatar.FieldAppID:
  3029. return m.OldAppID(ctx)
  3030. case aliyunavatar.FieldTenantID:
  3031. return m.OldTenantID(ctx)
  3032. case aliyunavatar.FieldResponse:
  3033. return m.OldResponse(ctx)
  3034. case aliyunavatar.FieldToken:
  3035. return m.OldToken(ctx)
  3036. case aliyunavatar.FieldSessionID:
  3037. return m.OldSessionID(ctx)
  3038. }
  3039. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  3040. }
  3041. // SetField sets the value of a field with the given name. It returns an error if
  3042. // the field is not defined in the schema, or if the type mismatched the field
  3043. // type.
  3044. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  3045. switch name {
  3046. case aliyunavatar.FieldCreatedAt:
  3047. v, ok := value.(time.Time)
  3048. if !ok {
  3049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3050. }
  3051. m.SetCreatedAt(v)
  3052. return nil
  3053. case aliyunavatar.FieldUpdatedAt:
  3054. v, ok := value.(time.Time)
  3055. if !ok {
  3056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3057. }
  3058. m.SetUpdatedAt(v)
  3059. return nil
  3060. case aliyunavatar.FieldDeletedAt:
  3061. v, ok := value.(time.Time)
  3062. if !ok {
  3063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3064. }
  3065. m.SetDeletedAt(v)
  3066. return nil
  3067. case aliyunavatar.FieldUserID:
  3068. v, ok := value.(uint64)
  3069. if !ok {
  3070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3071. }
  3072. m.SetUserID(v)
  3073. return nil
  3074. case aliyunavatar.FieldBizID:
  3075. v, ok := value.(string)
  3076. if !ok {
  3077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3078. }
  3079. m.SetBizID(v)
  3080. return nil
  3081. case aliyunavatar.FieldAccessKeyID:
  3082. v, ok := value.(string)
  3083. if !ok {
  3084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3085. }
  3086. m.SetAccessKeyID(v)
  3087. return nil
  3088. case aliyunavatar.FieldAccessKeySecret:
  3089. v, ok := value.(string)
  3090. if !ok {
  3091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3092. }
  3093. m.SetAccessKeySecret(v)
  3094. return nil
  3095. case aliyunavatar.FieldAppID:
  3096. v, ok := value.(string)
  3097. if !ok {
  3098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3099. }
  3100. m.SetAppID(v)
  3101. return nil
  3102. case aliyunavatar.FieldTenantID:
  3103. v, ok := value.(uint64)
  3104. if !ok {
  3105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3106. }
  3107. m.SetTenantID(v)
  3108. return nil
  3109. case aliyunavatar.FieldResponse:
  3110. v, ok := value.(string)
  3111. if !ok {
  3112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3113. }
  3114. m.SetResponse(v)
  3115. return nil
  3116. case aliyunavatar.FieldToken:
  3117. v, ok := value.(string)
  3118. if !ok {
  3119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3120. }
  3121. m.SetToken(v)
  3122. return nil
  3123. case aliyunavatar.FieldSessionID:
  3124. v, ok := value.(string)
  3125. if !ok {
  3126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3127. }
  3128. m.SetSessionID(v)
  3129. return nil
  3130. }
  3131. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3132. }
  3133. // AddedFields returns all numeric fields that were incremented/decremented during
  3134. // this mutation.
  3135. func (m *AliyunAvatarMutation) AddedFields() []string {
  3136. var fields []string
  3137. if m.adduser_id != nil {
  3138. fields = append(fields, aliyunavatar.FieldUserID)
  3139. }
  3140. if m.addtenant_id != nil {
  3141. fields = append(fields, aliyunavatar.FieldTenantID)
  3142. }
  3143. return fields
  3144. }
  3145. // AddedField returns the numeric value that was incremented/decremented on a field
  3146. // with the given name. The second boolean return value indicates that this field
  3147. // was not set, or was not defined in the schema.
  3148. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3149. switch name {
  3150. case aliyunavatar.FieldUserID:
  3151. return m.AddedUserID()
  3152. case aliyunavatar.FieldTenantID:
  3153. return m.AddedTenantID()
  3154. }
  3155. return nil, false
  3156. }
  3157. // AddField adds the value to the field with the given name. It returns an error if
  3158. // the field is not defined in the schema, or if the type mismatched the field
  3159. // type.
  3160. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3161. switch name {
  3162. case aliyunavatar.FieldUserID:
  3163. v, ok := value.(int64)
  3164. if !ok {
  3165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3166. }
  3167. m.AddUserID(v)
  3168. return nil
  3169. case aliyunavatar.FieldTenantID:
  3170. v, ok := value.(int64)
  3171. if !ok {
  3172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3173. }
  3174. m.AddTenantID(v)
  3175. return nil
  3176. }
  3177. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3178. }
  3179. // ClearedFields returns all nullable fields that were cleared during this
  3180. // mutation.
  3181. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3182. var fields []string
  3183. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3184. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3185. }
  3186. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3187. fields = append(fields, aliyunavatar.FieldAppID)
  3188. }
  3189. return fields
  3190. }
  3191. // FieldCleared returns a boolean indicating if a field with the given name was
  3192. // cleared in this mutation.
  3193. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3194. _, ok := m.clearedFields[name]
  3195. return ok
  3196. }
  3197. // ClearField clears the value of the field with the given name. It returns an
  3198. // error if the field is not defined in the schema.
  3199. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3200. switch name {
  3201. case aliyunavatar.FieldDeletedAt:
  3202. m.ClearDeletedAt()
  3203. return nil
  3204. case aliyunavatar.FieldAppID:
  3205. m.ClearAppID()
  3206. return nil
  3207. }
  3208. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3209. }
  3210. // ResetField resets all changes in the mutation for the field with the given name.
  3211. // It returns an error if the field is not defined in the schema.
  3212. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3213. switch name {
  3214. case aliyunavatar.FieldCreatedAt:
  3215. m.ResetCreatedAt()
  3216. return nil
  3217. case aliyunavatar.FieldUpdatedAt:
  3218. m.ResetUpdatedAt()
  3219. return nil
  3220. case aliyunavatar.FieldDeletedAt:
  3221. m.ResetDeletedAt()
  3222. return nil
  3223. case aliyunavatar.FieldUserID:
  3224. m.ResetUserID()
  3225. return nil
  3226. case aliyunavatar.FieldBizID:
  3227. m.ResetBizID()
  3228. return nil
  3229. case aliyunavatar.FieldAccessKeyID:
  3230. m.ResetAccessKeyID()
  3231. return nil
  3232. case aliyunavatar.FieldAccessKeySecret:
  3233. m.ResetAccessKeySecret()
  3234. return nil
  3235. case aliyunavatar.FieldAppID:
  3236. m.ResetAppID()
  3237. return nil
  3238. case aliyunavatar.FieldTenantID:
  3239. m.ResetTenantID()
  3240. return nil
  3241. case aliyunavatar.FieldResponse:
  3242. m.ResetResponse()
  3243. return nil
  3244. case aliyunavatar.FieldToken:
  3245. m.ResetToken()
  3246. return nil
  3247. case aliyunavatar.FieldSessionID:
  3248. m.ResetSessionID()
  3249. return nil
  3250. }
  3251. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3252. }
  3253. // AddedEdges returns all edge names that were set/added in this mutation.
  3254. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3255. edges := make([]string, 0, 0)
  3256. return edges
  3257. }
  3258. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3259. // name in this mutation.
  3260. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3261. return nil
  3262. }
  3263. // RemovedEdges returns all edge names that were removed in this mutation.
  3264. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3265. edges := make([]string, 0, 0)
  3266. return edges
  3267. }
  3268. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3269. // the given name in this mutation.
  3270. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3271. return nil
  3272. }
  3273. // ClearedEdges returns all edge names that were cleared in this mutation.
  3274. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3275. edges := make([]string, 0, 0)
  3276. return edges
  3277. }
  3278. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3279. // was cleared in this mutation.
  3280. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3281. return false
  3282. }
  3283. // ClearEdge clears the value of the edge with the given name. It returns an error
  3284. // if that edge is not defined in the schema.
  3285. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3286. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3287. }
  3288. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3289. // It returns an error if the edge is not defined in the schema.
  3290. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3291. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3292. }
  3293. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3294. type AllocAgentMutation struct {
  3295. config
  3296. op Op
  3297. typ string
  3298. id *uint64
  3299. created_at *time.Time
  3300. updated_at *time.Time
  3301. deleted_at *time.Time
  3302. user_id *string
  3303. organization_id *uint64
  3304. addorganization_id *int64
  3305. agents *[]uint64
  3306. appendagents []uint64
  3307. status *int
  3308. addstatus *int
  3309. clearedFields map[string]struct{}
  3310. done bool
  3311. oldValue func(context.Context) (*AllocAgent, error)
  3312. predicates []predicate.AllocAgent
  3313. }
  3314. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3315. // allocagentOption allows management of the mutation configuration using functional options.
  3316. type allocagentOption func(*AllocAgentMutation)
  3317. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3318. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3319. m := &AllocAgentMutation{
  3320. config: c,
  3321. op: op,
  3322. typ: TypeAllocAgent,
  3323. clearedFields: make(map[string]struct{}),
  3324. }
  3325. for _, opt := range opts {
  3326. opt(m)
  3327. }
  3328. return m
  3329. }
  3330. // withAllocAgentID sets the ID field of the mutation.
  3331. func withAllocAgentID(id uint64) allocagentOption {
  3332. return func(m *AllocAgentMutation) {
  3333. var (
  3334. err error
  3335. once sync.Once
  3336. value *AllocAgent
  3337. )
  3338. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3339. once.Do(func() {
  3340. if m.done {
  3341. err = errors.New("querying old values post mutation is not allowed")
  3342. } else {
  3343. value, err = m.Client().AllocAgent.Get(ctx, id)
  3344. }
  3345. })
  3346. return value, err
  3347. }
  3348. m.id = &id
  3349. }
  3350. }
  3351. // withAllocAgent sets the old AllocAgent of the mutation.
  3352. func withAllocAgent(node *AllocAgent) allocagentOption {
  3353. return func(m *AllocAgentMutation) {
  3354. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3355. return node, nil
  3356. }
  3357. m.id = &node.ID
  3358. }
  3359. }
  3360. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3361. // executed in a transaction (ent.Tx), a transactional client is returned.
  3362. func (m AllocAgentMutation) Client() *Client {
  3363. client := &Client{config: m.config}
  3364. client.init()
  3365. return client
  3366. }
  3367. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3368. // it returns an error otherwise.
  3369. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3370. if _, ok := m.driver.(*txDriver); !ok {
  3371. return nil, errors.New("ent: mutation is not running in a transaction")
  3372. }
  3373. tx := &Tx{config: m.config}
  3374. tx.init()
  3375. return tx, nil
  3376. }
  3377. // SetID sets the value of the id field. Note that this
  3378. // operation is only accepted on creation of AllocAgent entities.
  3379. func (m *AllocAgentMutation) SetID(id uint64) {
  3380. m.id = &id
  3381. }
  3382. // ID returns the ID value in the mutation. Note that the ID is only available
  3383. // if it was provided to the builder or after it was returned from the database.
  3384. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3385. if m.id == nil {
  3386. return
  3387. }
  3388. return *m.id, true
  3389. }
  3390. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3391. // That means, if the mutation is applied within a transaction with an isolation level such
  3392. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3393. // or updated by the mutation.
  3394. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3395. switch {
  3396. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3397. id, exists := m.ID()
  3398. if exists {
  3399. return []uint64{id}, nil
  3400. }
  3401. fallthrough
  3402. case m.op.Is(OpUpdate | OpDelete):
  3403. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3404. default:
  3405. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3406. }
  3407. }
  3408. // SetCreatedAt sets the "created_at" field.
  3409. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3410. m.created_at = &t
  3411. }
  3412. // CreatedAt returns the value of the "created_at" field in the mutation.
  3413. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3414. v := m.created_at
  3415. if v == nil {
  3416. return
  3417. }
  3418. return *v, true
  3419. }
  3420. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3421. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3423. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3424. if !m.op.Is(OpUpdateOne) {
  3425. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3426. }
  3427. if m.id == nil || m.oldValue == nil {
  3428. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3429. }
  3430. oldValue, err := m.oldValue(ctx)
  3431. if err != nil {
  3432. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3433. }
  3434. return oldValue.CreatedAt, nil
  3435. }
  3436. // ResetCreatedAt resets all changes to the "created_at" field.
  3437. func (m *AllocAgentMutation) ResetCreatedAt() {
  3438. m.created_at = nil
  3439. }
  3440. // SetUpdatedAt sets the "updated_at" field.
  3441. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3442. m.updated_at = &t
  3443. }
  3444. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3445. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3446. v := m.updated_at
  3447. if v == nil {
  3448. return
  3449. }
  3450. return *v, true
  3451. }
  3452. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3453. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3455. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3456. if !m.op.Is(OpUpdateOne) {
  3457. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3458. }
  3459. if m.id == nil || m.oldValue == nil {
  3460. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3461. }
  3462. oldValue, err := m.oldValue(ctx)
  3463. if err != nil {
  3464. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3465. }
  3466. return oldValue.UpdatedAt, nil
  3467. }
  3468. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3469. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3470. m.updated_at = nil
  3471. }
  3472. // SetDeletedAt sets the "deleted_at" field.
  3473. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3474. m.deleted_at = &t
  3475. }
  3476. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3477. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3478. v := m.deleted_at
  3479. if v == nil {
  3480. return
  3481. }
  3482. return *v, true
  3483. }
  3484. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3485. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3487. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3488. if !m.op.Is(OpUpdateOne) {
  3489. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3490. }
  3491. if m.id == nil || m.oldValue == nil {
  3492. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3493. }
  3494. oldValue, err := m.oldValue(ctx)
  3495. if err != nil {
  3496. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3497. }
  3498. return oldValue.DeletedAt, nil
  3499. }
  3500. // ClearDeletedAt clears the value of the "deleted_at" field.
  3501. func (m *AllocAgentMutation) ClearDeletedAt() {
  3502. m.deleted_at = nil
  3503. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3504. }
  3505. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3506. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3507. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3508. return ok
  3509. }
  3510. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3511. func (m *AllocAgentMutation) ResetDeletedAt() {
  3512. m.deleted_at = nil
  3513. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3514. }
  3515. // SetUserID sets the "user_id" field.
  3516. func (m *AllocAgentMutation) SetUserID(s string) {
  3517. m.user_id = &s
  3518. }
  3519. // UserID returns the value of the "user_id" field in the mutation.
  3520. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3521. v := m.user_id
  3522. if v == nil {
  3523. return
  3524. }
  3525. return *v, true
  3526. }
  3527. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3528. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3529. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3530. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3531. if !m.op.Is(OpUpdateOne) {
  3532. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3533. }
  3534. if m.id == nil || m.oldValue == nil {
  3535. return v, errors.New("OldUserID requires an ID field in the mutation")
  3536. }
  3537. oldValue, err := m.oldValue(ctx)
  3538. if err != nil {
  3539. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3540. }
  3541. return oldValue.UserID, nil
  3542. }
  3543. // ClearUserID clears the value of the "user_id" field.
  3544. func (m *AllocAgentMutation) ClearUserID() {
  3545. m.user_id = nil
  3546. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3547. }
  3548. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3549. func (m *AllocAgentMutation) UserIDCleared() bool {
  3550. _, ok := m.clearedFields[allocagent.FieldUserID]
  3551. return ok
  3552. }
  3553. // ResetUserID resets all changes to the "user_id" field.
  3554. func (m *AllocAgentMutation) ResetUserID() {
  3555. m.user_id = nil
  3556. delete(m.clearedFields, allocagent.FieldUserID)
  3557. }
  3558. // SetOrganizationID sets the "organization_id" field.
  3559. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3560. m.organization_id = &u
  3561. m.addorganization_id = nil
  3562. }
  3563. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3564. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3565. v := m.organization_id
  3566. if v == nil {
  3567. return
  3568. }
  3569. return *v, true
  3570. }
  3571. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3572. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3574. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3575. if !m.op.Is(OpUpdateOne) {
  3576. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3577. }
  3578. if m.id == nil || m.oldValue == nil {
  3579. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3580. }
  3581. oldValue, err := m.oldValue(ctx)
  3582. if err != nil {
  3583. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3584. }
  3585. return oldValue.OrganizationID, nil
  3586. }
  3587. // AddOrganizationID adds u to the "organization_id" field.
  3588. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3589. if m.addorganization_id != nil {
  3590. *m.addorganization_id += u
  3591. } else {
  3592. m.addorganization_id = &u
  3593. }
  3594. }
  3595. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3596. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3597. v := m.addorganization_id
  3598. if v == nil {
  3599. return
  3600. }
  3601. return *v, true
  3602. }
  3603. // ClearOrganizationID clears the value of the "organization_id" field.
  3604. func (m *AllocAgentMutation) ClearOrganizationID() {
  3605. m.organization_id = nil
  3606. m.addorganization_id = nil
  3607. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3608. }
  3609. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3610. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3611. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3612. return ok
  3613. }
  3614. // ResetOrganizationID resets all changes to the "organization_id" field.
  3615. func (m *AllocAgentMutation) ResetOrganizationID() {
  3616. m.organization_id = nil
  3617. m.addorganization_id = nil
  3618. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3619. }
  3620. // SetAgents sets the "agents" field.
  3621. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3622. m.agents = &u
  3623. m.appendagents = nil
  3624. }
  3625. // Agents returns the value of the "agents" field in the mutation.
  3626. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3627. v := m.agents
  3628. if v == nil {
  3629. return
  3630. }
  3631. return *v, true
  3632. }
  3633. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3634. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3636. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3637. if !m.op.Is(OpUpdateOne) {
  3638. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3639. }
  3640. if m.id == nil || m.oldValue == nil {
  3641. return v, errors.New("OldAgents requires an ID field in the mutation")
  3642. }
  3643. oldValue, err := m.oldValue(ctx)
  3644. if err != nil {
  3645. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3646. }
  3647. return oldValue.Agents, nil
  3648. }
  3649. // AppendAgents adds u to the "agents" field.
  3650. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3651. m.appendagents = append(m.appendagents, u...)
  3652. }
  3653. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3654. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3655. if len(m.appendagents) == 0 {
  3656. return nil, false
  3657. }
  3658. return m.appendagents, true
  3659. }
  3660. // ResetAgents resets all changes to the "agents" field.
  3661. func (m *AllocAgentMutation) ResetAgents() {
  3662. m.agents = nil
  3663. m.appendagents = nil
  3664. }
  3665. // SetStatus sets the "status" field.
  3666. func (m *AllocAgentMutation) SetStatus(i int) {
  3667. m.status = &i
  3668. m.addstatus = nil
  3669. }
  3670. // Status returns the value of the "status" field in the mutation.
  3671. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3672. v := m.status
  3673. if v == nil {
  3674. return
  3675. }
  3676. return *v, true
  3677. }
  3678. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3679. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3681. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3682. if !m.op.Is(OpUpdateOne) {
  3683. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3684. }
  3685. if m.id == nil || m.oldValue == nil {
  3686. return v, errors.New("OldStatus requires an ID field in the mutation")
  3687. }
  3688. oldValue, err := m.oldValue(ctx)
  3689. if err != nil {
  3690. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3691. }
  3692. return oldValue.Status, nil
  3693. }
  3694. // AddStatus adds i to the "status" field.
  3695. func (m *AllocAgentMutation) AddStatus(i int) {
  3696. if m.addstatus != nil {
  3697. *m.addstatus += i
  3698. } else {
  3699. m.addstatus = &i
  3700. }
  3701. }
  3702. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3703. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3704. v := m.addstatus
  3705. if v == nil {
  3706. return
  3707. }
  3708. return *v, true
  3709. }
  3710. // ClearStatus clears the value of the "status" field.
  3711. func (m *AllocAgentMutation) ClearStatus() {
  3712. m.status = nil
  3713. m.addstatus = nil
  3714. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3715. }
  3716. // StatusCleared returns if the "status" field was cleared in this mutation.
  3717. func (m *AllocAgentMutation) StatusCleared() bool {
  3718. _, ok := m.clearedFields[allocagent.FieldStatus]
  3719. return ok
  3720. }
  3721. // ResetStatus resets all changes to the "status" field.
  3722. func (m *AllocAgentMutation) ResetStatus() {
  3723. m.status = nil
  3724. m.addstatus = nil
  3725. delete(m.clearedFields, allocagent.FieldStatus)
  3726. }
  3727. // Where appends a list predicates to the AllocAgentMutation builder.
  3728. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3729. m.predicates = append(m.predicates, ps...)
  3730. }
  3731. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3732. // users can use type-assertion to append predicates that do not depend on any generated package.
  3733. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3734. p := make([]predicate.AllocAgent, len(ps))
  3735. for i := range ps {
  3736. p[i] = ps[i]
  3737. }
  3738. m.Where(p...)
  3739. }
  3740. // Op returns the operation name.
  3741. func (m *AllocAgentMutation) Op() Op {
  3742. return m.op
  3743. }
  3744. // SetOp allows setting the mutation operation.
  3745. func (m *AllocAgentMutation) SetOp(op Op) {
  3746. m.op = op
  3747. }
  3748. // Type returns the node type of this mutation (AllocAgent).
  3749. func (m *AllocAgentMutation) Type() string {
  3750. return m.typ
  3751. }
  3752. // Fields returns all fields that were changed during this mutation. Note that in
  3753. // order to get all numeric fields that were incremented/decremented, call
  3754. // AddedFields().
  3755. func (m *AllocAgentMutation) Fields() []string {
  3756. fields := make([]string, 0, 7)
  3757. if m.created_at != nil {
  3758. fields = append(fields, allocagent.FieldCreatedAt)
  3759. }
  3760. if m.updated_at != nil {
  3761. fields = append(fields, allocagent.FieldUpdatedAt)
  3762. }
  3763. if m.deleted_at != nil {
  3764. fields = append(fields, allocagent.FieldDeletedAt)
  3765. }
  3766. if m.user_id != nil {
  3767. fields = append(fields, allocagent.FieldUserID)
  3768. }
  3769. if m.organization_id != nil {
  3770. fields = append(fields, allocagent.FieldOrganizationID)
  3771. }
  3772. if m.agents != nil {
  3773. fields = append(fields, allocagent.FieldAgents)
  3774. }
  3775. if m.status != nil {
  3776. fields = append(fields, allocagent.FieldStatus)
  3777. }
  3778. return fields
  3779. }
  3780. // Field returns the value of a field with the given name. The second boolean
  3781. // return value indicates that this field was not set, or was not defined in the
  3782. // schema.
  3783. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3784. switch name {
  3785. case allocagent.FieldCreatedAt:
  3786. return m.CreatedAt()
  3787. case allocagent.FieldUpdatedAt:
  3788. return m.UpdatedAt()
  3789. case allocagent.FieldDeletedAt:
  3790. return m.DeletedAt()
  3791. case allocagent.FieldUserID:
  3792. return m.UserID()
  3793. case allocagent.FieldOrganizationID:
  3794. return m.OrganizationID()
  3795. case allocagent.FieldAgents:
  3796. return m.Agents()
  3797. case allocagent.FieldStatus:
  3798. return m.Status()
  3799. }
  3800. return nil, false
  3801. }
  3802. // OldField returns the old value of the field from the database. An error is
  3803. // returned if the mutation operation is not UpdateOne, or the query to the
  3804. // database failed.
  3805. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3806. switch name {
  3807. case allocagent.FieldCreatedAt:
  3808. return m.OldCreatedAt(ctx)
  3809. case allocagent.FieldUpdatedAt:
  3810. return m.OldUpdatedAt(ctx)
  3811. case allocagent.FieldDeletedAt:
  3812. return m.OldDeletedAt(ctx)
  3813. case allocagent.FieldUserID:
  3814. return m.OldUserID(ctx)
  3815. case allocagent.FieldOrganizationID:
  3816. return m.OldOrganizationID(ctx)
  3817. case allocagent.FieldAgents:
  3818. return m.OldAgents(ctx)
  3819. case allocagent.FieldStatus:
  3820. return m.OldStatus(ctx)
  3821. }
  3822. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3823. }
  3824. // SetField sets the value of a field with the given name. It returns an error if
  3825. // the field is not defined in the schema, or if the type mismatched the field
  3826. // type.
  3827. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3828. switch name {
  3829. case allocagent.FieldCreatedAt:
  3830. v, ok := value.(time.Time)
  3831. if !ok {
  3832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3833. }
  3834. m.SetCreatedAt(v)
  3835. return nil
  3836. case allocagent.FieldUpdatedAt:
  3837. v, ok := value.(time.Time)
  3838. if !ok {
  3839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3840. }
  3841. m.SetUpdatedAt(v)
  3842. return nil
  3843. case allocagent.FieldDeletedAt:
  3844. v, ok := value.(time.Time)
  3845. if !ok {
  3846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3847. }
  3848. m.SetDeletedAt(v)
  3849. return nil
  3850. case allocagent.FieldUserID:
  3851. v, ok := value.(string)
  3852. if !ok {
  3853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3854. }
  3855. m.SetUserID(v)
  3856. return nil
  3857. case allocagent.FieldOrganizationID:
  3858. v, ok := value.(uint64)
  3859. if !ok {
  3860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3861. }
  3862. m.SetOrganizationID(v)
  3863. return nil
  3864. case allocagent.FieldAgents:
  3865. v, ok := value.([]uint64)
  3866. if !ok {
  3867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3868. }
  3869. m.SetAgents(v)
  3870. return nil
  3871. case allocagent.FieldStatus:
  3872. v, ok := value.(int)
  3873. if !ok {
  3874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3875. }
  3876. m.SetStatus(v)
  3877. return nil
  3878. }
  3879. return fmt.Errorf("unknown AllocAgent field %s", name)
  3880. }
  3881. // AddedFields returns all numeric fields that were incremented/decremented during
  3882. // this mutation.
  3883. func (m *AllocAgentMutation) AddedFields() []string {
  3884. var fields []string
  3885. if m.addorganization_id != nil {
  3886. fields = append(fields, allocagent.FieldOrganizationID)
  3887. }
  3888. if m.addstatus != nil {
  3889. fields = append(fields, allocagent.FieldStatus)
  3890. }
  3891. return fields
  3892. }
  3893. // AddedField returns the numeric value that was incremented/decremented on a field
  3894. // with the given name. The second boolean return value indicates that this field
  3895. // was not set, or was not defined in the schema.
  3896. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3897. switch name {
  3898. case allocagent.FieldOrganizationID:
  3899. return m.AddedOrganizationID()
  3900. case allocagent.FieldStatus:
  3901. return m.AddedStatus()
  3902. }
  3903. return nil, false
  3904. }
  3905. // AddField adds the value to the field with the given name. It returns an error if
  3906. // the field is not defined in the schema, or if the type mismatched the field
  3907. // type.
  3908. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3909. switch name {
  3910. case allocagent.FieldOrganizationID:
  3911. v, ok := value.(int64)
  3912. if !ok {
  3913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3914. }
  3915. m.AddOrganizationID(v)
  3916. return nil
  3917. case allocagent.FieldStatus:
  3918. v, ok := value.(int)
  3919. if !ok {
  3920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3921. }
  3922. m.AddStatus(v)
  3923. return nil
  3924. }
  3925. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3926. }
  3927. // ClearedFields returns all nullable fields that were cleared during this
  3928. // mutation.
  3929. func (m *AllocAgentMutation) ClearedFields() []string {
  3930. var fields []string
  3931. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3932. fields = append(fields, allocagent.FieldDeletedAt)
  3933. }
  3934. if m.FieldCleared(allocagent.FieldUserID) {
  3935. fields = append(fields, allocagent.FieldUserID)
  3936. }
  3937. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3938. fields = append(fields, allocagent.FieldOrganizationID)
  3939. }
  3940. if m.FieldCleared(allocagent.FieldStatus) {
  3941. fields = append(fields, allocagent.FieldStatus)
  3942. }
  3943. return fields
  3944. }
  3945. // FieldCleared returns a boolean indicating if a field with the given name was
  3946. // cleared in this mutation.
  3947. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3948. _, ok := m.clearedFields[name]
  3949. return ok
  3950. }
  3951. // ClearField clears the value of the field with the given name. It returns an
  3952. // error if the field is not defined in the schema.
  3953. func (m *AllocAgentMutation) ClearField(name string) error {
  3954. switch name {
  3955. case allocagent.FieldDeletedAt:
  3956. m.ClearDeletedAt()
  3957. return nil
  3958. case allocagent.FieldUserID:
  3959. m.ClearUserID()
  3960. return nil
  3961. case allocagent.FieldOrganizationID:
  3962. m.ClearOrganizationID()
  3963. return nil
  3964. case allocagent.FieldStatus:
  3965. m.ClearStatus()
  3966. return nil
  3967. }
  3968. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3969. }
  3970. // ResetField resets all changes in the mutation for the field with the given name.
  3971. // It returns an error if the field is not defined in the schema.
  3972. func (m *AllocAgentMutation) ResetField(name string) error {
  3973. switch name {
  3974. case allocagent.FieldCreatedAt:
  3975. m.ResetCreatedAt()
  3976. return nil
  3977. case allocagent.FieldUpdatedAt:
  3978. m.ResetUpdatedAt()
  3979. return nil
  3980. case allocagent.FieldDeletedAt:
  3981. m.ResetDeletedAt()
  3982. return nil
  3983. case allocagent.FieldUserID:
  3984. m.ResetUserID()
  3985. return nil
  3986. case allocagent.FieldOrganizationID:
  3987. m.ResetOrganizationID()
  3988. return nil
  3989. case allocagent.FieldAgents:
  3990. m.ResetAgents()
  3991. return nil
  3992. case allocagent.FieldStatus:
  3993. m.ResetStatus()
  3994. return nil
  3995. }
  3996. return fmt.Errorf("unknown AllocAgent field %s", name)
  3997. }
  3998. // AddedEdges returns all edge names that were set/added in this mutation.
  3999. func (m *AllocAgentMutation) AddedEdges() []string {
  4000. edges := make([]string, 0, 0)
  4001. return edges
  4002. }
  4003. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4004. // name in this mutation.
  4005. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  4006. return nil
  4007. }
  4008. // RemovedEdges returns all edge names that were removed in this mutation.
  4009. func (m *AllocAgentMutation) RemovedEdges() []string {
  4010. edges := make([]string, 0, 0)
  4011. return edges
  4012. }
  4013. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4014. // the given name in this mutation.
  4015. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  4016. return nil
  4017. }
  4018. // ClearedEdges returns all edge names that were cleared in this mutation.
  4019. func (m *AllocAgentMutation) ClearedEdges() []string {
  4020. edges := make([]string, 0, 0)
  4021. return edges
  4022. }
  4023. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4024. // was cleared in this mutation.
  4025. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  4026. return false
  4027. }
  4028. // ClearEdge clears the value of the edge with the given name. It returns an error
  4029. // if that edge is not defined in the schema.
  4030. func (m *AllocAgentMutation) ClearEdge(name string) error {
  4031. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  4032. }
  4033. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4034. // It returns an error if the edge is not defined in the schema.
  4035. func (m *AllocAgentMutation) ResetEdge(name string) error {
  4036. return fmt.Errorf("unknown AllocAgent edge %s", name)
  4037. }
  4038. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  4039. type ApiKeyMutation struct {
  4040. config
  4041. op Op
  4042. typ string
  4043. id *uint64
  4044. created_at *time.Time
  4045. updated_at *time.Time
  4046. deleted_at *time.Time
  4047. title *string
  4048. key *string
  4049. organization_id *uint64
  4050. addorganization_id *int64
  4051. custom_agent_base *string
  4052. custom_agent_key *string
  4053. openai_base *string
  4054. openai_key *string
  4055. clearedFields map[string]struct{}
  4056. agent *uint64
  4057. clearedagent bool
  4058. done bool
  4059. oldValue func(context.Context) (*ApiKey, error)
  4060. predicates []predicate.ApiKey
  4061. }
  4062. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  4063. // apikeyOption allows management of the mutation configuration using functional options.
  4064. type apikeyOption func(*ApiKeyMutation)
  4065. // newApiKeyMutation creates new mutation for the ApiKey entity.
  4066. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  4067. m := &ApiKeyMutation{
  4068. config: c,
  4069. op: op,
  4070. typ: TypeApiKey,
  4071. clearedFields: make(map[string]struct{}),
  4072. }
  4073. for _, opt := range opts {
  4074. opt(m)
  4075. }
  4076. return m
  4077. }
  4078. // withApiKeyID sets the ID field of the mutation.
  4079. func withApiKeyID(id uint64) apikeyOption {
  4080. return func(m *ApiKeyMutation) {
  4081. var (
  4082. err error
  4083. once sync.Once
  4084. value *ApiKey
  4085. )
  4086. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  4087. once.Do(func() {
  4088. if m.done {
  4089. err = errors.New("querying old values post mutation is not allowed")
  4090. } else {
  4091. value, err = m.Client().ApiKey.Get(ctx, id)
  4092. }
  4093. })
  4094. return value, err
  4095. }
  4096. m.id = &id
  4097. }
  4098. }
  4099. // withApiKey sets the old ApiKey of the mutation.
  4100. func withApiKey(node *ApiKey) apikeyOption {
  4101. return func(m *ApiKeyMutation) {
  4102. m.oldValue = func(context.Context) (*ApiKey, error) {
  4103. return node, nil
  4104. }
  4105. m.id = &node.ID
  4106. }
  4107. }
  4108. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4109. // executed in a transaction (ent.Tx), a transactional client is returned.
  4110. func (m ApiKeyMutation) Client() *Client {
  4111. client := &Client{config: m.config}
  4112. client.init()
  4113. return client
  4114. }
  4115. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4116. // it returns an error otherwise.
  4117. func (m ApiKeyMutation) Tx() (*Tx, error) {
  4118. if _, ok := m.driver.(*txDriver); !ok {
  4119. return nil, errors.New("ent: mutation is not running in a transaction")
  4120. }
  4121. tx := &Tx{config: m.config}
  4122. tx.init()
  4123. return tx, nil
  4124. }
  4125. // SetID sets the value of the id field. Note that this
  4126. // operation is only accepted on creation of ApiKey entities.
  4127. func (m *ApiKeyMutation) SetID(id uint64) {
  4128. m.id = &id
  4129. }
  4130. // ID returns the ID value in the mutation. Note that the ID is only available
  4131. // if it was provided to the builder or after it was returned from the database.
  4132. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  4133. if m.id == nil {
  4134. return
  4135. }
  4136. return *m.id, true
  4137. }
  4138. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4139. // That means, if the mutation is applied within a transaction with an isolation level such
  4140. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4141. // or updated by the mutation.
  4142. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  4143. switch {
  4144. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4145. id, exists := m.ID()
  4146. if exists {
  4147. return []uint64{id}, nil
  4148. }
  4149. fallthrough
  4150. case m.op.Is(OpUpdate | OpDelete):
  4151. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  4152. default:
  4153. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4154. }
  4155. }
  4156. // SetCreatedAt sets the "created_at" field.
  4157. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  4158. m.created_at = &t
  4159. }
  4160. // CreatedAt returns the value of the "created_at" field in the mutation.
  4161. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  4162. v := m.created_at
  4163. if v == nil {
  4164. return
  4165. }
  4166. return *v, true
  4167. }
  4168. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  4169. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4171. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4172. if !m.op.Is(OpUpdateOne) {
  4173. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4174. }
  4175. if m.id == nil || m.oldValue == nil {
  4176. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4177. }
  4178. oldValue, err := m.oldValue(ctx)
  4179. if err != nil {
  4180. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4181. }
  4182. return oldValue.CreatedAt, nil
  4183. }
  4184. // ResetCreatedAt resets all changes to the "created_at" field.
  4185. func (m *ApiKeyMutation) ResetCreatedAt() {
  4186. m.created_at = nil
  4187. }
  4188. // SetUpdatedAt sets the "updated_at" field.
  4189. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  4190. m.updated_at = &t
  4191. }
  4192. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4193. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  4194. v := m.updated_at
  4195. if v == nil {
  4196. return
  4197. }
  4198. return *v, true
  4199. }
  4200. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  4201. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4203. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4204. if !m.op.Is(OpUpdateOne) {
  4205. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4206. }
  4207. if m.id == nil || m.oldValue == nil {
  4208. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4209. }
  4210. oldValue, err := m.oldValue(ctx)
  4211. if err != nil {
  4212. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4213. }
  4214. return oldValue.UpdatedAt, nil
  4215. }
  4216. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4217. func (m *ApiKeyMutation) ResetUpdatedAt() {
  4218. m.updated_at = nil
  4219. }
  4220. // SetDeletedAt sets the "deleted_at" field.
  4221. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  4222. m.deleted_at = &t
  4223. }
  4224. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4225. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  4226. v := m.deleted_at
  4227. if v == nil {
  4228. return
  4229. }
  4230. return *v, true
  4231. }
  4232. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  4233. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4235. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4236. if !m.op.Is(OpUpdateOne) {
  4237. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4238. }
  4239. if m.id == nil || m.oldValue == nil {
  4240. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4241. }
  4242. oldValue, err := m.oldValue(ctx)
  4243. if err != nil {
  4244. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4245. }
  4246. return oldValue.DeletedAt, nil
  4247. }
  4248. // ClearDeletedAt clears the value of the "deleted_at" field.
  4249. func (m *ApiKeyMutation) ClearDeletedAt() {
  4250. m.deleted_at = nil
  4251. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  4252. }
  4253. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4254. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  4255. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  4256. return ok
  4257. }
  4258. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4259. func (m *ApiKeyMutation) ResetDeletedAt() {
  4260. m.deleted_at = nil
  4261. delete(m.clearedFields, apikey.FieldDeletedAt)
  4262. }
  4263. // SetTitle sets the "title" field.
  4264. func (m *ApiKeyMutation) SetTitle(s string) {
  4265. m.title = &s
  4266. }
  4267. // Title returns the value of the "title" field in the mutation.
  4268. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  4269. v := m.title
  4270. if v == nil {
  4271. return
  4272. }
  4273. return *v, true
  4274. }
  4275. // OldTitle returns the old "title" field's value of the ApiKey entity.
  4276. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4278. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  4279. if !m.op.Is(OpUpdateOne) {
  4280. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  4281. }
  4282. if m.id == nil || m.oldValue == nil {
  4283. return v, errors.New("OldTitle requires an ID field in the mutation")
  4284. }
  4285. oldValue, err := m.oldValue(ctx)
  4286. if err != nil {
  4287. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  4288. }
  4289. return oldValue.Title, nil
  4290. }
  4291. // ClearTitle clears the value of the "title" field.
  4292. func (m *ApiKeyMutation) ClearTitle() {
  4293. m.title = nil
  4294. m.clearedFields[apikey.FieldTitle] = struct{}{}
  4295. }
  4296. // TitleCleared returns if the "title" field was cleared in this mutation.
  4297. func (m *ApiKeyMutation) TitleCleared() bool {
  4298. _, ok := m.clearedFields[apikey.FieldTitle]
  4299. return ok
  4300. }
  4301. // ResetTitle resets all changes to the "title" field.
  4302. func (m *ApiKeyMutation) ResetTitle() {
  4303. m.title = nil
  4304. delete(m.clearedFields, apikey.FieldTitle)
  4305. }
  4306. // SetKey sets the "key" field.
  4307. func (m *ApiKeyMutation) SetKey(s string) {
  4308. m.key = &s
  4309. }
  4310. // Key returns the value of the "key" field in the mutation.
  4311. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  4312. v := m.key
  4313. if v == nil {
  4314. return
  4315. }
  4316. return *v, true
  4317. }
  4318. // OldKey returns the old "key" field's value of the ApiKey entity.
  4319. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4321. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  4322. if !m.op.Is(OpUpdateOne) {
  4323. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  4324. }
  4325. if m.id == nil || m.oldValue == nil {
  4326. return v, errors.New("OldKey requires an ID field in the mutation")
  4327. }
  4328. oldValue, err := m.oldValue(ctx)
  4329. if err != nil {
  4330. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  4331. }
  4332. return oldValue.Key, nil
  4333. }
  4334. // ClearKey clears the value of the "key" field.
  4335. func (m *ApiKeyMutation) ClearKey() {
  4336. m.key = nil
  4337. m.clearedFields[apikey.FieldKey] = struct{}{}
  4338. }
  4339. // KeyCleared returns if the "key" field was cleared in this mutation.
  4340. func (m *ApiKeyMutation) KeyCleared() bool {
  4341. _, ok := m.clearedFields[apikey.FieldKey]
  4342. return ok
  4343. }
  4344. // ResetKey resets all changes to the "key" field.
  4345. func (m *ApiKeyMutation) ResetKey() {
  4346. m.key = nil
  4347. delete(m.clearedFields, apikey.FieldKey)
  4348. }
  4349. // SetOrganizationID sets the "organization_id" field.
  4350. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  4351. m.organization_id = &u
  4352. m.addorganization_id = nil
  4353. }
  4354. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4355. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  4356. v := m.organization_id
  4357. if v == nil {
  4358. return
  4359. }
  4360. return *v, true
  4361. }
  4362. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  4363. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4365. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4366. if !m.op.Is(OpUpdateOne) {
  4367. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4368. }
  4369. if m.id == nil || m.oldValue == nil {
  4370. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4371. }
  4372. oldValue, err := m.oldValue(ctx)
  4373. if err != nil {
  4374. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4375. }
  4376. return oldValue.OrganizationID, nil
  4377. }
  4378. // AddOrganizationID adds u to the "organization_id" field.
  4379. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  4380. if m.addorganization_id != nil {
  4381. *m.addorganization_id += u
  4382. } else {
  4383. m.addorganization_id = &u
  4384. }
  4385. }
  4386. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4387. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  4388. v := m.addorganization_id
  4389. if v == nil {
  4390. return
  4391. }
  4392. return *v, true
  4393. }
  4394. // ResetOrganizationID resets all changes to the "organization_id" field.
  4395. func (m *ApiKeyMutation) ResetOrganizationID() {
  4396. m.organization_id = nil
  4397. m.addorganization_id = nil
  4398. }
  4399. // SetAgentID sets the "agent_id" field.
  4400. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  4401. m.agent = &u
  4402. }
  4403. // AgentID returns the value of the "agent_id" field in the mutation.
  4404. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  4405. v := m.agent
  4406. if v == nil {
  4407. return
  4408. }
  4409. return *v, true
  4410. }
  4411. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  4412. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4414. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  4415. if !m.op.Is(OpUpdateOne) {
  4416. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  4417. }
  4418. if m.id == nil || m.oldValue == nil {
  4419. return v, errors.New("OldAgentID requires an ID field in the mutation")
  4420. }
  4421. oldValue, err := m.oldValue(ctx)
  4422. if err != nil {
  4423. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  4424. }
  4425. return oldValue.AgentID, nil
  4426. }
  4427. // ResetAgentID resets all changes to the "agent_id" field.
  4428. func (m *ApiKeyMutation) ResetAgentID() {
  4429. m.agent = nil
  4430. }
  4431. // SetCustomAgentBase sets the "custom_agent_base" field.
  4432. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  4433. m.custom_agent_base = &s
  4434. }
  4435. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  4436. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  4437. v := m.custom_agent_base
  4438. if v == nil {
  4439. return
  4440. }
  4441. return *v, true
  4442. }
  4443. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  4444. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4446. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  4447. if !m.op.Is(OpUpdateOne) {
  4448. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  4449. }
  4450. if m.id == nil || m.oldValue == nil {
  4451. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  4452. }
  4453. oldValue, err := m.oldValue(ctx)
  4454. if err != nil {
  4455. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  4456. }
  4457. return oldValue.CustomAgentBase, nil
  4458. }
  4459. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  4460. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  4461. m.custom_agent_base = nil
  4462. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  4463. }
  4464. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  4465. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  4466. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  4467. return ok
  4468. }
  4469. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  4470. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  4471. m.custom_agent_base = nil
  4472. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  4473. }
  4474. // SetCustomAgentKey sets the "custom_agent_key" field.
  4475. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  4476. m.custom_agent_key = &s
  4477. }
  4478. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  4479. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  4480. v := m.custom_agent_key
  4481. if v == nil {
  4482. return
  4483. }
  4484. return *v, true
  4485. }
  4486. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  4487. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4489. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  4490. if !m.op.Is(OpUpdateOne) {
  4491. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  4492. }
  4493. if m.id == nil || m.oldValue == nil {
  4494. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  4495. }
  4496. oldValue, err := m.oldValue(ctx)
  4497. if err != nil {
  4498. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  4499. }
  4500. return oldValue.CustomAgentKey, nil
  4501. }
  4502. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  4503. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  4504. m.custom_agent_key = nil
  4505. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  4506. }
  4507. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  4508. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  4509. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  4510. return ok
  4511. }
  4512. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  4513. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  4514. m.custom_agent_key = nil
  4515. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  4516. }
  4517. // SetOpenaiBase sets the "openai_base" field.
  4518. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  4519. m.openai_base = &s
  4520. }
  4521. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  4522. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  4523. v := m.openai_base
  4524. if v == nil {
  4525. return
  4526. }
  4527. return *v, true
  4528. }
  4529. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  4530. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4532. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  4533. if !m.op.Is(OpUpdateOne) {
  4534. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  4535. }
  4536. if m.id == nil || m.oldValue == nil {
  4537. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  4538. }
  4539. oldValue, err := m.oldValue(ctx)
  4540. if err != nil {
  4541. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  4542. }
  4543. return oldValue.OpenaiBase, nil
  4544. }
  4545. // ClearOpenaiBase clears the value of the "openai_base" field.
  4546. func (m *ApiKeyMutation) ClearOpenaiBase() {
  4547. m.openai_base = nil
  4548. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  4549. }
  4550. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  4551. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  4552. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  4553. return ok
  4554. }
  4555. // ResetOpenaiBase resets all changes to the "openai_base" field.
  4556. func (m *ApiKeyMutation) ResetOpenaiBase() {
  4557. m.openai_base = nil
  4558. delete(m.clearedFields, apikey.FieldOpenaiBase)
  4559. }
  4560. // SetOpenaiKey sets the "openai_key" field.
  4561. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  4562. m.openai_key = &s
  4563. }
  4564. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  4565. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  4566. v := m.openai_key
  4567. if v == nil {
  4568. return
  4569. }
  4570. return *v, true
  4571. }
  4572. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  4573. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  4574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4575. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  4576. if !m.op.Is(OpUpdateOne) {
  4577. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  4578. }
  4579. if m.id == nil || m.oldValue == nil {
  4580. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  4581. }
  4582. oldValue, err := m.oldValue(ctx)
  4583. if err != nil {
  4584. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  4585. }
  4586. return oldValue.OpenaiKey, nil
  4587. }
  4588. // ClearOpenaiKey clears the value of the "openai_key" field.
  4589. func (m *ApiKeyMutation) ClearOpenaiKey() {
  4590. m.openai_key = nil
  4591. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  4592. }
  4593. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  4594. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  4595. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  4596. return ok
  4597. }
  4598. // ResetOpenaiKey resets all changes to the "openai_key" field.
  4599. func (m *ApiKeyMutation) ResetOpenaiKey() {
  4600. m.openai_key = nil
  4601. delete(m.clearedFields, apikey.FieldOpenaiKey)
  4602. }
  4603. // ClearAgent clears the "agent" edge to the Agent entity.
  4604. func (m *ApiKeyMutation) ClearAgent() {
  4605. m.clearedagent = true
  4606. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  4607. }
  4608. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  4609. func (m *ApiKeyMutation) AgentCleared() bool {
  4610. return m.clearedagent
  4611. }
  4612. // AgentIDs returns the "agent" edge IDs in the mutation.
  4613. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  4614. // AgentID instead. It exists only for internal usage by the builders.
  4615. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  4616. if id := m.agent; id != nil {
  4617. ids = append(ids, *id)
  4618. }
  4619. return
  4620. }
  4621. // ResetAgent resets all changes to the "agent" edge.
  4622. func (m *ApiKeyMutation) ResetAgent() {
  4623. m.agent = nil
  4624. m.clearedagent = false
  4625. }
  4626. // Where appends a list predicates to the ApiKeyMutation builder.
  4627. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  4628. m.predicates = append(m.predicates, ps...)
  4629. }
  4630. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  4631. // users can use type-assertion to append predicates that do not depend on any generated package.
  4632. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  4633. p := make([]predicate.ApiKey, len(ps))
  4634. for i := range ps {
  4635. p[i] = ps[i]
  4636. }
  4637. m.Where(p...)
  4638. }
  4639. // Op returns the operation name.
  4640. func (m *ApiKeyMutation) Op() Op {
  4641. return m.op
  4642. }
  4643. // SetOp allows setting the mutation operation.
  4644. func (m *ApiKeyMutation) SetOp(op Op) {
  4645. m.op = op
  4646. }
  4647. // Type returns the node type of this mutation (ApiKey).
  4648. func (m *ApiKeyMutation) Type() string {
  4649. return m.typ
  4650. }
  4651. // Fields returns all fields that were changed during this mutation. Note that in
  4652. // order to get all numeric fields that were incremented/decremented, call
  4653. // AddedFields().
  4654. func (m *ApiKeyMutation) Fields() []string {
  4655. fields := make([]string, 0, 11)
  4656. if m.created_at != nil {
  4657. fields = append(fields, apikey.FieldCreatedAt)
  4658. }
  4659. if m.updated_at != nil {
  4660. fields = append(fields, apikey.FieldUpdatedAt)
  4661. }
  4662. if m.deleted_at != nil {
  4663. fields = append(fields, apikey.FieldDeletedAt)
  4664. }
  4665. if m.title != nil {
  4666. fields = append(fields, apikey.FieldTitle)
  4667. }
  4668. if m.key != nil {
  4669. fields = append(fields, apikey.FieldKey)
  4670. }
  4671. if m.organization_id != nil {
  4672. fields = append(fields, apikey.FieldOrganizationID)
  4673. }
  4674. if m.agent != nil {
  4675. fields = append(fields, apikey.FieldAgentID)
  4676. }
  4677. if m.custom_agent_base != nil {
  4678. fields = append(fields, apikey.FieldCustomAgentBase)
  4679. }
  4680. if m.custom_agent_key != nil {
  4681. fields = append(fields, apikey.FieldCustomAgentKey)
  4682. }
  4683. if m.openai_base != nil {
  4684. fields = append(fields, apikey.FieldOpenaiBase)
  4685. }
  4686. if m.openai_key != nil {
  4687. fields = append(fields, apikey.FieldOpenaiKey)
  4688. }
  4689. return fields
  4690. }
  4691. // Field returns the value of a field with the given name. The second boolean
  4692. // return value indicates that this field was not set, or was not defined in the
  4693. // schema.
  4694. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  4695. switch name {
  4696. case apikey.FieldCreatedAt:
  4697. return m.CreatedAt()
  4698. case apikey.FieldUpdatedAt:
  4699. return m.UpdatedAt()
  4700. case apikey.FieldDeletedAt:
  4701. return m.DeletedAt()
  4702. case apikey.FieldTitle:
  4703. return m.Title()
  4704. case apikey.FieldKey:
  4705. return m.Key()
  4706. case apikey.FieldOrganizationID:
  4707. return m.OrganizationID()
  4708. case apikey.FieldAgentID:
  4709. return m.AgentID()
  4710. case apikey.FieldCustomAgentBase:
  4711. return m.CustomAgentBase()
  4712. case apikey.FieldCustomAgentKey:
  4713. return m.CustomAgentKey()
  4714. case apikey.FieldOpenaiBase:
  4715. return m.OpenaiBase()
  4716. case apikey.FieldOpenaiKey:
  4717. return m.OpenaiKey()
  4718. }
  4719. return nil, false
  4720. }
  4721. // OldField returns the old value of the field from the database. An error is
  4722. // returned if the mutation operation is not UpdateOne, or the query to the
  4723. // database failed.
  4724. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4725. switch name {
  4726. case apikey.FieldCreatedAt:
  4727. return m.OldCreatedAt(ctx)
  4728. case apikey.FieldUpdatedAt:
  4729. return m.OldUpdatedAt(ctx)
  4730. case apikey.FieldDeletedAt:
  4731. return m.OldDeletedAt(ctx)
  4732. case apikey.FieldTitle:
  4733. return m.OldTitle(ctx)
  4734. case apikey.FieldKey:
  4735. return m.OldKey(ctx)
  4736. case apikey.FieldOrganizationID:
  4737. return m.OldOrganizationID(ctx)
  4738. case apikey.FieldAgentID:
  4739. return m.OldAgentID(ctx)
  4740. case apikey.FieldCustomAgentBase:
  4741. return m.OldCustomAgentBase(ctx)
  4742. case apikey.FieldCustomAgentKey:
  4743. return m.OldCustomAgentKey(ctx)
  4744. case apikey.FieldOpenaiBase:
  4745. return m.OldOpenaiBase(ctx)
  4746. case apikey.FieldOpenaiKey:
  4747. return m.OldOpenaiKey(ctx)
  4748. }
  4749. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  4750. }
  4751. // SetField sets the value of a field with the given name. It returns an error if
  4752. // the field is not defined in the schema, or if the type mismatched the field
  4753. // type.
  4754. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  4755. switch name {
  4756. case apikey.FieldCreatedAt:
  4757. v, ok := value.(time.Time)
  4758. if !ok {
  4759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4760. }
  4761. m.SetCreatedAt(v)
  4762. return nil
  4763. case apikey.FieldUpdatedAt:
  4764. v, ok := value.(time.Time)
  4765. if !ok {
  4766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4767. }
  4768. m.SetUpdatedAt(v)
  4769. return nil
  4770. case apikey.FieldDeletedAt:
  4771. v, ok := value.(time.Time)
  4772. if !ok {
  4773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4774. }
  4775. m.SetDeletedAt(v)
  4776. return nil
  4777. case apikey.FieldTitle:
  4778. v, ok := value.(string)
  4779. if !ok {
  4780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4781. }
  4782. m.SetTitle(v)
  4783. return nil
  4784. case apikey.FieldKey:
  4785. v, ok := value.(string)
  4786. if !ok {
  4787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4788. }
  4789. m.SetKey(v)
  4790. return nil
  4791. case apikey.FieldOrganizationID:
  4792. v, ok := value.(uint64)
  4793. if !ok {
  4794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4795. }
  4796. m.SetOrganizationID(v)
  4797. return nil
  4798. case apikey.FieldAgentID:
  4799. v, ok := value.(uint64)
  4800. if !ok {
  4801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4802. }
  4803. m.SetAgentID(v)
  4804. return nil
  4805. case apikey.FieldCustomAgentBase:
  4806. v, ok := value.(string)
  4807. if !ok {
  4808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4809. }
  4810. m.SetCustomAgentBase(v)
  4811. return nil
  4812. case apikey.FieldCustomAgentKey:
  4813. v, ok := value.(string)
  4814. if !ok {
  4815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4816. }
  4817. m.SetCustomAgentKey(v)
  4818. return nil
  4819. case apikey.FieldOpenaiBase:
  4820. v, ok := value.(string)
  4821. if !ok {
  4822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4823. }
  4824. m.SetOpenaiBase(v)
  4825. return nil
  4826. case apikey.FieldOpenaiKey:
  4827. v, ok := value.(string)
  4828. if !ok {
  4829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4830. }
  4831. m.SetOpenaiKey(v)
  4832. return nil
  4833. }
  4834. return fmt.Errorf("unknown ApiKey field %s", name)
  4835. }
  4836. // AddedFields returns all numeric fields that were incremented/decremented during
  4837. // this mutation.
  4838. func (m *ApiKeyMutation) AddedFields() []string {
  4839. var fields []string
  4840. if m.addorganization_id != nil {
  4841. fields = append(fields, apikey.FieldOrganizationID)
  4842. }
  4843. return fields
  4844. }
  4845. // AddedField returns the numeric value that was incremented/decremented on a field
  4846. // with the given name. The second boolean return value indicates that this field
  4847. // was not set, or was not defined in the schema.
  4848. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  4849. switch name {
  4850. case apikey.FieldOrganizationID:
  4851. return m.AddedOrganizationID()
  4852. }
  4853. return nil, false
  4854. }
  4855. // AddField adds the value to the field with the given name. It returns an error if
  4856. // the field is not defined in the schema, or if the type mismatched the field
  4857. // type.
  4858. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  4859. switch name {
  4860. case apikey.FieldOrganizationID:
  4861. v, ok := value.(int64)
  4862. if !ok {
  4863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4864. }
  4865. m.AddOrganizationID(v)
  4866. return nil
  4867. }
  4868. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  4869. }
  4870. // ClearedFields returns all nullable fields that were cleared during this
  4871. // mutation.
  4872. func (m *ApiKeyMutation) ClearedFields() []string {
  4873. var fields []string
  4874. if m.FieldCleared(apikey.FieldDeletedAt) {
  4875. fields = append(fields, apikey.FieldDeletedAt)
  4876. }
  4877. if m.FieldCleared(apikey.FieldTitle) {
  4878. fields = append(fields, apikey.FieldTitle)
  4879. }
  4880. if m.FieldCleared(apikey.FieldKey) {
  4881. fields = append(fields, apikey.FieldKey)
  4882. }
  4883. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  4884. fields = append(fields, apikey.FieldCustomAgentBase)
  4885. }
  4886. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  4887. fields = append(fields, apikey.FieldCustomAgentKey)
  4888. }
  4889. if m.FieldCleared(apikey.FieldOpenaiBase) {
  4890. fields = append(fields, apikey.FieldOpenaiBase)
  4891. }
  4892. if m.FieldCleared(apikey.FieldOpenaiKey) {
  4893. fields = append(fields, apikey.FieldOpenaiKey)
  4894. }
  4895. return fields
  4896. }
  4897. // FieldCleared returns a boolean indicating if a field with the given name was
  4898. // cleared in this mutation.
  4899. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  4900. _, ok := m.clearedFields[name]
  4901. return ok
  4902. }
  4903. // ClearField clears the value of the field with the given name. It returns an
  4904. // error if the field is not defined in the schema.
  4905. func (m *ApiKeyMutation) ClearField(name string) error {
  4906. switch name {
  4907. case apikey.FieldDeletedAt:
  4908. m.ClearDeletedAt()
  4909. return nil
  4910. case apikey.FieldTitle:
  4911. m.ClearTitle()
  4912. return nil
  4913. case apikey.FieldKey:
  4914. m.ClearKey()
  4915. return nil
  4916. case apikey.FieldCustomAgentBase:
  4917. m.ClearCustomAgentBase()
  4918. return nil
  4919. case apikey.FieldCustomAgentKey:
  4920. m.ClearCustomAgentKey()
  4921. return nil
  4922. case apikey.FieldOpenaiBase:
  4923. m.ClearOpenaiBase()
  4924. return nil
  4925. case apikey.FieldOpenaiKey:
  4926. m.ClearOpenaiKey()
  4927. return nil
  4928. }
  4929. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  4930. }
  4931. // ResetField resets all changes in the mutation for the field with the given name.
  4932. // It returns an error if the field is not defined in the schema.
  4933. func (m *ApiKeyMutation) ResetField(name string) error {
  4934. switch name {
  4935. case apikey.FieldCreatedAt:
  4936. m.ResetCreatedAt()
  4937. return nil
  4938. case apikey.FieldUpdatedAt:
  4939. m.ResetUpdatedAt()
  4940. return nil
  4941. case apikey.FieldDeletedAt:
  4942. m.ResetDeletedAt()
  4943. return nil
  4944. case apikey.FieldTitle:
  4945. m.ResetTitle()
  4946. return nil
  4947. case apikey.FieldKey:
  4948. m.ResetKey()
  4949. return nil
  4950. case apikey.FieldOrganizationID:
  4951. m.ResetOrganizationID()
  4952. return nil
  4953. case apikey.FieldAgentID:
  4954. m.ResetAgentID()
  4955. return nil
  4956. case apikey.FieldCustomAgentBase:
  4957. m.ResetCustomAgentBase()
  4958. return nil
  4959. case apikey.FieldCustomAgentKey:
  4960. m.ResetCustomAgentKey()
  4961. return nil
  4962. case apikey.FieldOpenaiBase:
  4963. m.ResetOpenaiBase()
  4964. return nil
  4965. case apikey.FieldOpenaiKey:
  4966. m.ResetOpenaiKey()
  4967. return nil
  4968. }
  4969. return fmt.Errorf("unknown ApiKey field %s", name)
  4970. }
  4971. // AddedEdges returns all edge names that were set/added in this mutation.
  4972. func (m *ApiKeyMutation) AddedEdges() []string {
  4973. edges := make([]string, 0, 1)
  4974. if m.agent != nil {
  4975. edges = append(edges, apikey.EdgeAgent)
  4976. }
  4977. return edges
  4978. }
  4979. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4980. // name in this mutation.
  4981. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  4982. switch name {
  4983. case apikey.EdgeAgent:
  4984. if id := m.agent; id != nil {
  4985. return []ent.Value{*id}
  4986. }
  4987. }
  4988. return nil
  4989. }
  4990. // RemovedEdges returns all edge names that were removed in this mutation.
  4991. func (m *ApiKeyMutation) RemovedEdges() []string {
  4992. edges := make([]string, 0, 1)
  4993. return edges
  4994. }
  4995. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4996. // the given name in this mutation.
  4997. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  4998. return nil
  4999. }
  5000. // ClearedEdges returns all edge names that were cleared in this mutation.
  5001. func (m *ApiKeyMutation) ClearedEdges() []string {
  5002. edges := make([]string, 0, 1)
  5003. if m.clearedagent {
  5004. edges = append(edges, apikey.EdgeAgent)
  5005. }
  5006. return edges
  5007. }
  5008. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5009. // was cleared in this mutation.
  5010. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  5011. switch name {
  5012. case apikey.EdgeAgent:
  5013. return m.clearedagent
  5014. }
  5015. return false
  5016. }
  5017. // ClearEdge clears the value of the edge with the given name. It returns an error
  5018. // if that edge is not defined in the schema.
  5019. func (m *ApiKeyMutation) ClearEdge(name string) error {
  5020. switch name {
  5021. case apikey.EdgeAgent:
  5022. m.ClearAgent()
  5023. return nil
  5024. }
  5025. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  5026. }
  5027. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5028. // It returns an error if the edge is not defined in the schema.
  5029. func (m *ApiKeyMutation) ResetEdge(name string) error {
  5030. switch name {
  5031. case apikey.EdgeAgent:
  5032. m.ResetAgent()
  5033. return nil
  5034. }
  5035. return fmt.Errorf("unknown ApiKey edge %s", name)
  5036. }
  5037. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  5038. type BatchMsgMutation struct {
  5039. config
  5040. op Op
  5041. typ string
  5042. id *uint64
  5043. created_at *time.Time
  5044. updated_at *time.Time
  5045. deleted_at *time.Time
  5046. status *uint8
  5047. addstatus *int8
  5048. batch_no *string
  5049. task_name *string
  5050. fromwxid *string
  5051. msg *string
  5052. tag *string
  5053. tagids *string
  5054. total *int32
  5055. addtotal *int32
  5056. success *int32
  5057. addsuccess *int32
  5058. fail *int32
  5059. addfail *int32
  5060. start_time *time.Time
  5061. stop_time *time.Time
  5062. send_time *time.Time
  5063. _type *int32
  5064. add_type *int32
  5065. organization_id *uint64
  5066. addorganization_id *int64
  5067. ctype *uint64
  5068. addctype *int64
  5069. cc *string
  5070. phone *string
  5071. template_name *string
  5072. template_code *string
  5073. lang *string
  5074. clearedFields map[string]struct{}
  5075. done bool
  5076. oldValue func(context.Context) (*BatchMsg, error)
  5077. predicates []predicate.BatchMsg
  5078. }
  5079. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  5080. // batchmsgOption allows management of the mutation configuration using functional options.
  5081. type batchmsgOption func(*BatchMsgMutation)
  5082. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  5083. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  5084. m := &BatchMsgMutation{
  5085. config: c,
  5086. op: op,
  5087. typ: TypeBatchMsg,
  5088. clearedFields: make(map[string]struct{}),
  5089. }
  5090. for _, opt := range opts {
  5091. opt(m)
  5092. }
  5093. return m
  5094. }
  5095. // withBatchMsgID sets the ID field of the mutation.
  5096. func withBatchMsgID(id uint64) batchmsgOption {
  5097. return func(m *BatchMsgMutation) {
  5098. var (
  5099. err error
  5100. once sync.Once
  5101. value *BatchMsg
  5102. )
  5103. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  5104. once.Do(func() {
  5105. if m.done {
  5106. err = errors.New("querying old values post mutation is not allowed")
  5107. } else {
  5108. value, err = m.Client().BatchMsg.Get(ctx, id)
  5109. }
  5110. })
  5111. return value, err
  5112. }
  5113. m.id = &id
  5114. }
  5115. }
  5116. // withBatchMsg sets the old BatchMsg of the mutation.
  5117. func withBatchMsg(node *BatchMsg) batchmsgOption {
  5118. return func(m *BatchMsgMutation) {
  5119. m.oldValue = func(context.Context) (*BatchMsg, error) {
  5120. return node, nil
  5121. }
  5122. m.id = &node.ID
  5123. }
  5124. }
  5125. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5126. // executed in a transaction (ent.Tx), a transactional client is returned.
  5127. func (m BatchMsgMutation) Client() *Client {
  5128. client := &Client{config: m.config}
  5129. client.init()
  5130. return client
  5131. }
  5132. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5133. // it returns an error otherwise.
  5134. func (m BatchMsgMutation) Tx() (*Tx, error) {
  5135. if _, ok := m.driver.(*txDriver); !ok {
  5136. return nil, errors.New("ent: mutation is not running in a transaction")
  5137. }
  5138. tx := &Tx{config: m.config}
  5139. tx.init()
  5140. return tx, nil
  5141. }
  5142. // SetID sets the value of the id field. Note that this
  5143. // operation is only accepted on creation of BatchMsg entities.
  5144. func (m *BatchMsgMutation) SetID(id uint64) {
  5145. m.id = &id
  5146. }
  5147. // ID returns the ID value in the mutation. Note that the ID is only available
  5148. // if it was provided to the builder or after it was returned from the database.
  5149. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  5150. if m.id == nil {
  5151. return
  5152. }
  5153. return *m.id, true
  5154. }
  5155. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5156. // That means, if the mutation is applied within a transaction with an isolation level such
  5157. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5158. // or updated by the mutation.
  5159. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  5160. switch {
  5161. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5162. id, exists := m.ID()
  5163. if exists {
  5164. return []uint64{id}, nil
  5165. }
  5166. fallthrough
  5167. case m.op.Is(OpUpdate | OpDelete):
  5168. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  5169. default:
  5170. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5171. }
  5172. }
  5173. // SetCreatedAt sets the "created_at" field.
  5174. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  5175. m.created_at = &t
  5176. }
  5177. // CreatedAt returns the value of the "created_at" field in the mutation.
  5178. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  5179. v := m.created_at
  5180. if v == nil {
  5181. return
  5182. }
  5183. return *v, true
  5184. }
  5185. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  5186. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5188. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5189. if !m.op.Is(OpUpdateOne) {
  5190. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5191. }
  5192. if m.id == nil || m.oldValue == nil {
  5193. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5194. }
  5195. oldValue, err := m.oldValue(ctx)
  5196. if err != nil {
  5197. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5198. }
  5199. return oldValue.CreatedAt, nil
  5200. }
  5201. // ResetCreatedAt resets all changes to the "created_at" field.
  5202. func (m *BatchMsgMutation) ResetCreatedAt() {
  5203. m.created_at = nil
  5204. }
  5205. // SetUpdatedAt sets the "updated_at" field.
  5206. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  5207. m.updated_at = &t
  5208. }
  5209. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5210. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  5211. v := m.updated_at
  5212. if v == nil {
  5213. return
  5214. }
  5215. return *v, true
  5216. }
  5217. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  5218. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5220. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5221. if !m.op.Is(OpUpdateOne) {
  5222. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5223. }
  5224. if m.id == nil || m.oldValue == nil {
  5225. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5226. }
  5227. oldValue, err := m.oldValue(ctx)
  5228. if err != nil {
  5229. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5230. }
  5231. return oldValue.UpdatedAt, nil
  5232. }
  5233. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5234. func (m *BatchMsgMutation) ResetUpdatedAt() {
  5235. m.updated_at = nil
  5236. }
  5237. // SetDeletedAt sets the "deleted_at" field.
  5238. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  5239. m.deleted_at = &t
  5240. }
  5241. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5242. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  5243. v := m.deleted_at
  5244. if v == nil {
  5245. return
  5246. }
  5247. return *v, true
  5248. }
  5249. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  5250. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5252. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5253. if !m.op.Is(OpUpdateOne) {
  5254. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5255. }
  5256. if m.id == nil || m.oldValue == nil {
  5257. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5258. }
  5259. oldValue, err := m.oldValue(ctx)
  5260. if err != nil {
  5261. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5262. }
  5263. return oldValue.DeletedAt, nil
  5264. }
  5265. // ClearDeletedAt clears the value of the "deleted_at" field.
  5266. func (m *BatchMsgMutation) ClearDeletedAt() {
  5267. m.deleted_at = nil
  5268. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  5269. }
  5270. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5271. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  5272. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  5273. return ok
  5274. }
  5275. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5276. func (m *BatchMsgMutation) ResetDeletedAt() {
  5277. m.deleted_at = nil
  5278. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  5279. }
  5280. // SetStatus sets the "status" field.
  5281. func (m *BatchMsgMutation) SetStatus(u uint8) {
  5282. m.status = &u
  5283. m.addstatus = nil
  5284. }
  5285. // Status returns the value of the "status" field in the mutation.
  5286. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  5287. v := m.status
  5288. if v == nil {
  5289. return
  5290. }
  5291. return *v, true
  5292. }
  5293. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  5294. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5296. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  5297. if !m.op.Is(OpUpdateOne) {
  5298. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5299. }
  5300. if m.id == nil || m.oldValue == nil {
  5301. return v, errors.New("OldStatus requires an ID field in the mutation")
  5302. }
  5303. oldValue, err := m.oldValue(ctx)
  5304. if err != nil {
  5305. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5306. }
  5307. return oldValue.Status, nil
  5308. }
  5309. // AddStatus adds u to the "status" field.
  5310. func (m *BatchMsgMutation) AddStatus(u int8) {
  5311. if m.addstatus != nil {
  5312. *m.addstatus += u
  5313. } else {
  5314. m.addstatus = &u
  5315. }
  5316. }
  5317. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5318. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  5319. v := m.addstatus
  5320. if v == nil {
  5321. return
  5322. }
  5323. return *v, true
  5324. }
  5325. // ClearStatus clears the value of the "status" field.
  5326. func (m *BatchMsgMutation) ClearStatus() {
  5327. m.status = nil
  5328. m.addstatus = nil
  5329. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  5330. }
  5331. // StatusCleared returns if the "status" field was cleared in this mutation.
  5332. func (m *BatchMsgMutation) StatusCleared() bool {
  5333. _, ok := m.clearedFields[batchmsg.FieldStatus]
  5334. return ok
  5335. }
  5336. // ResetStatus resets all changes to the "status" field.
  5337. func (m *BatchMsgMutation) ResetStatus() {
  5338. m.status = nil
  5339. m.addstatus = nil
  5340. delete(m.clearedFields, batchmsg.FieldStatus)
  5341. }
  5342. // SetBatchNo sets the "batch_no" field.
  5343. func (m *BatchMsgMutation) SetBatchNo(s string) {
  5344. m.batch_no = &s
  5345. }
  5346. // BatchNo returns the value of the "batch_no" field in the mutation.
  5347. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  5348. v := m.batch_no
  5349. if v == nil {
  5350. return
  5351. }
  5352. return *v, true
  5353. }
  5354. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  5355. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5357. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  5358. if !m.op.Is(OpUpdateOne) {
  5359. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  5360. }
  5361. if m.id == nil || m.oldValue == nil {
  5362. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  5363. }
  5364. oldValue, err := m.oldValue(ctx)
  5365. if err != nil {
  5366. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  5367. }
  5368. return oldValue.BatchNo, nil
  5369. }
  5370. // ClearBatchNo clears the value of the "batch_no" field.
  5371. func (m *BatchMsgMutation) ClearBatchNo() {
  5372. m.batch_no = nil
  5373. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  5374. }
  5375. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  5376. func (m *BatchMsgMutation) BatchNoCleared() bool {
  5377. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  5378. return ok
  5379. }
  5380. // ResetBatchNo resets all changes to the "batch_no" field.
  5381. func (m *BatchMsgMutation) ResetBatchNo() {
  5382. m.batch_no = nil
  5383. delete(m.clearedFields, batchmsg.FieldBatchNo)
  5384. }
  5385. // SetTaskName sets the "task_name" field.
  5386. func (m *BatchMsgMutation) SetTaskName(s string) {
  5387. m.task_name = &s
  5388. }
  5389. // TaskName returns the value of the "task_name" field in the mutation.
  5390. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  5391. v := m.task_name
  5392. if v == nil {
  5393. return
  5394. }
  5395. return *v, true
  5396. }
  5397. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  5398. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5400. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  5401. if !m.op.Is(OpUpdateOne) {
  5402. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  5403. }
  5404. if m.id == nil || m.oldValue == nil {
  5405. return v, errors.New("OldTaskName requires an ID field in the mutation")
  5406. }
  5407. oldValue, err := m.oldValue(ctx)
  5408. if err != nil {
  5409. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  5410. }
  5411. return oldValue.TaskName, nil
  5412. }
  5413. // ClearTaskName clears the value of the "task_name" field.
  5414. func (m *BatchMsgMutation) ClearTaskName() {
  5415. m.task_name = nil
  5416. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  5417. }
  5418. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  5419. func (m *BatchMsgMutation) TaskNameCleared() bool {
  5420. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  5421. return ok
  5422. }
  5423. // ResetTaskName resets all changes to the "task_name" field.
  5424. func (m *BatchMsgMutation) ResetTaskName() {
  5425. m.task_name = nil
  5426. delete(m.clearedFields, batchmsg.FieldTaskName)
  5427. }
  5428. // SetFromwxid sets the "fromwxid" field.
  5429. func (m *BatchMsgMutation) SetFromwxid(s string) {
  5430. m.fromwxid = &s
  5431. }
  5432. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  5433. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  5434. v := m.fromwxid
  5435. if v == nil {
  5436. return
  5437. }
  5438. return *v, true
  5439. }
  5440. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  5441. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5443. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  5444. if !m.op.Is(OpUpdateOne) {
  5445. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  5446. }
  5447. if m.id == nil || m.oldValue == nil {
  5448. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  5449. }
  5450. oldValue, err := m.oldValue(ctx)
  5451. if err != nil {
  5452. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  5453. }
  5454. return oldValue.Fromwxid, nil
  5455. }
  5456. // ClearFromwxid clears the value of the "fromwxid" field.
  5457. func (m *BatchMsgMutation) ClearFromwxid() {
  5458. m.fromwxid = nil
  5459. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  5460. }
  5461. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  5462. func (m *BatchMsgMutation) FromwxidCleared() bool {
  5463. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  5464. return ok
  5465. }
  5466. // ResetFromwxid resets all changes to the "fromwxid" field.
  5467. func (m *BatchMsgMutation) ResetFromwxid() {
  5468. m.fromwxid = nil
  5469. delete(m.clearedFields, batchmsg.FieldFromwxid)
  5470. }
  5471. // SetMsg sets the "msg" field.
  5472. func (m *BatchMsgMutation) SetMsg(s string) {
  5473. m.msg = &s
  5474. }
  5475. // Msg returns the value of the "msg" field in the mutation.
  5476. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  5477. v := m.msg
  5478. if v == nil {
  5479. return
  5480. }
  5481. return *v, true
  5482. }
  5483. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  5484. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5486. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  5487. if !m.op.Is(OpUpdateOne) {
  5488. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  5489. }
  5490. if m.id == nil || m.oldValue == nil {
  5491. return v, errors.New("OldMsg requires an ID field in the mutation")
  5492. }
  5493. oldValue, err := m.oldValue(ctx)
  5494. if err != nil {
  5495. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  5496. }
  5497. return oldValue.Msg, nil
  5498. }
  5499. // ClearMsg clears the value of the "msg" field.
  5500. func (m *BatchMsgMutation) ClearMsg() {
  5501. m.msg = nil
  5502. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  5503. }
  5504. // MsgCleared returns if the "msg" field was cleared in this mutation.
  5505. func (m *BatchMsgMutation) MsgCleared() bool {
  5506. _, ok := m.clearedFields[batchmsg.FieldMsg]
  5507. return ok
  5508. }
  5509. // ResetMsg resets all changes to the "msg" field.
  5510. func (m *BatchMsgMutation) ResetMsg() {
  5511. m.msg = nil
  5512. delete(m.clearedFields, batchmsg.FieldMsg)
  5513. }
  5514. // SetTag sets the "tag" field.
  5515. func (m *BatchMsgMutation) SetTag(s string) {
  5516. m.tag = &s
  5517. }
  5518. // Tag returns the value of the "tag" field in the mutation.
  5519. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  5520. v := m.tag
  5521. if v == nil {
  5522. return
  5523. }
  5524. return *v, true
  5525. }
  5526. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  5527. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5529. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  5530. if !m.op.Is(OpUpdateOne) {
  5531. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  5532. }
  5533. if m.id == nil || m.oldValue == nil {
  5534. return v, errors.New("OldTag requires an ID field in the mutation")
  5535. }
  5536. oldValue, err := m.oldValue(ctx)
  5537. if err != nil {
  5538. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  5539. }
  5540. return oldValue.Tag, nil
  5541. }
  5542. // ClearTag clears the value of the "tag" field.
  5543. func (m *BatchMsgMutation) ClearTag() {
  5544. m.tag = nil
  5545. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  5546. }
  5547. // TagCleared returns if the "tag" field was cleared in this mutation.
  5548. func (m *BatchMsgMutation) TagCleared() bool {
  5549. _, ok := m.clearedFields[batchmsg.FieldTag]
  5550. return ok
  5551. }
  5552. // ResetTag resets all changes to the "tag" field.
  5553. func (m *BatchMsgMutation) ResetTag() {
  5554. m.tag = nil
  5555. delete(m.clearedFields, batchmsg.FieldTag)
  5556. }
  5557. // SetTagids sets the "tagids" field.
  5558. func (m *BatchMsgMutation) SetTagids(s string) {
  5559. m.tagids = &s
  5560. }
  5561. // Tagids returns the value of the "tagids" field in the mutation.
  5562. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  5563. v := m.tagids
  5564. if v == nil {
  5565. return
  5566. }
  5567. return *v, true
  5568. }
  5569. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  5570. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5572. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  5573. if !m.op.Is(OpUpdateOne) {
  5574. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  5575. }
  5576. if m.id == nil || m.oldValue == nil {
  5577. return v, errors.New("OldTagids requires an ID field in the mutation")
  5578. }
  5579. oldValue, err := m.oldValue(ctx)
  5580. if err != nil {
  5581. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  5582. }
  5583. return oldValue.Tagids, nil
  5584. }
  5585. // ClearTagids clears the value of the "tagids" field.
  5586. func (m *BatchMsgMutation) ClearTagids() {
  5587. m.tagids = nil
  5588. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  5589. }
  5590. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  5591. func (m *BatchMsgMutation) TagidsCleared() bool {
  5592. _, ok := m.clearedFields[batchmsg.FieldTagids]
  5593. return ok
  5594. }
  5595. // ResetTagids resets all changes to the "tagids" field.
  5596. func (m *BatchMsgMutation) ResetTagids() {
  5597. m.tagids = nil
  5598. delete(m.clearedFields, batchmsg.FieldTagids)
  5599. }
  5600. // SetTotal sets the "total" field.
  5601. func (m *BatchMsgMutation) SetTotal(i int32) {
  5602. m.total = &i
  5603. m.addtotal = nil
  5604. }
  5605. // Total returns the value of the "total" field in the mutation.
  5606. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  5607. v := m.total
  5608. if v == nil {
  5609. return
  5610. }
  5611. return *v, true
  5612. }
  5613. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  5614. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5616. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  5617. if !m.op.Is(OpUpdateOne) {
  5618. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  5619. }
  5620. if m.id == nil || m.oldValue == nil {
  5621. return v, errors.New("OldTotal requires an ID field in the mutation")
  5622. }
  5623. oldValue, err := m.oldValue(ctx)
  5624. if err != nil {
  5625. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  5626. }
  5627. return oldValue.Total, nil
  5628. }
  5629. // AddTotal adds i to the "total" field.
  5630. func (m *BatchMsgMutation) AddTotal(i int32) {
  5631. if m.addtotal != nil {
  5632. *m.addtotal += i
  5633. } else {
  5634. m.addtotal = &i
  5635. }
  5636. }
  5637. // AddedTotal returns the value that was added to the "total" field in this mutation.
  5638. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  5639. v := m.addtotal
  5640. if v == nil {
  5641. return
  5642. }
  5643. return *v, true
  5644. }
  5645. // ClearTotal clears the value of the "total" field.
  5646. func (m *BatchMsgMutation) ClearTotal() {
  5647. m.total = nil
  5648. m.addtotal = nil
  5649. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  5650. }
  5651. // TotalCleared returns if the "total" field was cleared in this mutation.
  5652. func (m *BatchMsgMutation) TotalCleared() bool {
  5653. _, ok := m.clearedFields[batchmsg.FieldTotal]
  5654. return ok
  5655. }
  5656. // ResetTotal resets all changes to the "total" field.
  5657. func (m *BatchMsgMutation) ResetTotal() {
  5658. m.total = nil
  5659. m.addtotal = nil
  5660. delete(m.clearedFields, batchmsg.FieldTotal)
  5661. }
  5662. // SetSuccess sets the "success" field.
  5663. func (m *BatchMsgMutation) SetSuccess(i int32) {
  5664. m.success = &i
  5665. m.addsuccess = nil
  5666. }
  5667. // Success returns the value of the "success" field in the mutation.
  5668. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  5669. v := m.success
  5670. if v == nil {
  5671. return
  5672. }
  5673. return *v, true
  5674. }
  5675. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  5676. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5678. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  5679. if !m.op.Is(OpUpdateOne) {
  5680. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  5681. }
  5682. if m.id == nil || m.oldValue == nil {
  5683. return v, errors.New("OldSuccess requires an ID field in the mutation")
  5684. }
  5685. oldValue, err := m.oldValue(ctx)
  5686. if err != nil {
  5687. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  5688. }
  5689. return oldValue.Success, nil
  5690. }
  5691. // AddSuccess adds i to the "success" field.
  5692. func (m *BatchMsgMutation) AddSuccess(i int32) {
  5693. if m.addsuccess != nil {
  5694. *m.addsuccess += i
  5695. } else {
  5696. m.addsuccess = &i
  5697. }
  5698. }
  5699. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  5700. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  5701. v := m.addsuccess
  5702. if v == nil {
  5703. return
  5704. }
  5705. return *v, true
  5706. }
  5707. // ClearSuccess clears the value of the "success" field.
  5708. func (m *BatchMsgMutation) ClearSuccess() {
  5709. m.success = nil
  5710. m.addsuccess = nil
  5711. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  5712. }
  5713. // SuccessCleared returns if the "success" field was cleared in this mutation.
  5714. func (m *BatchMsgMutation) SuccessCleared() bool {
  5715. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  5716. return ok
  5717. }
  5718. // ResetSuccess resets all changes to the "success" field.
  5719. func (m *BatchMsgMutation) ResetSuccess() {
  5720. m.success = nil
  5721. m.addsuccess = nil
  5722. delete(m.clearedFields, batchmsg.FieldSuccess)
  5723. }
  5724. // SetFail sets the "fail" field.
  5725. func (m *BatchMsgMutation) SetFail(i int32) {
  5726. m.fail = &i
  5727. m.addfail = nil
  5728. }
  5729. // Fail returns the value of the "fail" field in the mutation.
  5730. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  5731. v := m.fail
  5732. if v == nil {
  5733. return
  5734. }
  5735. return *v, true
  5736. }
  5737. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  5738. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  5739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5740. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  5741. if !m.op.Is(OpUpdateOne) {
  5742. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  5743. }
  5744. if m.id == nil || m.oldValue == nil {
  5745. return v, errors.New("OldFail requires an ID field in the mutation")
  5746. }
  5747. oldValue, err := m.oldValue(ctx)
  5748. if err != nil {
  5749. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  5750. }
  5751. return oldValue.Fail, nil
  5752. }
  5753. // AddFail adds i to the "fail" field.
  5754. func (m *BatchMsgMutation) AddFail(i int32) {
  5755. if m.addfail != nil {
  5756. *m.addfail += i
  5757. } else {
  5758. m.addfail = &i
  5759. }
  5760. }
  5761. // AddedFail returns the value that was added to the "fail" field in this mutation.
  5762. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  5763. v := m.addfail
  5764. if v == nil {
  5765. return
  5766. }
  5767. return *v, true
  5768. }
  5769. // ClearFail clears the value of the "fail" field.
  5770. func (m *BatchMsgMutation) ClearFail() {
  5771. m.fail = nil
  5772. m.addfail = nil
  5773. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  5774. }
  5775. // FailCleared returns if the "fail" field was cleared in this mutation.
  5776. func (m *BatchMsgMutation) FailCleared() bool {
  5777. _, ok := m.clearedFields[batchmsg.FieldFail]
  5778. return ok
  5779. }
  5780. // ResetFail resets all changes to the "fail" field.
  5781. func (m *BatchMsgMutation) ResetFail() {
  5782. m.fail = nil
  5783. m.addfail = nil
  5784. delete(m.clearedFields, batchmsg.FieldFail)
  5785. }
  5786. // SetStartTime sets the "start_time" field.
  5787. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  5788. m.start_time = &t
  5789. }
  5790. // StartTime returns the value of the "start_time" field in the mutation.
  5791. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  5792. v := m.start_time
  5793. if v == nil {
  5794. return
  5795. }
  5796. return *v, true
  5797. }
  5798. // OldStartTime returns the old "start_time" 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) OldStartTime(ctx context.Context) (v time.Time, err error) {
  5802. if !m.op.Is(OpUpdateOne) {
  5803. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  5804. }
  5805. if m.id == nil || m.oldValue == nil {
  5806. return v, errors.New("OldStartTime 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 OldStartTime: %w", err)
  5811. }
  5812. return oldValue.StartTime, nil
  5813. }
  5814. // ClearStartTime clears the value of the "start_time" field.
  5815. func (m *BatchMsgMutation) ClearStartTime() {
  5816. m.start_time = nil
  5817. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  5818. }
  5819. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  5820. func (m *BatchMsgMutation) StartTimeCleared() bool {
  5821. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  5822. return ok
  5823. }
  5824. // ResetStartTime resets all changes to the "start_time" field.
  5825. func (m *BatchMsgMutation) ResetStartTime() {
  5826. m.start_time = nil
  5827. delete(m.clearedFields, batchmsg.FieldStartTime)
  5828. }
  5829. // SetStopTime sets the "stop_time" field.
  5830. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  5831. m.stop_time = &t
  5832. }
  5833. // StopTime returns the value of the "stop_time" field in the mutation.
  5834. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  5835. v := m.stop_time
  5836. if v == nil {
  5837. return
  5838. }
  5839. return *v, true
  5840. }
  5841. // OldStopTime returns the old "stop_time" 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) OldStopTime(ctx context.Context) (v time.Time, err error) {
  5845. if !m.op.Is(OpUpdateOne) {
  5846. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  5847. }
  5848. if m.id == nil || m.oldValue == nil {
  5849. return v, errors.New("OldStopTime 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 OldStopTime: %w", err)
  5854. }
  5855. return oldValue.StopTime, nil
  5856. }
  5857. // ClearStopTime clears the value of the "stop_time" field.
  5858. func (m *BatchMsgMutation) ClearStopTime() {
  5859. m.stop_time = nil
  5860. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  5861. }
  5862. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  5863. func (m *BatchMsgMutation) StopTimeCleared() bool {
  5864. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  5865. return ok
  5866. }
  5867. // ResetStopTime resets all changes to the "stop_time" field.
  5868. func (m *BatchMsgMutation) ResetStopTime() {
  5869. m.stop_time = nil
  5870. delete(m.clearedFields, batchmsg.FieldStopTime)
  5871. }
  5872. // SetSendTime sets the "send_time" field.
  5873. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  5874. m.send_time = &t
  5875. }
  5876. // SendTime returns the value of the "send_time" field in the mutation.
  5877. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  5878. v := m.send_time
  5879. if v == nil {
  5880. return
  5881. }
  5882. return *v, true
  5883. }
  5884. // OldSendTime returns the old "send_time" 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) OldSendTime(ctx context.Context) (v time.Time, err error) {
  5888. if !m.op.Is(OpUpdateOne) {
  5889. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  5890. }
  5891. if m.id == nil || m.oldValue == nil {
  5892. return v, errors.New("OldSendTime 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 OldSendTime: %w", err)
  5897. }
  5898. return oldValue.SendTime, nil
  5899. }
  5900. // ClearSendTime clears the value of the "send_time" field.
  5901. func (m *BatchMsgMutation) ClearSendTime() {
  5902. m.send_time = nil
  5903. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  5904. }
  5905. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  5906. func (m *BatchMsgMutation) SendTimeCleared() bool {
  5907. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  5908. return ok
  5909. }
  5910. // ResetSendTime resets all changes to the "send_time" field.
  5911. func (m *BatchMsgMutation) ResetSendTime() {
  5912. m.send_time = nil
  5913. delete(m.clearedFields, batchmsg.FieldSendTime)
  5914. }
  5915. // SetType sets the "type" field.
  5916. func (m *BatchMsgMutation) SetType(i int32) {
  5917. m._type = &i
  5918. m.add_type = nil
  5919. }
  5920. // GetType returns the value of the "type" field in the mutation.
  5921. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  5922. v := m._type
  5923. if v == nil {
  5924. return
  5925. }
  5926. return *v, true
  5927. }
  5928. // OldType returns the old "type" 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) OldType(ctx context.Context) (v int32, err error) {
  5932. if !m.op.Is(OpUpdateOne) {
  5933. return v, errors.New("OldType is only allowed on UpdateOne operations")
  5934. }
  5935. if m.id == nil || m.oldValue == nil {
  5936. return v, errors.New("OldType 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 OldType: %w", err)
  5941. }
  5942. return oldValue.Type, nil
  5943. }
  5944. // AddType adds i to the "type" field.
  5945. func (m *BatchMsgMutation) AddType(i int32) {
  5946. if m.add_type != nil {
  5947. *m.add_type += i
  5948. } else {
  5949. m.add_type = &i
  5950. }
  5951. }
  5952. // AddedType returns the value that was added to the "type" field in this mutation.
  5953. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  5954. v := m.add_type
  5955. if v == nil {
  5956. return
  5957. }
  5958. return *v, true
  5959. }
  5960. // ClearType clears the value of the "type" field.
  5961. func (m *BatchMsgMutation) ClearType() {
  5962. m._type = nil
  5963. m.add_type = nil
  5964. m.clearedFields[batchmsg.FieldType] = struct{}{}
  5965. }
  5966. // TypeCleared returns if the "type" field was cleared in this mutation.
  5967. func (m *BatchMsgMutation) TypeCleared() bool {
  5968. _, ok := m.clearedFields[batchmsg.FieldType]
  5969. return ok
  5970. }
  5971. // ResetType resets all changes to the "type" field.
  5972. func (m *BatchMsgMutation) ResetType() {
  5973. m._type = nil
  5974. m.add_type = nil
  5975. delete(m.clearedFields, batchmsg.FieldType)
  5976. }
  5977. // SetOrganizationID sets the "organization_id" field.
  5978. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  5979. m.organization_id = &u
  5980. m.addorganization_id = nil
  5981. }
  5982. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5983. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  5984. v := m.organization_id
  5985. if v == nil {
  5986. return
  5987. }
  5988. return *v, true
  5989. }
  5990. // OldOrganizationID returns the old "organization_id" 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) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5994. if !m.op.Is(OpUpdateOne) {
  5995. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5996. }
  5997. if m.id == nil || m.oldValue == nil {
  5998. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  6003. }
  6004. return oldValue.OrganizationID, nil
  6005. }
  6006. // AddOrganizationID adds u to the "organization_id" field.
  6007. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  6008. if m.addorganization_id != nil {
  6009. *m.addorganization_id += u
  6010. } else {
  6011. m.addorganization_id = &u
  6012. }
  6013. }
  6014. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  6015. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  6016. v := m.addorganization_id
  6017. if v == nil {
  6018. return
  6019. }
  6020. return *v, true
  6021. }
  6022. // ResetOrganizationID resets all changes to the "organization_id" field.
  6023. func (m *BatchMsgMutation) ResetOrganizationID() {
  6024. m.organization_id = nil
  6025. m.addorganization_id = nil
  6026. }
  6027. // SetCtype sets the "ctype" field.
  6028. func (m *BatchMsgMutation) SetCtype(u uint64) {
  6029. m.ctype = &u
  6030. m.addctype = nil
  6031. }
  6032. // Ctype returns the value of the "ctype" field in the mutation.
  6033. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  6034. v := m.ctype
  6035. if v == nil {
  6036. return
  6037. }
  6038. return *v, true
  6039. }
  6040. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  6041. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6043. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  6044. if !m.op.Is(OpUpdateOne) {
  6045. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  6046. }
  6047. if m.id == nil || m.oldValue == nil {
  6048. return v, errors.New("OldCtype requires an ID field in the mutation")
  6049. }
  6050. oldValue, err := m.oldValue(ctx)
  6051. if err != nil {
  6052. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  6053. }
  6054. return oldValue.Ctype, nil
  6055. }
  6056. // AddCtype adds u to the "ctype" field.
  6057. func (m *BatchMsgMutation) AddCtype(u int64) {
  6058. if m.addctype != nil {
  6059. *m.addctype += u
  6060. } else {
  6061. m.addctype = &u
  6062. }
  6063. }
  6064. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  6065. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  6066. v := m.addctype
  6067. if v == nil {
  6068. return
  6069. }
  6070. return *v, true
  6071. }
  6072. // ResetCtype resets all changes to the "ctype" field.
  6073. func (m *BatchMsgMutation) ResetCtype() {
  6074. m.ctype = nil
  6075. m.addctype = nil
  6076. }
  6077. // SetCc sets the "cc" field.
  6078. func (m *BatchMsgMutation) SetCc(s string) {
  6079. m.cc = &s
  6080. }
  6081. // Cc returns the value of the "cc" field in the mutation.
  6082. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  6083. v := m.cc
  6084. if v == nil {
  6085. return
  6086. }
  6087. return *v, true
  6088. }
  6089. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  6090. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6092. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  6093. if !m.op.Is(OpUpdateOne) {
  6094. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  6095. }
  6096. if m.id == nil || m.oldValue == nil {
  6097. return v, errors.New("OldCc requires an ID field in the mutation")
  6098. }
  6099. oldValue, err := m.oldValue(ctx)
  6100. if err != nil {
  6101. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  6102. }
  6103. return oldValue.Cc, nil
  6104. }
  6105. // ClearCc clears the value of the "cc" field.
  6106. func (m *BatchMsgMutation) ClearCc() {
  6107. m.cc = nil
  6108. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  6109. }
  6110. // CcCleared returns if the "cc" field was cleared in this mutation.
  6111. func (m *BatchMsgMutation) CcCleared() bool {
  6112. _, ok := m.clearedFields[batchmsg.FieldCc]
  6113. return ok
  6114. }
  6115. // ResetCc resets all changes to the "cc" field.
  6116. func (m *BatchMsgMutation) ResetCc() {
  6117. m.cc = nil
  6118. delete(m.clearedFields, batchmsg.FieldCc)
  6119. }
  6120. // SetPhone sets the "phone" field.
  6121. func (m *BatchMsgMutation) SetPhone(s string) {
  6122. m.phone = &s
  6123. }
  6124. // Phone returns the value of the "phone" field in the mutation.
  6125. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  6126. v := m.phone
  6127. if v == nil {
  6128. return
  6129. }
  6130. return *v, true
  6131. }
  6132. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  6133. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6135. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  6136. if !m.op.Is(OpUpdateOne) {
  6137. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  6138. }
  6139. if m.id == nil || m.oldValue == nil {
  6140. return v, errors.New("OldPhone requires an ID field in the mutation")
  6141. }
  6142. oldValue, err := m.oldValue(ctx)
  6143. if err != nil {
  6144. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  6145. }
  6146. return oldValue.Phone, nil
  6147. }
  6148. // ClearPhone clears the value of the "phone" field.
  6149. func (m *BatchMsgMutation) ClearPhone() {
  6150. m.phone = nil
  6151. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  6152. }
  6153. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  6154. func (m *BatchMsgMutation) PhoneCleared() bool {
  6155. _, ok := m.clearedFields[batchmsg.FieldPhone]
  6156. return ok
  6157. }
  6158. // ResetPhone resets all changes to the "phone" field.
  6159. func (m *BatchMsgMutation) ResetPhone() {
  6160. m.phone = nil
  6161. delete(m.clearedFields, batchmsg.FieldPhone)
  6162. }
  6163. // SetTemplateName sets the "template_name" field.
  6164. func (m *BatchMsgMutation) SetTemplateName(s string) {
  6165. m.template_name = &s
  6166. }
  6167. // TemplateName returns the value of the "template_name" field in the mutation.
  6168. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  6169. v := m.template_name
  6170. if v == nil {
  6171. return
  6172. }
  6173. return *v, true
  6174. }
  6175. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  6176. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6178. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  6179. if !m.op.Is(OpUpdateOne) {
  6180. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  6181. }
  6182. if m.id == nil || m.oldValue == nil {
  6183. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  6184. }
  6185. oldValue, err := m.oldValue(ctx)
  6186. if err != nil {
  6187. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  6188. }
  6189. return oldValue.TemplateName, nil
  6190. }
  6191. // ClearTemplateName clears the value of the "template_name" field.
  6192. func (m *BatchMsgMutation) ClearTemplateName() {
  6193. m.template_name = nil
  6194. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  6195. }
  6196. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  6197. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  6198. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  6199. return ok
  6200. }
  6201. // ResetTemplateName resets all changes to the "template_name" field.
  6202. func (m *BatchMsgMutation) ResetTemplateName() {
  6203. m.template_name = nil
  6204. delete(m.clearedFields, batchmsg.FieldTemplateName)
  6205. }
  6206. // SetTemplateCode sets the "template_code" field.
  6207. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  6208. m.template_code = &s
  6209. }
  6210. // TemplateCode returns the value of the "template_code" field in the mutation.
  6211. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  6212. v := m.template_code
  6213. if v == nil {
  6214. return
  6215. }
  6216. return *v, true
  6217. }
  6218. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  6219. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6221. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  6222. if !m.op.Is(OpUpdateOne) {
  6223. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  6224. }
  6225. if m.id == nil || m.oldValue == nil {
  6226. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  6227. }
  6228. oldValue, err := m.oldValue(ctx)
  6229. if err != nil {
  6230. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  6231. }
  6232. return oldValue.TemplateCode, nil
  6233. }
  6234. // ClearTemplateCode clears the value of the "template_code" field.
  6235. func (m *BatchMsgMutation) ClearTemplateCode() {
  6236. m.template_code = nil
  6237. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  6238. }
  6239. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  6240. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  6241. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  6242. return ok
  6243. }
  6244. // ResetTemplateCode resets all changes to the "template_code" field.
  6245. func (m *BatchMsgMutation) ResetTemplateCode() {
  6246. m.template_code = nil
  6247. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  6248. }
  6249. // SetLang sets the "lang" field.
  6250. func (m *BatchMsgMutation) SetLang(s string) {
  6251. m.lang = &s
  6252. }
  6253. // Lang returns the value of the "lang" field in the mutation.
  6254. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  6255. v := m.lang
  6256. if v == nil {
  6257. return
  6258. }
  6259. return *v, true
  6260. }
  6261. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  6262. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6264. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  6265. if !m.op.Is(OpUpdateOne) {
  6266. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  6267. }
  6268. if m.id == nil || m.oldValue == nil {
  6269. return v, errors.New("OldLang requires an ID field in the mutation")
  6270. }
  6271. oldValue, err := m.oldValue(ctx)
  6272. if err != nil {
  6273. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  6274. }
  6275. return oldValue.Lang, nil
  6276. }
  6277. // ClearLang clears the value of the "lang" field.
  6278. func (m *BatchMsgMutation) ClearLang() {
  6279. m.lang = nil
  6280. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  6281. }
  6282. // LangCleared returns if the "lang" field was cleared in this mutation.
  6283. func (m *BatchMsgMutation) LangCleared() bool {
  6284. _, ok := m.clearedFields[batchmsg.FieldLang]
  6285. return ok
  6286. }
  6287. // ResetLang resets all changes to the "lang" field.
  6288. func (m *BatchMsgMutation) ResetLang() {
  6289. m.lang = nil
  6290. delete(m.clearedFields, batchmsg.FieldLang)
  6291. }
  6292. // Where appends a list predicates to the BatchMsgMutation builder.
  6293. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  6294. m.predicates = append(m.predicates, ps...)
  6295. }
  6296. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  6297. // users can use type-assertion to append predicates that do not depend on any generated package.
  6298. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  6299. p := make([]predicate.BatchMsg, len(ps))
  6300. for i := range ps {
  6301. p[i] = ps[i]
  6302. }
  6303. m.Where(p...)
  6304. }
  6305. // Op returns the operation name.
  6306. func (m *BatchMsgMutation) Op() Op {
  6307. return m.op
  6308. }
  6309. // SetOp allows setting the mutation operation.
  6310. func (m *BatchMsgMutation) SetOp(op Op) {
  6311. m.op = op
  6312. }
  6313. // Type returns the node type of this mutation (BatchMsg).
  6314. func (m *BatchMsgMutation) Type() string {
  6315. return m.typ
  6316. }
  6317. // Fields returns all fields that were changed during this mutation. Note that in
  6318. // order to get all numeric fields that were incremented/decremented, call
  6319. // AddedFields().
  6320. func (m *BatchMsgMutation) Fields() []string {
  6321. fields := make([]string, 0, 24)
  6322. if m.created_at != nil {
  6323. fields = append(fields, batchmsg.FieldCreatedAt)
  6324. }
  6325. if m.updated_at != nil {
  6326. fields = append(fields, batchmsg.FieldUpdatedAt)
  6327. }
  6328. if m.deleted_at != nil {
  6329. fields = append(fields, batchmsg.FieldDeletedAt)
  6330. }
  6331. if m.status != nil {
  6332. fields = append(fields, batchmsg.FieldStatus)
  6333. }
  6334. if m.batch_no != nil {
  6335. fields = append(fields, batchmsg.FieldBatchNo)
  6336. }
  6337. if m.task_name != nil {
  6338. fields = append(fields, batchmsg.FieldTaskName)
  6339. }
  6340. if m.fromwxid != nil {
  6341. fields = append(fields, batchmsg.FieldFromwxid)
  6342. }
  6343. if m.msg != nil {
  6344. fields = append(fields, batchmsg.FieldMsg)
  6345. }
  6346. if m.tag != nil {
  6347. fields = append(fields, batchmsg.FieldTag)
  6348. }
  6349. if m.tagids != nil {
  6350. fields = append(fields, batchmsg.FieldTagids)
  6351. }
  6352. if m.total != nil {
  6353. fields = append(fields, batchmsg.FieldTotal)
  6354. }
  6355. if m.success != nil {
  6356. fields = append(fields, batchmsg.FieldSuccess)
  6357. }
  6358. if m.fail != nil {
  6359. fields = append(fields, batchmsg.FieldFail)
  6360. }
  6361. if m.start_time != nil {
  6362. fields = append(fields, batchmsg.FieldStartTime)
  6363. }
  6364. if m.stop_time != nil {
  6365. fields = append(fields, batchmsg.FieldStopTime)
  6366. }
  6367. if m.send_time != nil {
  6368. fields = append(fields, batchmsg.FieldSendTime)
  6369. }
  6370. if m._type != nil {
  6371. fields = append(fields, batchmsg.FieldType)
  6372. }
  6373. if m.organization_id != nil {
  6374. fields = append(fields, batchmsg.FieldOrganizationID)
  6375. }
  6376. if m.ctype != nil {
  6377. fields = append(fields, batchmsg.FieldCtype)
  6378. }
  6379. if m.cc != nil {
  6380. fields = append(fields, batchmsg.FieldCc)
  6381. }
  6382. if m.phone != nil {
  6383. fields = append(fields, batchmsg.FieldPhone)
  6384. }
  6385. if m.template_name != nil {
  6386. fields = append(fields, batchmsg.FieldTemplateName)
  6387. }
  6388. if m.template_code != nil {
  6389. fields = append(fields, batchmsg.FieldTemplateCode)
  6390. }
  6391. if m.lang != nil {
  6392. fields = append(fields, batchmsg.FieldLang)
  6393. }
  6394. return fields
  6395. }
  6396. // Field returns the value of a field with the given name. The second boolean
  6397. // return value indicates that this field was not set, or was not defined in the
  6398. // schema.
  6399. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  6400. switch name {
  6401. case batchmsg.FieldCreatedAt:
  6402. return m.CreatedAt()
  6403. case batchmsg.FieldUpdatedAt:
  6404. return m.UpdatedAt()
  6405. case batchmsg.FieldDeletedAt:
  6406. return m.DeletedAt()
  6407. case batchmsg.FieldStatus:
  6408. return m.Status()
  6409. case batchmsg.FieldBatchNo:
  6410. return m.BatchNo()
  6411. case batchmsg.FieldTaskName:
  6412. return m.TaskName()
  6413. case batchmsg.FieldFromwxid:
  6414. return m.Fromwxid()
  6415. case batchmsg.FieldMsg:
  6416. return m.Msg()
  6417. case batchmsg.FieldTag:
  6418. return m.Tag()
  6419. case batchmsg.FieldTagids:
  6420. return m.Tagids()
  6421. case batchmsg.FieldTotal:
  6422. return m.Total()
  6423. case batchmsg.FieldSuccess:
  6424. return m.Success()
  6425. case batchmsg.FieldFail:
  6426. return m.Fail()
  6427. case batchmsg.FieldStartTime:
  6428. return m.StartTime()
  6429. case batchmsg.FieldStopTime:
  6430. return m.StopTime()
  6431. case batchmsg.FieldSendTime:
  6432. return m.SendTime()
  6433. case batchmsg.FieldType:
  6434. return m.GetType()
  6435. case batchmsg.FieldOrganizationID:
  6436. return m.OrganizationID()
  6437. case batchmsg.FieldCtype:
  6438. return m.Ctype()
  6439. case batchmsg.FieldCc:
  6440. return m.Cc()
  6441. case batchmsg.FieldPhone:
  6442. return m.Phone()
  6443. case batchmsg.FieldTemplateName:
  6444. return m.TemplateName()
  6445. case batchmsg.FieldTemplateCode:
  6446. return m.TemplateCode()
  6447. case batchmsg.FieldLang:
  6448. return m.Lang()
  6449. }
  6450. return nil, false
  6451. }
  6452. // OldField returns the old value of the field from the database. An error is
  6453. // returned if the mutation operation is not UpdateOne, or the query to the
  6454. // database failed.
  6455. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6456. switch name {
  6457. case batchmsg.FieldCreatedAt:
  6458. return m.OldCreatedAt(ctx)
  6459. case batchmsg.FieldUpdatedAt:
  6460. return m.OldUpdatedAt(ctx)
  6461. case batchmsg.FieldDeletedAt:
  6462. return m.OldDeletedAt(ctx)
  6463. case batchmsg.FieldStatus:
  6464. return m.OldStatus(ctx)
  6465. case batchmsg.FieldBatchNo:
  6466. return m.OldBatchNo(ctx)
  6467. case batchmsg.FieldTaskName:
  6468. return m.OldTaskName(ctx)
  6469. case batchmsg.FieldFromwxid:
  6470. return m.OldFromwxid(ctx)
  6471. case batchmsg.FieldMsg:
  6472. return m.OldMsg(ctx)
  6473. case batchmsg.FieldTag:
  6474. return m.OldTag(ctx)
  6475. case batchmsg.FieldTagids:
  6476. return m.OldTagids(ctx)
  6477. case batchmsg.FieldTotal:
  6478. return m.OldTotal(ctx)
  6479. case batchmsg.FieldSuccess:
  6480. return m.OldSuccess(ctx)
  6481. case batchmsg.FieldFail:
  6482. return m.OldFail(ctx)
  6483. case batchmsg.FieldStartTime:
  6484. return m.OldStartTime(ctx)
  6485. case batchmsg.FieldStopTime:
  6486. return m.OldStopTime(ctx)
  6487. case batchmsg.FieldSendTime:
  6488. return m.OldSendTime(ctx)
  6489. case batchmsg.FieldType:
  6490. return m.OldType(ctx)
  6491. case batchmsg.FieldOrganizationID:
  6492. return m.OldOrganizationID(ctx)
  6493. case batchmsg.FieldCtype:
  6494. return m.OldCtype(ctx)
  6495. case batchmsg.FieldCc:
  6496. return m.OldCc(ctx)
  6497. case batchmsg.FieldPhone:
  6498. return m.OldPhone(ctx)
  6499. case batchmsg.FieldTemplateName:
  6500. return m.OldTemplateName(ctx)
  6501. case batchmsg.FieldTemplateCode:
  6502. return m.OldTemplateCode(ctx)
  6503. case batchmsg.FieldLang:
  6504. return m.OldLang(ctx)
  6505. }
  6506. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  6507. }
  6508. // SetField sets the value of a field with the given name. It returns an error if
  6509. // the field is not defined in the schema, or if the type mismatched the field
  6510. // type.
  6511. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  6512. switch name {
  6513. case batchmsg.FieldCreatedAt:
  6514. v, ok := value.(time.Time)
  6515. if !ok {
  6516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6517. }
  6518. m.SetCreatedAt(v)
  6519. return nil
  6520. case batchmsg.FieldUpdatedAt:
  6521. v, ok := value.(time.Time)
  6522. if !ok {
  6523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6524. }
  6525. m.SetUpdatedAt(v)
  6526. return nil
  6527. case batchmsg.FieldDeletedAt:
  6528. v, ok := value.(time.Time)
  6529. if !ok {
  6530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6531. }
  6532. m.SetDeletedAt(v)
  6533. return nil
  6534. case batchmsg.FieldStatus:
  6535. v, ok := value.(uint8)
  6536. if !ok {
  6537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6538. }
  6539. m.SetStatus(v)
  6540. return nil
  6541. case batchmsg.FieldBatchNo:
  6542. v, ok := value.(string)
  6543. if !ok {
  6544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6545. }
  6546. m.SetBatchNo(v)
  6547. return nil
  6548. case batchmsg.FieldTaskName:
  6549. v, ok := value.(string)
  6550. if !ok {
  6551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6552. }
  6553. m.SetTaskName(v)
  6554. return nil
  6555. case batchmsg.FieldFromwxid:
  6556. v, ok := value.(string)
  6557. if !ok {
  6558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6559. }
  6560. m.SetFromwxid(v)
  6561. return nil
  6562. case batchmsg.FieldMsg:
  6563. v, ok := value.(string)
  6564. if !ok {
  6565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6566. }
  6567. m.SetMsg(v)
  6568. return nil
  6569. case batchmsg.FieldTag:
  6570. v, ok := value.(string)
  6571. if !ok {
  6572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6573. }
  6574. m.SetTag(v)
  6575. return nil
  6576. case batchmsg.FieldTagids:
  6577. v, ok := value.(string)
  6578. if !ok {
  6579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6580. }
  6581. m.SetTagids(v)
  6582. return nil
  6583. case batchmsg.FieldTotal:
  6584. v, ok := value.(int32)
  6585. if !ok {
  6586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6587. }
  6588. m.SetTotal(v)
  6589. return nil
  6590. case batchmsg.FieldSuccess:
  6591. v, ok := value.(int32)
  6592. if !ok {
  6593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6594. }
  6595. m.SetSuccess(v)
  6596. return nil
  6597. case batchmsg.FieldFail:
  6598. v, ok := value.(int32)
  6599. if !ok {
  6600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6601. }
  6602. m.SetFail(v)
  6603. return nil
  6604. case batchmsg.FieldStartTime:
  6605. v, ok := value.(time.Time)
  6606. if !ok {
  6607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6608. }
  6609. m.SetStartTime(v)
  6610. return nil
  6611. case batchmsg.FieldStopTime:
  6612. v, ok := value.(time.Time)
  6613. if !ok {
  6614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6615. }
  6616. m.SetStopTime(v)
  6617. return nil
  6618. case batchmsg.FieldSendTime:
  6619. v, ok := value.(time.Time)
  6620. if !ok {
  6621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6622. }
  6623. m.SetSendTime(v)
  6624. return nil
  6625. case batchmsg.FieldType:
  6626. v, ok := value.(int32)
  6627. if !ok {
  6628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6629. }
  6630. m.SetType(v)
  6631. return nil
  6632. case batchmsg.FieldOrganizationID:
  6633. v, ok := value.(uint64)
  6634. if !ok {
  6635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6636. }
  6637. m.SetOrganizationID(v)
  6638. return nil
  6639. case batchmsg.FieldCtype:
  6640. v, ok := value.(uint64)
  6641. if !ok {
  6642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6643. }
  6644. m.SetCtype(v)
  6645. return nil
  6646. case batchmsg.FieldCc:
  6647. v, ok := value.(string)
  6648. if !ok {
  6649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6650. }
  6651. m.SetCc(v)
  6652. return nil
  6653. case batchmsg.FieldPhone:
  6654. v, ok := value.(string)
  6655. if !ok {
  6656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6657. }
  6658. m.SetPhone(v)
  6659. return nil
  6660. case batchmsg.FieldTemplateName:
  6661. v, ok := value.(string)
  6662. if !ok {
  6663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6664. }
  6665. m.SetTemplateName(v)
  6666. return nil
  6667. case batchmsg.FieldTemplateCode:
  6668. v, ok := value.(string)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetTemplateCode(v)
  6673. return nil
  6674. case batchmsg.FieldLang:
  6675. v, ok := value.(string)
  6676. if !ok {
  6677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6678. }
  6679. m.SetLang(v)
  6680. return nil
  6681. }
  6682. return fmt.Errorf("unknown BatchMsg field %s", name)
  6683. }
  6684. // AddedFields returns all numeric fields that were incremented/decremented during
  6685. // this mutation.
  6686. func (m *BatchMsgMutation) AddedFields() []string {
  6687. var fields []string
  6688. if m.addstatus != nil {
  6689. fields = append(fields, batchmsg.FieldStatus)
  6690. }
  6691. if m.addtotal != nil {
  6692. fields = append(fields, batchmsg.FieldTotal)
  6693. }
  6694. if m.addsuccess != nil {
  6695. fields = append(fields, batchmsg.FieldSuccess)
  6696. }
  6697. if m.addfail != nil {
  6698. fields = append(fields, batchmsg.FieldFail)
  6699. }
  6700. if m.add_type != nil {
  6701. fields = append(fields, batchmsg.FieldType)
  6702. }
  6703. if m.addorganization_id != nil {
  6704. fields = append(fields, batchmsg.FieldOrganizationID)
  6705. }
  6706. if m.addctype != nil {
  6707. fields = append(fields, batchmsg.FieldCtype)
  6708. }
  6709. return fields
  6710. }
  6711. // AddedField returns the numeric value that was incremented/decremented on a field
  6712. // with the given name. The second boolean return value indicates that this field
  6713. // was not set, or was not defined in the schema.
  6714. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  6715. switch name {
  6716. case batchmsg.FieldStatus:
  6717. return m.AddedStatus()
  6718. case batchmsg.FieldTotal:
  6719. return m.AddedTotal()
  6720. case batchmsg.FieldSuccess:
  6721. return m.AddedSuccess()
  6722. case batchmsg.FieldFail:
  6723. return m.AddedFail()
  6724. case batchmsg.FieldType:
  6725. return m.AddedType()
  6726. case batchmsg.FieldOrganizationID:
  6727. return m.AddedOrganizationID()
  6728. case batchmsg.FieldCtype:
  6729. return m.AddedCtype()
  6730. }
  6731. return nil, false
  6732. }
  6733. // AddField adds the value to the field with the given name. It returns an error if
  6734. // the field is not defined in the schema, or if the type mismatched the field
  6735. // type.
  6736. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  6737. switch name {
  6738. case batchmsg.FieldStatus:
  6739. v, ok := value.(int8)
  6740. if !ok {
  6741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6742. }
  6743. m.AddStatus(v)
  6744. return nil
  6745. case batchmsg.FieldTotal:
  6746. v, ok := value.(int32)
  6747. if !ok {
  6748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6749. }
  6750. m.AddTotal(v)
  6751. return nil
  6752. case batchmsg.FieldSuccess:
  6753. v, ok := value.(int32)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.AddSuccess(v)
  6758. return nil
  6759. case batchmsg.FieldFail:
  6760. v, ok := value.(int32)
  6761. if !ok {
  6762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6763. }
  6764. m.AddFail(v)
  6765. return nil
  6766. case batchmsg.FieldType:
  6767. v, ok := value.(int32)
  6768. if !ok {
  6769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6770. }
  6771. m.AddType(v)
  6772. return nil
  6773. case batchmsg.FieldOrganizationID:
  6774. v, ok := value.(int64)
  6775. if !ok {
  6776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6777. }
  6778. m.AddOrganizationID(v)
  6779. return nil
  6780. case batchmsg.FieldCtype:
  6781. v, ok := value.(int64)
  6782. if !ok {
  6783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6784. }
  6785. m.AddCtype(v)
  6786. return nil
  6787. }
  6788. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  6789. }
  6790. // ClearedFields returns all nullable fields that were cleared during this
  6791. // mutation.
  6792. func (m *BatchMsgMutation) ClearedFields() []string {
  6793. var fields []string
  6794. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  6795. fields = append(fields, batchmsg.FieldDeletedAt)
  6796. }
  6797. if m.FieldCleared(batchmsg.FieldStatus) {
  6798. fields = append(fields, batchmsg.FieldStatus)
  6799. }
  6800. if m.FieldCleared(batchmsg.FieldBatchNo) {
  6801. fields = append(fields, batchmsg.FieldBatchNo)
  6802. }
  6803. if m.FieldCleared(batchmsg.FieldTaskName) {
  6804. fields = append(fields, batchmsg.FieldTaskName)
  6805. }
  6806. if m.FieldCleared(batchmsg.FieldFromwxid) {
  6807. fields = append(fields, batchmsg.FieldFromwxid)
  6808. }
  6809. if m.FieldCleared(batchmsg.FieldMsg) {
  6810. fields = append(fields, batchmsg.FieldMsg)
  6811. }
  6812. if m.FieldCleared(batchmsg.FieldTag) {
  6813. fields = append(fields, batchmsg.FieldTag)
  6814. }
  6815. if m.FieldCleared(batchmsg.FieldTagids) {
  6816. fields = append(fields, batchmsg.FieldTagids)
  6817. }
  6818. if m.FieldCleared(batchmsg.FieldTotal) {
  6819. fields = append(fields, batchmsg.FieldTotal)
  6820. }
  6821. if m.FieldCleared(batchmsg.FieldSuccess) {
  6822. fields = append(fields, batchmsg.FieldSuccess)
  6823. }
  6824. if m.FieldCleared(batchmsg.FieldFail) {
  6825. fields = append(fields, batchmsg.FieldFail)
  6826. }
  6827. if m.FieldCleared(batchmsg.FieldStartTime) {
  6828. fields = append(fields, batchmsg.FieldStartTime)
  6829. }
  6830. if m.FieldCleared(batchmsg.FieldStopTime) {
  6831. fields = append(fields, batchmsg.FieldStopTime)
  6832. }
  6833. if m.FieldCleared(batchmsg.FieldSendTime) {
  6834. fields = append(fields, batchmsg.FieldSendTime)
  6835. }
  6836. if m.FieldCleared(batchmsg.FieldType) {
  6837. fields = append(fields, batchmsg.FieldType)
  6838. }
  6839. if m.FieldCleared(batchmsg.FieldCc) {
  6840. fields = append(fields, batchmsg.FieldCc)
  6841. }
  6842. if m.FieldCleared(batchmsg.FieldPhone) {
  6843. fields = append(fields, batchmsg.FieldPhone)
  6844. }
  6845. if m.FieldCleared(batchmsg.FieldTemplateName) {
  6846. fields = append(fields, batchmsg.FieldTemplateName)
  6847. }
  6848. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  6849. fields = append(fields, batchmsg.FieldTemplateCode)
  6850. }
  6851. if m.FieldCleared(batchmsg.FieldLang) {
  6852. fields = append(fields, batchmsg.FieldLang)
  6853. }
  6854. return fields
  6855. }
  6856. // FieldCleared returns a boolean indicating if a field with the given name was
  6857. // cleared in this mutation.
  6858. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  6859. _, ok := m.clearedFields[name]
  6860. return ok
  6861. }
  6862. // ClearField clears the value of the field with the given name. It returns an
  6863. // error if the field is not defined in the schema.
  6864. func (m *BatchMsgMutation) ClearField(name string) error {
  6865. switch name {
  6866. case batchmsg.FieldDeletedAt:
  6867. m.ClearDeletedAt()
  6868. return nil
  6869. case batchmsg.FieldStatus:
  6870. m.ClearStatus()
  6871. return nil
  6872. case batchmsg.FieldBatchNo:
  6873. m.ClearBatchNo()
  6874. return nil
  6875. case batchmsg.FieldTaskName:
  6876. m.ClearTaskName()
  6877. return nil
  6878. case batchmsg.FieldFromwxid:
  6879. m.ClearFromwxid()
  6880. return nil
  6881. case batchmsg.FieldMsg:
  6882. m.ClearMsg()
  6883. return nil
  6884. case batchmsg.FieldTag:
  6885. m.ClearTag()
  6886. return nil
  6887. case batchmsg.FieldTagids:
  6888. m.ClearTagids()
  6889. return nil
  6890. case batchmsg.FieldTotal:
  6891. m.ClearTotal()
  6892. return nil
  6893. case batchmsg.FieldSuccess:
  6894. m.ClearSuccess()
  6895. return nil
  6896. case batchmsg.FieldFail:
  6897. m.ClearFail()
  6898. return nil
  6899. case batchmsg.FieldStartTime:
  6900. m.ClearStartTime()
  6901. return nil
  6902. case batchmsg.FieldStopTime:
  6903. m.ClearStopTime()
  6904. return nil
  6905. case batchmsg.FieldSendTime:
  6906. m.ClearSendTime()
  6907. return nil
  6908. case batchmsg.FieldType:
  6909. m.ClearType()
  6910. return nil
  6911. case batchmsg.FieldCc:
  6912. m.ClearCc()
  6913. return nil
  6914. case batchmsg.FieldPhone:
  6915. m.ClearPhone()
  6916. return nil
  6917. case batchmsg.FieldTemplateName:
  6918. m.ClearTemplateName()
  6919. return nil
  6920. case batchmsg.FieldTemplateCode:
  6921. m.ClearTemplateCode()
  6922. return nil
  6923. case batchmsg.FieldLang:
  6924. m.ClearLang()
  6925. return nil
  6926. }
  6927. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  6928. }
  6929. // ResetField resets all changes in the mutation for the field with the given name.
  6930. // It returns an error if the field is not defined in the schema.
  6931. func (m *BatchMsgMutation) ResetField(name string) error {
  6932. switch name {
  6933. case batchmsg.FieldCreatedAt:
  6934. m.ResetCreatedAt()
  6935. return nil
  6936. case batchmsg.FieldUpdatedAt:
  6937. m.ResetUpdatedAt()
  6938. return nil
  6939. case batchmsg.FieldDeletedAt:
  6940. m.ResetDeletedAt()
  6941. return nil
  6942. case batchmsg.FieldStatus:
  6943. m.ResetStatus()
  6944. return nil
  6945. case batchmsg.FieldBatchNo:
  6946. m.ResetBatchNo()
  6947. return nil
  6948. case batchmsg.FieldTaskName:
  6949. m.ResetTaskName()
  6950. return nil
  6951. case batchmsg.FieldFromwxid:
  6952. m.ResetFromwxid()
  6953. return nil
  6954. case batchmsg.FieldMsg:
  6955. m.ResetMsg()
  6956. return nil
  6957. case batchmsg.FieldTag:
  6958. m.ResetTag()
  6959. return nil
  6960. case batchmsg.FieldTagids:
  6961. m.ResetTagids()
  6962. return nil
  6963. case batchmsg.FieldTotal:
  6964. m.ResetTotal()
  6965. return nil
  6966. case batchmsg.FieldSuccess:
  6967. m.ResetSuccess()
  6968. return nil
  6969. case batchmsg.FieldFail:
  6970. m.ResetFail()
  6971. return nil
  6972. case batchmsg.FieldStartTime:
  6973. m.ResetStartTime()
  6974. return nil
  6975. case batchmsg.FieldStopTime:
  6976. m.ResetStopTime()
  6977. return nil
  6978. case batchmsg.FieldSendTime:
  6979. m.ResetSendTime()
  6980. return nil
  6981. case batchmsg.FieldType:
  6982. m.ResetType()
  6983. return nil
  6984. case batchmsg.FieldOrganizationID:
  6985. m.ResetOrganizationID()
  6986. return nil
  6987. case batchmsg.FieldCtype:
  6988. m.ResetCtype()
  6989. return nil
  6990. case batchmsg.FieldCc:
  6991. m.ResetCc()
  6992. return nil
  6993. case batchmsg.FieldPhone:
  6994. m.ResetPhone()
  6995. return nil
  6996. case batchmsg.FieldTemplateName:
  6997. m.ResetTemplateName()
  6998. return nil
  6999. case batchmsg.FieldTemplateCode:
  7000. m.ResetTemplateCode()
  7001. return nil
  7002. case batchmsg.FieldLang:
  7003. m.ResetLang()
  7004. return nil
  7005. }
  7006. return fmt.Errorf("unknown BatchMsg field %s", name)
  7007. }
  7008. // AddedEdges returns all edge names that were set/added in this mutation.
  7009. func (m *BatchMsgMutation) AddedEdges() []string {
  7010. edges := make([]string, 0, 0)
  7011. return edges
  7012. }
  7013. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7014. // name in this mutation.
  7015. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  7016. return nil
  7017. }
  7018. // RemovedEdges returns all edge names that were removed in this mutation.
  7019. func (m *BatchMsgMutation) RemovedEdges() []string {
  7020. edges := make([]string, 0, 0)
  7021. return edges
  7022. }
  7023. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7024. // the given name in this mutation.
  7025. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  7026. return nil
  7027. }
  7028. // ClearedEdges returns all edge names that were cleared in this mutation.
  7029. func (m *BatchMsgMutation) ClearedEdges() []string {
  7030. edges := make([]string, 0, 0)
  7031. return edges
  7032. }
  7033. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7034. // was cleared in this mutation.
  7035. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  7036. return false
  7037. }
  7038. // ClearEdge clears the value of the edge with the given name. It returns an error
  7039. // if that edge is not defined in the schema.
  7040. func (m *BatchMsgMutation) ClearEdge(name string) error {
  7041. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  7042. }
  7043. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7044. // It returns an error if the edge is not defined in the schema.
  7045. func (m *BatchMsgMutation) ResetEdge(name string) error {
  7046. return fmt.Errorf("unknown BatchMsg edge %s", name)
  7047. }
  7048. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  7049. type CategoryMutation struct {
  7050. config
  7051. op Op
  7052. typ string
  7053. id *uint64
  7054. created_at *time.Time
  7055. updated_at *time.Time
  7056. deleted_at *time.Time
  7057. name *string
  7058. organization_id *uint64
  7059. addorganization_id *int64
  7060. clearedFields map[string]struct{}
  7061. done bool
  7062. oldValue func(context.Context) (*Category, error)
  7063. predicates []predicate.Category
  7064. }
  7065. var _ ent.Mutation = (*CategoryMutation)(nil)
  7066. // categoryOption allows management of the mutation configuration using functional options.
  7067. type categoryOption func(*CategoryMutation)
  7068. // newCategoryMutation creates new mutation for the Category entity.
  7069. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  7070. m := &CategoryMutation{
  7071. config: c,
  7072. op: op,
  7073. typ: TypeCategory,
  7074. clearedFields: make(map[string]struct{}),
  7075. }
  7076. for _, opt := range opts {
  7077. opt(m)
  7078. }
  7079. return m
  7080. }
  7081. // withCategoryID sets the ID field of the mutation.
  7082. func withCategoryID(id uint64) categoryOption {
  7083. return func(m *CategoryMutation) {
  7084. var (
  7085. err error
  7086. once sync.Once
  7087. value *Category
  7088. )
  7089. m.oldValue = func(ctx context.Context) (*Category, error) {
  7090. once.Do(func() {
  7091. if m.done {
  7092. err = errors.New("querying old values post mutation is not allowed")
  7093. } else {
  7094. value, err = m.Client().Category.Get(ctx, id)
  7095. }
  7096. })
  7097. return value, err
  7098. }
  7099. m.id = &id
  7100. }
  7101. }
  7102. // withCategory sets the old Category of the mutation.
  7103. func withCategory(node *Category) categoryOption {
  7104. return func(m *CategoryMutation) {
  7105. m.oldValue = func(context.Context) (*Category, error) {
  7106. return node, nil
  7107. }
  7108. m.id = &node.ID
  7109. }
  7110. }
  7111. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7112. // executed in a transaction (ent.Tx), a transactional client is returned.
  7113. func (m CategoryMutation) Client() *Client {
  7114. client := &Client{config: m.config}
  7115. client.init()
  7116. return client
  7117. }
  7118. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7119. // it returns an error otherwise.
  7120. func (m CategoryMutation) Tx() (*Tx, error) {
  7121. if _, ok := m.driver.(*txDriver); !ok {
  7122. return nil, errors.New("ent: mutation is not running in a transaction")
  7123. }
  7124. tx := &Tx{config: m.config}
  7125. tx.init()
  7126. return tx, nil
  7127. }
  7128. // SetID sets the value of the id field. Note that this
  7129. // operation is only accepted on creation of Category entities.
  7130. func (m *CategoryMutation) SetID(id uint64) {
  7131. m.id = &id
  7132. }
  7133. // ID returns the ID value in the mutation. Note that the ID is only available
  7134. // if it was provided to the builder or after it was returned from the database.
  7135. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  7136. if m.id == nil {
  7137. return
  7138. }
  7139. return *m.id, true
  7140. }
  7141. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7142. // That means, if the mutation is applied within a transaction with an isolation level such
  7143. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7144. // or updated by the mutation.
  7145. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  7146. switch {
  7147. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7148. id, exists := m.ID()
  7149. if exists {
  7150. return []uint64{id}, nil
  7151. }
  7152. fallthrough
  7153. case m.op.Is(OpUpdate | OpDelete):
  7154. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  7155. default:
  7156. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7157. }
  7158. }
  7159. // SetCreatedAt sets the "created_at" field.
  7160. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  7161. m.created_at = &t
  7162. }
  7163. // CreatedAt returns the value of the "created_at" field in the mutation.
  7164. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  7165. v := m.created_at
  7166. if v == nil {
  7167. return
  7168. }
  7169. return *v, true
  7170. }
  7171. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  7172. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7174. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7175. if !m.op.Is(OpUpdateOne) {
  7176. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7177. }
  7178. if m.id == nil || m.oldValue == nil {
  7179. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7180. }
  7181. oldValue, err := m.oldValue(ctx)
  7182. if err != nil {
  7183. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7184. }
  7185. return oldValue.CreatedAt, nil
  7186. }
  7187. // ResetCreatedAt resets all changes to the "created_at" field.
  7188. func (m *CategoryMutation) ResetCreatedAt() {
  7189. m.created_at = nil
  7190. }
  7191. // SetUpdatedAt sets the "updated_at" field.
  7192. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  7193. m.updated_at = &t
  7194. }
  7195. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7196. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  7197. v := m.updated_at
  7198. if v == nil {
  7199. return
  7200. }
  7201. return *v, true
  7202. }
  7203. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  7204. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7206. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7207. if !m.op.Is(OpUpdateOne) {
  7208. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7209. }
  7210. if m.id == nil || m.oldValue == nil {
  7211. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7212. }
  7213. oldValue, err := m.oldValue(ctx)
  7214. if err != nil {
  7215. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7216. }
  7217. return oldValue.UpdatedAt, nil
  7218. }
  7219. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7220. func (m *CategoryMutation) ResetUpdatedAt() {
  7221. m.updated_at = nil
  7222. }
  7223. // SetDeletedAt sets the "deleted_at" field.
  7224. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  7225. m.deleted_at = &t
  7226. }
  7227. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7228. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  7229. v := m.deleted_at
  7230. if v == nil {
  7231. return
  7232. }
  7233. return *v, true
  7234. }
  7235. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  7236. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7238. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7239. if !m.op.Is(OpUpdateOne) {
  7240. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7241. }
  7242. if m.id == nil || m.oldValue == nil {
  7243. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7244. }
  7245. oldValue, err := m.oldValue(ctx)
  7246. if err != nil {
  7247. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7248. }
  7249. return oldValue.DeletedAt, nil
  7250. }
  7251. // ClearDeletedAt clears the value of the "deleted_at" field.
  7252. func (m *CategoryMutation) ClearDeletedAt() {
  7253. m.deleted_at = nil
  7254. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  7255. }
  7256. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7257. func (m *CategoryMutation) DeletedAtCleared() bool {
  7258. _, ok := m.clearedFields[category.FieldDeletedAt]
  7259. return ok
  7260. }
  7261. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7262. func (m *CategoryMutation) ResetDeletedAt() {
  7263. m.deleted_at = nil
  7264. delete(m.clearedFields, category.FieldDeletedAt)
  7265. }
  7266. // SetName sets the "name" field.
  7267. func (m *CategoryMutation) SetName(s string) {
  7268. m.name = &s
  7269. }
  7270. // Name returns the value of the "name" field in the mutation.
  7271. func (m *CategoryMutation) Name() (r string, exists bool) {
  7272. v := m.name
  7273. if v == nil {
  7274. return
  7275. }
  7276. return *v, true
  7277. }
  7278. // OldName returns the old "name" field's value of the Category entity.
  7279. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7281. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  7282. if !m.op.Is(OpUpdateOne) {
  7283. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7284. }
  7285. if m.id == nil || m.oldValue == nil {
  7286. return v, errors.New("OldName requires an ID field in the mutation")
  7287. }
  7288. oldValue, err := m.oldValue(ctx)
  7289. if err != nil {
  7290. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7291. }
  7292. return oldValue.Name, nil
  7293. }
  7294. // ResetName resets all changes to the "name" field.
  7295. func (m *CategoryMutation) ResetName() {
  7296. m.name = nil
  7297. }
  7298. // SetOrganizationID sets the "organization_id" field.
  7299. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  7300. m.organization_id = &u
  7301. m.addorganization_id = nil
  7302. }
  7303. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7304. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  7305. v := m.organization_id
  7306. if v == nil {
  7307. return
  7308. }
  7309. return *v, true
  7310. }
  7311. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  7312. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  7313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7314. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7315. if !m.op.Is(OpUpdateOne) {
  7316. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7317. }
  7318. if m.id == nil || m.oldValue == nil {
  7319. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7320. }
  7321. oldValue, err := m.oldValue(ctx)
  7322. if err != nil {
  7323. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7324. }
  7325. return oldValue.OrganizationID, nil
  7326. }
  7327. // AddOrganizationID adds u to the "organization_id" field.
  7328. func (m *CategoryMutation) AddOrganizationID(u int64) {
  7329. if m.addorganization_id != nil {
  7330. *m.addorganization_id += u
  7331. } else {
  7332. m.addorganization_id = &u
  7333. }
  7334. }
  7335. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7336. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  7337. v := m.addorganization_id
  7338. if v == nil {
  7339. return
  7340. }
  7341. return *v, true
  7342. }
  7343. // ResetOrganizationID resets all changes to the "organization_id" field.
  7344. func (m *CategoryMutation) ResetOrganizationID() {
  7345. m.organization_id = nil
  7346. m.addorganization_id = nil
  7347. }
  7348. // Where appends a list predicates to the CategoryMutation builder.
  7349. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  7350. m.predicates = append(m.predicates, ps...)
  7351. }
  7352. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  7353. // users can use type-assertion to append predicates that do not depend on any generated package.
  7354. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  7355. p := make([]predicate.Category, len(ps))
  7356. for i := range ps {
  7357. p[i] = ps[i]
  7358. }
  7359. m.Where(p...)
  7360. }
  7361. // Op returns the operation name.
  7362. func (m *CategoryMutation) Op() Op {
  7363. return m.op
  7364. }
  7365. // SetOp allows setting the mutation operation.
  7366. func (m *CategoryMutation) SetOp(op Op) {
  7367. m.op = op
  7368. }
  7369. // Type returns the node type of this mutation (Category).
  7370. func (m *CategoryMutation) Type() string {
  7371. return m.typ
  7372. }
  7373. // Fields returns all fields that were changed during this mutation. Note that in
  7374. // order to get all numeric fields that were incremented/decremented, call
  7375. // AddedFields().
  7376. func (m *CategoryMutation) Fields() []string {
  7377. fields := make([]string, 0, 5)
  7378. if m.created_at != nil {
  7379. fields = append(fields, category.FieldCreatedAt)
  7380. }
  7381. if m.updated_at != nil {
  7382. fields = append(fields, category.FieldUpdatedAt)
  7383. }
  7384. if m.deleted_at != nil {
  7385. fields = append(fields, category.FieldDeletedAt)
  7386. }
  7387. if m.name != nil {
  7388. fields = append(fields, category.FieldName)
  7389. }
  7390. if m.organization_id != nil {
  7391. fields = append(fields, category.FieldOrganizationID)
  7392. }
  7393. return fields
  7394. }
  7395. // Field returns the value of a field with the given name. The second boolean
  7396. // return value indicates that this field was not set, or was not defined in the
  7397. // schema.
  7398. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  7399. switch name {
  7400. case category.FieldCreatedAt:
  7401. return m.CreatedAt()
  7402. case category.FieldUpdatedAt:
  7403. return m.UpdatedAt()
  7404. case category.FieldDeletedAt:
  7405. return m.DeletedAt()
  7406. case category.FieldName:
  7407. return m.Name()
  7408. case category.FieldOrganizationID:
  7409. return m.OrganizationID()
  7410. }
  7411. return nil, false
  7412. }
  7413. // OldField returns the old value of the field from the database. An error is
  7414. // returned if the mutation operation is not UpdateOne, or the query to the
  7415. // database failed.
  7416. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7417. switch name {
  7418. case category.FieldCreatedAt:
  7419. return m.OldCreatedAt(ctx)
  7420. case category.FieldUpdatedAt:
  7421. return m.OldUpdatedAt(ctx)
  7422. case category.FieldDeletedAt:
  7423. return m.OldDeletedAt(ctx)
  7424. case category.FieldName:
  7425. return m.OldName(ctx)
  7426. case category.FieldOrganizationID:
  7427. return m.OldOrganizationID(ctx)
  7428. }
  7429. return nil, fmt.Errorf("unknown Category field %s", name)
  7430. }
  7431. // SetField sets the value of a field with the given name. It returns an error if
  7432. // the field is not defined in the schema, or if the type mismatched the field
  7433. // type.
  7434. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  7435. switch name {
  7436. case category.FieldCreatedAt:
  7437. v, ok := value.(time.Time)
  7438. if !ok {
  7439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7440. }
  7441. m.SetCreatedAt(v)
  7442. return nil
  7443. case category.FieldUpdatedAt:
  7444. v, ok := value.(time.Time)
  7445. if !ok {
  7446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7447. }
  7448. m.SetUpdatedAt(v)
  7449. return nil
  7450. case category.FieldDeletedAt:
  7451. v, ok := value.(time.Time)
  7452. if !ok {
  7453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7454. }
  7455. m.SetDeletedAt(v)
  7456. return nil
  7457. case category.FieldName:
  7458. v, ok := value.(string)
  7459. if !ok {
  7460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7461. }
  7462. m.SetName(v)
  7463. return nil
  7464. case category.FieldOrganizationID:
  7465. v, ok := value.(uint64)
  7466. if !ok {
  7467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7468. }
  7469. m.SetOrganizationID(v)
  7470. return nil
  7471. }
  7472. return fmt.Errorf("unknown Category field %s", name)
  7473. }
  7474. // AddedFields returns all numeric fields that were incremented/decremented during
  7475. // this mutation.
  7476. func (m *CategoryMutation) AddedFields() []string {
  7477. var fields []string
  7478. if m.addorganization_id != nil {
  7479. fields = append(fields, category.FieldOrganizationID)
  7480. }
  7481. return fields
  7482. }
  7483. // AddedField returns the numeric value that was incremented/decremented on a field
  7484. // with the given name. The second boolean return value indicates that this field
  7485. // was not set, or was not defined in the schema.
  7486. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  7487. switch name {
  7488. case category.FieldOrganizationID:
  7489. return m.AddedOrganizationID()
  7490. }
  7491. return nil, false
  7492. }
  7493. // AddField adds the value to the field with the given name. It returns an error if
  7494. // the field is not defined in the schema, or if the type mismatched the field
  7495. // type.
  7496. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  7497. switch name {
  7498. case category.FieldOrganizationID:
  7499. v, ok := value.(int64)
  7500. if !ok {
  7501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7502. }
  7503. m.AddOrganizationID(v)
  7504. return nil
  7505. }
  7506. return fmt.Errorf("unknown Category numeric field %s", name)
  7507. }
  7508. // ClearedFields returns all nullable fields that were cleared during this
  7509. // mutation.
  7510. func (m *CategoryMutation) ClearedFields() []string {
  7511. var fields []string
  7512. if m.FieldCleared(category.FieldDeletedAt) {
  7513. fields = append(fields, category.FieldDeletedAt)
  7514. }
  7515. return fields
  7516. }
  7517. // FieldCleared returns a boolean indicating if a field with the given name was
  7518. // cleared in this mutation.
  7519. func (m *CategoryMutation) FieldCleared(name string) bool {
  7520. _, ok := m.clearedFields[name]
  7521. return ok
  7522. }
  7523. // ClearField clears the value of the field with the given name. It returns an
  7524. // error if the field is not defined in the schema.
  7525. func (m *CategoryMutation) ClearField(name string) error {
  7526. switch name {
  7527. case category.FieldDeletedAt:
  7528. m.ClearDeletedAt()
  7529. return nil
  7530. }
  7531. return fmt.Errorf("unknown Category nullable field %s", name)
  7532. }
  7533. // ResetField resets all changes in the mutation for the field with the given name.
  7534. // It returns an error if the field is not defined in the schema.
  7535. func (m *CategoryMutation) ResetField(name string) error {
  7536. switch name {
  7537. case category.FieldCreatedAt:
  7538. m.ResetCreatedAt()
  7539. return nil
  7540. case category.FieldUpdatedAt:
  7541. m.ResetUpdatedAt()
  7542. return nil
  7543. case category.FieldDeletedAt:
  7544. m.ResetDeletedAt()
  7545. return nil
  7546. case category.FieldName:
  7547. m.ResetName()
  7548. return nil
  7549. case category.FieldOrganizationID:
  7550. m.ResetOrganizationID()
  7551. return nil
  7552. }
  7553. return fmt.Errorf("unknown Category field %s", name)
  7554. }
  7555. // AddedEdges returns all edge names that were set/added in this mutation.
  7556. func (m *CategoryMutation) AddedEdges() []string {
  7557. edges := make([]string, 0, 0)
  7558. return edges
  7559. }
  7560. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7561. // name in this mutation.
  7562. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  7563. return nil
  7564. }
  7565. // RemovedEdges returns all edge names that were removed in this mutation.
  7566. func (m *CategoryMutation) RemovedEdges() []string {
  7567. edges := make([]string, 0, 0)
  7568. return edges
  7569. }
  7570. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7571. // the given name in this mutation.
  7572. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  7573. return nil
  7574. }
  7575. // ClearedEdges returns all edge names that were cleared in this mutation.
  7576. func (m *CategoryMutation) ClearedEdges() []string {
  7577. edges := make([]string, 0, 0)
  7578. return edges
  7579. }
  7580. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7581. // was cleared in this mutation.
  7582. func (m *CategoryMutation) EdgeCleared(name string) bool {
  7583. return false
  7584. }
  7585. // ClearEdge clears the value of the edge with the given name. It returns an error
  7586. // if that edge is not defined in the schema.
  7587. func (m *CategoryMutation) ClearEdge(name string) error {
  7588. return fmt.Errorf("unknown Category unique edge %s", name)
  7589. }
  7590. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7591. // It returns an error if the edge is not defined in the schema.
  7592. func (m *CategoryMutation) ResetEdge(name string) error {
  7593. return fmt.Errorf("unknown Category edge %s", name)
  7594. }
  7595. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  7596. type ChatRecordsMutation struct {
  7597. config
  7598. op Op
  7599. typ string
  7600. id *uint64
  7601. created_at *time.Time
  7602. updated_at *time.Time
  7603. deleted_at *time.Time
  7604. content *string
  7605. content_type *uint8
  7606. addcontent_type *int8
  7607. session_id *uint64
  7608. addsession_id *int64
  7609. user_id *uint64
  7610. adduser_id *int64
  7611. bot_id *uint64
  7612. addbot_id *int64
  7613. bot_type *uint8
  7614. addbot_type *int8
  7615. clearedFields map[string]struct{}
  7616. done bool
  7617. oldValue func(context.Context) (*ChatRecords, error)
  7618. predicates []predicate.ChatRecords
  7619. }
  7620. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  7621. // chatrecordsOption allows management of the mutation configuration using functional options.
  7622. type chatrecordsOption func(*ChatRecordsMutation)
  7623. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  7624. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  7625. m := &ChatRecordsMutation{
  7626. config: c,
  7627. op: op,
  7628. typ: TypeChatRecords,
  7629. clearedFields: make(map[string]struct{}),
  7630. }
  7631. for _, opt := range opts {
  7632. opt(m)
  7633. }
  7634. return m
  7635. }
  7636. // withChatRecordsID sets the ID field of the mutation.
  7637. func withChatRecordsID(id uint64) chatrecordsOption {
  7638. return func(m *ChatRecordsMutation) {
  7639. var (
  7640. err error
  7641. once sync.Once
  7642. value *ChatRecords
  7643. )
  7644. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  7645. once.Do(func() {
  7646. if m.done {
  7647. err = errors.New("querying old values post mutation is not allowed")
  7648. } else {
  7649. value, err = m.Client().ChatRecords.Get(ctx, id)
  7650. }
  7651. })
  7652. return value, err
  7653. }
  7654. m.id = &id
  7655. }
  7656. }
  7657. // withChatRecords sets the old ChatRecords of the mutation.
  7658. func withChatRecords(node *ChatRecords) chatrecordsOption {
  7659. return func(m *ChatRecordsMutation) {
  7660. m.oldValue = func(context.Context) (*ChatRecords, error) {
  7661. return node, nil
  7662. }
  7663. m.id = &node.ID
  7664. }
  7665. }
  7666. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7667. // executed in a transaction (ent.Tx), a transactional client is returned.
  7668. func (m ChatRecordsMutation) Client() *Client {
  7669. client := &Client{config: m.config}
  7670. client.init()
  7671. return client
  7672. }
  7673. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7674. // it returns an error otherwise.
  7675. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  7676. if _, ok := m.driver.(*txDriver); !ok {
  7677. return nil, errors.New("ent: mutation is not running in a transaction")
  7678. }
  7679. tx := &Tx{config: m.config}
  7680. tx.init()
  7681. return tx, nil
  7682. }
  7683. // SetID sets the value of the id field. Note that this
  7684. // operation is only accepted on creation of ChatRecords entities.
  7685. func (m *ChatRecordsMutation) SetID(id uint64) {
  7686. m.id = &id
  7687. }
  7688. // ID returns the ID value in the mutation. Note that the ID is only available
  7689. // if it was provided to the builder or after it was returned from the database.
  7690. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  7691. if m.id == nil {
  7692. return
  7693. }
  7694. return *m.id, true
  7695. }
  7696. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7697. // That means, if the mutation is applied within a transaction with an isolation level such
  7698. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7699. // or updated by the mutation.
  7700. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  7701. switch {
  7702. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7703. id, exists := m.ID()
  7704. if exists {
  7705. return []uint64{id}, nil
  7706. }
  7707. fallthrough
  7708. case m.op.Is(OpUpdate | OpDelete):
  7709. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  7710. default:
  7711. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7712. }
  7713. }
  7714. // SetCreatedAt sets the "created_at" field.
  7715. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  7716. m.created_at = &t
  7717. }
  7718. // CreatedAt returns the value of the "created_at" field in the mutation.
  7719. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  7720. v := m.created_at
  7721. if v == nil {
  7722. return
  7723. }
  7724. return *v, true
  7725. }
  7726. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  7727. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7729. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7730. if !m.op.Is(OpUpdateOne) {
  7731. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7732. }
  7733. if m.id == nil || m.oldValue == nil {
  7734. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7735. }
  7736. oldValue, err := m.oldValue(ctx)
  7737. if err != nil {
  7738. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7739. }
  7740. return oldValue.CreatedAt, nil
  7741. }
  7742. // ResetCreatedAt resets all changes to the "created_at" field.
  7743. func (m *ChatRecordsMutation) ResetCreatedAt() {
  7744. m.created_at = nil
  7745. }
  7746. // SetUpdatedAt sets the "updated_at" field.
  7747. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  7748. m.updated_at = &t
  7749. }
  7750. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7751. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  7752. v := m.updated_at
  7753. if v == nil {
  7754. return
  7755. }
  7756. return *v, true
  7757. }
  7758. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  7759. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7761. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7762. if !m.op.Is(OpUpdateOne) {
  7763. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7764. }
  7765. if m.id == nil || m.oldValue == nil {
  7766. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7767. }
  7768. oldValue, err := m.oldValue(ctx)
  7769. if err != nil {
  7770. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7771. }
  7772. return oldValue.UpdatedAt, nil
  7773. }
  7774. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7775. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  7776. m.updated_at = nil
  7777. }
  7778. // SetDeletedAt sets the "deleted_at" field.
  7779. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  7780. m.deleted_at = &t
  7781. }
  7782. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7783. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  7784. v := m.deleted_at
  7785. if v == nil {
  7786. return
  7787. }
  7788. return *v, true
  7789. }
  7790. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  7791. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7793. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7794. if !m.op.Is(OpUpdateOne) {
  7795. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7796. }
  7797. if m.id == nil || m.oldValue == nil {
  7798. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7799. }
  7800. oldValue, err := m.oldValue(ctx)
  7801. if err != nil {
  7802. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7803. }
  7804. return oldValue.DeletedAt, nil
  7805. }
  7806. // ClearDeletedAt clears the value of the "deleted_at" field.
  7807. func (m *ChatRecordsMutation) ClearDeletedAt() {
  7808. m.deleted_at = nil
  7809. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  7810. }
  7811. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7812. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  7813. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  7814. return ok
  7815. }
  7816. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7817. func (m *ChatRecordsMutation) ResetDeletedAt() {
  7818. m.deleted_at = nil
  7819. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  7820. }
  7821. // SetContent sets the "content" field.
  7822. func (m *ChatRecordsMutation) SetContent(s string) {
  7823. m.content = &s
  7824. }
  7825. // Content returns the value of the "content" field in the mutation.
  7826. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  7827. v := m.content
  7828. if v == nil {
  7829. return
  7830. }
  7831. return *v, true
  7832. }
  7833. // OldContent returns the old "content" field's value of the ChatRecords entity.
  7834. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7836. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  7837. if !m.op.Is(OpUpdateOne) {
  7838. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  7839. }
  7840. if m.id == nil || m.oldValue == nil {
  7841. return v, errors.New("OldContent requires an ID field in the mutation")
  7842. }
  7843. oldValue, err := m.oldValue(ctx)
  7844. if err != nil {
  7845. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  7846. }
  7847. return oldValue.Content, nil
  7848. }
  7849. // ResetContent resets all changes to the "content" field.
  7850. func (m *ChatRecordsMutation) ResetContent() {
  7851. m.content = nil
  7852. }
  7853. // SetContentType sets the "content_type" field.
  7854. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  7855. m.content_type = &u
  7856. m.addcontent_type = nil
  7857. }
  7858. // ContentType returns the value of the "content_type" field in the mutation.
  7859. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  7860. v := m.content_type
  7861. if v == nil {
  7862. return
  7863. }
  7864. return *v, true
  7865. }
  7866. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  7867. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7869. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  7870. if !m.op.Is(OpUpdateOne) {
  7871. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  7872. }
  7873. if m.id == nil || m.oldValue == nil {
  7874. return v, errors.New("OldContentType requires an ID field in the mutation")
  7875. }
  7876. oldValue, err := m.oldValue(ctx)
  7877. if err != nil {
  7878. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  7879. }
  7880. return oldValue.ContentType, nil
  7881. }
  7882. // AddContentType adds u to the "content_type" field.
  7883. func (m *ChatRecordsMutation) AddContentType(u int8) {
  7884. if m.addcontent_type != nil {
  7885. *m.addcontent_type += u
  7886. } else {
  7887. m.addcontent_type = &u
  7888. }
  7889. }
  7890. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  7891. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  7892. v := m.addcontent_type
  7893. if v == nil {
  7894. return
  7895. }
  7896. return *v, true
  7897. }
  7898. // ResetContentType resets all changes to the "content_type" field.
  7899. func (m *ChatRecordsMutation) ResetContentType() {
  7900. m.content_type = nil
  7901. m.addcontent_type = nil
  7902. }
  7903. // SetSessionID sets the "session_id" field.
  7904. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  7905. m.session_id = &u
  7906. m.addsession_id = nil
  7907. }
  7908. // SessionID returns the value of the "session_id" field in the mutation.
  7909. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  7910. v := m.session_id
  7911. if v == nil {
  7912. return
  7913. }
  7914. return *v, true
  7915. }
  7916. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  7917. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7919. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  7920. if !m.op.Is(OpUpdateOne) {
  7921. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  7922. }
  7923. if m.id == nil || m.oldValue == nil {
  7924. return v, errors.New("OldSessionID requires an ID field in the mutation")
  7925. }
  7926. oldValue, err := m.oldValue(ctx)
  7927. if err != nil {
  7928. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  7929. }
  7930. return oldValue.SessionID, nil
  7931. }
  7932. // AddSessionID adds u to the "session_id" field.
  7933. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  7934. if m.addsession_id != nil {
  7935. *m.addsession_id += u
  7936. } else {
  7937. m.addsession_id = &u
  7938. }
  7939. }
  7940. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  7941. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  7942. v := m.addsession_id
  7943. if v == nil {
  7944. return
  7945. }
  7946. return *v, true
  7947. }
  7948. // ResetSessionID resets all changes to the "session_id" field.
  7949. func (m *ChatRecordsMutation) ResetSessionID() {
  7950. m.session_id = nil
  7951. m.addsession_id = nil
  7952. }
  7953. // SetUserID sets the "user_id" field.
  7954. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  7955. m.user_id = &u
  7956. m.adduser_id = nil
  7957. }
  7958. // UserID returns the value of the "user_id" field in the mutation.
  7959. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  7960. v := m.user_id
  7961. if v == nil {
  7962. return
  7963. }
  7964. return *v, true
  7965. }
  7966. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  7967. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  7968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7969. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7970. if !m.op.Is(OpUpdateOne) {
  7971. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7972. }
  7973. if m.id == nil || m.oldValue == nil {
  7974. return v, errors.New("OldUserID requires an ID field in the mutation")
  7975. }
  7976. oldValue, err := m.oldValue(ctx)
  7977. if err != nil {
  7978. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7979. }
  7980. return oldValue.UserID, nil
  7981. }
  7982. // AddUserID adds u to the "user_id" field.
  7983. func (m *ChatRecordsMutation) AddUserID(u int64) {
  7984. if m.adduser_id != nil {
  7985. *m.adduser_id += u
  7986. } else {
  7987. m.adduser_id = &u
  7988. }
  7989. }
  7990. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7991. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  7992. v := m.adduser_id
  7993. if v == nil {
  7994. return
  7995. }
  7996. return *v, true
  7997. }
  7998. // ResetUserID resets all changes to the "user_id" field.
  7999. func (m *ChatRecordsMutation) ResetUserID() {
  8000. m.user_id = nil
  8001. m.adduser_id = nil
  8002. }
  8003. // SetBotID sets the "bot_id" field.
  8004. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  8005. m.bot_id = &u
  8006. m.addbot_id = nil
  8007. }
  8008. // BotID returns the value of the "bot_id" field in the mutation.
  8009. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  8010. v := m.bot_id
  8011. if v == nil {
  8012. return
  8013. }
  8014. return *v, true
  8015. }
  8016. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  8017. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8019. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8020. if !m.op.Is(OpUpdateOne) {
  8021. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8022. }
  8023. if m.id == nil || m.oldValue == nil {
  8024. return v, errors.New("OldBotID requires an ID field in the mutation")
  8025. }
  8026. oldValue, err := m.oldValue(ctx)
  8027. if err != nil {
  8028. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8029. }
  8030. return oldValue.BotID, nil
  8031. }
  8032. // AddBotID adds u to the "bot_id" field.
  8033. func (m *ChatRecordsMutation) AddBotID(u int64) {
  8034. if m.addbot_id != nil {
  8035. *m.addbot_id += u
  8036. } else {
  8037. m.addbot_id = &u
  8038. }
  8039. }
  8040. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8041. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  8042. v := m.addbot_id
  8043. if v == nil {
  8044. return
  8045. }
  8046. return *v, true
  8047. }
  8048. // ResetBotID resets all changes to the "bot_id" field.
  8049. func (m *ChatRecordsMutation) ResetBotID() {
  8050. m.bot_id = nil
  8051. m.addbot_id = nil
  8052. }
  8053. // SetBotType sets the "bot_type" field.
  8054. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  8055. m.bot_type = &u
  8056. m.addbot_type = nil
  8057. }
  8058. // BotType returns the value of the "bot_type" field in the mutation.
  8059. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  8060. v := m.bot_type
  8061. if v == nil {
  8062. return
  8063. }
  8064. return *v, true
  8065. }
  8066. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  8067. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  8068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8069. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8070. if !m.op.Is(OpUpdateOne) {
  8071. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8072. }
  8073. if m.id == nil || m.oldValue == nil {
  8074. return v, errors.New("OldBotType requires an ID field in the mutation")
  8075. }
  8076. oldValue, err := m.oldValue(ctx)
  8077. if err != nil {
  8078. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8079. }
  8080. return oldValue.BotType, nil
  8081. }
  8082. // AddBotType adds u to the "bot_type" field.
  8083. func (m *ChatRecordsMutation) AddBotType(u int8) {
  8084. if m.addbot_type != nil {
  8085. *m.addbot_type += u
  8086. } else {
  8087. m.addbot_type = &u
  8088. }
  8089. }
  8090. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8091. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  8092. v := m.addbot_type
  8093. if v == nil {
  8094. return
  8095. }
  8096. return *v, true
  8097. }
  8098. // ResetBotType resets all changes to the "bot_type" field.
  8099. func (m *ChatRecordsMutation) ResetBotType() {
  8100. m.bot_type = nil
  8101. m.addbot_type = nil
  8102. }
  8103. // Where appends a list predicates to the ChatRecordsMutation builder.
  8104. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  8105. m.predicates = append(m.predicates, ps...)
  8106. }
  8107. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  8108. // users can use type-assertion to append predicates that do not depend on any generated package.
  8109. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  8110. p := make([]predicate.ChatRecords, len(ps))
  8111. for i := range ps {
  8112. p[i] = ps[i]
  8113. }
  8114. m.Where(p...)
  8115. }
  8116. // Op returns the operation name.
  8117. func (m *ChatRecordsMutation) Op() Op {
  8118. return m.op
  8119. }
  8120. // SetOp allows setting the mutation operation.
  8121. func (m *ChatRecordsMutation) SetOp(op Op) {
  8122. m.op = op
  8123. }
  8124. // Type returns the node type of this mutation (ChatRecords).
  8125. func (m *ChatRecordsMutation) Type() string {
  8126. return m.typ
  8127. }
  8128. // Fields returns all fields that were changed during this mutation. Note that in
  8129. // order to get all numeric fields that were incremented/decremented, call
  8130. // AddedFields().
  8131. func (m *ChatRecordsMutation) Fields() []string {
  8132. fields := make([]string, 0, 9)
  8133. if m.created_at != nil {
  8134. fields = append(fields, chatrecords.FieldCreatedAt)
  8135. }
  8136. if m.updated_at != nil {
  8137. fields = append(fields, chatrecords.FieldUpdatedAt)
  8138. }
  8139. if m.deleted_at != nil {
  8140. fields = append(fields, chatrecords.FieldDeletedAt)
  8141. }
  8142. if m.content != nil {
  8143. fields = append(fields, chatrecords.FieldContent)
  8144. }
  8145. if m.content_type != nil {
  8146. fields = append(fields, chatrecords.FieldContentType)
  8147. }
  8148. if m.session_id != nil {
  8149. fields = append(fields, chatrecords.FieldSessionID)
  8150. }
  8151. if m.user_id != nil {
  8152. fields = append(fields, chatrecords.FieldUserID)
  8153. }
  8154. if m.bot_id != nil {
  8155. fields = append(fields, chatrecords.FieldBotID)
  8156. }
  8157. if m.bot_type != nil {
  8158. fields = append(fields, chatrecords.FieldBotType)
  8159. }
  8160. return fields
  8161. }
  8162. // Field returns the value of a field with the given name. The second boolean
  8163. // return value indicates that this field was not set, or was not defined in the
  8164. // schema.
  8165. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  8166. switch name {
  8167. case chatrecords.FieldCreatedAt:
  8168. return m.CreatedAt()
  8169. case chatrecords.FieldUpdatedAt:
  8170. return m.UpdatedAt()
  8171. case chatrecords.FieldDeletedAt:
  8172. return m.DeletedAt()
  8173. case chatrecords.FieldContent:
  8174. return m.Content()
  8175. case chatrecords.FieldContentType:
  8176. return m.ContentType()
  8177. case chatrecords.FieldSessionID:
  8178. return m.SessionID()
  8179. case chatrecords.FieldUserID:
  8180. return m.UserID()
  8181. case chatrecords.FieldBotID:
  8182. return m.BotID()
  8183. case chatrecords.FieldBotType:
  8184. return m.BotType()
  8185. }
  8186. return nil, false
  8187. }
  8188. // OldField returns the old value of the field from the database. An error is
  8189. // returned if the mutation operation is not UpdateOne, or the query to the
  8190. // database failed.
  8191. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8192. switch name {
  8193. case chatrecords.FieldCreatedAt:
  8194. return m.OldCreatedAt(ctx)
  8195. case chatrecords.FieldUpdatedAt:
  8196. return m.OldUpdatedAt(ctx)
  8197. case chatrecords.FieldDeletedAt:
  8198. return m.OldDeletedAt(ctx)
  8199. case chatrecords.FieldContent:
  8200. return m.OldContent(ctx)
  8201. case chatrecords.FieldContentType:
  8202. return m.OldContentType(ctx)
  8203. case chatrecords.FieldSessionID:
  8204. return m.OldSessionID(ctx)
  8205. case chatrecords.FieldUserID:
  8206. return m.OldUserID(ctx)
  8207. case chatrecords.FieldBotID:
  8208. return m.OldBotID(ctx)
  8209. case chatrecords.FieldBotType:
  8210. return m.OldBotType(ctx)
  8211. }
  8212. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  8213. }
  8214. // SetField sets the value of a field with the given name. It returns an error if
  8215. // the field is not defined in the schema, or if the type mismatched the field
  8216. // type.
  8217. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  8218. switch name {
  8219. case chatrecords.FieldCreatedAt:
  8220. v, ok := value.(time.Time)
  8221. if !ok {
  8222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8223. }
  8224. m.SetCreatedAt(v)
  8225. return nil
  8226. case chatrecords.FieldUpdatedAt:
  8227. v, ok := value.(time.Time)
  8228. if !ok {
  8229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8230. }
  8231. m.SetUpdatedAt(v)
  8232. return nil
  8233. case chatrecords.FieldDeletedAt:
  8234. v, ok := value.(time.Time)
  8235. if !ok {
  8236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8237. }
  8238. m.SetDeletedAt(v)
  8239. return nil
  8240. case chatrecords.FieldContent:
  8241. v, ok := value.(string)
  8242. if !ok {
  8243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8244. }
  8245. m.SetContent(v)
  8246. return nil
  8247. case chatrecords.FieldContentType:
  8248. v, ok := value.(uint8)
  8249. if !ok {
  8250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8251. }
  8252. m.SetContentType(v)
  8253. return nil
  8254. case chatrecords.FieldSessionID:
  8255. v, ok := value.(uint64)
  8256. if !ok {
  8257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8258. }
  8259. m.SetSessionID(v)
  8260. return nil
  8261. case chatrecords.FieldUserID:
  8262. v, ok := value.(uint64)
  8263. if !ok {
  8264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8265. }
  8266. m.SetUserID(v)
  8267. return nil
  8268. case chatrecords.FieldBotID:
  8269. v, ok := value.(uint64)
  8270. if !ok {
  8271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8272. }
  8273. m.SetBotID(v)
  8274. return nil
  8275. case chatrecords.FieldBotType:
  8276. v, ok := value.(uint8)
  8277. if !ok {
  8278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8279. }
  8280. m.SetBotType(v)
  8281. return nil
  8282. }
  8283. return fmt.Errorf("unknown ChatRecords field %s", name)
  8284. }
  8285. // AddedFields returns all numeric fields that were incremented/decremented during
  8286. // this mutation.
  8287. func (m *ChatRecordsMutation) AddedFields() []string {
  8288. var fields []string
  8289. if m.addcontent_type != nil {
  8290. fields = append(fields, chatrecords.FieldContentType)
  8291. }
  8292. if m.addsession_id != nil {
  8293. fields = append(fields, chatrecords.FieldSessionID)
  8294. }
  8295. if m.adduser_id != nil {
  8296. fields = append(fields, chatrecords.FieldUserID)
  8297. }
  8298. if m.addbot_id != nil {
  8299. fields = append(fields, chatrecords.FieldBotID)
  8300. }
  8301. if m.addbot_type != nil {
  8302. fields = append(fields, chatrecords.FieldBotType)
  8303. }
  8304. return fields
  8305. }
  8306. // AddedField returns the numeric value that was incremented/decremented on a field
  8307. // with the given name. The second boolean return value indicates that this field
  8308. // was not set, or was not defined in the schema.
  8309. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  8310. switch name {
  8311. case chatrecords.FieldContentType:
  8312. return m.AddedContentType()
  8313. case chatrecords.FieldSessionID:
  8314. return m.AddedSessionID()
  8315. case chatrecords.FieldUserID:
  8316. return m.AddedUserID()
  8317. case chatrecords.FieldBotID:
  8318. return m.AddedBotID()
  8319. case chatrecords.FieldBotType:
  8320. return m.AddedBotType()
  8321. }
  8322. return nil, false
  8323. }
  8324. // AddField adds the value to the field with the given name. It returns an error if
  8325. // the field is not defined in the schema, or if the type mismatched the field
  8326. // type.
  8327. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  8328. switch name {
  8329. case chatrecords.FieldContentType:
  8330. v, ok := value.(int8)
  8331. if !ok {
  8332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8333. }
  8334. m.AddContentType(v)
  8335. return nil
  8336. case chatrecords.FieldSessionID:
  8337. v, ok := value.(int64)
  8338. if !ok {
  8339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8340. }
  8341. m.AddSessionID(v)
  8342. return nil
  8343. case chatrecords.FieldUserID:
  8344. v, ok := value.(int64)
  8345. if !ok {
  8346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8347. }
  8348. m.AddUserID(v)
  8349. return nil
  8350. case chatrecords.FieldBotID:
  8351. v, ok := value.(int64)
  8352. if !ok {
  8353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8354. }
  8355. m.AddBotID(v)
  8356. return nil
  8357. case chatrecords.FieldBotType:
  8358. v, ok := value.(int8)
  8359. if !ok {
  8360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8361. }
  8362. m.AddBotType(v)
  8363. return nil
  8364. }
  8365. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  8366. }
  8367. // ClearedFields returns all nullable fields that were cleared during this
  8368. // mutation.
  8369. func (m *ChatRecordsMutation) ClearedFields() []string {
  8370. var fields []string
  8371. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  8372. fields = append(fields, chatrecords.FieldDeletedAt)
  8373. }
  8374. return fields
  8375. }
  8376. // FieldCleared returns a boolean indicating if a field with the given name was
  8377. // cleared in this mutation.
  8378. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  8379. _, ok := m.clearedFields[name]
  8380. return ok
  8381. }
  8382. // ClearField clears the value of the field with the given name. It returns an
  8383. // error if the field is not defined in the schema.
  8384. func (m *ChatRecordsMutation) ClearField(name string) error {
  8385. switch name {
  8386. case chatrecords.FieldDeletedAt:
  8387. m.ClearDeletedAt()
  8388. return nil
  8389. }
  8390. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  8391. }
  8392. // ResetField resets all changes in the mutation for the field with the given name.
  8393. // It returns an error if the field is not defined in the schema.
  8394. func (m *ChatRecordsMutation) ResetField(name string) error {
  8395. switch name {
  8396. case chatrecords.FieldCreatedAt:
  8397. m.ResetCreatedAt()
  8398. return nil
  8399. case chatrecords.FieldUpdatedAt:
  8400. m.ResetUpdatedAt()
  8401. return nil
  8402. case chatrecords.FieldDeletedAt:
  8403. m.ResetDeletedAt()
  8404. return nil
  8405. case chatrecords.FieldContent:
  8406. m.ResetContent()
  8407. return nil
  8408. case chatrecords.FieldContentType:
  8409. m.ResetContentType()
  8410. return nil
  8411. case chatrecords.FieldSessionID:
  8412. m.ResetSessionID()
  8413. return nil
  8414. case chatrecords.FieldUserID:
  8415. m.ResetUserID()
  8416. return nil
  8417. case chatrecords.FieldBotID:
  8418. m.ResetBotID()
  8419. return nil
  8420. case chatrecords.FieldBotType:
  8421. m.ResetBotType()
  8422. return nil
  8423. }
  8424. return fmt.Errorf("unknown ChatRecords field %s", name)
  8425. }
  8426. // AddedEdges returns all edge names that were set/added in this mutation.
  8427. func (m *ChatRecordsMutation) AddedEdges() []string {
  8428. edges := make([]string, 0, 0)
  8429. return edges
  8430. }
  8431. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8432. // name in this mutation.
  8433. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  8434. return nil
  8435. }
  8436. // RemovedEdges returns all edge names that were removed in this mutation.
  8437. func (m *ChatRecordsMutation) RemovedEdges() []string {
  8438. edges := make([]string, 0, 0)
  8439. return edges
  8440. }
  8441. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8442. // the given name in this mutation.
  8443. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  8444. return nil
  8445. }
  8446. // ClearedEdges returns all edge names that were cleared in this mutation.
  8447. func (m *ChatRecordsMutation) ClearedEdges() []string {
  8448. edges := make([]string, 0, 0)
  8449. return edges
  8450. }
  8451. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8452. // was cleared in this mutation.
  8453. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  8454. return false
  8455. }
  8456. // ClearEdge clears the value of the edge with the given name. It returns an error
  8457. // if that edge is not defined in the schema.
  8458. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  8459. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  8460. }
  8461. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8462. // It returns an error if the edge is not defined in the schema.
  8463. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  8464. return fmt.Errorf("unknown ChatRecords edge %s", name)
  8465. }
  8466. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  8467. type ChatSessionMutation struct {
  8468. config
  8469. op Op
  8470. typ string
  8471. id *uint64
  8472. created_at *time.Time
  8473. updated_at *time.Time
  8474. deleted_at *time.Time
  8475. name *string
  8476. user_id *uint64
  8477. adduser_id *int64
  8478. bot_id *uint64
  8479. addbot_id *int64
  8480. bot_type *uint8
  8481. addbot_type *int8
  8482. clearedFields map[string]struct{}
  8483. done bool
  8484. oldValue func(context.Context) (*ChatSession, error)
  8485. predicates []predicate.ChatSession
  8486. }
  8487. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  8488. // chatsessionOption allows management of the mutation configuration using functional options.
  8489. type chatsessionOption func(*ChatSessionMutation)
  8490. // newChatSessionMutation creates new mutation for the ChatSession entity.
  8491. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  8492. m := &ChatSessionMutation{
  8493. config: c,
  8494. op: op,
  8495. typ: TypeChatSession,
  8496. clearedFields: make(map[string]struct{}),
  8497. }
  8498. for _, opt := range opts {
  8499. opt(m)
  8500. }
  8501. return m
  8502. }
  8503. // withChatSessionID sets the ID field of the mutation.
  8504. func withChatSessionID(id uint64) chatsessionOption {
  8505. return func(m *ChatSessionMutation) {
  8506. var (
  8507. err error
  8508. once sync.Once
  8509. value *ChatSession
  8510. )
  8511. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  8512. once.Do(func() {
  8513. if m.done {
  8514. err = errors.New("querying old values post mutation is not allowed")
  8515. } else {
  8516. value, err = m.Client().ChatSession.Get(ctx, id)
  8517. }
  8518. })
  8519. return value, err
  8520. }
  8521. m.id = &id
  8522. }
  8523. }
  8524. // withChatSession sets the old ChatSession of the mutation.
  8525. func withChatSession(node *ChatSession) chatsessionOption {
  8526. return func(m *ChatSessionMutation) {
  8527. m.oldValue = func(context.Context) (*ChatSession, error) {
  8528. return node, nil
  8529. }
  8530. m.id = &node.ID
  8531. }
  8532. }
  8533. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8534. // executed in a transaction (ent.Tx), a transactional client is returned.
  8535. func (m ChatSessionMutation) Client() *Client {
  8536. client := &Client{config: m.config}
  8537. client.init()
  8538. return client
  8539. }
  8540. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8541. // it returns an error otherwise.
  8542. func (m ChatSessionMutation) Tx() (*Tx, error) {
  8543. if _, ok := m.driver.(*txDriver); !ok {
  8544. return nil, errors.New("ent: mutation is not running in a transaction")
  8545. }
  8546. tx := &Tx{config: m.config}
  8547. tx.init()
  8548. return tx, nil
  8549. }
  8550. // SetID sets the value of the id field. Note that this
  8551. // operation is only accepted on creation of ChatSession entities.
  8552. func (m *ChatSessionMutation) SetID(id uint64) {
  8553. m.id = &id
  8554. }
  8555. // ID returns the ID value in the mutation. Note that the ID is only available
  8556. // if it was provided to the builder or after it was returned from the database.
  8557. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  8558. if m.id == nil {
  8559. return
  8560. }
  8561. return *m.id, true
  8562. }
  8563. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8564. // That means, if the mutation is applied within a transaction with an isolation level such
  8565. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8566. // or updated by the mutation.
  8567. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  8568. switch {
  8569. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8570. id, exists := m.ID()
  8571. if exists {
  8572. return []uint64{id}, nil
  8573. }
  8574. fallthrough
  8575. case m.op.Is(OpUpdate | OpDelete):
  8576. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  8577. default:
  8578. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8579. }
  8580. }
  8581. // SetCreatedAt sets the "created_at" field.
  8582. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  8583. m.created_at = &t
  8584. }
  8585. // CreatedAt returns the value of the "created_at" field in the mutation.
  8586. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  8587. v := m.created_at
  8588. if v == nil {
  8589. return
  8590. }
  8591. return *v, true
  8592. }
  8593. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  8594. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8596. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8597. if !m.op.Is(OpUpdateOne) {
  8598. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8599. }
  8600. if m.id == nil || m.oldValue == nil {
  8601. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8602. }
  8603. oldValue, err := m.oldValue(ctx)
  8604. if err != nil {
  8605. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8606. }
  8607. return oldValue.CreatedAt, nil
  8608. }
  8609. // ResetCreatedAt resets all changes to the "created_at" field.
  8610. func (m *ChatSessionMutation) ResetCreatedAt() {
  8611. m.created_at = nil
  8612. }
  8613. // SetUpdatedAt sets the "updated_at" field.
  8614. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  8615. m.updated_at = &t
  8616. }
  8617. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8618. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  8619. v := m.updated_at
  8620. if v == nil {
  8621. return
  8622. }
  8623. return *v, true
  8624. }
  8625. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  8626. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8628. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8629. if !m.op.Is(OpUpdateOne) {
  8630. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8631. }
  8632. if m.id == nil || m.oldValue == nil {
  8633. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8634. }
  8635. oldValue, err := m.oldValue(ctx)
  8636. if err != nil {
  8637. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8638. }
  8639. return oldValue.UpdatedAt, nil
  8640. }
  8641. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8642. func (m *ChatSessionMutation) ResetUpdatedAt() {
  8643. m.updated_at = nil
  8644. }
  8645. // SetDeletedAt sets the "deleted_at" field.
  8646. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  8647. m.deleted_at = &t
  8648. }
  8649. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8650. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  8651. v := m.deleted_at
  8652. if v == nil {
  8653. return
  8654. }
  8655. return *v, true
  8656. }
  8657. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  8658. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8660. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8661. if !m.op.Is(OpUpdateOne) {
  8662. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8663. }
  8664. if m.id == nil || m.oldValue == nil {
  8665. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8666. }
  8667. oldValue, err := m.oldValue(ctx)
  8668. if err != nil {
  8669. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8670. }
  8671. return oldValue.DeletedAt, nil
  8672. }
  8673. // ClearDeletedAt clears the value of the "deleted_at" field.
  8674. func (m *ChatSessionMutation) ClearDeletedAt() {
  8675. m.deleted_at = nil
  8676. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  8677. }
  8678. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8679. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  8680. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  8681. return ok
  8682. }
  8683. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8684. func (m *ChatSessionMutation) ResetDeletedAt() {
  8685. m.deleted_at = nil
  8686. delete(m.clearedFields, chatsession.FieldDeletedAt)
  8687. }
  8688. // SetName sets the "name" field.
  8689. func (m *ChatSessionMutation) SetName(s string) {
  8690. m.name = &s
  8691. }
  8692. // Name returns the value of the "name" field in the mutation.
  8693. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  8694. v := m.name
  8695. if v == nil {
  8696. return
  8697. }
  8698. return *v, true
  8699. }
  8700. // OldName returns the old "name" field's value of the ChatSession entity.
  8701. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8703. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  8704. if !m.op.Is(OpUpdateOne) {
  8705. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8706. }
  8707. if m.id == nil || m.oldValue == nil {
  8708. return v, errors.New("OldName requires an ID field in the mutation")
  8709. }
  8710. oldValue, err := m.oldValue(ctx)
  8711. if err != nil {
  8712. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8713. }
  8714. return oldValue.Name, nil
  8715. }
  8716. // ResetName resets all changes to the "name" field.
  8717. func (m *ChatSessionMutation) ResetName() {
  8718. m.name = nil
  8719. }
  8720. // SetUserID sets the "user_id" field.
  8721. func (m *ChatSessionMutation) SetUserID(u uint64) {
  8722. m.user_id = &u
  8723. m.adduser_id = nil
  8724. }
  8725. // UserID returns the value of the "user_id" field in the mutation.
  8726. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  8727. v := m.user_id
  8728. if v == nil {
  8729. return
  8730. }
  8731. return *v, true
  8732. }
  8733. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  8734. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8736. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  8737. if !m.op.Is(OpUpdateOne) {
  8738. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  8739. }
  8740. if m.id == nil || m.oldValue == nil {
  8741. return v, errors.New("OldUserID requires an ID field in the mutation")
  8742. }
  8743. oldValue, err := m.oldValue(ctx)
  8744. if err != nil {
  8745. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  8746. }
  8747. return oldValue.UserID, nil
  8748. }
  8749. // AddUserID adds u to the "user_id" field.
  8750. func (m *ChatSessionMutation) AddUserID(u int64) {
  8751. if m.adduser_id != nil {
  8752. *m.adduser_id += u
  8753. } else {
  8754. m.adduser_id = &u
  8755. }
  8756. }
  8757. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  8758. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  8759. v := m.adduser_id
  8760. if v == nil {
  8761. return
  8762. }
  8763. return *v, true
  8764. }
  8765. // ResetUserID resets all changes to the "user_id" field.
  8766. func (m *ChatSessionMutation) ResetUserID() {
  8767. m.user_id = nil
  8768. m.adduser_id = nil
  8769. }
  8770. // SetBotID sets the "bot_id" field.
  8771. func (m *ChatSessionMutation) SetBotID(u uint64) {
  8772. m.bot_id = &u
  8773. m.addbot_id = nil
  8774. }
  8775. // BotID returns the value of the "bot_id" field in the mutation.
  8776. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  8777. v := m.bot_id
  8778. if v == nil {
  8779. return
  8780. }
  8781. return *v, true
  8782. }
  8783. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  8784. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8786. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  8787. if !m.op.Is(OpUpdateOne) {
  8788. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  8789. }
  8790. if m.id == nil || m.oldValue == nil {
  8791. return v, errors.New("OldBotID requires an ID field in the mutation")
  8792. }
  8793. oldValue, err := m.oldValue(ctx)
  8794. if err != nil {
  8795. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  8796. }
  8797. return oldValue.BotID, nil
  8798. }
  8799. // AddBotID adds u to the "bot_id" field.
  8800. func (m *ChatSessionMutation) AddBotID(u int64) {
  8801. if m.addbot_id != nil {
  8802. *m.addbot_id += u
  8803. } else {
  8804. m.addbot_id = &u
  8805. }
  8806. }
  8807. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  8808. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  8809. v := m.addbot_id
  8810. if v == nil {
  8811. return
  8812. }
  8813. return *v, true
  8814. }
  8815. // ResetBotID resets all changes to the "bot_id" field.
  8816. func (m *ChatSessionMutation) ResetBotID() {
  8817. m.bot_id = nil
  8818. m.addbot_id = nil
  8819. }
  8820. // SetBotType sets the "bot_type" field.
  8821. func (m *ChatSessionMutation) SetBotType(u uint8) {
  8822. m.bot_type = &u
  8823. m.addbot_type = nil
  8824. }
  8825. // BotType returns the value of the "bot_type" field in the mutation.
  8826. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  8827. v := m.bot_type
  8828. if v == nil {
  8829. return
  8830. }
  8831. return *v, true
  8832. }
  8833. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  8834. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  8835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8836. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  8837. if !m.op.Is(OpUpdateOne) {
  8838. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  8839. }
  8840. if m.id == nil || m.oldValue == nil {
  8841. return v, errors.New("OldBotType requires an ID field in the mutation")
  8842. }
  8843. oldValue, err := m.oldValue(ctx)
  8844. if err != nil {
  8845. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  8846. }
  8847. return oldValue.BotType, nil
  8848. }
  8849. // AddBotType adds u to the "bot_type" field.
  8850. func (m *ChatSessionMutation) AddBotType(u int8) {
  8851. if m.addbot_type != nil {
  8852. *m.addbot_type += u
  8853. } else {
  8854. m.addbot_type = &u
  8855. }
  8856. }
  8857. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  8858. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  8859. v := m.addbot_type
  8860. if v == nil {
  8861. return
  8862. }
  8863. return *v, true
  8864. }
  8865. // ResetBotType resets all changes to the "bot_type" field.
  8866. func (m *ChatSessionMutation) ResetBotType() {
  8867. m.bot_type = nil
  8868. m.addbot_type = nil
  8869. }
  8870. // Where appends a list predicates to the ChatSessionMutation builder.
  8871. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  8872. m.predicates = append(m.predicates, ps...)
  8873. }
  8874. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  8875. // users can use type-assertion to append predicates that do not depend on any generated package.
  8876. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  8877. p := make([]predicate.ChatSession, len(ps))
  8878. for i := range ps {
  8879. p[i] = ps[i]
  8880. }
  8881. m.Where(p...)
  8882. }
  8883. // Op returns the operation name.
  8884. func (m *ChatSessionMutation) Op() Op {
  8885. return m.op
  8886. }
  8887. // SetOp allows setting the mutation operation.
  8888. func (m *ChatSessionMutation) SetOp(op Op) {
  8889. m.op = op
  8890. }
  8891. // Type returns the node type of this mutation (ChatSession).
  8892. func (m *ChatSessionMutation) Type() string {
  8893. return m.typ
  8894. }
  8895. // Fields returns all fields that were changed during this mutation. Note that in
  8896. // order to get all numeric fields that were incremented/decremented, call
  8897. // AddedFields().
  8898. func (m *ChatSessionMutation) Fields() []string {
  8899. fields := make([]string, 0, 7)
  8900. if m.created_at != nil {
  8901. fields = append(fields, chatsession.FieldCreatedAt)
  8902. }
  8903. if m.updated_at != nil {
  8904. fields = append(fields, chatsession.FieldUpdatedAt)
  8905. }
  8906. if m.deleted_at != nil {
  8907. fields = append(fields, chatsession.FieldDeletedAt)
  8908. }
  8909. if m.name != nil {
  8910. fields = append(fields, chatsession.FieldName)
  8911. }
  8912. if m.user_id != nil {
  8913. fields = append(fields, chatsession.FieldUserID)
  8914. }
  8915. if m.bot_id != nil {
  8916. fields = append(fields, chatsession.FieldBotID)
  8917. }
  8918. if m.bot_type != nil {
  8919. fields = append(fields, chatsession.FieldBotType)
  8920. }
  8921. return fields
  8922. }
  8923. // Field returns the value of a field with the given name. The second boolean
  8924. // return value indicates that this field was not set, or was not defined in the
  8925. // schema.
  8926. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  8927. switch name {
  8928. case chatsession.FieldCreatedAt:
  8929. return m.CreatedAt()
  8930. case chatsession.FieldUpdatedAt:
  8931. return m.UpdatedAt()
  8932. case chatsession.FieldDeletedAt:
  8933. return m.DeletedAt()
  8934. case chatsession.FieldName:
  8935. return m.Name()
  8936. case chatsession.FieldUserID:
  8937. return m.UserID()
  8938. case chatsession.FieldBotID:
  8939. return m.BotID()
  8940. case chatsession.FieldBotType:
  8941. return m.BotType()
  8942. }
  8943. return nil, false
  8944. }
  8945. // OldField returns the old value of the field from the database. An error is
  8946. // returned if the mutation operation is not UpdateOne, or the query to the
  8947. // database failed.
  8948. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8949. switch name {
  8950. case chatsession.FieldCreatedAt:
  8951. return m.OldCreatedAt(ctx)
  8952. case chatsession.FieldUpdatedAt:
  8953. return m.OldUpdatedAt(ctx)
  8954. case chatsession.FieldDeletedAt:
  8955. return m.OldDeletedAt(ctx)
  8956. case chatsession.FieldName:
  8957. return m.OldName(ctx)
  8958. case chatsession.FieldUserID:
  8959. return m.OldUserID(ctx)
  8960. case chatsession.FieldBotID:
  8961. return m.OldBotID(ctx)
  8962. case chatsession.FieldBotType:
  8963. return m.OldBotType(ctx)
  8964. }
  8965. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  8966. }
  8967. // SetField sets the value of a field with the given name. It returns an error if
  8968. // the field is not defined in the schema, or if the type mismatched the field
  8969. // type.
  8970. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  8971. switch name {
  8972. case chatsession.FieldCreatedAt:
  8973. v, ok := value.(time.Time)
  8974. if !ok {
  8975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8976. }
  8977. m.SetCreatedAt(v)
  8978. return nil
  8979. case chatsession.FieldUpdatedAt:
  8980. v, ok := value.(time.Time)
  8981. if !ok {
  8982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8983. }
  8984. m.SetUpdatedAt(v)
  8985. return nil
  8986. case chatsession.FieldDeletedAt:
  8987. v, ok := value.(time.Time)
  8988. if !ok {
  8989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8990. }
  8991. m.SetDeletedAt(v)
  8992. return nil
  8993. case chatsession.FieldName:
  8994. v, ok := value.(string)
  8995. if !ok {
  8996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8997. }
  8998. m.SetName(v)
  8999. return nil
  9000. case chatsession.FieldUserID:
  9001. v, ok := value.(uint64)
  9002. if !ok {
  9003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9004. }
  9005. m.SetUserID(v)
  9006. return nil
  9007. case chatsession.FieldBotID:
  9008. v, ok := value.(uint64)
  9009. if !ok {
  9010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9011. }
  9012. m.SetBotID(v)
  9013. return nil
  9014. case chatsession.FieldBotType:
  9015. v, ok := value.(uint8)
  9016. if !ok {
  9017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9018. }
  9019. m.SetBotType(v)
  9020. return nil
  9021. }
  9022. return fmt.Errorf("unknown ChatSession field %s", name)
  9023. }
  9024. // AddedFields returns all numeric fields that were incremented/decremented during
  9025. // this mutation.
  9026. func (m *ChatSessionMutation) AddedFields() []string {
  9027. var fields []string
  9028. if m.adduser_id != nil {
  9029. fields = append(fields, chatsession.FieldUserID)
  9030. }
  9031. if m.addbot_id != nil {
  9032. fields = append(fields, chatsession.FieldBotID)
  9033. }
  9034. if m.addbot_type != nil {
  9035. fields = append(fields, chatsession.FieldBotType)
  9036. }
  9037. return fields
  9038. }
  9039. // AddedField returns the numeric value that was incremented/decremented on a field
  9040. // with the given name. The second boolean return value indicates that this field
  9041. // was not set, or was not defined in the schema.
  9042. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  9043. switch name {
  9044. case chatsession.FieldUserID:
  9045. return m.AddedUserID()
  9046. case chatsession.FieldBotID:
  9047. return m.AddedBotID()
  9048. case chatsession.FieldBotType:
  9049. return m.AddedBotType()
  9050. }
  9051. return nil, false
  9052. }
  9053. // AddField adds the value to the field with the given name. It returns an error if
  9054. // the field is not defined in the schema, or if the type mismatched the field
  9055. // type.
  9056. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  9057. switch name {
  9058. case chatsession.FieldUserID:
  9059. v, ok := value.(int64)
  9060. if !ok {
  9061. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9062. }
  9063. m.AddUserID(v)
  9064. return nil
  9065. case chatsession.FieldBotID:
  9066. v, ok := value.(int64)
  9067. if !ok {
  9068. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9069. }
  9070. m.AddBotID(v)
  9071. return nil
  9072. case chatsession.FieldBotType:
  9073. v, ok := value.(int8)
  9074. if !ok {
  9075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9076. }
  9077. m.AddBotType(v)
  9078. return nil
  9079. }
  9080. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  9081. }
  9082. // ClearedFields returns all nullable fields that were cleared during this
  9083. // mutation.
  9084. func (m *ChatSessionMutation) ClearedFields() []string {
  9085. var fields []string
  9086. if m.FieldCleared(chatsession.FieldDeletedAt) {
  9087. fields = append(fields, chatsession.FieldDeletedAt)
  9088. }
  9089. return fields
  9090. }
  9091. // FieldCleared returns a boolean indicating if a field with the given name was
  9092. // cleared in this mutation.
  9093. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  9094. _, ok := m.clearedFields[name]
  9095. return ok
  9096. }
  9097. // ClearField clears the value of the field with the given name. It returns an
  9098. // error if the field is not defined in the schema.
  9099. func (m *ChatSessionMutation) ClearField(name string) error {
  9100. switch name {
  9101. case chatsession.FieldDeletedAt:
  9102. m.ClearDeletedAt()
  9103. return nil
  9104. }
  9105. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  9106. }
  9107. // ResetField resets all changes in the mutation for the field with the given name.
  9108. // It returns an error if the field is not defined in the schema.
  9109. func (m *ChatSessionMutation) ResetField(name string) error {
  9110. switch name {
  9111. case chatsession.FieldCreatedAt:
  9112. m.ResetCreatedAt()
  9113. return nil
  9114. case chatsession.FieldUpdatedAt:
  9115. m.ResetUpdatedAt()
  9116. return nil
  9117. case chatsession.FieldDeletedAt:
  9118. m.ResetDeletedAt()
  9119. return nil
  9120. case chatsession.FieldName:
  9121. m.ResetName()
  9122. return nil
  9123. case chatsession.FieldUserID:
  9124. m.ResetUserID()
  9125. return nil
  9126. case chatsession.FieldBotID:
  9127. m.ResetBotID()
  9128. return nil
  9129. case chatsession.FieldBotType:
  9130. m.ResetBotType()
  9131. return nil
  9132. }
  9133. return fmt.Errorf("unknown ChatSession field %s", name)
  9134. }
  9135. // AddedEdges returns all edge names that were set/added in this mutation.
  9136. func (m *ChatSessionMutation) AddedEdges() []string {
  9137. edges := make([]string, 0, 0)
  9138. return edges
  9139. }
  9140. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9141. // name in this mutation.
  9142. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  9143. return nil
  9144. }
  9145. // RemovedEdges returns all edge names that were removed in this mutation.
  9146. func (m *ChatSessionMutation) RemovedEdges() []string {
  9147. edges := make([]string, 0, 0)
  9148. return edges
  9149. }
  9150. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9151. // the given name in this mutation.
  9152. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  9153. return nil
  9154. }
  9155. // ClearedEdges returns all edge names that were cleared in this mutation.
  9156. func (m *ChatSessionMutation) ClearedEdges() []string {
  9157. edges := make([]string, 0, 0)
  9158. return edges
  9159. }
  9160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9161. // was cleared in this mutation.
  9162. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  9163. return false
  9164. }
  9165. // ClearEdge clears the value of the edge with the given name. It returns an error
  9166. // if that edge is not defined in the schema.
  9167. func (m *ChatSessionMutation) ClearEdge(name string) error {
  9168. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  9169. }
  9170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9171. // It returns an error if the edge is not defined in the schema.
  9172. func (m *ChatSessionMutation) ResetEdge(name string) error {
  9173. return fmt.Errorf("unknown ChatSession edge %s", name)
  9174. }
  9175. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  9176. type CompapiAsynctaskMutation struct {
  9177. config
  9178. op Op
  9179. typ string
  9180. id *uint64
  9181. created_at *time.Time
  9182. updated_at *time.Time
  9183. auth_token *string
  9184. event_type *string
  9185. chat_id *string
  9186. workid_idx *int8
  9187. addworkid_idx *int8
  9188. openai_base *string
  9189. openai_key *string
  9190. request_raw *string
  9191. response_raw *string
  9192. callback_url *string
  9193. task_status *int8
  9194. addtask_status *int8
  9195. retry_count *int8
  9196. addretry_count *int8
  9197. last_error *string
  9198. clearedFields map[string]struct{}
  9199. done bool
  9200. oldValue func(context.Context) (*CompapiAsynctask, error)
  9201. predicates []predicate.CompapiAsynctask
  9202. }
  9203. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  9204. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  9205. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  9206. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  9207. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  9208. m := &CompapiAsynctaskMutation{
  9209. config: c,
  9210. op: op,
  9211. typ: TypeCompapiAsynctask,
  9212. clearedFields: make(map[string]struct{}),
  9213. }
  9214. for _, opt := range opts {
  9215. opt(m)
  9216. }
  9217. return m
  9218. }
  9219. // withCompapiAsynctaskID sets the ID field of the mutation.
  9220. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  9221. return func(m *CompapiAsynctaskMutation) {
  9222. var (
  9223. err error
  9224. once sync.Once
  9225. value *CompapiAsynctask
  9226. )
  9227. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  9228. once.Do(func() {
  9229. if m.done {
  9230. err = errors.New("querying old values post mutation is not allowed")
  9231. } else {
  9232. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  9233. }
  9234. })
  9235. return value, err
  9236. }
  9237. m.id = &id
  9238. }
  9239. }
  9240. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  9241. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  9242. return func(m *CompapiAsynctaskMutation) {
  9243. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  9244. return node, nil
  9245. }
  9246. m.id = &node.ID
  9247. }
  9248. }
  9249. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9250. // executed in a transaction (ent.Tx), a transactional client is returned.
  9251. func (m CompapiAsynctaskMutation) Client() *Client {
  9252. client := &Client{config: m.config}
  9253. client.init()
  9254. return client
  9255. }
  9256. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9257. // it returns an error otherwise.
  9258. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  9259. if _, ok := m.driver.(*txDriver); !ok {
  9260. return nil, errors.New("ent: mutation is not running in a transaction")
  9261. }
  9262. tx := &Tx{config: m.config}
  9263. tx.init()
  9264. return tx, nil
  9265. }
  9266. // SetID sets the value of the id field. Note that this
  9267. // operation is only accepted on creation of CompapiAsynctask entities.
  9268. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  9269. m.id = &id
  9270. }
  9271. // ID returns the ID value in the mutation. Note that the ID is only available
  9272. // if it was provided to the builder or after it was returned from the database.
  9273. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  9274. if m.id == nil {
  9275. return
  9276. }
  9277. return *m.id, true
  9278. }
  9279. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9280. // That means, if the mutation is applied within a transaction with an isolation level such
  9281. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9282. // or updated by the mutation.
  9283. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  9284. switch {
  9285. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9286. id, exists := m.ID()
  9287. if exists {
  9288. return []uint64{id}, nil
  9289. }
  9290. fallthrough
  9291. case m.op.Is(OpUpdate | OpDelete):
  9292. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  9293. default:
  9294. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9295. }
  9296. }
  9297. // SetCreatedAt sets the "created_at" field.
  9298. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  9299. m.created_at = &t
  9300. }
  9301. // CreatedAt returns the value of the "created_at" field in the mutation.
  9302. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  9303. v := m.created_at
  9304. if v == nil {
  9305. return
  9306. }
  9307. return *v, true
  9308. }
  9309. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  9310. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9312. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9313. if !m.op.Is(OpUpdateOne) {
  9314. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9315. }
  9316. if m.id == nil || m.oldValue == nil {
  9317. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9318. }
  9319. oldValue, err := m.oldValue(ctx)
  9320. if err != nil {
  9321. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9322. }
  9323. return oldValue.CreatedAt, nil
  9324. }
  9325. // ResetCreatedAt resets all changes to the "created_at" field.
  9326. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  9327. m.created_at = nil
  9328. }
  9329. // SetUpdatedAt sets the "updated_at" field.
  9330. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  9331. m.updated_at = &t
  9332. }
  9333. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9334. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  9335. v := m.updated_at
  9336. if v == nil {
  9337. return
  9338. }
  9339. return *v, true
  9340. }
  9341. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  9342. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9344. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9345. if !m.op.Is(OpUpdateOne) {
  9346. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9347. }
  9348. if m.id == nil || m.oldValue == nil {
  9349. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9350. }
  9351. oldValue, err := m.oldValue(ctx)
  9352. if err != nil {
  9353. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9354. }
  9355. return oldValue.UpdatedAt, nil
  9356. }
  9357. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9358. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  9359. m.updated_at = nil
  9360. }
  9361. // SetAuthToken sets the "auth_token" field.
  9362. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  9363. m.auth_token = &s
  9364. }
  9365. // AuthToken returns the value of the "auth_token" field in the mutation.
  9366. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  9367. v := m.auth_token
  9368. if v == nil {
  9369. return
  9370. }
  9371. return *v, true
  9372. }
  9373. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  9374. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9376. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  9377. if !m.op.Is(OpUpdateOne) {
  9378. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  9379. }
  9380. if m.id == nil || m.oldValue == nil {
  9381. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  9382. }
  9383. oldValue, err := m.oldValue(ctx)
  9384. if err != nil {
  9385. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  9386. }
  9387. return oldValue.AuthToken, nil
  9388. }
  9389. // ResetAuthToken resets all changes to the "auth_token" field.
  9390. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  9391. m.auth_token = nil
  9392. }
  9393. // SetEventType sets the "event_type" field.
  9394. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  9395. m.event_type = &s
  9396. }
  9397. // EventType returns the value of the "event_type" field in the mutation.
  9398. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  9399. v := m.event_type
  9400. if v == nil {
  9401. return
  9402. }
  9403. return *v, true
  9404. }
  9405. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  9406. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9408. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  9409. if !m.op.Is(OpUpdateOne) {
  9410. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  9411. }
  9412. if m.id == nil || m.oldValue == nil {
  9413. return v, errors.New("OldEventType requires an ID field in the mutation")
  9414. }
  9415. oldValue, err := m.oldValue(ctx)
  9416. if err != nil {
  9417. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  9418. }
  9419. return oldValue.EventType, nil
  9420. }
  9421. // ResetEventType resets all changes to the "event_type" field.
  9422. func (m *CompapiAsynctaskMutation) ResetEventType() {
  9423. m.event_type = nil
  9424. }
  9425. // SetChatID sets the "chat_id" field.
  9426. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  9427. m.chat_id = &s
  9428. }
  9429. // ChatID returns the value of the "chat_id" field in the mutation.
  9430. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  9431. v := m.chat_id
  9432. if v == nil {
  9433. return
  9434. }
  9435. return *v, true
  9436. }
  9437. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  9438. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9440. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  9441. if !m.op.Is(OpUpdateOne) {
  9442. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  9443. }
  9444. if m.id == nil || m.oldValue == nil {
  9445. return v, errors.New("OldChatID requires an ID field in the mutation")
  9446. }
  9447. oldValue, err := m.oldValue(ctx)
  9448. if err != nil {
  9449. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  9450. }
  9451. return oldValue.ChatID, nil
  9452. }
  9453. // ClearChatID clears the value of the "chat_id" field.
  9454. func (m *CompapiAsynctaskMutation) ClearChatID() {
  9455. m.chat_id = nil
  9456. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  9457. }
  9458. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  9459. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  9460. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  9461. return ok
  9462. }
  9463. // ResetChatID resets all changes to the "chat_id" field.
  9464. func (m *CompapiAsynctaskMutation) ResetChatID() {
  9465. m.chat_id = nil
  9466. delete(m.clearedFields, compapiasynctask.FieldChatID)
  9467. }
  9468. // SetWorkidIdx sets the "workid_idx" field.
  9469. func (m *CompapiAsynctaskMutation) SetWorkidIdx(i int8) {
  9470. m.workid_idx = &i
  9471. m.addworkid_idx = nil
  9472. }
  9473. // WorkidIdx returns the value of the "workid_idx" field in the mutation.
  9474. func (m *CompapiAsynctaskMutation) WorkidIdx() (r int8, exists bool) {
  9475. v := m.workid_idx
  9476. if v == nil {
  9477. return
  9478. }
  9479. return *v, true
  9480. }
  9481. // OldWorkidIdx returns the old "workid_idx" field's value of the CompapiAsynctask entity.
  9482. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9484. func (m *CompapiAsynctaskMutation) OldWorkidIdx(ctx context.Context) (v int8, err error) {
  9485. if !m.op.Is(OpUpdateOne) {
  9486. return v, errors.New("OldWorkidIdx is only allowed on UpdateOne operations")
  9487. }
  9488. if m.id == nil || m.oldValue == nil {
  9489. return v, errors.New("OldWorkidIdx requires an ID field in the mutation")
  9490. }
  9491. oldValue, err := m.oldValue(ctx)
  9492. if err != nil {
  9493. return v, fmt.Errorf("querying old value for OldWorkidIdx: %w", err)
  9494. }
  9495. return oldValue.WorkidIdx, nil
  9496. }
  9497. // AddWorkidIdx adds i to the "workid_idx" field.
  9498. func (m *CompapiAsynctaskMutation) AddWorkidIdx(i int8) {
  9499. if m.addworkid_idx != nil {
  9500. *m.addworkid_idx += i
  9501. } else {
  9502. m.addworkid_idx = &i
  9503. }
  9504. }
  9505. // AddedWorkidIdx returns the value that was added to the "workid_idx" field in this mutation.
  9506. func (m *CompapiAsynctaskMutation) AddedWorkidIdx() (r int8, exists bool) {
  9507. v := m.addworkid_idx
  9508. if v == nil {
  9509. return
  9510. }
  9511. return *v, true
  9512. }
  9513. // ClearWorkidIdx clears the value of the "workid_idx" field.
  9514. func (m *CompapiAsynctaskMutation) ClearWorkidIdx() {
  9515. m.workid_idx = nil
  9516. m.addworkid_idx = nil
  9517. m.clearedFields[compapiasynctask.FieldWorkidIdx] = struct{}{}
  9518. }
  9519. // WorkidIdxCleared returns if the "workid_idx" field was cleared in this mutation.
  9520. func (m *CompapiAsynctaskMutation) WorkidIdxCleared() bool {
  9521. _, ok := m.clearedFields[compapiasynctask.FieldWorkidIdx]
  9522. return ok
  9523. }
  9524. // ResetWorkidIdx resets all changes to the "workid_idx" field.
  9525. func (m *CompapiAsynctaskMutation) ResetWorkidIdx() {
  9526. m.workid_idx = nil
  9527. m.addworkid_idx = nil
  9528. delete(m.clearedFields, compapiasynctask.FieldWorkidIdx)
  9529. }
  9530. // SetOpenaiBase sets the "openai_base" field.
  9531. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  9532. m.openai_base = &s
  9533. }
  9534. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  9535. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  9536. v := m.openai_base
  9537. if v == nil {
  9538. return
  9539. }
  9540. return *v, true
  9541. }
  9542. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  9543. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9545. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  9546. if !m.op.Is(OpUpdateOne) {
  9547. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  9548. }
  9549. if m.id == nil || m.oldValue == nil {
  9550. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  9551. }
  9552. oldValue, err := m.oldValue(ctx)
  9553. if err != nil {
  9554. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  9555. }
  9556. return oldValue.OpenaiBase, nil
  9557. }
  9558. // ResetOpenaiBase resets all changes to the "openai_base" field.
  9559. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  9560. m.openai_base = nil
  9561. }
  9562. // SetOpenaiKey sets the "openai_key" field.
  9563. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  9564. m.openai_key = &s
  9565. }
  9566. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  9567. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  9568. v := m.openai_key
  9569. if v == nil {
  9570. return
  9571. }
  9572. return *v, true
  9573. }
  9574. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  9575. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9577. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  9578. if !m.op.Is(OpUpdateOne) {
  9579. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  9580. }
  9581. if m.id == nil || m.oldValue == nil {
  9582. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  9583. }
  9584. oldValue, err := m.oldValue(ctx)
  9585. if err != nil {
  9586. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  9587. }
  9588. return oldValue.OpenaiKey, nil
  9589. }
  9590. // ResetOpenaiKey resets all changes to the "openai_key" field.
  9591. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  9592. m.openai_key = nil
  9593. }
  9594. // SetRequestRaw sets the "request_raw" field.
  9595. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  9596. m.request_raw = &s
  9597. }
  9598. // RequestRaw returns the value of the "request_raw" field in the mutation.
  9599. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  9600. v := m.request_raw
  9601. if v == nil {
  9602. return
  9603. }
  9604. return *v, true
  9605. }
  9606. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  9607. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9609. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  9610. if !m.op.Is(OpUpdateOne) {
  9611. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  9612. }
  9613. if m.id == nil || m.oldValue == nil {
  9614. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  9615. }
  9616. oldValue, err := m.oldValue(ctx)
  9617. if err != nil {
  9618. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  9619. }
  9620. return oldValue.RequestRaw, nil
  9621. }
  9622. // ResetRequestRaw resets all changes to the "request_raw" field.
  9623. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  9624. m.request_raw = nil
  9625. }
  9626. // SetResponseRaw sets the "response_raw" field.
  9627. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  9628. m.response_raw = &s
  9629. }
  9630. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  9631. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  9632. v := m.response_raw
  9633. if v == nil {
  9634. return
  9635. }
  9636. return *v, true
  9637. }
  9638. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  9639. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9641. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  9642. if !m.op.Is(OpUpdateOne) {
  9643. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  9644. }
  9645. if m.id == nil || m.oldValue == nil {
  9646. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  9647. }
  9648. oldValue, err := m.oldValue(ctx)
  9649. if err != nil {
  9650. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  9651. }
  9652. return oldValue.ResponseRaw, nil
  9653. }
  9654. // ClearResponseRaw clears the value of the "response_raw" field.
  9655. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  9656. m.response_raw = nil
  9657. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  9658. }
  9659. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  9660. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  9661. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  9662. return ok
  9663. }
  9664. // ResetResponseRaw resets all changes to the "response_raw" field.
  9665. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  9666. m.response_raw = nil
  9667. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  9668. }
  9669. // SetCallbackURL sets the "callback_url" field.
  9670. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  9671. m.callback_url = &s
  9672. }
  9673. // CallbackURL returns the value of the "callback_url" field in the mutation.
  9674. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  9675. v := m.callback_url
  9676. if v == nil {
  9677. return
  9678. }
  9679. return *v, true
  9680. }
  9681. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  9682. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9684. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  9685. if !m.op.Is(OpUpdateOne) {
  9686. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  9687. }
  9688. if m.id == nil || m.oldValue == nil {
  9689. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  9690. }
  9691. oldValue, err := m.oldValue(ctx)
  9692. if err != nil {
  9693. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  9694. }
  9695. return oldValue.CallbackURL, nil
  9696. }
  9697. // ResetCallbackURL resets all changes to the "callback_url" field.
  9698. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  9699. m.callback_url = nil
  9700. }
  9701. // SetTaskStatus sets the "task_status" field.
  9702. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  9703. m.task_status = &i
  9704. m.addtask_status = nil
  9705. }
  9706. // TaskStatus returns the value of the "task_status" field in the mutation.
  9707. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  9708. v := m.task_status
  9709. if v == nil {
  9710. return
  9711. }
  9712. return *v, true
  9713. }
  9714. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  9715. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9717. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  9718. if !m.op.Is(OpUpdateOne) {
  9719. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  9720. }
  9721. if m.id == nil || m.oldValue == nil {
  9722. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  9723. }
  9724. oldValue, err := m.oldValue(ctx)
  9725. if err != nil {
  9726. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  9727. }
  9728. return oldValue.TaskStatus, nil
  9729. }
  9730. // AddTaskStatus adds i to the "task_status" field.
  9731. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  9732. if m.addtask_status != nil {
  9733. *m.addtask_status += i
  9734. } else {
  9735. m.addtask_status = &i
  9736. }
  9737. }
  9738. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  9739. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  9740. v := m.addtask_status
  9741. if v == nil {
  9742. return
  9743. }
  9744. return *v, true
  9745. }
  9746. // ClearTaskStatus clears the value of the "task_status" field.
  9747. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  9748. m.task_status = nil
  9749. m.addtask_status = nil
  9750. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  9751. }
  9752. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  9753. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  9754. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  9755. return ok
  9756. }
  9757. // ResetTaskStatus resets all changes to the "task_status" field.
  9758. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  9759. m.task_status = nil
  9760. m.addtask_status = nil
  9761. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  9762. }
  9763. // SetRetryCount sets the "retry_count" field.
  9764. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  9765. m.retry_count = &i
  9766. m.addretry_count = nil
  9767. }
  9768. // RetryCount returns the value of the "retry_count" field in the mutation.
  9769. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  9770. v := m.retry_count
  9771. if v == nil {
  9772. return
  9773. }
  9774. return *v, true
  9775. }
  9776. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  9777. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9779. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  9780. if !m.op.Is(OpUpdateOne) {
  9781. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  9782. }
  9783. if m.id == nil || m.oldValue == nil {
  9784. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  9785. }
  9786. oldValue, err := m.oldValue(ctx)
  9787. if err != nil {
  9788. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  9789. }
  9790. return oldValue.RetryCount, nil
  9791. }
  9792. // AddRetryCount adds i to the "retry_count" field.
  9793. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  9794. if m.addretry_count != nil {
  9795. *m.addretry_count += i
  9796. } else {
  9797. m.addretry_count = &i
  9798. }
  9799. }
  9800. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  9801. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  9802. v := m.addretry_count
  9803. if v == nil {
  9804. return
  9805. }
  9806. return *v, true
  9807. }
  9808. // ClearRetryCount clears the value of the "retry_count" field.
  9809. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  9810. m.retry_count = nil
  9811. m.addretry_count = nil
  9812. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  9813. }
  9814. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  9815. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  9816. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  9817. return ok
  9818. }
  9819. // ResetRetryCount resets all changes to the "retry_count" field.
  9820. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  9821. m.retry_count = nil
  9822. m.addretry_count = nil
  9823. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  9824. }
  9825. // SetLastError sets the "last_error" field.
  9826. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  9827. m.last_error = &s
  9828. }
  9829. // LastError returns the value of the "last_error" field in the mutation.
  9830. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  9831. v := m.last_error
  9832. if v == nil {
  9833. return
  9834. }
  9835. return *v, true
  9836. }
  9837. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  9838. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  9839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9840. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  9841. if !m.op.Is(OpUpdateOne) {
  9842. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  9843. }
  9844. if m.id == nil || m.oldValue == nil {
  9845. return v, errors.New("OldLastError requires an ID field in the mutation")
  9846. }
  9847. oldValue, err := m.oldValue(ctx)
  9848. if err != nil {
  9849. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  9850. }
  9851. return oldValue.LastError, nil
  9852. }
  9853. // ClearLastError clears the value of the "last_error" field.
  9854. func (m *CompapiAsynctaskMutation) ClearLastError() {
  9855. m.last_error = nil
  9856. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  9857. }
  9858. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  9859. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  9860. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  9861. return ok
  9862. }
  9863. // ResetLastError resets all changes to the "last_error" field.
  9864. func (m *CompapiAsynctaskMutation) ResetLastError() {
  9865. m.last_error = nil
  9866. delete(m.clearedFields, compapiasynctask.FieldLastError)
  9867. }
  9868. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  9869. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  9870. m.predicates = append(m.predicates, ps...)
  9871. }
  9872. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  9873. // users can use type-assertion to append predicates that do not depend on any generated package.
  9874. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  9875. p := make([]predicate.CompapiAsynctask, len(ps))
  9876. for i := range ps {
  9877. p[i] = ps[i]
  9878. }
  9879. m.Where(p...)
  9880. }
  9881. // Op returns the operation name.
  9882. func (m *CompapiAsynctaskMutation) Op() Op {
  9883. return m.op
  9884. }
  9885. // SetOp allows setting the mutation operation.
  9886. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  9887. m.op = op
  9888. }
  9889. // Type returns the node type of this mutation (CompapiAsynctask).
  9890. func (m *CompapiAsynctaskMutation) Type() string {
  9891. return m.typ
  9892. }
  9893. // Fields returns all fields that were changed during this mutation. Note that in
  9894. // order to get all numeric fields that were incremented/decremented, call
  9895. // AddedFields().
  9896. func (m *CompapiAsynctaskMutation) Fields() []string {
  9897. fields := make([]string, 0, 14)
  9898. if m.created_at != nil {
  9899. fields = append(fields, compapiasynctask.FieldCreatedAt)
  9900. }
  9901. if m.updated_at != nil {
  9902. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  9903. }
  9904. if m.auth_token != nil {
  9905. fields = append(fields, compapiasynctask.FieldAuthToken)
  9906. }
  9907. if m.event_type != nil {
  9908. fields = append(fields, compapiasynctask.FieldEventType)
  9909. }
  9910. if m.chat_id != nil {
  9911. fields = append(fields, compapiasynctask.FieldChatID)
  9912. }
  9913. if m.workid_idx != nil {
  9914. fields = append(fields, compapiasynctask.FieldWorkidIdx)
  9915. }
  9916. if m.openai_base != nil {
  9917. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  9918. }
  9919. if m.openai_key != nil {
  9920. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  9921. }
  9922. if m.request_raw != nil {
  9923. fields = append(fields, compapiasynctask.FieldRequestRaw)
  9924. }
  9925. if m.response_raw != nil {
  9926. fields = append(fields, compapiasynctask.FieldResponseRaw)
  9927. }
  9928. if m.callback_url != nil {
  9929. fields = append(fields, compapiasynctask.FieldCallbackURL)
  9930. }
  9931. if m.task_status != nil {
  9932. fields = append(fields, compapiasynctask.FieldTaskStatus)
  9933. }
  9934. if m.retry_count != nil {
  9935. fields = append(fields, compapiasynctask.FieldRetryCount)
  9936. }
  9937. if m.last_error != nil {
  9938. fields = append(fields, compapiasynctask.FieldLastError)
  9939. }
  9940. return fields
  9941. }
  9942. // Field returns the value of a field with the given name. The second boolean
  9943. // return value indicates that this field was not set, or was not defined in the
  9944. // schema.
  9945. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  9946. switch name {
  9947. case compapiasynctask.FieldCreatedAt:
  9948. return m.CreatedAt()
  9949. case compapiasynctask.FieldUpdatedAt:
  9950. return m.UpdatedAt()
  9951. case compapiasynctask.FieldAuthToken:
  9952. return m.AuthToken()
  9953. case compapiasynctask.FieldEventType:
  9954. return m.EventType()
  9955. case compapiasynctask.FieldChatID:
  9956. return m.ChatID()
  9957. case compapiasynctask.FieldWorkidIdx:
  9958. return m.WorkidIdx()
  9959. case compapiasynctask.FieldOpenaiBase:
  9960. return m.OpenaiBase()
  9961. case compapiasynctask.FieldOpenaiKey:
  9962. return m.OpenaiKey()
  9963. case compapiasynctask.FieldRequestRaw:
  9964. return m.RequestRaw()
  9965. case compapiasynctask.FieldResponseRaw:
  9966. return m.ResponseRaw()
  9967. case compapiasynctask.FieldCallbackURL:
  9968. return m.CallbackURL()
  9969. case compapiasynctask.FieldTaskStatus:
  9970. return m.TaskStatus()
  9971. case compapiasynctask.FieldRetryCount:
  9972. return m.RetryCount()
  9973. case compapiasynctask.FieldLastError:
  9974. return m.LastError()
  9975. }
  9976. return nil, false
  9977. }
  9978. // OldField returns the old value of the field from the database. An error is
  9979. // returned if the mutation operation is not UpdateOne, or the query to the
  9980. // database failed.
  9981. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9982. switch name {
  9983. case compapiasynctask.FieldCreatedAt:
  9984. return m.OldCreatedAt(ctx)
  9985. case compapiasynctask.FieldUpdatedAt:
  9986. return m.OldUpdatedAt(ctx)
  9987. case compapiasynctask.FieldAuthToken:
  9988. return m.OldAuthToken(ctx)
  9989. case compapiasynctask.FieldEventType:
  9990. return m.OldEventType(ctx)
  9991. case compapiasynctask.FieldChatID:
  9992. return m.OldChatID(ctx)
  9993. case compapiasynctask.FieldWorkidIdx:
  9994. return m.OldWorkidIdx(ctx)
  9995. case compapiasynctask.FieldOpenaiBase:
  9996. return m.OldOpenaiBase(ctx)
  9997. case compapiasynctask.FieldOpenaiKey:
  9998. return m.OldOpenaiKey(ctx)
  9999. case compapiasynctask.FieldRequestRaw:
  10000. return m.OldRequestRaw(ctx)
  10001. case compapiasynctask.FieldResponseRaw:
  10002. return m.OldResponseRaw(ctx)
  10003. case compapiasynctask.FieldCallbackURL:
  10004. return m.OldCallbackURL(ctx)
  10005. case compapiasynctask.FieldTaskStatus:
  10006. return m.OldTaskStatus(ctx)
  10007. case compapiasynctask.FieldRetryCount:
  10008. return m.OldRetryCount(ctx)
  10009. case compapiasynctask.FieldLastError:
  10010. return m.OldLastError(ctx)
  10011. }
  10012. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10013. }
  10014. // SetField sets the value of a field with the given name. It returns an error if
  10015. // the field is not defined in the schema, or if the type mismatched the field
  10016. // type.
  10017. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  10018. switch name {
  10019. case compapiasynctask.FieldCreatedAt:
  10020. v, ok := value.(time.Time)
  10021. if !ok {
  10022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10023. }
  10024. m.SetCreatedAt(v)
  10025. return nil
  10026. case compapiasynctask.FieldUpdatedAt:
  10027. v, ok := value.(time.Time)
  10028. if !ok {
  10029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10030. }
  10031. m.SetUpdatedAt(v)
  10032. return nil
  10033. case compapiasynctask.FieldAuthToken:
  10034. v, ok := value.(string)
  10035. if !ok {
  10036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10037. }
  10038. m.SetAuthToken(v)
  10039. return nil
  10040. case compapiasynctask.FieldEventType:
  10041. v, ok := value.(string)
  10042. if !ok {
  10043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10044. }
  10045. m.SetEventType(v)
  10046. return nil
  10047. case compapiasynctask.FieldChatID:
  10048. v, ok := value.(string)
  10049. if !ok {
  10050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10051. }
  10052. m.SetChatID(v)
  10053. return nil
  10054. case compapiasynctask.FieldWorkidIdx:
  10055. v, ok := value.(int8)
  10056. if !ok {
  10057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10058. }
  10059. m.SetWorkidIdx(v)
  10060. return nil
  10061. case compapiasynctask.FieldOpenaiBase:
  10062. v, ok := value.(string)
  10063. if !ok {
  10064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10065. }
  10066. m.SetOpenaiBase(v)
  10067. return nil
  10068. case compapiasynctask.FieldOpenaiKey:
  10069. v, ok := value.(string)
  10070. if !ok {
  10071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10072. }
  10073. m.SetOpenaiKey(v)
  10074. return nil
  10075. case compapiasynctask.FieldRequestRaw:
  10076. v, ok := value.(string)
  10077. if !ok {
  10078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10079. }
  10080. m.SetRequestRaw(v)
  10081. return nil
  10082. case compapiasynctask.FieldResponseRaw:
  10083. v, ok := value.(string)
  10084. if !ok {
  10085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10086. }
  10087. m.SetResponseRaw(v)
  10088. return nil
  10089. case compapiasynctask.FieldCallbackURL:
  10090. v, ok := value.(string)
  10091. if !ok {
  10092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10093. }
  10094. m.SetCallbackURL(v)
  10095. return nil
  10096. case compapiasynctask.FieldTaskStatus:
  10097. v, ok := value.(int8)
  10098. if !ok {
  10099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10100. }
  10101. m.SetTaskStatus(v)
  10102. return nil
  10103. case compapiasynctask.FieldRetryCount:
  10104. v, ok := value.(int8)
  10105. if !ok {
  10106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10107. }
  10108. m.SetRetryCount(v)
  10109. return nil
  10110. case compapiasynctask.FieldLastError:
  10111. v, ok := value.(string)
  10112. if !ok {
  10113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10114. }
  10115. m.SetLastError(v)
  10116. return nil
  10117. }
  10118. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10119. }
  10120. // AddedFields returns all numeric fields that were incremented/decremented during
  10121. // this mutation.
  10122. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  10123. var fields []string
  10124. if m.addworkid_idx != nil {
  10125. fields = append(fields, compapiasynctask.FieldWorkidIdx)
  10126. }
  10127. if m.addtask_status != nil {
  10128. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10129. }
  10130. if m.addretry_count != nil {
  10131. fields = append(fields, compapiasynctask.FieldRetryCount)
  10132. }
  10133. return fields
  10134. }
  10135. // AddedField returns the numeric value that was incremented/decremented on a field
  10136. // with the given name. The second boolean return value indicates that this field
  10137. // was not set, or was not defined in the schema.
  10138. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  10139. switch name {
  10140. case compapiasynctask.FieldWorkidIdx:
  10141. return m.AddedWorkidIdx()
  10142. case compapiasynctask.FieldTaskStatus:
  10143. return m.AddedTaskStatus()
  10144. case compapiasynctask.FieldRetryCount:
  10145. return m.AddedRetryCount()
  10146. }
  10147. return nil, false
  10148. }
  10149. // AddField adds the value to the field with the given name. It returns an error if
  10150. // the field is not defined in the schema, or if the type mismatched the field
  10151. // type.
  10152. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  10153. switch name {
  10154. case compapiasynctask.FieldWorkidIdx:
  10155. v, ok := value.(int8)
  10156. if !ok {
  10157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10158. }
  10159. m.AddWorkidIdx(v)
  10160. return nil
  10161. case compapiasynctask.FieldTaskStatus:
  10162. v, ok := value.(int8)
  10163. if !ok {
  10164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10165. }
  10166. m.AddTaskStatus(v)
  10167. return nil
  10168. case compapiasynctask.FieldRetryCount:
  10169. v, ok := value.(int8)
  10170. if !ok {
  10171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10172. }
  10173. m.AddRetryCount(v)
  10174. return nil
  10175. }
  10176. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  10177. }
  10178. // ClearedFields returns all nullable fields that were cleared during this
  10179. // mutation.
  10180. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  10181. var fields []string
  10182. if m.FieldCleared(compapiasynctask.FieldChatID) {
  10183. fields = append(fields, compapiasynctask.FieldChatID)
  10184. }
  10185. if m.FieldCleared(compapiasynctask.FieldWorkidIdx) {
  10186. fields = append(fields, compapiasynctask.FieldWorkidIdx)
  10187. }
  10188. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  10189. fields = append(fields, compapiasynctask.FieldResponseRaw)
  10190. }
  10191. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  10192. fields = append(fields, compapiasynctask.FieldTaskStatus)
  10193. }
  10194. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  10195. fields = append(fields, compapiasynctask.FieldRetryCount)
  10196. }
  10197. if m.FieldCleared(compapiasynctask.FieldLastError) {
  10198. fields = append(fields, compapiasynctask.FieldLastError)
  10199. }
  10200. return fields
  10201. }
  10202. // FieldCleared returns a boolean indicating if a field with the given name was
  10203. // cleared in this mutation.
  10204. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  10205. _, ok := m.clearedFields[name]
  10206. return ok
  10207. }
  10208. // ClearField clears the value of the field with the given name. It returns an
  10209. // error if the field is not defined in the schema.
  10210. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  10211. switch name {
  10212. case compapiasynctask.FieldChatID:
  10213. m.ClearChatID()
  10214. return nil
  10215. case compapiasynctask.FieldWorkidIdx:
  10216. m.ClearWorkidIdx()
  10217. return nil
  10218. case compapiasynctask.FieldResponseRaw:
  10219. m.ClearResponseRaw()
  10220. return nil
  10221. case compapiasynctask.FieldTaskStatus:
  10222. m.ClearTaskStatus()
  10223. return nil
  10224. case compapiasynctask.FieldRetryCount:
  10225. m.ClearRetryCount()
  10226. return nil
  10227. case compapiasynctask.FieldLastError:
  10228. m.ClearLastError()
  10229. return nil
  10230. }
  10231. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  10232. }
  10233. // ResetField resets all changes in the mutation for the field with the given name.
  10234. // It returns an error if the field is not defined in the schema.
  10235. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  10236. switch name {
  10237. case compapiasynctask.FieldCreatedAt:
  10238. m.ResetCreatedAt()
  10239. return nil
  10240. case compapiasynctask.FieldUpdatedAt:
  10241. m.ResetUpdatedAt()
  10242. return nil
  10243. case compapiasynctask.FieldAuthToken:
  10244. m.ResetAuthToken()
  10245. return nil
  10246. case compapiasynctask.FieldEventType:
  10247. m.ResetEventType()
  10248. return nil
  10249. case compapiasynctask.FieldChatID:
  10250. m.ResetChatID()
  10251. return nil
  10252. case compapiasynctask.FieldWorkidIdx:
  10253. m.ResetWorkidIdx()
  10254. return nil
  10255. case compapiasynctask.FieldOpenaiBase:
  10256. m.ResetOpenaiBase()
  10257. return nil
  10258. case compapiasynctask.FieldOpenaiKey:
  10259. m.ResetOpenaiKey()
  10260. return nil
  10261. case compapiasynctask.FieldRequestRaw:
  10262. m.ResetRequestRaw()
  10263. return nil
  10264. case compapiasynctask.FieldResponseRaw:
  10265. m.ResetResponseRaw()
  10266. return nil
  10267. case compapiasynctask.FieldCallbackURL:
  10268. m.ResetCallbackURL()
  10269. return nil
  10270. case compapiasynctask.FieldTaskStatus:
  10271. m.ResetTaskStatus()
  10272. return nil
  10273. case compapiasynctask.FieldRetryCount:
  10274. m.ResetRetryCount()
  10275. return nil
  10276. case compapiasynctask.FieldLastError:
  10277. m.ResetLastError()
  10278. return nil
  10279. }
  10280. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  10281. }
  10282. // AddedEdges returns all edge names that were set/added in this mutation.
  10283. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  10284. edges := make([]string, 0, 0)
  10285. return edges
  10286. }
  10287. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10288. // name in this mutation.
  10289. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  10290. return nil
  10291. }
  10292. // RemovedEdges returns all edge names that were removed in this mutation.
  10293. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  10294. edges := make([]string, 0, 0)
  10295. return edges
  10296. }
  10297. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10298. // the given name in this mutation.
  10299. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  10300. return nil
  10301. }
  10302. // ClearedEdges returns all edge names that were cleared in this mutation.
  10303. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  10304. edges := make([]string, 0, 0)
  10305. return edges
  10306. }
  10307. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10308. // was cleared in this mutation.
  10309. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  10310. return false
  10311. }
  10312. // ClearEdge clears the value of the edge with the given name. It returns an error
  10313. // if that edge is not defined in the schema.
  10314. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  10315. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  10316. }
  10317. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10318. // It returns an error if the edge is not defined in the schema.
  10319. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  10320. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  10321. }
  10322. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  10323. type ContactMutation struct {
  10324. config
  10325. op Op
  10326. typ string
  10327. id *uint64
  10328. created_at *time.Time
  10329. updated_at *time.Time
  10330. status *uint8
  10331. addstatus *int8
  10332. deleted_at *time.Time
  10333. wx_wxid *string
  10334. _type *int
  10335. add_type *int
  10336. wxid *string
  10337. account *string
  10338. nickname *string
  10339. markname *string
  10340. headimg *string
  10341. sex *int
  10342. addsex *int
  10343. starrole *string
  10344. dontseeit *int
  10345. adddontseeit *int
  10346. dontseeme *int
  10347. adddontseeme *int
  10348. lag *string
  10349. gid *string
  10350. gname *string
  10351. v3 *string
  10352. organization_id *uint64
  10353. addorganization_id *int64
  10354. ctype *uint64
  10355. addctype *int64
  10356. cage *int
  10357. addcage *int
  10358. cname *string
  10359. carea *string
  10360. cbirthday *string
  10361. cbirtharea *string
  10362. cidcard_no *string
  10363. ctitle *string
  10364. cc *string
  10365. phone *string
  10366. clearedFields map[string]struct{}
  10367. contact_relationships map[uint64]struct{}
  10368. removedcontact_relationships map[uint64]struct{}
  10369. clearedcontact_relationships bool
  10370. contact_messages map[uint64]struct{}
  10371. removedcontact_messages map[uint64]struct{}
  10372. clearedcontact_messages bool
  10373. done bool
  10374. oldValue func(context.Context) (*Contact, error)
  10375. predicates []predicate.Contact
  10376. }
  10377. var _ ent.Mutation = (*ContactMutation)(nil)
  10378. // contactOption allows management of the mutation configuration using functional options.
  10379. type contactOption func(*ContactMutation)
  10380. // newContactMutation creates new mutation for the Contact entity.
  10381. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  10382. m := &ContactMutation{
  10383. config: c,
  10384. op: op,
  10385. typ: TypeContact,
  10386. clearedFields: make(map[string]struct{}),
  10387. }
  10388. for _, opt := range opts {
  10389. opt(m)
  10390. }
  10391. return m
  10392. }
  10393. // withContactID sets the ID field of the mutation.
  10394. func withContactID(id uint64) contactOption {
  10395. return func(m *ContactMutation) {
  10396. var (
  10397. err error
  10398. once sync.Once
  10399. value *Contact
  10400. )
  10401. m.oldValue = func(ctx context.Context) (*Contact, error) {
  10402. once.Do(func() {
  10403. if m.done {
  10404. err = errors.New("querying old values post mutation is not allowed")
  10405. } else {
  10406. value, err = m.Client().Contact.Get(ctx, id)
  10407. }
  10408. })
  10409. return value, err
  10410. }
  10411. m.id = &id
  10412. }
  10413. }
  10414. // withContact sets the old Contact of the mutation.
  10415. func withContact(node *Contact) contactOption {
  10416. return func(m *ContactMutation) {
  10417. m.oldValue = func(context.Context) (*Contact, error) {
  10418. return node, nil
  10419. }
  10420. m.id = &node.ID
  10421. }
  10422. }
  10423. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10424. // executed in a transaction (ent.Tx), a transactional client is returned.
  10425. func (m ContactMutation) Client() *Client {
  10426. client := &Client{config: m.config}
  10427. client.init()
  10428. return client
  10429. }
  10430. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10431. // it returns an error otherwise.
  10432. func (m ContactMutation) Tx() (*Tx, error) {
  10433. if _, ok := m.driver.(*txDriver); !ok {
  10434. return nil, errors.New("ent: mutation is not running in a transaction")
  10435. }
  10436. tx := &Tx{config: m.config}
  10437. tx.init()
  10438. return tx, nil
  10439. }
  10440. // SetID sets the value of the id field. Note that this
  10441. // operation is only accepted on creation of Contact entities.
  10442. func (m *ContactMutation) SetID(id uint64) {
  10443. m.id = &id
  10444. }
  10445. // ID returns the ID value in the mutation. Note that the ID is only available
  10446. // if it was provided to the builder or after it was returned from the database.
  10447. func (m *ContactMutation) ID() (id uint64, exists bool) {
  10448. if m.id == nil {
  10449. return
  10450. }
  10451. return *m.id, true
  10452. }
  10453. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10454. // That means, if the mutation is applied within a transaction with an isolation level such
  10455. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10456. // or updated by the mutation.
  10457. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  10458. switch {
  10459. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10460. id, exists := m.ID()
  10461. if exists {
  10462. return []uint64{id}, nil
  10463. }
  10464. fallthrough
  10465. case m.op.Is(OpUpdate | OpDelete):
  10466. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  10467. default:
  10468. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10469. }
  10470. }
  10471. // SetCreatedAt sets the "created_at" field.
  10472. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  10473. m.created_at = &t
  10474. }
  10475. // CreatedAt returns the value of the "created_at" field in the mutation.
  10476. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  10477. v := m.created_at
  10478. if v == nil {
  10479. return
  10480. }
  10481. return *v, true
  10482. }
  10483. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  10484. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10486. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10487. if !m.op.Is(OpUpdateOne) {
  10488. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10489. }
  10490. if m.id == nil || m.oldValue == nil {
  10491. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10492. }
  10493. oldValue, err := m.oldValue(ctx)
  10494. if err != nil {
  10495. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10496. }
  10497. return oldValue.CreatedAt, nil
  10498. }
  10499. // ResetCreatedAt resets all changes to the "created_at" field.
  10500. func (m *ContactMutation) ResetCreatedAt() {
  10501. m.created_at = nil
  10502. }
  10503. // SetUpdatedAt sets the "updated_at" field.
  10504. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  10505. m.updated_at = &t
  10506. }
  10507. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10508. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  10509. v := m.updated_at
  10510. if v == nil {
  10511. return
  10512. }
  10513. return *v, true
  10514. }
  10515. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  10516. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10518. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10519. if !m.op.Is(OpUpdateOne) {
  10520. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10521. }
  10522. if m.id == nil || m.oldValue == nil {
  10523. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10524. }
  10525. oldValue, err := m.oldValue(ctx)
  10526. if err != nil {
  10527. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10528. }
  10529. return oldValue.UpdatedAt, nil
  10530. }
  10531. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10532. func (m *ContactMutation) ResetUpdatedAt() {
  10533. m.updated_at = nil
  10534. }
  10535. // SetStatus sets the "status" field.
  10536. func (m *ContactMutation) SetStatus(u uint8) {
  10537. m.status = &u
  10538. m.addstatus = nil
  10539. }
  10540. // Status returns the value of the "status" field in the mutation.
  10541. func (m *ContactMutation) Status() (r uint8, exists bool) {
  10542. v := m.status
  10543. if v == nil {
  10544. return
  10545. }
  10546. return *v, true
  10547. }
  10548. // OldStatus returns the old "status" field's value of the Contact entity.
  10549. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10551. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  10552. if !m.op.Is(OpUpdateOne) {
  10553. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10554. }
  10555. if m.id == nil || m.oldValue == nil {
  10556. return v, errors.New("OldStatus requires an ID field in the mutation")
  10557. }
  10558. oldValue, err := m.oldValue(ctx)
  10559. if err != nil {
  10560. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10561. }
  10562. return oldValue.Status, nil
  10563. }
  10564. // AddStatus adds u to the "status" field.
  10565. func (m *ContactMutation) AddStatus(u int8) {
  10566. if m.addstatus != nil {
  10567. *m.addstatus += u
  10568. } else {
  10569. m.addstatus = &u
  10570. }
  10571. }
  10572. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10573. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  10574. v := m.addstatus
  10575. if v == nil {
  10576. return
  10577. }
  10578. return *v, true
  10579. }
  10580. // ClearStatus clears the value of the "status" field.
  10581. func (m *ContactMutation) ClearStatus() {
  10582. m.status = nil
  10583. m.addstatus = nil
  10584. m.clearedFields[contact.FieldStatus] = struct{}{}
  10585. }
  10586. // StatusCleared returns if the "status" field was cleared in this mutation.
  10587. func (m *ContactMutation) StatusCleared() bool {
  10588. _, ok := m.clearedFields[contact.FieldStatus]
  10589. return ok
  10590. }
  10591. // ResetStatus resets all changes to the "status" field.
  10592. func (m *ContactMutation) ResetStatus() {
  10593. m.status = nil
  10594. m.addstatus = nil
  10595. delete(m.clearedFields, contact.FieldStatus)
  10596. }
  10597. // SetDeletedAt sets the "deleted_at" field.
  10598. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  10599. m.deleted_at = &t
  10600. }
  10601. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10602. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  10603. v := m.deleted_at
  10604. if v == nil {
  10605. return
  10606. }
  10607. return *v, true
  10608. }
  10609. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  10610. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10612. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10613. if !m.op.Is(OpUpdateOne) {
  10614. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10615. }
  10616. if m.id == nil || m.oldValue == nil {
  10617. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10618. }
  10619. oldValue, err := m.oldValue(ctx)
  10620. if err != nil {
  10621. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10622. }
  10623. return oldValue.DeletedAt, nil
  10624. }
  10625. // ClearDeletedAt clears the value of the "deleted_at" field.
  10626. func (m *ContactMutation) ClearDeletedAt() {
  10627. m.deleted_at = nil
  10628. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  10629. }
  10630. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10631. func (m *ContactMutation) DeletedAtCleared() bool {
  10632. _, ok := m.clearedFields[contact.FieldDeletedAt]
  10633. return ok
  10634. }
  10635. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10636. func (m *ContactMutation) ResetDeletedAt() {
  10637. m.deleted_at = nil
  10638. delete(m.clearedFields, contact.FieldDeletedAt)
  10639. }
  10640. // SetWxWxid sets the "wx_wxid" field.
  10641. func (m *ContactMutation) SetWxWxid(s string) {
  10642. m.wx_wxid = &s
  10643. }
  10644. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  10645. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  10646. v := m.wx_wxid
  10647. if v == nil {
  10648. return
  10649. }
  10650. return *v, true
  10651. }
  10652. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  10653. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10655. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  10656. if !m.op.Is(OpUpdateOne) {
  10657. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  10658. }
  10659. if m.id == nil || m.oldValue == nil {
  10660. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  10661. }
  10662. oldValue, err := m.oldValue(ctx)
  10663. if err != nil {
  10664. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  10665. }
  10666. return oldValue.WxWxid, nil
  10667. }
  10668. // ResetWxWxid resets all changes to the "wx_wxid" field.
  10669. func (m *ContactMutation) ResetWxWxid() {
  10670. m.wx_wxid = nil
  10671. }
  10672. // SetType sets the "type" field.
  10673. func (m *ContactMutation) SetType(i int) {
  10674. m._type = &i
  10675. m.add_type = nil
  10676. }
  10677. // GetType returns the value of the "type" field in the mutation.
  10678. func (m *ContactMutation) GetType() (r int, exists bool) {
  10679. v := m._type
  10680. if v == nil {
  10681. return
  10682. }
  10683. return *v, true
  10684. }
  10685. // OldType returns the old "type" field's value of the Contact entity.
  10686. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10688. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  10689. if !m.op.Is(OpUpdateOne) {
  10690. return v, errors.New("OldType is only allowed on UpdateOne operations")
  10691. }
  10692. if m.id == nil || m.oldValue == nil {
  10693. return v, errors.New("OldType requires an ID field in the mutation")
  10694. }
  10695. oldValue, err := m.oldValue(ctx)
  10696. if err != nil {
  10697. return v, fmt.Errorf("querying old value for OldType: %w", err)
  10698. }
  10699. return oldValue.Type, nil
  10700. }
  10701. // AddType adds i to the "type" field.
  10702. func (m *ContactMutation) AddType(i int) {
  10703. if m.add_type != nil {
  10704. *m.add_type += i
  10705. } else {
  10706. m.add_type = &i
  10707. }
  10708. }
  10709. // AddedType returns the value that was added to the "type" field in this mutation.
  10710. func (m *ContactMutation) AddedType() (r int, exists bool) {
  10711. v := m.add_type
  10712. if v == nil {
  10713. return
  10714. }
  10715. return *v, true
  10716. }
  10717. // ClearType clears the value of the "type" field.
  10718. func (m *ContactMutation) ClearType() {
  10719. m._type = nil
  10720. m.add_type = nil
  10721. m.clearedFields[contact.FieldType] = struct{}{}
  10722. }
  10723. // TypeCleared returns if the "type" field was cleared in this mutation.
  10724. func (m *ContactMutation) TypeCleared() bool {
  10725. _, ok := m.clearedFields[contact.FieldType]
  10726. return ok
  10727. }
  10728. // ResetType resets all changes to the "type" field.
  10729. func (m *ContactMutation) ResetType() {
  10730. m._type = nil
  10731. m.add_type = nil
  10732. delete(m.clearedFields, contact.FieldType)
  10733. }
  10734. // SetWxid sets the "wxid" field.
  10735. func (m *ContactMutation) SetWxid(s string) {
  10736. m.wxid = &s
  10737. }
  10738. // Wxid returns the value of the "wxid" field in the mutation.
  10739. func (m *ContactMutation) Wxid() (r string, exists bool) {
  10740. v := m.wxid
  10741. if v == nil {
  10742. return
  10743. }
  10744. return *v, true
  10745. }
  10746. // OldWxid returns the old "wxid" field's value of the Contact entity.
  10747. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10749. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  10750. if !m.op.Is(OpUpdateOne) {
  10751. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  10752. }
  10753. if m.id == nil || m.oldValue == nil {
  10754. return v, errors.New("OldWxid requires an ID field in the mutation")
  10755. }
  10756. oldValue, err := m.oldValue(ctx)
  10757. if err != nil {
  10758. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  10759. }
  10760. return oldValue.Wxid, nil
  10761. }
  10762. // ResetWxid resets all changes to the "wxid" field.
  10763. func (m *ContactMutation) ResetWxid() {
  10764. m.wxid = nil
  10765. }
  10766. // SetAccount sets the "account" field.
  10767. func (m *ContactMutation) SetAccount(s string) {
  10768. m.account = &s
  10769. }
  10770. // Account returns the value of the "account" field in the mutation.
  10771. func (m *ContactMutation) Account() (r string, exists bool) {
  10772. v := m.account
  10773. if v == nil {
  10774. return
  10775. }
  10776. return *v, true
  10777. }
  10778. // OldAccount returns the old "account" field's value of the Contact entity.
  10779. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10781. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  10782. if !m.op.Is(OpUpdateOne) {
  10783. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  10784. }
  10785. if m.id == nil || m.oldValue == nil {
  10786. return v, errors.New("OldAccount requires an ID field in the mutation")
  10787. }
  10788. oldValue, err := m.oldValue(ctx)
  10789. if err != nil {
  10790. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  10791. }
  10792. return oldValue.Account, nil
  10793. }
  10794. // ResetAccount resets all changes to the "account" field.
  10795. func (m *ContactMutation) ResetAccount() {
  10796. m.account = nil
  10797. }
  10798. // SetNickname sets the "nickname" field.
  10799. func (m *ContactMutation) SetNickname(s string) {
  10800. m.nickname = &s
  10801. }
  10802. // Nickname returns the value of the "nickname" field in the mutation.
  10803. func (m *ContactMutation) Nickname() (r string, exists bool) {
  10804. v := m.nickname
  10805. if v == nil {
  10806. return
  10807. }
  10808. return *v, true
  10809. }
  10810. // OldNickname returns the old "nickname" field's value of the Contact entity.
  10811. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10813. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  10814. if !m.op.Is(OpUpdateOne) {
  10815. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  10816. }
  10817. if m.id == nil || m.oldValue == nil {
  10818. return v, errors.New("OldNickname requires an ID field in the mutation")
  10819. }
  10820. oldValue, err := m.oldValue(ctx)
  10821. if err != nil {
  10822. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  10823. }
  10824. return oldValue.Nickname, nil
  10825. }
  10826. // ResetNickname resets all changes to the "nickname" field.
  10827. func (m *ContactMutation) ResetNickname() {
  10828. m.nickname = nil
  10829. }
  10830. // SetMarkname sets the "markname" field.
  10831. func (m *ContactMutation) SetMarkname(s string) {
  10832. m.markname = &s
  10833. }
  10834. // Markname returns the value of the "markname" field in the mutation.
  10835. func (m *ContactMutation) Markname() (r string, exists bool) {
  10836. v := m.markname
  10837. if v == nil {
  10838. return
  10839. }
  10840. return *v, true
  10841. }
  10842. // OldMarkname returns the old "markname" field's value of the Contact entity.
  10843. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10845. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  10846. if !m.op.Is(OpUpdateOne) {
  10847. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  10848. }
  10849. if m.id == nil || m.oldValue == nil {
  10850. return v, errors.New("OldMarkname requires an ID field in the mutation")
  10851. }
  10852. oldValue, err := m.oldValue(ctx)
  10853. if err != nil {
  10854. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  10855. }
  10856. return oldValue.Markname, nil
  10857. }
  10858. // ResetMarkname resets all changes to the "markname" field.
  10859. func (m *ContactMutation) ResetMarkname() {
  10860. m.markname = nil
  10861. }
  10862. // SetHeadimg sets the "headimg" field.
  10863. func (m *ContactMutation) SetHeadimg(s string) {
  10864. m.headimg = &s
  10865. }
  10866. // Headimg returns the value of the "headimg" field in the mutation.
  10867. func (m *ContactMutation) Headimg() (r string, exists bool) {
  10868. v := m.headimg
  10869. if v == nil {
  10870. return
  10871. }
  10872. return *v, true
  10873. }
  10874. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  10875. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10877. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  10878. if !m.op.Is(OpUpdateOne) {
  10879. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  10880. }
  10881. if m.id == nil || m.oldValue == nil {
  10882. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  10883. }
  10884. oldValue, err := m.oldValue(ctx)
  10885. if err != nil {
  10886. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  10887. }
  10888. return oldValue.Headimg, nil
  10889. }
  10890. // ResetHeadimg resets all changes to the "headimg" field.
  10891. func (m *ContactMutation) ResetHeadimg() {
  10892. m.headimg = nil
  10893. }
  10894. // SetSex sets the "sex" field.
  10895. func (m *ContactMutation) SetSex(i int) {
  10896. m.sex = &i
  10897. m.addsex = nil
  10898. }
  10899. // Sex returns the value of the "sex" field in the mutation.
  10900. func (m *ContactMutation) Sex() (r int, exists bool) {
  10901. v := m.sex
  10902. if v == nil {
  10903. return
  10904. }
  10905. return *v, true
  10906. }
  10907. // OldSex returns the old "sex" field's value of the Contact entity.
  10908. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10910. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  10911. if !m.op.Is(OpUpdateOne) {
  10912. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  10913. }
  10914. if m.id == nil || m.oldValue == nil {
  10915. return v, errors.New("OldSex requires an ID field in the mutation")
  10916. }
  10917. oldValue, err := m.oldValue(ctx)
  10918. if err != nil {
  10919. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  10920. }
  10921. return oldValue.Sex, nil
  10922. }
  10923. // AddSex adds i to the "sex" field.
  10924. func (m *ContactMutation) AddSex(i int) {
  10925. if m.addsex != nil {
  10926. *m.addsex += i
  10927. } else {
  10928. m.addsex = &i
  10929. }
  10930. }
  10931. // AddedSex returns the value that was added to the "sex" field in this mutation.
  10932. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  10933. v := m.addsex
  10934. if v == nil {
  10935. return
  10936. }
  10937. return *v, true
  10938. }
  10939. // ResetSex resets all changes to the "sex" field.
  10940. func (m *ContactMutation) ResetSex() {
  10941. m.sex = nil
  10942. m.addsex = nil
  10943. }
  10944. // SetStarrole sets the "starrole" field.
  10945. func (m *ContactMutation) SetStarrole(s string) {
  10946. m.starrole = &s
  10947. }
  10948. // Starrole returns the value of the "starrole" field in the mutation.
  10949. func (m *ContactMutation) Starrole() (r string, exists bool) {
  10950. v := m.starrole
  10951. if v == nil {
  10952. return
  10953. }
  10954. return *v, true
  10955. }
  10956. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  10957. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10959. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  10960. if !m.op.Is(OpUpdateOne) {
  10961. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  10962. }
  10963. if m.id == nil || m.oldValue == nil {
  10964. return v, errors.New("OldStarrole requires an ID field in the mutation")
  10965. }
  10966. oldValue, err := m.oldValue(ctx)
  10967. if err != nil {
  10968. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  10969. }
  10970. return oldValue.Starrole, nil
  10971. }
  10972. // ResetStarrole resets all changes to the "starrole" field.
  10973. func (m *ContactMutation) ResetStarrole() {
  10974. m.starrole = nil
  10975. }
  10976. // SetDontseeit sets the "dontseeit" field.
  10977. func (m *ContactMutation) SetDontseeit(i int) {
  10978. m.dontseeit = &i
  10979. m.adddontseeit = nil
  10980. }
  10981. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  10982. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  10983. v := m.dontseeit
  10984. if v == nil {
  10985. return
  10986. }
  10987. return *v, true
  10988. }
  10989. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  10990. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  10991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10992. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  10993. if !m.op.Is(OpUpdateOne) {
  10994. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  10995. }
  10996. if m.id == nil || m.oldValue == nil {
  10997. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  10998. }
  10999. oldValue, err := m.oldValue(ctx)
  11000. if err != nil {
  11001. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  11002. }
  11003. return oldValue.Dontseeit, nil
  11004. }
  11005. // AddDontseeit adds i to the "dontseeit" field.
  11006. func (m *ContactMutation) AddDontseeit(i int) {
  11007. if m.adddontseeit != nil {
  11008. *m.adddontseeit += i
  11009. } else {
  11010. m.adddontseeit = &i
  11011. }
  11012. }
  11013. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  11014. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  11015. v := m.adddontseeit
  11016. if v == nil {
  11017. return
  11018. }
  11019. return *v, true
  11020. }
  11021. // ResetDontseeit resets all changes to the "dontseeit" field.
  11022. func (m *ContactMutation) ResetDontseeit() {
  11023. m.dontseeit = nil
  11024. m.adddontseeit = nil
  11025. }
  11026. // SetDontseeme sets the "dontseeme" field.
  11027. func (m *ContactMutation) SetDontseeme(i int) {
  11028. m.dontseeme = &i
  11029. m.adddontseeme = nil
  11030. }
  11031. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  11032. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  11033. v := m.dontseeme
  11034. if v == nil {
  11035. return
  11036. }
  11037. return *v, true
  11038. }
  11039. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  11040. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11042. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  11043. if !m.op.Is(OpUpdateOne) {
  11044. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  11045. }
  11046. if m.id == nil || m.oldValue == nil {
  11047. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  11048. }
  11049. oldValue, err := m.oldValue(ctx)
  11050. if err != nil {
  11051. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  11052. }
  11053. return oldValue.Dontseeme, nil
  11054. }
  11055. // AddDontseeme adds i to the "dontseeme" field.
  11056. func (m *ContactMutation) AddDontseeme(i int) {
  11057. if m.adddontseeme != nil {
  11058. *m.adddontseeme += i
  11059. } else {
  11060. m.adddontseeme = &i
  11061. }
  11062. }
  11063. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  11064. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  11065. v := m.adddontseeme
  11066. if v == nil {
  11067. return
  11068. }
  11069. return *v, true
  11070. }
  11071. // ResetDontseeme resets all changes to the "dontseeme" field.
  11072. func (m *ContactMutation) ResetDontseeme() {
  11073. m.dontseeme = nil
  11074. m.adddontseeme = nil
  11075. }
  11076. // SetLag sets the "lag" field.
  11077. func (m *ContactMutation) SetLag(s string) {
  11078. m.lag = &s
  11079. }
  11080. // Lag returns the value of the "lag" field in the mutation.
  11081. func (m *ContactMutation) Lag() (r string, exists bool) {
  11082. v := m.lag
  11083. if v == nil {
  11084. return
  11085. }
  11086. return *v, true
  11087. }
  11088. // OldLag returns the old "lag" field's value of the Contact entity.
  11089. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11091. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  11092. if !m.op.Is(OpUpdateOne) {
  11093. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  11094. }
  11095. if m.id == nil || m.oldValue == nil {
  11096. return v, errors.New("OldLag requires an ID field in the mutation")
  11097. }
  11098. oldValue, err := m.oldValue(ctx)
  11099. if err != nil {
  11100. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  11101. }
  11102. return oldValue.Lag, nil
  11103. }
  11104. // ResetLag resets all changes to the "lag" field.
  11105. func (m *ContactMutation) ResetLag() {
  11106. m.lag = nil
  11107. }
  11108. // SetGid sets the "gid" field.
  11109. func (m *ContactMutation) SetGid(s string) {
  11110. m.gid = &s
  11111. }
  11112. // Gid returns the value of the "gid" field in the mutation.
  11113. func (m *ContactMutation) Gid() (r string, exists bool) {
  11114. v := m.gid
  11115. if v == nil {
  11116. return
  11117. }
  11118. return *v, true
  11119. }
  11120. // OldGid returns the old "gid" field's value of the Contact entity.
  11121. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11123. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  11124. if !m.op.Is(OpUpdateOne) {
  11125. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  11126. }
  11127. if m.id == nil || m.oldValue == nil {
  11128. return v, errors.New("OldGid requires an ID field in the mutation")
  11129. }
  11130. oldValue, err := m.oldValue(ctx)
  11131. if err != nil {
  11132. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  11133. }
  11134. return oldValue.Gid, nil
  11135. }
  11136. // ResetGid resets all changes to the "gid" field.
  11137. func (m *ContactMutation) ResetGid() {
  11138. m.gid = nil
  11139. }
  11140. // SetGname sets the "gname" field.
  11141. func (m *ContactMutation) SetGname(s string) {
  11142. m.gname = &s
  11143. }
  11144. // Gname returns the value of the "gname" field in the mutation.
  11145. func (m *ContactMutation) Gname() (r string, exists bool) {
  11146. v := m.gname
  11147. if v == nil {
  11148. return
  11149. }
  11150. return *v, true
  11151. }
  11152. // OldGname returns the old "gname" field's value of the Contact entity.
  11153. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11155. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  11156. if !m.op.Is(OpUpdateOne) {
  11157. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  11158. }
  11159. if m.id == nil || m.oldValue == nil {
  11160. return v, errors.New("OldGname requires an ID field in the mutation")
  11161. }
  11162. oldValue, err := m.oldValue(ctx)
  11163. if err != nil {
  11164. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  11165. }
  11166. return oldValue.Gname, nil
  11167. }
  11168. // ResetGname resets all changes to the "gname" field.
  11169. func (m *ContactMutation) ResetGname() {
  11170. m.gname = nil
  11171. }
  11172. // SetV3 sets the "v3" field.
  11173. func (m *ContactMutation) SetV3(s string) {
  11174. m.v3 = &s
  11175. }
  11176. // V3 returns the value of the "v3" field in the mutation.
  11177. func (m *ContactMutation) V3() (r string, exists bool) {
  11178. v := m.v3
  11179. if v == nil {
  11180. return
  11181. }
  11182. return *v, true
  11183. }
  11184. // OldV3 returns the old "v3" field's value of the Contact entity.
  11185. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11187. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  11188. if !m.op.Is(OpUpdateOne) {
  11189. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  11190. }
  11191. if m.id == nil || m.oldValue == nil {
  11192. return v, errors.New("OldV3 requires an ID field in the mutation")
  11193. }
  11194. oldValue, err := m.oldValue(ctx)
  11195. if err != nil {
  11196. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  11197. }
  11198. return oldValue.V3, nil
  11199. }
  11200. // ResetV3 resets all changes to the "v3" field.
  11201. func (m *ContactMutation) ResetV3() {
  11202. m.v3 = nil
  11203. }
  11204. // SetOrganizationID sets the "organization_id" field.
  11205. func (m *ContactMutation) SetOrganizationID(u uint64) {
  11206. m.organization_id = &u
  11207. m.addorganization_id = nil
  11208. }
  11209. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11210. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  11211. v := m.organization_id
  11212. if v == nil {
  11213. return
  11214. }
  11215. return *v, true
  11216. }
  11217. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  11218. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11220. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11221. if !m.op.Is(OpUpdateOne) {
  11222. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11223. }
  11224. if m.id == nil || m.oldValue == nil {
  11225. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11226. }
  11227. oldValue, err := m.oldValue(ctx)
  11228. if err != nil {
  11229. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11230. }
  11231. return oldValue.OrganizationID, nil
  11232. }
  11233. // AddOrganizationID adds u to the "organization_id" field.
  11234. func (m *ContactMutation) AddOrganizationID(u int64) {
  11235. if m.addorganization_id != nil {
  11236. *m.addorganization_id += u
  11237. } else {
  11238. m.addorganization_id = &u
  11239. }
  11240. }
  11241. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11242. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  11243. v := m.addorganization_id
  11244. if v == nil {
  11245. return
  11246. }
  11247. return *v, true
  11248. }
  11249. // ClearOrganizationID clears the value of the "organization_id" field.
  11250. func (m *ContactMutation) ClearOrganizationID() {
  11251. m.organization_id = nil
  11252. m.addorganization_id = nil
  11253. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  11254. }
  11255. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11256. func (m *ContactMutation) OrganizationIDCleared() bool {
  11257. _, ok := m.clearedFields[contact.FieldOrganizationID]
  11258. return ok
  11259. }
  11260. // ResetOrganizationID resets all changes to the "organization_id" field.
  11261. func (m *ContactMutation) ResetOrganizationID() {
  11262. m.organization_id = nil
  11263. m.addorganization_id = nil
  11264. delete(m.clearedFields, contact.FieldOrganizationID)
  11265. }
  11266. // SetCtype sets the "ctype" field.
  11267. func (m *ContactMutation) SetCtype(u uint64) {
  11268. m.ctype = &u
  11269. m.addctype = nil
  11270. }
  11271. // Ctype returns the value of the "ctype" field in the mutation.
  11272. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  11273. v := m.ctype
  11274. if v == nil {
  11275. return
  11276. }
  11277. return *v, true
  11278. }
  11279. // OldCtype returns the old "ctype" field's value of the Contact entity.
  11280. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11282. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  11283. if !m.op.Is(OpUpdateOne) {
  11284. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  11285. }
  11286. if m.id == nil || m.oldValue == nil {
  11287. return v, errors.New("OldCtype requires an ID field in the mutation")
  11288. }
  11289. oldValue, err := m.oldValue(ctx)
  11290. if err != nil {
  11291. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  11292. }
  11293. return oldValue.Ctype, nil
  11294. }
  11295. // AddCtype adds u to the "ctype" field.
  11296. func (m *ContactMutation) AddCtype(u int64) {
  11297. if m.addctype != nil {
  11298. *m.addctype += u
  11299. } else {
  11300. m.addctype = &u
  11301. }
  11302. }
  11303. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  11304. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  11305. v := m.addctype
  11306. if v == nil {
  11307. return
  11308. }
  11309. return *v, true
  11310. }
  11311. // ResetCtype resets all changes to the "ctype" field.
  11312. func (m *ContactMutation) ResetCtype() {
  11313. m.ctype = nil
  11314. m.addctype = nil
  11315. }
  11316. // SetCage sets the "cage" field.
  11317. func (m *ContactMutation) SetCage(i int) {
  11318. m.cage = &i
  11319. m.addcage = nil
  11320. }
  11321. // Cage returns the value of the "cage" field in the mutation.
  11322. func (m *ContactMutation) Cage() (r int, exists bool) {
  11323. v := m.cage
  11324. if v == nil {
  11325. return
  11326. }
  11327. return *v, true
  11328. }
  11329. // OldCage returns the old "cage" field's value of the Contact entity.
  11330. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11332. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  11333. if !m.op.Is(OpUpdateOne) {
  11334. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  11335. }
  11336. if m.id == nil || m.oldValue == nil {
  11337. return v, errors.New("OldCage requires an ID field in the mutation")
  11338. }
  11339. oldValue, err := m.oldValue(ctx)
  11340. if err != nil {
  11341. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  11342. }
  11343. return oldValue.Cage, nil
  11344. }
  11345. // AddCage adds i to the "cage" field.
  11346. func (m *ContactMutation) AddCage(i int) {
  11347. if m.addcage != nil {
  11348. *m.addcage += i
  11349. } else {
  11350. m.addcage = &i
  11351. }
  11352. }
  11353. // AddedCage returns the value that was added to the "cage" field in this mutation.
  11354. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  11355. v := m.addcage
  11356. if v == nil {
  11357. return
  11358. }
  11359. return *v, true
  11360. }
  11361. // ResetCage resets all changes to the "cage" field.
  11362. func (m *ContactMutation) ResetCage() {
  11363. m.cage = nil
  11364. m.addcage = nil
  11365. }
  11366. // SetCname sets the "cname" field.
  11367. func (m *ContactMutation) SetCname(s string) {
  11368. m.cname = &s
  11369. }
  11370. // Cname returns the value of the "cname" field in the mutation.
  11371. func (m *ContactMutation) Cname() (r string, exists bool) {
  11372. v := m.cname
  11373. if v == nil {
  11374. return
  11375. }
  11376. return *v, true
  11377. }
  11378. // OldCname returns the old "cname" field's value of the Contact entity.
  11379. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11381. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  11382. if !m.op.Is(OpUpdateOne) {
  11383. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  11384. }
  11385. if m.id == nil || m.oldValue == nil {
  11386. return v, errors.New("OldCname requires an ID field in the mutation")
  11387. }
  11388. oldValue, err := m.oldValue(ctx)
  11389. if err != nil {
  11390. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  11391. }
  11392. return oldValue.Cname, nil
  11393. }
  11394. // ResetCname resets all changes to the "cname" field.
  11395. func (m *ContactMutation) ResetCname() {
  11396. m.cname = nil
  11397. }
  11398. // SetCarea sets the "carea" field.
  11399. func (m *ContactMutation) SetCarea(s string) {
  11400. m.carea = &s
  11401. }
  11402. // Carea returns the value of the "carea" field in the mutation.
  11403. func (m *ContactMutation) Carea() (r string, exists bool) {
  11404. v := m.carea
  11405. if v == nil {
  11406. return
  11407. }
  11408. return *v, true
  11409. }
  11410. // OldCarea returns the old "carea" field's value of the Contact entity.
  11411. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11413. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  11414. if !m.op.Is(OpUpdateOne) {
  11415. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  11416. }
  11417. if m.id == nil || m.oldValue == nil {
  11418. return v, errors.New("OldCarea requires an ID field in the mutation")
  11419. }
  11420. oldValue, err := m.oldValue(ctx)
  11421. if err != nil {
  11422. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  11423. }
  11424. return oldValue.Carea, nil
  11425. }
  11426. // ResetCarea resets all changes to the "carea" field.
  11427. func (m *ContactMutation) ResetCarea() {
  11428. m.carea = nil
  11429. }
  11430. // SetCbirthday sets the "cbirthday" field.
  11431. func (m *ContactMutation) SetCbirthday(s string) {
  11432. m.cbirthday = &s
  11433. }
  11434. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  11435. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  11436. v := m.cbirthday
  11437. if v == nil {
  11438. return
  11439. }
  11440. return *v, true
  11441. }
  11442. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  11443. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11445. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  11446. if !m.op.Is(OpUpdateOne) {
  11447. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  11448. }
  11449. if m.id == nil || m.oldValue == nil {
  11450. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  11451. }
  11452. oldValue, err := m.oldValue(ctx)
  11453. if err != nil {
  11454. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  11455. }
  11456. return oldValue.Cbirthday, nil
  11457. }
  11458. // ResetCbirthday resets all changes to the "cbirthday" field.
  11459. func (m *ContactMutation) ResetCbirthday() {
  11460. m.cbirthday = nil
  11461. }
  11462. // SetCbirtharea sets the "cbirtharea" field.
  11463. func (m *ContactMutation) SetCbirtharea(s string) {
  11464. m.cbirtharea = &s
  11465. }
  11466. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  11467. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  11468. v := m.cbirtharea
  11469. if v == nil {
  11470. return
  11471. }
  11472. return *v, true
  11473. }
  11474. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  11475. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11477. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  11478. if !m.op.Is(OpUpdateOne) {
  11479. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  11480. }
  11481. if m.id == nil || m.oldValue == nil {
  11482. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  11483. }
  11484. oldValue, err := m.oldValue(ctx)
  11485. if err != nil {
  11486. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  11487. }
  11488. return oldValue.Cbirtharea, nil
  11489. }
  11490. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  11491. func (m *ContactMutation) ResetCbirtharea() {
  11492. m.cbirtharea = nil
  11493. }
  11494. // SetCidcardNo sets the "cidcard_no" field.
  11495. func (m *ContactMutation) SetCidcardNo(s string) {
  11496. m.cidcard_no = &s
  11497. }
  11498. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  11499. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  11500. v := m.cidcard_no
  11501. if v == nil {
  11502. return
  11503. }
  11504. return *v, true
  11505. }
  11506. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  11507. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11509. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  11510. if !m.op.Is(OpUpdateOne) {
  11511. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  11512. }
  11513. if m.id == nil || m.oldValue == nil {
  11514. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  11515. }
  11516. oldValue, err := m.oldValue(ctx)
  11517. if err != nil {
  11518. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  11519. }
  11520. return oldValue.CidcardNo, nil
  11521. }
  11522. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  11523. func (m *ContactMutation) ResetCidcardNo() {
  11524. m.cidcard_no = nil
  11525. }
  11526. // SetCtitle sets the "ctitle" field.
  11527. func (m *ContactMutation) SetCtitle(s string) {
  11528. m.ctitle = &s
  11529. }
  11530. // Ctitle returns the value of the "ctitle" field in the mutation.
  11531. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  11532. v := m.ctitle
  11533. if v == nil {
  11534. return
  11535. }
  11536. return *v, true
  11537. }
  11538. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  11539. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11541. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  11542. if !m.op.Is(OpUpdateOne) {
  11543. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  11544. }
  11545. if m.id == nil || m.oldValue == nil {
  11546. return v, errors.New("OldCtitle requires an ID field in the mutation")
  11547. }
  11548. oldValue, err := m.oldValue(ctx)
  11549. if err != nil {
  11550. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  11551. }
  11552. return oldValue.Ctitle, nil
  11553. }
  11554. // ResetCtitle resets all changes to the "ctitle" field.
  11555. func (m *ContactMutation) ResetCtitle() {
  11556. m.ctitle = nil
  11557. }
  11558. // SetCc sets the "cc" field.
  11559. func (m *ContactMutation) SetCc(s string) {
  11560. m.cc = &s
  11561. }
  11562. // Cc returns the value of the "cc" field in the mutation.
  11563. func (m *ContactMutation) Cc() (r string, exists bool) {
  11564. v := m.cc
  11565. if v == nil {
  11566. return
  11567. }
  11568. return *v, true
  11569. }
  11570. // OldCc returns the old "cc" field's value of the Contact entity.
  11571. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11573. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  11574. if !m.op.Is(OpUpdateOne) {
  11575. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  11576. }
  11577. if m.id == nil || m.oldValue == nil {
  11578. return v, errors.New("OldCc requires an ID field in the mutation")
  11579. }
  11580. oldValue, err := m.oldValue(ctx)
  11581. if err != nil {
  11582. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  11583. }
  11584. return oldValue.Cc, nil
  11585. }
  11586. // ResetCc resets all changes to the "cc" field.
  11587. func (m *ContactMutation) ResetCc() {
  11588. m.cc = nil
  11589. }
  11590. // SetPhone sets the "phone" field.
  11591. func (m *ContactMutation) SetPhone(s string) {
  11592. m.phone = &s
  11593. }
  11594. // Phone returns the value of the "phone" field in the mutation.
  11595. func (m *ContactMutation) Phone() (r string, exists bool) {
  11596. v := m.phone
  11597. if v == nil {
  11598. return
  11599. }
  11600. return *v, true
  11601. }
  11602. // OldPhone returns the old "phone" field's value of the Contact entity.
  11603. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  11604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11605. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  11606. if !m.op.Is(OpUpdateOne) {
  11607. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  11608. }
  11609. if m.id == nil || m.oldValue == nil {
  11610. return v, errors.New("OldPhone requires an ID field in the mutation")
  11611. }
  11612. oldValue, err := m.oldValue(ctx)
  11613. if err != nil {
  11614. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  11615. }
  11616. return oldValue.Phone, nil
  11617. }
  11618. // ResetPhone resets all changes to the "phone" field.
  11619. func (m *ContactMutation) ResetPhone() {
  11620. m.phone = nil
  11621. }
  11622. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  11623. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  11624. if m.contact_relationships == nil {
  11625. m.contact_relationships = make(map[uint64]struct{})
  11626. }
  11627. for i := range ids {
  11628. m.contact_relationships[ids[i]] = struct{}{}
  11629. }
  11630. }
  11631. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  11632. func (m *ContactMutation) ClearContactRelationships() {
  11633. m.clearedcontact_relationships = true
  11634. }
  11635. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  11636. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  11637. return m.clearedcontact_relationships
  11638. }
  11639. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  11640. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  11641. if m.removedcontact_relationships == nil {
  11642. m.removedcontact_relationships = make(map[uint64]struct{})
  11643. }
  11644. for i := range ids {
  11645. delete(m.contact_relationships, ids[i])
  11646. m.removedcontact_relationships[ids[i]] = struct{}{}
  11647. }
  11648. }
  11649. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  11650. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  11651. for id := range m.removedcontact_relationships {
  11652. ids = append(ids, id)
  11653. }
  11654. return
  11655. }
  11656. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  11657. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  11658. for id := range m.contact_relationships {
  11659. ids = append(ids, id)
  11660. }
  11661. return
  11662. }
  11663. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  11664. func (m *ContactMutation) ResetContactRelationships() {
  11665. m.contact_relationships = nil
  11666. m.clearedcontact_relationships = false
  11667. m.removedcontact_relationships = nil
  11668. }
  11669. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  11670. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  11671. if m.contact_messages == nil {
  11672. m.contact_messages = make(map[uint64]struct{})
  11673. }
  11674. for i := range ids {
  11675. m.contact_messages[ids[i]] = struct{}{}
  11676. }
  11677. }
  11678. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  11679. func (m *ContactMutation) ClearContactMessages() {
  11680. m.clearedcontact_messages = true
  11681. }
  11682. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  11683. func (m *ContactMutation) ContactMessagesCleared() bool {
  11684. return m.clearedcontact_messages
  11685. }
  11686. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  11687. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  11688. if m.removedcontact_messages == nil {
  11689. m.removedcontact_messages = make(map[uint64]struct{})
  11690. }
  11691. for i := range ids {
  11692. delete(m.contact_messages, ids[i])
  11693. m.removedcontact_messages[ids[i]] = struct{}{}
  11694. }
  11695. }
  11696. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  11697. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  11698. for id := range m.removedcontact_messages {
  11699. ids = append(ids, id)
  11700. }
  11701. return
  11702. }
  11703. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  11704. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  11705. for id := range m.contact_messages {
  11706. ids = append(ids, id)
  11707. }
  11708. return
  11709. }
  11710. // ResetContactMessages resets all changes to the "contact_messages" edge.
  11711. func (m *ContactMutation) ResetContactMessages() {
  11712. m.contact_messages = nil
  11713. m.clearedcontact_messages = false
  11714. m.removedcontact_messages = nil
  11715. }
  11716. // Where appends a list predicates to the ContactMutation builder.
  11717. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  11718. m.predicates = append(m.predicates, ps...)
  11719. }
  11720. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  11721. // users can use type-assertion to append predicates that do not depend on any generated package.
  11722. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  11723. p := make([]predicate.Contact, len(ps))
  11724. for i := range ps {
  11725. p[i] = ps[i]
  11726. }
  11727. m.Where(p...)
  11728. }
  11729. // Op returns the operation name.
  11730. func (m *ContactMutation) Op() Op {
  11731. return m.op
  11732. }
  11733. // SetOp allows setting the mutation operation.
  11734. func (m *ContactMutation) SetOp(op Op) {
  11735. m.op = op
  11736. }
  11737. // Type returns the node type of this mutation (Contact).
  11738. func (m *ContactMutation) Type() string {
  11739. return m.typ
  11740. }
  11741. // Fields returns all fields that were changed during this mutation. Note that in
  11742. // order to get all numeric fields that were incremented/decremented, call
  11743. // AddedFields().
  11744. func (m *ContactMutation) Fields() []string {
  11745. fields := make([]string, 0, 30)
  11746. if m.created_at != nil {
  11747. fields = append(fields, contact.FieldCreatedAt)
  11748. }
  11749. if m.updated_at != nil {
  11750. fields = append(fields, contact.FieldUpdatedAt)
  11751. }
  11752. if m.status != nil {
  11753. fields = append(fields, contact.FieldStatus)
  11754. }
  11755. if m.deleted_at != nil {
  11756. fields = append(fields, contact.FieldDeletedAt)
  11757. }
  11758. if m.wx_wxid != nil {
  11759. fields = append(fields, contact.FieldWxWxid)
  11760. }
  11761. if m._type != nil {
  11762. fields = append(fields, contact.FieldType)
  11763. }
  11764. if m.wxid != nil {
  11765. fields = append(fields, contact.FieldWxid)
  11766. }
  11767. if m.account != nil {
  11768. fields = append(fields, contact.FieldAccount)
  11769. }
  11770. if m.nickname != nil {
  11771. fields = append(fields, contact.FieldNickname)
  11772. }
  11773. if m.markname != nil {
  11774. fields = append(fields, contact.FieldMarkname)
  11775. }
  11776. if m.headimg != nil {
  11777. fields = append(fields, contact.FieldHeadimg)
  11778. }
  11779. if m.sex != nil {
  11780. fields = append(fields, contact.FieldSex)
  11781. }
  11782. if m.starrole != nil {
  11783. fields = append(fields, contact.FieldStarrole)
  11784. }
  11785. if m.dontseeit != nil {
  11786. fields = append(fields, contact.FieldDontseeit)
  11787. }
  11788. if m.dontseeme != nil {
  11789. fields = append(fields, contact.FieldDontseeme)
  11790. }
  11791. if m.lag != nil {
  11792. fields = append(fields, contact.FieldLag)
  11793. }
  11794. if m.gid != nil {
  11795. fields = append(fields, contact.FieldGid)
  11796. }
  11797. if m.gname != nil {
  11798. fields = append(fields, contact.FieldGname)
  11799. }
  11800. if m.v3 != nil {
  11801. fields = append(fields, contact.FieldV3)
  11802. }
  11803. if m.organization_id != nil {
  11804. fields = append(fields, contact.FieldOrganizationID)
  11805. }
  11806. if m.ctype != nil {
  11807. fields = append(fields, contact.FieldCtype)
  11808. }
  11809. if m.cage != nil {
  11810. fields = append(fields, contact.FieldCage)
  11811. }
  11812. if m.cname != nil {
  11813. fields = append(fields, contact.FieldCname)
  11814. }
  11815. if m.carea != nil {
  11816. fields = append(fields, contact.FieldCarea)
  11817. }
  11818. if m.cbirthday != nil {
  11819. fields = append(fields, contact.FieldCbirthday)
  11820. }
  11821. if m.cbirtharea != nil {
  11822. fields = append(fields, contact.FieldCbirtharea)
  11823. }
  11824. if m.cidcard_no != nil {
  11825. fields = append(fields, contact.FieldCidcardNo)
  11826. }
  11827. if m.ctitle != nil {
  11828. fields = append(fields, contact.FieldCtitle)
  11829. }
  11830. if m.cc != nil {
  11831. fields = append(fields, contact.FieldCc)
  11832. }
  11833. if m.phone != nil {
  11834. fields = append(fields, contact.FieldPhone)
  11835. }
  11836. return fields
  11837. }
  11838. // Field returns the value of a field with the given name. The second boolean
  11839. // return value indicates that this field was not set, or was not defined in the
  11840. // schema.
  11841. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  11842. switch name {
  11843. case contact.FieldCreatedAt:
  11844. return m.CreatedAt()
  11845. case contact.FieldUpdatedAt:
  11846. return m.UpdatedAt()
  11847. case contact.FieldStatus:
  11848. return m.Status()
  11849. case contact.FieldDeletedAt:
  11850. return m.DeletedAt()
  11851. case contact.FieldWxWxid:
  11852. return m.WxWxid()
  11853. case contact.FieldType:
  11854. return m.GetType()
  11855. case contact.FieldWxid:
  11856. return m.Wxid()
  11857. case contact.FieldAccount:
  11858. return m.Account()
  11859. case contact.FieldNickname:
  11860. return m.Nickname()
  11861. case contact.FieldMarkname:
  11862. return m.Markname()
  11863. case contact.FieldHeadimg:
  11864. return m.Headimg()
  11865. case contact.FieldSex:
  11866. return m.Sex()
  11867. case contact.FieldStarrole:
  11868. return m.Starrole()
  11869. case contact.FieldDontseeit:
  11870. return m.Dontseeit()
  11871. case contact.FieldDontseeme:
  11872. return m.Dontseeme()
  11873. case contact.FieldLag:
  11874. return m.Lag()
  11875. case contact.FieldGid:
  11876. return m.Gid()
  11877. case contact.FieldGname:
  11878. return m.Gname()
  11879. case contact.FieldV3:
  11880. return m.V3()
  11881. case contact.FieldOrganizationID:
  11882. return m.OrganizationID()
  11883. case contact.FieldCtype:
  11884. return m.Ctype()
  11885. case contact.FieldCage:
  11886. return m.Cage()
  11887. case contact.FieldCname:
  11888. return m.Cname()
  11889. case contact.FieldCarea:
  11890. return m.Carea()
  11891. case contact.FieldCbirthday:
  11892. return m.Cbirthday()
  11893. case contact.FieldCbirtharea:
  11894. return m.Cbirtharea()
  11895. case contact.FieldCidcardNo:
  11896. return m.CidcardNo()
  11897. case contact.FieldCtitle:
  11898. return m.Ctitle()
  11899. case contact.FieldCc:
  11900. return m.Cc()
  11901. case contact.FieldPhone:
  11902. return m.Phone()
  11903. }
  11904. return nil, false
  11905. }
  11906. // OldField returns the old value of the field from the database. An error is
  11907. // returned if the mutation operation is not UpdateOne, or the query to the
  11908. // database failed.
  11909. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11910. switch name {
  11911. case contact.FieldCreatedAt:
  11912. return m.OldCreatedAt(ctx)
  11913. case contact.FieldUpdatedAt:
  11914. return m.OldUpdatedAt(ctx)
  11915. case contact.FieldStatus:
  11916. return m.OldStatus(ctx)
  11917. case contact.FieldDeletedAt:
  11918. return m.OldDeletedAt(ctx)
  11919. case contact.FieldWxWxid:
  11920. return m.OldWxWxid(ctx)
  11921. case contact.FieldType:
  11922. return m.OldType(ctx)
  11923. case contact.FieldWxid:
  11924. return m.OldWxid(ctx)
  11925. case contact.FieldAccount:
  11926. return m.OldAccount(ctx)
  11927. case contact.FieldNickname:
  11928. return m.OldNickname(ctx)
  11929. case contact.FieldMarkname:
  11930. return m.OldMarkname(ctx)
  11931. case contact.FieldHeadimg:
  11932. return m.OldHeadimg(ctx)
  11933. case contact.FieldSex:
  11934. return m.OldSex(ctx)
  11935. case contact.FieldStarrole:
  11936. return m.OldStarrole(ctx)
  11937. case contact.FieldDontseeit:
  11938. return m.OldDontseeit(ctx)
  11939. case contact.FieldDontseeme:
  11940. return m.OldDontseeme(ctx)
  11941. case contact.FieldLag:
  11942. return m.OldLag(ctx)
  11943. case contact.FieldGid:
  11944. return m.OldGid(ctx)
  11945. case contact.FieldGname:
  11946. return m.OldGname(ctx)
  11947. case contact.FieldV3:
  11948. return m.OldV3(ctx)
  11949. case contact.FieldOrganizationID:
  11950. return m.OldOrganizationID(ctx)
  11951. case contact.FieldCtype:
  11952. return m.OldCtype(ctx)
  11953. case contact.FieldCage:
  11954. return m.OldCage(ctx)
  11955. case contact.FieldCname:
  11956. return m.OldCname(ctx)
  11957. case contact.FieldCarea:
  11958. return m.OldCarea(ctx)
  11959. case contact.FieldCbirthday:
  11960. return m.OldCbirthday(ctx)
  11961. case contact.FieldCbirtharea:
  11962. return m.OldCbirtharea(ctx)
  11963. case contact.FieldCidcardNo:
  11964. return m.OldCidcardNo(ctx)
  11965. case contact.FieldCtitle:
  11966. return m.OldCtitle(ctx)
  11967. case contact.FieldCc:
  11968. return m.OldCc(ctx)
  11969. case contact.FieldPhone:
  11970. return m.OldPhone(ctx)
  11971. }
  11972. return nil, fmt.Errorf("unknown Contact field %s", name)
  11973. }
  11974. // SetField sets the value of a field with the given name. It returns an error if
  11975. // the field is not defined in the schema, or if the type mismatched the field
  11976. // type.
  11977. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  11978. switch name {
  11979. case contact.FieldCreatedAt:
  11980. v, ok := value.(time.Time)
  11981. if !ok {
  11982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11983. }
  11984. m.SetCreatedAt(v)
  11985. return nil
  11986. case contact.FieldUpdatedAt:
  11987. v, ok := value.(time.Time)
  11988. if !ok {
  11989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11990. }
  11991. m.SetUpdatedAt(v)
  11992. return nil
  11993. case contact.FieldStatus:
  11994. v, ok := value.(uint8)
  11995. if !ok {
  11996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11997. }
  11998. m.SetStatus(v)
  11999. return nil
  12000. case contact.FieldDeletedAt:
  12001. v, ok := value.(time.Time)
  12002. if !ok {
  12003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12004. }
  12005. m.SetDeletedAt(v)
  12006. return nil
  12007. case contact.FieldWxWxid:
  12008. v, ok := value.(string)
  12009. if !ok {
  12010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12011. }
  12012. m.SetWxWxid(v)
  12013. return nil
  12014. case contact.FieldType:
  12015. v, ok := value.(int)
  12016. if !ok {
  12017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12018. }
  12019. m.SetType(v)
  12020. return nil
  12021. case contact.FieldWxid:
  12022. v, ok := value.(string)
  12023. if !ok {
  12024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12025. }
  12026. m.SetWxid(v)
  12027. return nil
  12028. case contact.FieldAccount:
  12029. v, ok := value.(string)
  12030. if !ok {
  12031. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12032. }
  12033. m.SetAccount(v)
  12034. return nil
  12035. case contact.FieldNickname:
  12036. v, ok := value.(string)
  12037. if !ok {
  12038. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12039. }
  12040. m.SetNickname(v)
  12041. return nil
  12042. case contact.FieldMarkname:
  12043. v, ok := value.(string)
  12044. if !ok {
  12045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12046. }
  12047. m.SetMarkname(v)
  12048. return nil
  12049. case contact.FieldHeadimg:
  12050. v, ok := value.(string)
  12051. if !ok {
  12052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12053. }
  12054. m.SetHeadimg(v)
  12055. return nil
  12056. case contact.FieldSex:
  12057. v, ok := value.(int)
  12058. if !ok {
  12059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12060. }
  12061. m.SetSex(v)
  12062. return nil
  12063. case contact.FieldStarrole:
  12064. v, ok := value.(string)
  12065. if !ok {
  12066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12067. }
  12068. m.SetStarrole(v)
  12069. return nil
  12070. case contact.FieldDontseeit:
  12071. v, ok := value.(int)
  12072. if !ok {
  12073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12074. }
  12075. m.SetDontseeit(v)
  12076. return nil
  12077. case contact.FieldDontseeme:
  12078. v, ok := value.(int)
  12079. if !ok {
  12080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12081. }
  12082. m.SetDontseeme(v)
  12083. return nil
  12084. case contact.FieldLag:
  12085. v, ok := value.(string)
  12086. if !ok {
  12087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12088. }
  12089. m.SetLag(v)
  12090. return nil
  12091. case contact.FieldGid:
  12092. v, ok := value.(string)
  12093. if !ok {
  12094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12095. }
  12096. m.SetGid(v)
  12097. return nil
  12098. case contact.FieldGname:
  12099. v, ok := value.(string)
  12100. if !ok {
  12101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12102. }
  12103. m.SetGname(v)
  12104. return nil
  12105. case contact.FieldV3:
  12106. v, ok := value.(string)
  12107. if !ok {
  12108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12109. }
  12110. m.SetV3(v)
  12111. return nil
  12112. case contact.FieldOrganizationID:
  12113. v, ok := value.(uint64)
  12114. if !ok {
  12115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12116. }
  12117. m.SetOrganizationID(v)
  12118. return nil
  12119. case contact.FieldCtype:
  12120. v, ok := value.(uint64)
  12121. if !ok {
  12122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12123. }
  12124. m.SetCtype(v)
  12125. return nil
  12126. case contact.FieldCage:
  12127. v, ok := value.(int)
  12128. if !ok {
  12129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12130. }
  12131. m.SetCage(v)
  12132. return nil
  12133. case contact.FieldCname:
  12134. v, ok := value.(string)
  12135. if !ok {
  12136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12137. }
  12138. m.SetCname(v)
  12139. return nil
  12140. case contact.FieldCarea:
  12141. v, ok := value.(string)
  12142. if !ok {
  12143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12144. }
  12145. m.SetCarea(v)
  12146. return nil
  12147. case contact.FieldCbirthday:
  12148. v, ok := value.(string)
  12149. if !ok {
  12150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12151. }
  12152. m.SetCbirthday(v)
  12153. return nil
  12154. case contact.FieldCbirtharea:
  12155. v, ok := value.(string)
  12156. if !ok {
  12157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12158. }
  12159. m.SetCbirtharea(v)
  12160. return nil
  12161. case contact.FieldCidcardNo:
  12162. v, ok := value.(string)
  12163. if !ok {
  12164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12165. }
  12166. m.SetCidcardNo(v)
  12167. return nil
  12168. case contact.FieldCtitle:
  12169. v, ok := value.(string)
  12170. if !ok {
  12171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12172. }
  12173. m.SetCtitle(v)
  12174. return nil
  12175. case contact.FieldCc:
  12176. v, ok := value.(string)
  12177. if !ok {
  12178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12179. }
  12180. m.SetCc(v)
  12181. return nil
  12182. case contact.FieldPhone:
  12183. v, ok := value.(string)
  12184. if !ok {
  12185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12186. }
  12187. m.SetPhone(v)
  12188. return nil
  12189. }
  12190. return fmt.Errorf("unknown Contact field %s", name)
  12191. }
  12192. // AddedFields returns all numeric fields that were incremented/decremented during
  12193. // this mutation.
  12194. func (m *ContactMutation) AddedFields() []string {
  12195. var fields []string
  12196. if m.addstatus != nil {
  12197. fields = append(fields, contact.FieldStatus)
  12198. }
  12199. if m.add_type != nil {
  12200. fields = append(fields, contact.FieldType)
  12201. }
  12202. if m.addsex != nil {
  12203. fields = append(fields, contact.FieldSex)
  12204. }
  12205. if m.adddontseeit != nil {
  12206. fields = append(fields, contact.FieldDontseeit)
  12207. }
  12208. if m.adddontseeme != nil {
  12209. fields = append(fields, contact.FieldDontseeme)
  12210. }
  12211. if m.addorganization_id != nil {
  12212. fields = append(fields, contact.FieldOrganizationID)
  12213. }
  12214. if m.addctype != nil {
  12215. fields = append(fields, contact.FieldCtype)
  12216. }
  12217. if m.addcage != nil {
  12218. fields = append(fields, contact.FieldCage)
  12219. }
  12220. return fields
  12221. }
  12222. // AddedField returns the numeric value that was incremented/decremented on a field
  12223. // with the given name. The second boolean return value indicates that this field
  12224. // was not set, or was not defined in the schema.
  12225. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  12226. switch name {
  12227. case contact.FieldStatus:
  12228. return m.AddedStatus()
  12229. case contact.FieldType:
  12230. return m.AddedType()
  12231. case contact.FieldSex:
  12232. return m.AddedSex()
  12233. case contact.FieldDontseeit:
  12234. return m.AddedDontseeit()
  12235. case contact.FieldDontseeme:
  12236. return m.AddedDontseeme()
  12237. case contact.FieldOrganizationID:
  12238. return m.AddedOrganizationID()
  12239. case contact.FieldCtype:
  12240. return m.AddedCtype()
  12241. case contact.FieldCage:
  12242. return m.AddedCage()
  12243. }
  12244. return nil, false
  12245. }
  12246. // AddField adds the value to the field with the given name. It returns an error if
  12247. // the field is not defined in the schema, or if the type mismatched the field
  12248. // type.
  12249. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  12250. switch name {
  12251. case contact.FieldStatus:
  12252. v, ok := value.(int8)
  12253. if !ok {
  12254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12255. }
  12256. m.AddStatus(v)
  12257. return nil
  12258. case contact.FieldType:
  12259. v, ok := value.(int)
  12260. if !ok {
  12261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12262. }
  12263. m.AddType(v)
  12264. return nil
  12265. case contact.FieldSex:
  12266. v, ok := value.(int)
  12267. if !ok {
  12268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12269. }
  12270. m.AddSex(v)
  12271. return nil
  12272. case contact.FieldDontseeit:
  12273. v, ok := value.(int)
  12274. if !ok {
  12275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12276. }
  12277. m.AddDontseeit(v)
  12278. return nil
  12279. case contact.FieldDontseeme:
  12280. v, ok := value.(int)
  12281. if !ok {
  12282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12283. }
  12284. m.AddDontseeme(v)
  12285. return nil
  12286. case contact.FieldOrganizationID:
  12287. v, ok := value.(int64)
  12288. if !ok {
  12289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12290. }
  12291. m.AddOrganizationID(v)
  12292. return nil
  12293. case contact.FieldCtype:
  12294. v, ok := value.(int64)
  12295. if !ok {
  12296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12297. }
  12298. m.AddCtype(v)
  12299. return nil
  12300. case contact.FieldCage:
  12301. v, ok := value.(int)
  12302. if !ok {
  12303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12304. }
  12305. m.AddCage(v)
  12306. return nil
  12307. }
  12308. return fmt.Errorf("unknown Contact numeric field %s", name)
  12309. }
  12310. // ClearedFields returns all nullable fields that were cleared during this
  12311. // mutation.
  12312. func (m *ContactMutation) ClearedFields() []string {
  12313. var fields []string
  12314. if m.FieldCleared(contact.FieldStatus) {
  12315. fields = append(fields, contact.FieldStatus)
  12316. }
  12317. if m.FieldCleared(contact.FieldDeletedAt) {
  12318. fields = append(fields, contact.FieldDeletedAt)
  12319. }
  12320. if m.FieldCleared(contact.FieldType) {
  12321. fields = append(fields, contact.FieldType)
  12322. }
  12323. if m.FieldCleared(contact.FieldOrganizationID) {
  12324. fields = append(fields, contact.FieldOrganizationID)
  12325. }
  12326. return fields
  12327. }
  12328. // FieldCleared returns a boolean indicating if a field with the given name was
  12329. // cleared in this mutation.
  12330. func (m *ContactMutation) FieldCleared(name string) bool {
  12331. _, ok := m.clearedFields[name]
  12332. return ok
  12333. }
  12334. // ClearField clears the value of the field with the given name. It returns an
  12335. // error if the field is not defined in the schema.
  12336. func (m *ContactMutation) ClearField(name string) error {
  12337. switch name {
  12338. case contact.FieldStatus:
  12339. m.ClearStatus()
  12340. return nil
  12341. case contact.FieldDeletedAt:
  12342. m.ClearDeletedAt()
  12343. return nil
  12344. case contact.FieldType:
  12345. m.ClearType()
  12346. return nil
  12347. case contact.FieldOrganizationID:
  12348. m.ClearOrganizationID()
  12349. return nil
  12350. }
  12351. return fmt.Errorf("unknown Contact nullable field %s", name)
  12352. }
  12353. // ResetField resets all changes in the mutation for the field with the given name.
  12354. // It returns an error if the field is not defined in the schema.
  12355. func (m *ContactMutation) ResetField(name string) error {
  12356. switch name {
  12357. case contact.FieldCreatedAt:
  12358. m.ResetCreatedAt()
  12359. return nil
  12360. case contact.FieldUpdatedAt:
  12361. m.ResetUpdatedAt()
  12362. return nil
  12363. case contact.FieldStatus:
  12364. m.ResetStatus()
  12365. return nil
  12366. case contact.FieldDeletedAt:
  12367. m.ResetDeletedAt()
  12368. return nil
  12369. case contact.FieldWxWxid:
  12370. m.ResetWxWxid()
  12371. return nil
  12372. case contact.FieldType:
  12373. m.ResetType()
  12374. return nil
  12375. case contact.FieldWxid:
  12376. m.ResetWxid()
  12377. return nil
  12378. case contact.FieldAccount:
  12379. m.ResetAccount()
  12380. return nil
  12381. case contact.FieldNickname:
  12382. m.ResetNickname()
  12383. return nil
  12384. case contact.FieldMarkname:
  12385. m.ResetMarkname()
  12386. return nil
  12387. case contact.FieldHeadimg:
  12388. m.ResetHeadimg()
  12389. return nil
  12390. case contact.FieldSex:
  12391. m.ResetSex()
  12392. return nil
  12393. case contact.FieldStarrole:
  12394. m.ResetStarrole()
  12395. return nil
  12396. case contact.FieldDontseeit:
  12397. m.ResetDontseeit()
  12398. return nil
  12399. case contact.FieldDontseeme:
  12400. m.ResetDontseeme()
  12401. return nil
  12402. case contact.FieldLag:
  12403. m.ResetLag()
  12404. return nil
  12405. case contact.FieldGid:
  12406. m.ResetGid()
  12407. return nil
  12408. case contact.FieldGname:
  12409. m.ResetGname()
  12410. return nil
  12411. case contact.FieldV3:
  12412. m.ResetV3()
  12413. return nil
  12414. case contact.FieldOrganizationID:
  12415. m.ResetOrganizationID()
  12416. return nil
  12417. case contact.FieldCtype:
  12418. m.ResetCtype()
  12419. return nil
  12420. case contact.FieldCage:
  12421. m.ResetCage()
  12422. return nil
  12423. case contact.FieldCname:
  12424. m.ResetCname()
  12425. return nil
  12426. case contact.FieldCarea:
  12427. m.ResetCarea()
  12428. return nil
  12429. case contact.FieldCbirthday:
  12430. m.ResetCbirthday()
  12431. return nil
  12432. case contact.FieldCbirtharea:
  12433. m.ResetCbirtharea()
  12434. return nil
  12435. case contact.FieldCidcardNo:
  12436. m.ResetCidcardNo()
  12437. return nil
  12438. case contact.FieldCtitle:
  12439. m.ResetCtitle()
  12440. return nil
  12441. case contact.FieldCc:
  12442. m.ResetCc()
  12443. return nil
  12444. case contact.FieldPhone:
  12445. m.ResetPhone()
  12446. return nil
  12447. }
  12448. return fmt.Errorf("unknown Contact field %s", name)
  12449. }
  12450. // AddedEdges returns all edge names that were set/added in this mutation.
  12451. func (m *ContactMutation) AddedEdges() []string {
  12452. edges := make([]string, 0, 2)
  12453. if m.contact_relationships != nil {
  12454. edges = append(edges, contact.EdgeContactRelationships)
  12455. }
  12456. if m.contact_messages != nil {
  12457. edges = append(edges, contact.EdgeContactMessages)
  12458. }
  12459. return edges
  12460. }
  12461. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12462. // name in this mutation.
  12463. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  12464. switch name {
  12465. case contact.EdgeContactRelationships:
  12466. ids := make([]ent.Value, 0, len(m.contact_relationships))
  12467. for id := range m.contact_relationships {
  12468. ids = append(ids, id)
  12469. }
  12470. return ids
  12471. case contact.EdgeContactMessages:
  12472. ids := make([]ent.Value, 0, len(m.contact_messages))
  12473. for id := range m.contact_messages {
  12474. ids = append(ids, id)
  12475. }
  12476. return ids
  12477. }
  12478. return nil
  12479. }
  12480. // RemovedEdges returns all edge names that were removed in this mutation.
  12481. func (m *ContactMutation) RemovedEdges() []string {
  12482. edges := make([]string, 0, 2)
  12483. if m.removedcontact_relationships != nil {
  12484. edges = append(edges, contact.EdgeContactRelationships)
  12485. }
  12486. if m.removedcontact_messages != nil {
  12487. edges = append(edges, contact.EdgeContactMessages)
  12488. }
  12489. return edges
  12490. }
  12491. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12492. // the given name in this mutation.
  12493. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  12494. switch name {
  12495. case contact.EdgeContactRelationships:
  12496. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  12497. for id := range m.removedcontact_relationships {
  12498. ids = append(ids, id)
  12499. }
  12500. return ids
  12501. case contact.EdgeContactMessages:
  12502. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  12503. for id := range m.removedcontact_messages {
  12504. ids = append(ids, id)
  12505. }
  12506. return ids
  12507. }
  12508. return nil
  12509. }
  12510. // ClearedEdges returns all edge names that were cleared in this mutation.
  12511. func (m *ContactMutation) ClearedEdges() []string {
  12512. edges := make([]string, 0, 2)
  12513. if m.clearedcontact_relationships {
  12514. edges = append(edges, contact.EdgeContactRelationships)
  12515. }
  12516. if m.clearedcontact_messages {
  12517. edges = append(edges, contact.EdgeContactMessages)
  12518. }
  12519. return edges
  12520. }
  12521. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12522. // was cleared in this mutation.
  12523. func (m *ContactMutation) EdgeCleared(name string) bool {
  12524. switch name {
  12525. case contact.EdgeContactRelationships:
  12526. return m.clearedcontact_relationships
  12527. case contact.EdgeContactMessages:
  12528. return m.clearedcontact_messages
  12529. }
  12530. return false
  12531. }
  12532. // ClearEdge clears the value of the edge with the given name. It returns an error
  12533. // if that edge is not defined in the schema.
  12534. func (m *ContactMutation) ClearEdge(name string) error {
  12535. switch name {
  12536. }
  12537. return fmt.Errorf("unknown Contact unique edge %s", name)
  12538. }
  12539. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12540. // It returns an error if the edge is not defined in the schema.
  12541. func (m *ContactMutation) ResetEdge(name string) error {
  12542. switch name {
  12543. case contact.EdgeContactRelationships:
  12544. m.ResetContactRelationships()
  12545. return nil
  12546. case contact.EdgeContactMessages:
  12547. m.ResetContactMessages()
  12548. return nil
  12549. }
  12550. return fmt.Errorf("unknown Contact edge %s", name)
  12551. }
  12552. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  12553. type CreditBalanceMutation struct {
  12554. config
  12555. op Op
  12556. typ string
  12557. id *uint64
  12558. created_at *time.Time
  12559. updated_at *time.Time
  12560. deleted_at *time.Time
  12561. user_id *string
  12562. balance *float32
  12563. addbalance *float32
  12564. status *int
  12565. addstatus *int
  12566. organization_id *uint64
  12567. addorganization_id *int64
  12568. clearedFields map[string]struct{}
  12569. done bool
  12570. oldValue func(context.Context) (*CreditBalance, error)
  12571. predicates []predicate.CreditBalance
  12572. }
  12573. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  12574. // creditbalanceOption allows management of the mutation configuration using functional options.
  12575. type creditbalanceOption func(*CreditBalanceMutation)
  12576. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  12577. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  12578. m := &CreditBalanceMutation{
  12579. config: c,
  12580. op: op,
  12581. typ: TypeCreditBalance,
  12582. clearedFields: make(map[string]struct{}),
  12583. }
  12584. for _, opt := range opts {
  12585. opt(m)
  12586. }
  12587. return m
  12588. }
  12589. // withCreditBalanceID sets the ID field of the mutation.
  12590. func withCreditBalanceID(id uint64) creditbalanceOption {
  12591. return func(m *CreditBalanceMutation) {
  12592. var (
  12593. err error
  12594. once sync.Once
  12595. value *CreditBalance
  12596. )
  12597. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  12598. once.Do(func() {
  12599. if m.done {
  12600. err = errors.New("querying old values post mutation is not allowed")
  12601. } else {
  12602. value, err = m.Client().CreditBalance.Get(ctx, id)
  12603. }
  12604. })
  12605. return value, err
  12606. }
  12607. m.id = &id
  12608. }
  12609. }
  12610. // withCreditBalance sets the old CreditBalance of the mutation.
  12611. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  12612. return func(m *CreditBalanceMutation) {
  12613. m.oldValue = func(context.Context) (*CreditBalance, error) {
  12614. return node, nil
  12615. }
  12616. m.id = &node.ID
  12617. }
  12618. }
  12619. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12620. // executed in a transaction (ent.Tx), a transactional client is returned.
  12621. func (m CreditBalanceMutation) Client() *Client {
  12622. client := &Client{config: m.config}
  12623. client.init()
  12624. return client
  12625. }
  12626. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12627. // it returns an error otherwise.
  12628. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  12629. if _, ok := m.driver.(*txDriver); !ok {
  12630. return nil, errors.New("ent: mutation is not running in a transaction")
  12631. }
  12632. tx := &Tx{config: m.config}
  12633. tx.init()
  12634. return tx, nil
  12635. }
  12636. // SetID sets the value of the id field. Note that this
  12637. // operation is only accepted on creation of CreditBalance entities.
  12638. func (m *CreditBalanceMutation) SetID(id uint64) {
  12639. m.id = &id
  12640. }
  12641. // ID returns the ID value in the mutation. Note that the ID is only available
  12642. // if it was provided to the builder or after it was returned from the database.
  12643. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  12644. if m.id == nil {
  12645. return
  12646. }
  12647. return *m.id, true
  12648. }
  12649. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12650. // That means, if the mutation is applied within a transaction with an isolation level such
  12651. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12652. // or updated by the mutation.
  12653. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  12654. switch {
  12655. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12656. id, exists := m.ID()
  12657. if exists {
  12658. return []uint64{id}, nil
  12659. }
  12660. fallthrough
  12661. case m.op.Is(OpUpdate | OpDelete):
  12662. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  12663. default:
  12664. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12665. }
  12666. }
  12667. // SetCreatedAt sets the "created_at" field.
  12668. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  12669. m.created_at = &t
  12670. }
  12671. // CreatedAt returns the value of the "created_at" field in the mutation.
  12672. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  12673. v := m.created_at
  12674. if v == nil {
  12675. return
  12676. }
  12677. return *v, true
  12678. }
  12679. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  12680. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12682. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12683. if !m.op.Is(OpUpdateOne) {
  12684. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12685. }
  12686. if m.id == nil || m.oldValue == nil {
  12687. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12688. }
  12689. oldValue, err := m.oldValue(ctx)
  12690. if err != nil {
  12691. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12692. }
  12693. return oldValue.CreatedAt, nil
  12694. }
  12695. // ResetCreatedAt resets all changes to the "created_at" field.
  12696. func (m *CreditBalanceMutation) ResetCreatedAt() {
  12697. m.created_at = nil
  12698. }
  12699. // SetUpdatedAt sets the "updated_at" field.
  12700. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  12701. m.updated_at = &t
  12702. }
  12703. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12704. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  12705. v := m.updated_at
  12706. if v == nil {
  12707. return
  12708. }
  12709. return *v, true
  12710. }
  12711. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  12712. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12714. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12715. if !m.op.Is(OpUpdateOne) {
  12716. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12717. }
  12718. if m.id == nil || m.oldValue == nil {
  12719. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12720. }
  12721. oldValue, err := m.oldValue(ctx)
  12722. if err != nil {
  12723. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12724. }
  12725. return oldValue.UpdatedAt, nil
  12726. }
  12727. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12728. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  12729. m.updated_at = nil
  12730. }
  12731. // SetDeletedAt sets the "deleted_at" field.
  12732. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  12733. m.deleted_at = &t
  12734. }
  12735. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12736. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  12737. v := m.deleted_at
  12738. if v == nil {
  12739. return
  12740. }
  12741. return *v, true
  12742. }
  12743. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  12744. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12746. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12747. if !m.op.Is(OpUpdateOne) {
  12748. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12749. }
  12750. if m.id == nil || m.oldValue == nil {
  12751. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12752. }
  12753. oldValue, err := m.oldValue(ctx)
  12754. if err != nil {
  12755. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12756. }
  12757. return oldValue.DeletedAt, nil
  12758. }
  12759. // ClearDeletedAt clears the value of the "deleted_at" field.
  12760. func (m *CreditBalanceMutation) ClearDeletedAt() {
  12761. m.deleted_at = nil
  12762. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  12763. }
  12764. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12765. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  12766. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  12767. return ok
  12768. }
  12769. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12770. func (m *CreditBalanceMutation) ResetDeletedAt() {
  12771. m.deleted_at = nil
  12772. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  12773. }
  12774. // SetUserID sets the "user_id" field.
  12775. func (m *CreditBalanceMutation) SetUserID(s string) {
  12776. m.user_id = &s
  12777. }
  12778. // UserID returns the value of the "user_id" field in the mutation.
  12779. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  12780. v := m.user_id
  12781. if v == nil {
  12782. return
  12783. }
  12784. return *v, true
  12785. }
  12786. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  12787. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12789. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  12790. if !m.op.Is(OpUpdateOne) {
  12791. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  12792. }
  12793. if m.id == nil || m.oldValue == nil {
  12794. return v, errors.New("OldUserID requires an ID field in the mutation")
  12795. }
  12796. oldValue, err := m.oldValue(ctx)
  12797. if err != nil {
  12798. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  12799. }
  12800. return oldValue.UserID, nil
  12801. }
  12802. // ClearUserID clears the value of the "user_id" field.
  12803. func (m *CreditBalanceMutation) ClearUserID() {
  12804. m.user_id = nil
  12805. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  12806. }
  12807. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  12808. func (m *CreditBalanceMutation) UserIDCleared() bool {
  12809. _, ok := m.clearedFields[creditbalance.FieldUserID]
  12810. return ok
  12811. }
  12812. // ResetUserID resets all changes to the "user_id" field.
  12813. func (m *CreditBalanceMutation) ResetUserID() {
  12814. m.user_id = nil
  12815. delete(m.clearedFields, creditbalance.FieldUserID)
  12816. }
  12817. // SetBalance sets the "balance" field.
  12818. func (m *CreditBalanceMutation) SetBalance(f float32) {
  12819. m.balance = &f
  12820. m.addbalance = nil
  12821. }
  12822. // Balance returns the value of the "balance" field in the mutation.
  12823. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  12824. v := m.balance
  12825. if v == nil {
  12826. return
  12827. }
  12828. return *v, true
  12829. }
  12830. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  12831. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12833. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  12834. if !m.op.Is(OpUpdateOne) {
  12835. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  12836. }
  12837. if m.id == nil || m.oldValue == nil {
  12838. return v, errors.New("OldBalance requires an ID field in the mutation")
  12839. }
  12840. oldValue, err := m.oldValue(ctx)
  12841. if err != nil {
  12842. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  12843. }
  12844. return oldValue.Balance, nil
  12845. }
  12846. // AddBalance adds f to the "balance" field.
  12847. func (m *CreditBalanceMutation) AddBalance(f float32) {
  12848. if m.addbalance != nil {
  12849. *m.addbalance += f
  12850. } else {
  12851. m.addbalance = &f
  12852. }
  12853. }
  12854. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  12855. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  12856. v := m.addbalance
  12857. if v == nil {
  12858. return
  12859. }
  12860. return *v, true
  12861. }
  12862. // ResetBalance resets all changes to the "balance" field.
  12863. func (m *CreditBalanceMutation) ResetBalance() {
  12864. m.balance = nil
  12865. m.addbalance = nil
  12866. }
  12867. // SetStatus sets the "status" field.
  12868. func (m *CreditBalanceMutation) SetStatus(i int) {
  12869. m.status = &i
  12870. m.addstatus = nil
  12871. }
  12872. // Status returns the value of the "status" field in the mutation.
  12873. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  12874. v := m.status
  12875. if v == nil {
  12876. return
  12877. }
  12878. return *v, true
  12879. }
  12880. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  12881. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12883. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  12884. if !m.op.Is(OpUpdateOne) {
  12885. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12886. }
  12887. if m.id == nil || m.oldValue == nil {
  12888. return v, errors.New("OldStatus requires an ID field in the mutation")
  12889. }
  12890. oldValue, err := m.oldValue(ctx)
  12891. if err != nil {
  12892. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12893. }
  12894. return oldValue.Status, nil
  12895. }
  12896. // AddStatus adds i to the "status" field.
  12897. func (m *CreditBalanceMutation) AddStatus(i int) {
  12898. if m.addstatus != nil {
  12899. *m.addstatus += i
  12900. } else {
  12901. m.addstatus = &i
  12902. }
  12903. }
  12904. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12905. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  12906. v := m.addstatus
  12907. if v == nil {
  12908. return
  12909. }
  12910. return *v, true
  12911. }
  12912. // ClearStatus clears the value of the "status" field.
  12913. func (m *CreditBalanceMutation) ClearStatus() {
  12914. m.status = nil
  12915. m.addstatus = nil
  12916. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  12917. }
  12918. // StatusCleared returns if the "status" field was cleared in this mutation.
  12919. func (m *CreditBalanceMutation) StatusCleared() bool {
  12920. _, ok := m.clearedFields[creditbalance.FieldStatus]
  12921. return ok
  12922. }
  12923. // ResetStatus resets all changes to the "status" field.
  12924. func (m *CreditBalanceMutation) ResetStatus() {
  12925. m.status = nil
  12926. m.addstatus = nil
  12927. delete(m.clearedFields, creditbalance.FieldStatus)
  12928. }
  12929. // SetOrganizationID sets the "organization_id" field.
  12930. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  12931. m.organization_id = &u
  12932. m.addorganization_id = nil
  12933. }
  12934. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12935. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  12936. v := m.organization_id
  12937. if v == nil {
  12938. return
  12939. }
  12940. return *v, true
  12941. }
  12942. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  12943. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  12944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12945. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12946. if !m.op.Is(OpUpdateOne) {
  12947. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12948. }
  12949. if m.id == nil || m.oldValue == nil {
  12950. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12951. }
  12952. oldValue, err := m.oldValue(ctx)
  12953. if err != nil {
  12954. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12955. }
  12956. return oldValue.OrganizationID, nil
  12957. }
  12958. // AddOrganizationID adds u to the "organization_id" field.
  12959. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  12960. if m.addorganization_id != nil {
  12961. *m.addorganization_id += u
  12962. } else {
  12963. m.addorganization_id = &u
  12964. }
  12965. }
  12966. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12967. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  12968. v := m.addorganization_id
  12969. if v == nil {
  12970. return
  12971. }
  12972. return *v, true
  12973. }
  12974. // ClearOrganizationID clears the value of the "organization_id" field.
  12975. func (m *CreditBalanceMutation) ClearOrganizationID() {
  12976. m.organization_id = nil
  12977. m.addorganization_id = nil
  12978. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  12979. }
  12980. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12981. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  12982. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  12983. return ok
  12984. }
  12985. // ResetOrganizationID resets all changes to the "organization_id" field.
  12986. func (m *CreditBalanceMutation) ResetOrganizationID() {
  12987. m.organization_id = nil
  12988. m.addorganization_id = nil
  12989. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  12990. }
  12991. // Where appends a list predicates to the CreditBalanceMutation builder.
  12992. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  12993. m.predicates = append(m.predicates, ps...)
  12994. }
  12995. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  12996. // users can use type-assertion to append predicates that do not depend on any generated package.
  12997. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  12998. p := make([]predicate.CreditBalance, len(ps))
  12999. for i := range ps {
  13000. p[i] = ps[i]
  13001. }
  13002. m.Where(p...)
  13003. }
  13004. // Op returns the operation name.
  13005. func (m *CreditBalanceMutation) Op() Op {
  13006. return m.op
  13007. }
  13008. // SetOp allows setting the mutation operation.
  13009. func (m *CreditBalanceMutation) SetOp(op Op) {
  13010. m.op = op
  13011. }
  13012. // Type returns the node type of this mutation (CreditBalance).
  13013. func (m *CreditBalanceMutation) Type() string {
  13014. return m.typ
  13015. }
  13016. // Fields returns all fields that were changed during this mutation. Note that in
  13017. // order to get all numeric fields that were incremented/decremented, call
  13018. // AddedFields().
  13019. func (m *CreditBalanceMutation) Fields() []string {
  13020. fields := make([]string, 0, 7)
  13021. if m.created_at != nil {
  13022. fields = append(fields, creditbalance.FieldCreatedAt)
  13023. }
  13024. if m.updated_at != nil {
  13025. fields = append(fields, creditbalance.FieldUpdatedAt)
  13026. }
  13027. if m.deleted_at != nil {
  13028. fields = append(fields, creditbalance.FieldDeletedAt)
  13029. }
  13030. if m.user_id != nil {
  13031. fields = append(fields, creditbalance.FieldUserID)
  13032. }
  13033. if m.balance != nil {
  13034. fields = append(fields, creditbalance.FieldBalance)
  13035. }
  13036. if m.status != nil {
  13037. fields = append(fields, creditbalance.FieldStatus)
  13038. }
  13039. if m.organization_id != nil {
  13040. fields = append(fields, creditbalance.FieldOrganizationID)
  13041. }
  13042. return fields
  13043. }
  13044. // Field returns the value of a field with the given name. The second boolean
  13045. // return value indicates that this field was not set, or was not defined in the
  13046. // schema.
  13047. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  13048. switch name {
  13049. case creditbalance.FieldCreatedAt:
  13050. return m.CreatedAt()
  13051. case creditbalance.FieldUpdatedAt:
  13052. return m.UpdatedAt()
  13053. case creditbalance.FieldDeletedAt:
  13054. return m.DeletedAt()
  13055. case creditbalance.FieldUserID:
  13056. return m.UserID()
  13057. case creditbalance.FieldBalance:
  13058. return m.Balance()
  13059. case creditbalance.FieldStatus:
  13060. return m.Status()
  13061. case creditbalance.FieldOrganizationID:
  13062. return m.OrganizationID()
  13063. }
  13064. return nil, false
  13065. }
  13066. // OldField returns the old value of the field from the database. An error is
  13067. // returned if the mutation operation is not UpdateOne, or the query to the
  13068. // database failed.
  13069. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13070. switch name {
  13071. case creditbalance.FieldCreatedAt:
  13072. return m.OldCreatedAt(ctx)
  13073. case creditbalance.FieldUpdatedAt:
  13074. return m.OldUpdatedAt(ctx)
  13075. case creditbalance.FieldDeletedAt:
  13076. return m.OldDeletedAt(ctx)
  13077. case creditbalance.FieldUserID:
  13078. return m.OldUserID(ctx)
  13079. case creditbalance.FieldBalance:
  13080. return m.OldBalance(ctx)
  13081. case creditbalance.FieldStatus:
  13082. return m.OldStatus(ctx)
  13083. case creditbalance.FieldOrganizationID:
  13084. return m.OldOrganizationID(ctx)
  13085. }
  13086. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  13087. }
  13088. // SetField sets the value of a field with the given name. It returns an error if
  13089. // the field is not defined in the schema, or if the type mismatched the field
  13090. // type.
  13091. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  13092. switch name {
  13093. case creditbalance.FieldCreatedAt:
  13094. v, ok := value.(time.Time)
  13095. if !ok {
  13096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13097. }
  13098. m.SetCreatedAt(v)
  13099. return nil
  13100. case creditbalance.FieldUpdatedAt:
  13101. v, ok := value.(time.Time)
  13102. if !ok {
  13103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13104. }
  13105. m.SetUpdatedAt(v)
  13106. return nil
  13107. case creditbalance.FieldDeletedAt:
  13108. v, ok := value.(time.Time)
  13109. if !ok {
  13110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13111. }
  13112. m.SetDeletedAt(v)
  13113. return nil
  13114. case creditbalance.FieldUserID:
  13115. v, ok := value.(string)
  13116. if !ok {
  13117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13118. }
  13119. m.SetUserID(v)
  13120. return nil
  13121. case creditbalance.FieldBalance:
  13122. v, ok := value.(float32)
  13123. if !ok {
  13124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13125. }
  13126. m.SetBalance(v)
  13127. return nil
  13128. case creditbalance.FieldStatus:
  13129. v, ok := value.(int)
  13130. if !ok {
  13131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13132. }
  13133. m.SetStatus(v)
  13134. return nil
  13135. case creditbalance.FieldOrganizationID:
  13136. v, ok := value.(uint64)
  13137. if !ok {
  13138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13139. }
  13140. m.SetOrganizationID(v)
  13141. return nil
  13142. }
  13143. return fmt.Errorf("unknown CreditBalance field %s", name)
  13144. }
  13145. // AddedFields returns all numeric fields that were incremented/decremented during
  13146. // this mutation.
  13147. func (m *CreditBalanceMutation) AddedFields() []string {
  13148. var fields []string
  13149. if m.addbalance != nil {
  13150. fields = append(fields, creditbalance.FieldBalance)
  13151. }
  13152. if m.addstatus != nil {
  13153. fields = append(fields, creditbalance.FieldStatus)
  13154. }
  13155. if m.addorganization_id != nil {
  13156. fields = append(fields, creditbalance.FieldOrganizationID)
  13157. }
  13158. return fields
  13159. }
  13160. // AddedField returns the numeric value that was incremented/decremented on a field
  13161. // with the given name. The second boolean return value indicates that this field
  13162. // was not set, or was not defined in the schema.
  13163. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  13164. switch name {
  13165. case creditbalance.FieldBalance:
  13166. return m.AddedBalance()
  13167. case creditbalance.FieldStatus:
  13168. return m.AddedStatus()
  13169. case creditbalance.FieldOrganizationID:
  13170. return m.AddedOrganizationID()
  13171. }
  13172. return nil, false
  13173. }
  13174. // AddField adds the value to the field with the given name. It returns an error if
  13175. // the field is not defined in the schema, or if the type mismatched the field
  13176. // type.
  13177. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  13178. switch name {
  13179. case creditbalance.FieldBalance:
  13180. v, ok := value.(float32)
  13181. if !ok {
  13182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13183. }
  13184. m.AddBalance(v)
  13185. return nil
  13186. case creditbalance.FieldStatus:
  13187. v, ok := value.(int)
  13188. if !ok {
  13189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13190. }
  13191. m.AddStatus(v)
  13192. return nil
  13193. case creditbalance.FieldOrganizationID:
  13194. v, ok := value.(int64)
  13195. if !ok {
  13196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13197. }
  13198. m.AddOrganizationID(v)
  13199. return nil
  13200. }
  13201. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  13202. }
  13203. // ClearedFields returns all nullable fields that were cleared during this
  13204. // mutation.
  13205. func (m *CreditBalanceMutation) ClearedFields() []string {
  13206. var fields []string
  13207. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  13208. fields = append(fields, creditbalance.FieldDeletedAt)
  13209. }
  13210. if m.FieldCleared(creditbalance.FieldUserID) {
  13211. fields = append(fields, creditbalance.FieldUserID)
  13212. }
  13213. if m.FieldCleared(creditbalance.FieldStatus) {
  13214. fields = append(fields, creditbalance.FieldStatus)
  13215. }
  13216. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  13217. fields = append(fields, creditbalance.FieldOrganizationID)
  13218. }
  13219. return fields
  13220. }
  13221. // FieldCleared returns a boolean indicating if a field with the given name was
  13222. // cleared in this mutation.
  13223. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  13224. _, ok := m.clearedFields[name]
  13225. return ok
  13226. }
  13227. // ClearField clears the value of the field with the given name. It returns an
  13228. // error if the field is not defined in the schema.
  13229. func (m *CreditBalanceMutation) ClearField(name string) error {
  13230. switch name {
  13231. case creditbalance.FieldDeletedAt:
  13232. m.ClearDeletedAt()
  13233. return nil
  13234. case creditbalance.FieldUserID:
  13235. m.ClearUserID()
  13236. return nil
  13237. case creditbalance.FieldStatus:
  13238. m.ClearStatus()
  13239. return nil
  13240. case creditbalance.FieldOrganizationID:
  13241. m.ClearOrganizationID()
  13242. return nil
  13243. }
  13244. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  13245. }
  13246. // ResetField resets all changes in the mutation for the field with the given name.
  13247. // It returns an error if the field is not defined in the schema.
  13248. func (m *CreditBalanceMutation) ResetField(name string) error {
  13249. switch name {
  13250. case creditbalance.FieldCreatedAt:
  13251. m.ResetCreatedAt()
  13252. return nil
  13253. case creditbalance.FieldUpdatedAt:
  13254. m.ResetUpdatedAt()
  13255. return nil
  13256. case creditbalance.FieldDeletedAt:
  13257. m.ResetDeletedAt()
  13258. return nil
  13259. case creditbalance.FieldUserID:
  13260. m.ResetUserID()
  13261. return nil
  13262. case creditbalance.FieldBalance:
  13263. m.ResetBalance()
  13264. return nil
  13265. case creditbalance.FieldStatus:
  13266. m.ResetStatus()
  13267. return nil
  13268. case creditbalance.FieldOrganizationID:
  13269. m.ResetOrganizationID()
  13270. return nil
  13271. }
  13272. return fmt.Errorf("unknown CreditBalance field %s", name)
  13273. }
  13274. // AddedEdges returns all edge names that were set/added in this mutation.
  13275. func (m *CreditBalanceMutation) AddedEdges() []string {
  13276. edges := make([]string, 0, 0)
  13277. return edges
  13278. }
  13279. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13280. // name in this mutation.
  13281. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  13282. return nil
  13283. }
  13284. // RemovedEdges returns all edge names that were removed in this mutation.
  13285. func (m *CreditBalanceMutation) RemovedEdges() []string {
  13286. edges := make([]string, 0, 0)
  13287. return edges
  13288. }
  13289. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13290. // the given name in this mutation.
  13291. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  13292. return nil
  13293. }
  13294. // ClearedEdges returns all edge names that were cleared in this mutation.
  13295. func (m *CreditBalanceMutation) ClearedEdges() []string {
  13296. edges := make([]string, 0, 0)
  13297. return edges
  13298. }
  13299. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13300. // was cleared in this mutation.
  13301. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  13302. return false
  13303. }
  13304. // ClearEdge clears the value of the edge with the given name. It returns an error
  13305. // if that edge is not defined in the schema.
  13306. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  13307. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  13308. }
  13309. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13310. // It returns an error if the edge is not defined in the schema.
  13311. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  13312. return fmt.Errorf("unknown CreditBalance edge %s", name)
  13313. }
  13314. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  13315. type CreditUsageMutation struct {
  13316. config
  13317. op Op
  13318. typ string
  13319. id *uint64
  13320. created_at *time.Time
  13321. updated_at *time.Time
  13322. deleted_at *time.Time
  13323. user_id *string
  13324. number *float32
  13325. addnumber *float32
  13326. status *int
  13327. addstatus *int
  13328. ntype *int
  13329. addntype *int
  13330. table *string
  13331. organization_id *uint64
  13332. addorganization_id *int64
  13333. nid *uint64
  13334. addnid *int64
  13335. reason *string
  13336. operator *string
  13337. clearedFields map[string]struct{}
  13338. done bool
  13339. oldValue func(context.Context) (*CreditUsage, error)
  13340. predicates []predicate.CreditUsage
  13341. }
  13342. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  13343. // creditusageOption allows management of the mutation configuration using functional options.
  13344. type creditusageOption func(*CreditUsageMutation)
  13345. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  13346. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  13347. m := &CreditUsageMutation{
  13348. config: c,
  13349. op: op,
  13350. typ: TypeCreditUsage,
  13351. clearedFields: make(map[string]struct{}),
  13352. }
  13353. for _, opt := range opts {
  13354. opt(m)
  13355. }
  13356. return m
  13357. }
  13358. // withCreditUsageID sets the ID field of the mutation.
  13359. func withCreditUsageID(id uint64) creditusageOption {
  13360. return func(m *CreditUsageMutation) {
  13361. var (
  13362. err error
  13363. once sync.Once
  13364. value *CreditUsage
  13365. )
  13366. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  13367. once.Do(func() {
  13368. if m.done {
  13369. err = errors.New("querying old values post mutation is not allowed")
  13370. } else {
  13371. value, err = m.Client().CreditUsage.Get(ctx, id)
  13372. }
  13373. })
  13374. return value, err
  13375. }
  13376. m.id = &id
  13377. }
  13378. }
  13379. // withCreditUsage sets the old CreditUsage of the mutation.
  13380. func withCreditUsage(node *CreditUsage) creditusageOption {
  13381. return func(m *CreditUsageMutation) {
  13382. m.oldValue = func(context.Context) (*CreditUsage, error) {
  13383. return node, nil
  13384. }
  13385. m.id = &node.ID
  13386. }
  13387. }
  13388. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13389. // executed in a transaction (ent.Tx), a transactional client is returned.
  13390. func (m CreditUsageMutation) Client() *Client {
  13391. client := &Client{config: m.config}
  13392. client.init()
  13393. return client
  13394. }
  13395. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13396. // it returns an error otherwise.
  13397. func (m CreditUsageMutation) Tx() (*Tx, error) {
  13398. if _, ok := m.driver.(*txDriver); !ok {
  13399. return nil, errors.New("ent: mutation is not running in a transaction")
  13400. }
  13401. tx := &Tx{config: m.config}
  13402. tx.init()
  13403. return tx, nil
  13404. }
  13405. // SetID sets the value of the id field. Note that this
  13406. // operation is only accepted on creation of CreditUsage entities.
  13407. func (m *CreditUsageMutation) SetID(id uint64) {
  13408. m.id = &id
  13409. }
  13410. // ID returns the ID value in the mutation. Note that the ID is only available
  13411. // if it was provided to the builder or after it was returned from the database.
  13412. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  13413. if m.id == nil {
  13414. return
  13415. }
  13416. return *m.id, true
  13417. }
  13418. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13419. // That means, if the mutation is applied within a transaction with an isolation level such
  13420. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13421. // or updated by the mutation.
  13422. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  13423. switch {
  13424. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13425. id, exists := m.ID()
  13426. if exists {
  13427. return []uint64{id}, nil
  13428. }
  13429. fallthrough
  13430. case m.op.Is(OpUpdate | OpDelete):
  13431. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  13432. default:
  13433. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13434. }
  13435. }
  13436. // SetCreatedAt sets the "created_at" field.
  13437. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  13438. m.created_at = &t
  13439. }
  13440. // CreatedAt returns the value of the "created_at" field in the mutation.
  13441. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  13442. v := m.created_at
  13443. if v == nil {
  13444. return
  13445. }
  13446. return *v, true
  13447. }
  13448. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  13449. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13451. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13452. if !m.op.Is(OpUpdateOne) {
  13453. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13454. }
  13455. if m.id == nil || m.oldValue == nil {
  13456. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13457. }
  13458. oldValue, err := m.oldValue(ctx)
  13459. if err != nil {
  13460. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13461. }
  13462. return oldValue.CreatedAt, nil
  13463. }
  13464. // ResetCreatedAt resets all changes to the "created_at" field.
  13465. func (m *CreditUsageMutation) ResetCreatedAt() {
  13466. m.created_at = nil
  13467. }
  13468. // SetUpdatedAt sets the "updated_at" field.
  13469. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  13470. m.updated_at = &t
  13471. }
  13472. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13473. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  13474. v := m.updated_at
  13475. if v == nil {
  13476. return
  13477. }
  13478. return *v, true
  13479. }
  13480. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  13481. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13482. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13483. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13484. if !m.op.Is(OpUpdateOne) {
  13485. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13486. }
  13487. if m.id == nil || m.oldValue == nil {
  13488. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13489. }
  13490. oldValue, err := m.oldValue(ctx)
  13491. if err != nil {
  13492. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13493. }
  13494. return oldValue.UpdatedAt, nil
  13495. }
  13496. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13497. func (m *CreditUsageMutation) ResetUpdatedAt() {
  13498. m.updated_at = nil
  13499. }
  13500. // SetDeletedAt sets the "deleted_at" field.
  13501. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  13502. m.deleted_at = &t
  13503. }
  13504. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13505. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  13506. v := m.deleted_at
  13507. if v == nil {
  13508. return
  13509. }
  13510. return *v, true
  13511. }
  13512. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  13513. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13515. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13516. if !m.op.Is(OpUpdateOne) {
  13517. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13518. }
  13519. if m.id == nil || m.oldValue == nil {
  13520. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13521. }
  13522. oldValue, err := m.oldValue(ctx)
  13523. if err != nil {
  13524. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13525. }
  13526. return oldValue.DeletedAt, nil
  13527. }
  13528. // ClearDeletedAt clears the value of the "deleted_at" field.
  13529. func (m *CreditUsageMutation) ClearDeletedAt() {
  13530. m.deleted_at = nil
  13531. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  13532. }
  13533. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13534. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  13535. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  13536. return ok
  13537. }
  13538. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13539. func (m *CreditUsageMutation) ResetDeletedAt() {
  13540. m.deleted_at = nil
  13541. delete(m.clearedFields, creditusage.FieldDeletedAt)
  13542. }
  13543. // SetUserID sets the "user_id" field.
  13544. func (m *CreditUsageMutation) SetUserID(s string) {
  13545. m.user_id = &s
  13546. }
  13547. // UserID returns the value of the "user_id" field in the mutation.
  13548. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  13549. v := m.user_id
  13550. if v == nil {
  13551. return
  13552. }
  13553. return *v, true
  13554. }
  13555. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  13556. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13558. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  13559. if !m.op.Is(OpUpdateOne) {
  13560. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  13561. }
  13562. if m.id == nil || m.oldValue == nil {
  13563. return v, errors.New("OldUserID requires an ID field in the mutation")
  13564. }
  13565. oldValue, err := m.oldValue(ctx)
  13566. if err != nil {
  13567. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  13568. }
  13569. return oldValue.UserID, nil
  13570. }
  13571. // ClearUserID clears the value of the "user_id" field.
  13572. func (m *CreditUsageMutation) ClearUserID() {
  13573. m.user_id = nil
  13574. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  13575. }
  13576. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  13577. func (m *CreditUsageMutation) UserIDCleared() bool {
  13578. _, ok := m.clearedFields[creditusage.FieldUserID]
  13579. return ok
  13580. }
  13581. // ResetUserID resets all changes to the "user_id" field.
  13582. func (m *CreditUsageMutation) ResetUserID() {
  13583. m.user_id = nil
  13584. delete(m.clearedFields, creditusage.FieldUserID)
  13585. }
  13586. // SetNumber sets the "number" field.
  13587. func (m *CreditUsageMutation) SetNumber(f float32) {
  13588. m.number = &f
  13589. m.addnumber = nil
  13590. }
  13591. // Number returns the value of the "number" field in the mutation.
  13592. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  13593. v := m.number
  13594. if v == nil {
  13595. return
  13596. }
  13597. return *v, true
  13598. }
  13599. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  13600. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13602. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  13603. if !m.op.Is(OpUpdateOne) {
  13604. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  13605. }
  13606. if m.id == nil || m.oldValue == nil {
  13607. return v, errors.New("OldNumber requires an ID field in the mutation")
  13608. }
  13609. oldValue, err := m.oldValue(ctx)
  13610. if err != nil {
  13611. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  13612. }
  13613. return oldValue.Number, nil
  13614. }
  13615. // AddNumber adds f to the "number" field.
  13616. func (m *CreditUsageMutation) AddNumber(f float32) {
  13617. if m.addnumber != nil {
  13618. *m.addnumber += f
  13619. } else {
  13620. m.addnumber = &f
  13621. }
  13622. }
  13623. // AddedNumber returns the value that was added to the "number" field in this mutation.
  13624. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  13625. v := m.addnumber
  13626. if v == nil {
  13627. return
  13628. }
  13629. return *v, true
  13630. }
  13631. // ResetNumber resets all changes to the "number" field.
  13632. func (m *CreditUsageMutation) ResetNumber() {
  13633. m.number = nil
  13634. m.addnumber = nil
  13635. }
  13636. // SetStatus sets the "status" field.
  13637. func (m *CreditUsageMutation) SetStatus(i int) {
  13638. m.status = &i
  13639. m.addstatus = nil
  13640. }
  13641. // Status returns the value of the "status" field in the mutation.
  13642. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  13643. v := m.status
  13644. if v == nil {
  13645. return
  13646. }
  13647. return *v, true
  13648. }
  13649. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  13650. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13652. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  13653. if !m.op.Is(OpUpdateOne) {
  13654. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13655. }
  13656. if m.id == nil || m.oldValue == nil {
  13657. return v, errors.New("OldStatus requires an ID field in the mutation")
  13658. }
  13659. oldValue, err := m.oldValue(ctx)
  13660. if err != nil {
  13661. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13662. }
  13663. return oldValue.Status, nil
  13664. }
  13665. // AddStatus adds i to the "status" field.
  13666. func (m *CreditUsageMutation) AddStatus(i int) {
  13667. if m.addstatus != nil {
  13668. *m.addstatus += i
  13669. } else {
  13670. m.addstatus = &i
  13671. }
  13672. }
  13673. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13674. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  13675. v := m.addstatus
  13676. if v == nil {
  13677. return
  13678. }
  13679. return *v, true
  13680. }
  13681. // ClearStatus clears the value of the "status" field.
  13682. func (m *CreditUsageMutation) ClearStatus() {
  13683. m.status = nil
  13684. m.addstatus = nil
  13685. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  13686. }
  13687. // StatusCleared returns if the "status" field was cleared in this mutation.
  13688. func (m *CreditUsageMutation) StatusCleared() bool {
  13689. _, ok := m.clearedFields[creditusage.FieldStatus]
  13690. return ok
  13691. }
  13692. // ResetStatus resets all changes to the "status" field.
  13693. func (m *CreditUsageMutation) ResetStatus() {
  13694. m.status = nil
  13695. m.addstatus = nil
  13696. delete(m.clearedFields, creditusage.FieldStatus)
  13697. }
  13698. // SetNtype sets the "ntype" field.
  13699. func (m *CreditUsageMutation) SetNtype(i int) {
  13700. m.ntype = &i
  13701. m.addntype = nil
  13702. }
  13703. // Ntype returns the value of the "ntype" field in the mutation.
  13704. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  13705. v := m.ntype
  13706. if v == nil {
  13707. return
  13708. }
  13709. return *v, true
  13710. }
  13711. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  13712. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13714. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  13715. if !m.op.Is(OpUpdateOne) {
  13716. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  13717. }
  13718. if m.id == nil || m.oldValue == nil {
  13719. return v, errors.New("OldNtype requires an ID field in the mutation")
  13720. }
  13721. oldValue, err := m.oldValue(ctx)
  13722. if err != nil {
  13723. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  13724. }
  13725. return oldValue.Ntype, nil
  13726. }
  13727. // AddNtype adds i to the "ntype" field.
  13728. func (m *CreditUsageMutation) AddNtype(i int) {
  13729. if m.addntype != nil {
  13730. *m.addntype += i
  13731. } else {
  13732. m.addntype = &i
  13733. }
  13734. }
  13735. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  13736. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  13737. v := m.addntype
  13738. if v == nil {
  13739. return
  13740. }
  13741. return *v, true
  13742. }
  13743. // ResetNtype resets all changes to the "ntype" field.
  13744. func (m *CreditUsageMutation) ResetNtype() {
  13745. m.ntype = nil
  13746. m.addntype = nil
  13747. }
  13748. // SetTable sets the "table" field.
  13749. func (m *CreditUsageMutation) SetTable(s string) {
  13750. m.table = &s
  13751. }
  13752. // Table returns the value of the "table" field in the mutation.
  13753. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  13754. v := m.table
  13755. if v == nil {
  13756. return
  13757. }
  13758. return *v, true
  13759. }
  13760. // OldTable returns the old "table" field's value of the CreditUsage entity.
  13761. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13763. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  13764. if !m.op.Is(OpUpdateOne) {
  13765. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  13766. }
  13767. if m.id == nil || m.oldValue == nil {
  13768. return v, errors.New("OldTable requires an ID field in the mutation")
  13769. }
  13770. oldValue, err := m.oldValue(ctx)
  13771. if err != nil {
  13772. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  13773. }
  13774. return oldValue.Table, nil
  13775. }
  13776. // ResetTable resets all changes to the "table" field.
  13777. func (m *CreditUsageMutation) ResetTable() {
  13778. m.table = nil
  13779. }
  13780. // SetOrganizationID sets the "organization_id" field.
  13781. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  13782. m.organization_id = &u
  13783. m.addorganization_id = nil
  13784. }
  13785. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13786. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  13787. v := m.organization_id
  13788. if v == nil {
  13789. return
  13790. }
  13791. return *v, true
  13792. }
  13793. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  13794. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13796. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13797. if !m.op.Is(OpUpdateOne) {
  13798. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13799. }
  13800. if m.id == nil || m.oldValue == nil {
  13801. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13802. }
  13803. oldValue, err := m.oldValue(ctx)
  13804. if err != nil {
  13805. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13806. }
  13807. return oldValue.OrganizationID, nil
  13808. }
  13809. // AddOrganizationID adds u to the "organization_id" field.
  13810. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  13811. if m.addorganization_id != nil {
  13812. *m.addorganization_id += u
  13813. } else {
  13814. m.addorganization_id = &u
  13815. }
  13816. }
  13817. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13818. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  13819. v := m.addorganization_id
  13820. if v == nil {
  13821. return
  13822. }
  13823. return *v, true
  13824. }
  13825. // ClearOrganizationID clears the value of the "organization_id" field.
  13826. func (m *CreditUsageMutation) ClearOrganizationID() {
  13827. m.organization_id = nil
  13828. m.addorganization_id = nil
  13829. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  13830. }
  13831. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13832. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  13833. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  13834. return ok
  13835. }
  13836. // ResetOrganizationID resets all changes to the "organization_id" field.
  13837. func (m *CreditUsageMutation) ResetOrganizationID() {
  13838. m.organization_id = nil
  13839. m.addorganization_id = nil
  13840. delete(m.clearedFields, creditusage.FieldOrganizationID)
  13841. }
  13842. // SetNid sets the "nid" field.
  13843. func (m *CreditUsageMutation) SetNid(u uint64) {
  13844. m.nid = &u
  13845. m.addnid = nil
  13846. }
  13847. // Nid returns the value of the "nid" field in the mutation.
  13848. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  13849. v := m.nid
  13850. if v == nil {
  13851. return
  13852. }
  13853. return *v, true
  13854. }
  13855. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  13856. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13858. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  13859. if !m.op.Is(OpUpdateOne) {
  13860. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  13861. }
  13862. if m.id == nil || m.oldValue == nil {
  13863. return v, errors.New("OldNid requires an ID field in the mutation")
  13864. }
  13865. oldValue, err := m.oldValue(ctx)
  13866. if err != nil {
  13867. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  13868. }
  13869. return oldValue.Nid, nil
  13870. }
  13871. // AddNid adds u to the "nid" field.
  13872. func (m *CreditUsageMutation) AddNid(u int64) {
  13873. if m.addnid != nil {
  13874. *m.addnid += u
  13875. } else {
  13876. m.addnid = &u
  13877. }
  13878. }
  13879. // AddedNid returns the value that was added to the "nid" field in this mutation.
  13880. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  13881. v := m.addnid
  13882. if v == nil {
  13883. return
  13884. }
  13885. return *v, true
  13886. }
  13887. // ResetNid resets all changes to the "nid" field.
  13888. func (m *CreditUsageMutation) ResetNid() {
  13889. m.nid = nil
  13890. m.addnid = nil
  13891. }
  13892. // SetReason sets the "reason" field.
  13893. func (m *CreditUsageMutation) SetReason(s string) {
  13894. m.reason = &s
  13895. }
  13896. // Reason returns the value of the "reason" field in the mutation.
  13897. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  13898. v := m.reason
  13899. if v == nil {
  13900. return
  13901. }
  13902. return *v, true
  13903. }
  13904. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  13905. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13907. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  13908. if !m.op.Is(OpUpdateOne) {
  13909. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  13910. }
  13911. if m.id == nil || m.oldValue == nil {
  13912. return v, errors.New("OldReason requires an ID field in the mutation")
  13913. }
  13914. oldValue, err := m.oldValue(ctx)
  13915. if err != nil {
  13916. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  13917. }
  13918. return oldValue.Reason, nil
  13919. }
  13920. // ResetReason resets all changes to the "reason" field.
  13921. func (m *CreditUsageMutation) ResetReason() {
  13922. m.reason = nil
  13923. }
  13924. // SetOperator sets the "operator" field.
  13925. func (m *CreditUsageMutation) SetOperator(s string) {
  13926. m.operator = &s
  13927. }
  13928. // Operator returns the value of the "operator" field in the mutation.
  13929. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  13930. v := m.operator
  13931. if v == nil {
  13932. return
  13933. }
  13934. return *v, true
  13935. }
  13936. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  13937. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  13938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13939. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  13940. if !m.op.Is(OpUpdateOne) {
  13941. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  13942. }
  13943. if m.id == nil || m.oldValue == nil {
  13944. return v, errors.New("OldOperator requires an ID field in the mutation")
  13945. }
  13946. oldValue, err := m.oldValue(ctx)
  13947. if err != nil {
  13948. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  13949. }
  13950. return oldValue.Operator, nil
  13951. }
  13952. // ResetOperator resets all changes to the "operator" field.
  13953. func (m *CreditUsageMutation) ResetOperator() {
  13954. m.operator = nil
  13955. }
  13956. // Where appends a list predicates to the CreditUsageMutation builder.
  13957. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  13958. m.predicates = append(m.predicates, ps...)
  13959. }
  13960. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  13961. // users can use type-assertion to append predicates that do not depend on any generated package.
  13962. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  13963. p := make([]predicate.CreditUsage, len(ps))
  13964. for i := range ps {
  13965. p[i] = ps[i]
  13966. }
  13967. m.Where(p...)
  13968. }
  13969. // Op returns the operation name.
  13970. func (m *CreditUsageMutation) Op() Op {
  13971. return m.op
  13972. }
  13973. // SetOp allows setting the mutation operation.
  13974. func (m *CreditUsageMutation) SetOp(op Op) {
  13975. m.op = op
  13976. }
  13977. // Type returns the node type of this mutation (CreditUsage).
  13978. func (m *CreditUsageMutation) Type() string {
  13979. return m.typ
  13980. }
  13981. // Fields returns all fields that were changed during this mutation. Note that in
  13982. // order to get all numeric fields that were incremented/decremented, call
  13983. // AddedFields().
  13984. func (m *CreditUsageMutation) Fields() []string {
  13985. fields := make([]string, 0, 12)
  13986. if m.created_at != nil {
  13987. fields = append(fields, creditusage.FieldCreatedAt)
  13988. }
  13989. if m.updated_at != nil {
  13990. fields = append(fields, creditusage.FieldUpdatedAt)
  13991. }
  13992. if m.deleted_at != nil {
  13993. fields = append(fields, creditusage.FieldDeletedAt)
  13994. }
  13995. if m.user_id != nil {
  13996. fields = append(fields, creditusage.FieldUserID)
  13997. }
  13998. if m.number != nil {
  13999. fields = append(fields, creditusage.FieldNumber)
  14000. }
  14001. if m.status != nil {
  14002. fields = append(fields, creditusage.FieldStatus)
  14003. }
  14004. if m.ntype != nil {
  14005. fields = append(fields, creditusage.FieldNtype)
  14006. }
  14007. if m.table != nil {
  14008. fields = append(fields, creditusage.FieldTable)
  14009. }
  14010. if m.organization_id != nil {
  14011. fields = append(fields, creditusage.FieldOrganizationID)
  14012. }
  14013. if m.nid != nil {
  14014. fields = append(fields, creditusage.FieldNid)
  14015. }
  14016. if m.reason != nil {
  14017. fields = append(fields, creditusage.FieldReason)
  14018. }
  14019. if m.operator != nil {
  14020. fields = append(fields, creditusage.FieldOperator)
  14021. }
  14022. return fields
  14023. }
  14024. // Field returns the value of a field with the given name. The second boolean
  14025. // return value indicates that this field was not set, or was not defined in the
  14026. // schema.
  14027. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  14028. switch name {
  14029. case creditusage.FieldCreatedAt:
  14030. return m.CreatedAt()
  14031. case creditusage.FieldUpdatedAt:
  14032. return m.UpdatedAt()
  14033. case creditusage.FieldDeletedAt:
  14034. return m.DeletedAt()
  14035. case creditusage.FieldUserID:
  14036. return m.UserID()
  14037. case creditusage.FieldNumber:
  14038. return m.Number()
  14039. case creditusage.FieldStatus:
  14040. return m.Status()
  14041. case creditusage.FieldNtype:
  14042. return m.Ntype()
  14043. case creditusage.FieldTable:
  14044. return m.Table()
  14045. case creditusage.FieldOrganizationID:
  14046. return m.OrganizationID()
  14047. case creditusage.FieldNid:
  14048. return m.Nid()
  14049. case creditusage.FieldReason:
  14050. return m.Reason()
  14051. case creditusage.FieldOperator:
  14052. return m.Operator()
  14053. }
  14054. return nil, false
  14055. }
  14056. // OldField returns the old value of the field from the database. An error is
  14057. // returned if the mutation operation is not UpdateOne, or the query to the
  14058. // database failed.
  14059. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14060. switch name {
  14061. case creditusage.FieldCreatedAt:
  14062. return m.OldCreatedAt(ctx)
  14063. case creditusage.FieldUpdatedAt:
  14064. return m.OldUpdatedAt(ctx)
  14065. case creditusage.FieldDeletedAt:
  14066. return m.OldDeletedAt(ctx)
  14067. case creditusage.FieldUserID:
  14068. return m.OldUserID(ctx)
  14069. case creditusage.FieldNumber:
  14070. return m.OldNumber(ctx)
  14071. case creditusage.FieldStatus:
  14072. return m.OldStatus(ctx)
  14073. case creditusage.FieldNtype:
  14074. return m.OldNtype(ctx)
  14075. case creditusage.FieldTable:
  14076. return m.OldTable(ctx)
  14077. case creditusage.FieldOrganizationID:
  14078. return m.OldOrganizationID(ctx)
  14079. case creditusage.FieldNid:
  14080. return m.OldNid(ctx)
  14081. case creditusage.FieldReason:
  14082. return m.OldReason(ctx)
  14083. case creditusage.FieldOperator:
  14084. return m.OldOperator(ctx)
  14085. }
  14086. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  14087. }
  14088. // SetField sets the value of a field with the given name. It returns an error if
  14089. // the field is not defined in the schema, or if the type mismatched the field
  14090. // type.
  14091. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  14092. switch name {
  14093. case creditusage.FieldCreatedAt:
  14094. v, ok := value.(time.Time)
  14095. if !ok {
  14096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14097. }
  14098. m.SetCreatedAt(v)
  14099. return nil
  14100. case creditusage.FieldUpdatedAt:
  14101. v, ok := value.(time.Time)
  14102. if !ok {
  14103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14104. }
  14105. m.SetUpdatedAt(v)
  14106. return nil
  14107. case creditusage.FieldDeletedAt:
  14108. v, ok := value.(time.Time)
  14109. if !ok {
  14110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14111. }
  14112. m.SetDeletedAt(v)
  14113. return nil
  14114. case creditusage.FieldUserID:
  14115. v, ok := value.(string)
  14116. if !ok {
  14117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14118. }
  14119. m.SetUserID(v)
  14120. return nil
  14121. case creditusage.FieldNumber:
  14122. v, ok := value.(float32)
  14123. if !ok {
  14124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14125. }
  14126. m.SetNumber(v)
  14127. return nil
  14128. case creditusage.FieldStatus:
  14129. v, ok := value.(int)
  14130. if !ok {
  14131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14132. }
  14133. m.SetStatus(v)
  14134. return nil
  14135. case creditusage.FieldNtype:
  14136. v, ok := value.(int)
  14137. if !ok {
  14138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14139. }
  14140. m.SetNtype(v)
  14141. return nil
  14142. case creditusage.FieldTable:
  14143. v, ok := value.(string)
  14144. if !ok {
  14145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14146. }
  14147. m.SetTable(v)
  14148. return nil
  14149. case creditusage.FieldOrganizationID:
  14150. v, ok := value.(uint64)
  14151. if !ok {
  14152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14153. }
  14154. m.SetOrganizationID(v)
  14155. return nil
  14156. case creditusage.FieldNid:
  14157. v, ok := value.(uint64)
  14158. if !ok {
  14159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14160. }
  14161. m.SetNid(v)
  14162. return nil
  14163. case creditusage.FieldReason:
  14164. v, ok := value.(string)
  14165. if !ok {
  14166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14167. }
  14168. m.SetReason(v)
  14169. return nil
  14170. case creditusage.FieldOperator:
  14171. v, ok := value.(string)
  14172. if !ok {
  14173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14174. }
  14175. m.SetOperator(v)
  14176. return nil
  14177. }
  14178. return fmt.Errorf("unknown CreditUsage field %s", name)
  14179. }
  14180. // AddedFields returns all numeric fields that were incremented/decremented during
  14181. // this mutation.
  14182. func (m *CreditUsageMutation) AddedFields() []string {
  14183. var fields []string
  14184. if m.addnumber != nil {
  14185. fields = append(fields, creditusage.FieldNumber)
  14186. }
  14187. if m.addstatus != nil {
  14188. fields = append(fields, creditusage.FieldStatus)
  14189. }
  14190. if m.addntype != nil {
  14191. fields = append(fields, creditusage.FieldNtype)
  14192. }
  14193. if m.addorganization_id != nil {
  14194. fields = append(fields, creditusage.FieldOrganizationID)
  14195. }
  14196. if m.addnid != nil {
  14197. fields = append(fields, creditusage.FieldNid)
  14198. }
  14199. return fields
  14200. }
  14201. // AddedField returns the numeric value that was incremented/decremented on a field
  14202. // with the given name. The second boolean return value indicates that this field
  14203. // was not set, or was not defined in the schema.
  14204. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  14205. switch name {
  14206. case creditusage.FieldNumber:
  14207. return m.AddedNumber()
  14208. case creditusage.FieldStatus:
  14209. return m.AddedStatus()
  14210. case creditusage.FieldNtype:
  14211. return m.AddedNtype()
  14212. case creditusage.FieldOrganizationID:
  14213. return m.AddedOrganizationID()
  14214. case creditusage.FieldNid:
  14215. return m.AddedNid()
  14216. }
  14217. return nil, false
  14218. }
  14219. // AddField adds the value to the field with the given name. It returns an error if
  14220. // the field is not defined in the schema, or if the type mismatched the field
  14221. // type.
  14222. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  14223. switch name {
  14224. case creditusage.FieldNumber:
  14225. v, ok := value.(float32)
  14226. if !ok {
  14227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14228. }
  14229. m.AddNumber(v)
  14230. return nil
  14231. case creditusage.FieldStatus:
  14232. v, ok := value.(int)
  14233. if !ok {
  14234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14235. }
  14236. m.AddStatus(v)
  14237. return nil
  14238. case creditusage.FieldNtype:
  14239. v, ok := value.(int)
  14240. if !ok {
  14241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14242. }
  14243. m.AddNtype(v)
  14244. return nil
  14245. case creditusage.FieldOrganizationID:
  14246. v, ok := value.(int64)
  14247. if !ok {
  14248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14249. }
  14250. m.AddOrganizationID(v)
  14251. return nil
  14252. case creditusage.FieldNid:
  14253. v, ok := value.(int64)
  14254. if !ok {
  14255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14256. }
  14257. m.AddNid(v)
  14258. return nil
  14259. }
  14260. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  14261. }
  14262. // ClearedFields returns all nullable fields that were cleared during this
  14263. // mutation.
  14264. func (m *CreditUsageMutation) ClearedFields() []string {
  14265. var fields []string
  14266. if m.FieldCleared(creditusage.FieldDeletedAt) {
  14267. fields = append(fields, creditusage.FieldDeletedAt)
  14268. }
  14269. if m.FieldCleared(creditusage.FieldUserID) {
  14270. fields = append(fields, creditusage.FieldUserID)
  14271. }
  14272. if m.FieldCleared(creditusage.FieldStatus) {
  14273. fields = append(fields, creditusage.FieldStatus)
  14274. }
  14275. if m.FieldCleared(creditusage.FieldOrganizationID) {
  14276. fields = append(fields, creditusage.FieldOrganizationID)
  14277. }
  14278. return fields
  14279. }
  14280. // FieldCleared returns a boolean indicating if a field with the given name was
  14281. // cleared in this mutation.
  14282. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  14283. _, ok := m.clearedFields[name]
  14284. return ok
  14285. }
  14286. // ClearField clears the value of the field with the given name. It returns an
  14287. // error if the field is not defined in the schema.
  14288. func (m *CreditUsageMutation) ClearField(name string) error {
  14289. switch name {
  14290. case creditusage.FieldDeletedAt:
  14291. m.ClearDeletedAt()
  14292. return nil
  14293. case creditusage.FieldUserID:
  14294. m.ClearUserID()
  14295. return nil
  14296. case creditusage.FieldStatus:
  14297. m.ClearStatus()
  14298. return nil
  14299. case creditusage.FieldOrganizationID:
  14300. m.ClearOrganizationID()
  14301. return nil
  14302. }
  14303. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  14304. }
  14305. // ResetField resets all changes in the mutation for the field with the given name.
  14306. // It returns an error if the field is not defined in the schema.
  14307. func (m *CreditUsageMutation) ResetField(name string) error {
  14308. switch name {
  14309. case creditusage.FieldCreatedAt:
  14310. m.ResetCreatedAt()
  14311. return nil
  14312. case creditusage.FieldUpdatedAt:
  14313. m.ResetUpdatedAt()
  14314. return nil
  14315. case creditusage.FieldDeletedAt:
  14316. m.ResetDeletedAt()
  14317. return nil
  14318. case creditusage.FieldUserID:
  14319. m.ResetUserID()
  14320. return nil
  14321. case creditusage.FieldNumber:
  14322. m.ResetNumber()
  14323. return nil
  14324. case creditusage.FieldStatus:
  14325. m.ResetStatus()
  14326. return nil
  14327. case creditusage.FieldNtype:
  14328. m.ResetNtype()
  14329. return nil
  14330. case creditusage.FieldTable:
  14331. m.ResetTable()
  14332. return nil
  14333. case creditusage.FieldOrganizationID:
  14334. m.ResetOrganizationID()
  14335. return nil
  14336. case creditusage.FieldNid:
  14337. m.ResetNid()
  14338. return nil
  14339. case creditusage.FieldReason:
  14340. m.ResetReason()
  14341. return nil
  14342. case creditusage.FieldOperator:
  14343. m.ResetOperator()
  14344. return nil
  14345. }
  14346. return fmt.Errorf("unknown CreditUsage field %s", name)
  14347. }
  14348. // AddedEdges returns all edge names that were set/added in this mutation.
  14349. func (m *CreditUsageMutation) AddedEdges() []string {
  14350. edges := make([]string, 0, 0)
  14351. return edges
  14352. }
  14353. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14354. // name in this mutation.
  14355. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  14356. return nil
  14357. }
  14358. // RemovedEdges returns all edge names that were removed in this mutation.
  14359. func (m *CreditUsageMutation) RemovedEdges() []string {
  14360. edges := make([]string, 0, 0)
  14361. return edges
  14362. }
  14363. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14364. // the given name in this mutation.
  14365. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  14366. return nil
  14367. }
  14368. // ClearedEdges returns all edge names that were cleared in this mutation.
  14369. func (m *CreditUsageMutation) ClearedEdges() []string {
  14370. edges := make([]string, 0, 0)
  14371. return edges
  14372. }
  14373. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14374. // was cleared in this mutation.
  14375. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  14376. return false
  14377. }
  14378. // ClearEdge clears the value of the edge with the given name. It returns an error
  14379. // if that edge is not defined in the schema.
  14380. func (m *CreditUsageMutation) ClearEdge(name string) error {
  14381. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  14382. }
  14383. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14384. // It returns an error if the edge is not defined in the schema.
  14385. func (m *CreditUsageMutation) ResetEdge(name string) error {
  14386. return fmt.Errorf("unknown CreditUsage edge %s", name)
  14387. }
  14388. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  14389. type EmployeeMutation struct {
  14390. config
  14391. op Op
  14392. typ string
  14393. id *uint64
  14394. created_at *time.Time
  14395. updated_at *time.Time
  14396. deleted_at *time.Time
  14397. title *string
  14398. avatar *string
  14399. tags *string
  14400. hire_count *int
  14401. addhire_count *int
  14402. service_count *int
  14403. addservice_count *int
  14404. achievement_count *int
  14405. addachievement_count *int
  14406. intro *string
  14407. estimate *string
  14408. skill *string
  14409. ability_type *string
  14410. scene *string
  14411. switch_in *string
  14412. video_url *string
  14413. organization_id *uint64
  14414. addorganization_id *int64
  14415. category_id *uint64
  14416. addcategory_id *int64
  14417. api_base *string
  14418. api_key *string
  14419. ai_info *string
  14420. is_vip *int
  14421. addis_vip *int
  14422. chat_url *string
  14423. clearedFields map[string]struct{}
  14424. em_work_experiences map[uint64]struct{}
  14425. removedem_work_experiences map[uint64]struct{}
  14426. clearedem_work_experiences bool
  14427. em_tutorial map[uint64]struct{}
  14428. removedem_tutorial map[uint64]struct{}
  14429. clearedem_tutorial bool
  14430. done bool
  14431. oldValue func(context.Context) (*Employee, error)
  14432. predicates []predicate.Employee
  14433. }
  14434. var _ ent.Mutation = (*EmployeeMutation)(nil)
  14435. // employeeOption allows management of the mutation configuration using functional options.
  14436. type employeeOption func(*EmployeeMutation)
  14437. // newEmployeeMutation creates new mutation for the Employee entity.
  14438. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  14439. m := &EmployeeMutation{
  14440. config: c,
  14441. op: op,
  14442. typ: TypeEmployee,
  14443. clearedFields: make(map[string]struct{}),
  14444. }
  14445. for _, opt := range opts {
  14446. opt(m)
  14447. }
  14448. return m
  14449. }
  14450. // withEmployeeID sets the ID field of the mutation.
  14451. func withEmployeeID(id uint64) employeeOption {
  14452. return func(m *EmployeeMutation) {
  14453. var (
  14454. err error
  14455. once sync.Once
  14456. value *Employee
  14457. )
  14458. m.oldValue = func(ctx context.Context) (*Employee, error) {
  14459. once.Do(func() {
  14460. if m.done {
  14461. err = errors.New("querying old values post mutation is not allowed")
  14462. } else {
  14463. value, err = m.Client().Employee.Get(ctx, id)
  14464. }
  14465. })
  14466. return value, err
  14467. }
  14468. m.id = &id
  14469. }
  14470. }
  14471. // withEmployee sets the old Employee of the mutation.
  14472. func withEmployee(node *Employee) employeeOption {
  14473. return func(m *EmployeeMutation) {
  14474. m.oldValue = func(context.Context) (*Employee, error) {
  14475. return node, nil
  14476. }
  14477. m.id = &node.ID
  14478. }
  14479. }
  14480. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14481. // executed in a transaction (ent.Tx), a transactional client is returned.
  14482. func (m EmployeeMutation) Client() *Client {
  14483. client := &Client{config: m.config}
  14484. client.init()
  14485. return client
  14486. }
  14487. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14488. // it returns an error otherwise.
  14489. func (m EmployeeMutation) Tx() (*Tx, error) {
  14490. if _, ok := m.driver.(*txDriver); !ok {
  14491. return nil, errors.New("ent: mutation is not running in a transaction")
  14492. }
  14493. tx := &Tx{config: m.config}
  14494. tx.init()
  14495. return tx, nil
  14496. }
  14497. // SetID sets the value of the id field. Note that this
  14498. // operation is only accepted on creation of Employee entities.
  14499. func (m *EmployeeMutation) SetID(id uint64) {
  14500. m.id = &id
  14501. }
  14502. // ID returns the ID value in the mutation. Note that the ID is only available
  14503. // if it was provided to the builder or after it was returned from the database.
  14504. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  14505. if m.id == nil {
  14506. return
  14507. }
  14508. return *m.id, true
  14509. }
  14510. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14511. // That means, if the mutation is applied within a transaction with an isolation level such
  14512. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14513. // or updated by the mutation.
  14514. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  14515. switch {
  14516. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14517. id, exists := m.ID()
  14518. if exists {
  14519. return []uint64{id}, nil
  14520. }
  14521. fallthrough
  14522. case m.op.Is(OpUpdate | OpDelete):
  14523. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  14524. default:
  14525. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14526. }
  14527. }
  14528. // SetCreatedAt sets the "created_at" field.
  14529. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  14530. m.created_at = &t
  14531. }
  14532. // CreatedAt returns the value of the "created_at" field in the mutation.
  14533. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  14534. v := m.created_at
  14535. if v == nil {
  14536. return
  14537. }
  14538. return *v, true
  14539. }
  14540. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  14541. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14543. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14544. if !m.op.Is(OpUpdateOne) {
  14545. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14546. }
  14547. if m.id == nil || m.oldValue == nil {
  14548. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14549. }
  14550. oldValue, err := m.oldValue(ctx)
  14551. if err != nil {
  14552. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14553. }
  14554. return oldValue.CreatedAt, nil
  14555. }
  14556. // ResetCreatedAt resets all changes to the "created_at" field.
  14557. func (m *EmployeeMutation) ResetCreatedAt() {
  14558. m.created_at = nil
  14559. }
  14560. // SetUpdatedAt sets the "updated_at" field.
  14561. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  14562. m.updated_at = &t
  14563. }
  14564. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14565. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  14566. v := m.updated_at
  14567. if v == nil {
  14568. return
  14569. }
  14570. return *v, true
  14571. }
  14572. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  14573. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14575. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14576. if !m.op.Is(OpUpdateOne) {
  14577. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14578. }
  14579. if m.id == nil || m.oldValue == nil {
  14580. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14581. }
  14582. oldValue, err := m.oldValue(ctx)
  14583. if err != nil {
  14584. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14585. }
  14586. return oldValue.UpdatedAt, nil
  14587. }
  14588. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14589. func (m *EmployeeMutation) ResetUpdatedAt() {
  14590. m.updated_at = nil
  14591. }
  14592. // SetDeletedAt sets the "deleted_at" field.
  14593. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  14594. m.deleted_at = &t
  14595. }
  14596. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14597. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  14598. v := m.deleted_at
  14599. if v == nil {
  14600. return
  14601. }
  14602. return *v, true
  14603. }
  14604. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  14605. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14607. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14608. if !m.op.Is(OpUpdateOne) {
  14609. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14610. }
  14611. if m.id == nil || m.oldValue == nil {
  14612. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14613. }
  14614. oldValue, err := m.oldValue(ctx)
  14615. if err != nil {
  14616. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14617. }
  14618. return oldValue.DeletedAt, nil
  14619. }
  14620. // ClearDeletedAt clears the value of the "deleted_at" field.
  14621. func (m *EmployeeMutation) ClearDeletedAt() {
  14622. m.deleted_at = nil
  14623. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  14624. }
  14625. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14626. func (m *EmployeeMutation) DeletedAtCleared() bool {
  14627. _, ok := m.clearedFields[employee.FieldDeletedAt]
  14628. return ok
  14629. }
  14630. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14631. func (m *EmployeeMutation) ResetDeletedAt() {
  14632. m.deleted_at = nil
  14633. delete(m.clearedFields, employee.FieldDeletedAt)
  14634. }
  14635. // SetTitle sets the "title" field.
  14636. func (m *EmployeeMutation) SetTitle(s string) {
  14637. m.title = &s
  14638. }
  14639. // Title returns the value of the "title" field in the mutation.
  14640. func (m *EmployeeMutation) Title() (r string, exists bool) {
  14641. v := m.title
  14642. if v == nil {
  14643. return
  14644. }
  14645. return *v, true
  14646. }
  14647. // OldTitle returns the old "title" field's value of the Employee entity.
  14648. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14650. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  14651. if !m.op.Is(OpUpdateOne) {
  14652. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  14653. }
  14654. if m.id == nil || m.oldValue == nil {
  14655. return v, errors.New("OldTitle requires an ID field in the mutation")
  14656. }
  14657. oldValue, err := m.oldValue(ctx)
  14658. if err != nil {
  14659. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  14660. }
  14661. return oldValue.Title, nil
  14662. }
  14663. // ResetTitle resets all changes to the "title" field.
  14664. func (m *EmployeeMutation) ResetTitle() {
  14665. m.title = nil
  14666. }
  14667. // SetAvatar sets the "avatar" field.
  14668. func (m *EmployeeMutation) SetAvatar(s string) {
  14669. m.avatar = &s
  14670. }
  14671. // Avatar returns the value of the "avatar" field in the mutation.
  14672. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  14673. v := m.avatar
  14674. if v == nil {
  14675. return
  14676. }
  14677. return *v, true
  14678. }
  14679. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  14680. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14682. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  14683. if !m.op.Is(OpUpdateOne) {
  14684. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  14685. }
  14686. if m.id == nil || m.oldValue == nil {
  14687. return v, errors.New("OldAvatar requires an ID field in the mutation")
  14688. }
  14689. oldValue, err := m.oldValue(ctx)
  14690. if err != nil {
  14691. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  14692. }
  14693. return oldValue.Avatar, nil
  14694. }
  14695. // ResetAvatar resets all changes to the "avatar" field.
  14696. func (m *EmployeeMutation) ResetAvatar() {
  14697. m.avatar = nil
  14698. }
  14699. // SetTags sets the "tags" field.
  14700. func (m *EmployeeMutation) SetTags(s string) {
  14701. m.tags = &s
  14702. }
  14703. // Tags returns the value of the "tags" field in the mutation.
  14704. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  14705. v := m.tags
  14706. if v == nil {
  14707. return
  14708. }
  14709. return *v, true
  14710. }
  14711. // OldTags returns the old "tags" field's value of the Employee entity.
  14712. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14714. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  14715. if !m.op.Is(OpUpdateOne) {
  14716. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  14717. }
  14718. if m.id == nil || m.oldValue == nil {
  14719. return v, errors.New("OldTags requires an ID field in the mutation")
  14720. }
  14721. oldValue, err := m.oldValue(ctx)
  14722. if err != nil {
  14723. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  14724. }
  14725. return oldValue.Tags, nil
  14726. }
  14727. // ResetTags resets all changes to the "tags" field.
  14728. func (m *EmployeeMutation) ResetTags() {
  14729. m.tags = nil
  14730. }
  14731. // SetHireCount sets the "hire_count" field.
  14732. func (m *EmployeeMutation) SetHireCount(i int) {
  14733. m.hire_count = &i
  14734. m.addhire_count = nil
  14735. }
  14736. // HireCount returns the value of the "hire_count" field in the mutation.
  14737. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  14738. v := m.hire_count
  14739. if v == nil {
  14740. return
  14741. }
  14742. return *v, true
  14743. }
  14744. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  14745. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14747. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  14748. if !m.op.Is(OpUpdateOne) {
  14749. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  14750. }
  14751. if m.id == nil || m.oldValue == nil {
  14752. return v, errors.New("OldHireCount requires an ID field in the mutation")
  14753. }
  14754. oldValue, err := m.oldValue(ctx)
  14755. if err != nil {
  14756. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  14757. }
  14758. return oldValue.HireCount, nil
  14759. }
  14760. // AddHireCount adds i to the "hire_count" field.
  14761. func (m *EmployeeMutation) AddHireCount(i int) {
  14762. if m.addhire_count != nil {
  14763. *m.addhire_count += i
  14764. } else {
  14765. m.addhire_count = &i
  14766. }
  14767. }
  14768. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  14769. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  14770. v := m.addhire_count
  14771. if v == nil {
  14772. return
  14773. }
  14774. return *v, true
  14775. }
  14776. // ResetHireCount resets all changes to the "hire_count" field.
  14777. func (m *EmployeeMutation) ResetHireCount() {
  14778. m.hire_count = nil
  14779. m.addhire_count = nil
  14780. }
  14781. // SetServiceCount sets the "service_count" field.
  14782. func (m *EmployeeMutation) SetServiceCount(i int) {
  14783. m.service_count = &i
  14784. m.addservice_count = nil
  14785. }
  14786. // ServiceCount returns the value of the "service_count" field in the mutation.
  14787. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  14788. v := m.service_count
  14789. if v == nil {
  14790. return
  14791. }
  14792. return *v, true
  14793. }
  14794. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  14795. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14797. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  14798. if !m.op.Is(OpUpdateOne) {
  14799. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  14800. }
  14801. if m.id == nil || m.oldValue == nil {
  14802. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  14803. }
  14804. oldValue, err := m.oldValue(ctx)
  14805. if err != nil {
  14806. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  14807. }
  14808. return oldValue.ServiceCount, nil
  14809. }
  14810. // AddServiceCount adds i to the "service_count" field.
  14811. func (m *EmployeeMutation) AddServiceCount(i int) {
  14812. if m.addservice_count != nil {
  14813. *m.addservice_count += i
  14814. } else {
  14815. m.addservice_count = &i
  14816. }
  14817. }
  14818. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  14819. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  14820. v := m.addservice_count
  14821. if v == nil {
  14822. return
  14823. }
  14824. return *v, true
  14825. }
  14826. // ResetServiceCount resets all changes to the "service_count" field.
  14827. func (m *EmployeeMutation) ResetServiceCount() {
  14828. m.service_count = nil
  14829. m.addservice_count = nil
  14830. }
  14831. // SetAchievementCount sets the "achievement_count" field.
  14832. func (m *EmployeeMutation) SetAchievementCount(i int) {
  14833. m.achievement_count = &i
  14834. m.addachievement_count = nil
  14835. }
  14836. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  14837. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  14838. v := m.achievement_count
  14839. if v == nil {
  14840. return
  14841. }
  14842. return *v, true
  14843. }
  14844. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  14845. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14847. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  14848. if !m.op.Is(OpUpdateOne) {
  14849. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  14850. }
  14851. if m.id == nil || m.oldValue == nil {
  14852. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  14853. }
  14854. oldValue, err := m.oldValue(ctx)
  14855. if err != nil {
  14856. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  14857. }
  14858. return oldValue.AchievementCount, nil
  14859. }
  14860. // AddAchievementCount adds i to the "achievement_count" field.
  14861. func (m *EmployeeMutation) AddAchievementCount(i int) {
  14862. if m.addachievement_count != nil {
  14863. *m.addachievement_count += i
  14864. } else {
  14865. m.addachievement_count = &i
  14866. }
  14867. }
  14868. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  14869. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  14870. v := m.addachievement_count
  14871. if v == nil {
  14872. return
  14873. }
  14874. return *v, true
  14875. }
  14876. // ResetAchievementCount resets all changes to the "achievement_count" field.
  14877. func (m *EmployeeMutation) ResetAchievementCount() {
  14878. m.achievement_count = nil
  14879. m.addachievement_count = nil
  14880. }
  14881. // SetIntro sets the "intro" field.
  14882. func (m *EmployeeMutation) SetIntro(s string) {
  14883. m.intro = &s
  14884. }
  14885. // Intro returns the value of the "intro" field in the mutation.
  14886. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  14887. v := m.intro
  14888. if v == nil {
  14889. return
  14890. }
  14891. return *v, true
  14892. }
  14893. // OldIntro returns the old "intro" field's value of the Employee entity.
  14894. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14896. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  14897. if !m.op.Is(OpUpdateOne) {
  14898. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  14899. }
  14900. if m.id == nil || m.oldValue == nil {
  14901. return v, errors.New("OldIntro requires an ID field in the mutation")
  14902. }
  14903. oldValue, err := m.oldValue(ctx)
  14904. if err != nil {
  14905. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  14906. }
  14907. return oldValue.Intro, nil
  14908. }
  14909. // ResetIntro resets all changes to the "intro" field.
  14910. func (m *EmployeeMutation) ResetIntro() {
  14911. m.intro = nil
  14912. }
  14913. // SetEstimate sets the "estimate" field.
  14914. func (m *EmployeeMutation) SetEstimate(s string) {
  14915. m.estimate = &s
  14916. }
  14917. // Estimate returns the value of the "estimate" field in the mutation.
  14918. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  14919. v := m.estimate
  14920. if v == nil {
  14921. return
  14922. }
  14923. return *v, true
  14924. }
  14925. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  14926. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14928. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  14929. if !m.op.Is(OpUpdateOne) {
  14930. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  14931. }
  14932. if m.id == nil || m.oldValue == nil {
  14933. return v, errors.New("OldEstimate requires an ID field in the mutation")
  14934. }
  14935. oldValue, err := m.oldValue(ctx)
  14936. if err != nil {
  14937. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  14938. }
  14939. return oldValue.Estimate, nil
  14940. }
  14941. // ResetEstimate resets all changes to the "estimate" field.
  14942. func (m *EmployeeMutation) ResetEstimate() {
  14943. m.estimate = nil
  14944. }
  14945. // SetSkill sets the "skill" field.
  14946. func (m *EmployeeMutation) SetSkill(s string) {
  14947. m.skill = &s
  14948. }
  14949. // Skill returns the value of the "skill" field in the mutation.
  14950. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  14951. v := m.skill
  14952. if v == nil {
  14953. return
  14954. }
  14955. return *v, true
  14956. }
  14957. // OldSkill returns the old "skill" field's value of the Employee entity.
  14958. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14960. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  14961. if !m.op.Is(OpUpdateOne) {
  14962. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  14963. }
  14964. if m.id == nil || m.oldValue == nil {
  14965. return v, errors.New("OldSkill requires an ID field in the mutation")
  14966. }
  14967. oldValue, err := m.oldValue(ctx)
  14968. if err != nil {
  14969. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  14970. }
  14971. return oldValue.Skill, nil
  14972. }
  14973. // ResetSkill resets all changes to the "skill" field.
  14974. func (m *EmployeeMutation) ResetSkill() {
  14975. m.skill = nil
  14976. }
  14977. // SetAbilityType sets the "ability_type" field.
  14978. func (m *EmployeeMutation) SetAbilityType(s string) {
  14979. m.ability_type = &s
  14980. }
  14981. // AbilityType returns the value of the "ability_type" field in the mutation.
  14982. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  14983. v := m.ability_type
  14984. if v == nil {
  14985. return
  14986. }
  14987. return *v, true
  14988. }
  14989. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  14990. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  14991. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14992. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  14993. if !m.op.Is(OpUpdateOne) {
  14994. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  14995. }
  14996. if m.id == nil || m.oldValue == nil {
  14997. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  14998. }
  14999. oldValue, err := m.oldValue(ctx)
  15000. if err != nil {
  15001. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  15002. }
  15003. return oldValue.AbilityType, nil
  15004. }
  15005. // ResetAbilityType resets all changes to the "ability_type" field.
  15006. func (m *EmployeeMutation) ResetAbilityType() {
  15007. m.ability_type = nil
  15008. }
  15009. // SetScene sets the "scene" field.
  15010. func (m *EmployeeMutation) SetScene(s string) {
  15011. m.scene = &s
  15012. }
  15013. // Scene returns the value of the "scene" field in the mutation.
  15014. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  15015. v := m.scene
  15016. if v == nil {
  15017. return
  15018. }
  15019. return *v, true
  15020. }
  15021. // OldScene returns the old "scene" field's value of the Employee entity.
  15022. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15024. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  15025. if !m.op.Is(OpUpdateOne) {
  15026. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  15027. }
  15028. if m.id == nil || m.oldValue == nil {
  15029. return v, errors.New("OldScene requires an ID field in the mutation")
  15030. }
  15031. oldValue, err := m.oldValue(ctx)
  15032. if err != nil {
  15033. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  15034. }
  15035. return oldValue.Scene, nil
  15036. }
  15037. // ResetScene resets all changes to the "scene" field.
  15038. func (m *EmployeeMutation) ResetScene() {
  15039. m.scene = nil
  15040. }
  15041. // SetSwitchIn sets the "switch_in" field.
  15042. func (m *EmployeeMutation) SetSwitchIn(s string) {
  15043. m.switch_in = &s
  15044. }
  15045. // SwitchIn returns the value of the "switch_in" field in the mutation.
  15046. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  15047. v := m.switch_in
  15048. if v == nil {
  15049. return
  15050. }
  15051. return *v, true
  15052. }
  15053. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  15054. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15056. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  15057. if !m.op.Is(OpUpdateOne) {
  15058. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  15059. }
  15060. if m.id == nil || m.oldValue == nil {
  15061. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  15062. }
  15063. oldValue, err := m.oldValue(ctx)
  15064. if err != nil {
  15065. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  15066. }
  15067. return oldValue.SwitchIn, nil
  15068. }
  15069. // ResetSwitchIn resets all changes to the "switch_in" field.
  15070. func (m *EmployeeMutation) ResetSwitchIn() {
  15071. m.switch_in = nil
  15072. }
  15073. // SetVideoURL sets the "video_url" field.
  15074. func (m *EmployeeMutation) SetVideoURL(s string) {
  15075. m.video_url = &s
  15076. }
  15077. // VideoURL returns the value of the "video_url" field in the mutation.
  15078. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  15079. v := m.video_url
  15080. if v == nil {
  15081. return
  15082. }
  15083. return *v, true
  15084. }
  15085. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  15086. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15088. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  15089. if !m.op.Is(OpUpdateOne) {
  15090. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  15091. }
  15092. if m.id == nil || m.oldValue == nil {
  15093. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  15094. }
  15095. oldValue, err := m.oldValue(ctx)
  15096. if err != nil {
  15097. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  15098. }
  15099. return oldValue.VideoURL, nil
  15100. }
  15101. // ResetVideoURL resets all changes to the "video_url" field.
  15102. func (m *EmployeeMutation) ResetVideoURL() {
  15103. m.video_url = nil
  15104. }
  15105. // SetOrganizationID sets the "organization_id" field.
  15106. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  15107. m.organization_id = &u
  15108. m.addorganization_id = nil
  15109. }
  15110. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15111. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  15112. v := m.organization_id
  15113. if v == nil {
  15114. return
  15115. }
  15116. return *v, true
  15117. }
  15118. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  15119. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15121. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15122. if !m.op.Is(OpUpdateOne) {
  15123. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15124. }
  15125. if m.id == nil || m.oldValue == nil {
  15126. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15127. }
  15128. oldValue, err := m.oldValue(ctx)
  15129. if err != nil {
  15130. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15131. }
  15132. return oldValue.OrganizationID, nil
  15133. }
  15134. // AddOrganizationID adds u to the "organization_id" field.
  15135. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  15136. if m.addorganization_id != nil {
  15137. *m.addorganization_id += u
  15138. } else {
  15139. m.addorganization_id = &u
  15140. }
  15141. }
  15142. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15143. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  15144. v := m.addorganization_id
  15145. if v == nil {
  15146. return
  15147. }
  15148. return *v, true
  15149. }
  15150. // ResetOrganizationID resets all changes to the "organization_id" field.
  15151. func (m *EmployeeMutation) ResetOrganizationID() {
  15152. m.organization_id = nil
  15153. m.addorganization_id = nil
  15154. }
  15155. // SetCategoryID sets the "category_id" field.
  15156. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  15157. m.category_id = &u
  15158. m.addcategory_id = nil
  15159. }
  15160. // CategoryID returns the value of the "category_id" field in the mutation.
  15161. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  15162. v := m.category_id
  15163. if v == nil {
  15164. return
  15165. }
  15166. return *v, true
  15167. }
  15168. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  15169. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15171. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  15172. if !m.op.Is(OpUpdateOne) {
  15173. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  15174. }
  15175. if m.id == nil || m.oldValue == nil {
  15176. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  15177. }
  15178. oldValue, err := m.oldValue(ctx)
  15179. if err != nil {
  15180. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  15181. }
  15182. return oldValue.CategoryID, nil
  15183. }
  15184. // AddCategoryID adds u to the "category_id" field.
  15185. func (m *EmployeeMutation) AddCategoryID(u int64) {
  15186. if m.addcategory_id != nil {
  15187. *m.addcategory_id += u
  15188. } else {
  15189. m.addcategory_id = &u
  15190. }
  15191. }
  15192. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  15193. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  15194. v := m.addcategory_id
  15195. if v == nil {
  15196. return
  15197. }
  15198. return *v, true
  15199. }
  15200. // ResetCategoryID resets all changes to the "category_id" field.
  15201. func (m *EmployeeMutation) ResetCategoryID() {
  15202. m.category_id = nil
  15203. m.addcategory_id = nil
  15204. }
  15205. // SetAPIBase sets the "api_base" field.
  15206. func (m *EmployeeMutation) SetAPIBase(s string) {
  15207. m.api_base = &s
  15208. }
  15209. // APIBase returns the value of the "api_base" field in the mutation.
  15210. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  15211. v := m.api_base
  15212. if v == nil {
  15213. return
  15214. }
  15215. return *v, true
  15216. }
  15217. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  15218. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15220. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  15221. if !m.op.Is(OpUpdateOne) {
  15222. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  15223. }
  15224. if m.id == nil || m.oldValue == nil {
  15225. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  15226. }
  15227. oldValue, err := m.oldValue(ctx)
  15228. if err != nil {
  15229. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  15230. }
  15231. return oldValue.APIBase, nil
  15232. }
  15233. // ResetAPIBase resets all changes to the "api_base" field.
  15234. func (m *EmployeeMutation) ResetAPIBase() {
  15235. m.api_base = nil
  15236. }
  15237. // SetAPIKey sets the "api_key" field.
  15238. func (m *EmployeeMutation) SetAPIKey(s string) {
  15239. m.api_key = &s
  15240. }
  15241. // APIKey returns the value of the "api_key" field in the mutation.
  15242. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  15243. v := m.api_key
  15244. if v == nil {
  15245. return
  15246. }
  15247. return *v, true
  15248. }
  15249. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  15250. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15252. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  15253. if !m.op.Is(OpUpdateOne) {
  15254. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  15255. }
  15256. if m.id == nil || m.oldValue == nil {
  15257. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  15258. }
  15259. oldValue, err := m.oldValue(ctx)
  15260. if err != nil {
  15261. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  15262. }
  15263. return oldValue.APIKey, nil
  15264. }
  15265. // ResetAPIKey resets all changes to the "api_key" field.
  15266. func (m *EmployeeMutation) ResetAPIKey() {
  15267. m.api_key = nil
  15268. }
  15269. // SetAiInfo sets the "ai_info" field.
  15270. func (m *EmployeeMutation) SetAiInfo(s string) {
  15271. m.ai_info = &s
  15272. }
  15273. // AiInfo returns the value of the "ai_info" field in the mutation.
  15274. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  15275. v := m.ai_info
  15276. if v == nil {
  15277. return
  15278. }
  15279. return *v, true
  15280. }
  15281. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  15282. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15284. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  15285. if !m.op.Is(OpUpdateOne) {
  15286. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  15287. }
  15288. if m.id == nil || m.oldValue == nil {
  15289. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  15290. }
  15291. oldValue, err := m.oldValue(ctx)
  15292. if err != nil {
  15293. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  15294. }
  15295. return oldValue.AiInfo, nil
  15296. }
  15297. // ClearAiInfo clears the value of the "ai_info" field.
  15298. func (m *EmployeeMutation) ClearAiInfo() {
  15299. m.ai_info = nil
  15300. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  15301. }
  15302. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  15303. func (m *EmployeeMutation) AiInfoCleared() bool {
  15304. _, ok := m.clearedFields[employee.FieldAiInfo]
  15305. return ok
  15306. }
  15307. // ResetAiInfo resets all changes to the "ai_info" field.
  15308. func (m *EmployeeMutation) ResetAiInfo() {
  15309. m.ai_info = nil
  15310. delete(m.clearedFields, employee.FieldAiInfo)
  15311. }
  15312. // SetIsVip sets the "is_vip" field.
  15313. func (m *EmployeeMutation) SetIsVip(i int) {
  15314. m.is_vip = &i
  15315. m.addis_vip = nil
  15316. }
  15317. // IsVip returns the value of the "is_vip" field in the mutation.
  15318. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  15319. v := m.is_vip
  15320. if v == nil {
  15321. return
  15322. }
  15323. return *v, true
  15324. }
  15325. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  15326. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15328. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  15329. if !m.op.Is(OpUpdateOne) {
  15330. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  15331. }
  15332. if m.id == nil || m.oldValue == nil {
  15333. return v, errors.New("OldIsVip requires an ID field in the mutation")
  15334. }
  15335. oldValue, err := m.oldValue(ctx)
  15336. if err != nil {
  15337. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  15338. }
  15339. return oldValue.IsVip, nil
  15340. }
  15341. // AddIsVip adds i to the "is_vip" field.
  15342. func (m *EmployeeMutation) AddIsVip(i int) {
  15343. if m.addis_vip != nil {
  15344. *m.addis_vip += i
  15345. } else {
  15346. m.addis_vip = &i
  15347. }
  15348. }
  15349. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  15350. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  15351. v := m.addis_vip
  15352. if v == nil {
  15353. return
  15354. }
  15355. return *v, true
  15356. }
  15357. // ResetIsVip resets all changes to the "is_vip" field.
  15358. func (m *EmployeeMutation) ResetIsVip() {
  15359. m.is_vip = nil
  15360. m.addis_vip = nil
  15361. }
  15362. // SetChatURL sets the "chat_url" field.
  15363. func (m *EmployeeMutation) SetChatURL(s string) {
  15364. m.chat_url = &s
  15365. }
  15366. // ChatURL returns the value of the "chat_url" field in the mutation.
  15367. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  15368. v := m.chat_url
  15369. if v == nil {
  15370. return
  15371. }
  15372. return *v, true
  15373. }
  15374. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  15375. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  15376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15377. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  15378. if !m.op.Is(OpUpdateOne) {
  15379. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  15380. }
  15381. if m.id == nil || m.oldValue == nil {
  15382. return v, errors.New("OldChatURL requires an ID field in the mutation")
  15383. }
  15384. oldValue, err := m.oldValue(ctx)
  15385. if err != nil {
  15386. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  15387. }
  15388. return oldValue.ChatURL, nil
  15389. }
  15390. // ResetChatURL resets all changes to the "chat_url" field.
  15391. func (m *EmployeeMutation) ResetChatURL() {
  15392. m.chat_url = nil
  15393. }
  15394. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  15395. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  15396. if m.em_work_experiences == nil {
  15397. m.em_work_experiences = make(map[uint64]struct{})
  15398. }
  15399. for i := range ids {
  15400. m.em_work_experiences[ids[i]] = struct{}{}
  15401. }
  15402. }
  15403. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  15404. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  15405. m.clearedem_work_experiences = true
  15406. }
  15407. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  15408. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  15409. return m.clearedem_work_experiences
  15410. }
  15411. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  15412. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  15413. if m.removedem_work_experiences == nil {
  15414. m.removedem_work_experiences = make(map[uint64]struct{})
  15415. }
  15416. for i := range ids {
  15417. delete(m.em_work_experiences, ids[i])
  15418. m.removedem_work_experiences[ids[i]] = struct{}{}
  15419. }
  15420. }
  15421. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  15422. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  15423. for id := range m.removedem_work_experiences {
  15424. ids = append(ids, id)
  15425. }
  15426. return
  15427. }
  15428. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  15429. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  15430. for id := range m.em_work_experiences {
  15431. ids = append(ids, id)
  15432. }
  15433. return
  15434. }
  15435. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  15436. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  15437. m.em_work_experiences = nil
  15438. m.clearedem_work_experiences = false
  15439. m.removedem_work_experiences = nil
  15440. }
  15441. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  15442. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  15443. if m.em_tutorial == nil {
  15444. m.em_tutorial = make(map[uint64]struct{})
  15445. }
  15446. for i := range ids {
  15447. m.em_tutorial[ids[i]] = struct{}{}
  15448. }
  15449. }
  15450. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  15451. func (m *EmployeeMutation) ClearEmTutorial() {
  15452. m.clearedem_tutorial = true
  15453. }
  15454. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  15455. func (m *EmployeeMutation) EmTutorialCleared() bool {
  15456. return m.clearedem_tutorial
  15457. }
  15458. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  15459. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  15460. if m.removedem_tutorial == nil {
  15461. m.removedem_tutorial = make(map[uint64]struct{})
  15462. }
  15463. for i := range ids {
  15464. delete(m.em_tutorial, ids[i])
  15465. m.removedem_tutorial[ids[i]] = struct{}{}
  15466. }
  15467. }
  15468. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  15469. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  15470. for id := range m.removedem_tutorial {
  15471. ids = append(ids, id)
  15472. }
  15473. return
  15474. }
  15475. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  15476. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  15477. for id := range m.em_tutorial {
  15478. ids = append(ids, id)
  15479. }
  15480. return
  15481. }
  15482. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  15483. func (m *EmployeeMutation) ResetEmTutorial() {
  15484. m.em_tutorial = nil
  15485. m.clearedem_tutorial = false
  15486. m.removedem_tutorial = nil
  15487. }
  15488. // Where appends a list predicates to the EmployeeMutation builder.
  15489. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  15490. m.predicates = append(m.predicates, ps...)
  15491. }
  15492. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  15493. // users can use type-assertion to append predicates that do not depend on any generated package.
  15494. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  15495. p := make([]predicate.Employee, len(ps))
  15496. for i := range ps {
  15497. p[i] = ps[i]
  15498. }
  15499. m.Where(p...)
  15500. }
  15501. // Op returns the operation name.
  15502. func (m *EmployeeMutation) Op() Op {
  15503. return m.op
  15504. }
  15505. // SetOp allows setting the mutation operation.
  15506. func (m *EmployeeMutation) SetOp(op Op) {
  15507. m.op = op
  15508. }
  15509. // Type returns the node type of this mutation (Employee).
  15510. func (m *EmployeeMutation) Type() string {
  15511. return m.typ
  15512. }
  15513. // Fields returns all fields that were changed during this mutation. Note that in
  15514. // order to get all numeric fields that were incremented/decremented, call
  15515. // AddedFields().
  15516. func (m *EmployeeMutation) Fields() []string {
  15517. fields := make([]string, 0, 23)
  15518. if m.created_at != nil {
  15519. fields = append(fields, employee.FieldCreatedAt)
  15520. }
  15521. if m.updated_at != nil {
  15522. fields = append(fields, employee.FieldUpdatedAt)
  15523. }
  15524. if m.deleted_at != nil {
  15525. fields = append(fields, employee.FieldDeletedAt)
  15526. }
  15527. if m.title != nil {
  15528. fields = append(fields, employee.FieldTitle)
  15529. }
  15530. if m.avatar != nil {
  15531. fields = append(fields, employee.FieldAvatar)
  15532. }
  15533. if m.tags != nil {
  15534. fields = append(fields, employee.FieldTags)
  15535. }
  15536. if m.hire_count != nil {
  15537. fields = append(fields, employee.FieldHireCount)
  15538. }
  15539. if m.service_count != nil {
  15540. fields = append(fields, employee.FieldServiceCount)
  15541. }
  15542. if m.achievement_count != nil {
  15543. fields = append(fields, employee.FieldAchievementCount)
  15544. }
  15545. if m.intro != nil {
  15546. fields = append(fields, employee.FieldIntro)
  15547. }
  15548. if m.estimate != nil {
  15549. fields = append(fields, employee.FieldEstimate)
  15550. }
  15551. if m.skill != nil {
  15552. fields = append(fields, employee.FieldSkill)
  15553. }
  15554. if m.ability_type != nil {
  15555. fields = append(fields, employee.FieldAbilityType)
  15556. }
  15557. if m.scene != nil {
  15558. fields = append(fields, employee.FieldScene)
  15559. }
  15560. if m.switch_in != nil {
  15561. fields = append(fields, employee.FieldSwitchIn)
  15562. }
  15563. if m.video_url != nil {
  15564. fields = append(fields, employee.FieldVideoURL)
  15565. }
  15566. if m.organization_id != nil {
  15567. fields = append(fields, employee.FieldOrganizationID)
  15568. }
  15569. if m.category_id != nil {
  15570. fields = append(fields, employee.FieldCategoryID)
  15571. }
  15572. if m.api_base != nil {
  15573. fields = append(fields, employee.FieldAPIBase)
  15574. }
  15575. if m.api_key != nil {
  15576. fields = append(fields, employee.FieldAPIKey)
  15577. }
  15578. if m.ai_info != nil {
  15579. fields = append(fields, employee.FieldAiInfo)
  15580. }
  15581. if m.is_vip != nil {
  15582. fields = append(fields, employee.FieldIsVip)
  15583. }
  15584. if m.chat_url != nil {
  15585. fields = append(fields, employee.FieldChatURL)
  15586. }
  15587. return fields
  15588. }
  15589. // Field returns the value of a field with the given name. The second boolean
  15590. // return value indicates that this field was not set, or was not defined in the
  15591. // schema.
  15592. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  15593. switch name {
  15594. case employee.FieldCreatedAt:
  15595. return m.CreatedAt()
  15596. case employee.FieldUpdatedAt:
  15597. return m.UpdatedAt()
  15598. case employee.FieldDeletedAt:
  15599. return m.DeletedAt()
  15600. case employee.FieldTitle:
  15601. return m.Title()
  15602. case employee.FieldAvatar:
  15603. return m.Avatar()
  15604. case employee.FieldTags:
  15605. return m.Tags()
  15606. case employee.FieldHireCount:
  15607. return m.HireCount()
  15608. case employee.FieldServiceCount:
  15609. return m.ServiceCount()
  15610. case employee.FieldAchievementCount:
  15611. return m.AchievementCount()
  15612. case employee.FieldIntro:
  15613. return m.Intro()
  15614. case employee.FieldEstimate:
  15615. return m.Estimate()
  15616. case employee.FieldSkill:
  15617. return m.Skill()
  15618. case employee.FieldAbilityType:
  15619. return m.AbilityType()
  15620. case employee.FieldScene:
  15621. return m.Scene()
  15622. case employee.FieldSwitchIn:
  15623. return m.SwitchIn()
  15624. case employee.FieldVideoURL:
  15625. return m.VideoURL()
  15626. case employee.FieldOrganizationID:
  15627. return m.OrganizationID()
  15628. case employee.FieldCategoryID:
  15629. return m.CategoryID()
  15630. case employee.FieldAPIBase:
  15631. return m.APIBase()
  15632. case employee.FieldAPIKey:
  15633. return m.APIKey()
  15634. case employee.FieldAiInfo:
  15635. return m.AiInfo()
  15636. case employee.FieldIsVip:
  15637. return m.IsVip()
  15638. case employee.FieldChatURL:
  15639. return m.ChatURL()
  15640. }
  15641. return nil, false
  15642. }
  15643. // OldField returns the old value of the field from the database. An error is
  15644. // returned if the mutation operation is not UpdateOne, or the query to the
  15645. // database failed.
  15646. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15647. switch name {
  15648. case employee.FieldCreatedAt:
  15649. return m.OldCreatedAt(ctx)
  15650. case employee.FieldUpdatedAt:
  15651. return m.OldUpdatedAt(ctx)
  15652. case employee.FieldDeletedAt:
  15653. return m.OldDeletedAt(ctx)
  15654. case employee.FieldTitle:
  15655. return m.OldTitle(ctx)
  15656. case employee.FieldAvatar:
  15657. return m.OldAvatar(ctx)
  15658. case employee.FieldTags:
  15659. return m.OldTags(ctx)
  15660. case employee.FieldHireCount:
  15661. return m.OldHireCount(ctx)
  15662. case employee.FieldServiceCount:
  15663. return m.OldServiceCount(ctx)
  15664. case employee.FieldAchievementCount:
  15665. return m.OldAchievementCount(ctx)
  15666. case employee.FieldIntro:
  15667. return m.OldIntro(ctx)
  15668. case employee.FieldEstimate:
  15669. return m.OldEstimate(ctx)
  15670. case employee.FieldSkill:
  15671. return m.OldSkill(ctx)
  15672. case employee.FieldAbilityType:
  15673. return m.OldAbilityType(ctx)
  15674. case employee.FieldScene:
  15675. return m.OldScene(ctx)
  15676. case employee.FieldSwitchIn:
  15677. return m.OldSwitchIn(ctx)
  15678. case employee.FieldVideoURL:
  15679. return m.OldVideoURL(ctx)
  15680. case employee.FieldOrganizationID:
  15681. return m.OldOrganizationID(ctx)
  15682. case employee.FieldCategoryID:
  15683. return m.OldCategoryID(ctx)
  15684. case employee.FieldAPIBase:
  15685. return m.OldAPIBase(ctx)
  15686. case employee.FieldAPIKey:
  15687. return m.OldAPIKey(ctx)
  15688. case employee.FieldAiInfo:
  15689. return m.OldAiInfo(ctx)
  15690. case employee.FieldIsVip:
  15691. return m.OldIsVip(ctx)
  15692. case employee.FieldChatURL:
  15693. return m.OldChatURL(ctx)
  15694. }
  15695. return nil, fmt.Errorf("unknown Employee field %s", name)
  15696. }
  15697. // SetField sets the value of a field with the given name. It returns an error if
  15698. // the field is not defined in the schema, or if the type mismatched the field
  15699. // type.
  15700. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  15701. switch name {
  15702. case employee.FieldCreatedAt:
  15703. v, ok := value.(time.Time)
  15704. if !ok {
  15705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15706. }
  15707. m.SetCreatedAt(v)
  15708. return nil
  15709. case employee.FieldUpdatedAt:
  15710. v, ok := value.(time.Time)
  15711. if !ok {
  15712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15713. }
  15714. m.SetUpdatedAt(v)
  15715. return nil
  15716. case employee.FieldDeletedAt:
  15717. v, ok := value.(time.Time)
  15718. if !ok {
  15719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15720. }
  15721. m.SetDeletedAt(v)
  15722. return nil
  15723. case employee.FieldTitle:
  15724. v, ok := value.(string)
  15725. if !ok {
  15726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15727. }
  15728. m.SetTitle(v)
  15729. return nil
  15730. case employee.FieldAvatar:
  15731. v, ok := value.(string)
  15732. if !ok {
  15733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15734. }
  15735. m.SetAvatar(v)
  15736. return nil
  15737. case employee.FieldTags:
  15738. v, ok := value.(string)
  15739. if !ok {
  15740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15741. }
  15742. m.SetTags(v)
  15743. return nil
  15744. case employee.FieldHireCount:
  15745. v, ok := value.(int)
  15746. if !ok {
  15747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15748. }
  15749. m.SetHireCount(v)
  15750. return nil
  15751. case employee.FieldServiceCount:
  15752. v, ok := value.(int)
  15753. if !ok {
  15754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15755. }
  15756. m.SetServiceCount(v)
  15757. return nil
  15758. case employee.FieldAchievementCount:
  15759. v, ok := value.(int)
  15760. if !ok {
  15761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15762. }
  15763. m.SetAchievementCount(v)
  15764. return nil
  15765. case employee.FieldIntro:
  15766. v, ok := value.(string)
  15767. if !ok {
  15768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15769. }
  15770. m.SetIntro(v)
  15771. return nil
  15772. case employee.FieldEstimate:
  15773. v, ok := value.(string)
  15774. if !ok {
  15775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15776. }
  15777. m.SetEstimate(v)
  15778. return nil
  15779. case employee.FieldSkill:
  15780. v, ok := value.(string)
  15781. if !ok {
  15782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15783. }
  15784. m.SetSkill(v)
  15785. return nil
  15786. case employee.FieldAbilityType:
  15787. v, ok := value.(string)
  15788. if !ok {
  15789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15790. }
  15791. m.SetAbilityType(v)
  15792. return nil
  15793. case employee.FieldScene:
  15794. v, ok := value.(string)
  15795. if !ok {
  15796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15797. }
  15798. m.SetScene(v)
  15799. return nil
  15800. case employee.FieldSwitchIn:
  15801. v, ok := value.(string)
  15802. if !ok {
  15803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15804. }
  15805. m.SetSwitchIn(v)
  15806. return nil
  15807. case employee.FieldVideoURL:
  15808. v, ok := value.(string)
  15809. if !ok {
  15810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15811. }
  15812. m.SetVideoURL(v)
  15813. return nil
  15814. case employee.FieldOrganizationID:
  15815. v, ok := value.(uint64)
  15816. if !ok {
  15817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15818. }
  15819. m.SetOrganizationID(v)
  15820. return nil
  15821. case employee.FieldCategoryID:
  15822. v, ok := value.(uint64)
  15823. if !ok {
  15824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15825. }
  15826. m.SetCategoryID(v)
  15827. return nil
  15828. case employee.FieldAPIBase:
  15829. v, ok := value.(string)
  15830. if !ok {
  15831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15832. }
  15833. m.SetAPIBase(v)
  15834. return nil
  15835. case employee.FieldAPIKey:
  15836. v, ok := value.(string)
  15837. if !ok {
  15838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15839. }
  15840. m.SetAPIKey(v)
  15841. return nil
  15842. case employee.FieldAiInfo:
  15843. v, ok := value.(string)
  15844. if !ok {
  15845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15846. }
  15847. m.SetAiInfo(v)
  15848. return nil
  15849. case employee.FieldIsVip:
  15850. v, ok := value.(int)
  15851. if !ok {
  15852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15853. }
  15854. m.SetIsVip(v)
  15855. return nil
  15856. case employee.FieldChatURL:
  15857. v, ok := value.(string)
  15858. if !ok {
  15859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15860. }
  15861. m.SetChatURL(v)
  15862. return nil
  15863. }
  15864. return fmt.Errorf("unknown Employee field %s", name)
  15865. }
  15866. // AddedFields returns all numeric fields that were incremented/decremented during
  15867. // this mutation.
  15868. func (m *EmployeeMutation) AddedFields() []string {
  15869. var fields []string
  15870. if m.addhire_count != nil {
  15871. fields = append(fields, employee.FieldHireCount)
  15872. }
  15873. if m.addservice_count != nil {
  15874. fields = append(fields, employee.FieldServiceCount)
  15875. }
  15876. if m.addachievement_count != nil {
  15877. fields = append(fields, employee.FieldAchievementCount)
  15878. }
  15879. if m.addorganization_id != nil {
  15880. fields = append(fields, employee.FieldOrganizationID)
  15881. }
  15882. if m.addcategory_id != nil {
  15883. fields = append(fields, employee.FieldCategoryID)
  15884. }
  15885. if m.addis_vip != nil {
  15886. fields = append(fields, employee.FieldIsVip)
  15887. }
  15888. return fields
  15889. }
  15890. // AddedField returns the numeric value that was incremented/decremented on a field
  15891. // with the given name. The second boolean return value indicates that this field
  15892. // was not set, or was not defined in the schema.
  15893. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  15894. switch name {
  15895. case employee.FieldHireCount:
  15896. return m.AddedHireCount()
  15897. case employee.FieldServiceCount:
  15898. return m.AddedServiceCount()
  15899. case employee.FieldAchievementCount:
  15900. return m.AddedAchievementCount()
  15901. case employee.FieldOrganizationID:
  15902. return m.AddedOrganizationID()
  15903. case employee.FieldCategoryID:
  15904. return m.AddedCategoryID()
  15905. case employee.FieldIsVip:
  15906. return m.AddedIsVip()
  15907. }
  15908. return nil, false
  15909. }
  15910. // AddField adds the value to the field with the given name. It returns an error if
  15911. // the field is not defined in the schema, or if the type mismatched the field
  15912. // type.
  15913. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  15914. switch name {
  15915. case employee.FieldHireCount:
  15916. v, ok := value.(int)
  15917. if !ok {
  15918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15919. }
  15920. m.AddHireCount(v)
  15921. return nil
  15922. case employee.FieldServiceCount:
  15923. v, ok := value.(int)
  15924. if !ok {
  15925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15926. }
  15927. m.AddServiceCount(v)
  15928. return nil
  15929. case employee.FieldAchievementCount:
  15930. v, ok := value.(int)
  15931. if !ok {
  15932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15933. }
  15934. m.AddAchievementCount(v)
  15935. return nil
  15936. case employee.FieldOrganizationID:
  15937. v, ok := value.(int64)
  15938. if !ok {
  15939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15940. }
  15941. m.AddOrganizationID(v)
  15942. return nil
  15943. case employee.FieldCategoryID:
  15944. v, ok := value.(int64)
  15945. if !ok {
  15946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15947. }
  15948. m.AddCategoryID(v)
  15949. return nil
  15950. case employee.FieldIsVip:
  15951. v, ok := value.(int)
  15952. if !ok {
  15953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15954. }
  15955. m.AddIsVip(v)
  15956. return nil
  15957. }
  15958. return fmt.Errorf("unknown Employee numeric field %s", name)
  15959. }
  15960. // ClearedFields returns all nullable fields that were cleared during this
  15961. // mutation.
  15962. func (m *EmployeeMutation) ClearedFields() []string {
  15963. var fields []string
  15964. if m.FieldCleared(employee.FieldDeletedAt) {
  15965. fields = append(fields, employee.FieldDeletedAt)
  15966. }
  15967. if m.FieldCleared(employee.FieldAiInfo) {
  15968. fields = append(fields, employee.FieldAiInfo)
  15969. }
  15970. return fields
  15971. }
  15972. // FieldCleared returns a boolean indicating if a field with the given name was
  15973. // cleared in this mutation.
  15974. func (m *EmployeeMutation) FieldCleared(name string) bool {
  15975. _, ok := m.clearedFields[name]
  15976. return ok
  15977. }
  15978. // ClearField clears the value of the field with the given name. It returns an
  15979. // error if the field is not defined in the schema.
  15980. func (m *EmployeeMutation) ClearField(name string) error {
  15981. switch name {
  15982. case employee.FieldDeletedAt:
  15983. m.ClearDeletedAt()
  15984. return nil
  15985. case employee.FieldAiInfo:
  15986. m.ClearAiInfo()
  15987. return nil
  15988. }
  15989. return fmt.Errorf("unknown Employee nullable field %s", name)
  15990. }
  15991. // ResetField resets all changes in the mutation for the field with the given name.
  15992. // It returns an error if the field is not defined in the schema.
  15993. func (m *EmployeeMutation) ResetField(name string) error {
  15994. switch name {
  15995. case employee.FieldCreatedAt:
  15996. m.ResetCreatedAt()
  15997. return nil
  15998. case employee.FieldUpdatedAt:
  15999. m.ResetUpdatedAt()
  16000. return nil
  16001. case employee.FieldDeletedAt:
  16002. m.ResetDeletedAt()
  16003. return nil
  16004. case employee.FieldTitle:
  16005. m.ResetTitle()
  16006. return nil
  16007. case employee.FieldAvatar:
  16008. m.ResetAvatar()
  16009. return nil
  16010. case employee.FieldTags:
  16011. m.ResetTags()
  16012. return nil
  16013. case employee.FieldHireCount:
  16014. m.ResetHireCount()
  16015. return nil
  16016. case employee.FieldServiceCount:
  16017. m.ResetServiceCount()
  16018. return nil
  16019. case employee.FieldAchievementCount:
  16020. m.ResetAchievementCount()
  16021. return nil
  16022. case employee.FieldIntro:
  16023. m.ResetIntro()
  16024. return nil
  16025. case employee.FieldEstimate:
  16026. m.ResetEstimate()
  16027. return nil
  16028. case employee.FieldSkill:
  16029. m.ResetSkill()
  16030. return nil
  16031. case employee.FieldAbilityType:
  16032. m.ResetAbilityType()
  16033. return nil
  16034. case employee.FieldScene:
  16035. m.ResetScene()
  16036. return nil
  16037. case employee.FieldSwitchIn:
  16038. m.ResetSwitchIn()
  16039. return nil
  16040. case employee.FieldVideoURL:
  16041. m.ResetVideoURL()
  16042. return nil
  16043. case employee.FieldOrganizationID:
  16044. m.ResetOrganizationID()
  16045. return nil
  16046. case employee.FieldCategoryID:
  16047. m.ResetCategoryID()
  16048. return nil
  16049. case employee.FieldAPIBase:
  16050. m.ResetAPIBase()
  16051. return nil
  16052. case employee.FieldAPIKey:
  16053. m.ResetAPIKey()
  16054. return nil
  16055. case employee.FieldAiInfo:
  16056. m.ResetAiInfo()
  16057. return nil
  16058. case employee.FieldIsVip:
  16059. m.ResetIsVip()
  16060. return nil
  16061. case employee.FieldChatURL:
  16062. m.ResetChatURL()
  16063. return nil
  16064. }
  16065. return fmt.Errorf("unknown Employee field %s", name)
  16066. }
  16067. // AddedEdges returns all edge names that were set/added in this mutation.
  16068. func (m *EmployeeMutation) AddedEdges() []string {
  16069. edges := make([]string, 0, 2)
  16070. if m.em_work_experiences != nil {
  16071. edges = append(edges, employee.EdgeEmWorkExperiences)
  16072. }
  16073. if m.em_tutorial != nil {
  16074. edges = append(edges, employee.EdgeEmTutorial)
  16075. }
  16076. return edges
  16077. }
  16078. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16079. // name in this mutation.
  16080. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  16081. switch name {
  16082. case employee.EdgeEmWorkExperiences:
  16083. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  16084. for id := range m.em_work_experiences {
  16085. ids = append(ids, id)
  16086. }
  16087. return ids
  16088. case employee.EdgeEmTutorial:
  16089. ids := make([]ent.Value, 0, len(m.em_tutorial))
  16090. for id := range m.em_tutorial {
  16091. ids = append(ids, id)
  16092. }
  16093. return ids
  16094. }
  16095. return nil
  16096. }
  16097. // RemovedEdges returns all edge names that were removed in this mutation.
  16098. func (m *EmployeeMutation) RemovedEdges() []string {
  16099. edges := make([]string, 0, 2)
  16100. if m.removedem_work_experiences != nil {
  16101. edges = append(edges, employee.EdgeEmWorkExperiences)
  16102. }
  16103. if m.removedem_tutorial != nil {
  16104. edges = append(edges, employee.EdgeEmTutorial)
  16105. }
  16106. return edges
  16107. }
  16108. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16109. // the given name in this mutation.
  16110. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  16111. switch name {
  16112. case employee.EdgeEmWorkExperiences:
  16113. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  16114. for id := range m.removedem_work_experiences {
  16115. ids = append(ids, id)
  16116. }
  16117. return ids
  16118. case employee.EdgeEmTutorial:
  16119. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  16120. for id := range m.removedem_tutorial {
  16121. ids = append(ids, id)
  16122. }
  16123. return ids
  16124. }
  16125. return nil
  16126. }
  16127. // ClearedEdges returns all edge names that were cleared in this mutation.
  16128. func (m *EmployeeMutation) ClearedEdges() []string {
  16129. edges := make([]string, 0, 2)
  16130. if m.clearedem_work_experiences {
  16131. edges = append(edges, employee.EdgeEmWorkExperiences)
  16132. }
  16133. if m.clearedem_tutorial {
  16134. edges = append(edges, employee.EdgeEmTutorial)
  16135. }
  16136. return edges
  16137. }
  16138. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16139. // was cleared in this mutation.
  16140. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  16141. switch name {
  16142. case employee.EdgeEmWorkExperiences:
  16143. return m.clearedem_work_experiences
  16144. case employee.EdgeEmTutorial:
  16145. return m.clearedem_tutorial
  16146. }
  16147. return false
  16148. }
  16149. // ClearEdge clears the value of the edge with the given name. It returns an error
  16150. // if that edge is not defined in the schema.
  16151. func (m *EmployeeMutation) ClearEdge(name string) error {
  16152. switch name {
  16153. }
  16154. return fmt.Errorf("unknown Employee unique edge %s", name)
  16155. }
  16156. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16157. // It returns an error if the edge is not defined in the schema.
  16158. func (m *EmployeeMutation) ResetEdge(name string) error {
  16159. switch name {
  16160. case employee.EdgeEmWorkExperiences:
  16161. m.ResetEmWorkExperiences()
  16162. return nil
  16163. case employee.EdgeEmTutorial:
  16164. m.ResetEmTutorial()
  16165. return nil
  16166. }
  16167. return fmt.Errorf("unknown Employee edge %s", name)
  16168. }
  16169. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  16170. type EmployeeConfigMutation struct {
  16171. config
  16172. op Op
  16173. typ string
  16174. id *uint64
  16175. created_at *time.Time
  16176. updated_at *time.Time
  16177. deleted_at *time.Time
  16178. stype *string
  16179. title *string
  16180. photo *string
  16181. organization_id *uint64
  16182. addorganization_id *int64
  16183. clearedFields map[string]struct{}
  16184. done bool
  16185. oldValue func(context.Context) (*EmployeeConfig, error)
  16186. predicates []predicate.EmployeeConfig
  16187. }
  16188. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  16189. // employeeconfigOption allows management of the mutation configuration using functional options.
  16190. type employeeconfigOption func(*EmployeeConfigMutation)
  16191. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  16192. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  16193. m := &EmployeeConfigMutation{
  16194. config: c,
  16195. op: op,
  16196. typ: TypeEmployeeConfig,
  16197. clearedFields: make(map[string]struct{}),
  16198. }
  16199. for _, opt := range opts {
  16200. opt(m)
  16201. }
  16202. return m
  16203. }
  16204. // withEmployeeConfigID sets the ID field of the mutation.
  16205. func withEmployeeConfigID(id uint64) employeeconfigOption {
  16206. return func(m *EmployeeConfigMutation) {
  16207. var (
  16208. err error
  16209. once sync.Once
  16210. value *EmployeeConfig
  16211. )
  16212. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  16213. once.Do(func() {
  16214. if m.done {
  16215. err = errors.New("querying old values post mutation is not allowed")
  16216. } else {
  16217. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  16218. }
  16219. })
  16220. return value, err
  16221. }
  16222. m.id = &id
  16223. }
  16224. }
  16225. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  16226. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  16227. return func(m *EmployeeConfigMutation) {
  16228. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  16229. return node, nil
  16230. }
  16231. m.id = &node.ID
  16232. }
  16233. }
  16234. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16235. // executed in a transaction (ent.Tx), a transactional client is returned.
  16236. func (m EmployeeConfigMutation) Client() *Client {
  16237. client := &Client{config: m.config}
  16238. client.init()
  16239. return client
  16240. }
  16241. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16242. // it returns an error otherwise.
  16243. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  16244. if _, ok := m.driver.(*txDriver); !ok {
  16245. return nil, errors.New("ent: mutation is not running in a transaction")
  16246. }
  16247. tx := &Tx{config: m.config}
  16248. tx.init()
  16249. return tx, nil
  16250. }
  16251. // SetID sets the value of the id field. Note that this
  16252. // operation is only accepted on creation of EmployeeConfig entities.
  16253. func (m *EmployeeConfigMutation) SetID(id uint64) {
  16254. m.id = &id
  16255. }
  16256. // ID returns the ID value in the mutation. Note that the ID is only available
  16257. // if it was provided to the builder or after it was returned from the database.
  16258. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  16259. if m.id == nil {
  16260. return
  16261. }
  16262. return *m.id, true
  16263. }
  16264. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16265. // That means, if the mutation is applied within a transaction with an isolation level such
  16266. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16267. // or updated by the mutation.
  16268. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  16269. switch {
  16270. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16271. id, exists := m.ID()
  16272. if exists {
  16273. return []uint64{id}, nil
  16274. }
  16275. fallthrough
  16276. case m.op.Is(OpUpdate | OpDelete):
  16277. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  16278. default:
  16279. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16280. }
  16281. }
  16282. // SetCreatedAt sets the "created_at" field.
  16283. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  16284. m.created_at = &t
  16285. }
  16286. // CreatedAt returns the value of the "created_at" field in the mutation.
  16287. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  16288. v := m.created_at
  16289. if v == nil {
  16290. return
  16291. }
  16292. return *v, true
  16293. }
  16294. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  16295. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16297. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16298. if !m.op.Is(OpUpdateOne) {
  16299. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16300. }
  16301. if m.id == nil || m.oldValue == nil {
  16302. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16303. }
  16304. oldValue, err := m.oldValue(ctx)
  16305. if err != nil {
  16306. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16307. }
  16308. return oldValue.CreatedAt, nil
  16309. }
  16310. // ResetCreatedAt resets all changes to the "created_at" field.
  16311. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  16312. m.created_at = nil
  16313. }
  16314. // SetUpdatedAt sets the "updated_at" field.
  16315. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  16316. m.updated_at = &t
  16317. }
  16318. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16319. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  16320. v := m.updated_at
  16321. if v == nil {
  16322. return
  16323. }
  16324. return *v, true
  16325. }
  16326. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  16327. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16329. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16330. if !m.op.Is(OpUpdateOne) {
  16331. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16332. }
  16333. if m.id == nil || m.oldValue == nil {
  16334. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16335. }
  16336. oldValue, err := m.oldValue(ctx)
  16337. if err != nil {
  16338. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16339. }
  16340. return oldValue.UpdatedAt, nil
  16341. }
  16342. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16343. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  16344. m.updated_at = nil
  16345. }
  16346. // SetDeletedAt sets the "deleted_at" field.
  16347. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  16348. m.deleted_at = &t
  16349. }
  16350. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16351. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  16352. v := m.deleted_at
  16353. if v == nil {
  16354. return
  16355. }
  16356. return *v, true
  16357. }
  16358. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  16359. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16361. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16362. if !m.op.Is(OpUpdateOne) {
  16363. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16364. }
  16365. if m.id == nil || m.oldValue == nil {
  16366. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16367. }
  16368. oldValue, err := m.oldValue(ctx)
  16369. if err != nil {
  16370. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16371. }
  16372. return oldValue.DeletedAt, nil
  16373. }
  16374. // ClearDeletedAt clears the value of the "deleted_at" field.
  16375. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  16376. m.deleted_at = nil
  16377. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  16378. }
  16379. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16380. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  16381. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  16382. return ok
  16383. }
  16384. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16385. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  16386. m.deleted_at = nil
  16387. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  16388. }
  16389. // SetStype sets the "stype" field.
  16390. func (m *EmployeeConfigMutation) SetStype(s string) {
  16391. m.stype = &s
  16392. }
  16393. // Stype returns the value of the "stype" field in the mutation.
  16394. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  16395. v := m.stype
  16396. if v == nil {
  16397. return
  16398. }
  16399. return *v, true
  16400. }
  16401. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  16402. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16404. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  16405. if !m.op.Is(OpUpdateOne) {
  16406. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  16407. }
  16408. if m.id == nil || m.oldValue == nil {
  16409. return v, errors.New("OldStype requires an ID field in the mutation")
  16410. }
  16411. oldValue, err := m.oldValue(ctx)
  16412. if err != nil {
  16413. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  16414. }
  16415. return oldValue.Stype, nil
  16416. }
  16417. // ResetStype resets all changes to the "stype" field.
  16418. func (m *EmployeeConfigMutation) ResetStype() {
  16419. m.stype = nil
  16420. }
  16421. // SetTitle sets the "title" field.
  16422. func (m *EmployeeConfigMutation) SetTitle(s string) {
  16423. m.title = &s
  16424. }
  16425. // Title returns the value of the "title" field in the mutation.
  16426. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  16427. v := m.title
  16428. if v == nil {
  16429. return
  16430. }
  16431. return *v, true
  16432. }
  16433. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  16434. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16436. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  16437. if !m.op.Is(OpUpdateOne) {
  16438. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  16439. }
  16440. if m.id == nil || m.oldValue == nil {
  16441. return v, errors.New("OldTitle requires an ID field in the mutation")
  16442. }
  16443. oldValue, err := m.oldValue(ctx)
  16444. if err != nil {
  16445. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  16446. }
  16447. return oldValue.Title, nil
  16448. }
  16449. // ResetTitle resets all changes to the "title" field.
  16450. func (m *EmployeeConfigMutation) ResetTitle() {
  16451. m.title = nil
  16452. }
  16453. // SetPhoto sets the "photo" field.
  16454. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  16455. m.photo = &s
  16456. }
  16457. // Photo returns the value of the "photo" field in the mutation.
  16458. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  16459. v := m.photo
  16460. if v == nil {
  16461. return
  16462. }
  16463. return *v, true
  16464. }
  16465. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  16466. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16468. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  16469. if !m.op.Is(OpUpdateOne) {
  16470. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  16471. }
  16472. if m.id == nil || m.oldValue == nil {
  16473. return v, errors.New("OldPhoto requires an ID field in the mutation")
  16474. }
  16475. oldValue, err := m.oldValue(ctx)
  16476. if err != nil {
  16477. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  16478. }
  16479. return oldValue.Photo, nil
  16480. }
  16481. // ResetPhoto resets all changes to the "photo" field.
  16482. func (m *EmployeeConfigMutation) ResetPhoto() {
  16483. m.photo = nil
  16484. }
  16485. // SetOrganizationID sets the "organization_id" field.
  16486. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  16487. m.organization_id = &u
  16488. m.addorganization_id = nil
  16489. }
  16490. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16491. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  16492. v := m.organization_id
  16493. if v == nil {
  16494. return
  16495. }
  16496. return *v, true
  16497. }
  16498. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  16499. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  16500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16501. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16502. if !m.op.Is(OpUpdateOne) {
  16503. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16504. }
  16505. if m.id == nil || m.oldValue == nil {
  16506. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16507. }
  16508. oldValue, err := m.oldValue(ctx)
  16509. if err != nil {
  16510. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16511. }
  16512. return oldValue.OrganizationID, nil
  16513. }
  16514. // AddOrganizationID adds u to the "organization_id" field.
  16515. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  16516. if m.addorganization_id != nil {
  16517. *m.addorganization_id += u
  16518. } else {
  16519. m.addorganization_id = &u
  16520. }
  16521. }
  16522. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16523. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  16524. v := m.addorganization_id
  16525. if v == nil {
  16526. return
  16527. }
  16528. return *v, true
  16529. }
  16530. // ClearOrganizationID clears the value of the "organization_id" field.
  16531. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  16532. m.organization_id = nil
  16533. m.addorganization_id = nil
  16534. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  16535. }
  16536. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16537. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  16538. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  16539. return ok
  16540. }
  16541. // ResetOrganizationID resets all changes to the "organization_id" field.
  16542. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  16543. m.organization_id = nil
  16544. m.addorganization_id = nil
  16545. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  16546. }
  16547. // Where appends a list predicates to the EmployeeConfigMutation builder.
  16548. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  16549. m.predicates = append(m.predicates, ps...)
  16550. }
  16551. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  16552. // users can use type-assertion to append predicates that do not depend on any generated package.
  16553. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  16554. p := make([]predicate.EmployeeConfig, len(ps))
  16555. for i := range ps {
  16556. p[i] = ps[i]
  16557. }
  16558. m.Where(p...)
  16559. }
  16560. // Op returns the operation name.
  16561. func (m *EmployeeConfigMutation) Op() Op {
  16562. return m.op
  16563. }
  16564. // SetOp allows setting the mutation operation.
  16565. func (m *EmployeeConfigMutation) SetOp(op Op) {
  16566. m.op = op
  16567. }
  16568. // Type returns the node type of this mutation (EmployeeConfig).
  16569. func (m *EmployeeConfigMutation) Type() string {
  16570. return m.typ
  16571. }
  16572. // Fields returns all fields that were changed during this mutation. Note that in
  16573. // order to get all numeric fields that were incremented/decremented, call
  16574. // AddedFields().
  16575. func (m *EmployeeConfigMutation) Fields() []string {
  16576. fields := make([]string, 0, 7)
  16577. if m.created_at != nil {
  16578. fields = append(fields, employeeconfig.FieldCreatedAt)
  16579. }
  16580. if m.updated_at != nil {
  16581. fields = append(fields, employeeconfig.FieldUpdatedAt)
  16582. }
  16583. if m.deleted_at != nil {
  16584. fields = append(fields, employeeconfig.FieldDeletedAt)
  16585. }
  16586. if m.stype != nil {
  16587. fields = append(fields, employeeconfig.FieldStype)
  16588. }
  16589. if m.title != nil {
  16590. fields = append(fields, employeeconfig.FieldTitle)
  16591. }
  16592. if m.photo != nil {
  16593. fields = append(fields, employeeconfig.FieldPhoto)
  16594. }
  16595. if m.organization_id != nil {
  16596. fields = append(fields, employeeconfig.FieldOrganizationID)
  16597. }
  16598. return fields
  16599. }
  16600. // Field returns the value of a field with the given name. The second boolean
  16601. // return value indicates that this field was not set, or was not defined in the
  16602. // schema.
  16603. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  16604. switch name {
  16605. case employeeconfig.FieldCreatedAt:
  16606. return m.CreatedAt()
  16607. case employeeconfig.FieldUpdatedAt:
  16608. return m.UpdatedAt()
  16609. case employeeconfig.FieldDeletedAt:
  16610. return m.DeletedAt()
  16611. case employeeconfig.FieldStype:
  16612. return m.Stype()
  16613. case employeeconfig.FieldTitle:
  16614. return m.Title()
  16615. case employeeconfig.FieldPhoto:
  16616. return m.Photo()
  16617. case employeeconfig.FieldOrganizationID:
  16618. return m.OrganizationID()
  16619. }
  16620. return nil, false
  16621. }
  16622. // OldField returns the old value of the field from the database. An error is
  16623. // returned if the mutation operation is not UpdateOne, or the query to the
  16624. // database failed.
  16625. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16626. switch name {
  16627. case employeeconfig.FieldCreatedAt:
  16628. return m.OldCreatedAt(ctx)
  16629. case employeeconfig.FieldUpdatedAt:
  16630. return m.OldUpdatedAt(ctx)
  16631. case employeeconfig.FieldDeletedAt:
  16632. return m.OldDeletedAt(ctx)
  16633. case employeeconfig.FieldStype:
  16634. return m.OldStype(ctx)
  16635. case employeeconfig.FieldTitle:
  16636. return m.OldTitle(ctx)
  16637. case employeeconfig.FieldPhoto:
  16638. return m.OldPhoto(ctx)
  16639. case employeeconfig.FieldOrganizationID:
  16640. return m.OldOrganizationID(ctx)
  16641. }
  16642. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  16643. }
  16644. // SetField sets the value of a field with the given name. It returns an error if
  16645. // the field is not defined in the schema, or if the type mismatched the field
  16646. // type.
  16647. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  16648. switch name {
  16649. case employeeconfig.FieldCreatedAt:
  16650. v, ok := value.(time.Time)
  16651. if !ok {
  16652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16653. }
  16654. m.SetCreatedAt(v)
  16655. return nil
  16656. case employeeconfig.FieldUpdatedAt:
  16657. v, ok := value.(time.Time)
  16658. if !ok {
  16659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16660. }
  16661. m.SetUpdatedAt(v)
  16662. return nil
  16663. case employeeconfig.FieldDeletedAt:
  16664. v, ok := value.(time.Time)
  16665. if !ok {
  16666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16667. }
  16668. m.SetDeletedAt(v)
  16669. return nil
  16670. case employeeconfig.FieldStype:
  16671. v, ok := value.(string)
  16672. if !ok {
  16673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16674. }
  16675. m.SetStype(v)
  16676. return nil
  16677. case employeeconfig.FieldTitle:
  16678. v, ok := value.(string)
  16679. if !ok {
  16680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16681. }
  16682. m.SetTitle(v)
  16683. return nil
  16684. case employeeconfig.FieldPhoto:
  16685. v, ok := value.(string)
  16686. if !ok {
  16687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16688. }
  16689. m.SetPhoto(v)
  16690. return nil
  16691. case employeeconfig.FieldOrganizationID:
  16692. v, ok := value.(uint64)
  16693. if !ok {
  16694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16695. }
  16696. m.SetOrganizationID(v)
  16697. return nil
  16698. }
  16699. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  16700. }
  16701. // AddedFields returns all numeric fields that were incremented/decremented during
  16702. // this mutation.
  16703. func (m *EmployeeConfigMutation) AddedFields() []string {
  16704. var fields []string
  16705. if m.addorganization_id != nil {
  16706. fields = append(fields, employeeconfig.FieldOrganizationID)
  16707. }
  16708. return fields
  16709. }
  16710. // AddedField returns the numeric value that was incremented/decremented on a field
  16711. // with the given name. The second boolean return value indicates that this field
  16712. // was not set, or was not defined in the schema.
  16713. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  16714. switch name {
  16715. case employeeconfig.FieldOrganizationID:
  16716. return m.AddedOrganizationID()
  16717. }
  16718. return nil, false
  16719. }
  16720. // AddField adds the value to the field with the given name. It returns an error if
  16721. // the field is not defined in the schema, or if the type mismatched the field
  16722. // type.
  16723. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  16724. switch name {
  16725. case employeeconfig.FieldOrganizationID:
  16726. v, ok := value.(int64)
  16727. if !ok {
  16728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16729. }
  16730. m.AddOrganizationID(v)
  16731. return nil
  16732. }
  16733. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  16734. }
  16735. // ClearedFields returns all nullable fields that were cleared during this
  16736. // mutation.
  16737. func (m *EmployeeConfigMutation) ClearedFields() []string {
  16738. var fields []string
  16739. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  16740. fields = append(fields, employeeconfig.FieldDeletedAt)
  16741. }
  16742. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  16743. fields = append(fields, employeeconfig.FieldOrganizationID)
  16744. }
  16745. return fields
  16746. }
  16747. // FieldCleared returns a boolean indicating if a field with the given name was
  16748. // cleared in this mutation.
  16749. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  16750. _, ok := m.clearedFields[name]
  16751. return ok
  16752. }
  16753. // ClearField clears the value of the field with the given name. It returns an
  16754. // error if the field is not defined in the schema.
  16755. func (m *EmployeeConfigMutation) ClearField(name string) error {
  16756. switch name {
  16757. case employeeconfig.FieldDeletedAt:
  16758. m.ClearDeletedAt()
  16759. return nil
  16760. case employeeconfig.FieldOrganizationID:
  16761. m.ClearOrganizationID()
  16762. return nil
  16763. }
  16764. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  16765. }
  16766. // ResetField resets all changes in the mutation for the field with the given name.
  16767. // It returns an error if the field is not defined in the schema.
  16768. func (m *EmployeeConfigMutation) ResetField(name string) error {
  16769. switch name {
  16770. case employeeconfig.FieldCreatedAt:
  16771. m.ResetCreatedAt()
  16772. return nil
  16773. case employeeconfig.FieldUpdatedAt:
  16774. m.ResetUpdatedAt()
  16775. return nil
  16776. case employeeconfig.FieldDeletedAt:
  16777. m.ResetDeletedAt()
  16778. return nil
  16779. case employeeconfig.FieldStype:
  16780. m.ResetStype()
  16781. return nil
  16782. case employeeconfig.FieldTitle:
  16783. m.ResetTitle()
  16784. return nil
  16785. case employeeconfig.FieldPhoto:
  16786. m.ResetPhoto()
  16787. return nil
  16788. case employeeconfig.FieldOrganizationID:
  16789. m.ResetOrganizationID()
  16790. return nil
  16791. }
  16792. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  16793. }
  16794. // AddedEdges returns all edge names that were set/added in this mutation.
  16795. func (m *EmployeeConfigMutation) AddedEdges() []string {
  16796. edges := make([]string, 0, 0)
  16797. return edges
  16798. }
  16799. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16800. // name in this mutation.
  16801. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  16802. return nil
  16803. }
  16804. // RemovedEdges returns all edge names that were removed in this mutation.
  16805. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  16806. edges := make([]string, 0, 0)
  16807. return edges
  16808. }
  16809. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16810. // the given name in this mutation.
  16811. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  16812. return nil
  16813. }
  16814. // ClearedEdges returns all edge names that were cleared in this mutation.
  16815. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  16816. edges := make([]string, 0, 0)
  16817. return edges
  16818. }
  16819. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16820. // was cleared in this mutation.
  16821. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  16822. return false
  16823. }
  16824. // ClearEdge clears the value of the edge with the given name. It returns an error
  16825. // if that edge is not defined in the schema.
  16826. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  16827. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  16828. }
  16829. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16830. // It returns an error if the edge is not defined in the schema.
  16831. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  16832. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  16833. }
  16834. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  16835. type LabelMutation struct {
  16836. config
  16837. op Op
  16838. typ string
  16839. id *uint64
  16840. created_at *time.Time
  16841. updated_at *time.Time
  16842. status *uint8
  16843. addstatus *int8
  16844. _type *int
  16845. add_type *int
  16846. name *string
  16847. from *int
  16848. addfrom *int
  16849. mode *int
  16850. addmode *int
  16851. conditions *string
  16852. organization_id *uint64
  16853. addorganization_id *int64
  16854. clearedFields map[string]struct{}
  16855. label_relationships map[uint64]struct{}
  16856. removedlabel_relationships map[uint64]struct{}
  16857. clearedlabel_relationships bool
  16858. done bool
  16859. oldValue func(context.Context) (*Label, error)
  16860. predicates []predicate.Label
  16861. }
  16862. var _ ent.Mutation = (*LabelMutation)(nil)
  16863. // labelOption allows management of the mutation configuration using functional options.
  16864. type labelOption func(*LabelMutation)
  16865. // newLabelMutation creates new mutation for the Label entity.
  16866. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  16867. m := &LabelMutation{
  16868. config: c,
  16869. op: op,
  16870. typ: TypeLabel,
  16871. clearedFields: make(map[string]struct{}),
  16872. }
  16873. for _, opt := range opts {
  16874. opt(m)
  16875. }
  16876. return m
  16877. }
  16878. // withLabelID sets the ID field of the mutation.
  16879. func withLabelID(id uint64) labelOption {
  16880. return func(m *LabelMutation) {
  16881. var (
  16882. err error
  16883. once sync.Once
  16884. value *Label
  16885. )
  16886. m.oldValue = func(ctx context.Context) (*Label, error) {
  16887. once.Do(func() {
  16888. if m.done {
  16889. err = errors.New("querying old values post mutation is not allowed")
  16890. } else {
  16891. value, err = m.Client().Label.Get(ctx, id)
  16892. }
  16893. })
  16894. return value, err
  16895. }
  16896. m.id = &id
  16897. }
  16898. }
  16899. // withLabel sets the old Label of the mutation.
  16900. func withLabel(node *Label) labelOption {
  16901. return func(m *LabelMutation) {
  16902. m.oldValue = func(context.Context) (*Label, error) {
  16903. return node, nil
  16904. }
  16905. m.id = &node.ID
  16906. }
  16907. }
  16908. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16909. // executed in a transaction (ent.Tx), a transactional client is returned.
  16910. func (m LabelMutation) Client() *Client {
  16911. client := &Client{config: m.config}
  16912. client.init()
  16913. return client
  16914. }
  16915. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16916. // it returns an error otherwise.
  16917. func (m LabelMutation) Tx() (*Tx, error) {
  16918. if _, ok := m.driver.(*txDriver); !ok {
  16919. return nil, errors.New("ent: mutation is not running in a transaction")
  16920. }
  16921. tx := &Tx{config: m.config}
  16922. tx.init()
  16923. return tx, nil
  16924. }
  16925. // SetID sets the value of the id field. Note that this
  16926. // operation is only accepted on creation of Label entities.
  16927. func (m *LabelMutation) SetID(id uint64) {
  16928. m.id = &id
  16929. }
  16930. // ID returns the ID value in the mutation. Note that the ID is only available
  16931. // if it was provided to the builder or after it was returned from the database.
  16932. func (m *LabelMutation) ID() (id uint64, exists bool) {
  16933. if m.id == nil {
  16934. return
  16935. }
  16936. return *m.id, true
  16937. }
  16938. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16939. // That means, if the mutation is applied within a transaction with an isolation level such
  16940. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16941. // or updated by the mutation.
  16942. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  16943. switch {
  16944. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16945. id, exists := m.ID()
  16946. if exists {
  16947. return []uint64{id}, nil
  16948. }
  16949. fallthrough
  16950. case m.op.Is(OpUpdate | OpDelete):
  16951. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  16952. default:
  16953. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16954. }
  16955. }
  16956. // SetCreatedAt sets the "created_at" field.
  16957. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  16958. m.created_at = &t
  16959. }
  16960. // CreatedAt returns the value of the "created_at" field in the mutation.
  16961. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  16962. v := m.created_at
  16963. if v == nil {
  16964. return
  16965. }
  16966. return *v, true
  16967. }
  16968. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  16969. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  16970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16971. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16972. if !m.op.Is(OpUpdateOne) {
  16973. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16974. }
  16975. if m.id == nil || m.oldValue == nil {
  16976. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16977. }
  16978. oldValue, err := m.oldValue(ctx)
  16979. if err != nil {
  16980. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16981. }
  16982. return oldValue.CreatedAt, nil
  16983. }
  16984. // ResetCreatedAt resets all changes to the "created_at" field.
  16985. func (m *LabelMutation) ResetCreatedAt() {
  16986. m.created_at = nil
  16987. }
  16988. // SetUpdatedAt sets the "updated_at" field.
  16989. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  16990. m.updated_at = &t
  16991. }
  16992. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16993. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  16994. v := m.updated_at
  16995. if v == nil {
  16996. return
  16997. }
  16998. return *v, true
  16999. }
  17000. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  17001. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17002. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17003. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17004. if !m.op.Is(OpUpdateOne) {
  17005. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17006. }
  17007. if m.id == nil || m.oldValue == nil {
  17008. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17009. }
  17010. oldValue, err := m.oldValue(ctx)
  17011. if err != nil {
  17012. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17013. }
  17014. return oldValue.UpdatedAt, nil
  17015. }
  17016. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17017. func (m *LabelMutation) ResetUpdatedAt() {
  17018. m.updated_at = nil
  17019. }
  17020. // SetStatus sets the "status" field.
  17021. func (m *LabelMutation) SetStatus(u uint8) {
  17022. m.status = &u
  17023. m.addstatus = nil
  17024. }
  17025. // Status returns the value of the "status" field in the mutation.
  17026. func (m *LabelMutation) Status() (r uint8, exists bool) {
  17027. v := m.status
  17028. if v == nil {
  17029. return
  17030. }
  17031. return *v, true
  17032. }
  17033. // OldStatus returns the old "status" field's value of the Label entity.
  17034. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17036. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17037. if !m.op.Is(OpUpdateOne) {
  17038. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17039. }
  17040. if m.id == nil || m.oldValue == nil {
  17041. return v, errors.New("OldStatus requires an ID field in the mutation")
  17042. }
  17043. oldValue, err := m.oldValue(ctx)
  17044. if err != nil {
  17045. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17046. }
  17047. return oldValue.Status, nil
  17048. }
  17049. // AddStatus adds u to the "status" field.
  17050. func (m *LabelMutation) AddStatus(u int8) {
  17051. if m.addstatus != nil {
  17052. *m.addstatus += u
  17053. } else {
  17054. m.addstatus = &u
  17055. }
  17056. }
  17057. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17058. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  17059. v := m.addstatus
  17060. if v == nil {
  17061. return
  17062. }
  17063. return *v, true
  17064. }
  17065. // ClearStatus clears the value of the "status" field.
  17066. func (m *LabelMutation) ClearStatus() {
  17067. m.status = nil
  17068. m.addstatus = nil
  17069. m.clearedFields[label.FieldStatus] = struct{}{}
  17070. }
  17071. // StatusCleared returns if the "status" field was cleared in this mutation.
  17072. func (m *LabelMutation) StatusCleared() bool {
  17073. _, ok := m.clearedFields[label.FieldStatus]
  17074. return ok
  17075. }
  17076. // ResetStatus resets all changes to the "status" field.
  17077. func (m *LabelMutation) ResetStatus() {
  17078. m.status = nil
  17079. m.addstatus = nil
  17080. delete(m.clearedFields, label.FieldStatus)
  17081. }
  17082. // SetType sets the "type" field.
  17083. func (m *LabelMutation) SetType(i int) {
  17084. m._type = &i
  17085. m.add_type = nil
  17086. }
  17087. // GetType returns the value of the "type" field in the mutation.
  17088. func (m *LabelMutation) GetType() (r int, exists bool) {
  17089. v := m._type
  17090. if v == nil {
  17091. return
  17092. }
  17093. return *v, true
  17094. }
  17095. // OldType returns the old "type" field's value of the Label entity.
  17096. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17098. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  17099. if !m.op.Is(OpUpdateOne) {
  17100. return v, errors.New("OldType is only allowed on UpdateOne operations")
  17101. }
  17102. if m.id == nil || m.oldValue == nil {
  17103. return v, errors.New("OldType requires an ID field in the mutation")
  17104. }
  17105. oldValue, err := m.oldValue(ctx)
  17106. if err != nil {
  17107. return v, fmt.Errorf("querying old value for OldType: %w", err)
  17108. }
  17109. return oldValue.Type, nil
  17110. }
  17111. // AddType adds i to the "type" field.
  17112. func (m *LabelMutation) AddType(i int) {
  17113. if m.add_type != nil {
  17114. *m.add_type += i
  17115. } else {
  17116. m.add_type = &i
  17117. }
  17118. }
  17119. // AddedType returns the value that was added to the "type" field in this mutation.
  17120. func (m *LabelMutation) AddedType() (r int, exists bool) {
  17121. v := m.add_type
  17122. if v == nil {
  17123. return
  17124. }
  17125. return *v, true
  17126. }
  17127. // ResetType resets all changes to the "type" field.
  17128. func (m *LabelMutation) ResetType() {
  17129. m._type = nil
  17130. m.add_type = nil
  17131. }
  17132. // SetName sets the "name" field.
  17133. func (m *LabelMutation) SetName(s string) {
  17134. m.name = &s
  17135. }
  17136. // Name returns the value of the "name" field in the mutation.
  17137. func (m *LabelMutation) Name() (r string, exists bool) {
  17138. v := m.name
  17139. if v == nil {
  17140. return
  17141. }
  17142. return *v, true
  17143. }
  17144. // OldName returns the old "name" field's value of the Label entity.
  17145. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17147. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  17148. if !m.op.Is(OpUpdateOne) {
  17149. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17150. }
  17151. if m.id == nil || m.oldValue == nil {
  17152. return v, errors.New("OldName requires an ID field in the mutation")
  17153. }
  17154. oldValue, err := m.oldValue(ctx)
  17155. if err != nil {
  17156. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17157. }
  17158. return oldValue.Name, nil
  17159. }
  17160. // ResetName resets all changes to the "name" field.
  17161. func (m *LabelMutation) ResetName() {
  17162. m.name = nil
  17163. }
  17164. // SetFrom sets the "from" field.
  17165. func (m *LabelMutation) SetFrom(i int) {
  17166. m.from = &i
  17167. m.addfrom = nil
  17168. }
  17169. // From returns the value of the "from" field in the mutation.
  17170. func (m *LabelMutation) From() (r int, exists bool) {
  17171. v := m.from
  17172. if v == nil {
  17173. return
  17174. }
  17175. return *v, true
  17176. }
  17177. // OldFrom returns the old "from" field's value of the Label entity.
  17178. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17180. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  17181. if !m.op.Is(OpUpdateOne) {
  17182. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  17183. }
  17184. if m.id == nil || m.oldValue == nil {
  17185. return v, errors.New("OldFrom requires an ID field in the mutation")
  17186. }
  17187. oldValue, err := m.oldValue(ctx)
  17188. if err != nil {
  17189. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  17190. }
  17191. return oldValue.From, nil
  17192. }
  17193. // AddFrom adds i to the "from" field.
  17194. func (m *LabelMutation) AddFrom(i int) {
  17195. if m.addfrom != nil {
  17196. *m.addfrom += i
  17197. } else {
  17198. m.addfrom = &i
  17199. }
  17200. }
  17201. // AddedFrom returns the value that was added to the "from" field in this mutation.
  17202. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  17203. v := m.addfrom
  17204. if v == nil {
  17205. return
  17206. }
  17207. return *v, true
  17208. }
  17209. // ResetFrom resets all changes to the "from" field.
  17210. func (m *LabelMutation) ResetFrom() {
  17211. m.from = nil
  17212. m.addfrom = nil
  17213. }
  17214. // SetMode sets the "mode" field.
  17215. func (m *LabelMutation) SetMode(i int) {
  17216. m.mode = &i
  17217. m.addmode = nil
  17218. }
  17219. // Mode returns the value of the "mode" field in the mutation.
  17220. func (m *LabelMutation) Mode() (r int, exists bool) {
  17221. v := m.mode
  17222. if v == nil {
  17223. return
  17224. }
  17225. return *v, true
  17226. }
  17227. // OldMode returns the old "mode" field's value of the Label entity.
  17228. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17230. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  17231. if !m.op.Is(OpUpdateOne) {
  17232. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  17233. }
  17234. if m.id == nil || m.oldValue == nil {
  17235. return v, errors.New("OldMode requires an ID field in the mutation")
  17236. }
  17237. oldValue, err := m.oldValue(ctx)
  17238. if err != nil {
  17239. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  17240. }
  17241. return oldValue.Mode, nil
  17242. }
  17243. // AddMode adds i to the "mode" field.
  17244. func (m *LabelMutation) AddMode(i int) {
  17245. if m.addmode != nil {
  17246. *m.addmode += i
  17247. } else {
  17248. m.addmode = &i
  17249. }
  17250. }
  17251. // AddedMode returns the value that was added to the "mode" field in this mutation.
  17252. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  17253. v := m.addmode
  17254. if v == nil {
  17255. return
  17256. }
  17257. return *v, true
  17258. }
  17259. // ResetMode resets all changes to the "mode" field.
  17260. func (m *LabelMutation) ResetMode() {
  17261. m.mode = nil
  17262. m.addmode = nil
  17263. }
  17264. // SetConditions sets the "conditions" field.
  17265. func (m *LabelMutation) SetConditions(s string) {
  17266. m.conditions = &s
  17267. }
  17268. // Conditions returns the value of the "conditions" field in the mutation.
  17269. func (m *LabelMutation) Conditions() (r string, exists bool) {
  17270. v := m.conditions
  17271. if v == nil {
  17272. return
  17273. }
  17274. return *v, true
  17275. }
  17276. // OldConditions returns the old "conditions" field's value of the Label entity.
  17277. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17279. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  17280. if !m.op.Is(OpUpdateOne) {
  17281. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  17282. }
  17283. if m.id == nil || m.oldValue == nil {
  17284. return v, errors.New("OldConditions requires an ID field in the mutation")
  17285. }
  17286. oldValue, err := m.oldValue(ctx)
  17287. if err != nil {
  17288. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  17289. }
  17290. return oldValue.Conditions, nil
  17291. }
  17292. // ClearConditions clears the value of the "conditions" field.
  17293. func (m *LabelMutation) ClearConditions() {
  17294. m.conditions = nil
  17295. m.clearedFields[label.FieldConditions] = struct{}{}
  17296. }
  17297. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  17298. func (m *LabelMutation) ConditionsCleared() bool {
  17299. _, ok := m.clearedFields[label.FieldConditions]
  17300. return ok
  17301. }
  17302. // ResetConditions resets all changes to the "conditions" field.
  17303. func (m *LabelMutation) ResetConditions() {
  17304. m.conditions = nil
  17305. delete(m.clearedFields, label.FieldConditions)
  17306. }
  17307. // SetOrganizationID sets the "organization_id" field.
  17308. func (m *LabelMutation) SetOrganizationID(u uint64) {
  17309. m.organization_id = &u
  17310. m.addorganization_id = nil
  17311. }
  17312. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17313. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  17314. v := m.organization_id
  17315. if v == nil {
  17316. return
  17317. }
  17318. return *v, true
  17319. }
  17320. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  17321. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  17322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17323. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17324. if !m.op.Is(OpUpdateOne) {
  17325. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17326. }
  17327. if m.id == nil || m.oldValue == nil {
  17328. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17329. }
  17330. oldValue, err := m.oldValue(ctx)
  17331. if err != nil {
  17332. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17333. }
  17334. return oldValue.OrganizationID, nil
  17335. }
  17336. // AddOrganizationID adds u to the "organization_id" field.
  17337. func (m *LabelMutation) AddOrganizationID(u int64) {
  17338. if m.addorganization_id != nil {
  17339. *m.addorganization_id += u
  17340. } else {
  17341. m.addorganization_id = &u
  17342. }
  17343. }
  17344. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17345. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  17346. v := m.addorganization_id
  17347. if v == nil {
  17348. return
  17349. }
  17350. return *v, true
  17351. }
  17352. // ClearOrganizationID clears the value of the "organization_id" field.
  17353. func (m *LabelMutation) ClearOrganizationID() {
  17354. m.organization_id = nil
  17355. m.addorganization_id = nil
  17356. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  17357. }
  17358. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17359. func (m *LabelMutation) OrganizationIDCleared() bool {
  17360. _, ok := m.clearedFields[label.FieldOrganizationID]
  17361. return ok
  17362. }
  17363. // ResetOrganizationID resets all changes to the "organization_id" field.
  17364. func (m *LabelMutation) ResetOrganizationID() {
  17365. m.organization_id = nil
  17366. m.addorganization_id = nil
  17367. delete(m.clearedFields, label.FieldOrganizationID)
  17368. }
  17369. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  17370. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  17371. if m.label_relationships == nil {
  17372. m.label_relationships = make(map[uint64]struct{})
  17373. }
  17374. for i := range ids {
  17375. m.label_relationships[ids[i]] = struct{}{}
  17376. }
  17377. }
  17378. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  17379. func (m *LabelMutation) ClearLabelRelationships() {
  17380. m.clearedlabel_relationships = true
  17381. }
  17382. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  17383. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  17384. return m.clearedlabel_relationships
  17385. }
  17386. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  17387. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  17388. if m.removedlabel_relationships == nil {
  17389. m.removedlabel_relationships = make(map[uint64]struct{})
  17390. }
  17391. for i := range ids {
  17392. delete(m.label_relationships, ids[i])
  17393. m.removedlabel_relationships[ids[i]] = struct{}{}
  17394. }
  17395. }
  17396. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  17397. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  17398. for id := range m.removedlabel_relationships {
  17399. ids = append(ids, id)
  17400. }
  17401. return
  17402. }
  17403. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  17404. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  17405. for id := range m.label_relationships {
  17406. ids = append(ids, id)
  17407. }
  17408. return
  17409. }
  17410. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  17411. func (m *LabelMutation) ResetLabelRelationships() {
  17412. m.label_relationships = nil
  17413. m.clearedlabel_relationships = false
  17414. m.removedlabel_relationships = nil
  17415. }
  17416. // Where appends a list predicates to the LabelMutation builder.
  17417. func (m *LabelMutation) Where(ps ...predicate.Label) {
  17418. m.predicates = append(m.predicates, ps...)
  17419. }
  17420. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  17421. // users can use type-assertion to append predicates that do not depend on any generated package.
  17422. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  17423. p := make([]predicate.Label, len(ps))
  17424. for i := range ps {
  17425. p[i] = ps[i]
  17426. }
  17427. m.Where(p...)
  17428. }
  17429. // Op returns the operation name.
  17430. func (m *LabelMutation) Op() Op {
  17431. return m.op
  17432. }
  17433. // SetOp allows setting the mutation operation.
  17434. func (m *LabelMutation) SetOp(op Op) {
  17435. m.op = op
  17436. }
  17437. // Type returns the node type of this mutation (Label).
  17438. func (m *LabelMutation) Type() string {
  17439. return m.typ
  17440. }
  17441. // Fields returns all fields that were changed during this mutation. Note that in
  17442. // order to get all numeric fields that were incremented/decremented, call
  17443. // AddedFields().
  17444. func (m *LabelMutation) Fields() []string {
  17445. fields := make([]string, 0, 9)
  17446. if m.created_at != nil {
  17447. fields = append(fields, label.FieldCreatedAt)
  17448. }
  17449. if m.updated_at != nil {
  17450. fields = append(fields, label.FieldUpdatedAt)
  17451. }
  17452. if m.status != nil {
  17453. fields = append(fields, label.FieldStatus)
  17454. }
  17455. if m._type != nil {
  17456. fields = append(fields, label.FieldType)
  17457. }
  17458. if m.name != nil {
  17459. fields = append(fields, label.FieldName)
  17460. }
  17461. if m.from != nil {
  17462. fields = append(fields, label.FieldFrom)
  17463. }
  17464. if m.mode != nil {
  17465. fields = append(fields, label.FieldMode)
  17466. }
  17467. if m.conditions != nil {
  17468. fields = append(fields, label.FieldConditions)
  17469. }
  17470. if m.organization_id != nil {
  17471. fields = append(fields, label.FieldOrganizationID)
  17472. }
  17473. return fields
  17474. }
  17475. // Field returns the value of a field with the given name. The second boolean
  17476. // return value indicates that this field was not set, or was not defined in the
  17477. // schema.
  17478. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  17479. switch name {
  17480. case label.FieldCreatedAt:
  17481. return m.CreatedAt()
  17482. case label.FieldUpdatedAt:
  17483. return m.UpdatedAt()
  17484. case label.FieldStatus:
  17485. return m.Status()
  17486. case label.FieldType:
  17487. return m.GetType()
  17488. case label.FieldName:
  17489. return m.Name()
  17490. case label.FieldFrom:
  17491. return m.From()
  17492. case label.FieldMode:
  17493. return m.Mode()
  17494. case label.FieldConditions:
  17495. return m.Conditions()
  17496. case label.FieldOrganizationID:
  17497. return m.OrganizationID()
  17498. }
  17499. return nil, false
  17500. }
  17501. // OldField returns the old value of the field from the database. An error is
  17502. // returned if the mutation operation is not UpdateOne, or the query to the
  17503. // database failed.
  17504. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17505. switch name {
  17506. case label.FieldCreatedAt:
  17507. return m.OldCreatedAt(ctx)
  17508. case label.FieldUpdatedAt:
  17509. return m.OldUpdatedAt(ctx)
  17510. case label.FieldStatus:
  17511. return m.OldStatus(ctx)
  17512. case label.FieldType:
  17513. return m.OldType(ctx)
  17514. case label.FieldName:
  17515. return m.OldName(ctx)
  17516. case label.FieldFrom:
  17517. return m.OldFrom(ctx)
  17518. case label.FieldMode:
  17519. return m.OldMode(ctx)
  17520. case label.FieldConditions:
  17521. return m.OldConditions(ctx)
  17522. case label.FieldOrganizationID:
  17523. return m.OldOrganizationID(ctx)
  17524. }
  17525. return nil, fmt.Errorf("unknown Label field %s", name)
  17526. }
  17527. // SetField sets the value of a field with the given name. It returns an error if
  17528. // the field is not defined in the schema, or if the type mismatched the field
  17529. // type.
  17530. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  17531. switch name {
  17532. case label.FieldCreatedAt:
  17533. v, ok := value.(time.Time)
  17534. if !ok {
  17535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17536. }
  17537. m.SetCreatedAt(v)
  17538. return nil
  17539. case label.FieldUpdatedAt:
  17540. v, ok := value.(time.Time)
  17541. if !ok {
  17542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17543. }
  17544. m.SetUpdatedAt(v)
  17545. return nil
  17546. case label.FieldStatus:
  17547. v, ok := value.(uint8)
  17548. if !ok {
  17549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17550. }
  17551. m.SetStatus(v)
  17552. return nil
  17553. case label.FieldType:
  17554. v, ok := value.(int)
  17555. if !ok {
  17556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17557. }
  17558. m.SetType(v)
  17559. return nil
  17560. case label.FieldName:
  17561. v, ok := value.(string)
  17562. if !ok {
  17563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17564. }
  17565. m.SetName(v)
  17566. return nil
  17567. case label.FieldFrom:
  17568. v, ok := value.(int)
  17569. if !ok {
  17570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17571. }
  17572. m.SetFrom(v)
  17573. return nil
  17574. case label.FieldMode:
  17575. v, ok := value.(int)
  17576. if !ok {
  17577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17578. }
  17579. m.SetMode(v)
  17580. return nil
  17581. case label.FieldConditions:
  17582. v, ok := value.(string)
  17583. if !ok {
  17584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17585. }
  17586. m.SetConditions(v)
  17587. return nil
  17588. case label.FieldOrganizationID:
  17589. v, ok := value.(uint64)
  17590. if !ok {
  17591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17592. }
  17593. m.SetOrganizationID(v)
  17594. return nil
  17595. }
  17596. return fmt.Errorf("unknown Label field %s", name)
  17597. }
  17598. // AddedFields returns all numeric fields that were incremented/decremented during
  17599. // this mutation.
  17600. func (m *LabelMutation) AddedFields() []string {
  17601. var fields []string
  17602. if m.addstatus != nil {
  17603. fields = append(fields, label.FieldStatus)
  17604. }
  17605. if m.add_type != nil {
  17606. fields = append(fields, label.FieldType)
  17607. }
  17608. if m.addfrom != nil {
  17609. fields = append(fields, label.FieldFrom)
  17610. }
  17611. if m.addmode != nil {
  17612. fields = append(fields, label.FieldMode)
  17613. }
  17614. if m.addorganization_id != nil {
  17615. fields = append(fields, label.FieldOrganizationID)
  17616. }
  17617. return fields
  17618. }
  17619. // AddedField returns the numeric value that was incremented/decremented on a field
  17620. // with the given name. The second boolean return value indicates that this field
  17621. // was not set, or was not defined in the schema.
  17622. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  17623. switch name {
  17624. case label.FieldStatus:
  17625. return m.AddedStatus()
  17626. case label.FieldType:
  17627. return m.AddedType()
  17628. case label.FieldFrom:
  17629. return m.AddedFrom()
  17630. case label.FieldMode:
  17631. return m.AddedMode()
  17632. case label.FieldOrganizationID:
  17633. return m.AddedOrganizationID()
  17634. }
  17635. return nil, false
  17636. }
  17637. // AddField adds the value to the field with the given name. It returns an error if
  17638. // the field is not defined in the schema, or if the type mismatched the field
  17639. // type.
  17640. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  17641. switch name {
  17642. case label.FieldStatus:
  17643. v, ok := value.(int8)
  17644. if !ok {
  17645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17646. }
  17647. m.AddStatus(v)
  17648. return nil
  17649. case label.FieldType:
  17650. v, ok := value.(int)
  17651. if !ok {
  17652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17653. }
  17654. m.AddType(v)
  17655. return nil
  17656. case label.FieldFrom:
  17657. v, ok := value.(int)
  17658. if !ok {
  17659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17660. }
  17661. m.AddFrom(v)
  17662. return nil
  17663. case label.FieldMode:
  17664. v, ok := value.(int)
  17665. if !ok {
  17666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17667. }
  17668. m.AddMode(v)
  17669. return nil
  17670. case label.FieldOrganizationID:
  17671. v, ok := value.(int64)
  17672. if !ok {
  17673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17674. }
  17675. m.AddOrganizationID(v)
  17676. return nil
  17677. }
  17678. return fmt.Errorf("unknown Label numeric field %s", name)
  17679. }
  17680. // ClearedFields returns all nullable fields that were cleared during this
  17681. // mutation.
  17682. func (m *LabelMutation) ClearedFields() []string {
  17683. var fields []string
  17684. if m.FieldCleared(label.FieldStatus) {
  17685. fields = append(fields, label.FieldStatus)
  17686. }
  17687. if m.FieldCleared(label.FieldConditions) {
  17688. fields = append(fields, label.FieldConditions)
  17689. }
  17690. if m.FieldCleared(label.FieldOrganizationID) {
  17691. fields = append(fields, label.FieldOrganizationID)
  17692. }
  17693. return fields
  17694. }
  17695. // FieldCleared returns a boolean indicating if a field with the given name was
  17696. // cleared in this mutation.
  17697. func (m *LabelMutation) FieldCleared(name string) bool {
  17698. _, ok := m.clearedFields[name]
  17699. return ok
  17700. }
  17701. // ClearField clears the value of the field with the given name. It returns an
  17702. // error if the field is not defined in the schema.
  17703. func (m *LabelMutation) ClearField(name string) error {
  17704. switch name {
  17705. case label.FieldStatus:
  17706. m.ClearStatus()
  17707. return nil
  17708. case label.FieldConditions:
  17709. m.ClearConditions()
  17710. return nil
  17711. case label.FieldOrganizationID:
  17712. m.ClearOrganizationID()
  17713. return nil
  17714. }
  17715. return fmt.Errorf("unknown Label nullable field %s", name)
  17716. }
  17717. // ResetField resets all changes in the mutation for the field with the given name.
  17718. // It returns an error if the field is not defined in the schema.
  17719. func (m *LabelMutation) ResetField(name string) error {
  17720. switch name {
  17721. case label.FieldCreatedAt:
  17722. m.ResetCreatedAt()
  17723. return nil
  17724. case label.FieldUpdatedAt:
  17725. m.ResetUpdatedAt()
  17726. return nil
  17727. case label.FieldStatus:
  17728. m.ResetStatus()
  17729. return nil
  17730. case label.FieldType:
  17731. m.ResetType()
  17732. return nil
  17733. case label.FieldName:
  17734. m.ResetName()
  17735. return nil
  17736. case label.FieldFrom:
  17737. m.ResetFrom()
  17738. return nil
  17739. case label.FieldMode:
  17740. m.ResetMode()
  17741. return nil
  17742. case label.FieldConditions:
  17743. m.ResetConditions()
  17744. return nil
  17745. case label.FieldOrganizationID:
  17746. m.ResetOrganizationID()
  17747. return nil
  17748. }
  17749. return fmt.Errorf("unknown Label field %s", name)
  17750. }
  17751. // AddedEdges returns all edge names that were set/added in this mutation.
  17752. func (m *LabelMutation) AddedEdges() []string {
  17753. edges := make([]string, 0, 1)
  17754. if m.label_relationships != nil {
  17755. edges = append(edges, label.EdgeLabelRelationships)
  17756. }
  17757. return edges
  17758. }
  17759. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17760. // name in this mutation.
  17761. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  17762. switch name {
  17763. case label.EdgeLabelRelationships:
  17764. ids := make([]ent.Value, 0, len(m.label_relationships))
  17765. for id := range m.label_relationships {
  17766. ids = append(ids, id)
  17767. }
  17768. return ids
  17769. }
  17770. return nil
  17771. }
  17772. // RemovedEdges returns all edge names that were removed in this mutation.
  17773. func (m *LabelMutation) RemovedEdges() []string {
  17774. edges := make([]string, 0, 1)
  17775. if m.removedlabel_relationships != nil {
  17776. edges = append(edges, label.EdgeLabelRelationships)
  17777. }
  17778. return edges
  17779. }
  17780. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17781. // the given name in this mutation.
  17782. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  17783. switch name {
  17784. case label.EdgeLabelRelationships:
  17785. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  17786. for id := range m.removedlabel_relationships {
  17787. ids = append(ids, id)
  17788. }
  17789. return ids
  17790. }
  17791. return nil
  17792. }
  17793. // ClearedEdges returns all edge names that were cleared in this mutation.
  17794. func (m *LabelMutation) ClearedEdges() []string {
  17795. edges := make([]string, 0, 1)
  17796. if m.clearedlabel_relationships {
  17797. edges = append(edges, label.EdgeLabelRelationships)
  17798. }
  17799. return edges
  17800. }
  17801. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17802. // was cleared in this mutation.
  17803. func (m *LabelMutation) EdgeCleared(name string) bool {
  17804. switch name {
  17805. case label.EdgeLabelRelationships:
  17806. return m.clearedlabel_relationships
  17807. }
  17808. return false
  17809. }
  17810. // ClearEdge clears the value of the edge with the given name. It returns an error
  17811. // if that edge is not defined in the schema.
  17812. func (m *LabelMutation) ClearEdge(name string) error {
  17813. switch name {
  17814. }
  17815. return fmt.Errorf("unknown Label unique edge %s", name)
  17816. }
  17817. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17818. // It returns an error if the edge is not defined in the schema.
  17819. func (m *LabelMutation) ResetEdge(name string) error {
  17820. switch name {
  17821. case label.EdgeLabelRelationships:
  17822. m.ResetLabelRelationships()
  17823. return nil
  17824. }
  17825. return fmt.Errorf("unknown Label edge %s", name)
  17826. }
  17827. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  17828. type LabelRelationshipMutation struct {
  17829. config
  17830. op Op
  17831. typ string
  17832. id *uint64
  17833. created_at *time.Time
  17834. updated_at *time.Time
  17835. status *uint8
  17836. addstatus *int8
  17837. organization_id *uint64
  17838. addorganization_id *int64
  17839. clearedFields map[string]struct{}
  17840. contacts *uint64
  17841. clearedcontacts bool
  17842. labels *uint64
  17843. clearedlabels bool
  17844. done bool
  17845. oldValue func(context.Context) (*LabelRelationship, error)
  17846. predicates []predicate.LabelRelationship
  17847. }
  17848. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  17849. // labelrelationshipOption allows management of the mutation configuration using functional options.
  17850. type labelrelationshipOption func(*LabelRelationshipMutation)
  17851. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  17852. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  17853. m := &LabelRelationshipMutation{
  17854. config: c,
  17855. op: op,
  17856. typ: TypeLabelRelationship,
  17857. clearedFields: make(map[string]struct{}),
  17858. }
  17859. for _, opt := range opts {
  17860. opt(m)
  17861. }
  17862. return m
  17863. }
  17864. // withLabelRelationshipID sets the ID field of the mutation.
  17865. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  17866. return func(m *LabelRelationshipMutation) {
  17867. var (
  17868. err error
  17869. once sync.Once
  17870. value *LabelRelationship
  17871. )
  17872. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  17873. once.Do(func() {
  17874. if m.done {
  17875. err = errors.New("querying old values post mutation is not allowed")
  17876. } else {
  17877. value, err = m.Client().LabelRelationship.Get(ctx, id)
  17878. }
  17879. })
  17880. return value, err
  17881. }
  17882. m.id = &id
  17883. }
  17884. }
  17885. // withLabelRelationship sets the old LabelRelationship of the mutation.
  17886. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  17887. return func(m *LabelRelationshipMutation) {
  17888. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  17889. return node, nil
  17890. }
  17891. m.id = &node.ID
  17892. }
  17893. }
  17894. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17895. // executed in a transaction (ent.Tx), a transactional client is returned.
  17896. func (m LabelRelationshipMutation) Client() *Client {
  17897. client := &Client{config: m.config}
  17898. client.init()
  17899. return client
  17900. }
  17901. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17902. // it returns an error otherwise.
  17903. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  17904. if _, ok := m.driver.(*txDriver); !ok {
  17905. return nil, errors.New("ent: mutation is not running in a transaction")
  17906. }
  17907. tx := &Tx{config: m.config}
  17908. tx.init()
  17909. return tx, nil
  17910. }
  17911. // SetID sets the value of the id field. Note that this
  17912. // operation is only accepted on creation of LabelRelationship entities.
  17913. func (m *LabelRelationshipMutation) SetID(id uint64) {
  17914. m.id = &id
  17915. }
  17916. // ID returns the ID value in the mutation. Note that the ID is only available
  17917. // if it was provided to the builder or after it was returned from the database.
  17918. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  17919. if m.id == nil {
  17920. return
  17921. }
  17922. return *m.id, true
  17923. }
  17924. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17925. // That means, if the mutation is applied within a transaction with an isolation level such
  17926. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17927. // or updated by the mutation.
  17928. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  17929. switch {
  17930. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17931. id, exists := m.ID()
  17932. if exists {
  17933. return []uint64{id}, nil
  17934. }
  17935. fallthrough
  17936. case m.op.Is(OpUpdate | OpDelete):
  17937. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  17938. default:
  17939. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17940. }
  17941. }
  17942. // SetCreatedAt sets the "created_at" field.
  17943. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  17944. m.created_at = &t
  17945. }
  17946. // CreatedAt returns the value of the "created_at" field in the mutation.
  17947. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  17948. v := m.created_at
  17949. if v == nil {
  17950. return
  17951. }
  17952. return *v, true
  17953. }
  17954. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  17955. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17957. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17958. if !m.op.Is(OpUpdateOne) {
  17959. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17960. }
  17961. if m.id == nil || m.oldValue == nil {
  17962. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17963. }
  17964. oldValue, err := m.oldValue(ctx)
  17965. if err != nil {
  17966. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17967. }
  17968. return oldValue.CreatedAt, nil
  17969. }
  17970. // ResetCreatedAt resets all changes to the "created_at" field.
  17971. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  17972. m.created_at = nil
  17973. }
  17974. // SetUpdatedAt sets the "updated_at" field.
  17975. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  17976. m.updated_at = &t
  17977. }
  17978. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17979. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  17980. v := m.updated_at
  17981. if v == nil {
  17982. return
  17983. }
  17984. return *v, true
  17985. }
  17986. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  17987. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  17988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17989. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17990. if !m.op.Is(OpUpdateOne) {
  17991. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17992. }
  17993. if m.id == nil || m.oldValue == nil {
  17994. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17995. }
  17996. oldValue, err := m.oldValue(ctx)
  17997. if err != nil {
  17998. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17999. }
  18000. return oldValue.UpdatedAt, nil
  18001. }
  18002. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18003. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  18004. m.updated_at = nil
  18005. }
  18006. // SetStatus sets the "status" field.
  18007. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  18008. m.status = &u
  18009. m.addstatus = nil
  18010. }
  18011. // Status returns the value of the "status" field in the mutation.
  18012. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  18013. v := m.status
  18014. if v == nil {
  18015. return
  18016. }
  18017. return *v, true
  18018. }
  18019. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  18020. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18022. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18023. if !m.op.Is(OpUpdateOne) {
  18024. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18025. }
  18026. if m.id == nil || m.oldValue == nil {
  18027. return v, errors.New("OldStatus requires an ID field in the mutation")
  18028. }
  18029. oldValue, err := m.oldValue(ctx)
  18030. if err != nil {
  18031. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18032. }
  18033. return oldValue.Status, nil
  18034. }
  18035. // AddStatus adds u to the "status" field.
  18036. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  18037. if m.addstatus != nil {
  18038. *m.addstatus += u
  18039. } else {
  18040. m.addstatus = &u
  18041. }
  18042. }
  18043. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18044. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  18045. v := m.addstatus
  18046. if v == nil {
  18047. return
  18048. }
  18049. return *v, true
  18050. }
  18051. // ClearStatus clears the value of the "status" field.
  18052. func (m *LabelRelationshipMutation) ClearStatus() {
  18053. m.status = nil
  18054. m.addstatus = nil
  18055. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  18056. }
  18057. // StatusCleared returns if the "status" field was cleared in this mutation.
  18058. func (m *LabelRelationshipMutation) StatusCleared() bool {
  18059. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  18060. return ok
  18061. }
  18062. // ResetStatus resets all changes to the "status" field.
  18063. func (m *LabelRelationshipMutation) ResetStatus() {
  18064. m.status = nil
  18065. m.addstatus = nil
  18066. delete(m.clearedFields, labelrelationship.FieldStatus)
  18067. }
  18068. // SetLabelID sets the "label_id" field.
  18069. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  18070. m.labels = &u
  18071. }
  18072. // LabelID returns the value of the "label_id" field in the mutation.
  18073. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  18074. v := m.labels
  18075. if v == nil {
  18076. return
  18077. }
  18078. return *v, true
  18079. }
  18080. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  18081. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18083. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  18084. if !m.op.Is(OpUpdateOne) {
  18085. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  18086. }
  18087. if m.id == nil || m.oldValue == nil {
  18088. return v, errors.New("OldLabelID requires an ID field in the mutation")
  18089. }
  18090. oldValue, err := m.oldValue(ctx)
  18091. if err != nil {
  18092. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  18093. }
  18094. return oldValue.LabelID, nil
  18095. }
  18096. // ResetLabelID resets all changes to the "label_id" field.
  18097. func (m *LabelRelationshipMutation) ResetLabelID() {
  18098. m.labels = nil
  18099. }
  18100. // SetContactID sets the "contact_id" field.
  18101. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  18102. m.contacts = &u
  18103. }
  18104. // ContactID returns the value of the "contact_id" field in the mutation.
  18105. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  18106. v := m.contacts
  18107. if v == nil {
  18108. return
  18109. }
  18110. return *v, true
  18111. }
  18112. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  18113. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18115. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  18116. if !m.op.Is(OpUpdateOne) {
  18117. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  18118. }
  18119. if m.id == nil || m.oldValue == nil {
  18120. return v, errors.New("OldContactID requires an ID field in the mutation")
  18121. }
  18122. oldValue, err := m.oldValue(ctx)
  18123. if err != nil {
  18124. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  18125. }
  18126. return oldValue.ContactID, nil
  18127. }
  18128. // ResetContactID resets all changes to the "contact_id" field.
  18129. func (m *LabelRelationshipMutation) ResetContactID() {
  18130. m.contacts = nil
  18131. }
  18132. // SetOrganizationID sets the "organization_id" field.
  18133. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  18134. m.organization_id = &u
  18135. m.addorganization_id = nil
  18136. }
  18137. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18138. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  18139. v := m.organization_id
  18140. if v == nil {
  18141. return
  18142. }
  18143. return *v, true
  18144. }
  18145. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  18146. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  18147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18148. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18149. if !m.op.Is(OpUpdateOne) {
  18150. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18151. }
  18152. if m.id == nil || m.oldValue == nil {
  18153. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18154. }
  18155. oldValue, err := m.oldValue(ctx)
  18156. if err != nil {
  18157. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18158. }
  18159. return oldValue.OrganizationID, nil
  18160. }
  18161. // AddOrganizationID adds u to the "organization_id" field.
  18162. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  18163. if m.addorganization_id != nil {
  18164. *m.addorganization_id += u
  18165. } else {
  18166. m.addorganization_id = &u
  18167. }
  18168. }
  18169. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18170. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  18171. v := m.addorganization_id
  18172. if v == nil {
  18173. return
  18174. }
  18175. return *v, true
  18176. }
  18177. // ClearOrganizationID clears the value of the "organization_id" field.
  18178. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  18179. m.organization_id = nil
  18180. m.addorganization_id = nil
  18181. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  18182. }
  18183. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  18184. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  18185. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  18186. return ok
  18187. }
  18188. // ResetOrganizationID resets all changes to the "organization_id" field.
  18189. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  18190. m.organization_id = nil
  18191. m.addorganization_id = nil
  18192. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  18193. }
  18194. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  18195. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  18196. m.contacts = &id
  18197. }
  18198. // ClearContacts clears the "contacts" edge to the Contact entity.
  18199. func (m *LabelRelationshipMutation) ClearContacts() {
  18200. m.clearedcontacts = true
  18201. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  18202. }
  18203. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  18204. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  18205. return m.clearedcontacts
  18206. }
  18207. // ContactsID returns the "contacts" edge ID in the mutation.
  18208. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  18209. if m.contacts != nil {
  18210. return *m.contacts, true
  18211. }
  18212. return
  18213. }
  18214. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  18215. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18216. // ContactsID instead. It exists only for internal usage by the builders.
  18217. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  18218. if id := m.contacts; id != nil {
  18219. ids = append(ids, *id)
  18220. }
  18221. return
  18222. }
  18223. // ResetContacts resets all changes to the "contacts" edge.
  18224. func (m *LabelRelationshipMutation) ResetContacts() {
  18225. m.contacts = nil
  18226. m.clearedcontacts = false
  18227. }
  18228. // SetLabelsID sets the "labels" edge to the Label entity by id.
  18229. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  18230. m.labels = &id
  18231. }
  18232. // ClearLabels clears the "labels" edge to the Label entity.
  18233. func (m *LabelRelationshipMutation) ClearLabels() {
  18234. m.clearedlabels = true
  18235. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  18236. }
  18237. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  18238. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  18239. return m.clearedlabels
  18240. }
  18241. // LabelsID returns the "labels" edge ID in the mutation.
  18242. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  18243. if m.labels != nil {
  18244. return *m.labels, true
  18245. }
  18246. return
  18247. }
  18248. // LabelsIDs returns the "labels" edge IDs in the mutation.
  18249. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18250. // LabelsID instead. It exists only for internal usage by the builders.
  18251. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  18252. if id := m.labels; id != nil {
  18253. ids = append(ids, *id)
  18254. }
  18255. return
  18256. }
  18257. // ResetLabels resets all changes to the "labels" edge.
  18258. func (m *LabelRelationshipMutation) ResetLabels() {
  18259. m.labels = nil
  18260. m.clearedlabels = false
  18261. }
  18262. // Where appends a list predicates to the LabelRelationshipMutation builder.
  18263. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  18264. m.predicates = append(m.predicates, ps...)
  18265. }
  18266. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  18267. // users can use type-assertion to append predicates that do not depend on any generated package.
  18268. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  18269. p := make([]predicate.LabelRelationship, len(ps))
  18270. for i := range ps {
  18271. p[i] = ps[i]
  18272. }
  18273. m.Where(p...)
  18274. }
  18275. // Op returns the operation name.
  18276. func (m *LabelRelationshipMutation) Op() Op {
  18277. return m.op
  18278. }
  18279. // SetOp allows setting the mutation operation.
  18280. func (m *LabelRelationshipMutation) SetOp(op Op) {
  18281. m.op = op
  18282. }
  18283. // Type returns the node type of this mutation (LabelRelationship).
  18284. func (m *LabelRelationshipMutation) Type() string {
  18285. return m.typ
  18286. }
  18287. // Fields returns all fields that were changed during this mutation. Note that in
  18288. // order to get all numeric fields that were incremented/decremented, call
  18289. // AddedFields().
  18290. func (m *LabelRelationshipMutation) Fields() []string {
  18291. fields := make([]string, 0, 6)
  18292. if m.created_at != nil {
  18293. fields = append(fields, labelrelationship.FieldCreatedAt)
  18294. }
  18295. if m.updated_at != nil {
  18296. fields = append(fields, labelrelationship.FieldUpdatedAt)
  18297. }
  18298. if m.status != nil {
  18299. fields = append(fields, labelrelationship.FieldStatus)
  18300. }
  18301. if m.labels != nil {
  18302. fields = append(fields, labelrelationship.FieldLabelID)
  18303. }
  18304. if m.contacts != nil {
  18305. fields = append(fields, labelrelationship.FieldContactID)
  18306. }
  18307. if m.organization_id != nil {
  18308. fields = append(fields, labelrelationship.FieldOrganizationID)
  18309. }
  18310. return fields
  18311. }
  18312. // Field returns the value of a field with the given name. The second boolean
  18313. // return value indicates that this field was not set, or was not defined in the
  18314. // schema.
  18315. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  18316. switch name {
  18317. case labelrelationship.FieldCreatedAt:
  18318. return m.CreatedAt()
  18319. case labelrelationship.FieldUpdatedAt:
  18320. return m.UpdatedAt()
  18321. case labelrelationship.FieldStatus:
  18322. return m.Status()
  18323. case labelrelationship.FieldLabelID:
  18324. return m.LabelID()
  18325. case labelrelationship.FieldContactID:
  18326. return m.ContactID()
  18327. case labelrelationship.FieldOrganizationID:
  18328. return m.OrganizationID()
  18329. }
  18330. return nil, false
  18331. }
  18332. // OldField returns the old value of the field from the database. An error is
  18333. // returned if the mutation operation is not UpdateOne, or the query to the
  18334. // database failed.
  18335. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18336. switch name {
  18337. case labelrelationship.FieldCreatedAt:
  18338. return m.OldCreatedAt(ctx)
  18339. case labelrelationship.FieldUpdatedAt:
  18340. return m.OldUpdatedAt(ctx)
  18341. case labelrelationship.FieldStatus:
  18342. return m.OldStatus(ctx)
  18343. case labelrelationship.FieldLabelID:
  18344. return m.OldLabelID(ctx)
  18345. case labelrelationship.FieldContactID:
  18346. return m.OldContactID(ctx)
  18347. case labelrelationship.FieldOrganizationID:
  18348. return m.OldOrganizationID(ctx)
  18349. }
  18350. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  18351. }
  18352. // SetField sets the value of a field with the given name. It returns an error if
  18353. // the field is not defined in the schema, or if the type mismatched the field
  18354. // type.
  18355. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  18356. switch name {
  18357. case labelrelationship.FieldCreatedAt:
  18358. v, ok := value.(time.Time)
  18359. if !ok {
  18360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18361. }
  18362. m.SetCreatedAt(v)
  18363. return nil
  18364. case labelrelationship.FieldUpdatedAt:
  18365. v, ok := value.(time.Time)
  18366. if !ok {
  18367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18368. }
  18369. m.SetUpdatedAt(v)
  18370. return nil
  18371. case labelrelationship.FieldStatus:
  18372. v, ok := value.(uint8)
  18373. if !ok {
  18374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18375. }
  18376. m.SetStatus(v)
  18377. return nil
  18378. case labelrelationship.FieldLabelID:
  18379. v, ok := value.(uint64)
  18380. if !ok {
  18381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18382. }
  18383. m.SetLabelID(v)
  18384. return nil
  18385. case labelrelationship.FieldContactID:
  18386. v, ok := value.(uint64)
  18387. if !ok {
  18388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18389. }
  18390. m.SetContactID(v)
  18391. return nil
  18392. case labelrelationship.FieldOrganizationID:
  18393. v, ok := value.(uint64)
  18394. if !ok {
  18395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18396. }
  18397. m.SetOrganizationID(v)
  18398. return nil
  18399. }
  18400. return fmt.Errorf("unknown LabelRelationship field %s", name)
  18401. }
  18402. // AddedFields returns all numeric fields that were incremented/decremented during
  18403. // this mutation.
  18404. func (m *LabelRelationshipMutation) AddedFields() []string {
  18405. var fields []string
  18406. if m.addstatus != nil {
  18407. fields = append(fields, labelrelationship.FieldStatus)
  18408. }
  18409. if m.addorganization_id != nil {
  18410. fields = append(fields, labelrelationship.FieldOrganizationID)
  18411. }
  18412. return fields
  18413. }
  18414. // AddedField returns the numeric value that was incremented/decremented on a field
  18415. // with the given name. The second boolean return value indicates that this field
  18416. // was not set, or was not defined in the schema.
  18417. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  18418. switch name {
  18419. case labelrelationship.FieldStatus:
  18420. return m.AddedStatus()
  18421. case labelrelationship.FieldOrganizationID:
  18422. return m.AddedOrganizationID()
  18423. }
  18424. return nil, false
  18425. }
  18426. // AddField adds the value to the field with the given name. It returns an error if
  18427. // the field is not defined in the schema, or if the type mismatched the field
  18428. // type.
  18429. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  18430. switch name {
  18431. case labelrelationship.FieldStatus:
  18432. v, ok := value.(int8)
  18433. if !ok {
  18434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18435. }
  18436. m.AddStatus(v)
  18437. return nil
  18438. case labelrelationship.FieldOrganizationID:
  18439. v, ok := value.(int64)
  18440. if !ok {
  18441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18442. }
  18443. m.AddOrganizationID(v)
  18444. return nil
  18445. }
  18446. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  18447. }
  18448. // ClearedFields returns all nullable fields that were cleared during this
  18449. // mutation.
  18450. func (m *LabelRelationshipMutation) ClearedFields() []string {
  18451. var fields []string
  18452. if m.FieldCleared(labelrelationship.FieldStatus) {
  18453. fields = append(fields, labelrelationship.FieldStatus)
  18454. }
  18455. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  18456. fields = append(fields, labelrelationship.FieldOrganizationID)
  18457. }
  18458. return fields
  18459. }
  18460. // FieldCleared returns a boolean indicating if a field with the given name was
  18461. // cleared in this mutation.
  18462. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  18463. _, ok := m.clearedFields[name]
  18464. return ok
  18465. }
  18466. // ClearField clears the value of the field with the given name. It returns an
  18467. // error if the field is not defined in the schema.
  18468. func (m *LabelRelationshipMutation) ClearField(name string) error {
  18469. switch name {
  18470. case labelrelationship.FieldStatus:
  18471. m.ClearStatus()
  18472. return nil
  18473. case labelrelationship.FieldOrganizationID:
  18474. m.ClearOrganizationID()
  18475. return nil
  18476. }
  18477. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  18478. }
  18479. // ResetField resets all changes in the mutation for the field with the given name.
  18480. // It returns an error if the field is not defined in the schema.
  18481. func (m *LabelRelationshipMutation) ResetField(name string) error {
  18482. switch name {
  18483. case labelrelationship.FieldCreatedAt:
  18484. m.ResetCreatedAt()
  18485. return nil
  18486. case labelrelationship.FieldUpdatedAt:
  18487. m.ResetUpdatedAt()
  18488. return nil
  18489. case labelrelationship.FieldStatus:
  18490. m.ResetStatus()
  18491. return nil
  18492. case labelrelationship.FieldLabelID:
  18493. m.ResetLabelID()
  18494. return nil
  18495. case labelrelationship.FieldContactID:
  18496. m.ResetContactID()
  18497. return nil
  18498. case labelrelationship.FieldOrganizationID:
  18499. m.ResetOrganizationID()
  18500. return nil
  18501. }
  18502. return fmt.Errorf("unknown LabelRelationship field %s", name)
  18503. }
  18504. // AddedEdges returns all edge names that were set/added in this mutation.
  18505. func (m *LabelRelationshipMutation) AddedEdges() []string {
  18506. edges := make([]string, 0, 2)
  18507. if m.contacts != nil {
  18508. edges = append(edges, labelrelationship.EdgeContacts)
  18509. }
  18510. if m.labels != nil {
  18511. edges = append(edges, labelrelationship.EdgeLabels)
  18512. }
  18513. return edges
  18514. }
  18515. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18516. // name in this mutation.
  18517. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  18518. switch name {
  18519. case labelrelationship.EdgeContacts:
  18520. if id := m.contacts; id != nil {
  18521. return []ent.Value{*id}
  18522. }
  18523. case labelrelationship.EdgeLabels:
  18524. if id := m.labels; id != nil {
  18525. return []ent.Value{*id}
  18526. }
  18527. }
  18528. return nil
  18529. }
  18530. // RemovedEdges returns all edge names that were removed in this mutation.
  18531. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  18532. edges := make([]string, 0, 2)
  18533. return edges
  18534. }
  18535. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18536. // the given name in this mutation.
  18537. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  18538. return nil
  18539. }
  18540. // ClearedEdges returns all edge names that were cleared in this mutation.
  18541. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  18542. edges := make([]string, 0, 2)
  18543. if m.clearedcontacts {
  18544. edges = append(edges, labelrelationship.EdgeContacts)
  18545. }
  18546. if m.clearedlabels {
  18547. edges = append(edges, labelrelationship.EdgeLabels)
  18548. }
  18549. return edges
  18550. }
  18551. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18552. // was cleared in this mutation.
  18553. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  18554. switch name {
  18555. case labelrelationship.EdgeContacts:
  18556. return m.clearedcontacts
  18557. case labelrelationship.EdgeLabels:
  18558. return m.clearedlabels
  18559. }
  18560. return false
  18561. }
  18562. // ClearEdge clears the value of the edge with the given name. It returns an error
  18563. // if that edge is not defined in the schema.
  18564. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  18565. switch name {
  18566. case labelrelationship.EdgeContacts:
  18567. m.ClearContacts()
  18568. return nil
  18569. case labelrelationship.EdgeLabels:
  18570. m.ClearLabels()
  18571. return nil
  18572. }
  18573. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  18574. }
  18575. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18576. // It returns an error if the edge is not defined in the schema.
  18577. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  18578. switch name {
  18579. case labelrelationship.EdgeContacts:
  18580. m.ResetContacts()
  18581. return nil
  18582. case labelrelationship.EdgeLabels:
  18583. m.ResetLabels()
  18584. return nil
  18585. }
  18586. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  18587. }
  18588. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  18589. type LabelTaggingMutation struct {
  18590. config
  18591. op Op
  18592. typ string
  18593. id *uint64
  18594. created_at *time.Time
  18595. updated_at *time.Time
  18596. status *uint8
  18597. addstatus *int8
  18598. deleted_at *time.Time
  18599. organization_id *uint64
  18600. addorganization_id *int64
  18601. _type *int
  18602. add_type *int
  18603. conditions *string
  18604. action_label_add *[]uint64
  18605. appendaction_label_add []uint64
  18606. action_label_del *[]uint64
  18607. appendaction_label_del []uint64
  18608. clearedFields map[string]struct{}
  18609. done bool
  18610. oldValue func(context.Context) (*LabelTagging, error)
  18611. predicates []predicate.LabelTagging
  18612. }
  18613. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  18614. // labeltaggingOption allows management of the mutation configuration using functional options.
  18615. type labeltaggingOption func(*LabelTaggingMutation)
  18616. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  18617. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  18618. m := &LabelTaggingMutation{
  18619. config: c,
  18620. op: op,
  18621. typ: TypeLabelTagging,
  18622. clearedFields: make(map[string]struct{}),
  18623. }
  18624. for _, opt := range opts {
  18625. opt(m)
  18626. }
  18627. return m
  18628. }
  18629. // withLabelTaggingID sets the ID field of the mutation.
  18630. func withLabelTaggingID(id uint64) labeltaggingOption {
  18631. return func(m *LabelTaggingMutation) {
  18632. var (
  18633. err error
  18634. once sync.Once
  18635. value *LabelTagging
  18636. )
  18637. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  18638. once.Do(func() {
  18639. if m.done {
  18640. err = errors.New("querying old values post mutation is not allowed")
  18641. } else {
  18642. value, err = m.Client().LabelTagging.Get(ctx, id)
  18643. }
  18644. })
  18645. return value, err
  18646. }
  18647. m.id = &id
  18648. }
  18649. }
  18650. // withLabelTagging sets the old LabelTagging of the mutation.
  18651. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  18652. return func(m *LabelTaggingMutation) {
  18653. m.oldValue = func(context.Context) (*LabelTagging, error) {
  18654. return node, nil
  18655. }
  18656. m.id = &node.ID
  18657. }
  18658. }
  18659. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18660. // executed in a transaction (ent.Tx), a transactional client is returned.
  18661. func (m LabelTaggingMutation) Client() *Client {
  18662. client := &Client{config: m.config}
  18663. client.init()
  18664. return client
  18665. }
  18666. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18667. // it returns an error otherwise.
  18668. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  18669. if _, ok := m.driver.(*txDriver); !ok {
  18670. return nil, errors.New("ent: mutation is not running in a transaction")
  18671. }
  18672. tx := &Tx{config: m.config}
  18673. tx.init()
  18674. return tx, nil
  18675. }
  18676. // SetID sets the value of the id field. Note that this
  18677. // operation is only accepted on creation of LabelTagging entities.
  18678. func (m *LabelTaggingMutation) SetID(id uint64) {
  18679. m.id = &id
  18680. }
  18681. // ID returns the ID value in the mutation. Note that the ID is only available
  18682. // if it was provided to the builder or after it was returned from the database.
  18683. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  18684. if m.id == nil {
  18685. return
  18686. }
  18687. return *m.id, true
  18688. }
  18689. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18690. // That means, if the mutation is applied within a transaction with an isolation level such
  18691. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18692. // or updated by the mutation.
  18693. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  18694. switch {
  18695. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18696. id, exists := m.ID()
  18697. if exists {
  18698. return []uint64{id}, nil
  18699. }
  18700. fallthrough
  18701. case m.op.Is(OpUpdate | OpDelete):
  18702. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  18703. default:
  18704. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18705. }
  18706. }
  18707. // SetCreatedAt sets the "created_at" field.
  18708. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  18709. m.created_at = &t
  18710. }
  18711. // CreatedAt returns the value of the "created_at" field in the mutation.
  18712. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  18713. v := m.created_at
  18714. if v == nil {
  18715. return
  18716. }
  18717. return *v, true
  18718. }
  18719. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  18720. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18722. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18723. if !m.op.Is(OpUpdateOne) {
  18724. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18725. }
  18726. if m.id == nil || m.oldValue == nil {
  18727. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18728. }
  18729. oldValue, err := m.oldValue(ctx)
  18730. if err != nil {
  18731. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18732. }
  18733. return oldValue.CreatedAt, nil
  18734. }
  18735. // ResetCreatedAt resets all changes to the "created_at" field.
  18736. func (m *LabelTaggingMutation) ResetCreatedAt() {
  18737. m.created_at = nil
  18738. }
  18739. // SetUpdatedAt sets the "updated_at" field.
  18740. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  18741. m.updated_at = &t
  18742. }
  18743. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18744. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  18745. v := m.updated_at
  18746. if v == nil {
  18747. return
  18748. }
  18749. return *v, true
  18750. }
  18751. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  18752. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18754. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18755. if !m.op.Is(OpUpdateOne) {
  18756. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18757. }
  18758. if m.id == nil || m.oldValue == nil {
  18759. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18760. }
  18761. oldValue, err := m.oldValue(ctx)
  18762. if err != nil {
  18763. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18764. }
  18765. return oldValue.UpdatedAt, nil
  18766. }
  18767. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18768. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  18769. m.updated_at = nil
  18770. }
  18771. // SetStatus sets the "status" field.
  18772. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  18773. m.status = &u
  18774. m.addstatus = nil
  18775. }
  18776. // Status returns the value of the "status" field in the mutation.
  18777. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  18778. v := m.status
  18779. if v == nil {
  18780. return
  18781. }
  18782. return *v, true
  18783. }
  18784. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  18785. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18787. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18788. if !m.op.Is(OpUpdateOne) {
  18789. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18790. }
  18791. if m.id == nil || m.oldValue == nil {
  18792. return v, errors.New("OldStatus requires an ID field in the mutation")
  18793. }
  18794. oldValue, err := m.oldValue(ctx)
  18795. if err != nil {
  18796. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18797. }
  18798. return oldValue.Status, nil
  18799. }
  18800. // AddStatus adds u to the "status" field.
  18801. func (m *LabelTaggingMutation) AddStatus(u int8) {
  18802. if m.addstatus != nil {
  18803. *m.addstatus += u
  18804. } else {
  18805. m.addstatus = &u
  18806. }
  18807. }
  18808. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18809. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  18810. v := m.addstatus
  18811. if v == nil {
  18812. return
  18813. }
  18814. return *v, true
  18815. }
  18816. // ClearStatus clears the value of the "status" field.
  18817. func (m *LabelTaggingMutation) ClearStatus() {
  18818. m.status = nil
  18819. m.addstatus = nil
  18820. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  18821. }
  18822. // StatusCleared returns if the "status" field was cleared in this mutation.
  18823. func (m *LabelTaggingMutation) StatusCleared() bool {
  18824. _, ok := m.clearedFields[labeltagging.FieldStatus]
  18825. return ok
  18826. }
  18827. // ResetStatus resets all changes to the "status" field.
  18828. func (m *LabelTaggingMutation) ResetStatus() {
  18829. m.status = nil
  18830. m.addstatus = nil
  18831. delete(m.clearedFields, labeltagging.FieldStatus)
  18832. }
  18833. // SetDeletedAt sets the "deleted_at" field.
  18834. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  18835. m.deleted_at = &t
  18836. }
  18837. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18838. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  18839. v := m.deleted_at
  18840. if v == nil {
  18841. return
  18842. }
  18843. return *v, true
  18844. }
  18845. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  18846. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18848. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18849. if !m.op.Is(OpUpdateOne) {
  18850. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18851. }
  18852. if m.id == nil || m.oldValue == nil {
  18853. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18854. }
  18855. oldValue, err := m.oldValue(ctx)
  18856. if err != nil {
  18857. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18858. }
  18859. return oldValue.DeletedAt, nil
  18860. }
  18861. // ClearDeletedAt clears the value of the "deleted_at" field.
  18862. func (m *LabelTaggingMutation) ClearDeletedAt() {
  18863. m.deleted_at = nil
  18864. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  18865. }
  18866. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18867. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  18868. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  18869. return ok
  18870. }
  18871. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18872. func (m *LabelTaggingMutation) ResetDeletedAt() {
  18873. m.deleted_at = nil
  18874. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  18875. }
  18876. // SetOrganizationID sets the "organization_id" field.
  18877. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  18878. m.organization_id = &u
  18879. m.addorganization_id = nil
  18880. }
  18881. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18882. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  18883. v := m.organization_id
  18884. if v == nil {
  18885. return
  18886. }
  18887. return *v, true
  18888. }
  18889. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  18890. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18892. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18893. if !m.op.Is(OpUpdateOne) {
  18894. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18895. }
  18896. if m.id == nil || m.oldValue == nil {
  18897. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18898. }
  18899. oldValue, err := m.oldValue(ctx)
  18900. if err != nil {
  18901. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18902. }
  18903. return oldValue.OrganizationID, nil
  18904. }
  18905. // AddOrganizationID adds u to the "organization_id" field.
  18906. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  18907. if m.addorganization_id != nil {
  18908. *m.addorganization_id += u
  18909. } else {
  18910. m.addorganization_id = &u
  18911. }
  18912. }
  18913. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18914. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  18915. v := m.addorganization_id
  18916. if v == nil {
  18917. return
  18918. }
  18919. return *v, true
  18920. }
  18921. // ResetOrganizationID resets all changes to the "organization_id" field.
  18922. func (m *LabelTaggingMutation) ResetOrganizationID() {
  18923. m.organization_id = nil
  18924. m.addorganization_id = nil
  18925. }
  18926. // SetType sets the "type" field.
  18927. func (m *LabelTaggingMutation) SetType(i int) {
  18928. m._type = &i
  18929. m.add_type = nil
  18930. }
  18931. // GetType returns the value of the "type" field in the mutation.
  18932. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  18933. v := m._type
  18934. if v == nil {
  18935. return
  18936. }
  18937. return *v, true
  18938. }
  18939. // OldType returns the old "type" field's value of the LabelTagging entity.
  18940. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18942. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  18943. if !m.op.Is(OpUpdateOne) {
  18944. return v, errors.New("OldType is only allowed on UpdateOne operations")
  18945. }
  18946. if m.id == nil || m.oldValue == nil {
  18947. return v, errors.New("OldType requires an ID field in the mutation")
  18948. }
  18949. oldValue, err := m.oldValue(ctx)
  18950. if err != nil {
  18951. return v, fmt.Errorf("querying old value for OldType: %w", err)
  18952. }
  18953. return oldValue.Type, nil
  18954. }
  18955. // AddType adds i to the "type" field.
  18956. func (m *LabelTaggingMutation) AddType(i int) {
  18957. if m.add_type != nil {
  18958. *m.add_type += i
  18959. } else {
  18960. m.add_type = &i
  18961. }
  18962. }
  18963. // AddedType returns the value that was added to the "type" field in this mutation.
  18964. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  18965. v := m.add_type
  18966. if v == nil {
  18967. return
  18968. }
  18969. return *v, true
  18970. }
  18971. // ResetType resets all changes to the "type" field.
  18972. func (m *LabelTaggingMutation) ResetType() {
  18973. m._type = nil
  18974. m.add_type = nil
  18975. }
  18976. // SetConditions sets the "conditions" field.
  18977. func (m *LabelTaggingMutation) SetConditions(s string) {
  18978. m.conditions = &s
  18979. }
  18980. // Conditions returns the value of the "conditions" field in the mutation.
  18981. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  18982. v := m.conditions
  18983. if v == nil {
  18984. return
  18985. }
  18986. return *v, true
  18987. }
  18988. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  18989. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  18990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18991. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  18992. if !m.op.Is(OpUpdateOne) {
  18993. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  18994. }
  18995. if m.id == nil || m.oldValue == nil {
  18996. return v, errors.New("OldConditions requires an ID field in the mutation")
  18997. }
  18998. oldValue, err := m.oldValue(ctx)
  18999. if err != nil {
  19000. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  19001. }
  19002. return oldValue.Conditions, nil
  19003. }
  19004. // ResetConditions resets all changes to the "conditions" field.
  19005. func (m *LabelTaggingMutation) ResetConditions() {
  19006. m.conditions = nil
  19007. }
  19008. // SetActionLabelAdd sets the "action_label_add" field.
  19009. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  19010. m.action_label_add = &u
  19011. m.appendaction_label_add = nil
  19012. }
  19013. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19014. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19015. v := m.action_label_add
  19016. if v == nil {
  19017. return
  19018. }
  19019. return *v, true
  19020. }
  19021. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  19022. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19024. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19025. if !m.op.Is(OpUpdateOne) {
  19026. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19027. }
  19028. if m.id == nil || m.oldValue == nil {
  19029. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19030. }
  19031. oldValue, err := m.oldValue(ctx)
  19032. if err != nil {
  19033. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19034. }
  19035. return oldValue.ActionLabelAdd, nil
  19036. }
  19037. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19038. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  19039. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19040. }
  19041. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19042. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19043. if len(m.appendaction_label_add) == 0 {
  19044. return nil, false
  19045. }
  19046. return m.appendaction_label_add, true
  19047. }
  19048. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19049. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  19050. m.action_label_add = nil
  19051. m.appendaction_label_add = nil
  19052. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  19053. }
  19054. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19055. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  19056. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  19057. return ok
  19058. }
  19059. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19060. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  19061. m.action_label_add = nil
  19062. m.appendaction_label_add = nil
  19063. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  19064. }
  19065. // SetActionLabelDel sets the "action_label_del" field.
  19066. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  19067. m.action_label_del = &u
  19068. m.appendaction_label_del = nil
  19069. }
  19070. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19071. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  19072. v := m.action_label_del
  19073. if v == nil {
  19074. return
  19075. }
  19076. return *v, true
  19077. }
  19078. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  19079. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  19080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19081. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19082. if !m.op.Is(OpUpdateOne) {
  19083. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19084. }
  19085. if m.id == nil || m.oldValue == nil {
  19086. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19087. }
  19088. oldValue, err := m.oldValue(ctx)
  19089. if err != nil {
  19090. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19091. }
  19092. return oldValue.ActionLabelDel, nil
  19093. }
  19094. // AppendActionLabelDel adds u to the "action_label_del" field.
  19095. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  19096. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19097. }
  19098. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19099. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19100. if len(m.appendaction_label_del) == 0 {
  19101. return nil, false
  19102. }
  19103. return m.appendaction_label_del, true
  19104. }
  19105. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19106. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  19107. m.action_label_del = nil
  19108. m.appendaction_label_del = nil
  19109. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  19110. }
  19111. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19112. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  19113. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  19114. return ok
  19115. }
  19116. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19117. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  19118. m.action_label_del = nil
  19119. m.appendaction_label_del = nil
  19120. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  19121. }
  19122. // Where appends a list predicates to the LabelTaggingMutation builder.
  19123. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  19124. m.predicates = append(m.predicates, ps...)
  19125. }
  19126. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  19127. // users can use type-assertion to append predicates that do not depend on any generated package.
  19128. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  19129. p := make([]predicate.LabelTagging, len(ps))
  19130. for i := range ps {
  19131. p[i] = ps[i]
  19132. }
  19133. m.Where(p...)
  19134. }
  19135. // Op returns the operation name.
  19136. func (m *LabelTaggingMutation) Op() Op {
  19137. return m.op
  19138. }
  19139. // SetOp allows setting the mutation operation.
  19140. func (m *LabelTaggingMutation) SetOp(op Op) {
  19141. m.op = op
  19142. }
  19143. // Type returns the node type of this mutation (LabelTagging).
  19144. func (m *LabelTaggingMutation) Type() string {
  19145. return m.typ
  19146. }
  19147. // Fields returns all fields that were changed during this mutation. Note that in
  19148. // order to get all numeric fields that were incremented/decremented, call
  19149. // AddedFields().
  19150. func (m *LabelTaggingMutation) Fields() []string {
  19151. fields := make([]string, 0, 9)
  19152. if m.created_at != nil {
  19153. fields = append(fields, labeltagging.FieldCreatedAt)
  19154. }
  19155. if m.updated_at != nil {
  19156. fields = append(fields, labeltagging.FieldUpdatedAt)
  19157. }
  19158. if m.status != nil {
  19159. fields = append(fields, labeltagging.FieldStatus)
  19160. }
  19161. if m.deleted_at != nil {
  19162. fields = append(fields, labeltagging.FieldDeletedAt)
  19163. }
  19164. if m.organization_id != nil {
  19165. fields = append(fields, labeltagging.FieldOrganizationID)
  19166. }
  19167. if m._type != nil {
  19168. fields = append(fields, labeltagging.FieldType)
  19169. }
  19170. if m.conditions != nil {
  19171. fields = append(fields, labeltagging.FieldConditions)
  19172. }
  19173. if m.action_label_add != nil {
  19174. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19175. }
  19176. if m.action_label_del != nil {
  19177. fields = append(fields, labeltagging.FieldActionLabelDel)
  19178. }
  19179. return fields
  19180. }
  19181. // Field returns the value of a field with the given name. The second boolean
  19182. // return value indicates that this field was not set, or was not defined in the
  19183. // schema.
  19184. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  19185. switch name {
  19186. case labeltagging.FieldCreatedAt:
  19187. return m.CreatedAt()
  19188. case labeltagging.FieldUpdatedAt:
  19189. return m.UpdatedAt()
  19190. case labeltagging.FieldStatus:
  19191. return m.Status()
  19192. case labeltagging.FieldDeletedAt:
  19193. return m.DeletedAt()
  19194. case labeltagging.FieldOrganizationID:
  19195. return m.OrganizationID()
  19196. case labeltagging.FieldType:
  19197. return m.GetType()
  19198. case labeltagging.FieldConditions:
  19199. return m.Conditions()
  19200. case labeltagging.FieldActionLabelAdd:
  19201. return m.ActionLabelAdd()
  19202. case labeltagging.FieldActionLabelDel:
  19203. return m.ActionLabelDel()
  19204. }
  19205. return nil, false
  19206. }
  19207. // OldField returns the old value of the field from the database. An error is
  19208. // returned if the mutation operation is not UpdateOne, or the query to the
  19209. // database failed.
  19210. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19211. switch name {
  19212. case labeltagging.FieldCreatedAt:
  19213. return m.OldCreatedAt(ctx)
  19214. case labeltagging.FieldUpdatedAt:
  19215. return m.OldUpdatedAt(ctx)
  19216. case labeltagging.FieldStatus:
  19217. return m.OldStatus(ctx)
  19218. case labeltagging.FieldDeletedAt:
  19219. return m.OldDeletedAt(ctx)
  19220. case labeltagging.FieldOrganizationID:
  19221. return m.OldOrganizationID(ctx)
  19222. case labeltagging.FieldType:
  19223. return m.OldType(ctx)
  19224. case labeltagging.FieldConditions:
  19225. return m.OldConditions(ctx)
  19226. case labeltagging.FieldActionLabelAdd:
  19227. return m.OldActionLabelAdd(ctx)
  19228. case labeltagging.FieldActionLabelDel:
  19229. return m.OldActionLabelDel(ctx)
  19230. }
  19231. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  19232. }
  19233. // SetField sets the value of a field with the given name. It returns an error if
  19234. // the field is not defined in the schema, or if the type mismatched the field
  19235. // type.
  19236. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  19237. switch name {
  19238. case labeltagging.FieldCreatedAt:
  19239. v, ok := value.(time.Time)
  19240. if !ok {
  19241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19242. }
  19243. m.SetCreatedAt(v)
  19244. return nil
  19245. case labeltagging.FieldUpdatedAt:
  19246. v, ok := value.(time.Time)
  19247. if !ok {
  19248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19249. }
  19250. m.SetUpdatedAt(v)
  19251. return nil
  19252. case labeltagging.FieldStatus:
  19253. v, ok := value.(uint8)
  19254. if !ok {
  19255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19256. }
  19257. m.SetStatus(v)
  19258. return nil
  19259. case labeltagging.FieldDeletedAt:
  19260. v, ok := value.(time.Time)
  19261. if !ok {
  19262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19263. }
  19264. m.SetDeletedAt(v)
  19265. return nil
  19266. case labeltagging.FieldOrganizationID:
  19267. v, ok := value.(uint64)
  19268. if !ok {
  19269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19270. }
  19271. m.SetOrganizationID(v)
  19272. return nil
  19273. case labeltagging.FieldType:
  19274. v, ok := value.(int)
  19275. if !ok {
  19276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19277. }
  19278. m.SetType(v)
  19279. return nil
  19280. case labeltagging.FieldConditions:
  19281. v, ok := value.(string)
  19282. if !ok {
  19283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19284. }
  19285. m.SetConditions(v)
  19286. return nil
  19287. case labeltagging.FieldActionLabelAdd:
  19288. v, ok := value.([]uint64)
  19289. if !ok {
  19290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19291. }
  19292. m.SetActionLabelAdd(v)
  19293. return nil
  19294. case labeltagging.FieldActionLabelDel:
  19295. v, ok := value.([]uint64)
  19296. if !ok {
  19297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19298. }
  19299. m.SetActionLabelDel(v)
  19300. return nil
  19301. }
  19302. return fmt.Errorf("unknown LabelTagging field %s", name)
  19303. }
  19304. // AddedFields returns all numeric fields that were incremented/decremented during
  19305. // this mutation.
  19306. func (m *LabelTaggingMutation) AddedFields() []string {
  19307. var fields []string
  19308. if m.addstatus != nil {
  19309. fields = append(fields, labeltagging.FieldStatus)
  19310. }
  19311. if m.addorganization_id != nil {
  19312. fields = append(fields, labeltagging.FieldOrganizationID)
  19313. }
  19314. if m.add_type != nil {
  19315. fields = append(fields, labeltagging.FieldType)
  19316. }
  19317. return fields
  19318. }
  19319. // AddedField returns the numeric value that was incremented/decremented on a field
  19320. // with the given name. The second boolean return value indicates that this field
  19321. // was not set, or was not defined in the schema.
  19322. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  19323. switch name {
  19324. case labeltagging.FieldStatus:
  19325. return m.AddedStatus()
  19326. case labeltagging.FieldOrganizationID:
  19327. return m.AddedOrganizationID()
  19328. case labeltagging.FieldType:
  19329. return m.AddedType()
  19330. }
  19331. return nil, false
  19332. }
  19333. // AddField adds the value to the field with the given name. It returns an error if
  19334. // the field is not defined in the schema, or if the type mismatched the field
  19335. // type.
  19336. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  19337. switch name {
  19338. case labeltagging.FieldStatus:
  19339. v, ok := value.(int8)
  19340. if !ok {
  19341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19342. }
  19343. m.AddStatus(v)
  19344. return nil
  19345. case labeltagging.FieldOrganizationID:
  19346. v, ok := value.(int64)
  19347. if !ok {
  19348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19349. }
  19350. m.AddOrganizationID(v)
  19351. return nil
  19352. case labeltagging.FieldType:
  19353. v, ok := value.(int)
  19354. if !ok {
  19355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19356. }
  19357. m.AddType(v)
  19358. return nil
  19359. }
  19360. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  19361. }
  19362. // ClearedFields returns all nullable fields that were cleared during this
  19363. // mutation.
  19364. func (m *LabelTaggingMutation) ClearedFields() []string {
  19365. var fields []string
  19366. if m.FieldCleared(labeltagging.FieldStatus) {
  19367. fields = append(fields, labeltagging.FieldStatus)
  19368. }
  19369. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  19370. fields = append(fields, labeltagging.FieldDeletedAt)
  19371. }
  19372. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  19373. fields = append(fields, labeltagging.FieldActionLabelAdd)
  19374. }
  19375. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  19376. fields = append(fields, labeltagging.FieldActionLabelDel)
  19377. }
  19378. return fields
  19379. }
  19380. // FieldCleared returns a boolean indicating if a field with the given name was
  19381. // cleared in this mutation.
  19382. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  19383. _, ok := m.clearedFields[name]
  19384. return ok
  19385. }
  19386. // ClearField clears the value of the field with the given name. It returns an
  19387. // error if the field is not defined in the schema.
  19388. func (m *LabelTaggingMutation) ClearField(name string) error {
  19389. switch name {
  19390. case labeltagging.FieldStatus:
  19391. m.ClearStatus()
  19392. return nil
  19393. case labeltagging.FieldDeletedAt:
  19394. m.ClearDeletedAt()
  19395. return nil
  19396. case labeltagging.FieldActionLabelAdd:
  19397. m.ClearActionLabelAdd()
  19398. return nil
  19399. case labeltagging.FieldActionLabelDel:
  19400. m.ClearActionLabelDel()
  19401. return nil
  19402. }
  19403. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  19404. }
  19405. // ResetField resets all changes in the mutation for the field with the given name.
  19406. // It returns an error if the field is not defined in the schema.
  19407. func (m *LabelTaggingMutation) ResetField(name string) error {
  19408. switch name {
  19409. case labeltagging.FieldCreatedAt:
  19410. m.ResetCreatedAt()
  19411. return nil
  19412. case labeltagging.FieldUpdatedAt:
  19413. m.ResetUpdatedAt()
  19414. return nil
  19415. case labeltagging.FieldStatus:
  19416. m.ResetStatus()
  19417. return nil
  19418. case labeltagging.FieldDeletedAt:
  19419. m.ResetDeletedAt()
  19420. return nil
  19421. case labeltagging.FieldOrganizationID:
  19422. m.ResetOrganizationID()
  19423. return nil
  19424. case labeltagging.FieldType:
  19425. m.ResetType()
  19426. return nil
  19427. case labeltagging.FieldConditions:
  19428. m.ResetConditions()
  19429. return nil
  19430. case labeltagging.FieldActionLabelAdd:
  19431. m.ResetActionLabelAdd()
  19432. return nil
  19433. case labeltagging.FieldActionLabelDel:
  19434. m.ResetActionLabelDel()
  19435. return nil
  19436. }
  19437. return fmt.Errorf("unknown LabelTagging field %s", name)
  19438. }
  19439. // AddedEdges returns all edge names that were set/added in this mutation.
  19440. func (m *LabelTaggingMutation) AddedEdges() []string {
  19441. edges := make([]string, 0, 0)
  19442. return edges
  19443. }
  19444. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19445. // name in this mutation.
  19446. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  19447. return nil
  19448. }
  19449. // RemovedEdges returns all edge names that were removed in this mutation.
  19450. func (m *LabelTaggingMutation) RemovedEdges() []string {
  19451. edges := make([]string, 0, 0)
  19452. return edges
  19453. }
  19454. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19455. // the given name in this mutation.
  19456. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  19457. return nil
  19458. }
  19459. // ClearedEdges returns all edge names that were cleared in this mutation.
  19460. func (m *LabelTaggingMutation) ClearedEdges() []string {
  19461. edges := make([]string, 0, 0)
  19462. return edges
  19463. }
  19464. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19465. // was cleared in this mutation.
  19466. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  19467. return false
  19468. }
  19469. // ClearEdge clears the value of the edge with the given name. It returns an error
  19470. // if that edge is not defined in the schema.
  19471. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  19472. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  19473. }
  19474. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19475. // It returns an error if the edge is not defined in the schema.
  19476. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  19477. return fmt.Errorf("unknown LabelTagging edge %s", name)
  19478. }
  19479. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  19480. type MessageMutation struct {
  19481. config
  19482. op Op
  19483. typ string
  19484. id *int
  19485. wx_wxid *string
  19486. wxid *string
  19487. content *string
  19488. clearedFields map[string]struct{}
  19489. done bool
  19490. oldValue func(context.Context) (*Message, error)
  19491. predicates []predicate.Message
  19492. }
  19493. var _ ent.Mutation = (*MessageMutation)(nil)
  19494. // messageOption allows management of the mutation configuration using functional options.
  19495. type messageOption func(*MessageMutation)
  19496. // newMessageMutation creates new mutation for the Message entity.
  19497. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  19498. m := &MessageMutation{
  19499. config: c,
  19500. op: op,
  19501. typ: TypeMessage,
  19502. clearedFields: make(map[string]struct{}),
  19503. }
  19504. for _, opt := range opts {
  19505. opt(m)
  19506. }
  19507. return m
  19508. }
  19509. // withMessageID sets the ID field of the mutation.
  19510. func withMessageID(id int) messageOption {
  19511. return func(m *MessageMutation) {
  19512. var (
  19513. err error
  19514. once sync.Once
  19515. value *Message
  19516. )
  19517. m.oldValue = func(ctx context.Context) (*Message, error) {
  19518. once.Do(func() {
  19519. if m.done {
  19520. err = errors.New("querying old values post mutation is not allowed")
  19521. } else {
  19522. value, err = m.Client().Message.Get(ctx, id)
  19523. }
  19524. })
  19525. return value, err
  19526. }
  19527. m.id = &id
  19528. }
  19529. }
  19530. // withMessage sets the old Message of the mutation.
  19531. func withMessage(node *Message) messageOption {
  19532. return func(m *MessageMutation) {
  19533. m.oldValue = func(context.Context) (*Message, error) {
  19534. return node, nil
  19535. }
  19536. m.id = &node.ID
  19537. }
  19538. }
  19539. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19540. // executed in a transaction (ent.Tx), a transactional client is returned.
  19541. func (m MessageMutation) Client() *Client {
  19542. client := &Client{config: m.config}
  19543. client.init()
  19544. return client
  19545. }
  19546. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19547. // it returns an error otherwise.
  19548. func (m MessageMutation) Tx() (*Tx, error) {
  19549. if _, ok := m.driver.(*txDriver); !ok {
  19550. return nil, errors.New("ent: mutation is not running in a transaction")
  19551. }
  19552. tx := &Tx{config: m.config}
  19553. tx.init()
  19554. return tx, nil
  19555. }
  19556. // ID returns the ID value in the mutation. Note that the ID is only available
  19557. // if it was provided to the builder or after it was returned from the database.
  19558. func (m *MessageMutation) ID() (id int, exists bool) {
  19559. if m.id == nil {
  19560. return
  19561. }
  19562. return *m.id, true
  19563. }
  19564. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19565. // That means, if the mutation is applied within a transaction with an isolation level such
  19566. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19567. // or updated by the mutation.
  19568. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  19569. switch {
  19570. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19571. id, exists := m.ID()
  19572. if exists {
  19573. return []int{id}, nil
  19574. }
  19575. fallthrough
  19576. case m.op.Is(OpUpdate | OpDelete):
  19577. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  19578. default:
  19579. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19580. }
  19581. }
  19582. // SetWxWxid sets the "wx_wxid" field.
  19583. func (m *MessageMutation) SetWxWxid(s string) {
  19584. m.wx_wxid = &s
  19585. }
  19586. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  19587. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  19588. v := m.wx_wxid
  19589. if v == nil {
  19590. return
  19591. }
  19592. return *v, true
  19593. }
  19594. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  19595. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  19596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19597. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  19598. if !m.op.Is(OpUpdateOne) {
  19599. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  19600. }
  19601. if m.id == nil || m.oldValue == nil {
  19602. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  19603. }
  19604. oldValue, err := m.oldValue(ctx)
  19605. if err != nil {
  19606. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  19607. }
  19608. return oldValue.WxWxid, nil
  19609. }
  19610. // ClearWxWxid clears the value of the "wx_wxid" field.
  19611. func (m *MessageMutation) ClearWxWxid() {
  19612. m.wx_wxid = nil
  19613. m.clearedFields[message.FieldWxWxid] = struct{}{}
  19614. }
  19615. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  19616. func (m *MessageMutation) WxWxidCleared() bool {
  19617. _, ok := m.clearedFields[message.FieldWxWxid]
  19618. return ok
  19619. }
  19620. // ResetWxWxid resets all changes to the "wx_wxid" field.
  19621. func (m *MessageMutation) ResetWxWxid() {
  19622. m.wx_wxid = nil
  19623. delete(m.clearedFields, message.FieldWxWxid)
  19624. }
  19625. // SetWxid sets the "wxid" field.
  19626. func (m *MessageMutation) SetWxid(s string) {
  19627. m.wxid = &s
  19628. }
  19629. // Wxid returns the value of the "wxid" field in the mutation.
  19630. func (m *MessageMutation) Wxid() (r string, exists bool) {
  19631. v := m.wxid
  19632. if v == nil {
  19633. return
  19634. }
  19635. return *v, true
  19636. }
  19637. // OldWxid returns the old "wxid" field's value of the Message entity.
  19638. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  19639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19640. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  19641. if !m.op.Is(OpUpdateOne) {
  19642. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  19643. }
  19644. if m.id == nil || m.oldValue == nil {
  19645. return v, errors.New("OldWxid requires an ID field in the mutation")
  19646. }
  19647. oldValue, err := m.oldValue(ctx)
  19648. if err != nil {
  19649. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  19650. }
  19651. return oldValue.Wxid, nil
  19652. }
  19653. // ResetWxid resets all changes to the "wxid" field.
  19654. func (m *MessageMutation) ResetWxid() {
  19655. m.wxid = nil
  19656. }
  19657. // SetContent sets the "content" field.
  19658. func (m *MessageMutation) SetContent(s string) {
  19659. m.content = &s
  19660. }
  19661. // Content returns the value of the "content" field in the mutation.
  19662. func (m *MessageMutation) Content() (r string, exists bool) {
  19663. v := m.content
  19664. if v == nil {
  19665. return
  19666. }
  19667. return *v, true
  19668. }
  19669. // OldContent returns the old "content" field's value of the Message entity.
  19670. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  19671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19672. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  19673. if !m.op.Is(OpUpdateOne) {
  19674. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  19675. }
  19676. if m.id == nil || m.oldValue == nil {
  19677. return v, errors.New("OldContent requires an ID field in the mutation")
  19678. }
  19679. oldValue, err := m.oldValue(ctx)
  19680. if err != nil {
  19681. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  19682. }
  19683. return oldValue.Content, nil
  19684. }
  19685. // ResetContent resets all changes to the "content" field.
  19686. func (m *MessageMutation) ResetContent() {
  19687. m.content = nil
  19688. }
  19689. // Where appends a list predicates to the MessageMutation builder.
  19690. func (m *MessageMutation) Where(ps ...predicate.Message) {
  19691. m.predicates = append(m.predicates, ps...)
  19692. }
  19693. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  19694. // users can use type-assertion to append predicates that do not depend on any generated package.
  19695. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  19696. p := make([]predicate.Message, len(ps))
  19697. for i := range ps {
  19698. p[i] = ps[i]
  19699. }
  19700. m.Where(p...)
  19701. }
  19702. // Op returns the operation name.
  19703. func (m *MessageMutation) Op() Op {
  19704. return m.op
  19705. }
  19706. // SetOp allows setting the mutation operation.
  19707. func (m *MessageMutation) SetOp(op Op) {
  19708. m.op = op
  19709. }
  19710. // Type returns the node type of this mutation (Message).
  19711. func (m *MessageMutation) Type() string {
  19712. return m.typ
  19713. }
  19714. // Fields returns all fields that were changed during this mutation. Note that in
  19715. // order to get all numeric fields that were incremented/decremented, call
  19716. // AddedFields().
  19717. func (m *MessageMutation) Fields() []string {
  19718. fields := make([]string, 0, 3)
  19719. if m.wx_wxid != nil {
  19720. fields = append(fields, message.FieldWxWxid)
  19721. }
  19722. if m.wxid != nil {
  19723. fields = append(fields, message.FieldWxid)
  19724. }
  19725. if m.content != nil {
  19726. fields = append(fields, message.FieldContent)
  19727. }
  19728. return fields
  19729. }
  19730. // Field returns the value of a field with the given name. The second boolean
  19731. // return value indicates that this field was not set, or was not defined in the
  19732. // schema.
  19733. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  19734. switch name {
  19735. case message.FieldWxWxid:
  19736. return m.WxWxid()
  19737. case message.FieldWxid:
  19738. return m.Wxid()
  19739. case message.FieldContent:
  19740. return m.Content()
  19741. }
  19742. return nil, false
  19743. }
  19744. // OldField returns the old value of the field from the database. An error is
  19745. // returned if the mutation operation is not UpdateOne, or the query to the
  19746. // database failed.
  19747. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19748. switch name {
  19749. case message.FieldWxWxid:
  19750. return m.OldWxWxid(ctx)
  19751. case message.FieldWxid:
  19752. return m.OldWxid(ctx)
  19753. case message.FieldContent:
  19754. return m.OldContent(ctx)
  19755. }
  19756. return nil, fmt.Errorf("unknown Message field %s", name)
  19757. }
  19758. // SetField sets the value of a field with the given name. It returns an error if
  19759. // the field is not defined in the schema, or if the type mismatched the field
  19760. // type.
  19761. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  19762. switch name {
  19763. case message.FieldWxWxid:
  19764. v, ok := value.(string)
  19765. if !ok {
  19766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19767. }
  19768. m.SetWxWxid(v)
  19769. return nil
  19770. case message.FieldWxid:
  19771. v, ok := value.(string)
  19772. if !ok {
  19773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19774. }
  19775. m.SetWxid(v)
  19776. return nil
  19777. case message.FieldContent:
  19778. v, ok := value.(string)
  19779. if !ok {
  19780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19781. }
  19782. m.SetContent(v)
  19783. return nil
  19784. }
  19785. return fmt.Errorf("unknown Message field %s", name)
  19786. }
  19787. // AddedFields returns all numeric fields that were incremented/decremented during
  19788. // this mutation.
  19789. func (m *MessageMutation) AddedFields() []string {
  19790. return nil
  19791. }
  19792. // AddedField returns the numeric value that was incremented/decremented on a field
  19793. // with the given name. The second boolean return value indicates that this field
  19794. // was not set, or was not defined in the schema.
  19795. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  19796. return nil, false
  19797. }
  19798. // AddField adds the value to the field with the given name. It returns an error if
  19799. // the field is not defined in the schema, or if the type mismatched the field
  19800. // type.
  19801. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  19802. switch name {
  19803. }
  19804. return fmt.Errorf("unknown Message numeric field %s", name)
  19805. }
  19806. // ClearedFields returns all nullable fields that were cleared during this
  19807. // mutation.
  19808. func (m *MessageMutation) ClearedFields() []string {
  19809. var fields []string
  19810. if m.FieldCleared(message.FieldWxWxid) {
  19811. fields = append(fields, message.FieldWxWxid)
  19812. }
  19813. return fields
  19814. }
  19815. // FieldCleared returns a boolean indicating if a field with the given name was
  19816. // cleared in this mutation.
  19817. func (m *MessageMutation) FieldCleared(name string) bool {
  19818. _, ok := m.clearedFields[name]
  19819. return ok
  19820. }
  19821. // ClearField clears the value of the field with the given name. It returns an
  19822. // error if the field is not defined in the schema.
  19823. func (m *MessageMutation) ClearField(name string) error {
  19824. switch name {
  19825. case message.FieldWxWxid:
  19826. m.ClearWxWxid()
  19827. return nil
  19828. }
  19829. return fmt.Errorf("unknown Message nullable field %s", name)
  19830. }
  19831. // ResetField resets all changes in the mutation for the field with the given name.
  19832. // It returns an error if the field is not defined in the schema.
  19833. func (m *MessageMutation) ResetField(name string) error {
  19834. switch name {
  19835. case message.FieldWxWxid:
  19836. m.ResetWxWxid()
  19837. return nil
  19838. case message.FieldWxid:
  19839. m.ResetWxid()
  19840. return nil
  19841. case message.FieldContent:
  19842. m.ResetContent()
  19843. return nil
  19844. }
  19845. return fmt.Errorf("unknown Message field %s", name)
  19846. }
  19847. // AddedEdges returns all edge names that were set/added in this mutation.
  19848. func (m *MessageMutation) AddedEdges() []string {
  19849. edges := make([]string, 0, 0)
  19850. return edges
  19851. }
  19852. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19853. // name in this mutation.
  19854. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  19855. return nil
  19856. }
  19857. // RemovedEdges returns all edge names that were removed in this mutation.
  19858. func (m *MessageMutation) RemovedEdges() []string {
  19859. edges := make([]string, 0, 0)
  19860. return edges
  19861. }
  19862. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19863. // the given name in this mutation.
  19864. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  19865. return nil
  19866. }
  19867. // ClearedEdges returns all edge names that were cleared in this mutation.
  19868. func (m *MessageMutation) ClearedEdges() []string {
  19869. edges := make([]string, 0, 0)
  19870. return edges
  19871. }
  19872. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19873. // was cleared in this mutation.
  19874. func (m *MessageMutation) EdgeCleared(name string) bool {
  19875. return false
  19876. }
  19877. // ClearEdge clears the value of the edge with the given name. It returns an error
  19878. // if that edge is not defined in the schema.
  19879. func (m *MessageMutation) ClearEdge(name string) error {
  19880. return fmt.Errorf("unknown Message unique edge %s", name)
  19881. }
  19882. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19883. // It returns an error if the edge is not defined in the schema.
  19884. func (m *MessageMutation) ResetEdge(name string) error {
  19885. return fmt.Errorf("unknown Message edge %s", name)
  19886. }
  19887. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  19888. type MessageRecordsMutation struct {
  19889. config
  19890. op Op
  19891. typ string
  19892. id *uint64
  19893. created_at *time.Time
  19894. updated_at *time.Time
  19895. status *uint8
  19896. addstatus *int8
  19897. bot_wxid *string
  19898. contact_type *int
  19899. addcontact_type *int
  19900. contact_wxid *string
  19901. content_type *int
  19902. addcontent_type *int
  19903. content *string
  19904. meta *custom_types.Meta
  19905. error_detail *string
  19906. send_time *time.Time
  19907. source_type *int
  19908. addsource_type *int
  19909. organization_id *uint64
  19910. addorganization_id *int64
  19911. clearedFields map[string]struct{}
  19912. sop_stage *uint64
  19913. clearedsop_stage bool
  19914. sop_node *uint64
  19915. clearedsop_node bool
  19916. message_contact *uint64
  19917. clearedmessage_contact bool
  19918. done bool
  19919. oldValue func(context.Context) (*MessageRecords, error)
  19920. predicates []predicate.MessageRecords
  19921. }
  19922. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  19923. // messagerecordsOption allows management of the mutation configuration using functional options.
  19924. type messagerecordsOption func(*MessageRecordsMutation)
  19925. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  19926. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  19927. m := &MessageRecordsMutation{
  19928. config: c,
  19929. op: op,
  19930. typ: TypeMessageRecords,
  19931. clearedFields: make(map[string]struct{}),
  19932. }
  19933. for _, opt := range opts {
  19934. opt(m)
  19935. }
  19936. return m
  19937. }
  19938. // withMessageRecordsID sets the ID field of the mutation.
  19939. func withMessageRecordsID(id uint64) messagerecordsOption {
  19940. return func(m *MessageRecordsMutation) {
  19941. var (
  19942. err error
  19943. once sync.Once
  19944. value *MessageRecords
  19945. )
  19946. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  19947. once.Do(func() {
  19948. if m.done {
  19949. err = errors.New("querying old values post mutation is not allowed")
  19950. } else {
  19951. value, err = m.Client().MessageRecords.Get(ctx, id)
  19952. }
  19953. })
  19954. return value, err
  19955. }
  19956. m.id = &id
  19957. }
  19958. }
  19959. // withMessageRecords sets the old MessageRecords of the mutation.
  19960. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  19961. return func(m *MessageRecordsMutation) {
  19962. m.oldValue = func(context.Context) (*MessageRecords, error) {
  19963. return node, nil
  19964. }
  19965. m.id = &node.ID
  19966. }
  19967. }
  19968. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19969. // executed in a transaction (ent.Tx), a transactional client is returned.
  19970. func (m MessageRecordsMutation) Client() *Client {
  19971. client := &Client{config: m.config}
  19972. client.init()
  19973. return client
  19974. }
  19975. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19976. // it returns an error otherwise.
  19977. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  19978. if _, ok := m.driver.(*txDriver); !ok {
  19979. return nil, errors.New("ent: mutation is not running in a transaction")
  19980. }
  19981. tx := &Tx{config: m.config}
  19982. tx.init()
  19983. return tx, nil
  19984. }
  19985. // SetID sets the value of the id field. Note that this
  19986. // operation is only accepted on creation of MessageRecords entities.
  19987. func (m *MessageRecordsMutation) SetID(id uint64) {
  19988. m.id = &id
  19989. }
  19990. // ID returns the ID value in the mutation. Note that the ID is only available
  19991. // if it was provided to the builder or after it was returned from the database.
  19992. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  19993. if m.id == nil {
  19994. return
  19995. }
  19996. return *m.id, true
  19997. }
  19998. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19999. // That means, if the mutation is applied within a transaction with an isolation level such
  20000. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20001. // or updated by the mutation.
  20002. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  20003. switch {
  20004. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20005. id, exists := m.ID()
  20006. if exists {
  20007. return []uint64{id}, nil
  20008. }
  20009. fallthrough
  20010. case m.op.Is(OpUpdate | OpDelete):
  20011. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  20012. default:
  20013. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20014. }
  20015. }
  20016. // SetCreatedAt sets the "created_at" field.
  20017. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  20018. m.created_at = &t
  20019. }
  20020. // CreatedAt returns the value of the "created_at" field in the mutation.
  20021. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  20022. v := m.created_at
  20023. if v == nil {
  20024. return
  20025. }
  20026. return *v, true
  20027. }
  20028. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  20029. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20031. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20032. if !m.op.Is(OpUpdateOne) {
  20033. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20034. }
  20035. if m.id == nil || m.oldValue == nil {
  20036. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20037. }
  20038. oldValue, err := m.oldValue(ctx)
  20039. if err != nil {
  20040. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20041. }
  20042. return oldValue.CreatedAt, nil
  20043. }
  20044. // ResetCreatedAt resets all changes to the "created_at" field.
  20045. func (m *MessageRecordsMutation) ResetCreatedAt() {
  20046. m.created_at = nil
  20047. }
  20048. // SetUpdatedAt sets the "updated_at" field.
  20049. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  20050. m.updated_at = &t
  20051. }
  20052. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20053. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  20054. v := m.updated_at
  20055. if v == nil {
  20056. return
  20057. }
  20058. return *v, true
  20059. }
  20060. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  20061. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20063. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20064. if !m.op.Is(OpUpdateOne) {
  20065. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20066. }
  20067. if m.id == nil || m.oldValue == nil {
  20068. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20069. }
  20070. oldValue, err := m.oldValue(ctx)
  20071. if err != nil {
  20072. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20073. }
  20074. return oldValue.UpdatedAt, nil
  20075. }
  20076. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20077. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  20078. m.updated_at = nil
  20079. }
  20080. // SetStatus sets the "status" field.
  20081. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  20082. m.status = &u
  20083. m.addstatus = nil
  20084. }
  20085. // Status returns the value of the "status" field in the mutation.
  20086. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  20087. v := m.status
  20088. if v == nil {
  20089. return
  20090. }
  20091. return *v, true
  20092. }
  20093. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  20094. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20096. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20097. if !m.op.Is(OpUpdateOne) {
  20098. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20099. }
  20100. if m.id == nil || m.oldValue == nil {
  20101. return v, errors.New("OldStatus requires an ID field in the mutation")
  20102. }
  20103. oldValue, err := m.oldValue(ctx)
  20104. if err != nil {
  20105. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20106. }
  20107. return oldValue.Status, nil
  20108. }
  20109. // AddStatus adds u to the "status" field.
  20110. func (m *MessageRecordsMutation) AddStatus(u int8) {
  20111. if m.addstatus != nil {
  20112. *m.addstatus += u
  20113. } else {
  20114. m.addstatus = &u
  20115. }
  20116. }
  20117. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20118. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  20119. v := m.addstatus
  20120. if v == nil {
  20121. return
  20122. }
  20123. return *v, true
  20124. }
  20125. // ClearStatus clears the value of the "status" field.
  20126. func (m *MessageRecordsMutation) ClearStatus() {
  20127. m.status = nil
  20128. m.addstatus = nil
  20129. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  20130. }
  20131. // StatusCleared returns if the "status" field was cleared in this mutation.
  20132. func (m *MessageRecordsMutation) StatusCleared() bool {
  20133. _, ok := m.clearedFields[messagerecords.FieldStatus]
  20134. return ok
  20135. }
  20136. // ResetStatus resets all changes to the "status" field.
  20137. func (m *MessageRecordsMutation) ResetStatus() {
  20138. m.status = nil
  20139. m.addstatus = nil
  20140. delete(m.clearedFields, messagerecords.FieldStatus)
  20141. }
  20142. // SetBotWxid sets the "bot_wxid" field.
  20143. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  20144. m.bot_wxid = &s
  20145. }
  20146. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  20147. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  20148. v := m.bot_wxid
  20149. if v == nil {
  20150. return
  20151. }
  20152. return *v, true
  20153. }
  20154. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  20155. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20157. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  20158. if !m.op.Is(OpUpdateOne) {
  20159. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  20160. }
  20161. if m.id == nil || m.oldValue == nil {
  20162. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  20163. }
  20164. oldValue, err := m.oldValue(ctx)
  20165. if err != nil {
  20166. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  20167. }
  20168. return oldValue.BotWxid, nil
  20169. }
  20170. // ResetBotWxid resets all changes to the "bot_wxid" field.
  20171. func (m *MessageRecordsMutation) ResetBotWxid() {
  20172. m.bot_wxid = nil
  20173. }
  20174. // SetContactID sets the "contact_id" field.
  20175. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  20176. m.message_contact = &u
  20177. }
  20178. // ContactID returns the value of the "contact_id" field in the mutation.
  20179. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  20180. v := m.message_contact
  20181. if v == nil {
  20182. return
  20183. }
  20184. return *v, true
  20185. }
  20186. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  20187. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20189. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  20190. if !m.op.Is(OpUpdateOne) {
  20191. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  20192. }
  20193. if m.id == nil || m.oldValue == nil {
  20194. return v, errors.New("OldContactID requires an ID field in the mutation")
  20195. }
  20196. oldValue, err := m.oldValue(ctx)
  20197. if err != nil {
  20198. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  20199. }
  20200. return oldValue.ContactID, nil
  20201. }
  20202. // ClearContactID clears the value of the "contact_id" field.
  20203. func (m *MessageRecordsMutation) ClearContactID() {
  20204. m.message_contact = nil
  20205. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  20206. }
  20207. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  20208. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  20209. _, ok := m.clearedFields[messagerecords.FieldContactID]
  20210. return ok
  20211. }
  20212. // ResetContactID resets all changes to the "contact_id" field.
  20213. func (m *MessageRecordsMutation) ResetContactID() {
  20214. m.message_contact = nil
  20215. delete(m.clearedFields, messagerecords.FieldContactID)
  20216. }
  20217. // SetContactType sets the "contact_type" field.
  20218. func (m *MessageRecordsMutation) SetContactType(i int) {
  20219. m.contact_type = &i
  20220. m.addcontact_type = nil
  20221. }
  20222. // ContactType returns the value of the "contact_type" field in the mutation.
  20223. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  20224. v := m.contact_type
  20225. if v == nil {
  20226. return
  20227. }
  20228. return *v, true
  20229. }
  20230. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  20231. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20233. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  20234. if !m.op.Is(OpUpdateOne) {
  20235. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  20236. }
  20237. if m.id == nil || m.oldValue == nil {
  20238. return v, errors.New("OldContactType requires an ID field in the mutation")
  20239. }
  20240. oldValue, err := m.oldValue(ctx)
  20241. if err != nil {
  20242. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  20243. }
  20244. return oldValue.ContactType, nil
  20245. }
  20246. // AddContactType adds i to the "contact_type" field.
  20247. func (m *MessageRecordsMutation) AddContactType(i int) {
  20248. if m.addcontact_type != nil {
  20249. *m.addcontact_type += i
  20250. } else {
  20251. m.addcontact_type = &i
  20252. }
  20253. }
  20254. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  20255. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  20256. v := m.addcontact_type
  20257. if v == nil {
  20258. return
  20259. }
  20260. return *v, true
  20261. }
  20262. // ResetContactType resets all changes to the "contact_type" field.
  20263. func (m *MessageRecordsMutation) ResetContactType() {
  20264. m.contact_type = nil
  20265. m.addcontact_type = nil
  20266. }
  20267. // SetContactWxid sets the "contact_wxid" field.
  20268. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  20269. m.contact_wxid = &s
  20270. }
  20271. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  20272. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  20273. v := m.contact_wxid
  20274. if v == nil {
  20275. return
  20276. }
  20277. return *v, true
  20278. }
  20279. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  20280. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20281. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20282. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  20283. if !m.op.Is(OpUpdateOne) {
  20284. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  20285. }
  20286. if m.id == nil || m.oldValue == nil {
  20287. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  20288. }
  20289. oldValue, err := m.oldValue(ctx)
  20290. if err != nil {
  20291. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  20292. }
  20293. return oldValue.ContactWxid, nil
  20294. }
  20295. // ResetContactWxid resets all changes to the "contact_wxid" field.
  20296. func (m *MessageRecordsMutation) ResetContactWxid() {
  20297. m.contact_wxid = nil
  20298. }
  20299. // SetContentType sets the "content_type" field.
  20300. func (m *MessageRecordsMutation) SetContentType(i int) {
  20301. m.content_type = &i
  20302. m.addcontent_type = nil
  20303. }
  20304. // ContentType returns the value of the "content_type" field in the mutation.
  20305. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  20306. v := m.content_type
  20307. if v == nil {
  20308. return
  20309. }
  20310. return *v, true
  20311. }
  20312. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  20313. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20315. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  20316. if !m.op.Is(OpUpdateOne) {
  20317. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  20318. }
  20319. if m.id == nil || m.oldValue == nil {
  20320. return v, errors.New("OldContentType requires an ID field in the mutation")
  20321. }
  20322. oldValue, err := m.oldValue(ctx)
  20323. if err != nil {
  20324. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  20325. }
  20326. return oldValue.ContentType, nil
  20327. }
  20328. // AddContentType adds i to the "content_type" field.
  20329. func (m *MessageRecordsMutation) AddContentType(i int) {
  20330. if m.addcontent_type != nil {
  20331. *m.addcontent_type += i
  20332. } else {
  20333. m.addcontent_type = &i
  20334. }
  20335. }
  20336. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  20337. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  20338. v := m.addcontent_type
  20339. if v == nil {
  20340. return
  20341. }
  20342. return *v, true
  20343. }
  20344. // ResetContentType resets all changes to the "content_type" field.
  20345. func (m *MessageRecordsMutation) ResetContentType() {
  20346. m.content_type = nil
  20347. m.addcontent_type = nil
  20348. }
  20349. // SetContent sets the "content" field.
  20350. func (m *MessageRecordsMutation) SetContent(s string) {
  20351. m.content = &s
  20352. }
  20353. // Content returns the value of the "content" field in the mutation.
  20354. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  20355. v := m.content
  20356. if v == nil {
  20357. return
  20358. }
  20359. return *v, true
  20360. }
  20361. // OldContent returns the old "content" field's value of the MessageRecords entity.
  20362. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20364. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  20365. if !m.op.Is(OpUpdateOne) {
  20366. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  20367. }
  20368. if m.id == nil || m.oldValue == nil {
  20369. return v, errors.New("OldContent requires an ID field in the mutation")
  20370. }
  20371. oldValue, err := m.oldValue(ctx)
  20372. if err != nil {
  20373. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  20374. }
  20375. return oldValue.Content, nil
  20376. }
  20377. // ResetContent resets all changes to the "content" field.
  20378. func (m *MessageRecordsMutation) ResetContent() {
  20379. m.content = nil
  20380. }
  20381. // SetMeta sets the "meta" field.
  20382. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  20383. m.meta = &ct
  20384. }
  20385. // Meta returns the value of the "meta" field in the mutation.
  20386. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  20387. v := m.meta
  20388. if v == nil {
  20389. return
  20390. }
  20391. return *v, true
  20392. }
  20393. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  20394. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20396. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  20397. if !m.op.Is(OpUpdateOne) {
  20398. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  20399. }
  20400. if m.id == nil || m.oldValue == nil {
  20401. return v, errors.New("OldMeta requires an ID field in the mutation")
  20402. }
  20403. oldValue, err := m.oldValue(ctx)
  20404. if err != nil {
  20405. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  20406. }
  20407. return oldValue.Meta, nil
  20408. }
  20409. // ClearMeta clears the value of the "meta" field.
  20410. func (m *MessageRecordsMutation) ClearMeta() {
  20411. m.meta = nil
  20412. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  20413. }
  20414. // MetaCleared returns if the "meta" field was cleared in this mutation.
  20415. func (m *MessageRecordsMutation) MetaCleared() bool {
  20416. _, ok := m.clearedFields[messagerecords.FieldMeta]
  20417. return ok
  20418. }
  20419. // ResetMeta resets all changes to the "meta" field.
  20420. func (m *MessageRecordsMutation) ResetMeta() {
  20421. m.meta = nil
  20422. delete(m.clearedFields, messagerecords.FieldMeta)
  20423. }
  20424. // SetErrorDetail sets the "error_detail" field.
  20425. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  20426. m.error_detail = &s
  20427. }
  20428. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  20429. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  20430. v := m.error_detail
  20431. if v == nil {
  20432. return
  20433. }
  20434. return *v, true
  20435. }
  20436. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  20437. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20439. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  20440. if !m.op.Is(OpUpdateOne) {
  20441. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  20442. }
  20443. if m.id == nil || m.oldValue == nil {
  20444. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  20445. }
  20446. oldValue, err := m.oldValue(ctx)
  20447. if err != nil {
  20448. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  20449. }
  20450. return oldValue.ErrorDetail, nil
  20451. }
  20452. // ResetErrorDetail resets all changes to the "error_detail" field.
  20453. func (m *MessageRecordsMutation) ResetErrorDetail() {
  20454. m.error_detail = nil
  20455. }
  20456. // SetSendTime sets the "send_time" field.
  20457. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  20458. m.send_time = &t
  20459. }
  20460. // SendTime returns the value of the "send_time" field in the mutation.
  20461. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  20462. v := m.send_time
  20463. if v == nil {
  20464. return
  20465. }
  20466. return *v, true
  20467. }
  20468. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  20469. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20471. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  20472. if !m.op.Is(OpUpdateOne) {
  20473. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  20474. }
  20475. if m.id == nil || m.oldValue == nil {
  20476. return v, errors.New("OldSendTime requires an ID field in the mutation")
  20477. }
  20478. oldValue, err := m.oldValue(ctx)
  20479. if err != nil {
  20480. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  20481. }
  20482. return oldValue.SendTime, nil
  20483. }
  20484. // ClearSendTime clears the value of the "send_time" field.
  20485. func (m *MessageRecordsMutation) ClearSendTime() {
  20486. m.send_time = nil
  20487. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  20488. }
  20489. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  20490. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  20491. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  20492. return ok
  20493. }
  20494. // ResetSendTime resets all changes to the "send_time" field.
  20495. func (m *MessageRecordsMutation) ResetSendTime() {
  20496. m.send_time = nil
  20497. delete(m.clearedFields, messagerecords.FieldSendTime)
  20498. }
  20499. // SetSourceType sets the "source_type" field.
  20500. func (m *MessageRecordsMutation) SetSourceType(i int) {
  20501. m.source_type = &i
  20502. m.addsource_type = nil
  20503. }
  20504. // SourceType returns the value of the "source_type" field in the mutation.
  20505. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  20506. v := m.source_type
  20507. if v == nil {
  20508. return
  20509. }
  20510. return *v, true
  20511. }
  20512. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  20513. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20515. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  20516. if !m.op.Is(OpUpdateOne) {
  20517. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  20518. }
  20519. if m.id == nil || m.oldValue == nil {
  20520. return v, errors.New("OldSourceType requires an ID field in the mutation")
  20521. }
  20522. oldValue, err := m.oldValue(ctx)
  20523. if err != nil {
  20524. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  20525. }
  20526. return oldValue.SourceType, nil
  20527. }
  20528. // AddSourceType adds i to the "source_type" field.
  20529. func (m *MessageRecordsMutation) AddSourceType(i int) {
  20530. if m.addsource_type != nil {
  20531. *m.addsource_type += i
  20532. } else {
  20533. m.addsource_type = &i
  20534. }
  20535. }
  20536. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  20537. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  20538. v := m.addsource_type
  20539. if v == nil {
  20540. return
  20541. }
  20542. return *v, true
  20543. }
  20544. // ResetSourceType resets all changes to the "source_type" field.
  20545. func (m *MessageRecordsMutation) ResetSourceType() {
  20546. m.source_type = nil
  20547. m.addsource_type = nil
  20548. }
  20549. // SetSourceID sets the "source_id" field.
  20550. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  20551. m.sop_stage = &u
  20552. }
  20553. // SourceID returns the value of the "source_id" field in the mutation.
  20554. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  20555. v := m.sop_stage
  20556. if v == nil {
  20557. return
  20558. }
  20559. return *v, true
  20560. }
  20561. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  20562. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20564. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  20565. if !m.op.Is(OpUpdateOne) {
  20566. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  20567. }
  20568. if m.id == nil || m.oldValue == nil {
  20569. return v, errors.New("OldSourceID requires an ID field in the mutation")
  20570. }
  20571. oldValue, err := m.oldValue(ctx)
  20572. if err != nil {
  20573. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  20574. }
  20575. return oldValue.SourceID, nil
  20576. }
  20577. // ClearSourceID clears the value of the "source_id" field.
  20578. func (m *MessageRecordsMutation) ClearSourceID() {
  20579. m.sop_stage = nil
  20580. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  20581. }
  20582. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  20583. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  20584. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  20585. return ok
  20586. }
  20587. // ResetSourceID resets all changes to the "source_id" field.
  20588. func (m *MessageRecordsMutation) ResetSourceID() {
  20589. m.sop_stage = nil
  20590. delete(m.clearedFields, messagerecords.FieldSourceID)
  20591. }
  20592. // SetSubSourceID sets the "sub_source_id" field.
  20593. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  20594. m.sop_node = &u
  20595. }
  20596. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  20597. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  20598. v := m.sop_node
  20599. if v == nil {
  20600. return
  20601. }
  20602. return *v, true
  20603. }
  20604. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  20605. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20607. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  20608. if !m.op.Is(OpUpdateOne) {
  20609. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  20610. }
  20611. if m.id == nil || m.oldValue == nil {
  20612. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  20613. }
  20614. oldValue, err := m.oldValue(ctx)
  20615. if err != nil {
  20616. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  20617. }
  20618. return oldValue.SubSourceID, nil
  20619. }
  20620. // ClearSubSourceID clears the value of the "sub_source_id" field.
  20621. func (m *MessageRecordsMutation) ClearSubSourceID() {
  20622. m.sop_node = nil
  20623. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  20624. }
  20625. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  20626. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  20627. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  20628. return ok
  20629. }
  20630. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  20631. func (m *MessageRecordsMutation) ResetSubSourceID() {
  20632. m.sop_node = nil
  20633. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  20634. }
  20635. // SetOrganizationID sets the "organization_id" field.
  20636. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  20637. m.organization_id = &u
  20638. m.addorganization_id = nil
  20639. }
  20640. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20641. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  20642. v := m.organization_id
  20643. if v == nil {
  20644. return
  20645. }
  20646. return *v, true
  20647. }
  20648. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  20649. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  20650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20651. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20652. if !m.op.Is(OpUpdateOne) {
  20653. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20654. }
  20655. if m.id == nil || m.oldValue == nil {
  20656. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20657. }
  20658. oldValue, err := m.oldValue(ctx)
  20659. if err != nil {
  20660. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20661. }
  20662. return oldValue.OrganizationID, nil
  20663. }
  20664. // AddOrganizationID adds u to the "organization_id" field.
  20665. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  20666. if m.addorganization_id != nil {
  20667. *m.addorganization_id += u
  20668. } else {
  20669. m.addorganization_id = &u
  20670. }
  20671. }
  20672. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20673. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  20674. v := m.addorganization_id
  20675. if v == nil {
  20676. return
  20677. }
  20678. return *v, true
  20679. }
  20680. // ClearOrganizationID clears the value of the "organization_id" field.
  20681. func (m *MessageRecordsMutation) ClearOrganizationID() {
  20682. m.organization_id = nil
  20683. m.addorganization_id = nil
  20684. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  20685. }
  20686. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20687. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  20688. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  20689. return ok
  20690. }
  20691. // ResetOrganizationID resets all changes to the "organization_id" field.
  20692. func (m *MessageRecordsMutation) ResetOrganizationID() {
  20693. m.organization_id = nil
  20694. m.addorganization_id = nil
  20695. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  20696. }
  20697. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  20698. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  20699. m.sop_stage = &id
  20700. }
  20701. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  20702. func (m *MessageRecordsMutation) ClearSopStage() {
  20703. m.clearedsop_stage = true
  20704. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  20705. }
  20706. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  20707. func (m *MessageRecordsMutation) SopStageCleared() bool {
  20708. return m.SourceIDCleared() || m.clearedsop_stage
  20709. }
  20710. // SopStageID returns the "sop_stage" edge ID in the mutation.
  20711. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  20712. if m.sop_stage != nil {
  20713. return *m.sop_stage, true
  20714. }
  20715. return
  20716. }
  20717. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  20718. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20719. // SopStageID instead. It exists only for internal usage by the builders.
  20720. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  20721. if id := m.sop_stage; id != nil {
  20722. ids = append(ids, *id)
  20723. }
  20724. return
  20725. }
  20726. // ResetSopStage resets all changes to the "sop_stage" edge.
  20727. func (m *MessageRecordsMutation) ResetSopStage() {
  20728. m.sop_stage = nil
  20729. m.clearedsop_stage = false
  20730. }
  20731. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  20732. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  20733. m.sop_node = &id
  20734. }
  20735. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  20736. func (m *MessageRecordsMutation) ClearSopNode() {
  20737. m.clearedsop_node = true
  20738. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  20739. }
  20740. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  20741. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  20742. return m.SubSourceIDCleared() || m.clearedsop_node
  20743. }
  20744. // SopNodeID returns the "sop_node" edge ID in the mutation.
  20745. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  20746. if m.sop_node != nil {
  20747. return *m.sop_node, true
  20748. }
  20749. return
  20750. }
  20751. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  20752. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20753. // SopNodeID instead. It exists only for internal usage by the builders.
  20754. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  20755. if id := m.sop_node; id != nil {
  20756. ids = append(ids, *id)
  20757. }
  20758. return
  20759. }
  20760. // ResetSopNode resets all changes to the "sop_node" edge.
  20761. func (m *MessageRecordsMutation) ResetSopNode() {
  20762. m.sop_node = nil
  20763. m.clearedsop_node = false
  20764. }
  20765. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  20766. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  20767. m.message_contact = &id
  20768. }
  20769. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  20770. func (m *MessageRecordsMutation) ClearMessageContact() {
  20771. m.clearedmessage_contact = true
  20772. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  20773. }
  20774. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  20775. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  20776. return m.ContactIDCleared() || m.clearedmessage_contact
  20777. }
  20778. // MessageContactID returns the "message_contact" edge ID in the mutation.
  20779. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  20780. if m.message_contact != nil {
  20781. return *m.message_contact, true
  20782. }
  20783. return
  20784. }
  20785. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  20786. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20787. // MessageContactID instead. It exists only for internal usage by the builders.
  20788. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  20789. if id := m.message_contact; id != nil {
  20790. ids = append(ids, *id)
  20791. }
  20792. return
  20793. }
  20794. // ResetMessageContact resets all changes to the "message_contact" edge.
  20795. func (m *MessageRecordsMutation) ResetMessageContact() {
  20796. m.message_contact = nil
  20797. m.clearedmessage_contact = false
  20798. }
  20799. // Where appends a list predicates to the MessageRecordsMutation builder.
  20800. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  20801. m.predicates = append(m.predicates, ps...)
  20802. }
  20803. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  20804. // users can use type-assertion to append predicates that do not depend on any generated package.
  20805. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  20806. p := make([]predicate.MessageRecords, len(ps))
  20807. for i := range ps {
  20808. p[i] = ps[i]
  20809. }
  20810. m.Where(p...)
  20811. }
  20812. // Op returns the operation name.
  20813. func (m *MessageRecordsMutation) Op() Op {
  20814. return m.op
  20815. }
  20816. // SetOp allows setting the mutation operation.
  20817. func (m *MessageRecordsMutation) SetOp(op Op) {
  20818. m.op = op
  20819. }
  20820. // Type returns the node type of this mutation (MessageRecords).
  20821. func (m *MessageRecordsMutation) Type() string {
  20822. return m.typ
  20823. }
  20824. // Fields returns all fields that were changed during this mutation. Note that in
  20825. // order to get all numeric fields that were incremented/decremented, call
  20826. // AddedFields().
  20827. func (m *MessageRecordsMutation) Fields() []string {
  20828. fields := make([]string, 0, 16)
  20829. if m.created_at != nil {
  20830. fields = append(fields, messagerecords.FieldCreatedAt)
  20831. }
  20832. if m.updated_at != nil {
  20833. fields = append(fields, messagerecords.FieldUpdatedAt)
  20834. }
  20835. if m.status != nil {
  20836. fields = append(fields, messagerecords.FieldStatus)
  20837. }
  20838. if m.bot_wxid != nil {
  20839. fields = append(fields, messagerecords.FieldBotWxid)
  20840. }
  20841. if m.message_contact != nil {
  20842. fields = append(fields, messagerecords.FieldContactID)
  20843. }
  20844. if m.contact_type != nil {
  20845. fields = append(fields, messagerecords.FieldContactType)
  20846. }
  20847. if m.contact_wxid != nil {
  20848. fields = append(fields, messagerecords.FieldContactWxid)
  20849. }
  20850. if m.content_type != nil {
  20851. fields = append(fields, messagerecords.FieldContentType)
  20852. }
  20853. if m.content != nil {
  20854. fields = append(fields, messagerecords.FieldContent)
  20855. }
  20856. if m.meta != nil {
  20857. fields = append(fields, messagerecords.FieldMeta)
  20858. }
  20859. if m.error_detail != nil {
  20860. fields = append(fields, messagerecords.FieldErrorDetail)
  20861. }
  20862. if m.send_time != nil {
  20863. fields = append(fields, messagerecords.FieldSendTime)
  20864. }
  20865. if m.source_type != nil {
  20866. fields = append(fields, messagerecords.FieldSourceType)
  20867. }
  20868. if m.sop_stage != nil {
  20869. fields = append(fields, messagerecords.FieldSourceID)
  20870. }
  20871. if m.sop_node != nil {
  20872. fields = append(fields, messagerecords.FieldSubSourceID)
  20873. }
  20874. if m.organization_id != nil {
  20875. fields = append(fields, messagerecords.FieldOrganizationID)
  20876. }
  20877. return fields
  20878. }
  20879. // Field returns the value of a field with the given name. The second boolean
  20880. // return value indicates that this field was not set, or was not defined in the
  20881. // schema.
  20882. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  20883. switch name {
  20884. case messagerecords.FieldCreatedAt:
  20885. return m.CreatedAt()
  20886. case messagerecords.FieldUpdatedAt:
  20887. return m.UpdatedAt()
  20888. case messagerecords.FieldStatus:
  20889. return m.Status()
  20890. case messagerecords.FieldBotWxid:
  20891. return m.BotWxid()
  20892. case messagerecords.FieldContactID:
  20893. return m.ContactID()
  20894. case messagerecords.FieldContactType:
  20895. return m.ContactType()
  20896. case messagerecords.FieldContactWxid:
  20897. return m.ContactWxid()
  20898. case messagerecords.FieldContentType:
  20899. return m.ContentType()
  20900. case messagerecords.FieldContent:
  20901. return m.Content()
  20902. case messagerecords.FieldMeta:
  20903. return m.Meta()
  20904. case messagerecords.FieldErrorDetail:
  20905. return m.ErrorDetail()
  20906. case messagerecords.FieldSendTime:
  20907. return m.SendTime()
  20908. case messagerecords.FieldSourceType:
  20909. return m.SourceType()
  20910. case messagerecords.FieldSourceID:
  20911. return m.SourceID()
  20912. case messagerecords.FieldSubSourceID:
  20913. return m.SubSourceID()
  20914. case messagerecords.FieldOrganizationID:
  20915. return m.OrganizationID()
  20916. }
  20917. return nil, false
  20918. }
  20919. // OldField returns the old value of the field from the database. An error is
  20920. // returned if the mutation operation is not UpdateOne, or the query to the
  20921. // database failed.
  20922. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20923. switch name {
  20924. case messagerecords.FieldCreatedAt:
  20925. return m.OldCreatedAt(ctx)
  20926. case messagerecords.FieldUpdatedAt:
  20927. return m.OldUpdatedAt(ctx)
  20928. case messagerecords.FieldStatus:
  20929. return m.OldStatus(ctx)
  20930. case messagerecords.FieldBotWxid:
  20931. return m.OldBotWxid(ctx)
  20932. case messagerecords.FieldContactID:
  20933. return m.OldContactID(ctx)
  20934. case messagerecords.FieldContactType:
  20935. return m.OldContactType(ctx)
  20936. case messagerecords.FieldContactWxid:
  20937. return m.OldContactWxid(ctx)
  20938. case messagerecords.FieldContentType:
  20939. return m.OldContentType(ctx)
  20940. case messagerecords.FieldContent:
  20941. return m.OldContent(ctx)
  20942. case messagerecords.FieldMeta:
  20943. return m.OldMeta(ctx)
  20944. case messagerecords.FieldErrorDetail:
  20945. return m.OldErrorDetail(ctx)
  20946. case messagerecords.FieldSendTime:
  20947. return m.OldSendTime(ctx)
  20948. case messagerecords.FieldSourceType:
  20949. return m.OldSourceType(ctx)
  20950. case messagerecords.FieldSourceID:
  20951. return m.OldSourceID(ctx)
  20952. case messagerecords.FieldSubSourceID:
  20953. return m.OldSubSourceID(ctx)
  20954. case messagerecords.FieldOrganizationID:
  20955. return m.OldOrganizationID(ctx)
  20956. }
  20957. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  20958. }
  20959. // SetField sets the value of a field with the given name. It returns an error if
  20960. // the field is not defined in the schema, or if the type mismatched the field
  20961. // type.
  20962. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  20963. switch name {
  20964. case messagerecords.FieldCreatedAt:
  20965. v, ok := value.(time.Time)
  20966. if !ok {
  20967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20968. }
  20969. m.SetCreatedAt(v)
  20970. return nil
  20971. case messagerecords.FieldUpdatedAt:
  20972. v, ok := value.(time.Time)
  20973. if !ok {
  20974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20975. }
  20976. m.SetUpdatedAt(v)
  20977. return nil
  20978. case messagerecords.FieldStatus:
  20979. v, ok := value.(uint8)
  20980. if !ok {
  20981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20982. }
  20983. m.SetStatus(v)
  20984. return nil
  20985. case messagerecords.FieldBotWxid:
  20986. v, ok := value.(string)
  20987. if !ok {
  20988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20989. }
  20990. m.SetBotWxid(v)
  20991. return nil
  20992. case messagerecords.FieldContactID:
  20993. v, ok := value.(uint64)
  20994. if !ok {
  20995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20996. }
  20997. m.SetContactID(v)
  20998. return nil
  20999. case messagerecords.FieldContactType:
  21000. v, ok := value.(int)
  21001. if !ok {
  21002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21003. }
  21004. m.SetContactType(v)
  21005. return nil
  21006. case messagerecords.FieldContactWxid:
  21007. v, ok := value.(string)
  21008. if !ok {
  21009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21010. }
  21011. m.SetContactWxid(v)
  21012. return nil
  21013. case messagerecords.FieldContentType:
  21014. v, ok := value.(int)
  21015. if !ok {
  21016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21017. }
  21018. m.SetContentType(v)
  21019. return nil
  21020. case messagerecords.FieldContent:
  21021. v, ok := value.(string)
  21022. if !ok {
  21023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21024. }
  21025. m.SetContent(v)
  21026. return nil
  21027. case messagerecords.FieldMeta:
  21028. v, ok := value.(custom_types.Meta)
  21029. if !ok {
  21030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21031. }
  21032. m.SetMeta(v)
  21033. return nil
  21034. case messagerecords.FieldErrorDetail:
  21035. v, ok := value.(string)
  21036. if !ok {
  21037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21038. }
  21039. m.SetErrorDetail(v)
  21040. return nil
  21041. case messagerecords.FieldSendTime:
  21042. v, ok := value.(time.Time)
  21043. if !ok {
  21044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21045. }
  21046. m.SetSendTime(v)
  21047. return nil
  21048. case messagerecords.FieldSourceType:
  21049. v, ok := value.(int)
  21050. if !ok {
  21051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21052. }
  21053. m.SetSourceType(v)
  21054. return nil
  21055. case messagerecords.FieldSourceID:
  21056. v, ok := value.(uint64)
  21057. if !ok {
  21058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21059. }
  21060. m.SetSourceID(v)
  21061. return nil
  21062. case messagerecords.FieldSubSourceID:
  21063. v, ok := value.(uint64)
  21064. if !ok {
  21065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21066. }
  21067. m.SetSubSourceID(v)
  21068. return nil
  21069. case messagerecords.FieldOrganizationID:
  21070. v, ok := value.(uint64)
  21071. if !ok {
  21072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21073. }
  21074. m.SetOrganizationID(v)
  21075. return nil
  21076. }
  21077. return fmt.Errorf("unknown MessageRecords field %s", name)
  21078. }
  21079. // AddedFields returns all numeric fields that were incremented/decremented during
  21080. // this mutation.
  21081. func (m *MessageRecordsMutation) AddedFields() []string {
  21082. var fields []string
  21083. if m.addstatus != nil {
  21084. fields = append(fields, messagerecords.FieldStatus)
  21085. }
  21086. if m.addcontact_type != nil {
  21087. fields = append(fields, messagerecords.FieldContactType)
  21088. }
  21089. if m.addcontent_type != nil {
  21090. fields = append(fields, messagerecords.FieldContentType)
  21091. }
  21092. if m.addsource_type != nil {
  21093. fields = append(fields, messagerecords.FieldSourceType)
  21094. }
  21095. if m.addorganization_id != nil {
  21096. fields = append(fields, messagerecords.FieldOrganizationID)
  21097. }
  21098. return fields
  21099. }
  21100. // AddedField returns the numeric value that was incremented/decremented on a field
  21101. // with the given name. The second boolean return value indicates that this field
  21102. // was not set, or was not defined in the schema.
  21103. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  21104. switch name {
  21105. case messagerecords.FieldStatus:
  21106. return m.AddedStatus()
  21107. case messagerecords.FieldContactType:
  21108. return m.AddedContactType()
  21109. case messagerecords.FieldContentType:
  21110. return m.AddedContentType()
  21111. case messagerecords.FieldSourceType:
  21112. return m.AddedSourceType()
  21113. case messagerecords.FieldOrganizationID:
  21114. return m.AddedOrganizationID()
  21115. }
  21116. return nil, false
  21117. }
  21118. // AddField adds the value to the field with the given name. It returns an error if
  21119. // the field is not defined in the schema, or if the type mismatched the field
  21120. // type.
  21121. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  21122. switch name {
  21123. case messagerecords.FieldStatus:
  21124. v, ok := value.(int8)
  21125. if !ok {
  21126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21127. }
  21128. m.AddStatus(v)
  21129. return nil
  21130. case messagerecords.FieldContactType:
  21131. v, ok := value.(int)
  21132. if !ok {
  21133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21134. }
  21135. m.AddContactType(v)
  21136. return nil
  21137. case messagerecords.FieldContentType:
  21138. v, ok := value.(int)
  21139. if !ok {
  21140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21141. }
  21142. m.AddContentType(v)
  21143. return nil
  21144. case messagerecords.FieldSourceType:
  21145. v, ok := value.(int)
  21146. if !ok {
  21147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21148. }
  21149. m.AddSourceType(v)
  21150. return nil
  21151. case messagerecords.FieldOrganizationID:
  21152. v, ok := value.(int64)
  21153. if !ok {
  21154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21155. }
  21156. m.AddOrganizationID(v)
  21157. return nil
  21158. }
  21159. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  21160. }
  21161. // ClearedFields returns all nullable fields that were cleared during this
  21162. // mutation.
  21163. func (m *MessageRecordsMutation) ClearedFields() []string {
  21164. var fields []string
  21165. if m.FieldCleared(messagerecords.FieldStatus) {
  21166. fields = append(fields, messagerecords.FieldStatus)
  21167. }
  21168. if m.FieldCleared(messagerecords.FieldContactID) {
  21169. fields = append(fields, messagerecords.FieldContactID)
  21170. }
  21171. if m.FieldCleared(messagerecords.FieldMeta) {
  21172. fields = append(fields, messagerecords.FieldMeta)
  21173. }
  21174. if m.FieldCleared(messagerecords.FieldSendTime) {
  21175. fields = append(fields, messagerecords.FieldSendTime)
  21176. }
  21177. if m.FieldCleared(messagerecords.FieldSourceID) {
  21178. fields = append(fields, messagerecords.FieldSourceID)
  21179. }
  21180. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  21181. fields = append(fields, messagerecords.FieldSubSourceID)
  21182. }
  21183. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  21184. fields = append(fields, messagerecords.FieldOrganizationID)
  21185. }
  21186. return fields
  21187. }
  21188. // FieldCleared returns a boolean indicating if a field with the given name was
  21189. // cleared in this mutation.
  21190. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  21191. _, ok := m.clearedFields[name]
  21192. return ok
  21193. }
  21194. // ClearField clears the value of the field with the given name. It returns an
  21195. // error if the field is not defined in the schema.
  21196. func (m *MessageRecordsMutation) ClearField(name string) error {
  21197. switch name {
  21198. case messagerecords.FieldStatus:
  21199. m.ClearStatus()
  21200. return nil
  21201. case messagerecords.FieldContactID:
  21202. m.ClearContactID()
  21203. return nil
  21204. case messagerecords.FieldMeta:
  21205. m.ClearMeta()
  21206. return nil
  21207. case messagerecords.FieldSendTime:
  21208. m.ClearSendTime()
  21209. return nil
  21210. case messagerecords.FieldSourceID:
  21211. m.ClearSourceID()
  21212. return nil
  21213. case messagerecords.FieldSubSourceID:
  21214. m.ClearSubSourceID()
  21215. return nil
  21216. case messagerecords.FieldOrganizationID:
  21217. m.ClearOrganizationID()
  21218. return nil
  21219. }
  21220. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  21221. }
  21222. // ResetField resets all changes in the mutation for the field with the given name.
  21223. // It returns an error if the field is not defined in the schema.
  21224. func (m *MessageRecordsMutation) ResetField(name string) error {
  21225. switch name {
  21226. case messagerecords.FieldCreatedAt:
  21227. m.ResetCreatedAt()
  21228. return nil
  21229. case messagerecords.FieldUpdatedAt:
  21230. m.ResetUpdatedAt()
  21231. return nil
  21232. case messagerecords.FieldStatus:
  21233. m.ResetStatus()
  21234. return nil
  21235. case messagerecords.FieldBotWxid:
  21236. m.ResetBotWxid()
  21237. return nil
  21238. case messagerecords.FieldContactID:
  21239. m.ResetContactID()
  21240. return nil
  21241. case messagerecords.FieldContactType:
  21242. m.ResetContactType()
  21243. return nil
  21244. case messagerecords.FieldContactWxid:
  21245. m.ResetContactWxid()
  21246. return nil
  21247. case messagerecords.FieldContentType:
  21248. m.ResetContentType()
  21249. return nil
  21250. case messagerecords.FieldContent:
  21251. m.ResetContent()
  21252. return nil
  21253. case messagerecords.FieldMeta:
  21254. m.ResetMeta()
  21255. return nil
  21256. case messagerecords.FieldErrorDetail:
  21257. m.ResetErrorDetail()
  21258. return nil
  21259. case messagerecords.FieldSendTime:
  21260. m.ResetSendTime()
  21261. return nil
  21262. case messagerecords.FieldSourceType:
  21263. m.ResetSourceType()
  21264. return nil
  21265. case messagerecords.FieldSourceID:
  21266. m.ResetSourceID()
  21267. return nil
  21268. case messagerecords.FieldSubSourceID:
  21269. m.ResetSubSourceID()
  21270. return nil
  21271. case messagerecords.FieldOrganizationID:
  21272. m.ResetOrganizationID()
  21273. return nil
  21274. }
  21275. return fmt.Errorf("unknown MessageRecords field %s", name)
  21276. }
  21277. // AddedEdges returns all edge names that were set/added in this mutation.
  21278. func (m *MessageRecordsMutation) AddedEdges() []string {
  21279. edges := make([]string, 0, 3)
  21280. if m.sop_stage != nil {
  21281. edges = append(edges, messagerecords.EdgeSopStage)
  21282. }
  21283. if m.sop_node != nil {
  21284. edges = append(edges, messagerecords.EdgeSopNode)
  21285. }
  21286. if m.message_contact != nil {
  21287. edges = append(edges, messagerecords.EdgeMessageContact)
  21288. }
  21289. return edges
  21290. }
  21291. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21292. // name in this mutation.
  21293. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  21294. switch name {
  21295. case messagerecords.EdgeSopStage:
  21296. if id := m.sop_stage; id != nil {
  21297. return []ent.Value{*id}
  21298. }
  21299. case messagerecords.EdgeSopNode:
  21300. if id := m.sop_node; id != nil {
  21301. return []ent.Value{*id}
  21302. }
  21303. case messagerecords.EdgeMessageContact:
  21304. if id := m.message_contact; id != nil {
  21305. return []ent.Value{*id}
  21306. }
  21307. }
  21308. return nil
  21309. }
  21310. // RemovedEdges returns all edge names that were removed in this mutation.
  21311. func (m *MessageRecordsMutation) RemovedEdges() []string {
  21312. edges := make([]string, 0, 3)
  21313. return edges
  21314. }
  21315. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21316. // the given name in this mutation.
  21317. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  21318. return nil
  21319. }
  21320. // ClearedEdges returns all edge names that were cleared in this mutation.
  21321. func (m *MessageRecordsMutation) ClearedEdges() []string {
  21322. edges := make([]string, 0, 3)
  21323. if m.clearedsop_stage {
  21324. edges = append(edges, messagerecords.EdgeSopStage)
  21325. }
  21326. if m.clearedsop_node {
  21327. edges = append(edges, messagerecords.EdgeSopNode)
  21328. }
  21329. if m.clearedmessage_contact {
  21330. edges = append(edges, messagerecords.EdgeMessageContact)
  21331. }
  21332. return edges
  21333. }
  21334. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21335. // was cleared in this mutation.
  21336. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  21337. switch name {
  21338. case messagerecords.EdgeSopStage:
  21339. return m.clearedsop_stage
  21340. case messagerecords.EdgeSopNode:
  21341. return m.clearedsop_node
  21342. case messagerecords.EdgeMessageContact:
  21343. return m.clearedmessage_contact
  21344. }
  21345. return false
  21346. }
  21347. // ClearEdge clears the value of the edge with the given name. It returns an error
  21348. // if that edge is not defined in the schema.
  21349. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  21350. switch name {
  21351. case messagerecords.EdgeSopStage:
  21352. m.ClearSopStage()
  21353. return nil
  21354. case messagerecords.EdgeSopNode:
  21355. m.ClearSopNode()
  21356. return nil
  21357. case messagerecords.EdgeMessageContact:
  21358. m.ClearMessageContact()
  21359. return nil
  21360. }
  21361. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  21362. }
  21363. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21364. // It returns an error if the edge is not defined in the schema.
  21365. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  21366. switch name {
  21367. case messagerecords.EdgeSopStage:
  21368. m.ResetSopStage()
  21369. return nil
  21370. case messagerecords.EdgeSopNode:
  21371. m.ResetSopNode()
  21372. return nil
  21373. case messagerecords.EdgeMessageContact:
  21374. m.ResetMessageContact()
  21375. return nil
  21376. }
  21377. return fmt.Errorf("unknown MessageRecords edge %s", name)
  21378. }
  21379. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  21380. type MsgMutation struct {
  21381. config
  21382. op Op
  21383. typ string
  21384. id *uint64
  21385. created_at *time.Time
  21386. updated_at *time.Time
  21387. deleted_at *time.Time
  21388. status *uint8
  21389. addstatus *int8
  21390. fromwxid *string
  21391. toid *string
  21392. msgtype *int32
  21393. addmsgtype *int32
  21394. msg *string
  21395. batch_no *string
  21396. cc *string
  21397. phone *string
  21398. clearedFields map[string]struct{}
  21399. done bool
  21400. oldValue func(context.Context) (*Msg, error)
  21401. predicates []predicate.Msg
  21402. }
  21403. var _ ent.Mutation = (*MsgMutation)(nil)
  21404. // msgOption allows management of the mutation configuration using functional options.
  21405. type msgOption func(*MsgMutation)
  21406. // newMsgMutation creates new mutation for the Msg entity.
  21407. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  21408. m := &MsgMutation{
  21409. config: c,
  21410. op: op,
  21411. typ: TypeMsg,
  21412. clearedFields: make(map[string]struct{}),
  21413. }
  21414. for _, opt := range opts {
  21415. opt(m)
  21416. }
  21417. return m
  21418. }
  21419. // withMsgID sets the ID field of the mutation.
  21420. func withMsgID(id uint64) msgOption {
  21421. return func(m *MsgMutation) {
  21422. var (
  21423. err error
  21424. once sync.Once
  21425. value *Msg
  21426. )
  21427. m.oldValue = func(ctx context.Context) (*Msg, error) {
  21428. once.Do(func() {
  21429. if m.done {
  21430. err = errors.New("querying old values post mutation is not allowed")
  21431. } else {
  21432. value, err = m.Client().Msg.Get(ctx, id)
  21433. }
  21434. })
  21435. return value, err
  21436. }
  21437. m.id = &id
  21438. }
  21439. }
  21440. // withMsg sets the old Msg of the mutation.
  21441. func withMsg(node *Msg) msgOption {
  21442. return func(m *MsgMutation) {
  21443. m.oldValue = func(context.Context) (*Msg, error) {
  21444. return node, nil
  21445. }
  21446. m.id = &node.ID
  21447. }
  21448. }
  21449. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21450. // executed in a transaction (ent.Tx), a transactional client is returned.
  21451. func (m MsgMutation) Client() *Client {
  21452. client := &Client{config: m.config}
  21453. client.init()
  21454. return client
  21455. }
  21456. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21457. // it returns an error otherwise.
  21458. func (m MsgMutation) Tx() (*Tx, error) {
  21459. if _, ok := m.driver.(*txDriver); !ok {
  21460. return nil, errors.New("ent: mutation is not running in a transaction")
  21461. }
  21462. tx := &Tx{config: m.config}
  21463. tx.init()
  21464. return tx, nil
  21465. }
  21466. // SetID sets the value of the id field. Note that this
  21467. // operation is only accepted on creation of Msg entities.
  21468. func (m *MsgMutation) SetID(id uint64) {
  21469. m.id = &id
  21470. }
  21471. // ID returns the ID value in the mutation. Note that the ID is only available
  21472. // if it was provided to the builder or after it was returned from the database.
  21473. func (m *MsgMutation) ID() (id uint64, exists bool) {
  21474. if m.id == nil {
  21475. return
  21476. }
  21477. return *m.id, true
  21478. }
  21479. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21480. // That means, if the mutation is applied within a transaction with an isolation level such
  21481. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21482. // or updated by the mutation.
  21483. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  21484. switch {
  21485. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21486. id, exists := m.ID()
  21487. if exists {
  21488. return []uint64{id}, nil
  21489. }
  21490. fallthrough
  21491. case m.op.Is(OpUpdate | OpDelete):
  21492. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  21493. default:
  21494. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21495. }
  21496. }
  21497. // SetCreatedAt sets the "created_at" field.
  21498. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  21499. m.created_at = &t
  21500. }
  21501. // CreatedAt returns the value of the "created_at" field in the mutation.
  21502. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  21503. v := m.created_at
  21504. if v == nil {
  21505. return
  21506. }
  21507. return *v, true
  21508. }
  21509. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  21510. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21512. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21513. if !m.op.Is(OpUpdateOne) {
  21514. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21515. }
  21516. if m.id == nil || m.oldValue == nil {
  21517. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21518. }
  21519. oldValue, err := m.oldValue(ctx)
  21520. if err != nil {
  21521. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21522. }
  21523. return oldValue.CreatedAt, nil
  21524. }
  21525. // ResetCreatedAt resets all changes to the "created_at" field.
  21526. func (m *MsgMutation) ResetCreatedAt() {
  21527. m.created_at = nil
  21528. }
  21529. // SetUpdatedAt sets the "updated_at" field.
  21530. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  21531. m.updated_at = &t
  21532. }
  21533. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21534. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  21535. v := m.updated_at
  21536. if v == nil {
  21537. return
  21538. }
  21539. return *v, true
  21540. }
  21541. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  21542. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21544. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21545. if !m.op.Is(OpUpdateOne) {
  21546. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21547. }
  21548. if m.id == nil || m.oldValue == nil {
  21549. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21550. }
  21551. oldValue, err := m.oldValue(ctx)
  21552. if err != nil {
  21553. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21554. }
  21555. return oldValue.UpdatedAt, nil
  21556. }
  21557. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21558. func (m *MsgMutation) ResetUpdatedAt() {
  21559. m.updated_at = nil
  21560. }
  21561. // SetDeletedAt sets the "deleted_at" field.
  21562. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  21563. m.deleted_at = &t
  21564. }
  21565. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21566. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  21567. v := m.deleted_at
  21568. if v == nil {
  21569. return
  21570. }
  21571. return *v, true
  21572. }
  21573. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  21574. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21576. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21577. if !m.op.Is(OpUpdateOne) {
  21578. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21579. }
  21580. if m.id == nil || m.oldValue == nil {
  21581. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21582. }
  21583. oldValue, err := m.oldValue(ctx)
  21584. if err != nil {
  21585. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21586. }
  21587. return oldValue.DeletedAt, nil
  21588. }
  21589. // ClearDeletedAt clears the value of the "deleted_at" field.
  21590. func (m *MsgMutation) ClearDeletedAt() {
  21591. m.deleted_at = nil
  21592. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  21593. }
  21594. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21595. func (m *MsgMutation) DeletedAtCleared() bool {
  21596. _, ok := m.clearedFields[msg.FieldDeletedAt]
  21597. return ok
  21598. }
  21599. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21600. func (m *MsgMutation) ResetDeletedAt() {
  21601. m.deleted_at = nil
  21602. delete(m.clearedFields, msg.FieldDeletedAt)
  21603. }
  21604. // SetStatus sets the "status" field.
  21605. func (m *MsgMutation) SetStatus(u uint8) {
  21606. m.status = &u
  21607. m.addstatus = nil
  21608. }
  21609. // Status returns the value of the "status" field in the mutation.
  21610. func (m *MsgMutation) Status() (r uint8, exists bool) {
  21611. v := m.status
  21612. if v == nil {
  21613. return
  21614. }
  21615. return *v, true
  21616. }
  21617. // OldStatus returns the old "status" field's value of the Msg entity.
  21618. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21620. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21621. if !m.op.Is(OpUpdateOne) {
  21622. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21623. }
  21624. if m.id == nil || m.oldValue == nil {
  21625. return v, errors.New("OldStatus requires an ID field in the mutation")
  21626. }
  21627. oldValue, err := m.oldValue(ctx)
  21628. if err != nil {
  21629. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21630. }
  21631. return oldValue.Status, nil
  21632. }
  21633. // AddStatus adds u to the "status" field.
  21634. func (m *MsgMutation) AddStatus(u int8) {
  21635. if m.addstatus != nil {
  21636. *m.addstatus += u
  21637. } else {
  21638. m.addstatus = &u
  21639. }
  21640. }
  21641. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21642. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  21643. v := m.addstatus
  21644. if v == nil {
  21645. return
  21646. }
  21647. return *v, true
  21648. }
  21649. // ClearStatus clears the value of the "status" field.
  21650. func (m *MsgMutation) ClearStatus() {
  21651. m.status = nil
  21652. m.addstatus = nil
  21653. m.clearedFields[msg.FieldStatus] = struct{}{}
  21654. }
  21655. // StatusCleared returns if the "status" field was cleared in this mutation.
  21656. func (m *MsgMutation) StatusCleared() bool {
  21657. _, ok := m.clearedFields[msg.FieldStatus]
  21658. return ok
  21659. }
  21660. // ResetStatus resets all changes to the "status" field.
  21661. func (m *MsgMutation) ResetStatus() {
  21662. m.status = nil
  21663. m.addstatus = nil
  21664. delete(m.clearedFields, msg.FieldStatus)
  21665. }
  21666. // SetFromwxid sets the "fromwxid" field.
  21667. func (m *MsgMutation) SetFromwxid(s string) {
  21668. m.fromwxid = &s
  21669. }
  21670. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  21671. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  21672. v := m.fromwxid
  21673. if v == nil {
  21674. return
  21675. }
  21676. return *v, true
  21677. }
  21678. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  21679. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21681. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  21682. if !m.op.Is(OpUpdateOne) {
  21683. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  21684. }
  21685. if m.id == nil || m.oldValue == nil {
  21686. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  21687. }
  21688. oldValue, err := m.oldValue(ctx)
  21689. if err != nil {
  21690. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  21691. }
  21692. return oldValue.Fromwxid, nil
  21693. }
  21694. // ClearFromwxid clears the value of the "fromwxid" field.
  21695. func (m *MsgMutation) ClearFromwxid() {
  21696. m.fromwxid = nil
  21697. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  21698. }
  21699. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  21700. func (m *MsgMutation) FromwxidCleared() bool {
  21701. _, ok := m.clearedFields[msg.FieldFromwxid]
  21702. return ok
  21703. }
  21704. // ResetFromwxid resets all changes to the "fromwxid" field.
  21705. func (m *MsgMutation) ResetFromwxid() {
  21706. m.fromwxid = nil
  21707. delete(m.clearedFields, msg.FieldFromwxid)
  21708. }
  21709. // SetToid sets the "toid" field.
  21710. func (m *MsgMutation) SetToid(s string) {
  21711. m.toid = &s
  21712. }
  21713. // Toid returns the value of the "toid" field in the mutation.
  21714. func (m *MsgMutation) Toid() (r string, exists bool) {
  21715. v := m.toid
  21716. if v == nil {
  21717. return
  21718. }
  21719. return *v, true
  21720. }
  21721. // OldToid returns the old "toid" field's value of the Msg entity.
  21722. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21724. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  21725. if !m.op.Is(OpUpdateOne) {
  21726. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  21727. }
  21728. if m.id == nil || m.oldValue == nil {
  21729. return v, errors.New("OldToid requires an ID field in the mutation")
  21730. }
  21731. oldValue, err := m.oldValue(ctx)
  21732. if err != nil {
  21733. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  21734. }
  21735. return oldValue.Toid, nil
  21736. }
  21737. // ClearToid clears the value of the "toid" field.
  21738. func (m *MsgMutation) ClearToid() {
  21739. m.toid = nil
  21740. m.clearedFields[msg.FieldToid] = struct{}{}
  21741. }
  21742. // ToidCleared returns if the "toid" field was cleared in this mutation.
  21743. func (m *MsgMutation) ToidCleared() bool {
  21744. _, ok := m.clearedFields[msg.FieldToid]
  21745. return ok
  21746. }
  21747. // ResetToid resets all changes to the "toid" field.
  21748. func (m *MsgMutation) ResetToid() {
  21749. m.toid = nil
  21750. delete(m.clearedFields, msg.FieldToid)
  21751. }
  21752. // SetMsgtype sets the "msgtype" field.
  21753. func (m *MsgMutation) SetMsgtype(i int32) {
  21754. m.msgtype = &i
  21755. m.addmsgtype = nil
  21756. }
  21757. // Msgtype returns the value of the "msgtype" field in the mutation.
  21758. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  21759. v := m.msgtype
  21760. if v == nil {
  21761. return
  21762. }
  21763. return *v, true
  21764. }
  21765. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  21766. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21768. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  21769. if !m.op.Is(OpUpdateOne) {
  21770. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  21771. }
  21772. if m.id == nil || m.oldValue == nil {
  21773. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  21774. }
  21775. oldValue, err := m.oldValue(ctx)
  21776. if err != nil {
  21777. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  21778. }
  21779. return oldValue.Msgtype, nil
  21780. }
  21781. // AddMsgtype adds i to the "msgtype" field.
  21782. func (m *MsgMutation) AddMsgtype(i int32) {
  21783. if m.addmsgtype != nil {
  21784. *m.addmsgtype += i
  21785. } else {
  21786. m.addmsgtype = &i
  21787. }
  21788. }
  21789. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  21790. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  21791. v := m.addmsgtype
  21792. if v == nil {
  21793. return
  21794. }
  21795. return *v, true
  21796. }
  21797. // ClearMsgtype clears the value of the "msgtype" field.
  21798. func (m *MsgMutation) ClearMsgtype() {
  21799. m.msgtype = nil
  21800. m.addmsgtype = nil
  21801. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  21802. }
  21803. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  21804. func (m *MsgMutation) MsgtypeCleared() bool {
  21805. _, ok := m.clearedFields[msg.FieldMsgtype]
  21806. return ok
  21807. }
  21808. // ResetMsgtype resets all changes to the "msgtype" field.
  21809. func (m *MsgMutation) ResetMsgtype() {
  21810. m.msgtype = nil
  21811. m.addmsgtype = nil
  21812. delete(m.clearedFields, msg.FieldMsgtype)
  21813. }
  21814. // SetMsg sets the "msg" field.
  21815. func (m *MsgMutation) SetMsg(s string) {
  21816. m.msg = &s
  21817. }
  21818. // Msg returns the value of the "msg" field in the mutation.
  21819. func (m *MsgMutation) Msg() (r string, exists bool) {
  21820. v := m.msg
  21821. if v == nil {
  21822. return
  21823. }
  21824. return *v, true
  21825. }
  21826. // OldMsg returns the old "msg" field's value of the Msg entity.
  21827. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21829. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  21830. if !m.op.Is(OpUpdateOne) {
  21831. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  21832. }
  21833. if m.id == nil || m.oldValue == nil {
  21834. return v, errors.New("OldMsg requires an ID field in the mutation")
  21835. }
  21836. oldValue, err := m.oldValue(ctx)
  21837. if err != nil {
  21838. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  21839. }
  21840. return oldValue.Msg, nil
  21841. }
  21842. // ClearMsg clears the value of the "msg" field.
  21843. func (m *MsgMutation) ClearMsg() {
  21844. m.msg = nil
  21845. m.clearedFields[msg.FieldMsg] = struct{}{}
  21846. }
  21847. // MsgCleared returns if the "msg" field was cleared in this mutation.
  21848. func (m *MsgMutation) MsgCleared() bool {
  21849. _, ok := m.clearedFields[msg.FieldMsg]
  21850. return ok
  21851. }
  21852. // ResetMsg resets all changes to the "msg" field.
  21853. func (m *MsgMutation) ResetMsg() {
  21854. m.msg = nil
  21855. delete(m.clearedFields, msg.FieldMsg)
  21856. }
  21857. // SetBatchNo sets the "batch_no" field.
  21858. func (m *MsgMutation) SetBatchNo(s string) {
  21859. m.batch_no = &s
  21860. }
  21861. // BatchNo returns the value of the "batch_no" field in the mutation.
  21862. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  21863. v := m.batch_no
  21864. if v == nil {
  21865. return
  21866. }
  21867. return *v, true
  21868. }
  21869. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  21870. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21872. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  21873. if !m.op.Is(OpUpdateOne) {
  21874. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  21875. }
  21876. if m.id == nil || m.oldValue == nil {
  21877. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  21878. }
  21879. oldValue, err := m.oldValue(ctx)
  21880. if err != nil {
  21881. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  21882. }
  21883. return oldValue.BatchNo, nil
  21884. }
  21885. // ClearBatchNo clears the value of the "batch_no" field.
  21886. func (m *MsgMutation) ClearBatchNo() {
  21887. m.batch_no = nil
  21888. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  21889. }
  21890. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  21891. func (m *MsgMutation) BatchNoCleared() bool {
  21892. _, ok := m.clearedFields[msg.FieldBatchNo]
  21893. return ok
  21894. }
  21895. // ResetBatchNo resets all changes to the "batch_no" field.
  21896. func (m *MsgMutation) ResetBatchNo() {
  21897. m.batch_no = nil
  21898. delete(m.clearedFields, msg.FieldBatchNo)
  21899. }
  21900. // SetCc sets the "cc" field.
  21901. func (m *MsgMutation) SetCc(s string) {
  21902. m.cc = &s
  21903. }
  21904. // Cc returns the value of the "cc" field in the mutation.
  21905. func (m *MsgMutation) Cc() (r string, exists bool) {
  21906. v := m.cc
  21907. if v == nil {
  21908. return
  21909. }
  21910. return *v, true
  21911. }
  21912. // OldCc returns the old "cc" field's value of the Msg entity.
  21913. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21915. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  21916. if !m.op.Is(OpUpdateOne) {
  21917. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  21918. }
  21919. if m.id == nil || m.oldValue == nil {
  21920. return v, errors.New("OldCc requires an ID field in the mutation")
  21921. }
  21922. oldValue, err := m.oldValue(ctx)
  21923. if err != nil {
  21924. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  21925. }
  21926. return oldValue.Cc, nil
  21927. }
  21928. // ResetCc resets all changes to the "cc" field.
  21929. func (m *MsgMutation) ResetCc() {
  21930. m.cc = nil
  21931. }
  21932. // SetPhone sets the "phone" field.
  21933. func (m *MsgMutation) SetPhone(s string) {
  21934. m.phone = &s
  21935. }
  21936. // Phone returns the value of the "phone" field in the mutation.
  21937. func (m *MsgMutation) Phone() (r string, exists bool) {
  21938. v := m.phone
  21939. if v == nil {
  21940. return
  21941. }
  21942. return *v, true
  21943. }
  21944. // OldPhone returns the old "phone" field's value of the Msg entity.
  21945. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  21946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21947. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  21948. if !m.op.Is(OpUpdateOne) {
  21949. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  21950. }
  21951. if m.id == nil || m.oldValue == nil {
  21952. return v, errors.New("OldPhone requires an ID field in the mutation")
  21953. }
  21954. oldValue, err := m.oldValue(ctx)
  21955. if err != nil {
  21956. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  21957. }
  21958. return oldValue.Phone, nil
  21959. }
  21960. // ResetPhone resets all changes to the "phone" field.
  21961. func (m *MsgMutation) ResetPhone() {
  21962. m.phone = nil
  21963. }
  21964. // Where appends a list predicates to the MsgMutation builder.
  21965. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  21966. m.predicates = append(m.predicates, ps...)
  21967. }
  21968. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  21969. // users can use type-assertion to append predicates that do not depend on any generated package.
  21970. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  21971. p := make([]predicate.Msg, len(ps))
  21972. for i := range ps {
  21973. p[i] = ps[i]
  21974. }
  21975. m.Where(p...)
  21976. }
  21977. // Op returns the operation name.
  21978. func (m *MsgMutation) Op() Op {
  21979. return m.op
  21980. }
  21981. // SetOp allows setting the mutation operation.
  21982. func (m *MsgMutation) SetOp(op Op) {
  21983. m.op = op
  21984. }
  21985. // Type returns the node type of this mutation (Msg).
  21986. func (m *MsgMutation) Type() string {
  21987. return m.typ
  21988. }
  21989. // Fields returns all fields that were changed during this mutation. Note that in
  21990. // order to get all numeric fields that were incremented/decremented, call
  21991. // AddedFields().
  21992. func (m *MsgMutation) Fields() []string {
  21993. fields := make([]string, 0, 11)
  21994. if m.created_at != nil {
  21995. fields = append(fields, msg.FieldCreatedAt)
  21996. }
  21997. if m.updated_at != nil {
  21998. fields = append(fields, msg.FieldUpdatedAt)
  21999. }
  22000. if m.deleted_at != nil {
  22001. fields = append(fields, msg.FieldDeletedAt)
  22002. }
  22003. if m.status != nil {
  22004. fields = append(fields, msg.FieldStatus)
  22005. }
  22006. if m.fromwxid != nil {
  22007. fields = append(fields, msg.FieldFromwxid)
  22008. }
  22009. if m.toid != nil {
  22010. fields = append(fields, msg.FieldToid)
  22011. }
  22012. if m.msgtype != nil {
  22013. fields = append(fields, msg.FieldMsgtype)
  22014. }
  22015. if m.msg != nil {
  22016. fields = append(fields, msg.FieldMsg)
  22017. }
  22018. if m.batch_no != nil {
  22019. fields = append(fields, msg.FieldBatchNo)
  22020. }
  22021. if m.cc != nil {
  22022. fields = append(fields, msg.FieldCc)
  22023. }
  22024. if m.phone != nil {
  22025. fields = append(fields, msg.FieldPhone)
  22026. }
  22027. return fields
  22028. }
  22029. // Field returns the value of a field with the given name. The second boolean
  22030. // return value indicates that this field was not set, or was not defined in the
  22031. // schema.
  22032. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  22033. switch name {
  22034. case msg.FieldCreatedAt:
  22035. return m.CreatedAt()
  22036. case msg.FieldUpdatedAt:
  22037. return m.UpdatedAt()
  22038. case msg.FieldDeletedAt:
  22039. return m.DeletedAt()
  22040. case msg.FieldStatus:
  22041. return m.Status()
  22042. case msg.FieldFromwxid:
  22043. return m.Fromwxid()
  22044. case msg.FieldToid:
  22045. return m.Toid()
  22046. case msg.FieldMsgtype:
  22047. return m.Msgtype()
  22048. case msg.FieldMsg:
  22049. return m.Msg()
  22050. case msg.FieldBatchNo:
  22051. return m.BatchNo()
  22052. case msg.FieldCc:
  22053. return m.Cc()
  22054. case msg.FieldPhone:
  22055. return m.Phone()
  22056. }
  22057. return nil, false
  22058. }
  22059. // OldField returns the old value of the field from the database. An error is
  22060. // returned if the mutation operation is not UpdateOne, or the query to the
  22061. // database failed.
  22062. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22063. switch name {
  22064. case msg.FieldCreatedAt:
  22065. return m.OldCreatedAt(ctx)
  22066. case msg.FieldUpdatedAt:
  22067. return m.OldUpdatedAt(ctx)
  22068. case msg.FieldDeletedAt:
  22069. return m.OldDeletedAt(ctx)
  22070. case msg.FieldStatus:
  22071. return m.OldStatus(ctx)
  22072. case msg.FieldFromwxid:
  22073. return m.OldFromwxid(ctx)
  22074. case msg.FieldToid:
  22075. return m.OldToid(ctx)
  22076. case msg.FieldMsgtype:
  22077. return m.OldMsgtype(ctx)
  22078. case msg.FieldMsg:
  22079. return m.OldMsg(ctx)
  22080. case msg.FieldBatchNo:
  22081. return m.OldBatchNo(ctx)
  22082. case msg.FieldCc:
  22083. return m.OldCc(ctx)
  22084. case msg.FieldPhone:
  22085. return m.OldPhone(ctx)
  22086. }
  22087. return nil, fmt.Errorf("unknown Msg field %s", name)
  22088. }
  22089. // SetField sets the value of a field with the given name. It returns an error if
  22090. // the field is not defined in the schema, or if the type mismatched the field
  22091. // type.
  22092. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  22093. switch name {
  22094. case msg.FieldCreatedAt:
  22095. v, ok := value.(time.Time)
  22096. if !ok {
  22097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22098. }
  22099. m.SetCreatedAt(v)
  22100. return nil
  22101. case msg.FieldUpdatedAt:
  22102. v, ok := value.(time.Time)
  22103. if !ok {
  22104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22105. }
  22106. m.SetUpdatedAt(v)
  22107. return nil
  22108. case msg.FieldDeletedAt:
  22109. v, ok := value.(time.Time)
  22110. if !ok {
  22111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22112. }
  22113. m.SetDeletedAt(v)
  22114. return nil
  22115. case msg.FieldStatus:
  22116. v, ok := value.(uint8)
  22117. if !ok {
  22118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22119. }
  22120. m.SetStatus(v)
  22121. return nil
  22122. case msg.FieldFromwxid:
  22123. v, ok := value.(string)
  22124. if !ok {
  22125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22126. }
  22127. m.SetFromwxid(v)
  22128. return nil
  22129. case msg.FieldToid:
  22130. v, ok := value.(string)
  22131. if !ok {
  22132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22133. }
  22134. m.SetToid(v)
  22135. return nil
  22136. case msg.FieldMsgtype:
  22137. v, ok := value.(int32)
  22138. if !ok {
  22139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22140. }
  22141. m.SetMsgtype(v)
  22142. return nil
  22143. case msg.FieldMsg:
  22144. v, ok := value.(string)
  22145. if !ok {
  22146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22147. }
  22148. m.SetMsg(v)
  22149. return nil
  22150. case msg.FieldBatchNo:
  22151. v, ok := value.(string)
  22152. if !ok {
  22153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22154. }
  22155. m.SetBatchNo(v)
  22156. return nil
  22157. case msg.FieldCc:
  22158. v, ok := value.(string)
  22159. if !ok {
  22160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22161. }
  22162. m.SetCc(v)
  22163. return nil
  22164. case msg.FieldPhone:
  22165. v, ok := value.(string)
  22166. if !ok {
  22167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22168. }
  22169. m.SetPhone(v)
  22170. return nil
  22171. }
  22172. return fmt.Errorf("unknown Msg field %s", name)
  22173. }
  22174. // AddedFields returns all numeric fields that were incremented/decremented during
  22175. // this mutation.
  22176. func (m *MsgMutation) AddedFields() []string {
  22177. var fields []string
  22178. if m.addstatus != nil {
  22179. fields = append(fields, msg.FieldStatus)
  22180. }
  22181. if m.addmsgtype != nil {
  22182. fields = append(fields, msg.FieldMsgtype)
  22183. }
  22184. return fields
  22185. }
  22186. // AddedField returns the numeric value that was incremented/decremented on a field
  22187. // with the given name. The second boolean return value indicates that this field
  22188. // was not set, or was not defined in the schema.
  22189. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  22190. switch name {
  22191. case msg.FieldStatus:
  22192. return m.AddedStatus()
  22193. case msg.FieldMsgtype:
  22194. return m.AddedMsgtype()
  22195. }
  22196. return nil, false
  22197. }
  22198. // AddField adds the value to the field with the given name. It returns an error if
  22199. // the field is not defined in the schema, or if the type mismatched the field
  22200. // type.
  22201. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  22202. switch name {
  22203. case msg.FieldStatus:
  22204. v, ok := value.(int8)
  22205. if !ok {
  22206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22207. }
  22208. m.AddStatus(v)
  22209. return nil
  22210. case msg.FieldMsgtype:
  22211. v, ok := value.(int32)
  22212. if !ok {
  22213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22214. }
  22215. m.AddMsgtype(v)
  22216. return nil
  22217. }
  22218. return fmt.Errorf("unknown Msg numeric field %s", name)
  22219. }
  22220. // ClearedFields returns all nullable fields that were cleared during this
  22221. // mutation.
  22222. func (m *MsgMutation) ClearedFields() []string {
  22223. var fields []string
  22224. if m.FieldCleared(msg.FieldDeletedAt) {
  22225. fields = append(fields, msg.FieldDeletedAt)
  22226. }
  22227. if m.FieldCleared(msg.FieldStatus) {
  22228. fields = append(fields, msg.FieldStatus)
  22229. }
  22230. if m.FieldCleared(msg.FieldFromwxid) {
  22231. fields = append(fields, msg.FieldFromwxid)
  22232. }
  22233. if m.FieldCleared(msg.FieldToid) {
  22234. fields = append(fields, msg.FieldToid)
  22235. }
  22236. if m.FieldCleared(msg.FieldMsgtype) {
  22237. fields = append(fields, msg.FieldMsgtype)
  22238. }
  22239. if m.FieldCleared(msg.FieldMsg) {
  22240. fields = append(fields, msg.FieldMsg)
  22241. }
  22242. if m.FieldCleared(msg.FieldBatchNo) {
  22243. fields = append(fields, msg.FieldBatchNo)
  22244. }
  22245. return fields
  22246. }
  22247. // FieldCleared returns a boolean indicating if a field with the given name was
  22248. // cleared in this mutation.
  22249. func (m *MsgMutation) FieldCleared(name string) bool {
  22250. _, ok := m.clearedFields[name]
  22251. return ok
  22252. }
  22253. // ClearField clears the value of the field with the given name. It returns an
  22254. // error if the field is not defined in the schema.
  22255. func (m *MsgMutation) ClearField(name string) error {
  22256. switch name {
  22257. case msg.FieldDeletedAt:
  22258. m.ClearDeletedAt()
  22259. return nil
  22260. case msg.FieldStatus:
  22261. m.ClearStatus()
  22262. return nil
  22263. case msg.FieldFromwxid:
  22264. m.ClearFromwxid()
  22265. return nil
  22266. case msg.FieldToid:
  22267. m.ClearToid()
  22268. return nil
  22269. case msg.FieldMsgtype:
  22270. m.ClearMsgtype()
  22271. return nil
  22272. case msg.FieldMsg:
  22273. m.ClearMsg()
  22274. return nil
  22275. case msg.FieldBatchNo:
  22276. m.ClearBatchNo()
  22277. return nil
  22278. }
  22279. return fmt.Errorf("unknown Msg nullable field %s", name)
  22280. }
  22281. // ResetField resets all changes in the mutation for the field with the given name.
  22282. // It returns an error if the field is not defined in the schema.
  22283. func (m *MsgMutation) ResetField(name string) error {
  22284. switch name {
  22285. case msg.FieldCreatedAt:
  22286. m.ResetCreatedAt()
  22287. return nil
  22288. case msg.FieldUpdatedAt:
  22289. m.ResetUpdatedAt()
  22290. return nil
  22291. case msg.FieldDeletedAt:
  22292. m.ResetDeletedAt()
  22293. return nil
  22294. case msg.FieldStatus:
  22295. m.ResetStatus()
  22296. return nil
  22297. case msg.FieldFromwxid:
  22298. m.ResetFromwxid()
  22299. return nil
  22300. case msg.FieldToid:
  22301. m.ResetToid()
  22302. return nil
  22303. case msg.FieldMsgtype:
  22304. m.ResetMsgtype()
  22305. return nil
  22306. case msg.FieldMsg:
  22307. m.ResetMsg()
  22308. return nil
  22309. case msg.FieldBatchNo:
  22310. m.ResetBatchNo()
  22311. return nil
  22312. case msg.FieldCc:
  22313. m.ResetCc()
  22314. return nil
  22315. case msg.FieldPhone:
  22316. m.ResetPhone()
  22317. return nil
  22318. }
  22319. return fmt.Errorf("unknown Msg field %s", name)
  22320. }
  22321. // AddedEdges returns all edge names that were set/added in this mutation.
  22322. func (m *MsgMutation) AddedEdges() []string {
  22323. edges := make([]string, 0, 0)
  22324. return edges
  22325. }
  22326. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22327. // name in this mutation.
  22328. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  22329. return nil
  22330. }
  22331. // RemovedEdges returns all edge names that were removed in this mutation.
  22332. func (m *MsgMutation) RemovedEdges() []string {
  22333. edges := make([]string, 0, 0)
  22334. return edges
  22335. }
  22336. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22337. // the given name in this mutation.
  22338. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  22339. return nil
  22340. }
  22341. // ClearedEdges returns all edge names that were cleared in this mutation.
  22342. func (m *MsgMutation) ClearedEdges() []string {
  22343. edges := make([]string, 0, 0)
  22344. return edges
  22345. }
  22346. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22347. // was cleared in this mutation.
  22348. func (m *MsgMutation) EdgeCleared(name string) bool {
  22349. return false
  22350. }
  22351. // ClearEdge clears the value of the edge with the given name. It returns an error
  22352. // if that edge is not defined in the schema.
  22353. func (m *MsgMutation) ClearEdge(name string) error {
  22354. return fmt.Errorf("unknown Msg unique edge %s", name)
  22355. }
  22356. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22357. // It returns an error if the edge is not defined in the schema.
  22358. func (m *MsgMutation) ResetEdge(name string) error {
  22359. return fmt.Errorf("unknown Msg edge %s", name)
  22360. }
  22361. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  22362. type PayRechargeMutation struct {
  22363. config
  22364. op Op
  22365. typ string
  22366. id *uint64
  22367. created_at *time.Time
  22368. updated_at *time.Time
  22369. deleted_at *time.Time
  22370. user_id *string
  22371. number *float32
  22372. addnumber *float32
  22373. status *int
  22374. addstatus *int
  22375. money *float32
  22376. addmoney *float32
  22377. out_trade_no *string
  22378. organization_id *uint64
  22379. addorganization_id *int64
  22380. clearedFields map[string]struct{}
  22381. done bool
  22382. oldValue func(context.Context) (*PayRecharge, error)
  22383. predicates []predicate.PayRecharge
  22384. }
  22385. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  22386. // payrechargeOption allows management of the mutation configuration using functional options.
  22387. type payrechargeOption func(*PayRechargeMutation)
  22388. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  22389. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  22390. m := &PayRechargeMutation{
  22391. config: c,
  22392. op: op,
  22393. typ: TypePayRecharge,
  22394. clearedFields: make(map[string]struct{}),
  22395. }
  22396. for _, opt := range opts {
  22397. opt(m)
  22398. }
  22399. return m
  22400. }
  22401. // withPayRechargeID sets the ID field of the mutation.
  22402. func withPayRechargeID(id uint64) payrechargeOption {
  22403. return func(m *PayRechargeMutation) {
  22404. var (
  22405. err error
  22406. once sync.Once
  22407. value *PayRecharge
  22408. )
  22409. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  22410. once.Do(func() {
  22411. if m.done {
  22412. err = errors.New("querying old values post mutation is not allowed")
  22413. } else {
  22414. value, err = m.Client().PayRecharge.Get(ctx, id)
  22415. }
  22416. })
  22417. return value, err
  22418. }
  22419. m.id = &id
  22420. }
  22421. }
  22422. // withPayRecharge sets the old PayRecharge of the mutation.
  22423. func withPayRecharge(node *PayRecharge) payrechargeOption {
  22424. return func(m *PayRechargeMutation) {
  22425. m.oldValue = func(context.Context) (*PayRecharge, error) {
  22426. return node, nil
  22427. }
  22428. m.id = &node.ID
  22429. }
  22430. }
  22431. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22432. // executed in a transaction (ent.Tx), a transactional client is returned.
  22433. func (m PayRechargeMutation) Client() *Client {
  22434. client := &Client{config: m.config}
  22435. client.init()
  22436. return client
  22437. }
  22438. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22439. // it returns an error otherwise.
  22440. func (m PayRechargeMutation) Tx() (*Tx, error) {
  22441. if _, ok := m.driver.(*txDriver); !ok {
  22442. return nil, errors.New("ent: mutation is not running in a transaction")
  22443. }
  22444. tx := &Tx{config: m.config}
  22445. tx.init()
  22446. return tx, nil
  22447. }
  22448. // SetID sets the value of the id field. Note that this
  22449. // operation is only accepted on creation of PayRecharge entities.
  22450. func (m *PayRechargeMutation) SetID(id uint64) {
  22451. m.id = &id
  22452. }
  22453. // ID returns the ID value in the mutation. Note that the ID is only available
  22454. // if it was provided to the builder or after it was returned from the database.
  22455. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  22456. if m.id == nil {
  22457. return
  22458. }
  22459. return *m.id, true
  22460. }
  22461. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22462. // That means, if the mutation is applied within a transaction with an isolation level such
  22463. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22464. // or updated by the mutation.
  22465. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  22466. switch {
  22467. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22468. id, exists := m.ID()
  22469. if exists {
  22470. return []uint64{id}, nil
  22471. }
  22472. fallthrough
  22473. case m.op.Is(OpUpdate | OpDelete):
  22474. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  22475. default:
  22476. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22477. }
  22478. }
  22479. // SetCreatedAt sets the "created_at" field.
  22480. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  22481. m.created_at = &t
  22482. }
  22483. // CreatedAt returns the value of the "created_at" field in the mutation.
  22484. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  22485. v := m.created_at
  22486. if v == nil {
  22487. return
  22488. }
  22489. return *v, true
  22490. }
  22491. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  22492. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22494. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22495. if !m.op.Is(OpUpdateOne) {
  22496. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22497. }
  22498. if m.id == nil || m.oldValue == nil {
  22499. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22500. }
  22501. oldValue, err := m.oldValue(ctx)
  22502. if err != nil {
  22503. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22504. }
  22505. return oldValue.CreatedAt, nil
  22506. }
  22507. // ResetCreatedAt resets all changes to the "created_at" field.
  22508. func (m *PayRechargeMutation) ResetCreatedAt() {
  22509. m.created_at = nil
  22510. }
  22511. // SetUpdatedAt sets the "updated_at" field.
  22512. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  22513. m.updated_at = &t
  22514. }
  22515. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22516. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  22517. v := m.updated_at
  22518. if v == nil {
  22519. return
  22520. }
  22521. return *v, true
  22522. }
  22523. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  22524. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22526. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22527. if !m.op.Is(OpUpdateOne) {
  22528. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22529. }
  22530. if m.id == nil || m.oldValue == nil {
  22531. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22532. }
  22533. oldValue, err := m.oldValue(ctx)
  22534. if err != nil {
  22535. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22536. }
  22537. return oldValue.UpdatedAt, nil
  22538. }
  22539. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22540. func (m *PayRechargeMutation) ResetUpdatedAt() {
  22541. m.updated_at = nil
  22542. }
  22543. // SetDeletedAt sets the "deleted_at" field.
  22544. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  22545. m.deleted_at = &t
  22546. }
  22547. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22548. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  22549. v := m.deleted_at
  22550. if v == nil {
  22551. return
  22552. }
  22553. return *v, true
  22554. }
  22555. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  22556. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22558. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22559. if !m.op.Is(OpUpdateOne) {
  22560. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22561. }
  22562. if m.id == nil || m.oldValue == nil {
  22563. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22564. }
  22565. oldValue, err := m.oldValue(ctx)
  22566. if err != nil {
  22567. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22568. }
  22569. return oldValue.DeletedAt, nil
  22570. }
  22571. // ClearDeletedAt clears the value of the "deleted_at" field.
  22572. func (m *PayRechargeMutation) ClearDeletedAt() {
  22573. m.deleted_at = nil
  22574. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  22575. }
  22576. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22577. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  22578. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  22579. return ok
  22580. }
  22581. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22582. func (m *PayRechargeMutation) ResetDeletedAt() {
  22583. m.deleted_at = nil
  22584. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  22585. }
  22586. // SetUserID sets the "user_id" field.
  22587. func (m *PayRechargeMutation) SetUserID(s string) {
  22588. m.user_id = &s
  22589. }
  22590. // UserID returns the value of the "user_id" field in the mutation.
  22591. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  22592. v := m.user_id
  22593. if v == nil {
  22594. return
  22595. }
  22596. return *v, true
  22597. }
  22598. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  22599. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22601. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  22602. if !m.op.Is(OpUpdateOne) {
  22603. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  22604. }
  22605. if m.id == nil || m.oldValue == nil {
  22606. return v, errors.New("OldUserID requires an ID field in the mutation")
  22607. }
  22608. oldValue, err := m.oldValue(ctx)
  22609. if err != nil {
  22610. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  22611. }
  22612. return oldValue.UserID, nil
  22613. }
  22614. // ResetUserID resets all changes to the "user_id" field.
  22615. func (m *PayRechargeMutation) ResetUserID() {
  22616. m.user_id = nil
  22617. }
  22618. // SetNumber sets the "number" field.
  22619. func (m *PayRechargeMutation) SetNumber(f float32) {
  22620. m.number = &f
  22621. m.addnumber = nil
  22622. }
  22623. // Number returns the value of the "number" field in the mutation.
  22624. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  22625. v := m.number
  22626. if v == nil {
  22627. return
  22628. }
  22629. return *v, true
  22630. }
  22631. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  22632. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22634. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  22635. if !m.op.Is(OpUpdateOne) {
  22636. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  22637. }
  22638. if m.id == nil || m.oldValue == nil {
  22639. return v, errors.New("OldNumber requires an ID field in the mutation")
  22640. }
  22641. oldValue, err := m.oldValue(ctx)
  22642. if err != nil {
  22643. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  22644. }
  22645. return oldValue.Number, nil
  22646. }
  22647. // AddNumber adds f to the "number" field.
  22648. func (m *PayRechargeMutation) AddNumber(f float32) {
  22649. if m.addnumber != nil {
  22650. *m.addnumber += f
  22651. } else {
  22652. m.addnumber = &f
  22653. }
  22654. }
  22655. // AddedNumber returns the value that was added to the "number" field in this mutation.
  22656. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  22657. v := m.addnumber
  22658. if v == nil {
  22659. return
  22660. }
  22661. return *v, true
  22662. }
  22663. // ResetNumber resets all changes to the "number" field.
  22664. func (m *PayRechargeMutation) ResetNumber() {
  22665. m.number = nil
  22666. m.addnumber = nil
  22667. }
  22668. // SetStatus sets the "status" field.
  22669. func (m *PayRechargeMutation) SetStatus(i int) {
  22670. m.status = &i
  22671. m.addstatus = nil
  22672. }
  22673. // Status returns the value of the "status" field in the mutation.
  22674. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  22675. v := m.status
  22676. if v == nil {
  22677. return
  22678. }
  22679. return *v, true
  22680. }
  22681. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  22682. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22684. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  22685. if !m.op.Is(OpUpdateOne) {
  22686. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22687. }
  22688. if m.id == nil || m.oldValue == nil {
  22689. return v, errors.New("OldStatus requires an ID field in the mutation")
  22690. }
  22691. oldValue, err := m.oldValue(ctx)
  22692. if err != nil {
  22693. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22694. }
  22695. return oldValue.Status, nil
  22696. }
  22697. // AddStatus adds i to the "status" field.
  22698. func (m *PayRechargeMutation) AddStatus(i int) {
  22699. if m.addstatus != nil {
  22700. *m.addstatus += i
  22701. } else {
  22702. m.addstatus = &i
  22703. }
  22704. }
  22705. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22706. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  22707. v := m.addstatus
  22708. if v == nil {
  22709. return
  22710. }
  22711. return *v, true
  22712. }
  22713. // ClearStatus clears the value of the "status" field.
  22714. func (m *PayRechargeMutation) ClearStatus() {
  22715. m.status = nil
  22716. m.addstatus = nil
  22717. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  22718. }
  22719. // StatusCleared returns if the "status" field was cleared in this mutation.
  22720. func (m *PayRechargeMutation) StatusCleared() bool {
  22721. _, ok := m.clearedFields[payrecharge.FieldStatus]
  22722. return ok
  22723. }
  22724. // ResetStatus resets all changes to the "status" field.
  22725. func (m *PayRechargeMutation) ResetStatus() {
  22726. m.status = nil
  22727. m.addstatus = nil
  22728. delete(m.clearedFields, payrecharge.FieldStatus)
  22729. }
  22730. // SetMoney sets the "money" field.
  22731. func (m *PayRechargeMutation) SetMoney(f float32) {
  22732. m.money = &f
  22733. m.addmoney = nil
  22734. }
  22735. // Money returns the value of the "money" field in the mutation.
  22736. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  22737. v := m.money
  22738. if v == nil {
  22739. return
  22740. }
  22741. return *v, true
  22742. }
  22743. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  22744. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22746. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  22747. if !m.op.Is(OpUpdateOne) {
  22748. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  22749. }
  22750. if m.id == nil || m.oldValue == nil {
  22751. return v, errors.New("OldMoney requires an ID field in the mutation")
  22752. }
  22753. oldValue, err := m.oldValue(ctx)
  22754. if err != nil {
  22755. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  22756. }
  22757. return oldValue.Money, nil
  22758. }
  22759. // AddMoney adds f to the "money" field.
  22760. func (m *PayRechargeMutation) AddMoney(f float32) {
  22761. if m.addmoney != nil {
  22762. *m.addmoney += f
  22763. } else {
  22764. m.addmoney = &f
  22765. }
  22766. }
  22767. // AddedMoney returns the value that was added to the "money" field in this mutation.
  22768. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  22769. v := m.addmoney
  22770. if v == nil {
  22771. return
  22772. }
  22773. return *v, true
  22774. }
  22775. // ClearMoney clears the value of the "money" field.
  22776. func (m *PayRechargeMutation) ClearMoney() {
  22777. m.money = nil
  22778. m.addmoney = nil
  22779. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  22780. }
  22781. // MoneyCleared returns if the "money" field was cleared in this mutation.
  22782. func (m *PayRechargeMutation) MoneyCleared() bool {
  22783. _, ok := m.clearedFields[payrecharge.FieldMoney]
  22784. return ok
  22785. }
  22786. // ResetMoney resets all changes to the "money" field.
  22787. func (m *PayRechargeMutation) ResetMoney() {
  22788. m.money = nil
  22789. m.addmoney = nil
  22790. delete(m.clearedFields, payrecharge.FieldMoney)
  22791. }
  22792. // SetOutTradeNo sets the "out_trade_no" field.
  22793. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  22794. m.out_trade_no = &s
  22795. }
  22796. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  22797. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  22798. v := m.out_trade_no
  22799. if v == nil {
  22800. return
  22801. }
  22802. return *v, true
  22803. }
  22804. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  22805. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22807. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  22808. if !m.op.Is(OpUpdateOne) {
  22809. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  22810. }
  22811. if m.id == nil || m.oldValue == nil {
  22812. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  22813. }
  22814. oldValue, err := m.oldValue(ctx)
  22815. if err != nil {
  22816. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  22817. }
  22818. return oldValue.OutTradeNo, nil
  22819. }
  22820. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  22821. func (m *PayRechargeMutation) ClearOutTradeNo() {
  22822. m.out_trade_no = nil
  22823. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  22824. }
  22825. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  22826. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  22827. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  22828. return ok
  22829. }
  22830. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  22831. func (m *PayRechargeMutation) ResetOutTradeNo() {
  22832. m.out_trade_no = nil
  22833. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  22834. }
  22835. // SetOrganizationID sets the "organization_id" field.
  22836. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  22837. m.organization_id = &u
  22838. m.addorganization_id = nil
  22839. }
  22840. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22841. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  22842. v := m.organization_id
  22843. if v == nil {
  22844. return
  22845. }
  22846. return *v, true
  22847. }
  22848. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  22849. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  22850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22851. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22852. if !m.op.Is(OpUpdateOne) {
  22853. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22854. }
  22855. if m.id == nil || m.oldValue == nil {
  22856. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22857. }
  22858. oldValue, err := m.oldValue(ctx)
  22859. if err != nil {
  22860. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22861. }
  22862. return oldValue.OrganizationID, nil
  22863. }
  22864. // AddOrganizationID adds u to the "organization_id" field.
  22865. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  22866. if m.addorganization_id != nil {
  22867. *m.addorganization_id += u
  22868. } else {
  22869. m.addorganization_id = &u
  22870. }
  22871. }
  22872. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22873. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  22874. v := m.addorganization_id
  22875. if v == nil {
  22876. return
  22877. }
  22878. return *v, true
  22879. }
  22880. // ResetOrganizationID resets all changes to the "organization_id" field.
  22881. func (m *PayRechargeMutation) ResetOrganizationID() {
  22882. m.organization_id = nil
  22883. m.addorganization_id = nil
  22884. }
  22885. // Where appends a list predicates to the PayRechargeMutation builder.
  22886. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  22887. m.predicates = append(m.predicates, ps...)
  22888. }
  22889. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  22890. // users can use type-assertion to append predicates that do not depend on any generated package.
  22891. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  22892. p := make([]predicate.PayRecharge, len(ps))
  22893. for i := range ps {
  22894. p[i] = ps[i]
  22895. }
  22896. m.Where(p...)
  22897. }
  22898. // Op returns the operation name.
  22899. func (m *PayRechargeMutation) Op() Op {
  22900. return m.op
  22901. }
  22902. // SetOp allows setting the mutation operation.
  22903. func (m *PayRechargeMutation) SetOp(op Op) {
  22904. m.op = op
  22905. }
  22906. // Type returns the node type of this mutation (PayRecharge).
  22907. func (m *PayRechargeMutation) Type() string {
  22908. return m.typ
  22909. }
  22910. // Fields returns all fields that were changed during this mutation. Note that in
  22911. // order to get all numeric fields that were incremented/decremented, call
  22912. // AddedFields().
  22913. func (m *PayRechargeMutation) Fields() []string {
  22914. fields := make([]string, 0, 9)
  22915. if m.created_at != nil {
  22916. fields = append(fields, payrecharge.FieldCreatedAt)
  22917. }
  22918. if m.updated_at != nil {
  22919. fields = append(fields, payrecharge.FieldUpdatedAt)
  22920. }
  22921. if m.deleted_at != nil {
  22922. fields = append(fields, payrecharge.FieldDeletedAt)
  22923. }
  22924. if m.user_id != nil {
  22925. fields = append(fields, payrecharge.FieldUserID)
  22926. }
  22927. if m.number != nil {
  22928. fields = append(fields, payrecharge.FieldNumber)
  22929. }
  22930. if m.status != nil {
  22931. fields = append(fields, payrecharge.FieldStatus)
  22932. }
  22933. if m.money != nil {
  22934. fields = append(fields, payrecharge.FieldMoney)
  22935. }
  22936. if m.out_trade_no != nil {
  22937. fields = append(fields, payrecharge.FieldOutTradeNo)
  22938. }
  22939. if m.organization_id != nil {
  22940. fields = append(fields, payrecharge.FieldOrganizationID)
  22941. }
  22942. return fields
  22943. }
  22944. // Field returns the value of a field with the given name. The second boolean
  22945. // return value indicates that this field was not set, or was not defined in the
  22946. // schema.
  22947. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  22948. switch name {
  22949. case payrecharge.FieldCreatedAt:
  22950. return m.CreatedAt()
  22951. case payrecharge.FieldUpdatedAt:
  22952. return m.UpdatedAt()
  22953. case payrecharge.FieldDeletedAt:
  22954. return m.DeletedAt()
  22955. case payrecharge.FieldUserID:
  22956. return m.UserID()
  22957. case payrecharge.FieldNumber:
  22958. return m.Number()
  22959. case payrecharge.FieldStatus:
  22960. return m.Status()
  22961. case payrecharge.FieldMoney:
  22962. return m.Money()
  22963. case payrecharge.FieldOutTradeNo:
  22964. return m.OutTradeNo()
  22965. case payrecharge.FieldOrganizationID:
  22966. return m.OrganizationID()
  22967. }
  22968. return nil, false
  22969. }
  22970. // OldField returns the old value of the field from the database. An error is
  22971. // returned if the mutation operation is not UpdateOne, or the query to the
  22972. // database failed.
  22973. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22974. switch name {
  22975. case payrecharge.FieldCreatedAt:
  22976. return m.OldCreatedAt(ctx)
  22977. case payrecharge.FieldUpdatedAt:
  22978. return m.OldUpdatedAt(ctx)
  22979. case payrecharge.FieldDeletedAt:
  22980. return m.OldDeletedAt(ctx)
  22981. case payrecharge.FieldUserID:
  22982. return m.OldUserID(ctx)
  22983. case payrecharge.FieldNumber:
  22984. return m.OldNumber(ctx)
  22985. case payrecharge.FieldStatus:
  22986. return m.OldStatus(ctx)
  22987. case payrecharge.FieldMoney:
  22988. return m.OldMoney(ctx)
  22989. case payrecharge.FieldOutTradeNo:
  22990. return m.OldOutTradeNo(ctx)
  22991. case payrecharge.FieldOrganizationID:
  22992. return m.OldOrganizationID(ctx)
  22993. }
  22994. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  22995. }
  22996. // SetField sets the value of a field with the given name. It returns an error if
  22997. // the field is not defined in the schema, or if the type mismatched the field
  22998. // type.
  22999. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  23000. switch name {
  23001. case payrecharge.FieldCreatedAt:
  23002. v, ok := value.(time.Time)
  23003. if !ok {
  23004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23005. }
  23006. m.SetCreatedAt(v)
  23007. return nil
  23008. case payrecharge.FieldUpdatedAt:
  23009. v, ok := value.(time.Time)
  23010. if !ok {
  23011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23012. }
  23013. m.SetUpdatedAt(v)
  23014. return nil
  23015. case payrecharge.FieldDeletedAt:
  23016. v, ok := value.(time.Time)
  23017. if !ok {
  23018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23019. }
  23020. m.SetDeletedAt(v)
  23021. return nil
  23022. case payrecharge.FieldUserID:
  23023. v, ok := value.(string)
  23024. if !ok {
  23025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23026. }
  23027. m.SetUserID(v)
  23028. return nil
  23029. case payrecharge.FieldNumber:
  23030. v, ok := value.(float32)
  23031. if !ok {
  23032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23033. }
  23034. m.SetNumber(v)
  23035. return nil
  23036. case payrecharge.FieldStatus:
  23037. v, ok := value.(int)
  23038. if !ok {
  23039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23040. }
  23041. m.SetStatus(v)
  23042. return nil
  23043. case payrecharge.FieldMoney:
  23044. v, ok := value.(float32)
  23045. if !ok {
  23046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23047. }
  23048. m.SetMoney(v)
  23049. return nil
  23050. case payrecharge.FieldOutTradeNo:
  23051. v, ok := value.(string)
  23052. if !ok {
  23053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23054. }
  23055. m.SetOutTradeNo(v)
  23056. return nil
  23057. case payrecharge.FieldOrganizationID:
  23058. v, ok := value.(uint64)
  23059. if !ok {
  23060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23061. }
  23062. m.SetOrganizationID(v)
  23063. return nil
  23064. }
  23065. return fmt.Errorf("unknown PayRecharge field %s", name)
  23066. }
  23067. // AddedFields returns all numeric fields that were incremented/decremented during
  23068. // this mutation.
  23069. func (m *PayRechargeMutation) AddedFields() []string {
  23070. var fields []string
  23071. if m.addnumber != nil {
  23072. fields = append(fields, payrecharge.FieldNumber)
  23073. }
  23074. if m.addstatus != nil {
  23075. fields = append(fields, payrecharge.FieldStatus)
  23076. }
  23077. if m.addmoney != nil {
  23078. fields = append(fields, payrecharge.FieldMoney)
  23079. }
  23080. if m.addorganization_id != nil {
  23081. fields = append(fields, payrecharge.FieldOrganizationID)
  23082. }
  23083. return fields
  23084. }
  23085. // AddedField returns the numeric value that was incremented/decremented on a field
  23086. // with the given name. The second boolean return value indicates that this field
  23087. // was not set, or was not defined in the schema.
  23088. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  23089. switch name {
  23090. case payrecharge.FieldNumber:
  23091. return m.AddedNumber()
  23092. case payrecharge.FieldStatus:
  23093. return m.AddedStatus()
  23094. case payrecharge.FieldMoney:
  23095. return m.AddedMoney()
  23096. case payrecharge.FieldOrganizationID:
  23097. return m.AddedOrganizationID()
  23098. }
  23099. return nil, false
  23100. }
  23101. // AddField adds the value to the field with the given name. It returns an error if
  23102. // the field is not defined in the schema, or if the type mismatched the field
  23103. // type.
  23104. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  23105. switch name {
  23106. case payrecharge.FieldNumber:
  23107. v, ok := value.(float32)
  23108. if !ok {
  23109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23110. }
  23111. m.AddNumber(v)
  23112. return nil
  23113. case payrecharge.FieldStatus:
  23114. v, ok := value.(int)
  23115. if !ok {
  23116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23117. }
  23118. m.AddStatus(v)
  23119. return nil
  23120. case payrecharge.FieldMoney:
  23121. v, ok := value.(float32)
  23122. if !ok {
  23123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23124. }
  23125. m.AddMoney(v)
  23126. return nil
  23127. case payrecharge.FieldOrganizationID:
  23128. v, ok := value.(int64)
  23129. if !ok {
  23130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23131. }
  23132. m.AddOrganizationID(v)
  23133. return nil
  23134. }
  23135. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  23136. }
  23137. // ClearedFields returns all nullable fields that were cleared during this
  23138. // mutation.
  23139. func (m *PayRechargeMutation) ClearedFields() []string {
  23140. var fields []string
  23141. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  23142. fields = append(fields, payrecharge.FieldDeletedAt)
  23143. }
  23144. if m.FieldCleared(payrecharge.FieldStatus) {
  23145. fields = append(fields, payrecharge.FieldStatus)
  23146. }
  23147. if m.FieldCleared(payrecharge.FieldMoney) {
  23148. fields = append(fields, payrecharge.FieldMoney)
  23149. }
  23150. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  23151. fields = append(fields, payrecharge.FieldOutTradeNo)
  23152. }
  23153. return fields
  23154. }
  23155. // FieldCleared returns a boolean indicating if a field with the given name was
  23156. // cleared in this mutation.
  23157. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  23158. _, ok := m.clearedFields[name]
  23159. return ok
  23160. }
  23161. // ClearField clears the value of the field with the given name. It returns an
  23162. // error if the field is not defined in the schema.
  23163. func (m *PayRechargeMutation) ClearField(name string) error {
  23164. switch name {
  23165. case payrecharge.FieldDeletedAt:
  23166. m.ClearDeletedAt()
  23167. return nil
  23168. case payrecharge.FieldStatus:
  23169. m.ClearStatus()
  23170. return nil
  23171. case payrecharge.FieldMoney:
  23172. m.ClearMoney()
  23173. return nil
  23174. case payrecharge.FieldOutTradeNo:
  23175. m.ClearOutTradeNo()
  23176. return nil
  23177. }
  23178. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  23179. }
  23180. // ResetField resets all changes in the mutation for the field with the given name.
  23181. // It returns an error if the field is not defined in the schema.
  23182. func (m *PayRechargeMutation) ResetField(name string) error {
  23183. switch name {
  23184. case payrecharge.FieldCreatedAt:
  23185. m.ResetCreatedAt()
  23186. return nil
  23187. case payrecharge.FieldUpdatedAt:
  23188. m.ResetUpdatedAt()
  23189. return nil
  23190. case payrecharge.FieldDeletedAt:
  23191. m.ResetDeletedAt()
  23192. return nil
  23193. case payrecharge.FieldUserID:
  23194. m.ResetUserID()
  23195. return nil
  23196. case payrecharge.FieldNumber:
  23197. m.ResetNumber()
  23198. return nil
  23199. case payrecharge.FieldStatus:
  23200. m.ResetStatus()
  23201. return nil
  23202. case payrecharge.FieldMoney:
  23203. m.ResetMoney()
  23204. return nil
  23205. case payrecharge.FieldOutTradeNo:
  23206. m.ResetOutTradeNo()
  23207. return nil
  23208. case payrecharge.FieldOrganizationID:
  23209. m.ResetOrganizationID()
  23210. return nil
  23211. }
  23212. return fmt.Errorf("unknown PayRecharge field %s", name)
  23213. }
  23214. // AddedEdges returns all edge names that were set/added in this mutation.
  23215. func (m *PayRechargeMutation) AddedEdges() []string {
  23216. edges := make([]string, 0, 0)
  23217. return edges
  23218. }
  23219. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23220. // name in this mutation.
  23221. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  23222. return nil
  23223. }
  23224. // RemovedEdges returns all edge names that were removed in this mutation.
  23225. func (m *PayRechargeMutation) RemovedEdges() []string {
  23226. edges := make([]string, 0, 0)
  23227. return edges
  23228. }
  23229. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23230. // the given name in this mutation.
  23231. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  23232. return nil
  23233. }
  23234. // ClearedEdges returns all edge names that were cleared in this mutation.
  23235. func (m *PayRechargeMutation) ClearedEdges() []string {
  23236. edges := make([]string, 0, 0)
  23237. return edges
  23238. }
  23239. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23240. // was cleared in this mutation.
  23241. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  23242. return false
  23243. }
  23244. // ClearEdge clears the value of the edge with the given name. It returns an error
  23245. // if that edge is not defined in the schema.
  23246. func (m *PayRechargeMutation) ClearEdge(name string) error {
  23247. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  23248. }
  23249. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23250. // It returns an error if the edge is not defined in the schema.
  23251. func (m *PayRechargeMutation) ResetEdge(name string) error {
  23252. return fmt.Errorf("unknown PayRecharge edge %s", name)
  23253. }
  23254. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  23255. type ServerMutation struct {
  23256. config
  23257. op Op
  23258. typ string
  23259. id *uint64
  23260. created_at *time.Time
  23261. updated_at *time.Time
  23262. status *uint8
  23263. addstatus *int8
  23264. deleted_at *time.Time
  23265. name *string
  23266. public_ip *string
  23267. private_ip *string
  23268. admin_port *string
  23269. clearedFields map[string]struct{}
  23270. wxs map[uint64]struct{}
  23271. removedwxs map[uint64]struct{}
  23272. clearedwxs bool
  23273. done bool
  23274. oldValue func(context.Context) (*Server, error)
  23275. predicates []predicate.Server
  23276. }
  23277. var _ ent.Mutation = (*ServerMutation)(nil)
  23278. // serverOption allows management of the mutation configuration using functional options.
  23279. type serverOption func(*ServerMutation)
  23280. // newServerMutation creates new mutation for the Server entity.
  23281. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  23282. m := &ServerMutation{
  23283. config: c,
  23284. op: op,
  23285. typ: TypeServer,
  23286. clearedFields: make(map[string]struct{}),
  23287. }
  23288. for _, opt := range opts {
  23289. opt(m)
  23290. }
  23291. return m
  23292. }
  23293. // withServerID sets the ID field of the mutation.
  23294. func withServerID(id uint64) serverOption {
  23295. return func(m *ServerMutation) {
  23296. var (
  23297. err error
  23298. once sync.Once
  23299. value *Server
  23300. )
  23301. m.oldValue = func(ctx context.Context) (*Server, error) {
  23302. once.Do(func() {
  23303. if m.done {
  23304. err = errors.New("querying old values post mutation is not allowed")
  23305. } else {
  23306. value, err = m.Client().Server.Get(ctx, id)
  23307. }
  23308. })
  23309. return value, err
  23310. }
  23311. m.id = &id
  23312. }
  23313. }
  23314. // withServer sets the old Server of the mutation.
  23315. func withServer(node *Server) serverOption {
  23316. return func(m *ServerMutation) {
  23317. m.oldValue = func(context.Context) (*Server, error) {
  23318. return node, nil
  23319. }
  23320. m.id = &node.ID
  23321. }
  23322. }
  23323. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23324. // executed in a transaction (ent.Tx), a transactional client is returned.
  23325. func (m ServerMutation) Client() *Client {
  23326. client := &Client{config: m.config}
  23327. client.init()
  23328. return client
  23329. }
  23330. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23331. // it returns an error otherwise.
  23332. func (m ServerMutation) Tx() (*Tx, error) {
  23333. if _, ok := m.driver.(*txDriver); !ok {
  23334. return nil, errors.New("ent: mutation is not running in a transaction")
  23335. }
  23336. tx := &Tx{config: m.config}
  23337. tx.init()
  23338. return tx, nil
  23339. }
  23340. // SetID sets the value of the id field. Note that this
  23341. // operation is only accepted on creation of Server entities.
  23342. func (m *ServerMutation) SetID(id uint64) {
  23343. m.id = &id
  23344. }
  23345. // ID returns the ID value in the mutation. Note that the ID is only available
  23346. // if it was provided to the builder or after it was returned from the database.
  23347. func (m *ServerMutation) ID() (id uint64, exists bool) {
  23348. if m.id == nil {
  23349. return
  23350. }
  23351. return *m.id, true
  23352. }
  23353. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23354. // That means, if the mutation is applied within a transaction with an isolation level such
  23355. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23356. // or updated by the mutation.
  23357. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  23358. switch {
  23359. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23360. id, exists := m.ID()
  23361. if exists {
  23362. return []uint64{id}, nil
  23363. }
  23364. fallthrough
  23365. case m.op.Is(OpUpdate | OpDelete):
  23366. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  23367. default:
  23368. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23369. }
  23370. }
  23371. // SetCreatedAt sets the "created_at" field.
  23372. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  23373. m.created_at = &t
  23374. }
  23375. // CreatedAt returns the value of the "created_at" field in the mutation.
  23376. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  23377. v := m.created_at
  23378. if v == nil {
  23379. return
  23380. }
  23381. return *v, true
  23382. }
  23383. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  23384. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23386. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23387. if !m.op.Is(OpUpdateOne) {
  23388. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23389. }
  23390. if m.id == nil || m.oldValue == nil {
  23391. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23392. }
  23393. oldValue, err := m.oldValue(ctx)
  23394. if err != nil {
  23395. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23396. }
  23397. return oldValue.CreatedAt, nil
  23398. }
  23399. // ResetCreatedAt resets all changes to the "created_at" field.
  23400. func (m *ServerMutation) ResetCreatedAt() {
  23401. m.created_at = nil
  23402. }
  23403. // SetUpdatedAt sets the "updated_at" field.
  23404. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  23405. m.updated_at = &t
  23406. }
  23407. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23408. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  23409. v := m.updated_at
  23410. if v == nil {
  23411. return
  23412. }
  23413. return *v, true
  23414. }
  23415. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  23416. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23418. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23419. if !m.op.Is(OpUpdateOne) {
  23420. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23421. }
  23422. if m.id == nil || m.oldValue == nil {
  23423. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23424. }
  23425. oldValue, err := m.oldValue(ctx)
  23426. if err != nil {
  23427. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23428. }
  23429. return oldValue.UpdatedAt, nil
  23430. }
  23431. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23432. func (m *ServerMutation) ResetUpdatedAt() {
  23433. m.updated_at = nil
  23434. }
  23435. // SetStatus sets the "status" field.
  23436. func (m *ServerMutation) SetStatus(u uint8) {
  23437. m.status = &u
  23438. m.addstatus = nil
  23439. }
  23440. // Status returns the value of the "status" field in the mutation.
  23441. func (m *ServerMutation) Status() (r uint8, exists bool) {
  23442. v := m.status
  23443. if v == nil {
  23444. return
  23445. }
  23446. return *v, true
  23447. }
  23448. // OldStatus returns the old "status" field's value of the Server entity.
  23449. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23451. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23452. if !m.op.Is(OpUpdateOne) {
  23453. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23454. }
  23455. if m.id == nil || m.oldValue == nil {
  23456. return v, errors.New("OldStatus requires an ID field in the mutation")
  23457. }
  23458. oldValue, err := m.oldValue(ctx)
  23459. if err != nil {
  23460. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23461. }
  23462. return oldValue.Status, nil
  23463. }
  23464. // AddStatus adds u to the "status" field.
  23465. func (m *ServerMutation) AddStatus(u int8) {
  23466. if m.addstatus != nil {
  23467. *m.addstatus += u
  23468. } else {
  23469. m.addstatus = &u
  23470. }
  23471. }
  23472. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23473. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  23474. v := m.addstatus
  23475. if v == nil {
  23476. return
  23477. }
  23478. return *v, true
  23479. }
  23480. // ClearStatus clears the value of the "status" field.
  23481. func (m *ServerMutation) ClearStatus() {
  23482. m.status = nil
  23483. m.addstatus = nil
  23484. m.clearedFields[server.FieldStatus] = struct{}{}
  23485. }
  23486. // StatusCleared returns if the "status" field was cleared in this mutation.
  23487. func (m *ServerMutation) StatusCleared() bool {
  23488. _, ok := m.clearedFields[server.FieldStatus]
  23489. return ok
  23490. }
  23491. // ResetStatus resets all changes to the "status" field.
  23492. func (m *ServerMutation) ResetStatus() {
  23493. m.status = nil
  23494. m.addstatus = nil
  23495. delete(m.clearedFields, server.FieldStatus)
  23496. }
  23497. // SetDeletedAt sets the "deleted_at" field.
  23498. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  23499. m.deleted_at = &t
  23500. }
  23501. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23502. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  23503. v := m.deleted_at
  23504. if v == nil {
  23505. return
  23506. }
  23507. return *v, true
  23508. }
  23509. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  23510. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23512. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23513. if !m.op.Is(OpUpdateOne) {
  23514. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23515. }
  23516. if m.id == nil || m.oldValue == nil {
  23517. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23518. }
  23519. oldValue, err := m.oldValue(ctx)
  23520. if err != nil {
  23521. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23522. }
  23523. return oldValue.DeletedAt, nil
  23524. }
  23525. // ClearDeletedAt clears the value of the "deleted_at" field.
  23526. func (m *ServerMutation) ClearDeletedAt() {
  23527. m.deleted_at = nil
  23528. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  23529. }
  23530. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23531. func (m *ServerMutation) DeletedAtCleared() bool {
  23532. _, ok := m.clearedFields[server.FieldDeletedAt]
  23533. return ok
  23534. }
  23535. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23536. func (m *ServerMutation) ResetDeletedAt() {
  23537. m.deleted_at = nil
  23538. delete(m.clearedFields, server.FieldDeletedAt)
  23539. }
  23540. // SetName sets the "name" field.
  23541. func (m *ServerMutation) SetName(s string) {
  23542. m.name = &s
  23543. }
  23544. // Name returns the value of the "name" field in the mutation.
  23545. func (m *ServerMutation) Name() (r string, exists bool) {
  23546. v := m.name
  23547. if v == nil {
  23548. return
  23549. }
  23550. return *v, true
  23551. }
  23552. // OldName returns the old "name" field's value of the Server entity.
  23553. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23555. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  23556. if !m.op.Is(OpUpdateOne) {
  23557. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23558. }
  23559. if m.id == nil || m.oldValue == nil {
  23560. return v, errors.New("OldName requires an ID field in the mutation")
  23561. }
  23562. oldValue, err := m.oldValue(ctx)
  23563. if err != nil {
  23564. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23565. }
  23566. return oldValue.Name, nil
  23567. }
  23568. // ResetName resets all changes to the "name" field.
  23569. func (m *ServerMutation) ResetName() {
  23570. m.name = nil
  23571. }
  23572. // SetPublicIP sets the "public_ip" field.
  23573. func (m *ServerMutation) SetPublicIP(s string) {
  23574. m.public_ip = &s
  23575. }
  23576. // PublicIP returns the value of the "public_ip" field in the mutation.
  23577. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  23578. v := m.public_ip
  23579. if v == nil {
  23580. return
  23581. }
  23582. return *v, true
  23583. }
  23584. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  23585. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23587. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  23588. if !m.op.Is(OpUpdateOne) {
  23589. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  23590. }
  23591. if m.id == nil || m.oldValue == nil {
  23592. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  23593. }
  23594. oldValue, err := m.oldValue(ctx)
  23595. if err != nil {
  23596. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  23597. }
  23598. return oldValue.PublicIP, nil
  23599. }
  23600. // ResetPublicIP resets all changes to the "public_ip" field.
  23601. func (m *ServerMutation) ResetPublicIP() {
  23602. m.public_ip = nil
  23603. }
  23604. // SetPrivateIP sets the "private_ip" field.
  23605. func (m *ServerMutation) SetPrivateIP(s string) {
  23606. m.private_ip = &s
  23607. }
  23608. // PrivateIP returns the value of the "private_ip" field in the mutation.
  23609. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  23610. v := m.private_ip
  23611. if v == nil {
  23612. return
  23613. }
  23614. return *v, true
  23615. }
  23616. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  23617. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23619. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  23620. if !m.op.Is(OpUpdateOne) {
  23621. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  23622. }
  23623. if m.id == nil || m.oldValue == nil {
  23624. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  23625. }
  23626. oldValue, err := m.oldValue(ctx)
  23627. if err != nil {
  23628. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  23629. }
  23630. return oldValue.PrivateIP, nil
  23631. }
  23632. // ResetPrivateIP resets all changes to the "private_ip" field.
  23633. func (m *ServerMutation) ResetPrivateIP() {
  23634. m.private_ip = nil
  23635. }
  23636. // SetAdminPort sets the "admin_port" field.
  23637. func (m *ServerMutation) SetAdminPort(s string) {
  23638. m.admin_port = &s
  23639. }
  23640. // AdminPort returns the value of the "admin_port" field in the mutation.
  23641. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  23642. v := m.admin_port
  23643. if v == nil {
  23644. return
  23645. }
  23646. return *v, true
  23647. }
  23648. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  23649. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  23650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23651. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  23652. if !m.op.Is(OpUpdateOne) {
  23653. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  23654. }
  23655. if m.id == nil || m.oldValue == nil {
  23656. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  23657. }
  23658. oldValue, err := m.oldValue(ctx)
  23659. if err != nil {
  23660. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  23661. }
  23662. return oldValue.AdminPort, nil
  23663. }
  23664. // ResetAdminPort resets all changes to the "admin_port" field.
  23665. func (m *ServerMutation) ResetAdminPort() {
  23666. m.admin_port = nil
  23667. }
  23668. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  23669. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  23670. if m.wxs == nil {
  23671. m.wxs = make(map[uint64]struct{})
  23672. }
  23673. for i := range ids {
  23674. m.wxs[ids[i]] = struct{}{}
  23675. }
  23676. }
  23677. // ClearWxs clears the "wxs" edge to the Wx entity.
  23678. func (m *ServerMutation) ClearWxs() {
  23679. m.clearedwxs = true
  23680. }
  23681. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  23682. func (m *ServerMutation) WxsCleared() bool {
  23683. return m.clearedwxs
  23684. }
  23685. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  23686. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  23687. if m.removedwxs == nil {
  23688. m.removedwxs = make(map[uint64]struct{})
  23689. }
  23690. for i := range ids {
  23691. delete(m.wxs, ids[i])
  23692. m.removedwxs[ids[i]] = struct{}{}
  23693. }
  23694. }
  23695. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  23696. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  23697. for id := range m.removedwxs {
  23698. ids = append(ids, id)
  23699. }
  23700. return
  23701. }
  23702. // WxsIDs returns the "wxs" edge IDs in the mutation.
  23703. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  23704. for id := range m.wxs {
  23705. ids = append(ids, id)
  23706. }
  23707. return
  23708. }
  23709. // ResetWxs resets all changes to the "wxs" edge.
  23710. func (m *ServerMutation) ResetWxs() {
  23711. m.wxs = nil
  23712. m.clearedwxs = false
  23713. m.removedwxs = nil
  23714. }
  23715. // Where appends a list predicates to the ServerMutation builder.
  23716. func (m *ServerMutation) Where(ps ...predicate.Server) {
  23717. m.predicates = append(m.predicates, ps...)
  23718. }
  23719. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  23720. // users can use type-assertion to append predicates that do not depend on any generated package.
  23721. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  23722. p := make([]predicate.Server, len(ps))
  23723. for i := range ps {
  23724. p[i] = ps[i]
  23725. }
  23726. m.Where(p...)
  23727. }
  23728. // Op returns the operation name.
  23729. func (m *ServerMutation) Op() Op {
  23730. return m.op
  23731. }
  23732. // SetOp allows setting the mutation operation.
  23733. func (m *ServerMutation) SetOp(op Op) {
  23734. m.op = op
  23735. }
  23736. // Type returns the node type of this mutation (Server).
  23737. func (m *ServerMutation) Type() string {
  23738. return m.typ
  23739. }
  23740. // Fields returns all fields that were changed during this mutation. Note that in
  23741. // order to get all numeric fields that were incremented/decremented, call
  23742. // AddedFields().
  23743. func (m *ServerMutation) Fields() []string {
  23744. fields := make([]string, 0, 8)
  23745. if m.created_at != nil {
  23746. fields = append(fields, server.FieldCreatedAt)
  23747. }
  23748. if m.updated_at != nil {
  23749. fields = append(fields, server.FieldUpdatedAt)
  23750. }
  23751. if m.status != nil {
  23752. fields = append(fields, server.FieldStatus)
  23753. }
  23754. if m.deleted_at != nil {
  23755. fields = append(fields, server.FieldDeletedAt)
  23756. }
  23757. if m.name != nil {
  23758. fields = append(fields, server.FieldName)
  23759. }
  23760. if m.public_ip != nil {
  23761. fields = append(fields, server.FieldPublicIP)
  23762. }
  23763. if m.private_ip != nil {
  23764. fields = append(fields, server.FieldPrivateIP)
  23765. }
  23766. if m.admin_port != nil {
  23767. fields = append(fields, server.FieldAdminPort)
  23768. }
  23769. return fields
  23770. }
  23771. // Field returns the value of a field with the given name. The second boolean
  23772. // return value indicates that this field was not set, or was not defined in the
  23773. // schema.
  23774. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  23775. switch name {
  23776. case server.FieldCreatedAt:
  23777. return m.CreatedAt()
  23778. case server.FieldUpdatedAt:
  23779. return m.UpdatedAt()
  23780. case server.FieldStatus:
  23781. return m.Status()
  23782. case server.FieldDeletedAt:
  23783. return m.DeletedAt()
  23784. case server.FieldName:
  23785. return m.Name()
  23786. case server.FieldPublicIP:
  23787. return m.PublicIP()
  23788. case server.FieldPrivateIP:
  23789. return m.PrivateIP()
  23790. case server.FieldAdminPort:
  23791. return m.AdminPort()
  23792. }
  23793. return nil, false
  23794. }
  23795. // OldField returns the old value of the field from the database. An error is
  23796. // returned if the mutation operation is not UpdateOne, or the query to the
  23797. // database failed.
  23798. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23799. switch name {
  23800. case server.FieldCreatedAt:
  23801. return m.OldCreatedAt(ctx)
  23802. case server.FieldUpdatedAt:
  23803. return m.OldUpdatedAt(ctx)
  23804. case server.FieldStatus:
  23805. return m.OldStatus(ctx)
  23806. case server.FieldDeletedAt:
  23807. return m.OldDeletedAt(ctx)
  23808. case server.FieldName:
  23809. return m.OldName(ctx)
  23810. case server.FieldPublicIP:
  23811. return m.OldPublicIP(ctx)
  23812. case server.FieldPrivateIP:
  23813. return m.OldPrivateIP(ctx)
  23814. case server.FieldAdminPort:
  23815. return m.OldAdminPort(ctx)
  23816. }
  23817. return nil, fmt.Errorf("unknown Server field %s", name)
  23818. }
  23819. // SetField sets the value of a field with the given name. It returns an error if
  23820. // the field is not defined in the schema, or if the type mismatched the field
  23821. // type.
  23822. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  23823. switch name {
  23824. case server.FieldCreatedAt:
  23825. v, ok := value.(time.Time)
  23826. if !ok {
  23827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23828. }
  23829. m.SetCreatedAt(v)
  23830. return nil
  23831. case server.FieldUpdatedAt:
  23832. v, ok := value.(time.Time)
  23833. if !ok {
  23834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23835. }
  23836. m.SetUpdatedAt(v)
  23837. return nil
  23838. case server.FieldStatus:
  23839. v, ok := value.(uint8)
  23840. if !ok {
  23841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23842. }
  23843. m.SetStatus(v)
  23844. return nil
  23845. case server.FieldDeletedAt:
  23846. v, ok := value.(time.Time)
  23847. if !ok {
  23848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23849. }
  23850. m.SetDeletedAt(v)
  23851. return nil
  23852. case server.FieldName:
  23853. v, ok := value.(string)
  23854. if !ok {
  23855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23856. }
  23857. m.SetName(v)
  23858. return nil
  23859. case server.FieldPublicIP:
  23860. v, ok := value.(string)
  23861. if !ok {
  23862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23863. }
  23864. m.SetPublicIP(v)
  23865. return nil
  23866. case server.FieldPrivateIP:
  23867. v, ok := value.(string)
  23868. if !ok {
  23869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23870. }
  23871. m.SetPrivateIP(v)
  23872. return nil
  23873. case server.FieldAdminPort:
  23874. v, ok := value.(string)
  23875. if !ok {
  23876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23877. }
  23878. m.SetAdminPort(v)
  23879. return nil
  23880. }
  23881. return fmt.Errorf("unknown Server field %s", name)
  23882. }
  23883. // AddedFields returns all numeric fields that were incremented/decremented during
  23884. // this mutation.
  23885. func (m *ServerMutation) AddedFields() []string {
  23886. var fields []string
  23887. if m.addstatus != nil {
  23888. fields = append(fields, server.FieldStatus)
  23889. }
  23890. return fields
  23891. }
  23892. // AddedField returns the numeric value that was incremented/decremented on a field
  23893. // with the given name. The second boolean return value indicates that this field
  23894. // was not set, or was not defined in the schema.
  23895. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  23896. switch name {
  23897. case server.FieldStatus:
  23898. return m.AddedStatus()
  23899. }
  23900. return nil, false
  23901. }
  23902. // AddField adds the value to the field with the given name. It returns an error if
  23903. // the field is not defined in the schema, or if the type mismatched the field
  23904. // type.
  23905. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  23906. switch name {
  23907. case server.FieldStatus:
  23908. v, ok := value.(int8)
  23909. if !ok {
  23910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23911. }
  23912. m.AddStatus(v)
  23913. return nil
  23914. }
  23915. return fmt.Errorf("unknown Server numeric field %s", name)
  23916. }
  23917. // ClearedFields returns all nullable fields that were cleared during this
  23918. // mutation.
  23919. func (m *ServerMutation) ClearedFields() []string {
  23920. var fields []string
  23921. if m.FieldCleared(server.FieldStatus) {
  23922. fields = append(fields, server.FieldStatus)
  23923. }
  23924. if m.FieldCleared(server.FieldDeletedAt) {
  23925. fields = append(fields, server.FieldDeletedAt)
  23926. }
  23927. return fields
  23928. }
  23929. // FieldCleared returns a boolean indicating if a field with the given name was
  23930. // cleared in this mutation.
  23931. func (m *ServerMutation) FieldCleared(name string) bool {
  23932. _, ok := m.clearedFields[name]
  23933. return ok
  23934. }
  23935. // ClearField clears the value of the field with the given name. It returns an
  23936. // error if the field is not defined in the schema.
  23937. func (m *ServerMutation) ClearField(name string) error {
  23938. switch name {
  23939. case server.FieldStatus:
  23940. m.ClearStatus()
  23941. return nil
  23942. case server.FieldDeletedAt:
  23943. m.ClearDeletedAt()
  23944. return nil
  23945. }
  23946. return fmt.Errorf("unknown Server nullable field %s", name)
  23947. }
  23948. // ResetField resets all changes in the mutation for the field with the given name.
  23949. // It returns an error if the field is not defined in the schema.
  23950. func (m *ServerMutation) ResetField(name string) error {
  23951. switch name {
  23952. case server.FieldCreatedAt:
  23953. m.ResetCreatedAt()
  23954. return nil
  23955. case server.FieldUpdatedAt:
  23956. m.ResetUpdatedAt()
  23957. return nil
  23958. case server.FieldStatus:
  23959. m.ResetStatus()
  23960. return nil
  23961. case server.FieldDeletedAt:
  23962. m.ResetDeletedAt()
  23963. return nil
  23964. case server.FieldName:
  23965. m.ResetName()
  23966. return nil
  23967. case server.FieldPublicIP:
  23968. m.ResetPublicIP()
  23969. return nil
  23970. case server.FieldPrivateIP:
  23971. m.ResetPrivateIP()
  23972. return nil
  23973. case server.FieldAdminPort:
  23974. m.ResetAdminPort()
  23975. return nil
  23976. }
  23977. return fmt.Errorf("unknown Server field %s", name)
  23978. }
  23979. // AddedEdges returns all edge names that were set/added in this mutation.
  23980. func (m *ServerMutation) AddedEdges() []string {
  23981. edges := make([]string, 0, 1)
  23982. if m.wxs != nil {
  23983. edges = append(edges, server.EdgeWxs)
  23984. }
  23985. return edges
  23986. }
  23987. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23988. // name in this mutation.
  23989. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  23990. switch name {
  23991. case server.EdgeWxs:
  23992. ids := make([]ent.Value, 0, len(m.wxs))
  23993. for id := range m.wxs {
  23994. ids = append(ids, id)
  23995. }
  23996. return ids
  23997. }
  23998. return nil
  23999. }
  24000. // RemovedEdges returns all edge names that were removed in this mutation.
  24001. func (m *ServerMutation) RemovedEdges() []string {
  24002. edges := make([]string, 0, 1)
  24003. if m.removedwxs != nil {
  24004. edges = append(edges, server.EdgeWxs)
  24005. }
  24006. return edges
  24007. }
  24008. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24009. // the given name in this mutation.
  24010. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  24011. switch name {
  24012. case server.EdgeWxs:
  24013. ids := make([]ent.Value, 0, len(m.removedwxs))
  24014. for id := range m.removedwxs {
  24015. ids = append(ids, id)
  24016. }
  24017. return ids
  24018. }
  24019. return nil
  24020. }
  24021. // ClearedEdges returns all edge names that were cleared in this mutation.
  24022. func (m *ServerMutation) ClearedEdges() []string {
  24023. edges := make([]string, 0, 1)
  24024. if m.clearedwxs {
  24025. edges = append(edges, server.EdgeWxs)
  24026. }
  24027. return edges
  24028. }
  24029. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24030. // was cleared in this mutation.
  24031. func (m *ServerMutation) EdgeCleared(name string) bool {
  24032. switch name {
  24033. case server.EdgeWxs:
  24034. return m.clearedwxs
  24035. }
  24036. return false
  24037. }
  24038. // ClearEdge clears the value of the edge with the given name. It returns an error
  24039. // if that edge is not defined in the schema.
  24040. func (m *ServerMutation) ClearEdge(name string) error {
  24041. switch name {
  24042. }
  24043. return fmt.Errorf("unknown Server unique edge %s", name)
  24044. }
  24045. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24046. // It returns an error if the edge is not defined in the schema.
  24047. func (m *ServerMutation) ResetEdge(name string) error {
  24048. switch name {
  24049. case server.EdgeWxs:
  24050. m.ResetWxs()
  24051. return nil
  24052. }
  24053. return fmt.Errorf("unknown Server edge %s", name)
  24054. }
  24055. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  24056. type SopNodeMutation struct {
  24057. config
  24058. op Op
  24059. typ string
  24060. id *uint64
  24061. created_at *time.Time
  24062. updated_at *time.Time
  24063. status *uint8
  24064. addstatus *int8
  24065. deleted_at *time.Time
  24066. parent_id *uint64
  24067. addparent_id *int64
  24068. name *string
  24069. condition_type *int
  24070. addcondition_type *int
  24071. condition_list *[]string
  24072. appendcondition_list []string
  24073. no_reply_condition *uint64
  24074. addno_reply_condition *int64
  24075. no_reply_unit *string
  24076. action_message *[]custom_types.Action
  24077. appendaction_message []custom_types.Action
  24078. action_label_add *[]uint64
  24079. appendaction_label_add []uint64
  24080. action_label_del *[]uint64
  24081. appendaction_label_del []uint64
  24082. action_forward **custom_types.ActionForward
  24083. clearedFields map[string]struct{}
  24084. sop_stage *uint64
  24085. clearedsop_stage bool
  24086. node_messages map[uint64]struct{}
  24087. removednode_messages map[uint64]struct{}
  24088. clearednode_messages bool
  24089. done bool
  24090. oldValue func(context.Context) (*SopNode, error)
  24091. predicates []predicate.SopNode
  24092. }
  24093. var _ ent.Mutation = (*SopNodeMutation)(nil)
  24094. // sopnodeOption allows management of the mutation configuration using functional options.
  24095. type sopnodeOption func(*SopNodeMutation)
  24096. // newSopNodeMutation creates new mutation for the SopNode entity.
  24097. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  24098. m := &SopNodeMutation{
  24099. config: c,
  24100. op: op,
  24101. typ: TypeSopNode,
  24102. clearedFields: make(map[string]struct{}),
  24103. }
  24104. for _, opt := range opts {
  24105. opt(m)
  24106. }
  24107. return m
  24108. }
  24109. // withSopNodeID sets the ID field of the mutation.
  24110. func withSopNodeID(id uint64) sopnodeOption {
  24111. return func(m *SopNodeMutation) {
  24112. var (
  24113. err error
  24114. once sync.Once
  24115. value *SopNode
  24116. )
  24117. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  24118. once.Do(func() {
  24119. if m.done {
  24120. err = errors.New("querying old values post mutation is not allowed")
  24121. } else {
  24122. value, err = m.Client().SopNode.Get(ctx, id)
  24123. }
  24124. })
  24125. return value, err
  24126. }
  24127. m.id = &id
  24128. }
  24129. }
  24130. // withSopNode sets the old SopNode of the mutation.
  24131. func withSopNode(node *SopNode) sopnodeOption {
  24132. return func(m *SopNodeMutation) {
  24133. m.oldValue = func(context.Context) (*SopNode, error) {
  24134. return node, nil
  24135. }
  24136. m.id = &node.ID
  24137. }
  24138. }
  24139. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24140. // executed in a transaction (ent.Tx), a transactional client is returned.
  24141. func (m SopNodeMutation) Client() *Client {
  24142. client := &Client{config: m.config}
  24143. client.init()
  24144. return client
  24145. }
  24146. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24147. // it returns an error otherwise.
  24148. func (m SopNodeMutation) Tx() (*Tx, error) {
  24149. if _, ok := m.driver.(*txDriver); !ok {
  24150. return nil, errors.New("ent: mutation is not running in a transaction")
  24151. }
  24152. tx := &Tx{config: m.config}
  24153. tx.init()
  24154. return tx, nil
  24155. }
  24156. // SetID sets the value of the id field. Note that this
  24157. // operation is only accepted on creation of SopNode entities.
  24158. func (m *SopNodeMutation) SetID(id uint64) {
  24159. m.id = &id
  24160. }
  24161. // ID returns the ID value in the mutation. Note that the ID is only available
  24162. // if it was provided to the builder or after it was returned from the database.
  24163. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  24164. if m.id == nil {
  24165. return
  24166. }
  24167. return *m.id, true
  24168. }
  24169. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24170. // That means, if the mutation is applied within a transaction with an isolation level such
  24171. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24172. // or updated by the mutation.
  24173. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  24174. switch {
  24175. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24176. id, exists := m.ID()
  24177. if exists {
  24178. return []uint64{id}, nil
  24179. }
  24180. fallthrough
  24181. case m.op.Is(OpUpdate | OpDelete):
  24182. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  24183. default:
  24184. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24185. }
  24186. }
  24187. // SetCreatedAt sets the "created_at" field.
  24188. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  24189. m.created_at = &t
  24190. }
  24191. // CreatedAt returns the value of the "created_at" field in the mutation.
  24192. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  24193. v := m.created_at
  24194. if v == nil {
  24195. return
  24196. }
  24197. return *v, true
  24198. }
  24199. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  24200. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24202. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24203. if !m.op.Is(OpUpdateOne) {
  24204. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24205. }
  24206. if m.id == nil || m.oldValue == nil {
  24207. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24208. }
  24209. oldValue, err := m.oldValue(ctx)
  24210. if err != nil {
  24211. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24212. }
  24213. return oldValue.CreatedAt, nil
  24214. }
  24215. // ResetCreatedAt resets all changes to the "created_at" field.
  24216. func (m *SopNodeMutation) ResetCreatedAt() {
  24217. m.created_at = nil
  24218. }
  24219. // SetUpdatedAt sets the "updated_at" field.
  24220. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  24221. m.updated_at = &t
  24222. }
  24223. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24224. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  24225. v := m.updated_at
  24226. if v == nil {
  24227. return
  24228. }
  24229. return *v, true
  24230. }
  24231. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  24232. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24234. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24235. if !m.op.Is(OpUpdateOne) {
  24236. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24237. }
  24238. if m.id == nil || m.oldValue == nil {
  24239. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24240. }
  24241. oldValue, err := m.oldValue(ctx)
  24242. if err != nil {
  24243. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24244. }
  24245. return oldValue.UpdatedAt, nil
  24246. }
  24247. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24248. func (m *SopNodeMutation) ResetUpdatedAt() {
  24249. m.updated_at = nil
  24250. }
  24251. // SetStatus sets the "status" field.
  24252. func (m *SopNodeMutation) SetStatus(u uint8) {
  24253. m.status = &u
  24254. m.addstatus = nil
  24255. }
  24256. // Status returns the value of the "status" field in the mutation.
  24257. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  24258. v := m.status
  24259. if v == nil {
  24260. return
  24261. }
  24262. return *v, true
  24263. }
  24264. // OldStatus returns the old "status" field's value of the SopNode entity.
  24265. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24267. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24268. if !m.op.Is(OpUpdateOne) {
  24269. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24270. }
  24271. if m.id == nil || m.oldValue == nil {
  24272. return v, errors.New("OldStatus requires an ID field in the mutation")
  24273. }
  24274. oldValue, err := m.oldValue(ctx)
  24275. if err != nil {
  24276. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24277. }
  24278. return oldValue.Status, nil
  24279. }
  24280. // AddStatus adds u to the "status" field.
  24281. func (m *SopNodeMutation) AddStatus(u int8) {
  24282. if m.addstatus != nil {
  24283. *m.addstatus += u
  24284. } else {
  24285. m.addstatus = &u
  24286. }
  24287. }
  24288. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24289. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  24290. v := m.addstatus
  24291. if v == nil {
  24292. return
  24293. }
  24294. return *v, true
  24295. }
  24296. // ClearStatus clears the value of the "status" field.
  24297. func (m *SopNodeMutation) ClearStatus() {
  24298. m.status = nil
  24299. m.addstatus = nil
  24300. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  24301. }
  24302. // StatusCleared returns if the "status" field was cleared in this mutation.
  24303. func (m *SopNodeMutation) StatusCleared() bool {
  24304. _, ok := m.clearedFields[sopnode.FieldStatus]
  24305. return ok
  24306. }
  24307. // ResetStatus resets all changes to the "status" field.
  24308. func (m *SopNodeMutation) ResetStatus() {
  24309. m.status = nil
  24310. m.addstatus = nil
  24311. delete(m.clearedFields, sopnode.FieldStatus)
  24312. }
  24313. // SetDeletedAt sets the "deleted_at" field.
  24314. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  24315. m.deleted_at = &t
  24316. }
  24317. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24318. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  24319. v := m.deleted_at
  24320. if v == nil {
  24321. return
  24322. }
  24323. return *v, true
  24324. }
  24325. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  24326. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24328. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24329. if !m.op.Is(OpUpdateOne) {
  24330. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24331. }
  24332. if m.id == nil || m.oldValue == nil {
  24333. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24334. }
  24335. oldValue, err := m.oldValue(ctx)
  24336. if err != nil {
  24337. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24338. }
  24339. return oldValue.DeletedAt, nil
  24340. }
  24341. // ClearDeletedAt clears the value of the "deleted_at" field.
  24342. func (m *SopNodeMutation) ClearDeletedAt() {
  24343. m.deleted_at = nil
  24344. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  24345. }
  24346. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24347. func (m *SopNodeMutation) DeletedAtCleared() bool {
  24348. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  24349. return ok
  24350. }
  24351. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24352. func (m *SopNodeMutation) ResetDeletedAt() {
  24353. m.deleted_at = nil
  24354. delete(m.clearedFields, sopnode.FieldDeletedAt)
  24355. }
  24356. // SetStageID sets the "stage_id" field.
  24357. func (m *SopNodeMutation) SetStageID(u uint64) {
  24358. m.sop_stage = &u
  24359. }
  24360. // StageID returns the value of the "stage_id" field in the mutation.
  24361. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  24362. v := m.sop_stage
  24363. if v == nil {
  24364. return
  24365. }
  24366. return *v, true
  24367. }
  24368. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  24369. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24371. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  24372. if !m.op.Is(OpUpdateOne) {
  24373. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  24374. }
  24375. if m.id == nil || m.oldValue == nil {
  24376. return v, errors.New("OldStageID requires an ID field in the mutation")
  24377. }
  24378. oldValue, err := m.oldValue(ctx)
  24379. if err != nil {
  24380. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  24381. }
  24382. return oldValue.StageID, nil
  24383. }
  24384. // ResetStageID resets all changes to the "stage_id" field.
  24385. func (m *SopNodeMutation) ResetStageID() {
  24386. m.sop_stage = nil
  24387. }
  24388. // SetParentID sets the "parent_id" field.
  24389. func (m *SopNodeMutation) SetParentID(u uint64) {
  24390. m.parent_id = &u
  24391. m.addparent_id = nil
  24392. }
  24393. // ParentID returns the value of the "parent_id" field in the mutation.
  24394. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  24395. v := m.parent_id
  24396. if v == nil {
  24397. return
  24398. }
  24399. return *v, true
  24400. }
  24401. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  24402. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24404. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  24405. if !m.op.Is(OpUpdateOne) {
  24406. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  24407. }
  24408. if m.id == nil || m.oldValue == nil {
  24409. return v, errors.New("OldParentID requires an ID field in the mutation")
  24410. }
  24411. oldValue, err := m.oldValue(ctx)
  24412. if err != nil {
  24413. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  24414. }
  24415. return oldValue.ParentID, nil
  24416. }
  24417. // AddParentID adds u to the "parent_id" field.
  24418. func (m *SopNodeMutation) AddParentID(u int64) {
  24419. if m.addparent_id != nil {
  24420. *m.addparent_id += u
  24421. } else {
  24422. m.addparent_id = &u
  24423. }
  24424. }
  24425. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  24426. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  24427. v := m.addparent_id
  24428. if v == nil {
  24429. return
  24430. }
  24431. return *v, true
  24432. }
  24433. // ResetParentID resets all changes to the "parent_id" field.
  24434. func (m *SopNodeMutation) ResetParentID() {
  24435. m.parent_id = nil
  24436. m.addparent_id = nil
  24437. }
  24438. // SetName sets the "name" field.
  24439. func (m *SopNodeMutation) SetName(s string) {
  24440. m.name = &s
  24441. }
  24442. // Name returns the value of the "name" field in the mutation.
  24443. func (m *SopNodeMutation) Name() (r string, exists bool) {
  24444. v := m.name
  24445. if v == nil {
  24446. return
  24447. }
  24448. return *v, true
  24449. }
  24450. // OldName returns the old "name" field's value of the SopNode entity.
  24451. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24453. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  24454. if !m.op.Is(OpUpdateOne) {
  24455. return v, errors.New("OldName is only allowed on UpdateOne operations")
  24456. }
  24457. if m.id == nil || m.oldValue == nil {
  24458. return v, errors.New("OldName requires an ID field in the mutation")
  24459. }
  24460. oldValue, err := m.oldValue(ctx)
  24461. if err != nil {
  24462. return v, fmt.Errorf("querying old value for OldName: %w", err)
  24463. }
  24464. return oldValue.Name, nil
  24465. }
  24466. // ResetName resets all changes to the "name" field.
  24467. func (m *SopNodeMutation) ResetName() {
  24468. m.name = nil
  24469. }
  24470. // SetConditionType sets the "condition_type" field.
  24471. func (m *SopNodeMutation) SetConditionType(i int) {
  24472. m.condition_type = &i
  24473. m.addcondition_type = nil
  24474. }
  24475. // ConditionType returns the value of the "condition_type" field in the mutation.
  24476. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  24477. v := m.condition_type
  24478. if v == nil {
  24479. return
  24480. }
  24481. return *v, true
  24482. }
  24483. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  24484. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24486. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  24487. if !m.op.Is(OpUpdateOne) {
  24488. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  24489. }
  24490. if m.id == nil || m.oldValue == nil {
  24491. return v, errors.New("OldConditionType requires an ID field in the mutation")
  24492. }
  24493. oldValue, err := m.oldValue(ctx)
  24494. if err != nil {
  24495. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  24496. }
  24497. return oldValue.ConditionType, nil
  24498. }
  24499. // AddConditionType adds i to the "condition_type" field.
  24500. func (m *SopNodeMutation) AddConditionType(i int) {
  24501. if m.addcondition_type != nil {
  24502. *m.addcondition_type += i
  24503. } else {
  24504. m.addcondition_type = &i
  24505. }
  24506. }
  24507. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  24508. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  24509. v := m.addcondition_type
  24510. if v == nil {
  24511. return
  24512. }
  24513. return *v, true
  24514. }
  24515. // ResetConditionType resets all changes to the "condition_type" field.
  24516. func (m *SopNodeMutation) ResetConditionType() {
  24517. m.condition_type = nil
  24518. m.addcondition_type = nil
  24519. }
  24520. // SetConditionList sets the "condition_list" field.
  24521. func (m *SopNodeMutation) SetConditionList(s []string) {
  24522. m.condition_list = &s
  24523. m.appendcondition_list = nil
  24524. }
  24525. // ConditionList returns the value of the "condition_list" field in the mutation.
  24526. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  24527. v := m.condition_list
  24528. if v == nil {
  24529. return
  24530. }
  24531. return *v, true
  24532. }
  24533. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  24534. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24536. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  24537. if !m.op.Is(OpUpdateOne) {
  24538. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  24539. }
  24540. if m.id == nil || m.oldValue == nil {
  24541. return v, errors.New("OldConditionList requires an ID field in the mutation")
  24542. }
  24543. oldValue, err := m.oldValue(ctx)
  24544. if err != nil {
  24545. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  24546. }
  24547. return oldValue.ConditionList, nil
  24548. }
  24549. // AppendConditionList adds s to the "condition_list" field.
  24550. func (m *SopNodeMutation) AppendConditionList(s []string) {
  24551. m.appendcondition_list = append(m.appendcondition_list, s...)
  24552. }
  24553. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  24554. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  24555. if len(m.appendcondition_list) == 0 {
  24556. return nil, false
  24557. }
  24558. return m.appendcondition_list, true
  24559. }
  24560. // ClearConditionList clears the value of the "condition_list" field.
  24561. func (m *SopNodeMutation) ClearConditionList() {
  24562. m.condition_list = nil
  24563. m.appendcondition_list = nil
  24564. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  24565. }
  24566. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  24567. func (m *SopNodeMutation) ConditionListCleared() bool {
  24568. _, ok := m.clearedFields[sopnode.FieldConditionList]
  24569. return ok
  24570. }
  24571. // ResetConditionList resets all changes to the "condition_list" field.
  24572. func (m *SopNodeMutation) ResetConditionList() {
  24573. m.condition_list = nil
  24574. m.appendcondition_list = nil
  24575. delete(m.clearedFields, sopnode.FieldConditionList)
  24576. }
  24577. // SetNoReplyCondition sets the "no_reply_condition" field.
  24578. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  24579. m.no_reply_condition = &u
  24580. m.addno_reply_condition = nil
  24581. }
  24582. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  24583. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  24584. v := m.no_reply_condition
  24585. if v == nil {
  24586. return
  24587. }
  24588. return *v, true
  24589. }
  24590. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  24591. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24593. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  24594. if !m.op.Is(OpUpdateOne) {
  24595. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  24596. }
  24597. if m.id == nil || m.oldValue == nil {
  24598. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  24599. }
  24600. oldValue, err := m.oldValue(ctx)
  24601. if err != nil {
  24602. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  24603. }
  24604. return oldValue.NoReplyCondition, nil
  24605. }
  24606. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  24607. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  24608. if m.addno_reply_condition != nil {
  24609. *m.addno_reply_condition += u
  24610. } else {
  24611. m.addno_reply_condition = &u
  24612. }
  24613. }
  24614. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  24615. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  24616. v := m.addno_reply_condition
  24617. if v == nil {
  24618. return
  24619. }
  24620. return *v, true
  24621. }
  24622. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  24623. func (m *SopNodeMutation) ResetNoReplyCondition() {
  24624. m.no_reply_condition = nil
  24625. m.addno_reply_condition = nil
  24626. }
  24627. // SetNoReplyUnit sets the "no_reply_unit" field.
  24628. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  24629. m.no_reply_unit = &s
  24630. }
  24631. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  24632. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  24633. v := m.no_reply_unit
  24634. if v == nil {
  24635. return
  24636. }
  24637. return *v, true
  24638. }
  24639. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  24640. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24642. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  24643. if !m.op.Is(OpUpdateOne) {
  24644. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  24645. }
  24646. if m.id == nil || m.oldValue == nil {
  24647. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  24648. }
  24649. oldValue, err := m.oldValue(ctx)
  24650. if err != nil {
  24651. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  24652. }
  24653. return oldValue.NoReplyUnit, nil
  24654. }
  24655. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  24656. func (m *SopNodeMutation) ResetNoReplyUnit() {
  24657. m.no_reply_unit = nil
  24658. }
  24659. // SetActionMessage sets the "action_message" field.
  24660. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  24661. m.action_message = &ct
  24662. m.appendaction_message = nil
  24663. }
  24664. // ActionMessage returns the value of the "action_message" field in the mutation.
  24665. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  24666. v := m.action_message
  24667. if v == nil {
  24668. return
  24669. }
  24670. return *v, true
  24671. }
  24672. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  24673. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24675. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  24676. if !m.op.Is(OpUpdateOne) {
  24677. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  24678. }
  24679. if m.id == nil || m.oldValue == nil {
  24680. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  24681. }
  24682. oldValue, err := m.oldValue(ctx)
  24683. if err != nil {
  24684. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  24685. }
  24686. return oldValue.ActionMessage, nil
  24687. }
  24688. // AppendActionMessage adds ct to the "action_message" field.
  24689. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  24690. m.appendaction_message = append(m.appendaction_message, ct...)
  24691. }
  24692. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  24693. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  24694. if len(m.appendaction_message) == 0 {
  24695. return nil, false
  24696. }
  24697. return m.appendaction_message, true
  24698. }
  24699. // ClearActionMessage clears the value of the "action_message" field.
  24700. func (m *SopNodeMutation) ClearActionMessage() {
  24701. m.action_message = nil
  24702. m.appendaction_message = nil
  24703. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  24704. }
  24705. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  24706. func (m *SopNodeMutation) ActionMessageCleared() bool {
  24707. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  24708. return ok
  24709. }
  24710. // ResetActionMessage resets all changes to the "action_message" field.
  24711. func (m *SopNodeMutation) ResetActionMessage() {
  24712. m.action_message = nil
  24713. m.appendaction_message = nil
  24714. delete(m.clearedFields, sopnode.FieldActionMessage)
  24715. }
  24716. // SetActionLabelAdd sets the "action_label_add" field.
  24717. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  24718. m.action_label_add = &u
  24719. m.appendaction_label_add = nil
  24720. }
  24721. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  24722. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  24723. v := m.action_label_add
  24724. if v == nil {
  24725. return
  24726. }
  24727. return *v, true
  24728. }
  24729. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  24730. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24732. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  24733. if !m.op.Is(OpUpdateOne) {
  24734. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  24735. }
  24736. if m.id == nil || m.oldValue == nil {
  24737. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  24738. }
  24739. oldValue, err := m.oldValue(ctx)
  24740. if err != nil {
  24741. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  24742. }
  24743. return oldValue.ActionLabelAdd, nil
  24744. }
  24745. // AppendActionLabelAdd adds u to the "action_label_add" field.
  24746. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  24747. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  24748. }
  24749. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  24750. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  24751. if len(m.appendaction_label_add) == 0 {
  24752. return nil, false
  24753. }
  24754. return m.appendaction_label_add, true
  24755. }
  24756. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  24757. func (m *SopNodeMutation) ClearActionLabelAdd() {
  24758. m.action_label_add = nil
  24759. m.appendaction_label_add = nil
  24760. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  24761. }
  24762. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  24763. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  24764. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  24765. return ok
  24766. }
  24767. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  24768. func (m *SopNodeMutation) ResetActionLabelAdd() {
  24769. m.action_label_add = nil
  24770. m.appendaction_label_add = nil
  24771. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  24772. }
  24773. // SetActionLabelDel sets the "action_label_del" field.
  24774. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  24775. m.action_label_del = &u
  24776. m.appendaction_label_del = nil
  24777. }
  24778. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  24779. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  24780. v := m.action_label_del
  24781. if v == nil {
  24782. return
  24783. }
  24784. return *v, true
  24785. }
  24786. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  24787. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24789. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  24790. if !m.op.Is(OpUpdateOne) {
  24791. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  24792. }
  24793. if m.id == nil || m.oldValue == nil {
  24794. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  24795. }
  24796. oldValue, err := m.oldValue(ctx)
  24797. if err != nil {
  24798. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  24799. }
  24800. return oldValue.ActionLabelDel, nil
  24801. }
  24802. // AppendActionLabelDel adds u to the "action_label_del" field.
  24803. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  24804. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  24805. }
  24806. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  24807. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  24808. if len(m.appendaction_label_del) == 0 {
  24809. return nil, false
  24810. }
  24811. return m.appendaction_label_del, true
  24812. }
  24813. // ClearActionLabelDel clears the value of the "action_label_del" field.
  24814. func (m *SopNodeMutation) ClearActionLabelDel() {
  24815. m.action_label_del = nil
  24816. m.appendaction_label_del = nil
  24817. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  24818. }
  24819. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  24820. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  24821. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  24822. return ok
  24823. }
  24824. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  24825. func (m *SopNodeMutation) ResetActionLabelDel() {
  24826. m.action_label_del = nil
  24827. m.appendaction_label_del = nil
  24828. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  24829. }
  24830. // SetActionForward sets the "action_forward" field.
  24831. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  24832. m.action_forward = &ctf
  24833. }
  24834. // ActionForward returns the value of the "action_forward" field in the mutation.
  24835. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  24836. v := m.action_forward
  24837. if v == nil {
  24838. return
  24839. }
  24840. return *v, true
  24841. }
  24842. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  24843. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  24844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24845. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  24846. if !m.op.Is(OpUpdateOne) {
  24847. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  24848. }
  24849. if m.id == nil || m.oldValue == nil {
  24850. return v, errors.New("OldActionForward requires an ID field in the mutation")
  24851. }
  24852. oldValue, err := m.oldValue(ctx)
  24853. if err != nil {
  24854. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  24855. }
  24856. return oldValue.ActionForward, nil
  24857. }
  24858. // ClearActionForward clears the value of the "action_forward" field.
  24859. func (m *SopNodeMutation) ClearActionForward() {
  24860. m.action_forward = nil
  24861. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  24862. }
  24863. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  24864. func (m *SopNodeMutation) ActionForwardCleared() bool {
  24865. _, ok := m.clearedFields[sopnode.FieldActionForward]
  24866. return ok
  24867. }
  24868. // ResetActionForward resets all changes to the "action_forward" field.
  24869. func (m *SopNodeMutation) ResetActionForward() {
  24870. m.action_forward = nil
  24871. delete(m.clearedFields, sopnode.FieldActionForward)
  24872. }
  24873. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  24874. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  24875. m.sop_stage = &id
  24876. }
  24877. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  24878. func (m *SopNodeMutation) ClearSopStage() {
  24879. m.clearedsop_stage = true
  24880. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  24881. }
  24882. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  24883. func (m *SopNodeMutation) SopStageCleared() bool {
  24884. return m.clearedsop_stage
  24885. }
  24886. // SopStageID returns the "sop_stage" edge ID in the mutation.
  24887. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  24888. if m.sop_stage != nil {
  24889. return *m.sop_stage, true
  24890. }
  24891. return
  24892. }
  24893. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  24894. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24895. // SopStageID instead. It exists only for internal usage by the builders.
  24896. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  24897. if id := m.sop_stage; id != nil {
  24898. ids = append(ids, *id)
  24899. }
  24900. return
  24901. }
  24902. // ResetSopStage resets all changes to the "sop_stage" edge.
  24903. func (m *SopNodeMutation) ResetSopStage() {
  24904. m.sop_stage = nil
  24905. m.clearedsop_stage = false
  24906. }
  24907. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  24908. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  24909. if m.node_messages == nil {
  24910. m.node_messages = make(map[uint64]struct{})
  24911. }
  24912. for i := range ids {
  24913. m.node_messages[ids[i]] = struct{}{}
  24914. }
  24915. }
  24916. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  24917. func (m *SopNodeMutation) ClearNodeMessages() {
  24918. m.clearednode_messages = true
  24919. }
  24920. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  24921. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  24922. return m.clearednode_messages
  24923. }
  24924. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  24925. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  24926. if m.removednode_messages == nil {
  24927. m.removednode_messages = make(map[uint64]struct{})
  24928. }
  24929. for i := range ids {
  24930. delete(m.node_messages, ids[i])
  24931. m.removednode_messages[ids[i]] = struct{}{}
  24932. }
  24933. }
  24934. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  24935. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  24936. for id := range m.removednode_messages {
  24937. ids = append(ids, id)
  24938. }
  24939. return
  24940. }
  24941. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  24942. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  24943. for id := range m.node_messages {
  24944. ids = append(ids, id)
  24945. }
  24946. return
  24947. }
  24948. // ResetNodeMessages resets all changes to the "node_messages" edge.
  24949. func (m *SopNodeMutation) ResetNodeMessages() {
  24950. m.node_messages = nil
  24951. m.clearednode_messages = false
  24952. m.removednode_messages = nil
  24953. }
  24954. // Where appends a list predicates to the SopNodeMutation builder.
  24955. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  24956. m.predicates = append(m.predicates, ps...)
  24957. }
  24958. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  24959. // users can use type-assertion to append predicates that do not depend on any generated package.
  24960. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  24961. p := make([]predicate.SopNode, len(ps))
  24962. for i := range ps {
  24963. p[i] = ps[i]
  24964. }
  24965. m.Where(p...)
  24966. }
  24967. // Op returns the operation name.
  24968. func (m *SopNodeMutation) Op() Op {
  24969. return m.op
  24970. }
  24971. // SetOp allows setting the mutation operation.
  24972. func (m *SopNodeMutation) SetOp(op Op) {
  24973. m.op = op
  24974. }
  24975. // Type returns the node type of this mutation (SopNode).
  24976. func (m *SopNodeMutation) Type() string {
  24977. return m.typ
  24978. }
  24979. // Fields returns all fields that were changed during this mutation. Note that in
  24980. // order to get all numeric fields that were incremented/decremented, call
  24981. // AddedFields().
  24982. func (m *SopNodeMutation) Fields() []string {
  24983. fields := make([]string, 0, 15)
  24984. if m.created_at != nil {
  24985. fields = append(fields, sopnode.FieldCreatedAt)
  24986. }
  24987. if m.updated_at != nil {
  24988. fields = append(fields, sopnode.FieldUpdatedAt)
  24989. }
  24990. if m.status != nil {
  24991. fields = append(fields, sopnode.FieldStatus)
  24992. }
  24993. if m.deleted_at != nil {
  24994. fields = append(fields, sopnode.FieldDeletedAt)
  24995. }
  24996. if m.sop_stage != nil {
  24997. fields = append(fields, sopnode.FieldStageID)
  24998. }
  24999. if m.parent_id != nil {
  25000. fields = append(fields, sopnode.FieldParentID)
  25001. }
  25002. if m.name != nil {
  25003. fields = append(fields, sopnode.FieldName)
  25004. }
  25005. if m.condition_type != nil {
  25006. fields = append(fields, sopnode.FieldConditionType)
  25007. }
  25008. if m.condition_list != nil {
  25009. fields = append(fields, sopnode.FieldConditionList)
  25010. }
  25011. if m.no_reply_condition != nil {
  25012. fields = append(fields, sopnode.FieldNoReplyCondition)
  25013. }
  25014. if m.no_reply_unit != nil {
  25015. fields = append(fields, sopnode.FieldNoReplyUnit)
  25016. }
  25017. if m.action_message != nil {
  25018. fields = append(fields, sopnode.FieldActionMessage)
  25019. }
  25020. if m.action_label_add != nil {
  25021. fields = append(fields, sopnode.FieldActionLabelAdd)
  25022. }
  25023. if m.action_label_del != nil {
  25024. fields = append(fields, sopnode.FieldActionLabelDel)
  25025. }
  25026. if m.action_forward != nil {
  25027. fields = append(fields, sopnode.FieldActionForward)
  25028. }
  25029. return fields
  25030. }
  25031. // Field returns the value of a field with the given name. The second boolean
  25032. // return value indicates that this field was not set, or was not defined in the
  25033. // schema.
  25034. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  25035. switch name {
  25036. case sopnode.FieldCreatedAt:
  25037. return m.CreatedAt()
  25038. case sopnode.FieldUpdatedAt:
  25039. return m.UpdatedAt()
  25040. case sopnode.FieldStatus:
  25041. return m.Status()
  25042. case sopnode.FieldDeletedAt:
  25043. return m.DeletedAt()
  25044. case sopnode.FieldStageID:
  25045. return m.StageID()
  25046. case sopnode.FieldParentID:
  25047. return m.ParentID()
  25048. case sopnode.FieldName:
  25049. return m.Name()
  25050. case sopnode.FieldConditionType:
  25051. return m.ConditionType()
  25052. case sopnode.FieldConditionList:
  25053. return m.ConditionList()
  25054. case sopnode.FieldNoReplyCondition:
  25055. return m.NoReplyCondition()
  25056. case sopnode.FieldNoReplyUnit:
  25057. return m.NoReplyUnit()
  25058. case sopnode.FieldActionMessage:
  25059. return m.ActionMessage()
  25060. case sopnode.FieldActionLabelAdd:
  25061. return m.ActionLabelAdd()
  25062. case sopnode.FieldActionLabelDel:
  25063. return m.ActionLabelDel()
  25064. case sopnode.FieldActionForward:
  25065. return m.ActionForward()
  25066. }
  25067. return nil, false
  25068. }
  25069. // OldField returns the old value of the field from the database. An error is
  25070. // returned if the mutation operation is not UpdateOne, or the query to the
  25071. // database failed.
  25072. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25073. switch name {
  25074. case sopnode.FieldCreatedAt:
  25075. return m.OldCreatedAt(ctx)
  25076. case sopnode.FieldUpdatedAt:
  25077. return m.OldUpdatedAt(ctx)
  25078. case sopnode.FieldStatus:
  25079. return m.OldStatus(ctx)
  25080. case sopnode.FieldDeletedAt:
  25081. return m.OldDeletedAt(ctx)
  25082. case sopnode.FieldStageID:
  25083. return m.OldStageID(ctx)
  25084. case sopnode.FieldParentID:
  25085. return m.OldParentID(ctx)
  25086. case sopnode.FieldName:
  25087. return m.OldName(ctx)
  25088. case sopnode.FieldConditionType:
  25089. return m.OldConditionType(ctx)
  25090. case sopnode.FieldConditionList:
  25091. return m.OldConditionList(ctx)
  25092. case sopnode.FieldNoReplyCondition:
  25093. return m.OldNoReplyCondition(ctx)
  25094. case sopnode.FieldNoReplyUnit:
  25095. return m.OldNoReplyUnit(ctx)
  25096. case sopnode.FieldActionMessage:
  25097. return m.OldActionMessage(ctx)
  25098. case sopnode.FieldActionLabelAdd:
  25099. return m.OldActionLabelAdd(ctx)
  25100. case sopnode.FieldActionLabelDel:
  25101. return m.OldActionLabelDel(ctx)
  25102. case sopnode.FieldActionForward:
  25103. return m.OldActionForward(ctx)
  25104. }
  25105. return nil, fmt.Errorf("unknown SopNode field %s", name)
  25106. }
  25107. // SetField sets the value of a field with the given name. It returns an error if
  25108. // the field is not defined in the schema, or if the type mismatched the field
  25109. // type.
  25110. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  25111. switch name {
  25112. case sopnode.FieldCreatedAt:
  25113. v, ok := value.(time.Time)
  25114. if !ok {
  25115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25116. }
  25117. m.SetCreatedAt(v)
  25118. return nil
  25119. case sopnode.FieldUpdatedAt:
  25120. v, ok := value.(time.Time)
  25121. if !ok {
  25122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25123. }
  25124. m.SetUpdatedAt(v)
  25125. return nil
  25126. case sopnode.FieldStatus:
  25127. v, ok := value.(uint8)
  25128. if !ok {
  25129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25130. }
  25131. m.SetStatus(v)
  25132. return nil
  25133. case sopnode.FieldDeletedAt:
  25134. v, ok := value.(time.Time)
  25135. if !ok {
  25136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25137. }
  25138. m.SetDeletedAt(v)
  25139. return nil
  25140. case sopnode.FieldStageID:
  25141. v, ok := value.(uint64)
  25142. if !ok {
  25143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25144. }
  25145. m.SetStageID(v)
  25146. return nil
  25147. case sopnode.FieldParentID:
  25148. v, ok := value.(uint64)
  25149. if !ok {
  25150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25151. }
  25152. m.SetParentID(v)
  25153. return nil
  25154. case sopnode.FieldName:
  25155. v, ok := value.(string)
  25156. if !ok {
  25157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25158. }
  25159. m.SetName(v)
  25160. return nil
  25161. case sopnode.FieldConditionType:
  25162. v, ok := value.(int)
  25163. if !ok {
  25164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25165. }
  25166. m.SetConditionType(v)
  25167. return nil
  25168. case sopnode.FieldConditionList:
  25169. v, ok := value.([]string)
  25170. if !ok {
  25171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25172. }
  25173. m.SetConditionList(v)
  25174. return nil
  25175. case sopnode.FieldNoReplyCondition:
  25176. v, ok := value.(uint64)
  25177. if !ok {
  25178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25179. }
  25180. m.SetNoReplyCondition(v)
  25181. return nil
  25182. case sopnode.FieldNoReplyUnit:
  25183. v, ok := value.(string)
  25184. if !ok {
  25185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25186. }
  25187. m.SetNoReplyUnit(v)
  25188. return nil
  25189. case sopnode.FieldActionMessage:
  25190. v, ok := value.([]custom_types.Action)
  25191. if !ok {
  25192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25193. }
  25194. m.SetActionMessage(v)
  25195. return nil
  25196. case sopnode.FieldActionLabelAdd:
  25197. v, ok := value.([]uint64)
  25198. if !ok {
  25199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25200. }
  25201. m.SetActionLabelAdd(v)
  25202. return nil
  25203. case sopnode.FieldActionLabelDel:
  25204. v, ok := value.([]uint64)
  25205. if !ok {
  25206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25207. }
  25208. m.SetActionLabelDel(v)
  25209. return nil
  25210. case sopnode.FieldActionForward:
  25211. v, ok := value.(*custom_types.ActionForward)
  25212. if !ok {
  25213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25214. }
  25215. m.SetActionForward(v)
  25216. return nil
  25217. }
  25218. return fmt.Errorf("unknown SopNode field %s", name)
  25219. }
  25220. // AddedFields returns all numeric fields that were incremented/decremented during
  25221. // this mutation.
  25222. func (m *SopNodeMutation) AddedFields() []string {
  25223. var fields []string
  25224. if m.addstatus != nil {
  25225. fields = append(fields, sopnode.FieldStatus)
  25226. }
  25227. if m.addparent_id != nil {
  25228. fields = append(fields, sopnode.FieldParentID)
  25229. }
  25230. if m.addcondition_type != nil {
  25231. fields = append(fields, sopnode.FieldConditionType)
  25232. }
  25233. if m.addno_reply_condition != nil {
  25234. fields = append(fields, sopnode.FieldNoReplyCondition)
  25235. }
  25236. return fields
  25237. }
  25238. // AddedField returns the numeric value that was incremented/decremented on a field
  25239. // with the given name. The second boolean return value indicates that this field
  25240. // was not set, or was not defined in the schema.
  25241. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  25242. switch name {
  25243. case sopnode.FieldStatus:
  25244. return m.AddedStatus()
  25245. case sopnode.FieldParentID:
  25246. return m.AddedParentID()
  25247. case sopnode.FieldConditionType:
  25248. return m.AddedConditionType()
  25249. case sopnode.FieldNoReplyCondition:
  25250. return m.AddedNoReplyCondition()
  25251. }
  25252. return nil, false
  25253. }
  25254. // AddField adds the value to the field with the given name. It returns an error if
  25255. // the field is not defined in the schema, or if the type mismatched the field
  25256. // type.
  25257. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  25258. switch name {
  25259. case sopnode.FieldStatus:
  25260. v, ok := value.(int8)
  25261. if !ok {
  25262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25263. }
  25264. m.AddStatus(v)
  25265. return nil
  25266. case sopnode.FieldParentID:
  25267. v, ok := value.(int64)
  25268. if !ok {
  25269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25270. }
  25271. m.AddParentID(v)
  25272. return nil
  25273. case sopnode.FieldConditionType:
  25274. v, ok := value.(int)
  25275. if !ok {
  25276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25277. }
  25278. m.AddConditionType(v)
  25279. return nil
  25280. case sopnode.FieldNoReplyCondition:
  25281. v, ok := value.(int64)
  25282. if !ok {
  25283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25284. }
  25285. m.AddNoReplyCondition(v)
  25286. return nil
  25287. }
  25288. return fmt.Errorf("unknown SopNode numeric field %s", name)
  25289. }
  25290. // ClearedFields returns all nullable fields that were cleared during this
  25291. // mutation.
  25292. func (m *SopNodeMutation) ClearedFields() []string {
  25293. var fields []string
  25294. if m.FieldCleared(sopnode.FieldStatus) {
  25295. fields = append(fields, sopnode.FieldStatus)
  25296. }
  25297. if m.FieldCleared(sopnode.FieldDeletedAt) {
  25298. fields = append(fields, sopnode.FieldDeletedAt)
  25299. }
  25300. if m.FieldCleared(sopnode.FieldConditionList) {
  25301. fields = append(fields, sopnode.FieldConditionList)
  25302. }
  25303. if m.FieldCleared(sopnode.FieldActionMessage) {
  25304. fields = append(fields, sopnode.FieldActionMessage)
  25305. }
  25306. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  25307. fields = append(fields, sopnode.FieldActionLabelAdd)
  25308. }
  25309. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  25310. fields = append(fields, sopnode.FieldActionLabelDel)
  25311. }
  25312. if m.FieldCleared(sopnode.FieldActionForward) {
  25313. fields = append(fields, sopnode.FieldActionForward)
  25314. }
  25315. return fields
  25316. }
  25317. // FieldCleared returns a boolean indicating if a field with the given name was
  25318. // cleared in this mutation.
  25319. func (m *SopNodeMutation) FieldCleared(name string) bool {
  25320. _, ok := m.clearedFields[name]
  25321. return ok
  25322. }
  25323. // ClearField clears the value of the field with the given name. It returns an
  25324. // error if the field is not defined in the schema.
  25325. func (m *SopNodeMutation) ClearField(name string) error {
  25326. switch name {
  25327. case sopnode.FieldStatus:
  25328. m.ClearStatus()
  25329. return nil
  25330. case sopnode.FieldDeletedAt:
  25331. m.ClearDeletedAt()
  25332. return nil
  25333. case sopnode.FieldConditionList:
  25334. m.ClearConditionList()
  25335. return nil
  25336. case sopnode.FieldActionMessage:
  25337. m.ClearActionMessage()
  25338. return nil
  25339. case sopnode.FieldActionLabelAdd:
  25340. m.ClearActionLabelAdd()
  25341. return nil
  25342. case sopnode.FieldActionLabelDel:
  25343. m.ClearActionLabelDel()
  25344. return nil
  25345. case sopnode.FieldActionForward:
  25346. m.ClearActionForward()
  25347. return nil
  25348. }
  25349. return fmt.Errorf("unknown SopNode nullable field %s", name)
  25350. }
  25351. // ResetField resets all changes in the mutation for the field with the given name.
  25352. // It returns an error if the field is not defined in the schema.
  25353. func (m *SopNodeMutation) ResetField(name string) error {
  25354. switch name {
  25355. case sopnode.FieldCreatedAt:
  25356. m.ResetCreatedAt()
  25357. return nil
  25358. case sopnode.FieldUpdatedAt:
  25359. m.ResetUpdatedAt()
  25360. return nil
  25361. case sopnode.FieldStatus:
  25362. m.ResetStatus()
  25363. return nil
  25364. case sopnode.FieldDeletedAt:
  25365. m.ResetDeletedAt()
  25366. return nil
  25367. case sopnode.FieldStageID:
  25368. m.ResetStageID()
  25369. return nil
  25370. case sopnode.FieldParentID:
  25371. m.ResetParentID()
  25372. return nil
  25373. case sopnode.FieldName:
  25374. m.ResetName()
  25375. return nil
  25376. case sopnode.FieldConditionType:
  25377. m.ResetConditionType()
  25378. return nil
  25379. case sopnode.FieldConditionList:
  25380. m.ResetConditionList()
  25381. return nil
  25382. case sopnode.FieldNoReplyCondition:
  25383. m.ResetNoReplyCondition()
  25384. return nil
  25385. case sopnode.FieldNoReplyUnit:
  25386. m.ResetNoReplyUnit()
  25387. return nil
  25388. case sopnode.FieldActionMessage:
  25389. m.ResetActionMessage()
  25390. return nil
  25391. case sopnode.FieldActionLabelAdd:
  25392. m.ResetActionLabelAdd()
  25393. return nil
  25394. case sopnode.FieldActionLabelDel:
  25395. m.ResetActionLabelDel()
  25396. return nil
  25397. case sopnode.FieldActionForward:
  25398. m.ResetActionForward()
  25399. return nil
  25400. }
  25401. return fmt.Errorf("unknown SopNode field %s", name)
  25402. }
  25403. // AddedEdges returns all edge names that were set/added in this mutation.
  25404. func (m *SopNodeMutation) AddedEdges() []string {
  25405. edges := make([]string, 0, 2)
  25406. if m.sop_stage != nil {
  25407. edges = append(edges, sopnode.EdgeSopStage)
  25408. }
  25409. if m.node_messages != nil {
  25410. edges = append(edges, sopnode.EdgeNodeMessages)
  25411. }
  25412. return edges
  25413. }
  25414. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25415. // name in this mutation.
  25416. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  25417. switch name {
  25418. case sopnode.EdgeSopStage:
  25419. if id := m.sop_stage; id != nil {
  25420. return []ent.Value{*id}
  25421. }
  25422. case sopnode.EdgeNodeMessages:
  25423. ids := make([]ent.Value, 0, len(m.node_messages))
  25424. for id := range m.node_messages {
  25425. ids = append(ids, id)
  25426. }
  25427. return ids
  25428. }
  25429. return nil
  25430. }
  25431. // RemovedEdges returns all edge names that were removed in this mutation.
  25432. func (m *SopNodeMutation) RemovedEdges() []string {
  25433. edges := make([]string, 0, 2)
  25434. if m.removednode_messages != nil {
  25435. edges = append(edges, sopnode.EdgeNodeMessages)
  25436. }
  25437. return edges
  25438. }
  25439. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25440. // the given name in this mutation.
  25441. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  25442. switch name {
  25443. case sopnode.EdgeNodeMessages:
  25444. ids := make([]ent.Value, 0, len(m.removednode_messages))
  25445. for id := range m.removednode_messages {
  25446. ids = append(ids, id)
  25447. }
  25448. return ids
  25449. }
  25450. return nil
  25451. }
  25452. // ClearedEdges returns all edge names that were cleared in this mutation.
  25453. func (m *SopNodeMutation) ClearedEdges() []string {
  25454. edges := make([]string, 0, 2)
  25455. if m.clearedsop_stage {
  25456. edges = append(edges, sopnode.EdgeSopStage)
  25457. }
  25458. if m.clearednode_messages {
  25459. edges = append(edges, sopnode.EdgeNodeMessages)
  25460. }
  25461. return edges
  25462. }
  25463. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25464. // was cleared in this mutation.
  25465. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  25466. switch name {
  25467. case sopnode.EdgeSopStage:
  25468. return m.clearedsop_stage
  25469. case sopnode.EdgeNodeMessages:
  25470. return m.clearednode_messages
  25471. }
  25472. return false
  25473. }
  25474. // ClearEdge clears the value of the edge with the given name. It returns an error
  25475. // if that edge is not defined in the schema.
  25476. func (m *SopNodeMutation) ClearEdge(name string) error {
  25477. switch name {
  25478. case sopnode.EdgeSopStage:
  25479. m.ClearSopStage()
  25480. return nil
  25481. }
  25482. return fmt.Errorf("unknown SopNode unique edge %s", name)
  25483. }
  25484. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25485. // It returns an error if the edge is not defined in the schema.
  25486. func (m *SopNodeMutation) ResetEdge(name string) error {
  25487. switch name {
  25488. case sopnode.EdgeSopStage:
  25489. m.ResetSopStage()
  25490. return nil
  25491. case sopnode.EdgeNodeMessages:
  25492. m.ResetNodeMessages()
  25493. return nil
  25494. }
  25495. return fmt.Errorf("unknown SopNode edge %s", name)
  25496. }
  25497. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  25498. type SopStageMutation struct {
  25499. config
  25500. op Op
  25501. typ string
  25502. id *uint64
  25503. created_at *time.Time
  25504. updated_at *time.Time
  25505. status *uint8
  25506. addstatus *int8
  25507. deleted_at *time.Time
  25508. name *string
  25509. condition_type *int
  25510. addcondition_type *int
  25511. condition_operator *int
  25512. addcondition_operator *int
  25513. condition_list *[]custom_types.Condition
  25514. appendcondition_list []custom_types.Condition
  25515. action_message *[]custom_types.Action
  25516. appendaction_message []custom_types.Action
  25517. action_label_add *[]uint64
  25518. appendaction_label_add []uint64
  25519. action_label_del *[]uint64
  25520. appendaction_label_del []uint64
  25521. action_forward **custom_types.ActionForward
  25522. index_sort *int
  25523. addindex_sort *int
  25524. clearedFields map[string]struct{}
  25525. sop_task *uint64
  25526. clearedsop_task bool
  25527. stage_nodes map[uint64]struct{}
  25528. removedstage_nodes map[uint64]struct{}
  25529. clearedstage_nodes bool
  25530. stage_messages map[uint64]struct{}
  25531. removedstage_messages map[uint64]struct{}
  25532. clearedstage_messages bool
  25533. done bool
  25534. oldValue func(context.Context) (*SopStage, error)
  25535. predicates []predicate.SopStage
  25536. }
  25537. var _ ent.Mutation = (*SopStageMutation)(nil)
  25538. // sopstageOption allows management of the mutation configuration using functional options.
  25539. type sopstageOption func(*SopStageMutation)
  25540. // newSopStageMutation creates new mutation for the SopStage entity.
  25541. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  25542. m := &SopStageMutation{
  25543. config: c,
  25544. op: op,
  25545. typ: TypeSopStage,
  25546. clearedFields: make(map[string]struct{}),
  25547. }
  25548. for _, opt := range opts {
  25549. opt(m)
  25550. }
  25551. return m
  25552. }
  25553. // withSopStageID sets the ID field of the mutation.
  25554. func withSopStageID(id uint64) sopstageOption {
  25555. return func(m *SopStageMutation) {
  25556. var (
  25557. err error
  25558. once sync.Once
  25559. value *SopStage
  25560. )
  25561. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  25562. once.Do(func() {
  25563. if m.done {
  25564. err = errors.New("querying old values post mutation is not allowed")
  25565. } else {
  25566. value, err = m.Client().SopStage.Get(ctx, id)
  25567. }
  25568. })
  25569. return value, err
  25570. }
  25571. m.id = &id
  25572. }
  25573. }
  25574. // withSopStage sets the old SopStage of the mutation.
  25575. func withSopStage(node *SopStage) sopstageOption {
  25576. return func(m *SopStageMutation) {
  25577. m.oldValue = func(context.Context) (*SopStage, error) {
  25578. return node, nil
  25579. }
  25580. m.id = &node.ID
  25581. }
  25582. }
  25583. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25584. // executed in a transaction (ent.Tx), a transactional client is returned.
  25585. func (m SopStageMutation) Client() *Client {
  25586. client := &Client{config: m.config}
  25587. client.init()
  25588. return client
  25589. }
  25590. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25591. // it returns an error otherwise.
  25592. func (m SopStageMutation) Tx() (*Tx, error) {
  25593. if _, ok := m.driver.(*txDriver); !ok {
  25594. return nil, errors.New("ent: mutation is not running in a transaction")
  25595. }
  25596. tx := &Tx{config: m.config}
  25597. tx.init()
  25598. return tx, nil
  25599. }
  25600. // SetID sets the value of the id field. Note that this
  25601. // operation is only accepted on creation of SopStage entities.
  25602. func (m *SopStageMutation) SetID(id uint64) {
  25603. m.id = &id
  25604. }
  25605. // ID returns the ID value in the mutation. Note that the ID is only available
  25606. // if it was provided to the builder or after it was returned from the database.
  25607. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  25608. if m.id == nil {
  25609. return
  25610. }
  25611. return *m.id, true
  25612. }
  25613. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25614. // That means, if the mutation is applied within a transaction with an isolation level such
  25615. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25616. // or updated by the mutation.
  25617. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  25618. switch {
  25619. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25620. id, exists := m.ID()
  25621. if exists {
  25622. return []uint64{id}, nil
  25623. }
  25624. fallthrough
  25625. case m.op.Is(OpUpdate | OpDelete):
  25626. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  25627. default:
  25628. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25629. }
  25630. }
  25631. // SetCreatedAt sets the "created_at" field.
  25632. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  25633. m.created_at = &t
  25634. }
  25635. // CreatedAt returns the value of the "created_at" field in the mutation.
  25636. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  25637. v := m.created_at
  25638. if v == nil {
  25639. return
  25640. }
  25641. return *v, true
  25642. }
  25643. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  25644. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25646. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25647. if !m.op.Is(OpUpdateOne) {
  25648. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25649. }
  25650. if m.id == nil || m.oldValue == nil {
  25651. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25652. }
  25653. oldValue, err := m.oldValue(ctx)
  25654. if err != nil {
  25655. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25656. }
  25657. return oldValue.CreatedAt, nil
  25658. }
  25659. // ResetCreatedAt resets all changes to the "created_at" field.
  25660. func (m *SopStageMutation) ResetCreatedAt() {
  25661. m.created_at = nil
  25662. }
  25663. // SetUpdatedAt sets the "updated_at" field.
  25664. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  25665. m.updated_at = &t
  25666. }
  25667. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25668. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  25669. v := m.updated_at
  25670. if v == nil {
  25671. return
  25672. }
  25673. return *v, true
  25674. }
  25675. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  25676. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25678. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25679. if !m.op.Is(OpUpdateOne) {
  25680. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25681. }
  25682. if m.id == nil || m.oldValue == nil {
  25683. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25684. }
  25685. oldValue, err := m.oldValue(ctx)
  25686. if err != nil {
  25687. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25688. }
  25689. return oldValue.UpdatedAt, nil
  25690. }
  25691. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25692. func (m *SopStageMutation) ResetUpdatedAt() {
  25693. m.updated_at = nil
  25694. }
  25695. // SetStatus sets the "status" field.
  25696. func (m *SopStageMutation) SetStatus(u uint8) {
  25697. m.status = &u
  25698. m.addstatus = nil
  25699. }
  25700. // Status returns the value of the "status" field in the mutation.
  25701. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  25702. v := m.status
  25703. if v == nil {
  25704. return
  25705. }
  25706. return *v, true
  25707. }
  25708. // OldStatus returns the old "status" field's value of the SopStage entity.
  25709. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25711. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25712. if !m.op.Is(OpUpdateOne) {
  25713. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25714. }
  25715. if m.id == nil || m.oldValue == nil {
  25716. return v, errors.New("OldStatus requires an ID field in the mutation")
  25717. }
  25718. oldValue, err := m.oldValue(ctx)
  25719. if err != nil {
  25720. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25721. }
  25722. return oldValue.Status, nil
  25723. }
  25724. // AddStatus adds u to the "status" field.
  25725. func (m *SopStageMutation) AddStatus(u int8) {
  25726. if m.addstatus != nil {
  25727. *m.addstatus += u
  25728. } else {
  25729. m.addstatus = &u
  25730. }
  25731. }
  25732. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25733. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  25734. v := m.addstatus
  25735. if v == nil {
  25736. return
  25737. }
  25738. return *v, true
  25739. }
  25740. // ClearStatus clears the value of the "status" field.
  25741. func (m *SopStageMutation) ClearStatus() {
  25742. m.status = nil
  25743. m.addstatus = nil
  25744. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  25745. }
  25746. // StatusCleared returns if the "status" field was cleared in this mutation.
  25747. func (m *SopStageMutation) StatusCleared() bool {
  25748. _, ok := m.clearedFields[sopstage.FieldStatus]
  25749. return ok
  25750. }
  25751. // ResetStatus resets all changes to the "status" field.
  25752. func (m *SopStageMutation) ResetStatus() {
  25753. m.status = nil
  25754. m.addstatus = nil
  25755. delete(m.clearedFields, sopstage.FieldStatus)
  25756. }
  25757. // SetDeletedAt sets the "deleted_at" field.
  25758. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  25759. m.deleted_at = &t
  25760. }
  25761. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25762. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  25763. v := m.deleted_at
  25764. if v == nil {
  25765. return
  25766. }
  25767. return *v, true
  25768. }
  25769. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  25770. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25772. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25773. if !m.op.Is(OpUpdateOne) {
  25774. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25775. }
  25776. if m.id == nil || m.oldValue == nil {
  25777. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25778. }
  25779. oldValue, err := m.oldValue(ctx)
  25780. if err != nil {
  25781. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25782. }
  25783. return oldValue.DeletedAt, nil
  25784. }
  25785. // ClearDeletedAt clears the value of the "deleted_at" field.
  25786. func (m *SopStageMutation) ClearDeletedAt() {
  25787. m.deleted_at = nil
  25788. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  25789. }
  25790. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25791. func (m *SopStageMutation) DeletedAtCleared() bool {
  25792. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  25793. return ok
  25794. }
  25795. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25796. func (m *SopStageMutation) ResetDeletedAt() {
  25797. m.deleted_at = nil
  25798. delete(m.clearedFields, sopstage.FieldDeletedAt)
  25799. }
  25800. // SetTaskID sets the "task_id" field.
  25801. func (m *SopStageMutation) SetTaskID(u uint64) {
  25802. m.sop_task = &u
  25803. }
  25804. // TaskID returns the value of the "task_id" field in the mutation.
  25805. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  25806. v := m.sop_task
  25807. if v == nil {
  25808. return
  25809. }
  25810. return *v, true
  25811. }
  25812. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  25813. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25815. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  25816. if !m.op.Is(OpUpdateOne) {
  25817. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  25818. }
  25819. if m.id == nil || m.oldValue == nil {
  25820. return v, errors.New("OldTaskID requires an ID field in the mutation")
  25821. }
  25822. oldValue, err := m.oldValue(ctx)
  25823. if err != nil {
  25824. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  25825. }
  25826. return oldValue.TaskID, nil
  25827. }
  25828. // ResetTaskID resets all changes to the "task_id" field.
  25829. func (m *SopStageMutation) ResetTaskID() {
  25830. m.sop_task = nil
  25831. }
  25832. // SetName sets the "name" field.
  25833. func (m *SopStageMutation) SetName(s string) {
  25834. m.name = &s
  25835. }
  25836. // Name returns the value of the "name" field in the mutation.
  25837. func (m *SopStageMutation) Name() (r string, exists bool) {
  25838. v := m.name
  25839. if v == nil {
  25840. return
  25841. }
  25842. return *v, true
  25843. }
  25844. // OldName returns the old "name" field's value of the SopStage entity.
  25845. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25847. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  25848. if !m.op.Is(OpUpdateOne) {
  25849. return v, errors.New("OldName is only allowed on UpdateOne operations")
  25850. }
  25851. if m.id == nil || m.oldValue == nil {
  25852. return v, errors.New("OldName requires an ID field in the mutation")
  25853. }
  25854. oldValue, err := m.oldValue(ctx)
  25855. if err != nil {
  25856. return v, fmt.Errorf("querying old value for OldName: %w", err)
  25857. }
  25858. return oldValue.Name, nil
  25859. }
  25860. // ResetName resets all changes to the "name" field.
  25861. func (m *SopStageMutation) ResetName() {
  25862. m.name = nil
  25863. }
  25864. // SetConditionType sets the "condition_type" field.
  25865. func (m *SopStageMutation) SetConditionType(i int) {
  25866. m.condition_type = &i
  25867. m.addcondition_type = nil
  25868. }
  25869. // ConditionType returns the value of the "condition_type" field in the mutation.
  25870. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  25871. v := m.condition_type
  25872. if v == nil {
  25873. return
  25874. }
  25875. return *v, true
  25876. }
  25877. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  25878. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25880. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  25881. if !m.op.Is(OpUpdateOne) {
  25882. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  25883. }
  25884. if m.id == nil || m.oldValue == nil {
  25885. return v, errors.New("OldConditionType requires an ID field in the mutation")
  25886. }
  25887. oldValue, err := m.oldValue(ctx)
  25888. if err != nil {
  25889. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  25890. }
  25891. return oldValue.ConditionType, nil
  25892. }
  25893. // AddConditionType adds i to the "condition_type" field.
  25894. func (m *SopStageMutation) AddConditionType(i int) {
  25895. if m.addcondition_type != nil {
  25896. *m.addcondition_type += i
  25897. } else {
  25898. m.addcondition_type = &i
  25899. }
  25900. }
  25901. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  25902. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  25903. v := m.addcondition_type
  25904. if v == nil {
  25905. return
  25906. }
  25907. return *v, true
  25908. }
  25909. // ResetConditionType resets all changes to the "condition_type" field.
  25910. func (m *SopStageMutation) ResetConditionType() {
  25911. m.condition_type = nil
  25912. m.addcondition_type = nil
  25913. }
  25914. // SetConditionOperator sets the "condition_operator" field.
  25915. func (m *SopStageMutation) SetConditionOperator(i int) {
  25916. m.condition_operator = &i
  25917. m.addcondition_operator = nil
  25918. }
  25919. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  25920. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  25921. v := m.condition_operator
  25922. if v == nil {
  25923. return
  25924. }
  25925. return *v, true
  25926. }
  25927. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  25928. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25930. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  25931. if !m.op.Is(OpUpdateOne) {
  25932. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  25933. }
  25934. if m.id == nil || m.oldValue == nil {
  25935. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  25936. }
  25937. oldValue, err := m.oldValue(ctx)
  25938. if err != nil {
  25939. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  25940. }
  25941. return oldValue.ConditionOperator, nil
  25942. }
  25943. // AddConditionOperator adds i to the "condition_operator" field.
  25944. func (m *SopStageMutation) AddConditionOperator(i int) {
  25945. if m.addcondition_operator != nil {
  25946. *m.addcondition_operator += i
  25947. } else {
  25948. m.addcondition_operator = &i
  25949. }
  25950. }
  25951. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  25952. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  25953. v := m.addcondition_operator
  25954. if v == nil {
  25955. return
  25956. }
  25957. return *v, true
  25958. }
  25959. // ResetConditionOperator resets all changes to the "condition_operator" field.
  25960. func (m *SopStageMutation) ResetConditionOperator() {
  25961. m.condition_operator = nil
  25962. m.addcondition_operator = nil
  25963. }
  25964. // SetConditionList sets the "condition_list" field.
  25965. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  25966. m.condition_list = &ct
  25967. m.appendcondition_list = nil
  25968. }
  25969. // ConditionList returns the value of the "condition_list" field in the mutation.
  25970. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  25971. v := m.condition_list
  25972. if v == nil {
  25973. return
  25974. }
  25975. return *v, true
  25976. }
  25977. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  25978. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  25979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25980. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  25981. if !m.op.Is(OpUpdateOne) {
  25982. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  25983. }
  25984. if m.id == nil || m.oldValue == nil {
  25985. return v, errors.New("OldConditionList requires an ID field in the mutation")
  25986. }
  25987. oldValue, err := m.oldValue(ctx)
  25988. if err != nil {
  25989. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  25990. }
  25991. return oldValue.ConditionList, nil
  25992. }
  25993. // AppendConditionList adds ct to the "condition_list" field.
  25994. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  25995. m.appendcondition_list = append(m.appendcondition_list, ct...)
  25996. }
  25997. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  25998. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  25999. if len(m.appendcondition_list) == 0 {
  26000. return nil, false
  26001. }
  26002. return m.appendcondition_list, true
  26003. }
  26004. // ResetConditionList resets all changes to the "condition_list" field.
  26005. func (m *SopStageMutation) ResetConditionList() {
  26006. m.condition_list = nil
  26007. m.appendcondition_list = nil
  26008. }
  26009. // SetActionMessage sets the "action_message" field.
  26010. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  26011. m.action_message = &ct
  26012. m.appendaction_message = nil
  26013. }
  26014. // ActionMessage returns the value of the "action_message" field in the mutation.
  26015. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  26016. v := m.action_message
  26017. if v == nil {
  26018. return
  26019. }
  26020. return *v, true
  26021. }
  26022. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  26023. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26025. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  26026. if !m.op.Is(OpUpdateOne) {
  26027. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  26028. }
  26029. if m.id == nil || m.oldValue == nil {
  26030. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  26031. }
  26032. oldValue, err := m.oldValue(ctx)
  26033. if err != nil {
  26034. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  26035. }
  26036. return oldValue.ActionMessage, nil
  26037. }
  26038. // AppendActionMessage adds ct to the "action_message" field.
  26039. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  26040. m.appendaction_message = append(m.appendaction_message, ct...)
  26041. }
  26042. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  26043. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  26044. if len(m.appendaction_message) == 0 {
  26045. return nil, false
  26046. }
  26047. return m.appendaction_message, true
  26048. }
  26049. // ClearActionMessage clears the value of the "action_message" field.
  26050. func (m *SopStageMutation) ClearActionMessage() {
  26051. m.action_message = nil
  26052. m.appendaction_message = nil
  26053. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  26054. }
  26055. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  26056. func (m *SopStageMutation) ActionMessageCleared() bool {
  26057. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  26058. return ok
  26059. }
  26060. // ResetActionMessage resets all changes to the "action_message" field.
  26061. func (m *SopStageMutation) ResetActionMessage() {
  26062. m.action_message = nil
  26063. m.appendaction_message = nil
  26064. delete(m.clearedFields, sopstage.FieldActionMessage)
  26065. }
  26066. // SetActionLabelAdd sets the "action_label_add" field.
  26067. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  26068. m.action_label_add = &u
  26069. m.appendaction_label_add = nil
  26070. }
  26071. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  26072. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  26073. v := m.action_label_add
  26074. if v == nil {
  26075. return
  26076. }
  26077. return *v, true
  26078. }
  26079. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  26080. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26082. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  26083. if !m.op.Is(OpUpdateOne) {
  26084. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  26085. }
  26086. if m.id == nil || m.oldValue == nil {
  26087. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  26088. }
  26089. oldValue, err := m.oldValue(ctx)
  26090. if err != nil {
  26091. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  26092. }
  26093. return oldValue.ActionLabelAdd, nil
  26094. }
  26095. // AppendActionLabelAdd adds u to the "action_label_add" field.
  26096. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  26097. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  26098. }
  26099. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  26100. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  26101. if len(m.appendaction_label_add) == 0 {
  26102. return nil, false
  26103. }
  26104. return m.appendaction_label_add, true
  26105. }
  26106. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  26107. func (m *SopStageMutation) ClearActionLabelAdd() {
  26108. m.action_label_add = nil
  26109. m.appendaction_label_add = nil
  26110. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  26111. }
  26112. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  26113. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  26114. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  26115. return ok
  26116. }
  26117. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  26118. func (m *SopStageMutation) ResetActionLabelAdd() {
  26119. m.action_label_add = nil
  26120. m.appendaction_label_add = nil
  26121. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  26122. }
  26123. // SetActionLabelDel sets the "action_label_del" field.
  26124. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  26125. m.action_label_del = &u
  26126. m.appendaction_label_del = nil
  26127. }
  26128. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  26129. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  26130. v := m.action_label_del
  26131. if v == nil {
  26132. return
  26133. }
  26134. return *v, true
  26135. }
  26136. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  26137. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26139. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  26140. if !m.op.Is(OpUpdateOne) {
  26141. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  26142. }
  26143. if m.id == nil || m.oldValue == nil {
  26144. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  26145. }
  26146. oldValue, err := m.oldValue(ctx)
  26147. if err != nil {
  26148. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  26149. }
  26150. return oldValue.ActionLabelDel, nil
  26151. }
  26152. // AppendActionLabelDel adds u to the "action_label_del" field.
  26153. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  26154. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  26155. }
  26156. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  26157. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  26158. if len(m.appendaction_label_del) == 0 {
  26159. return nil, false
  26160. }
  26161. return m.appendaction_label_del, true
  26162. }
  26163. // ClearActionLabelDel clears the value of the "action_label_del" field.
  26164. func (m *SopStageMutation) ClearActionLabelDel() {
  26165. m.action_label_del = nil
  26166. m.appendaction_label_del = nil
  26167. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  26168. }
  26169. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  26170. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  26171. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  26172. return ok
  26173. }
  26174. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  26175. func (m *SopStageMutation) ResetActionLabelDel() {
  26176. m.action_label_del = nil
  26177. m.appendaction_label_del = nil
  26178. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  26179. }
  26180. // SetActionForward sets the "action_forward" field.
  26181. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  26182. m.action_forward = &ctf
  26183. }
  26184. // ActionForward returns the value of the "action_forward" field in the mutation.
  26185. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  26186. v := m.action_forward
  26187. if v == nil {
  26188. return
  26189. }
  26190. return *v, true
  26191. }
  26192. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  26193. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26195. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  26196. if !m.op.Is(OpUpdateOne) {
  26197. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  26198. }
  26199. if m.id == nil || m.oldValue == nil {
  26200. return v, errors.New("OldActionForward requires an ID field in the mutation")
  26201. }
  26202. oldValue, err := m.oldValue(ctx)
  26203. if err != nil {
  26204. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  26205. }
  26206. return oldValue.ActionForward, nil
  26207. }
  26208. // ClearActionForward clears the value of the "action_forward" field.
  26209. func (m *SopStageMutation) ClearActionForward() {
  26210. m.action_forward = nil
  26211. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  26212. }
  26213. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  26214. func (m *SopStageMutation) ActionForwardCleared() bool {
  26215. _, ok := m.clearedFields[sopstage.FieldActionForward]
  26216. return ok
  26217. }
  26218. // ResetActionForward resets all changes to the "action_forward" field.
  26219. func (m *SopStageMutation) ResetActionForward() {
  26220. m.action_forward = nil
  26221. delete(m.clearedFields, sopstage.FieldActionForward)
  26222. }
  26223. // SetIndexSort sets the "index_sort" field.
  26224. func (m *SopStageMutation) SetIndexSort(i int) {
  26225. m.index_sort = &i
  26226. m.addindex_sort = nil
  26227. }
  26228. // IndexSort returns the value of the "index_sort" field in the mutation.
  26229. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  26230. v := m.index_sort
  26231. if v == nil {
  26232. return
  26233. }
  26234. return *v, true
  26235. }
  26236. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  26237. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  26238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26239. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  26240. if !m.op.Is(OpUpdateOne) {
  26241. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  26242. }
  26243. if m.id == nil || m.oldValue == nil {
  26244. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  26245. }
  26246. oldValue, err := m.oldValue(ctx)
  26247. if err != nil {
  26248. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  26249. }
  26250. return oldValue.IndexSort, nil
  26251. }
  26252. // AddIndexSort adds i to the "index_sort" field.
  26253. func (m *SopStageMutation) AddIndexSort(i int) {
  26254. if m.addindex_sort != nil {
  26255. *m.addindex_sort += i
  26256. } else {
  26257. m.addindex_sort = &i
  26258. }
  26259. }
  26260. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  26261. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  26262. v := m.addindex_sort
  26263. if v == nil {
  26264. return
  26265. }
  26266. return *v, true
  26267. }
  26268. // ClearIndexSort clears the value of the "index_sort" field.
  26269. func (m *SopStageMutation) ClearIndexSort() {
  26270. m.index_sort = nil
  26271. m.addindex_sort = nil
  26272. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  26273. }
  26274. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  26275. func (m *SopStageMutation) IndexSortCleared() bool {
  26276. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  26277. return ok
  26278. }
  26279. // ResetIndexSort resets all changes to the "index_sort" field.
  26280. func (m *SopStageMutation) ResetIndexSort() {
  26281. m.index_sort = nil
  26282. m.addindex_sort = nil
  26283. delete(m.clearedFields, sopstage.FieldIndexSort)
  26284. }
  26285. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  26286. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  26287. m.sop_task = &id
  26288. }
  26289. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  26290. func (m *SopStageMutation) ClearSopTask() {
  26291. m.clearedsop_task = true
  26292. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  26293. }
  26294. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  26295. func (m *SopStageMutation) SopTaskCleared() bool {
  26296. return m.clearedsop_task
  26297. }
  26298. // SopTaskID returns the "sop_task" edge ID in the mutation.
  26299. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  26300. if m.sop_task != nil {
  26301. return *m.sop_task, true
  26302. }
  26303. return
  26304. }
  26305. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  26306. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26307. // SopTaskID instead. It exists only for internal usage by the builders.
  26308. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  26309. if id := m.sop_task; id != nil {
  26310. ids = append(ids, *id)
  26311. }
  26312. return
  26313. }
  26314. // ResetSopTask resets all changes to the "sop_task" edge.
  26315. func (m *SopStageMutation) ResetSopTask() {
  26316. m.sop_task = nil
  26317. m.clearedsop_task = false
  26318. }
  26319. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  26320. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  26321. if m.stage_nodes == nil {
  26322. m.stage_nodes = make(map[uint64]struct{})
  26323. }
  26324. for i := range ids {
  26325. m.stage_nodes[ids[i]] = struct{}{}
  26326. }
  26327. }
  26328. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  26329. func (m *SopStageMutation) ClearStageNodes() {
  26330. m.clearedstage_nodes = true
  26331. }
  26332. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  26333. func (m *SopStageMutation) StageNodesCleared() bool {
  26334. return m.clearedstage_nodes
  26335. }
  26336. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  26337. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  26338. if m.removedstage_nodes == nil {
  26339. m.removedstage_nodes = make(map[uint64]struct{})
  26340. }
  26341. for i := range ids {
  26342. delete(m.stage_nodes, ids[i])
  26343. m.removedstage_nodes[ids[i]] = struct{}{}
  26344. }
  26345. }
  26346. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  26347. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  26348. for id := range m.removedstage_nodes {
  26349. ids = append(ids, id)
  26350. }
  26351. return
  26352. }
  26353. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  26354. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  26355. for id := range m.stage_nodes {
  26356. ids = append(ids, id)
  26357. }
  26358. return
  26359. }
  26360. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  26361. func (m *SopStageMutation) ResetStageNodes() {
  26362. m.stage_nodes = nil
  26363. m.clearedstage_nodes = false
  26364. m.removedstage_nodes = nil
  26365. }
  26366. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  26367. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  26368. if m.stage_messages == nil {
  26369. m.stage_messages = make(map[uint64]struct{})
  26370. }
  26371. for i := range ids {
  26372. m.stage_messages[ids[i]] = struct{}{}
  26373. }
  26374. }
  26375. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  26376. func (m *SopStageMutation) ClearStageMessages() {
  26377. m.clearedstage_messages = true
  26378. }
  26379. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  26380. func (m *SopStageMutation) StageMessagesCleared() bool {
  26381. return m.clearedstage_messages
  26382. }
  26383. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  26384. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  26385. if m.removedstage_messages == nil {
  26386. m.removedstage_messages = make(map[uint64]struct{})
  26387. }
  26388. for i := range ids {
  26389. delete(m.stage_messages, ids[i])
  26390. m.removedstage_messages[ids[i]] = struct{}{}
  26391. }
  26392. }
  26393. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  26394. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  26395. for id := range m.removedstage_messages {
  26396. ids = append(ids, id)
  26397. }
  26398. return
  26399. }
  26400. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  26401. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  26402. for id := range m.stage_messages {
  26403. ids = append(ids, id)
  26404. }
  26405. return
  26406. }
  26407. // ResetStageMessages resets all changes to the "stage_messages" edge.
  26408. func (m *SopStageMutation) ResetStageMessages() {
  26409. m.stage_messages = nil
  26410. m.clearedstage_messages = false
  26411. m.removedstage_messages = nil
  26412. }
  26413. // Where appends a list predicates to the SopStageMutation builder.
  26414. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  26415. m.predicates = append(m.predicates, ps...)
  26416. }
  26417. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  26418. // users can use type-assertion to append predicates that do not depend on any generated package.
  26419. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  26420. p := make([]predicate.SopStage, len(ps))
  26421. for i := range ps {
  26422. p[i] = ps[i]
  26423. }
  26424. m.Where(p...)
  26425. }
  26426. // Op returns the operation name.
  26427. func (m *SopStageMutation) Op() Op {
  26428. return m.op
  26429. }
  26430. // SetOp allows setting the mutation operation.
  26431. func (m *SopStageMutation) SetOp(op Op) {
  26432. m.op = op
  26433. }
  26434. // Type returns the node type of this mutation (SopStage).
  26435. func (m *SopStageMutation) Type() string {
  26436. return m.typ
  26437. }
  26438. // Fields returns all fields that were changed during this mutation. Note that in
  26439. // order to get all numeric fields that were incremented/decremented, call
  26440. // AddedFields().
  26441. func (m *SopStageMutation) Fields() []string {
  26442. fields := make([]string, 0, 14)
  26443. if m.created_at != nil {
  26444. fields = append(fields, sopstage.FieldCreatedAt)
  26445. }
  26446. if m.updated_at != nil {
  26447. fields = append(fields, sopstage.FieldUpdatedAt)
  26448. }
  26449. if m.status != nil {
  26450. fields = append(fields, sopstage.FieldStatus)
  26451. }
  26452. if m.deleted_at != nil {
  26453. fields = append(fields, sopstage.FieldDeletedAt)
  26454. }
  26455. if m.sop_task != nil {
  26456. fields = append(fields, sopstage.FieldTaskID)
  26457. }
  26458. if m.name != nil {
  26459. fields = append(fields, sopstage.FieldName)
  26460. }
  26461. if m.condition_type != nil {
  26462. fields = append(fields, sopstage.FieldConditionType)
  26463. }
  26464. if m.condition_operator != nil {
  26465. fields = append(fields, sopstage.FieldConditionOperator)
  26466. }
  26467. if m.condition_list != nil {
  26468. fields = append(fields, sopstage.FieldConditionList)
  26469. }
  26470. if m.action_message != nil {
  26471. fields = append(fields, sopstage.FieldActionMessage)
  26472. }
  26473. if m.action_label_add != nil {
  26474. fields = append(fields, sopstage.FieldActionLabelAdd)
  26475. }
  26476. if m.action_label_del != nil {
  26477. fields = append(fields, sopstage.FieldActionLabelDel)
  26478. }
  26479. if m.action_forward != nil {
  26480. fields = append(fields, sopstage.FieldActionForward)
  26481. }
  26482. if m.index_sort != nil {
  26483. fields = append(fields, sopstage.FieldIndexSort)
  26484. }
  26485. return fields
  26486. }
  26487. // Field returns the value of a field with the given name. The second boolean
  26488. // return value indicates that this field was not set, or was not defined in the
  26489. // schema.
  26490. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  26491. switch name {
  26492. case sopstage.FieldCreatedAt:
  26493. return m.CreatedAt()
  26494. case sopstage.FieldUpdatedAt:
  26495. return m.UpdatedAt()
  26496. case sopstage.FieldStatus:
  26497. return m.Status()
  26498. case sopstage.FieldDeletedAt:
  26499. return m.DeletedAt()
  26500. case sopstage.FieldTaskID:
  26501. return m.TaskID()
  26502. case sopstage.FieldName:
  26503. return m.Name()
  26504. case sopstage.FieldConditionType:
  26505. return m.ConditionType()
  26506. case sopstage.FieldConditionOperator:
  26507. return m.ConditionOperator()
  26508. case sopstage.FieldConditionList:
  26509. return m.ConditionList()
  26510. case sopstage.FieldActionMessage:
  26511. return m.ActionMessage()
  26512. case sopstage.FieldActionLabelAdd:
  26513. return m.ActionLabelAdd()
  26514. case sopstage.FieldActionLabelDel:
  26515. return m.ActionLabelDel()
  26516. case sopstage.FieldActionForward:
  26517. return m.ActionForward()
  26518. case sopstage.FieldIndexSort:
  26519. return m.IndexSort()
  26520. }
  26521. return nil, false
  26522. }
  26523. // OldField returns the old value of the field from the database. An error is
  26524. // returned if the mutation operation is not UpdateOne, or the query to the
  26525. // database failed.
  26526. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26527. switch name {
  26528. case sopstage.FieldCreatedAt:
  26529. return m.OldCreatedAt(ctx)
  26530. case sopstage.FieldUpdatedAt:
  26531. return m.OldUpdatedAt(ctx)
  26532. case sopstage.FieldStatus:
  26533. return m.OldStatus(ctx)
  26534. case sopstage.FieldDeletedAt:
  26535. return m.OldDeletedAt(ctx)
  26536. case sopstage.FieldTaskID:
  26537. return m.OldTaskID(ctx)
  26538. case sopstage.FieldName:
  26539. return m.OldName(ctx)
  26540. case sopstage.FieldConditionType:
  26541. return m.OldConditionType(ctx)
  26542. case sopstage.FieldConditionOperator:
  26543. return m.OldConditionOperator(ctx)
  26544. case sopstage.FieldConditionList:
  26545. return m.OldConditionList(ctx)
  26546. case sopstage.FieldActionMessage:
  26547. return m.OldActionMessage(ctx)
  26548. case sopstage.FieldActionLabelAdd:
  26549. return m.OldActionLabelAdd(ctx)
  26550. case sopstage.FieldActionLabelDel:
  26551. return m.OldActionLabelDel(ctx)
  26552. case sopstage.FieldActionForward:
  26553. return m.OldActionForward(ctx)
  26554. case sopstage.FieldIndexSort:
  26555. return m.OldIndexSort(ctx)
  26556. }
  26557. return nil, fmt.Errorf("unknown SopStage field %s", name)
  26558. }
  26559. // SetField sets the value of a field with the given name. It returns an error if
  26560. // the field is not defined in the schema, or if the type mismatched the field
  26561. // type.
  26562. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  26563. switch name {
  26564. case sopstage.FieldCreatedAt:
  26565. v, ok := value.(time.Time)
  26566. if !ok {
  26567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26568. }
  26569. m.SetCreatedAt(v)
  26570. return nil
  26571. case sopstage.FieldUpdatedAt:
  26572. v, ok := value.(time.Time)
  26573. if !ok {
  26574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26575. }
  26576. m.SetUpdatedAt(v)
  26577. return nil
  26578. case sopstage.FieldStatus:
  26579. v, ok := value.(uint8)
  26580. if !ok {
  26581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26582. }
  26583. m.SetStatus(v)
  26584. return nil
  26585. case sopstage.FieldDeletedAt:
  26586. v, ok := value.(time.Time)
  26587. if !ok {
  26588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26589. }
  26590. m.SetDeletedAt(v)
  26591. return nil
  26592. case sopstage.FieldTaskID:
  26593. v, ok := value.(uint64)
  26594. if !ok {
  26595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26596. }
  26597. m.SetTaskID(v)
  26598. return nil
  26599. case sopstage.FieldName:
  26600. v, ok := value.(string)
  26601. if !ok {
  26602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26603. }
  26604. m.SetName(v)
  26605. return nil
  26606. case sopstage.FieldConditionType:
  26607. v, ok := value.(int)
  26608. if !ok {
  26609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26610. }
  26611. m.SetConditionType(v)
  26612. return nil
  26613. case sopstage.FieldConditionOperator:
  26614. v, ok := value.(int)
  26615. if !ok {
  26616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26617. }
  26618. m.SetConditionOperator(v)
  26619. return nil
  26620. case sopstage.FieldConditionList:
  26621. v, ok := value.([]custom_types.Condition)
  26622. if !ok {
  26623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26624. }
  26625. m.SetConditionList(v)
  26626. return nil
  26627. case sopstage.FieldActionMessage:
  26628. v, ok := value.([]custom_types.Action)
  26629. if !ok {
  26630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26631. }
  26632. m.SetActionMessage(v)
  26633. return nil
  26634. case sopstage.FieldActionLabelAdd:
  26635. v, ok := value.([]uint64)
  26636. if !ok {
  26637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26638. }
  26639. m.SetActionLabelAdd(v)
  26640. return nil
  26641. case sopstage.FieldActionLabelDel:
  26642. v, ok := value.([]uint64)
  26643. if !ok {
  26644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26645. }
  26646. m.SetActionLabelDel(v)
  26647. return nil
  26648. case sopstage.FieldActionForward:
  26649. v, ok := value.(*custom_types.ActionForward)
  26650. if !ok {
  26651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26652. }
  26653. m.SetActionForward(v)
  26654. return nil
  26655. case sopstage.FieldIndexSort:
  26656. v, ok := value.(int)
  26657. if !ok {
  26658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26659. }
  26660. m.SetIndexSort(v)
  26661. return nil
  26662. }
  26663. return fmt.Errorf("unknown SopStage field %s", name)
  26664. }
  26665. // AddedFields returns all numeric fields that were incremented/decremented during
  26666. // this mutation.
  26667. func (m *SopStageMutation) AddedFields() []string {
  26668. var fields []string
  26669. if m.addstatus != nil {
  26670. fields = append(fields, sopstage.FieldStatus)
  26671. }
  26672. if m.addcondition_type != nil {
  26673. fields = append(fields, sopstage.FieldConditionType)
  26674. }
  26675. if m.addcondition_operator != nil {
  26676. fields = append(fields, sopstage.FieldConditionOperator)
  26677. }
  26678. if m.addindex_sort != nil {
  26679. fields = append(fields, sopstage.FieldIndexSort)
  26680. }
  26681. return fields
  26682. }
  26683. // AddedField returns the numeric value that was incremented/decremented on a field
  26684. // with the given name. The second boolean return value indicates that this field
  26685. // was not set, or was not defined in the schema.
  26686. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  26687. switch name {
  26688. case sopstage.FieldStatus:
  26689. return m.AddedStatus()
  26690. case sopstage.FieldConditionType:
  26691. return m.AddedConditionType()
  26692. case sopstage.FieldConditionOperator:
  26693. return m.AddedConditionOperator()
  26694. case sopstage.FieldIndexSort:
  26695. return m.AddedIndexSort()
  26696. }
  26697. return nil, false
  26698. }
  26699. // AddField adds the value to the field with the given name. It returns an error if
  26700. // the field is not defined in the schema, or if the type mismatched the field
  26701. // type.
  26702. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  26703. switch name {
  26704. case sopstage.FieldStatus:
  26705. v, ok := value.(int8)
  26706. if !ok {
  26707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26708. }
  26709. m.AddStatus(v)
  26710. return nil
  26711. case sopstage.FieldConditionType:
  26712. v, ok := value.(int)
  26713. if !ok {
  26714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26715. }
  26716. m.AddConditionType(v)
  26717. return nil
  26718. case sopstage.FieldConditionOperator:
  26719. v, ok := value.(int)
  26720. if !ok {
  26721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26722. }
  26723. m.AddConditionOperator(v)
  26724. return nil
  26725. case sopstage.FieldIndexSort:
  26726. v, ok := value.(int)
  26727. if !ok {
  26728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26729. }
  26730. m.AddIndexSort(v)
  26731. return nil
  26732. }
  26733. return fmt.Errorf("unknown SopStage numeric field %s", name)
  26734. }
  26735. // ClearedFields returns all nullable fields that were cleared during this
  26736. // mutation.
  26737. func (m *SopStageMutation) ClearedFields() []string {
  26738. var fields []string
  26739. if m.FieldCleared(sopstage.FieldStatus) {
  26740. fields = append(fields, sopstage.FieldStatus)
  26741. }
  26742. if m.FieldCleared(sopstage.FieldDeletedAt) {
  26743. fields = append(fields, sopstage.FieldDeletedAt)
  26744. }
  26745. if m.FieldCleared(sopstage.FieldActionMessage) {
  26746. fields = append(fields, sopstage.FieldActionMessage)
  26747. }
  26748. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  26749. fields = append(fields, sopstage.FieldActionLabelAdd)
  26750. }
  26751. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  26752. fields = append(fields, sopstage.FieldActionLabelDel)
  26753. }
  26754. if m.FieldCleared(sopstage.FieldActionForward) {
  26755. fields = append(fields, sopstage.FieldActionForward)
  26756. }
  26757. if m.FieldCleared(sopstage.FieldIndexSort) {
  26758. fields = append(fields, sopstage.FieldIndexSort)
  26759. }
  26760. return fields
  26761. }
  26762. // FieldCleared returns a boolean indicating if a field with the given name was
  26763. // cleared in this mutation.
  26764. func (m *SopStageMutation) FieldCleared(name string) bool {
  26765. _, ok := m.clearedFields[name]
  26766. return ok
  26767. }
  26768. // ClearField clears the value of the field with the given name. It returns an
  26769. // error if the field is not defined in the schema.
  26770. func (m *SopStageMutation) ClearField(name string) error {
  26771. switch name {
  26772. case sopstage.FieldStatus:
  26773. m.ClearStatus()
  26774. return nil
  26775. case sopstage.FieldDeletedAt:
  26776. m.ClearDeletedAt()
  26777. return nil
  26778. case sopstage.FieldActionMessage:
  26779. m.ClearActionMessage()
  26780. return nil
  26781. case sopstage.FieldActionLabelAdd:
  26782. m.ClearActionLabelAdd()
  26783. return nil
  26784. case sopstage.FieldActionLabelDel:
  26785. m.ClearActionLabelDel()
  26786. return nil
  26787. case sopstage.FieldActionForward:
  26788. m.ClearActionForward()
  26789. return nil
  26790. case sopstage.FieldIndexSort:
  26791. m.ClearIndexSort()
  26792. return nil
  26793. }
  26794. return fmt.Errorf("unknown SopStage nullable field %s", name)
  26795. }
  26796. // ResetField resets all changes in the mutation for the field with the given name.
  26797. // It returns an error if the field is not defined in the schema.
  26798. func (m *SopStageMutation) ResetField(name string) error {
  26799. switch name {
  26800. case sopstage.FieldCreatedAt:
  26801. m.ResetCreatedAt()
  26802. return nil
  26803. case sopstage.FieldUpdatedAt:
  26804. m.ResetUpdatedAt()
  26805. return nil
  26806. case sopstage.FieldStatus:
  26807. m.ResetStatus()
  26808. return nil
  26809. case sopstage.FieldDeletedAt:
  26810. m.ResetDeletedAt()
  26811. return nil
  26812. case sopstage.FieldTaskID:
  26813. m.ResetTaskID()
  26814. return nil
  26815. case sopstage.FieldName:
  26816. m.ResetName()
  26817. return nil
  26818. case sopstage.FieldConditionType:
  26819. m.ResetConditionType()
  26820. return nil
  26821. case sopstage.FieldConditionOperator:
  26822. m.ResetConditionOperator()
  26823. return nil
  26824. case sopstage.FieldConditionList:
  26825. m.ResetConditionList()
  26826. return nil
  26827. case sopstage.FieldActionMessage:
  26828. m.ResetActionMessage()
  26829. return nil
  26830. case sopstage.FieldActionLabelAdd:
  26831. m.ResetActionLabelAdd()
  26832. return nil
  26833. case sopstage.FieldActionLabelDel:
  26834. m.ResetActionLabelDel()
  26835. return nil
  26836. case sopstage.FieldActionForward:
  26837. m.ResetActionForward()
  26838. return nil
  26839. case sopstage.FieldIndexSort:
  26840. m.ResetIndexSort()
  26841. return nil
  26842. }
  26843. return fmt.Errorf("unknown SopStage field %s", name)
  26844. }
  26845. // AddedEdges returns all edge names that were set/added in this mutation.
  26846. func (m *SopStageMutation) AddedEdges() []string {
  26847. edges := make([]string, 0, 3)
  26848. if m.sop_task != nil {
  26849. edges = append(edges, sopstage.EdgeSopTask)
  26850. }
  26851. if m.stage_nodes != nil {
  26852. edges = append(edges, sopstage.EdgeStageNodes)
  26853. }
  26854. if m.stage_messages != nil {
  26855. edges = append(edges, sopstage.EdgeStageMessages)
  26856. }
  26857. return edges
  26858. }
  26859. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26860. // name in this mutation.
  26861. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  26862. switch name {
  26863. case sopstage.EdgeSopTask:
  26864. if id := m.sop_task; id != nil {
  26865. return []ent.Value{*id}
  26866. }
  26867. case sopstage.EdgeStageNodes:
  26868. ids := make([]ent.Value, 0, len(m.stage_nodes))
  26869. for id := range m.stage_nodes {
  26870. ids = append(ids, id)
  26871. }
  26872. return ids
  26873. case sopstage.EdgeStageMessages:
  26874. ids := make([]ent.Value, 0, len(m.stage_messages))
  26875. for id := range m.stage_messages {
  26876. ids = append(ids, id)
  26877. }
  26878. return ids
  26879. }
  26880. return nil
  26881. }
  26882. // RemovedEdges returns all edge names that were removed in this mutation.
  26883. func (m *SopStageMutation) RemovedEdges() []string {
  26884. edges := make([]string, 0, 3)
  26885. if m.removedstage_nodes != nil {
  26886. edges = append(edges, sopstage.EdgeStageNodes)
  26887. }
  26888. if m.removedstage_messages != nil {
  26889. edges = append(edges, sopstage.EdgeStageMessages)
  26890. }
  26891. return edges
  26892. }
  26893. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26894. // the given name in this mutation.
  26895. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  26896. switch name {
  26897. case sopstage.EdgeStageNodes:
  26898. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  26899. for id := range m.removedstage_nodes {
  26900. ids = append(ids, id)
  26901. }
  26902. return ids
  26903. case sopstage.EdgeStageMessages:
  26904. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  26905. for id := range m.removedstage_messages {
  26906. ids = append(ids, id)
  26907. }
  26908. return ids
  26909. }
  26910. return nil
  26911. }
  26912. // ClearedEdges returns all edge names that were cleared in this mutation.
  26913. func (m *SopStageMutation) ClearedEdges() []string {
  26914. edges := make([]string, 0, 3)
  26915. if m.clearedsop_task {
  26916. edges = append(edges, sopstage.EdgeSopTask)
  26917. }
  26918. if m.clearedstage_nodes {
  26919. edges = append(edges, sopstage.EdgeStageNodes)
  26920. }
  26921. if m.clearedstage_messages {
  26922. edges = append(edges, sopstage.EdgeStageMessages)
  26923. }
  26924. return edges
  26925. }
  26926. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26927. // was cleared in this mutation.
  26928. func (m *SopStageMutation) EdgeCleared(name string) bool {
  26929. switch name {
  26930. case sopstage.EdgeSopTask:
  26931. return m.clearedsop_task
  26932. case sopstage.EdgeStageNodes:
  26933. return m.clearedstage_nodes
  26934. case sopstage.EdgeStageMessages:
  26935. return m.clearedstage_messages
  26936. }
  26937. return false
  26938. }
  26939. // ClearEdge clears the value of the edge with the given name. It returns an error
  26940. // if that edge is not defined in the schema.
  26941. func (m *SopStageMutation) ClearEdge(name string) error {
  26942. switch name {
  26943. case sopstage.EdgeSopTask:
  26944. m.ClearSopTask()
  26945. return nil
  26946. }
  26947. return fmt.Errorf("unknown SopStage unique edge %s", name)
  26948. }
  26949. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26950. // It returns an error if the edge is not defined in the schema.
  26951. func (m *SopStageMutation) ResetEdge(name string) error {
  26952. switch name {
  26953. case sopstage.EdgeSopTask:
  26954. m.ResetSopTask()
  26955. return nil
  26956. case sopstage.EdgeStageNodes:
  26957. m.ResetStageNodes()
  26958. return nil
  26959. case sopstage.EdgeStageMessages:
  26960. m.ResetStageMessages()
  26961. return nil
  26962. }
  26963. return fmt.Errorf("unknown SopStage edge %s", name)
  26964. }
  26965. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  26966. type SopTaskMutation struct {
  26967. config
  26968. op Op
  26969. typ string
  26970. id *uint64
  26971. created_at *time.Time
  26972. updated_at *time.Time
  26973. status *uint8
  26974. addstatus *int8
  26975. deleted_at *time.Time
  26976. name *string
  26977. bot_wxid_list *[]string
  26978. appendbot_wxid_list []string
  26979. _type *int
  26980. add_type *int
  26981. plan_start_time *time.Time
  26982. plan_end_time *time.Time
  26983. creator_id *string
  26984. organization_id *uint64
  26985. addorganization_id *int64
  26986. token *[]string
  26987. appendtoken []string
  26988. clearedFields map[string]struct{}
  26989. task_stages map[uint64]struct{}
  26990. removedtask_stages map[uint64]struct{}
  26991. clearedtask_stages bool
  26992. done bool
  26993. oldValue func(context.Context) (*SopTask, error)
  26994. predicates []predicate.SopTask
  26995. }
  26996. var _ ent.Mutation = (*SopTaskMutation)(nil)
  26997. // soptaskOption allows management of the mutation configuration using functional options.
  26998. type soptaskOption func(*SopTaskMutation)
  26999. // newSopTaskMutation creates new mutation for the SopTask entity.
  27000. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  27001. m := &SopTaskMutation{
  27002. config: c,
  27003. op: op,
  27004. typ: TypeSopTask,
  27005. clearedFields: make(map[string]struct{}),
  27006. }
  27007. for _, opt := range opts {
  27008. opt(m)
  27009. }
  27010. return m
  27011. }
  27012. // withSopTaskID sets the ID field of the mutation.
  27013. func withSopTaskID(id uint64) soptaskOption {
  27014. return func(m *SopTaskMutation) {
  27015. var (
  27016. err error
  27017. once sync.Once
  27018. value *SopTask
  27019. )
  27020. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  27021. once.Do(func() {
  27022. if m.done {
  27023. err = errors.New("querying old values post mutation is not allowed")
  27024. } else {
  27025. value, err = m.Client().SopTask.Get(ctx, id)
  27026. }
  27027. })
  27028. return value, err
  27029. }
  27030. m.id = &id
  27031. }
  27032. }
  27033. // withSopTask sets the old SopTask of the mutation.
  27034. func withSopTask(node *SopTask) soptaskOption {
  27035. return func(m *SopTaskMutation) {
  27036. m.oldValue = func(context.Context) (*SopTask, error) {
  27037. return node, nil
  27038. }
  27039. m.id = &node.ID
  27040. }
  27041. }
  27042. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27043. // executed in a transaction (ent.Tx), a transactional client is returned.
  27044. func (m SopTaskMutation) Client() *Client {
  27045. client := &Client{config: m.config}
  27046. client.init()
  27047. return client
  27048. }
  27049. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27050. // it returns an error otherwise.
  27051. func (m SopTaskMutation) Tx() (*Tx, error) {
  27052. if _, ok := m.driver.(*txDriver); !ok {
  27053. return nil, errors.New("ent: mutation is not running in a transaction")
  27054. }
  27055. tx := &Tx{config: m.config}
  27056. tx.init()
  27057. return tx, nil
  27058. }
  27059. // SetID sets the value of the id field. Note that this
  27060. // operation is only accepted on creation of SopTask entities.
  27061. func (m *SopTaskMutation) SetID(id uint64) {
  27062. m.id = &id
  27063. }
  27064. // ID returns the ID value in the mutation. Note that the ID is only available
  27065. // if it was provided to the builder or after it was returned from the database.
  27066. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  27067. if m.id == nil {
  27068. return
  27069. }
  27070. return *m.id, true
  27071. }
  27072. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27073. // That means, if the mutation is applied within a transaction with an isolation level such
  27074. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27075. // or updated by the mutation.
  27076. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  27077. switch {
  27078. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27079. id, exists := m.ID()
  27080. if exists {
  27081. return []uint64{id}, nil
  27082. }
  27083. fallthrough
  27084. case m.op.Is(OpUpdate | OpDelete):
  27085. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  27086. default:
  27087. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27088. }
  27089. }
  27090. // SetCreatedAt sets the "created_at" field.
  27091. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  27092. m.created_at = &t
  27093. }
  27094. // CreatedAt returns the value of the "created_at" field in the mutation.
  27095. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  27096. v := m.created_at
  27097. if v == nil {
  27098. return
  27099. }
  27100. return *v, true
  27101. }
  27102. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  27103. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27105. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27106. if !m.op.Is(OpUpdateOne) {
  27107. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27108. }
  27109. if m.id == nil || m.oldValue == nil {
  27110. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27111. }
  27112. oldValue, err := m.oldValue(ctx)
  27113. if err != nil {
  27114. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27115. }
  27116. return oldValue.CreatedAt, nil
  27117. }
  27118. // ResetCreatedAt resets all changes to the "created_at" field.
  27119. func (m *SopTaskMutation) ResetCreatedAt() {
  27120. m.created_at = nil
  27121. }
  27122. // SetUpdatedAt sets the "updated_at" field.
  27123. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  27124. m.updated_at = &t
  27125. }
  27126. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27127. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  27128. v := m.updated_at
  27129. if v == nil {
  27130. return
  27131. }
  27132. return *v, true
  27133. }
  27134. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  27135. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27137. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27138. if !m.op.Is(OpUpdateOne) {
  27139. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27140. }
  27141. if m.id == nil || m.oldValue == nil {
  27142. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27143. }
  27144. oldValue, err := m.oldValue(ctx)
  27145. if err != nil {
  27146. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27147. }
  27148. return oldValue.UpdatedAt, nil
  27149. }
  27150. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27151. func (m *SopTaskMutation) ResetUpdatedAt() {
  27152. m.updated_at = nil
  27153. }
  27154. // SetStatus sets the "status" field.
  27155. func (m *SopTaskMutation) SetStatus(u uint8) {
  27156. m.status = &u
  27157. m.addstatus = nil
  27158. }
  27159. // Status returns the value of the "status" field in the mutation.
  27160. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  27161. v := m.status
  27162. if v == nil {
  27163. return
  27164. }
  27165. return *v, true
  27166. }
  27167. // OldStatus returns the old "status" field's value of the SopTask entity.
  27168. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27170. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27171. if !m.op.Is(OpUpdateOne) {
  27172. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27173. }
  27174. if m.id == nil || m.oldValue == nil {
  27175. return v, errors.New("OldStatus requires an ID field in the mutation")
  27176. }
  27177. oldValue, err := m.oldValue(ctx)
  27178. if err != nil {
  27179. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27180. }
  27181. return oldValue.Status, nil
  27182. }
  27183. // AddStatus adds u to the "status" field.
  27184. func (m *SopTaskMutation) AddStatus(u int8) {
  27185. if m.addstatus != nil {
  27186. *m.addstatus += u
  27187. } else {
  27188. m.addstatus = &u
  27189. }
  27190. }
  27191. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27192. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  27193. v := m.addstatus
  27194. if v == nil {
  27195. return
  27196. }
  27197. return *v, true
  27198. }
  27199. // ClearStatus clears the value of the "status" field.
  27200. func (m *SopTaskMutation) ClearStatus() {
  27201. m.status = nil
  27202. m.addstatus = nil
  27203. m.clearedFields[soptask.FieldStatus] = struct{}{}
  27204. }
  27205. // StatusCleared returns if the "status" field was cleared in this mutation.
  27206. func (m *SopTaskMutation) StatusCleared() bool {
  27207. _, ok := m.clearedFields[soptask.FieldStatus]
  27208. return ok
  27209. }
  27210. // ResetStatus resets all changes to the "status" field.
  27211. func (m *SopTaskMutation) ResetStatus() {
  27212. m.status = nil
  27213. m.addstatus = nil
  27214. delete(m.clearedFields, soptask.FieldStatus)
  27215. }
  27216. // SetDeletedAt sets the "deleted_at" field.
  27217. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  27218. m.deleted_at = &t
  27219. }
  27220. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27221. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  27222. v := m.deleted_at
  27223. if v == nil {
  27224. return
  27225. }
  27226. return *v, true
  27227. }
  27228. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  27229. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27231. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27232. if !m.op.Is(OpUpdateOne) {
  27233. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27234. }
  27235. if m.id == nil || m.oldValue == nil {
  27236. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27237. }
  27238. oldValue, err := m.oldValue(ctx)
  27239. if err != nil {
  27240. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27241. }
  27242. return oldValue.DeletedAt, nil
  27243. }
  27244. // ClearDeletedAt clears the value of the "deleted_at" field.
  27245. func (m *SopTaskMutation) ClearDeletedAt() {
  27246. m.deleted_at = nil
  27247. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  27248. }
  27249. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27250. func (m *SopTaskMutation) DeletedAtCleared() bool {
  27251. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  27252. return ok
  27253. }
  27254. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27255. func (m *SopTaskMutation) ResetDeletedAt() {
  27256. m.deleted_at = nil
  27257. delete(m.clearedFields, soptask.FieldDeletedAt)
  27258. }
  27259. // SetName sets the "name" field.
  27260. func (m *SopTaskMutation) SetName(s string) {
  27261. m.name = &s
  27262. }
  27263. // Name returns the value of the "name" field in the mutation.
  27264. func (m *SopTaskMutation) Name() (r string, exists bool) {
  27265. v := m.name
  27266. if v == nil {
  27267. return
  27268. }
  27269. return *v, true
  27270. }
  27271. // OldName returns the old "name" field's value of the SopTask entity.
  27272. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27274. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  27275. if !m.op.Is(OpUpdateOne) {
  27276. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27277. }
  27278. if m.id == nil || m.oldValue == nil {
  27279. return v, errors.New("OldName requires an ID field in the mutation")
  27280. }
  27281. oldValue, err := m.oldValue(ctx)
  27282. if err != nil {
  27283. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27284. }
  27285. return oldValue.Name, nil
  27286. }
  27287. // ResetName resets all changes to the "name" field.
  27288. func (m *SopTaskMutation) ResetName() {
  27289. m.name = nil
  27290. }
  27291. // SetBotWxidList sets the "bot_wxid_list" field.
  27292. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  27293. m.bot_wxid_list = &s
  27294. m.appendbot_wxid_list = nil
  27295. }
  27296. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  27297. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  27298. v := m.bot_wxid_list
  27299. if v == nil {
  27300. return
  27301. }
  27302. return *v, true
  27303. }
  27304. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  27305. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27307. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  27308. if !m.op.Is(OpUpdateOne) {
  27309. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  27310. }
  27311. if m.id == nil || m.oldValue == nil {
  27312. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  27313. }
  27314. oldValue, err := m.oldValue(ctx)
  27315. if err != nil {
  27316. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  27317. }
  27318. return oldValue.BotWxidList, nil
  27319. }
  27320. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  27321. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  27322. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  27323. }
  27324. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  27325. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  27326. if len(m.appendbot_wxid_list) == 0 {
  27327. return nil, false
  27328. }
  27329. return m.appendbot_wxid_list, true
  27330. }
  27331. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  27332. func (m *SopTaskMutation) ClearBotWxidList() {
  27333. m.bot_wxid_list = nil
  27334. m.appendbot_wxid_list = nil
  27335. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  27336. }
  27337. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  27338. func (m *SopTaskMutation) BotWxidListCleared() bool {
  27339. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  27340. return ok
  27341. }
  27342. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  27343. func (m *SopTaskMutation) ResetBotWxidList() {
  27344. m.bot_wxid_list = nil
  27345. m.appendbot_wxid_list = nil
  27346. delete(m.clearedFields, soptask.FieldBotWxidList)
  27347. }
  27348. // SetType sets the "type" field.
  27349. func (m *SopTaskMutation) SetType(i int) {
  27350. m._type = &i
  27351. m.add_type = nil
  27352. }
  27353. // GetType returns the value of the "type" field in the mutation.
  27354. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  27355. v := m._type
  27356. if v == nil {
  27357. return
  27358. }
  27359. return *v, true
  27360. }
  27361. // OldType returns the old "type" field's value of the SopTask entity.
  27362. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27364. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  27365. if !m.op.Is(OpUpdateOne) {
  27366. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27367. }
  27368. if m.id == nil || m.oldValue == nil {
  27369. return v, errors.New("OldType requires an ID field in the mutation")
  27370. }
  27371. oldValue, err := m.oldValue(ctx)
  27372. if err != nil {
  27373. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27374. }
  27375. return oldValue.Type, nil
  27376. }
  27377. // AddType adds i to the "type" field.
  27378. func (m *SopTaskMutation) AddType(i int) {
  27379. if m.add_type != nil {
  27380. *m.add_type += i
  27381. } else {
  27382. m.add_type = &i
  27383. }
  27384. }
  27385. // AddedType returns the value that was added to the "type" field in this mutation.
  27386. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  27387. v := m.add_type
  27388. if v == nil {
  27389. return
  27390. }
  27391. return *v, true
  27392. }
  27393. // ResetType resets all changes to the "type" field.
  27394. func (m *SopTaskMutation) ResetType() {
  27395. m._type = nil
  27396. m.add_type = nil
  27397. }
  27398. // SetPlanStartTime sets the "plan_start_time" field.
  27399. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  27400. m.plan_start_time = &t
  27401. }
  27402. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  27403. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  27404. v := m.plan_start_time
  27405. if v == nil {
  27406. return
  27407. }
  27408. return *v, true
  27409. }
  27410. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  27411. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27413. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  27414. if !m.op.Is(OpUpdateOne) {
  27415. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  27416. }
  27417. if m.id == nil || m.oldValue == nil {
  27418. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  27419. }
  27420. oldValue, err := m.oldValue(ctx)
  27421. if err != nil {
  27422. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  27423. }
  27424. return oldValue.PlanStartTime, nil
  27425. }
  27426. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  27427. func (m *SopTaskMutation) ClearPlanStartTime() {
  27428. m.plan_start_time = nil
  27429. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  27430. }
  27431. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  27432. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  27433. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  27434. return ok
  27435. }
  27436. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  27437. func (m *SopTaskMutation) ResetPlanStartTime() {
  27438. m.plan_start_time = nil
  27439. delete(m.clearedFields, soptask.FieldPlanStartTime)
  27440. }
  27441. // SetPlanEndTime sets the "plan_end_time" field.
  27442. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  27443. m.plan_end_time = &t
  27444. }
  27445. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  27446. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  27447. v := m.plan_end_time
  27448. if v == nil {
  27449. return
  27450. }
  27451. return *v, true
  27452. }
  27453. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  27454. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27456. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  27457. if !m.op.Is(OpUpdateOne) {
  27458. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  27459. }
  27460. if m.id == nil || m.oldValue == nil {
  27461. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  27462. }
  27463. oldValue, err := m.oldValue(ctx)
  27464. if err != nil {
  27465. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  27466. }
  27467. return oldValue.PlanEndTime, nil
  27468. }
  27469. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  27470. func (m *SopTaskMutation) ClearPlanEndTime() {
  27471. m.plan_end_time = nil
  27472. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  27473. }
  27474. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  27475. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  27476. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  27477. return ok
  27478. }
  27479. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  27480. func (m *SopTaskMutation) ResetPlanEndTime() {
  27481. m.plan_end_time = nil
  27482. delete(m.clearedFields, soptask.FieldPlanEndTime)
  27483. }
  27484. // SetCreatorID sets the "creator_id" field.
  27485. func (m *SopTaskMutation) SetCreatorID(s string) {
  27486. m.creator_id = &s
  27487. }
  27488. // CreatorID returns the value of the "creator_id" field in the mutation.
  27489. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  27490. v := m.creator_id
  27491. if v == nil {
  27492. return
  27493. }
  27494. return *v, true
  27495. }
  27496. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  27497. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27499. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  27500. if !m.op.Is(OpUpdateOne) {
  27501. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  27502. }
  27503. if m.id == nil || m.oldValue == nil {
  27504. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  27505. }
  27506. oldValue, err := m.oldValue(ctx)
  27507. if err != nil {
  27508. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  27509. }
  27510. return oldValue.CreatorID, nil
  27511. }
  27512. // ClearCreatorID clears the value of the "creator_id" field.
  27513. func (m *SopTaskMutation) ClearCreatorID() {
  27514. m.creator_id = nil
  27515. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  27516. }
  27517. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  27518. func (m *SopTaskMutation) CreatorIDCleared() bool {
  27519. _, ok := m.clearedFields[soptask.FieldCreatorID]
  27520. return ok
  27521. }
  27522. // ResetCreatorID resets all changes to the "creator_id" field.
  27523. func (m *SopTaskMutation) ResetCreatorID() {
  27524. m.creator_id = nil
  27525. delete(m.clearedFields, soptask.FieldCreatorID)
  27526. }
  27527. // SetOrganizationID sets the "organization_id" field.
  27528. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  27529. m.organization_id = &u
  27530. m.addorganization_id = nil
  27531. }
  27532. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27533. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  27534. v := m.organization_id
  27535. if v == nil {
  27536. return
  27537. }
  27538. return *v, true
  27539. }
  27540. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  27541. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27543. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27544. if !m.op.Is(OpUpdateOne) {
  27545. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27546. }
  27547. if m.id == nil || m.oldValue == nil {
  27548. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27549. }
  27550. oldValue, err := m.oldValue(ctx)
  27551. if err != nil {
  27552. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27553. }
  27554. return oldValue.OrganizationID, nil
  27555. }
  27556. // AddOrganizationID adds u to the "organization_id" field.
  27557. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  27558. if m.addorganization_id != nil {
  27559. *m.addorganization_id += u
  27560. } else {
  27561. m.addorganization_id = &u
  27562. }
  27563. }
  27564. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27565. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  27566. v := m.addorganization_id
  27567. if v == nil {
  27568. return
  27569. }
  27570. return *v, true
  27571. }
  27572. // ClearOrganizationID clears the value of the "organization_id" field.
  27573. func (m *SopTaskMutation) ClearOrganizationID() {
  27574. m.organization_id = nil
  27575. m.addorganization_id = nil
  27576. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  27577. }
  27578. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27579. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  27580. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  27581. return ok
  27582. }
  27583. // ResetOrganizationID resets all changes to the "organization_id" field.
  27584. func (m *SopTaskMutation) ResetOrganizationID() {
  27585. m.organization_id = nil
  27586. m.addorganization_id = nil
  27587. delete(m.clearedFields, soptask.FieldOrganizationID)
  27588. }
  27589. // SetToken sets the "token" field.
  27590. func (m *SopTaskMutation) SetToken(s []string) {
  27591. m.token = &s
  27592. m.appendtoken = nil
  27593. }
  27594. // Token returns the value of the "token" field in the mutation.
  27595. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  27596. v := m.token
  27597. if v == nil {
  27598. return
  27599. }
  27600. return *v, true
  27601. }
  27602. // OldToken returns the old "token" field's value of the SopTask entity.
  27603. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  27604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27605. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  27606. if !m.op.Is(OpUpdateOne) {
  27607. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  27608. }
  27609. if m.id == nil || m.oldValue == nil {
  27610. return v, errors.New("OldToken requires an ID field in the mutation")
  27611. }
  27612. oldValue, err := m.oldValue(ctx)
  27613. if err != nil {
  27614. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  27615. }
  27616. return oldValue.Token, nil
  27617. }
  27618. // AppendToken adds s to the "token" field.
  27619. func (m *SopTaskMutation) AppendToken(s []string) {
  27620. m.appendtoken = append(m.appendtoken, s...)
  27621. }
  27622. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  27623. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  27624. if len(m.appendtoken) == 0 {
  27625. return nil, false
  27626. }
  27627. return m.appendtoken, true
  27628. }
  27629. // ClearToken clears the value of the "token" field.
  27630. func (m *SopTaskMutation) ClearToken() {
  27631. m.token = nil
  27632. m.appendtoken = nil
  27633. m.clearedFields[soptask.FieldToken] = struct{}{}
  27634. }
  27635. // TokenCleared returns if the "token" field was cleared in this mutation.
  27636. func (m *SopTaskMutation) TokenCleared() bool {
  27637. _, ok := m.clearedFields[soptask.FieldToken]
  27638. return ok
  27639. }
  27640. // ResetToken resets all changes to the "token" field.
  27641. func (m *SopTaskMutation) ResetToken() {
  27642. m.token = nil
  27643. m.appendtoken = nil
  27644. delete(m.clearedFields, soptask.FieldToken)
  27645. }
  27646. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  27647. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  27648. if m.task_stages == nil {
  27649. m.task_stages = make(map[uint64]struct{})
  27650. }
  27651. for i := range ids {
  27652. m.task_stages[ids[i]] = struct{}{}
  27653. }
  27654. }
  27655. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  27656. func (m *SopTaskMutation) ClearTaskStages() {
  27657. m.clearedtask_stages = true
  27658. }
  27659. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  27660. func (m *SopTaskMutation) TaskStagesCleared() bool {
  27661. return m.clearedtask_stages
  27662. }
  27663. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  27664. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  27665. if m.removedtask_stages == nil {
  27666. m.removedtask_stages = make(map[uint64]struct{})
  27667. }
  27668. for i := range ids {
  27669. delete(m.task_stages, ids[i])
  27670. m.removedtask_stages[ids[i]] = struct{}{}
  27671. }
  27672. }
  27673. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  27674. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  27675. for id := range m.removedtask_stages {
  27676. ids = append(ids, id)
  27677. }
  27678. return
  27679. }
  27680. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  27681. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  27682. for id := range m.task_stages {
  27683. ids = append(ids, id)
  27684. }
  27685. return
  27686. }
  27687. // ResetTaskStages resets all changes to the "task_stages" edge.
  27688. func (m *SopTaskMutation) ResetTaskStages() {
  27689. m.task_stages = nil
  27690. m.clearedtask_stages = false
  27691. m.removedtask_stages = nil
  27692. }
  27693. // Where appends a list predicates to the SopTaskMutation builder.
  27694. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  27695. m.predicates = append(m.predicates, ps...)
  27696. }
  27697. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  27698. // users can use type-assertion to append predicates that do not depend on any generated package.
  27699. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  27700. p := make([]predicate.SopTask, len(ps))
  27701. for i := range ps {
  27702. p[i] = ps[i]
  27703. }
  27704. m.Where(p...)
  27705. }
  27706. // Op returns the operation name.
  27707. func (m *SopTaskMutation) Op() Op {
  27708. return m.op
  27709. }
  27710. // SetOp allows setting the mutation operation.
  27711. func (m *SopTaskMutation) SetOp(op Op) {
  27712. m.op = op
  27713. }
  27714. // Type returns the node type of this mutation (SopTask).
  27715. func (m *SopTaskMutation) Type() string {
  27716. return m.typ
  27717. }
  27718. // Fields returns all fields that were changed during this mutation. Note that in
  27719. // order to get all numeric fields that were incremented/decremented, call
  27720. // AddedFields().
  27721. func (m *SopTaskMutation) Fields() []string {
  27722. fields := make([]string, 0, 12)
  27723. if m.created_at != nil {
  27724. fields = append(fields, soptask.FieldCreatedAt)
  27725. }
  27726. if m.updated_at != nil {
  27727. fields = append(fields, soptask.FieldUpdatedAt)
  27728. }
  27729. if m.status != nil {
  27730. fields = append(fields, soptask.FieldStatus)
  27731. }
  27732. if m.deleted_at != nil {
  27733. fields = append(fields, soptask.FieldDeletedAt)
  27734. }
  27735. if m.name != nil {
  27736. fields = append(fields, soptask.FieldName)
  27737. }
  27738. if m.bot_wxid_list != nil {
  27739. fields = append(fields, soptask.FieldBotWxidList)
  27740. }
  27741. if m._type != nil {
  27742. fields = append(fields, soptask.FieldType)
  27743. }
  27744. if m.plan_start_time != nil {
  27745. fields = append(fields, soptask.FieldPlanStartTime)
  27746. }
  27747. if m.plan_end_time != nil {
  27748. fields = append(fields, soptask.FieldPlanEndTime)
  27749. }
  27750. if m.creator_id != nil {
  27751. fields = append(fields, soptask.FieldCreatorID)
  27752. }
  27753. if m.organization_id != nil {
  27754. fields = append(fields, soptask.FieldOrganizationID)
  27755. }
  27756. if m.token != nil {
  27757. fields = append(fields, soptask.FieldToken)
  27758. }
  27759. return fields
  27760. }
  27761. // Field returns the value of a field with the given name. The second boolean
  27762. // return value indicates that this field was not set, or was not defined in the
  27763. // schema.
  27764. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  27765. switch name {
  27766. case soptask.FieldCreatedAt:
  27767. return m.CreatedAt()
  27768. case soptask.FieldUpdatedAt:
  27769. return m.UpdatedAt()
  27770. case soptask.FieldStatus:
  27771. return m.Status()
  27772. case soptask.FieldDeletedAt:
  27773. return m.DeletedAt()
  27774. case soptask.FieldName:
  27775. return m.Name()
  27776. case soptask.FieldBotWxidList:
  27777. return m.BotWxidList()
  27778. case soptask.FieldType:
  27779. return m.GetType()
  27780. case soptask.FieldPlanStartTime:
  27781. return m.PlanStartTime()
  27782. case soptask.FieldPlanEndTime:
  27783. return m.PlanEndTime()
  27784. case soptask.FieldCreatorID:
  27785. return m.CreatorID()
  27786. case soptask.FieldOrganizationID:
  27787. return m.OrganizationID()
  27788. case soptask.FieldToken:
  27789. return m.Token()
  27790. }
  27791. return nil, false
  27792. }
  27793. // OldField returns the old value of the field from the database. An error is
  27794. // returned if the mutation operation is not UpdateOne, or the query to the
  27795. // database failed.
  27796. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27797. switch name {
  27798. case soptask.FieldCreatedAt:
  27799. return m.OldCreatedAt(ctx)
  27800. case soptask.FieldUpdatedAt:
  27801. return m.OldUpdatedAt(ctx)
  27802. case soptask.FieldStatus:
  27803. return m.OldStatus(ctx)
  27804. case soptask.FieldDeletedAt:
  27805. return m.OldDeletedAt(ctx)
  27806. case soptask.FieldName:
  27807. return m.OldName(ctx)
  27808. case soptask.FieldBotWxidList:
  27809. return m.OldBotWxidList(ctx)
  27810. case soptask.FieldType:
  27811. return m.OldType(ctx)
  27812. case soptask.FieldPlanStartTime:
  27813. return m.OldPlanStartTime(ctx)
  27814. case soptask.FieldPlanEndTime:
  27815. return m.OldPlanEndTime(ctx)
  27816. case soptask.FieldCreatorID:
  27817. return m.OldCreatorID(ctx)
  27818. case soptask.FieldOrganizationID:
  27819. return m.OldOrganizationID(ctx)
  27820. case soptask.FieldToken:
  27821. return m.OldToken(ctx)
  27822. }
  27823. return nil, fmt.Errorf("unknown SopTask field %s", name)
  27824. }
  27825. // SetField sets the value of a field with the given name. It returns an error if
  27826. // the field is not defined in the schema, or if the type mismatched the field
  27827. // type.
  27828. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  27829. switch name {
  27830. case soptask.FieldCreatedAt:
  27831. v, ok := value.(time.Time)
  27832. if !ok {
  27833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27834. }
  27835. m.SetCreatedAt(v)
  27836. return nil
  27837. case soptask.FieldUpdatedAt:
  27838. v, ok := value.(time.Time)
  27839. if !ok {
  27840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27841. }
  27842. m.SetUpdatedAt(v)
  27843. return nil
  27844. case soptask.FieldStatus:
  27845. v, ok := value.(uint8)
  27846. if !ok {
  27847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27848. }
  27849. m.SetStatus(v)
  27850. return nil
  27851. case soptask.FieldDeletedAt:
  27852. v, ok := value.(time.Time)
  27853. if !ok {
  27854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27855. }
  27856. m.SetDeletedAt(v)
  27857. return nil
  27858. case soptask.FieldName:
  27859. v, ok := value.(string)
  27860. if !ok {
  27861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27862. }
  27863. m.SetName(v)
  27864. return nil
  27865. case soptask.FieldBotWxidList:
  27866. v, ok := value.([]string)
  27867. if !ok {
  27868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27869. }
  27870. m.SetBotWxidList(v)
  27871. return nil
  27872. case soptask.FieldType:
  27873. v, ok := value.(int)
  27874. if !ok {
  27875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27876. }
  27877. m.SetType(v)
  27878. return nil
  27879. case soptask.FieldPlanStartTime:
  27880. v, ok := value.(time.Time)
  27881. if !ok {
  27882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27883. }
  27884. m.SetPlanStartTime(v)
  27885. return nil
  27886. case soptask.FieldPlanEndTime:
  27887. v, ok := value.(time.Time)
  27888. if !ok {
  27889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27890. }
  27891. m.SetPlanEndTime(v)
  27892. return nil
  27893. case soptask.FieldCreatorID:
  27894. v, ok := value.(string)
  27895. if !ok {
  27896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27897. }
  27898. m.SetCreatorID(v)
  27899. return nil
  27900. case soptask.FieldOrganizationID:
  27901. v, ok := value.(uint64)
  27902. if !ok {
  27903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27904. }
  27905. m.SetOrganizationID(v)
  27906. return nil
  27907. case soptask.FieldToken:
  27908. v, ok := value.([]string)
  27909. if !ok {
  27910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27911. }
  27912. m.SetToken(v)
  27913. return nil
  27914. }
  27915. return fmt.Errorf("unknown SopTask field %s", name)
  27916. }
  27917. // AddedFields returns all numeric fields that were incremented/decremented during
  27918. // this mutation.
  27919. func (m *SopTaskMutation) AddedFields() []string {
  27920. var fields []string
  27921. if m.addstatus != nil {
  27922. fields = append(fields, soptask.FieldStatus)
  27923. }
  27924. if m.add_type != nil {
  27925. fields = append(fields, soptask.FieldType)
  27926. }
  27927. if m.addorganization_id != nil {
  27928. fields = append(fields, soptask.FieldOrganizationID)
  27929. }
  27930. return fields
  27931. }
  27932. // AddedField returns the numeric value that was incremented/decremented on a field
  27933. // with the given name. The second boolean return value indicates that this field
  27934. // was not set, or was not defined in the schema.
  27935. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  27936. switch name {
  27937. case soptask.FieldStatus:
  27938. return m.AddedStatus()
  27939. case soptask.FieldType:
  27940. return m.AddedType()
  27941. case soptask.FieldOrganizationID:
  27942. return m.AddedOrganizationID()
  27943. }
  27944. return nil, false
  27945. }
  27946. // AddField adds the value to the field with the given name. It returns an error if
  27947. // the field is not defined in the schema, or if the type mismatched the field
  27948. // type.
  27949. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  27950. switch name {
  27951. case soptask.FieldStatus:
  27952. v, ok := value.(int8)
  27953. if !ok {
  27954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27955. }
  27956. m.AddStatus(v)
  27957. return nil
  27958. case soptask.FieldType:
  27959. v, ok := value.(int)
  27960. if !ok {
  27961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27962. }
  27963. m.AddType(v)
  27964. return nil
  27965. case soptask.FieldOrganizationID:
  27966. v, ok := value.(int64)
  27967. if !ok {
  27968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27969. }
  27970. m.AddOrganizationID(v)
  27971. return nil
  27972. }
  27973. return fmt.Errorf("unknown SopTask numeric field %s", name)
  27974. }
  27975. // ClearedFields returns all nullable fields that were cleared during this
  27976. // mutation.
  27977. func (m *SopTaskMutation) ClearedFields() []string {
  27978. var fields []string
  27979. if m.FieldCleared(soptask.FieldStatus) {
  27980. fields = append(fields, soptask.FieldStatus)
  27981. }
  27982. if m.FieldCleared(soptask.FieldDeletedAt) {
  27983. fields = append(fields, soptask.FieldDeletedAt)
  27984. }
  27985. if m.FieldCleared(soptask.FieldBotWxidList) {
  27986. fields = append(fields, soptask.FieldBotWxidList)
  27987. }
  27988. if m.FieldCleared(soptask.FieldPlanStartTime) {
  27989. fields = append(fields, soptask.FieldPlanStartTime)
  27990. }
  27991. if m.FieldCleared(soptask.FieldPlanEndTime) {
  27992. fields = append(fields, soptask.FieldPlanEndTime)
  27993. }
  27994. if m.FieldCleared(soptask.FieldCreatorID) {
  27995. fields = append(fields, soptask.FieldCreatorID)
  27996. }
  27997. if m.FieldCleared(soptask.FieldOrganizationID) {
  27998. fields = append(fields, soptask.FieldOrganizationID)
  27999. }
  28000. if m.FieldCleared(soptask.FieldToken) {
  28001. fields = append(fields, soptask.FieldToken)
  28002. }
  28003. return fields
  28004. }
  28005. // FieldCleared returns a boolean indicating if a field with the given name was
  28006. // cleared in this mutation.
  28007. func (m *SopTaskMutation) FieldCleared(name string) bool {
  28008. _, ok := m.clearedFields[name]
  28009. return ok
  28010. }
  28011. // ClearField clears the value of the field with the given name. It returns an
  28012. // error if the field is not defined in the schema.
  28013. func (m *SopTaskMutation) ClearField(name string) error {
  28014. switch name {
  28015. case soptask.FieldStatus:
  28016. m.ClearStatus()
  28017. return nil
  28018. case soptask.FieldDeletedAt:
  28019. m.ClearDeletedAt()
  28020. return nil
  28021. case soptask.FieldBotWxidList:
  28022. m.ClearBotWxidList()
  28023. return nil
  28024. case soptask.FieldPlanStartTime:
  28025. m.ClearPlanStartTime()
  28026. return nil
  28027. case soptask.FieldPlanEndTime:
  28028. m.ClearPlanEndTime()
  28029. return nil
  28030. case soptask.FieldCreatorID:
  28031. m.ClearCreatorID()
  28032. return nil
  28033. case soptask.FieldOrganizationID:
  28034. m.ClearOrganizationID()
  28035. return nil
  28036. case soptask.FieldToken:
  28037. m.ClearToken()
  28038. return nil
  28039. }
  28040. return fmt.Errorf("unknown SopTask nullable field %s", name)
  28041. }
  28042. // ResetField resets all changes in the mutation for the field with the given name.
  28043. // It returns an error if the field is not defined in the schema.
  28044. func (m *SopTaskMutation) ResetField(name string) error {
  28045. switch name {
  28046. case soptask.FieldCreatedAt:
  28047. m.ResetCreatedAt()
  28048. return nil
  28049. case soptask.FieldUpdatedAt:
  28050. m.ResetUpdatedAt()
  28051. return nil
  28052. case soptask.FieldStatus:
  28053. m.ResetStatus()
  28054. return nil
  28055. case soptask.FieldDeletedAt:
  28056. m.ResetDeletedAt()
  28057. return nil
  28058. case soptask.FieldName:
  28059. m.ResetName()
  28060. return nil
  28061. case soptask.FieldBotWxidList:
  28062. m.ResetBotWxidList()
  28063. return nil
  28064. case soptask.FieldType:
  28065. m.ResetType()
  28066. return nil
  28067. case soptask.FieldPlanStartTime:
  28068. m.ResetPlanStartTime()
  28069. return nil
  28070. case soptask.FieldPlanEndTime:
  28071. m.ResetPlanEndTime()
  28072. return nil
  28073. case soptask.FieldCreatorID:
  28074. m.ResetCreatorID()
  28075. return nil
  28076. case soptask.FieldOrganizationID:
  28077. m.ResetOrganizationID()
  28078. return nil
  28079. case soptask.FieldToken:
  28080. m.ResetToken()
  28081. return nil
  28082. }
  28083. return fmt.Errorf("unknown SopTask field %s", name)
  28084. }
  28085. // AddedEdges returns all edge names that were set/added in this mutation.
  28086. func (m *SopTaskMutation) AddedEdges() []string {
  28087. edges := make([]string, 0, 1)
  28088. if m.task_stages != nil {
  28089. edges = append(edges, soptask.EdgeTaskStages)
  28090. }
  28091. return edges
  28092. }
  28093. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28094. // name in this mutation.
  28095. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  28096. switch name {
  28097. case soptask.EdgeTaskStages:
  28098. ids := make([]ent.Value, 0, len(m.task_stages))
  28099. for id := range m.task_stages {
  28100. ids = append(ids, id)
  28101. }
  28102. return ids
  28103. }
  28104. return nil
  28105. }
  28106. // RemovedEdges returns all edge names that were removed in this mutation.
  28107. func (m *SopTaskMutation) RemovedEdges() []string {
  28108. edges := make([]string, 0, 1)
  28109. if m.removedtask_stages != nil {
  28110. edges = append(edges, soptask.EdgeTaskStages)
  28111. }
  28112. return edges
  28113. }
  28114. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28115. // the given name in this mutation.
  28116. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  28117. switch name {
  28118. case soptask.EdgeTaskStages:
  28119. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  28120. for id := range m.removedtask_stages {
  28121. ids = append(ids, id)
  28122. }
  28123. return ids
  28124. }
  28125. return nil
  28126. }
  28127. // ClearedEdges returns all edge names that were cleared in this mutation.
  28128. func (m *SopTaskMutation) ClearedEdges() []string {
  28129. edges := make([]string, 0, 1)
  28130. if m.clearedtask_stages {
  28131. edges = append(edges, soptask.EdgeTaskStages)
  28132. }
  28133. return edges
  28134. }
  28135. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28136. // was cleared in this mutation.
  28137. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  28138. switch name {
  28139. case soptask.EdgeTaskStages:
  28140. return m.clearedtask_stages
  28141. }
  28142. return false
  28143. }
  28144. // ClearEdge clears the value of the edge with the given name. It returns an error
  28145. // if that edge is not defined in the schema.
  28146. func (m *SopTaskMutation) ClearEdge(name string) error {
  28147. switch name {
  28148. }
  28149. return fmt.Errorf("unknown SopTask unique edge %s", name)
  28150. }
  28151. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28152. // It returns an error if the edge is not defined in the schema.
  28153. func (m *SopTaskMutation) ResetEdge(name string) error {
  28154. switch name {
  28155. case soptask.EdgeTaskStages:
  28156. m.ResetTaskStages()
  28157. return nil
  28158. }
  28159. return fmt.Errorf("unknown SopTask edge %s", name)
  28160. }
  28161. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  28162. type TokenMutation struct {
  28163. config
  28164. op Op
  28165. typ string
  28166. id *uint64
  28167. created_at *time.Time
  28168. updated_at *time.Time
  28169. deleted_at *time.Time
  28170. expire_at *time.Time
  28171. token *string
  28172. mac *string
  28173. organization_id *uint64
  28174. addorganization_id *int64
  28175. custom_agent_base *string
  28176. custom_agent_key *string
  28177. openai_base *string
  28178. openai_key *string
  28179. clearedFields map[string]struct{}
  28180. agent *uint64
  28181. clearedagent bool
  28182. done bool
  28183. oldValue func(context.Context) (*Token, error)
  28184. predicates []predicate.Token
  28185. }
  28186. var _ ent.Mutation = (*TokenMutation)(nil)
  28187. // tokenOption allows management of the mutation configuration using functional options.
  28188. type tokenOption func(*TokenMutation)
  28189. // newTokenMutation creates new mutation for the Token entity.
  28190. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  28191. m := &TokenMutation{
  28192. config: c,
  28193. op: op,
  28194. typ: TypeToken,
  28195. clearedFields: make(map[string]struct{}),
  28196. }
  28197. for _, opt := range opts {
  28198. opt(m)
  28199. }
  28200. return m
  28201. }
  28202. // withTokenID sets the ID field of the mutation.
  28203. func withTokenID(id uint64) tokenOption {
  28204. return func(m *TokenMutation) {
  28205. var (
  28206. err error
  28207. once sync.Once
  28208. value *Token
  28209. )
  28210. m.oldValue = func(ctx context.Context) (*Token, error) {
  28211. once.Do(func() {
  28212. if m.done {
  28213. err = errors.New("querying old values post mutation is not allowed")
  28214. } else {
  28215. value, err = m.Client().Token.Get(ctx, id)
  28216. }
  28217. })
  28218. return value, err
  28219. }
  28220. m.id = &id
  28221. }
  28222. }
  28223. // withToken sets the old Token of the mutation.
  28224. func withToken(node *Token) tokenOption {
  28225. return func(m *TokenMutation) {
  28226. m.oldValue = func(context.Context) (*Token, error) {
  28227. return node, nil
  28228. }
  28229. m.id = &node.ID
  28230. }
  28231. }
  28232. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28233. // executed in a transaction (ent.Tx), a transactional client is returned.
  28234. func (m TokenMutation) Client() *Client {
  28235. client := &Client{config: m.config}
  28236. client.init()
  28237. return client
  28238. }
  28239. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28240. // it returns an error otherwise.
  28241. func (m TokenMutation) Tx() (*Tx, error) {
  28242. if _, ok := m.driver.(*txDriver); !ok {
  28243. return nil, errors.New("ent: mutation is not running in a transaction")
  28244. }
  28245. tx := &Tx{config: m.config}
  28246. tx.init()
  28247. return tx, nil
  28248. }
  28249. // SetID sets the value of the id field. Note that this
  28250. // operation is only accepted on creation of Token entities.
  28251. func (m *TokenMutation) SetID(id uint64) {
  28252. m.id = &id
  28253. }
  28254. // ID returns the ID value in the mutation. Note that the ID is only available
  28255. // if it was provided to the builder or after it was returned from the database.
  28256. func (m *TokenMutation) ID() (id uint64, exists bool) {
  28257. if m.id == nil {
  28258. return
  28259. }
  28260. return *m.id, true
  28261. }
  28262. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28263. // That means, if the mutation is applied within a transaction with an isolation level such
  28264. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28265. // or updated by the mutation.
  28266. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  28267. switch {
  28268. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28269. id, exists := m.ID()
  28270. if exists {
  28271. return []uint64{id}, nil
  28272. }
  28273. fallthrough
  28274. case m.op.Is(OpUpdate | OpDelete):
  28275. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  28276. default:
  28277. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28278. }
  28279. }
  28280. // SetCreatedAt sets the "created_at" field.
  28281. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  28282. m.created_at = &t
  28283. }
  28284. // CreatedAt returns the value of the "created_at" field in the mutation.
  28285. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  28286. v := m.created_at
  28287. if v == nil {
  28288. return
  28289. }
  28290. return *v, true
  28291. }
  28292. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  28293. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28295. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28296. if !m.op.Is(OpUpdateOne) {
  28297. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28298. }
  28299. if m.id == nil || m.oldValue == nil {
  28300. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28301. }
  28302. oldValue, err := m.oldValue(ctx)
  28303. if err != nil {
  28304. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28305. }
  28306. return oldValue.CreatedAt, nil
  28307. }
  28308. // ResetCreatedAt resets all changes to the "created_at" field.
  28309. func (m *TokenMutation) ResetCreatedAt() {
  28310. m.created_at = nil
  28311. }
  28312. // SetUpdatedAt sets the "updated_at" field.
  28313. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  28314. m.updated_at = &t
  28315. }
  28316. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28317. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  28318. v := m.updated_at
  28319. if v == nil {
  28320. return
  28321. }
  28322. return *v, true
  28323. }
  28324. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  28325. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28327. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28328. if !m.op.Is(OpUpdateOne) {
  28329. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28330. }
  28331. if m.id == nil || m.oldValue == nil {
  28332. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28333. }
  28334. oldValue, err := m.oldValue(ctx)
  28335. if err != nil {
  28336. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28337. }
  28338. return oldValue.UpdatedAt, nil
  28339. }
  28340. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28341. func (m *TokenMutation) ResetUpdatedAt() {
  28342. m.updated_at = nil
  28343. }
  28344. // SetDeletedAt sets the "deleted_at" field.
  28345. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  28346. m.deleted_at = &t
  28347. }
  28348. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28349. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  28350. v := m.deleted_at
  28351. if v == nil {
  28352. return
  28353. }
  28354. return *v, true
  28355. }
  28356. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  28357. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28359. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28360. if !m.op.Is(OpUpdateOne) {
  28361. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28362. }
  28363. if m.id == nil || m.oldValue == nil {
  28364. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28365. }
  28366. oldValue, err := m.oldValue(ctx)
  28367. if err != nil {
  28368. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28369. }
  28370. return oldValue.DeletedAt, nil
  28371. }
  28372. // ClearDeletedAt clears the value of the "deleted_at" field.
  28373. func (m *TokenMutation) ClearDeletedAt() {
  28374. m.deleted_at = nil
  28375. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  28376. }
  28377. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28378. func (m *TokenMutation) DeletedAtCleared() bool {
  28379. _, ok := m.clearedFields[token.FieldDeletedAt]
  28380. return ok
  28381. }
  28382. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28383. func (m *TokenMutation) ResetDeletedAt() {
  28384. m.deleted_at = nil
  28385. delete(m.clearedFields, token.FieldDeletedAt)
  28386. }
  28387. // SetExpireAt sets the "expire_at" field.
  28388. func (m *TokenMutation) SetExpireAt(t time.Time) {
  28389. m.expire_at = &t
  28390. }
  28391. // ExpireAt returns the value of the "expire_at" field in the mutation.
  28392. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  28393. v := m.expire_at
  28394. if v == nil {
  28395. return
  28396. }
  28397. return *v, true
  28398. }
  28399. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  28400. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28402. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  28403. if !m.op.Is(OpUpdateOne) {
  28404. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  28405. }
  28406. if m.id == nil || m.oldValue == nil {
  28407. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  28408. }
  28409. oldValue, err := m.oldValue(ctx)
  28410. if err != nil {
  28411. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  28412. }
  28413. return oldValue.ExpireAt, nil
  28414. }
  28415. // ClearExpireAt clears the value of the "expire_at" field.
  28416. func (m *TokenMutation) ClearExpireAt() {
  28417. m.expire_at = nil
  28418. m.clearedFields[token.FieldExpireAt] = struct{}{}
  28419. }
  28420. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  28421. func (m *TokenMutation) ExpireAtCleared() bool {
  28422. _, ok := m.clearedFields[token.FieldExpireAt]
  28423. return ok
  28424. }
  28425. // ResetExpireAt resets all changes to the "expire_at" field.
  28426. func (m *TokenMutation) ResetExpireAt() {
  28427. m.expire_at = nil
  28428. delete(m.clearedFields, token.FieldExpireAt)
  28429. }
  28430. // SetToken sets the "token" field.
  28431. func (m *TokenMutation) SetToken(s string) {
  28432. m.token = &s
  28433. }
  28434. // Token returns the value of the "token" field in the mutation.
  28435. func (m *TokenMutation) Token() (r string, exists bool) {
  28436. v := m.token
  28437. if v == nil {
  28438. return
  28439. }
  28440. return *v, true
  28441. }
  28442. // OldToken returns the old "token" field's value of the Token entity.
  28443. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28445. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  28446. if !m.op.Is(OpUpdateOne) {
  28447. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  28448. }
  28449. if m.id == nil || m.oldValue == nil {
  28450. return v, errors.New("OldToken requires an ID field in the mutation")
  28451. }
  28452. oldValue, err := m.oldValue(ctx)
  28453. if err != nil {
  28454. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  28455. }
  28456. return oldValue.Token, nil
  28457. }
  28458. // ClearToken clears the value of the "token" field.
  28459. func (m *TokenMutation) ClearToken() {
  28460. m.token = nil
  28461. m.clearedFields[token.FieldToken] = struct{}{}
  28462. }
  28463. // TokenCleared returns if the "token" field was cleared in this mutation.
  28464. func (m *TokenMutation) TokenCleared() bool {
  28465. _, ok := m.clearedFields[token.FieldToken]
  28466. return ok
  28467. }
  28468. // ResetToken resets all changes to the "token" field.
  28469. func (m *TokenMutation) ResetToken() {
  28470. m.token = nil
  28471. delete(m.clearedFields, token.FieldToken)
  28472. }
  28473. // SetMAC sets the "mac" field.
  28474. func (m *TokenMutation) SetMAC(s string) {
  28475. m.mac = &s
  28476. }
  28477. // MAC returns the value of the "mac" field in the mutation.
  28478. func (m *TokenMutation) MAC() (r string, exists bool) {
  28479. v := m.mac
  28480. if v == nil {
  28481. return
  28482. }
  28483. return *v, true
  28484. }
  28485. // OldMAC returns the old "mac" field's value of the Token entity.
  28486. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28488. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  28489. if !m.op.Is(OpUpdateOne) {
  28490. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  28491. }
  28492. if m.id == nil || m.oldValue == nil {
  28493. return v, errors.New("OldMAC requires an ID field in the mutation")
  28494. }
  28495. oldValue, err := m.oldValue(ctx)
  28496. if err != nil {
  28497. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  28498. }
  28499. return oldValue.MAC, nil
  28500. }
  28501. // ClearMAC clears the value of the "mac" field.
  28502. func (m *TokenMutation) ClearMAC() {
  28503. m.mac = nil
  28504. m.clearedFields[token.FieldMAC] = struct{}{}
  28505. }
  28506. // MACCleared returns if the "mac" field was cleared in this mutation.
  28507. func (m *TokenMutation) MACCleared() bool {
  28508. _, ok := m.clearedFields[token.FieldMAC]
  28509. return ok
  28510. }
  28511. // ResetMAC resets all changes to the "mac" field.
  28512. func (m *TokenMutation) ResetMAC() {
  28513. m.mac = nil
  28514. delete(m.clearedFields, token.FieldMAC)
  28515. }
  28516. // SetOrganizationID sets the "organization_id" field.
  28517. func (m *TokenMutation) SetOrganizationID(u uint64) {
  28518. m.organization_id = &u
  28519. m.addorganization_id = nil
  28520. }
  28521. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28522. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  28523. v := m.organization_id
  28524. if v == nil {
  28525. return
  28526. }
  28527. return *v, true
  28528. }
  28529. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  28530. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28532. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28533. if !m.op.Is(OpUpdateOne) {
  28534. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28535. }
  28536. if m.id == nil || m.oldValue == nil {
  28537. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28538. }
  28539. oldValue, err := m.oldValue(ctx)
  28540. if err != nil {
  28541. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28542. }
  28543. return oldValue.OrganizationID, nil
  28544. }
  28545. // AddOrganizationID adds u to the "organization_id" field.
  28546. func (m *TokenMutation) AddOrganizationID(u int64) {
  28547. if m.addorganization_id != nil {
  28548. *m.addorganization_id += u
  28549. } else {
  28550. m.addorganization_id = &u
  28551. }
  28552. }
  28553. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28554. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  28555. v := m.addorganization_id
  28556. if v == nil {
  28557. return
  28558. }
  28559. return *v, true
  28560. }
  28561. // ResetOrganizationID resets all changes to the "organization_id" field.
  28562. func (m *TokenMutation) ResetOrganizationID() {
  28563. m.organization_id = nil
  28564. m.addorganization_id = nil
  28565. }
  28566. // SetAgentID sets the "agent_id" field.
  28567. func (m *TokenMutation) SetAgentID(u uint64) {
  28568. m.agent = &u
  28569. }
  28570. // AgentID returns the value of the "agent_id" field in the mutation.
  28571. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  28572. v := m.agent
  28573. if v == nil {
  28574. return
  28575. }
  28576. return *v, true
  28577. }
  28578. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  28579. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28581. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  28582. if !m.op.Is(OpUpdateOne) {
  28583. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  28584. }
  28585. if m.id == nil || m.oldValue == nil {
  28586. return v, errors.New("OldAgentID requires an ID field in the mutation")
  28587. }
  28588. oldValue, err := m.oldValue(ctx)
  28589. if err != nil {
  28590. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  28591. }
  28592. return oldValue.AgentID, nil
  28593. }
  28594. // ResetAgentID resets all changes to the "agent_id" field.
  28595. func (m *TokenMutation) ResetAgentID() {
  28596. m.agent = nil
  28597. }
  28598. // SetCustomAgentBase sets the "custom_agent_base" field.
  28599. func (m *TokenMutation) SetCustomAgentBase(s string) {
  28600. m.custom_agent_base = &s
  28601. }
  28602. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  28603. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  28604. v := m.custom_agent_base
  28605. if v == nil {
  28606. return
  28607. }
  28608. return *v, true
  28609. }
  28610. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  28611. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28613. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  28614. if !m.op.Is(OpUpdateOne) {
  28615. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  28616. }
  28617. if m.id == nil || m.oldValue == nil {
  28618. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  28619. }
  28620. oldValue, err := m.oldValue(ctx)
  28621. if err != nil {
  28622. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  28623. }
  28624. return oldValue.CustomAgentBase, nil
  28625. }
  28626. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  28627. func (m *TokenMutation) ClearCustomAgentBase() {
  28628. m.custom_agent_base = nil
  28629. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  28630. }
  28631. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  28632. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  28633. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  28634. return ok
  28635. }
  28636. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  28637. func (m *TokenMutation) ResetCustomAgentBase() {
  28638. m.custom_agent_base = nil
  28639. delete(m.clearedFields, token.FieldCustomAgentBase)
  28640. }
  28641. // SetCustomAgentKey sets the "custom_agent_key" field.
  28642. func (m *TokenMutation) SetCustomAgentKey(s string) {
  28643. m.custom_agent_key = &s
  28644. }
  28645. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  28646. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  28647. v := m.custom_agent_key
  28648. if v == nil {
  28649. return
  28650. }
  28651. return *v, true
  28652. }
  28653. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  28654. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28656. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  28657. if !m.op.Is(OpUpdateOne) {
  28658. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  28659. }
  28660. if m.id == nil || m.oldValue == nil {
  28661. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  28662. }
  28663. oldValue, err := m.oldValue(ctx)
  28664. if err != nil {
  28665. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  28666. }
  28667. return oldValue.CustomAgentKey, nil
  28668. }
  28669. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  28670. func (m *TokenMutation) ClearCustomAgentKey() {
  28671. m.custom_agent_key = nil
  28672. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  28673. }
  28674. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  28675. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  28676. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  28677. return ok
  28678. }
  28679. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  28680. func (m *TokenMutation) ResetCustomAgentKey() {
  28681. m.custom_agent_key = nil
  28682. delete(m.clearedFields, token.FieldCustomAgentKey)
  28683. }
  28684. // SetOpenaiBase sets the "openai_base" field.
  28685. func (m *TokenMutation) SetOpenaiBase(s string) {
  28686. m.openai_base = &s
  28687. }
  28688. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  28689. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  28690. v := m.openai_base
  28691. if v == nil {
  28692. return
  28693. }
  28694. return *v, true
  28695. }
  28696. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  28697. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28699. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  28700. if !m.op.Is(OpUpdateOne) {
  28701. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  28702. }
  28703. if m.id == nil || m.oldValue == nil {
  28704. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  28705. }
  28706. oldValue, err := m.oldValue(ctx)
  28707. if err != nil {
  28708. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  28709. }
  28710. return oldValue.OpenaiBase, nil
  28711. }
  28712. // ClearOpenaiBase clears the value of the "openai_base" field.
  28713. func (m *TokenMutation) ClearOpenaiBase() {
  28714. m.openai_base = nil
  28715. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  28716. }
  28717. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  28718. func (m *TokenMutation) OpenaiBaseCleared() bool {
  28719. _, ok := m.clearedFields[token.FieldOpenaiBase]
  28720. return ok
  28721. }
  28722. // ResetOpenaiBase resets all changes to the "openai_base" field.
  28723. func (m *TokenMutation) ResetOpenaiBase() {
  28724. m.openai_base = nil
  28725. delete(m.clearedFields, token.FieldOpenaiBase)
  28726. }
  28727. // SetOpenaiKey sets the "openai_key" field.
  28728. func (m *TokenMutation) SetOpenaiKey(s string) {
  28729. m.openai_key = &s
  28730. }
  28731. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  28732. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  28733. v := m.openai_key
  28734. if v == nil {
  28735. return
  28736. }
  28737. return *v, true
  28738. }
  28739. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  28740. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  28741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28742. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  28743. if !m.op.Is(OpUpdateOne) {
  28744. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  28745. }
  28746. if m.id == nil || m.oldValue == nil {
  28747. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  28748. }
  28749. oldValue, err := m.oldValue(ctx)
  28750. if err != nil {
  28751. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  28752. }
  28753. return oldValue.OpenaiKey, nil
  28754. }
  28755. // ClearOpenaiKey clears the value of the "openai_key" field.
  28756. func (m *TokenMutation) ClearOpenaiKey() {
  28757. m.openai_key = nil
  28758. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  28759. }
  28760. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  28761. func (m *TokenMutation) OpenaiKeyCleared() bool {
  28762. _, ok := m.clearedFields[token.FieldOpenaiKey]
  28763. return ok
  28764. }
  28765. // ResetOpenaiKey resets all changes to the "openai_key" field.
  28766. func (m *TokenMutation) ResetOpenaiKey() {
  28767. m.openai_key = nil
  28768. delete(m.clearedFields, token.FieldOpenaiKey)
  28769. }
  28770. // ClearAgent clears the "agent" edge to the Agent entity.
  28771. func (m *TokenMutation) ClearAgent() {
  28772. m.clearedagent = true
  28773. m.clearedFields[token.FieldAgentID] = struct{}{}
  28774. }
  28775. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  28776. func (m *TokenMutation) AgentCleared() bool {
  28777. return m.clearedagent
  28778. }
  28779. // AgentIDs returns the "agent" edge IDs in the mutation.
  28780. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  28781. // AgentID instead. It exists only for internal usage by the builders.
  28782. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  28783. if id := m.agent; id != nil {
  28784. ids = append(ids, *id)
  28785. }
  28786. return
  28787. }
  28788. // ResetAgent resets all changes to the "agent" edge.
  28789. func (m *TokenMutation) ResetAgent() {
  28790. m.agent = nil
  28791. m.clearedagent = false
  28792. }
  28793. // Where appends a list predicates to the TokenMutation builder.
  28794. func (m *TokenMutation) Where(ps ...predicate.Token) {
  28795. m.predicates = append(m.predicates, ps...)
  28796. }
  28797. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  28798. // users can use type-assertion to append predicates that do not depend on any generated package.
  28799. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  28800. p := make([]predicate.Token, len(ps))
  28801. for i := range ps {
  28802. p[i] = ps[i]
  28803. }
  28804. m.Where(p...)
  28805. }
  28806. // Op returns the operation name.
  28807. func (m *TokenMutation) Op() Op {
  28808. return m.op
  28809. }
  28810. // SetOp allows setting the mutation operation.
  28811. func (m *TokenMutation) SetOp(op Op) {
  28812. m.op = op
  28813. }
  28814. // Type returns the node type of this mutation (Token).
  28815. func (m *TokenMutation) Type() string {
  28816. return m.typ
  28817. }
  28818. // Fields returns all fields that were changed during this mutation. Note that in
  28819. // order to get all numeric fields that were incremented/decremented, call
  28820. // AddedFields().
  28821. func (m *TokenMutation) Fields() []string {
  28822. fields := make([]string, 0, 12)
  28823. if m.created_at != nil {
  28824. fields = append(fields, token.FieldCreatedAt)
  28825. }
  28826. if m.updated_at != nil {
  28827. fields = append(fields, token.FieldUpdatedAt)
  28828. }
  28829. if m.deleted_at != nil {
  28830. fields = append(fields, token.FieldDeletedAt)
  28831. }
  28832. if m.expire_at != nil {
  28833. fields = append(fields, token.FieldExpireAt)
  28834. }
  28835. if m.token != nil {
  28836. fields = append(fields, token.FieldToken)
  28837. }
  28838. if m.mac != nil {
  28839. fields = append(fields, token.FieldMAC)
  28840. }
  28841. if m.organization_id != nil {
  28842. fields = append(fields, token.FieldOrganizationID)
  28843. }
  28844. if m.agent != nil {
  28845. fields = append(fields, token.FieldAgentID)
  28846. }
  28847. if m.custom_agent_base != nil {
  28848. fields = append(fields, token.FieldCustomAgentBase)
  28849. }
  28850. if m.custom_agent_key != nil {
  28851. fields = append(fields, token.FieldCustomAgentKey)
  28852. }
  28853. if m.openai_base != nil {
  28854. fields = append(fields, token.FieldOpenaiBase)
  28855. }
  28856. if m.openai_key != nil {
  28857. fields = append(fields, token.FieldOpenaiKey)
  28858. }
  28859. return fields
  28860. }
  28861. // Field returns the value of a field with the given name. The second boolean
  28862. // return value indicates that this field was not set, or was not defined in the
  28863. // schema.
  28864. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  28865. switch name {
  28866. case token.FieldCreatedAt:
  28867. return m.CreatedAt()
  28868. case token.FieldUpdatedAt:
  28869. return m.UpdatedAt()
  28870. case token.FieldDeletedAt:
  28871. return m.DeletedAt()
  28872. case token.FieldExpireAt:
  28873. return m.ExpireAt()
  28874. case token.FieldToken:
  28875. return m.Token()
  28876. case token.FieldMAC:
  28877. return m.MAC()
  28878. case token.FieldOrganizationID:
  28879. return m.OrganizationID()
  28880. case token.FieldAgentID:
  28881. return m.AgentID()
  28882. case token.FieldCustomAgentBase:
  28883. return m.CustomAgentBase()
  28884. case token.FieldCustomAgentKey:
  28885. return m.CustomAgentKey()
  28886. case token.FieldOpenaiBase:
  28887. return m.OpenaiBase()
  28888. case token.FieldOpenaiKey:
  28889. return m.OpenaiKey()
  28890. }
  28891. return nil, false
  28892. }
  28893. // OldField returns the old value of the field from the database. An error is
  28894. // returned if the mutation operation is not UpdateOne, or the query to the
  28895. // database failed.
  28896. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28897. switch name {
  28898. case token.FieldCreatedAt:
  28899. return m.OldCreatedAt(ctx)
  28900. case token.FieldUpdatedAt:
  28901. return m.OldUpdatedAt(ctx)
  28902. case token.FieldDeletedAt:
  28903. return m.OldDeletedAt(ctx)
  28904. case token.FieldExpireAt:
  28905. return m.OldExpireAt(ctx)
  28906. case token.FieldToken:
  28907. return m.OldToken(ctx)
  28908. case token.FieldMAC:
  28909. return m.OldMAC(ctx)
  28910. case token.FieldOrganizationID:
  28911. return m.OldOrganizationID(ctx)
  28912. case token.FieldAgentID:
  28913. return m.OldAgentID(ctx)
  28914. case token.FieldCustomAgentBase:
  28915. return m.OldCustomAgentBase(ctx)
  28916. case token.FieldCustomAgentKey:
  28917. return m.OldCustomAgentKey(ctx)
  28918. case token.FieldOpenaiBase:
  28919. return m.OldOpenaiBase(ctx)
  28920. case token.FieldOpenaiKey:
  28921. return m.OldOpenaiKey(ctx)
  28922. }
  28923. return nil, fmt.Errorf("unknown Token field %s", name)
  28924. }
  28925. // SetField sets the value of a field with the given name. It returns an error if
  28926. // the field is not defined in the schema, or if the type mismatched the field
  28927. // type.
  28928. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  28929. switch name {
  28930. case token.FieldCreatedAt:
  28931. v, ok := value.(time.Time)
  28932. if !ok {
  28933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28934. }
  28935. m.SetCreatedAt(v)
  28936. return nil
  28937. case token.FieldUpdatedAt:
  28938. v, ok := value.(time.Time)
  28939. if !ok {
  28940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28941. }
  28942. m.SetUpdatedAt(v)
  28943. return nil
  28944. case token.FieldDeletedAt:
  28945. v, ok := value.(time.Time)
  28946. if !ok {
  28947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28948. }
  28949. m.SetDeletedAt(v)
  28950. return nil
  28951. case token.FieldExpireAt:
  28952. v, ok := value.(time.Time)
  28953. if !ok {
  28954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28955. }
  28956. m.SetExpireAt(v)
  28957. return nil
  28958. case token.FieldToken:
  28959. v, ok := value.(string)
  28960. if !ok {
  28961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28962. }
  28963. m.SetToken(v)
  28964. return nil
  28965. case token.FieldMAC:
  28966. v, ok := value.(string)
  28967. if !ok {
  28968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28969. }
  28970. m.SetMAC(v)
  28971. return nil
  28972. case token.FieldOrganizationID:
  28973. v, ok := value.(uint64)
  28974. if !ok {
  28975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28976. }
  28977. m.SetOrganizationID(v)
  28978. return nil
  28979. case token.FieldAgentID:
  28980. v, ok := value.(uint64)
  28981. if !ok {
  28982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28983. }
  28984. m.SetAgentID(v)
  28985. return nil
  28986. case token.FieldCustomAgentBase:
  28987. v, ok := value.(string)
  28988. if !ok {
  28989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28990. }
  28991. m.SetCustomAgentBase(v)
  28992. return nil
  28993. case token.FieldCustomAgentKey:
  28994. v, ok := value.(string)
  28995. if !ok {
  28996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28997. }
  28998. m.SetCustomAgentKey(v)
  28999. return nil
  29000. case token.FieldOpenaiBase:
  29001. v, ok := value.(string)
  29002. if !ok {
  29003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29004. }
  29005. m.SetOpenaiBase(v)
  29006. return nil
  29007. case token.FieldOpenaiKey:
  29008. v, ok := value.(string)
  29009. if !ok {
  29010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29011. }
  29012. m.SetOpenaiKey(v)
  29013. return nil
  29014. }
  29015. return fmt.Errorf("unknown Token field %s", name)
  29016. }
  29017. // AddedFields returns all numeric fields that were incremented/decremented during
  29018. // this mutation.
  29019. func (m *TokenMutation) AddedFields() []string {
  29020. var fields []string
  29021. if m.addorganization_id != nil {
  29022. fields = append(fields, token.FieldOrganizationID)
  29023. }
  29024. return fields
  29025. }
  29026. // AddedField returns the numeric value that was incremented/decremented on a field
  29027. // with the given name. The second boolean return value indicates that this field
  29028. // was not set, or was not defined in the schema.
  29029. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  29030. switch name {
  29031. case token.FieldOrganizationID:
  29032. return m.AddedOrganizationID()
  29033. }
  29034. return nil, false
  29035. }
  29036. // AddField adds the value to the field with the given name. It returns an error if
  29037. // the field is not defined in the schema, or if the type mismatched the field
  29038. // type.
  29039. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  29040. switch name {
  29041. case token.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 Token numeric field %s", name)
  29050. }
  29051. // ClearedFields returns all nullable fields that were cleared during this
  29052. // mutation.
  29053. func (m *TokenMutation) ClearedFields() []string {
  29054. var fields []string
  29055. if m.FieldCleared(token.FieldDeletedAt) {
  29056. fields = append(fields, token.FieldDeletedAt)
  29057. }
  29058. if m.FieldCleared(token.FieldExpireAt) {
  29059. fields = append(fields, token.FieldExpireAt)
  29060. }
  29061. if m.FieldCleared(token.FieldToken) {
  29062. fields = append(fields, token.FieldToken)
  29063. }
  29064. if m.FieldCleared(token.FieldMAC) {
  29065. fields = append(fields, token.FieldMAC)
  29066. }
  29067. if m.FieldCleared(token.FieldCustomAgentBase) {
  29068. fields = append(fields, token.FieldCustomAgentBase)
  29069. }
  29070. if m.FieldCleared(token.FieldCustomAgentKey) {
  29071. fields = append(fields, token.FieldCustomAgentKey)
  29072. }
  29073. if m.FieldCleared(token.FieldOpenaiBase) {
  29074. fields = append(fields, token.FieldOpenaiBase)
  29075. }
  29076. if m.FieldCleared(token.FieldOpenaiKey) {
  29077. fields = append(fields, token.FieldOpenaiKey)
  29078. }
  29079. return fields
  29080. }
  29081. // FieldCleared returns a boolean indicating if a field with the given name was
  29082. // cleared in this mutation.
  29083. func (m *TokenMutation) FieldCleared(name string) bool {
  29084. _, ok := m.clearedFields[name]
  29085. return ok
  29086. }
  29087. // ClearField clears the value of the field with the given name. It returns an
  29088. // error if the field is not defined in the schema.
  29089. func (m *TokenMutation) ClearField(name string) error {
  29090. switch name {
  29091. case token.FieldDeletedAt:
  29092. m.ClearDeletedAt()
  29093. return nil
  29094. case token.FieldExpireAt:
  29095. m.ClearExpireAt()
  29096. return nil
  29097. case token.FieldToken:
  29098. m.ClearToken()
  29099. return nil
  29100. case token.FieldMAC:
  29101. m.ClearMAC()
  29102. return nil
  29103. case token.FieldCustomAgentBase:
  29104. m.ClearCustomAgentBase()
  29105. return nil
  29106. case token.FieldCustomAgentKey:
  29107. m.ClearCustomAgentKey()
  29108. return nil
  29109. case token.FieldOpenaiBase:
  29110. m.ClearOpenaiBase()
  29111. return nil
  29112. case token.FieldOpenaiKey:
  29113. m.ClearOpenaiKey()
  29114. return nil
  29115. }
  29116. return fmt.Errorf("unknown Token nullable field %s", name)
  29117. }
  29118. // ResetField resets all changes in the mutation for the field with the given name.
  29119. // It returns an error if the field is not defined in the schema.
  29120. func (m *TokenMutation) ResetField(name string) error {
  29121. switch name {
  29122. case token.FieldCreatedAt:
  29123. m.ResetCreatedAt()
  29124. return nil
  29125. case token.FieldUpdatedAt:
  29126. m.ResetUpdatedAt()
  29127. return nil
  29128. case token.FieldDeletedAt:
  29129. m.ResetDeletedAt()
  29130. return nil
  29131. case token.FieldExpireAt:
  29132. m.ResetExpireAt()
  29133. return nil
  29134. case token.FieldToken:
  29135. m.ResetToken()
  29136. return nil
  29137. case token.FieldMAC:
  29138. m.ResetMAC()
  29139. return nil
  29140. case token.FieldOrganizationID:
  29141. m.ResetOrganizationID()
  29142. return nil
  29143. case token.FieldAgentID:
  29144. m.ResetAgentID()
  29145. return nil
  29146. case token.FieldCustomAgentBase:
  29147. m.ResetCustomAgentBase()
  29148. return nil
  29149. case token.FieldCustomAgentKey:
  29150. m.ResetCustomAgentKey()
  29151. return nil
  29152. case token.FieldOpenaiBase:
  29153. m.ResetOpenaiBase()
  29154. return nil
  29155. case token.FieldOpenaiKey:
  29156. m.ResetOpenaiKey()
  29157. return nil
  29158. }
  29159. return fmt.Errorf("unknown Token field %s", name)
  29160. }
  29161. // AddedEdges returns all edge names that were set/added in this mutation.
  29162. func (m *TokenMutation) AddedEdges() []string {
  29163. edges := make([]string, 0, 1)
  29164. if m.agent != nil {
  29165. edges = append(edges, token.EdgeAgent)
  29166. }
  29167. return edges
  29168. }
  29169. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29170. // name in this mutation.
  29171. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  29172. switch name {
  29173. case token.EdgeAgent:
  29174. if id := m.agent; id != nil {
  29175. return []ent.Value{*id}
  29176. }
  29177. }
  29178. return nil
  29179. }
  29180. // RemovedEdges returns all edge names that were removed in this mutation.
  29181. func (m *TokenMutation) RemovedEdges() []string {
  29182. edges := make([]string, 0, 1)
  29183. return edges
  29184. }
  29185. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29186. // the given name in this mutation.
  29187. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  29188. return nil
  29189. }
  29190. // ClearedEdges returns all edge names that were cleared in this mutation.
  29191. func (m *TokenMutation) ClearedEdges() []string {
  29192. edges := make([]string, 0, 1)
  29193. if m.clearedagent {
  29194. edges = append(edges, token.EdgeAgent)
  29195. }
  29196. return edges
  29197. }
  29198. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29199. // was cleared in this mutation.
  29200. func (m *TokenMutation) EdgeCleared(name string) bool {
  29201. switch name {
  29202. case token.EdgeAgent:
  29203. return m.clearedagent
  29204. }
  29205. return false
  29206. }
  29207. // ClearEdge clears the value of the edge with the given name. It returns an error
  29208. // if that edge is not defined in the schema.
  29209. func (m *TokenMutation) ClearEdge(name string) error {
  29210. switch name {
  29211. case token.EdgeAgent:
  29212. m.ClearAgent()
  29213. return nil
  29214. }
  29215. return fmt.Errorf("unknown Token unique edge %s", name)
  29216. }
  29217. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29218. // It returns an error if the edge is not defined in the schema.
  29219. func (m *TokenMutation) ResetEdge(name string) error {
  29220. switch name {
  29221. case token.EdgeAgent:
  29222. m.ResetAgent()
  29223. return nil
  29224. }
  29225. return fmt.Errorf("unknown Token edge %s", name)
  29226. }
  29227. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  29228. type TutorialMutation struct {
  29229. config
  29230. op Op
  29231. typ string
  29232. id *uint64
  29233. created_at *time.Time
  29234. updated_at *time.Time
  29235. deleted_at *time.Time
  29236. index *int
  29237. addindex *int
  29238. title *string
  29239. content *string
  29240. organization_id *uint64
  29241. addorganization_id *int64
  29242. clearedFields map[string]struct{}
  29243. employee *uint64
  29244. clearedemployee bool
  29245. done bool
  29246. oldValue func(context.Context) (*Tutorial, error)
  29247. predicates []predicate.Tutorial
  29248. }
  29249. var _ ent.Mutation = (*TutorialMutation)(nil)
  29250. // tutorialOption allows management of the mutation configuration using functional options.
  29251. type tutorialOption func(*TutorialMutation)
  29252. // newTutorialMutation creates new mutation for the Tutorial entity.
  29253. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  29254. m := &TutorialMutation{
  29255. config: c,
  29256. op: op,
  29257. typ: TypeTutorial,
  29258. clearedFields: make(map[string]struct{}),
  29259. }
  29260. for _, opt := range opts {
  29261. opt(m)
  29262. }
  29263. return m
  29264. }
  29265. // withTutorialID sets the ID field of the mutation.
  29266. func withTutorialID(id uint64) tutorialOption {
  29267. return func(m *TutorialMutation) {
  29268. var (
  29269. err error
  29270. once sync.Once
  29271. value *Tutorial
  29272. )
  29273. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  29274. once.Do(func() {
  29275. if m.done {
  29276. err = errors.New("querying old values post mutation is not allowed")
  29277. } else {
  29278. value, err = m.Client().Tutorial.Get(ctx, id)
  29279. }
  29280. })
  29281. return value, err
  29282. }
  29283. m.id = &id
  29284. }
  29285. }
  29286. // withTutorial sets the old Tutorial of the mutation.
  29287. func withTutorial(node *Tutorial) tutorialOption {
  29288. return func(m *TutorialMutation) {
  29289. m.oldValue = func(context.Context) (*Tutorial, error) {
  29290. return node, nil
  29291. }
  29292. m.id = &node.ID
  29293. }
  29294. }
  29295. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29296. // executed in a transaction (ent.Tx), a transactional client is returned.
  29297. func (m TutorialMutation) Client() *Client {
  29298. client := &Client{config: m.config}
  29299. client.init()
  29300. return client
  29301. }
  29302. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29303. // it returns an error otherwise.
  29304. func (m TutorialMutation) Tx() (*Tx, error) {
  29305. if _, ok := m.driver.(*txDriver); !ok {
  29306. return nil, errors.New("ent: mutation is not running in a transaction")
  29307. }
  29308. tx := &Tx{config: m.config}
  29309. tx.init()
  29310. return tx, nil
  29311. }
  29312. // SetID sets the value of the id field. Note that this
  29313. // operation is only accepted on creation of Tutorial entities.
  29314. func (m *TutorialMutation) SetID(id uint64) {
  29315. m.id = &id
  29316. }
  29317. // ID returns the ID value in the mutation. Note that the ID is only available
  29318. // if it was provided to the builder or after it was returned from the database.
  29319. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  29320. if m.id == nil {
  29321. return
  29322. }
  29323. return *m.id, true
  29324. }
  29325. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29326. // That means, if the mutation is applied within a transaction with an isolation level such
  29327. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29328. // or updated by the mutation.
  29329. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  29330. switch {
  29331. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29332. id, exists := m.ID()
  29333. if exists {
  29334. return []uint64{id}, nil
  29335. }
  29336. fallthrough
  29337. case m.op.Is(OpUpdate | OpDelete):
  29338. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  29339. default:
  29340. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29341. }
  29342. }
  29343. // SetCreatedAt sets the "created_at" field.
  29344. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  29345. m.created_at = &t
  29346. }
  29347. // CreatedAt returns the value of the "created_at" field in the mutation.
  29348. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  29349. v := m.created_at
  29350. if v == nil {
  29351. return
  29352. }
  29353. return *v, true
  29354. }
  29355. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  29356. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29358. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29359. if !m.op.Is(OpUpdateOne) {
  29360. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29361. }
  29362. if m.id == nil || m.oldValue == nil {
  29363. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29364. }
  29365. oldValue, err := m.oldValue(ctx)
  29366. if err != nil {
  29367. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29368. }
  29369. return oldValue.CreatedAt, nil
  29370. }
  29371. // ResetCreatedAt resets all changes to the "created_at" field.
  29372. func (m *TutorialMutation) ResetCreatedAt() {
  29373. m.created_at = nil
  29374. }
  29375. // SetUpdatedAt sets the "updated_at" field.
  29376. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  29377. m.updated_at = &t
  29378. }
  29379. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29380. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  29381. v := m.updated_at
  29382. if v == nil {
  29383. return
  29384. }
  29385. return *v, true
  29386. }
  29387. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  29388. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29390. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29391. if !m.op.Is(OpUpdateOne) {
  29392. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29393. }
  29394. if m.id == nil || m.oldValue == nil {
  29395. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29396. }
  29397. oldValue, err := m.oldValue(ctx)
  29398. if err != nil {
  29399. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29400. }
  29401. return oldValue.UpdatedAt, nil
  29402. }
  29403. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29404. func (m *TutorialMutation) ResetUpdatedAt() {
  29405. m.updated_at = nil
  29406. }
  29407. // SetDeletedAt sets the "deleted_at" field.
  29408. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  29409. m.deleted_at = &t
  29410. }
  29411. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29412. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  29413. v := m.deleted_at
  29414. if v == nil {
  29415. return
  29416. }
  29417. return *v, true
  29418. }
  29419. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  29420. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29422. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29423. if !m.op.Is(OpUpdateOne) {
  29424. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29425. }
  29426. if m.id == nil || m.oldValue == nil {
  29427. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29428. }
  29429. oldValue, err := m.oldValue(ctx)
  29430. if err != nil {
  29431. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29432. }
  29433. return oldValue.DeletedAt, nil
  29434. }
  29435. // ClearDeletedAt clears the value of the "deleted_at" field.
  29436. func (m *TutorialMutation) ClearDeletedAt() {
  29437. m.deleted_at = nil
  29438. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  29439. }
  29440. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29441. func (m *TutorialMutation) DeletedAtCleared() bool {
  29442. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  29443. return ok
  29444. }
  29445. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29446. func (m *TutorialMutation) ResetDeletedAt() {
  29447. m.deleted_at = nil
  29448. delete(m.clearedFields, tutorial.FieldDeletedAt)
  29449. }
  29450. // SetEmployeeID sets the "employee_id" field.
  29451. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  29452. m.employee = &u
  29453. }
  29454. // EmployeeID returns the value of the "employee_id" field in the mutation.
  29455. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  29456. v := m.employee
  29457. if v == nil {
  29458. return
  29459. }
  29460. return *v, true
  29461. }
  29462. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  29463. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29465. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  29466. if !m.op.Is(OpUpdateOne) {
  29467. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  29468. }
  29469. if m.id == nil || m.oldValue == nil {
  29470. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  29471. }
  29472. oldValue, err := m.oldValue(ctx)
  29473. if err != nil {
  29474. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  29475. }
  29476. return oldValue.EmployeeID, nil
  29477. }
  29478. // ResetEmployeeID resets all changes to the "employee_id" field.
  29479. func (m *TutorialMutation) ResetEmployeeID() {
  29480. m.employee = nil
  29481. }
  29482. // SetIndex sets the "index" field.
  29483. func (m *TutorialMutation) SetIndex(i int) {
  29484. m.index = &i
  29485. m.addindex = nil
  29486. }
  29487. // Index returns the value of the "index" field in the mutation.
  29488. func (m *TutorialMutation) Index() (r int, exists bool) {
  29489. v := m.index
  29490. if v == nil {
  29491. return
  29492. }
  29493. return *v, true
  29494. }
  29495. // OldIndex returns the old "index" field's value of the Tutorial entity.
  29496. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29498. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  29499. if !m.op.Is(OpUpdateOne) {
  29500. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  29501. }
  29502. if m.id == nil || m.oldValue == nil {
  29503. return v, errors.New("OldIndex requires an ID field in the mutation")
  29504. }
  29505. oldValue, err := m.oldValue(ctx)
  29506. if err != nil {
  29507. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  29508. }
  29509. return oldValue.Index, nil
  29510. }
  29511. // AddIndex adds i to the "index" field.
  29512. func (m *TutorialMutation) AddIndex(i int) {
  29513. if m.addindex != nil {
  29514. *m.addindex += i
  29515. } else {
  29516. m.addindex = &i
  29517. }
  29518. }
  29519. // AddedIndex returns the value that was added to the "index" field in this mutation.
  29520. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  29521. v := m.addindex
  29522. if v == nil {
  29523. return
  29524. }
  29525. return *v, true
  29526. }
  29527. // ResetIndex resets all changes to the "index" field.
  29528. func (m *TutorialMutation) ResetIndex() {
  29529. m.index = nil
  29530. m.addindex = nil
  29531. }
  29532. // SetTitle sets the "title" field.
  29533. func (m *TutorialMutation) SetTitle(s string) {
  29534. m.title = &s
  29535. }
  29536. // Title returns the value of the "title" field in the mutation.
  29537. func (m *TutorialMutation) Title() (r string, exists bool) {
  29538. v := m.title
  29539. if v == nil {
  29540. return
  29541. }
  29542. return *v, true
  29543. }
  29544. // OldTitle returns the old "title" field's value of the Tutorial entity.
  29545. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29547. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  29548. if !m.op.Is(OpUpdateOne) {
  29549. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  29550. }
  29551. if m.id == nil || m.oldValue == nil {
  29552. return v, errors.New("OldTitle requires an ID field in the mutation")
  29553. }
  29554. oldValue, err := m.oldValue(ctx)
  29555. if err != nil {
  29556. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  29557. }
  29558. return oldValue.Title, nil
  29559. }
  29560. // ResetTitle resets all changes to the "title" field.
  29561. func (m *TutorialMutation) ResetTitle() {
  29562. m.title = nil
  29563. }
  29564. // SetContent sets the "content" field.
  29565. func (m *TutorialMutation) SetContent(s string) {
  29566. m.content = &s
  29567. }
  29568. // Content returns the value of the "content" field in the mutation.
  29569. func (m *TutorialMutation) Content() (r string, exists bool) {
  29570. v := m.content
  29571. if v == nil {
  29572. return
  29573. }
  29574. return *v, true
  29575. }
  29576. // OldContent returns the old "content" field's value of the Tutorial entity.
  29577. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29579. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  29580. if !m.op.Is(OpUpdateOne) {
  29581. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  29582. }
  29583. if m.id == nil || m.oldValue == nil {
  29584. return v, errors.New("OldContent requires an ID field in the mutation")
  29585. }
  29586. oldValue, err := m.oldValue(ctx)
  29587. if err != nil {
  29588. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  29589. }
  29590. return oldValue.Content, nil
  29591. }
  29592. // ResetContent resets all changes to the "content" field.
  29593. func (m *TutorialMutation) ResetContent() {
  29594. m.content = nil
  29595. }
  29596. // SetOrganizationID sets the "organization_id" field.
  29597. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  29598. m.organization_id = &u
  29599. m.addorganization_id = nil
  29600. }
  29601. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29602. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  29603. v := m.organization_id
  29604. if v == nil {
  29605. return
  29606. }
  29607. return *v, true
  29608. }
  29609. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  29610. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  29611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29612. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29613. if !m.op.Is(OpUpdateOne) {
  29614. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29615. }
  29616. if m.id == nil || m.oldValue == nil {
  29617. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29618. }
  29619. oldValue, err := m.oldValue(ctx)
  29620. if err != nil {
  29621. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29622. }
  29623. return oldValue.OrganizationID, nil
  29624. }
  29625. // AddOrganizationID adds u to the "organization_id" field.
  29626. func (m *TutorialMutation) AddOrganizationID(u int64) {
  29627. if m.addorganization_id != nil {
  29628. *m.addorganization_id += u
  29629. } else {
  29630. m.addorganization_id = &u
  29631. }
  29632. }
  29633. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29634. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  29635. v := m.addorganization_id
  29636. if v == nil {
  29637. return
  29638. }
  29639. return *v, true
  29640. }
  29641. // ResetOrganizationID resets all changes to the "organization_id" field.
  29642. func (m *TutorialMutation) ResetOrganizationID() {
  29643. m.organization_id = nil
  29644. m.addorganization_id = nil
  29645. }
  29646. // ClearEmployee clears the "employee" edge to the Employee entity.
  29647. func (m *TutorialMutation) ClearEmployee() {
  29648. m.clearedemployee = true
  29649. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  29650. }
  29651. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  29652. func (m *TutorialMutation) EmployeeCleared() bool {
  29653. return m.clearedemployee
  29654. }
  29655. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  29656. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29657. // EmployeeID instead. It exists only for internal usage by the builders.
  29658. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  29659. if id := m.employee; id != nil {
  29660. ids = append(ids, *id)
  29661. }
  29662. return
  29663. }
  29664. // ResetEmployee resets all changes to the "employee" edge.
  29665. func (m *TutorialMutation) ResetEmployee() {
  29666. m.employee = nil
  29667. m.clearedemployee = false
  29668. }
  29669. // Where appends a list predicates to the TutorialMutation builder.
  29670. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  29671. m.predicates = append(m.predicates, ps...)
  29672. }
  29673. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  29674. // users can use type-assertion to append predicates that do not depend on any generated package.
  29675. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  29676. p := make([]predicate.Tutorial, len(ps))
  29677. for i := range ps {
  29678. p[i] = ps[i]
  29679. }
  29680. m.Where(p...)
  29681. }
  29682. // Op returns the operation name.
  29683. func (m *TutorialMutation) Op() Op {
  29684. return m.op
  29685. }
  29686. // SetOp allows setting the mutation operation.
  29687. func (m *TutorialMutation) SetOp(op Op) {
  29688. m.op = op
  29689. }
  29690. // Type returns the node type of this mutation (Tutorial).
  29691. func (m *TutorialMutation) Type() string {
  29692. return m.typ
  29693. }
  29694. // Fields returns all fields that were changed during this mutation. Note that in
  29695. // order to get all numeric fields that were incremented/decremented, call
  29696. // AddedFields().
  29697. func (m *TutorialMutation) Fields() []string {
  29698. fields := make([]string, 0, 8)
  29699. if m.created_at != nil {
  29700. fields = append(fields, tutorial.FieldCreatedAt)
  29701. }
  29702. if m.updated_at != nil {
  29703. fields = append(fields, tutorial.FieldUpdatedAt)
  29704. }
  29705. if m.deleted_at != nil {
  29706. fields = append(fields, tutorial.FieldDeletedAt)
  29707. }
  29708. if m.employee != nil {
  29709. fields = append(fields, tutorial.FieldEmployeeID)
  29710. }
  29711. if m.index != nil {
  29712. fields = append(fields, tutorial.FieldIndex)
  29713. }
  29714. if m.title != nil {
  29715. fields = append(fields, tutorial.FieldTitle)
  29716. }
  29717. if m.content != nil {
  29718. fields = append(fields, tutorial.FieldContent)
  29719. }
  29720. if m.organization_id != nil {
  29721. fields = append(fields, tutorial.FieldOrganizationID)
  29722. }
  29723. return fields
  29724. }
  29725. // Field returns the value of a field with the given name. The second boolean
  29726. // return value indicates that this field was not set, or was not defined in the
  29727. // schema.
  29728. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  29729. switch name {
  29730. case tutorial.FieldCreatedAt:
  29731. return m.CreatedAt()
  29732. case tutorial.FieldUpdatedAt:
  29733. return m.UpdatedAt()
  29734. case tutorial.FieldDeletedAt:
  29735. return m.DeletedAt()
  29736. case tutorial.FieldEmployeeID:
  29737. return m.EmployeeID()
  29738. case tutorial.FieldIndex:
  29739. return m.Index()
  29740. case tutorial.FieldTitle:
  29741. return m.Title()
  29742. case tutorial.FieldContent:
  29743. return m.Content()
  29744. case tutorial.FieldOrganizationID:
  29745. return m.OrganizationID()
  29746. }
  29747. return nil, false
  29748. }
  29749. // OldField returns the old value of the field from the database. An error is
  29750. // returned if the mutation operation is not UpdateOne, or the query to the
  29751. // database failed.
  29752. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29753. switch name {
  29754. case tutorial.FieldCreatedAt:
  29755. return m.OldCreatedAt(ctx)
  29756. case tutorial.FieldUpdatedAt:
  29757. return m.OldUpdatedAt(ctx)
  29758. case tutorial.FieldDeletedAt:
  29759. return m.OldDeletedAt(ctx)
  29760. case tutorial.FieldEmployeeID:
  29761. return m.OldEmployeeID(ctx)
  29762. case tutorial.FieldIndex:
  29763. return m.OldIndex(ctx)
  29764. case tutorial.FieldTitle:
  29765. return m.OldTitle(ctx)
  29766. case tutorial.FieldContent:
  29767. return m.OldContent(ctx)
  29768. case tutorial.FieldOrganizationID:
  29769. return m.OldOrganizationID(ctx)
  29770. }
  29771. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  29772. }
  29773. // SetField sets the value of a field with the given name. It returns an error if
  29774. // the field is not defined in the schema, or if the type mismatched the field
  29775. // type.
  29776. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  29777. switch name {
  29778. case tutorial.FieldCreatedAt:
  29779. v, ok := value.(time.Time)
  29780. if !ok {
  29781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29782. }
  29783. m.SetCreatedAt(v)
  29784. return nil
  29785. case tutorial.FieldUpdatedAt:
  29786. v, ok := value.(time.Time)
  29787. if !ok {
  29788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29789. }
  29790. m.SetUpdatedAt(v)
  29791. return nil
  29792. case tutorial.FieldDeletedAt:
  29793. v, ok := value.(time.Time)
  29794. if !ok {
  29795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29796. }
  29797. m.SetDeletedAt(v)
  29798. return nil
  29799. case tutorial.FieldEmployeeID:
  29800. v, ok := value.(uint64)
  29801. if !ok {
  29802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29803. }
  29804. m.SetEmployeeID(v)
  29805. return nil
  29806. case tutorial.FieldIndex:
  29807. v, ok := value.(int)
  29808. if !ok {
  29809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29810. }
  29811. m.SetIndex(v)
  29812. return nil
  29813. case tutorial.FieldTitle:
  29814. v, ok := value.(string)
  29815. if !ok {
  29816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29817. }
  29818. m.SetTitle(v)
  29819. return nil
  29820. case tutorial.FieldContent:
  29821. v, ok := value.(string)
  29822. if !ok {
  29823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29824. }
  29825. m.SetContent(v)
  29826. return nil
  29827. case tutorial.FieldOrganizationID:
  29828. v, ok := value.(uint64)
  29829. if !ok {
  29830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29831. }
  29832. m.SetOrganizationID(v)
  29833. return nil
  29834. }
  29835. return fmt.Errorf("unknown Tutorial field %s", name)
  29836. }
  29837. // AddedFields returns all numeric fields that were incremented/decremented during
  29838. // this mutation.
  29839. func (m *TutorialMutation) AddedFields() []string {
  29840. var fields []string
  29841. if m.addindex != nil {
  29842. fields = append(fields, tutorial.FieldIndex)
  29843. }
  29844. if m.addorganization_id != nil {
  29845. fields = append(fields, tutorial.FieldOrganizationID)
  29846. }
  29847. return fields
  29848. }
  29849. // AddedField returns the numeric value that was incremented/decremented on a field
  29850. // with the given name. The second boolean return value indicates that this field
  29851. // was not set, or was not defined in the schema.
  29852. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  29853. switch name {
  29854. case tutorial.FieldIndex:
  29855. return m.AddedIndex()
  29856. case tutorial.FieldOrganizationID:
  29857. return m.AddedOrganizationID()
  29858. }
  29859. return nil, false
  29860. }
  29861. // AddField adds the value to the field with the given name. It returns an error if
  29862. // the field is not defined in the schema, or if the type mismatched the field
  29863. // type.
  29864. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  29865. switch name {
  29866. case tutorial.FieldIndex:
  29867. v, ok := value.(int)
  29868. if !ok {
  29869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29870. }
  29871. m.AddIndex(v)
  29872. return nil
  29873. case tutorial.FieldOrganizationID:
  29874. v, ok := value.(int64)
  29875. if !ok {
  29876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29877. }
  29878. m.AddOrganizationID(v)
  29879. return nil
  29880. }
  29881. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  29882. }
  29883. // ClearedFields returns all nullable fields that were cleared during this
  29884. // mutation.
  29885. func (m *TutorialMutation) ClearedFields() []string {
  29886. var fields []string
  29887. if m.FieldCleared(tutorial.FieldDeletedAt) {
  29888. fields = append(fields, tutorial.FieldDeletedAt)
  29889. }
  29890. return fields
  29891. }
  29892. // FieldCleared returns a boolean indicating if a field with the given name was
  29893. // cleared in this mutation.
  29894. func (m *TutorialMutation) FieldCleared(name string) bool {
  29895. _, ok := m.clearedFields[name]
  29896. return ok
  29897. }
  29898. // ClearField clears the value of the field with the given name. It returns an
  29899. // error if the field is not defined in the schema.
  29900. func (m *TutorialMutation) ClearField(name string) error {
  29901. switch name {
  29902. case tutorial.FieldDeletedAt:
  29903. m.ClearDeletedAt()
  29904. return nil
  29905. }
  29906. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  29907. }
  29908. // ResetField resets all changes in the mutation for the field with the given name.
  29909. // It returns an error if the field is not defined in the schema.
  29910. func (m *TutorialMutation) ResetField(name string) error {
  29911. switch name {
  29912. case tutorial.FieldCreatedAt:
  29913. m.ResetCreatedAt()
  29914. return nil
  29915. case tutorial.FieldUpdatedAt:
  29916. m.ResetUpdatedAt()
  29917. return nil
  29918. case tutorial.FieldDeletedAt:
  29919. m.ResetDeletedAt()
  29920. return nil
  29921. case tutorial.FieldEmployeeID:
  29922. m.ResetEmployeeID()
  29923. return nil
  29924. case tutorial.FieldIndex:
  29925. m.ResetIndex()
  29926. return nil
  29927. case tutorial.FieldTitle:
  29928. m.ResetTitle()
  29929. return nil
  29930. case tutorial.FieldContent:
  29931. m.ResetContent()
  29932. return nil
  29933. case tutorial.FieldOrganizationID:
  29934. m.ResetOrganizationID()
  29935. return nil
  29936. }
  29937. return fmt.Errorf("unknown Tutorial field %s", name)
  29938. }
  29939. // AddedEdges returns all edge names that were set/added in this mutation.
  29940. func (m *TutorialMutation) AddedEdges() []string {
  29941. edges := make([]string, 0, 1)
  29942. if m.employee != nil {
  29943. edges = append(edges, tutorial.EdgeEmployee)
  29944. }
  29945. return edges
  29946. }
  29947. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29948. // name in this mutation.
  29949. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  29950. switch name {
  29951. case tutorial.EdgeEmployee:
  29952. if id := m.employee; id != nil {
  29953. return []ent.Value{*id}
  29954. }
  29955. }
  29956. return nil
  29957. }
  29958. // RemovedEdges returns all edge names that were removed in this mutation.
  29959. func (m *TutorialMutation) RemovedEdges() []string {
  29960. edges := make([]string, 0, 1)
  29961. return edges
  29962. }
  29963. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29964. // the given name in this mutation.
  29965. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  29966. return nil
  29967. }
  29968. // ClearedEdges returns all edge names that were cleared in this mutation.
  29969. func (m *TutorialMutation) ClearedEdges() []string {
  29970. edges := make([]string, 0, 1)
  29971. if m.clearedemployee {
  29972. edges = append(edges, tutorial.EdgeEmployee)
  29973. }
  29974. return edges
  29975. }
  29976. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29977. // was cleared in this mutation.
  29978. func (m *TutorialMutation) EdgeCleared(name string) bool {
  29979. switch name {
  29980. case tutorial.EdgeEmployee:
  29981. return m.clearedemployee
  29982. }
  29983. return false
  29984. }
  29985. // ClearEdge clears the value of the edge with the given name. It returns an error
  29986. // if that edge is not defined in the schema.
  29987. func (m *TutorialMutation) ClearEdge(name string) error {
  29988. switch name {
  29989. case tutorial.EdgeEmployee:
  29990. m.ClearEmployee()
  29991. return nil
  29992. }
  29993. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  29994. }
  29995. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29996. // It returns an error if the edge is not defined in the schema.
  29997. func (m *TutorialMutation) ResetEdge(name string) error {
  29998. switch name {
  29999. case tutorial.EdgeEmployee:
  30000. m.ResetEmployee()
  30001. return nil
  30002. }
  30003. return fmt.Errorf("unknown Tutorial edge %s", name)
  30004. }
  30005. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  30006. type UsageDetailMutation struct {
  30007. config
  30008. op Op
  30009. typ string
  30010. id *uint64
  30011. created_at *time.Time
  30012. updated_at *time.Time
  30013. status *uint8
  30014. addstatus *int8
  30015. _type *int
  30016. add_type *int
  30017. bot_id *string
  30018. receiver_id *string
  30019. app *int
  30020. addapp *int
  30021. session_id *uint64
  30022. addsession_id *int64
  30023. request *string
  30024. response *string
  30025. original_data *custom_types.OriginalData
  30026. total_tokens *uint64
  30027. addtotal_tokens *int64
  30028. prompt_tokens *uint64
  30029. addprompt_tokens *int64
  30030. completion_tokens *uint64
  30031. addcompletion_tokens *int64
  30032. organization_id *uint64
  30033. addorganization_id *int64
  30034. clearedFields map[string]struct{}
  30035. done bool
  30036. oldValue func(context.Context) (*UsageDetail, error)
  30037. predicates []predicate.UsageDetail
  30038. }
  30039. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  30040. // usagedetailOption allows management of the mutation configuration using functional options.
  30041. type usagedetailOption func(*UsageDetailMutation)
  30042. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  30043. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  30044. m := &UsageDetailMutation{
  30045. config: c,
  30046. op: op,
  30047. typ: TypeUsageDetail,
  30048. clearedFields: make(map[string]struct{}),
  30049. }
  30050. for _, opt := range opts {
  30051. opt(m)
  30052. }
  30053. return m
  30054. }
  30055. // withUsageDetailID sets the ID field of the mutation.
  30056. func withUsageDetailID(id uint64) usagedetailOption {
  30057. return func(m *UsageDetailMutation) {
  30058. var (
  30059. err error
  30060. once sync.Once
  30061. value *UsageDetail
  30062. )
  30063. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  30064. once.Do(func() {
  30065. if m.done {
  30066. err = errors.New("querying old values post mutation is not allowed")
  30067. } else {
  30068. value, err = m.Client().UsageDetail.Get(ctx, id)
  30069. }
  30070. })
  30071. return value, err
  30072. }
  30073. m.id = &id
  30074. }
  30075. }
  30076. // withUsageDetail sets the old UsageDetail of the mutation.
  30077. func withUsageDetail(node *UsageDetail) usagedetailOption {
  30078. return func(m *UsageDetailMutation) {
  30079. m.oldValue = func(context.Context) (*UsageDetail, error) {
  30080. return node, nil
  30081. }
  30082. m.id = &node.ID
  30083. }
  30084. }
  30085. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30086. // executed in a transaction (ent.Tx), a transactional client is returned.
  30087. func (m UsageDetailMutation) Client() *Client {
  30088. client := &Client{config: m.config}
  30089. client.init()
  30090. return client
  30091. }
  30092. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30093. // it returns an error otherwise.
  30094. func (m UsageDetailMutation) Tx() (*Tx, error) {
  30095. if _, ok := m.driver.(*txDriver); !ok {
  30096. return nil, errors.New("ent: mutation is not running in a transaction")
  30097. }
  30098. tx := &Tx{config: m.config}
  30099. tx.init()
  30100. return tx, nil
  30101. }
  30102. // SetID sets the value of the id field. Note that this
  30103. // operation is only accepted on creation of UsageDetail entities.
  30104. func (m *UsageDetailMutation) SetID(id uint64) {
  30105. m.id = &id
  30106. }
  30107. // ID returns the ID value in the mutation. Note that the ID is only available
  30108. // if it was provided to the builder or after it was returned from the database.
  30109. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  30110. if m.id == nil {
  30111. return
  30112. }
  30113. return *m.id, true
  30114. }
  30115. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30116. // That means, if the mutation is applied within a transaction with an isolation level such
  30117. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30118. // or updated by the mutation.
  30119. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  30120. switch {
  30121. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30122. id, exists := m.ID()
  30123. if exists {
  30124. return []uint64{id}, nil
  30125. }
  30126. fallthrough
  30127. case m.op.Is(OpUpdate | OpDelete):
  30128. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  30129. default:
  30130. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30131. }
  30132. }
  30133. // SetCreatedAt sets the "created_at" field.
  30134. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  30135. m.created_at = &t
  30136. }
  30137. // CreatedAt returns the value of the "created_at" field in the mutation.
  30138. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  30139. v := m.created_at
  30140. if v == nil {
  30141. return
  30142. }
  30143. return *v, true
  30144. }
  30145. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  30146. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30148. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30149. if !m.op.Is(OpUpdateOne) {
  30150. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30151. }
  30152. if m.id == nil || m.oldValue == nil {
  30153. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30154. }
  30155. oldValue, err := m.oldValue(ctx)
  30156. if err != nil {
  30157. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30158. }
  30159. return oldValue.CreatedAt, nil
  30160. }
  30161. // ResetCreatedAt resets all changes to the "created_at" field.
  30162. func (m *UsageDetailMutation) ResetCreatedAt() {
  30163. m.created_at = nil
  30164. }
  30165. // SetUpdatedAt sets the "updated_at" field.
  30166. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  30167. m.updated_at = &t
  30168. }
  30169. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30170. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  30171. v := m.updated_at
  30172. if v == nil {
  30173. return
  30174. }
  30175. return *v, true
  30176. }
  30177. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  30178. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30180. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30181. if !m.op.Is(OpUpdateOne) {
  30182. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30183. }
  30184. if m.id == nil || m.oldValue == nil {
  30185. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30186. }
  30187. oldValue, err := m.oldValue(ctx)
  30188. if err != nil {
  30189. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30190. }
  30191. return oldValue.UpdatedAt, nil
  30192. }
  30193. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30194. func (m *UsageDetailMutation) ResetUpdatedAt() {
  30195. m.updated_at = nil
  30196. }
  30197. // SetStatus sets the "status" field.
  30198. func (m *UsageDetailMutation) SetStatus(u uint8) {
  30199. m.status = &u
  30200. m.addstatus = nil
  30201. }
  30202. // Status returns the value of the "status" field in the mutation.
  30203. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  30204. v := m.status
  30205. if v == nil {
  30206. return
  30207. }
  30208. return *v, true
  30209. }
  30210. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  30211. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30213. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30214. if !m.op.Is(OpUpdateOne) {
  30215. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30216. }
  30217. if m.id == nil || m.oldValue == nil {
  30218. return v, errors.New("OldStatus requires an ID field in the mutation")
  30219. }
  30220. oldValue, err := m.oldValue(ctx)
  30221. if err != nil {
  30222. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30223. }
  30224. return oldValue.Status, nil
  30225. }
  30226. // AddStatus adds u to the "status" field.
  30227. func (m *UsageDetailMutation) AddStatus(u int8) {
  30228. if m.addstatus != nil {
  30229. *m.addstatus += u
  30230. } else {
  30231. m.addstatus = &u
  30232. }
  30233. }
  30234. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30235. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  30236. v := m.addstatus
  30237. if v == nil {
  30238. return
  30239. }
  30240. return *v, true
  30241. }
  30242. // ClearStatus clears the value of the "status" field.
  30243. func (m *UsageDetailMutation) ClearStatus() {
  30244. m.status = nil
  30245. m.addstatus = nil
  30246. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  30247. }
  30248. // StatusCleared returns if the "status" field was cleared in this mutation.
  30249. func (m *UsageDetailMutation) StatusCleared() bool {
  30250. _, ok := m.clearedFields[usagedetail.FieldStatus]
  30251. return ok
  30252. }
  30253. // ResetStatus resets all changes to the "status" field.
  30254. func (m *UsageDetailMutation) ResetStatus() {
  30255. m.status = nil
  30256. m.addstatus = nil
  30257. delete(m.clearedFields, usagedetail.FieldStatus)
  30258. }
  30259. // SetType sets the "type" field.
  30260. func (m *UsageDetailMutation) SetType(i int) {
  30261. m._type = &i
  30262. m.add_type = nil
  30263. }
  30264. // GetType returns the value of the "type" field in the mutation.
  30265. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  30266. v := m._type
  30267. if v == nil {
  30268. return
  30269. }
  30270. return *v, true
  30271. }
  30272. // OldType returns the old "type" field's value of the UsageDetail entity.
  30273. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30275. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  30276. if !m.op.Is(OpUpdateOne) {
  30277. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30278. }
  30279. if m.id == nil || m.oldValue == nil {
  30280. return v, errors.New("OldType requires an ID field in the mutation")
  30281. }
  30282. oldValue, err := m.oldValue(ctx)
  30283. if err != nil {
  30284. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30285. }
  30286. return oldValue.Type, nil
  30287. }
  30288. // AddType adds i to the "type" field.
  30289. func (m *UsageDetailMutation) AddType(i int) {
  30290. if m.add_type != nil {
  30291. *m.add_type += i
  30292. } else {
  30293. m.add_type = &i
  30294. }
  30295. }
  30296. // AddedType returns the value that was added to the "type" field in this mutation.
  30297. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  30298. v := m.add_type
  30299. if v == nil {
  30300. return
  30301. }
  30302. return *v, true
  30303. }
  30304. // ClearType clears the value of the "type" field.
  30305. func (m *UsageDetailMutation) ClearType() {
  30306. m._type = nil
  30307. m.add_type = nil
  30308. m.clearedFields[usagedetail.FieldType] = struct{}{}
  30309. }
  30310. // TypeCleared returns if the "type" field was cleared in this mutation.
  30311. func (m *UsageDetailMutation) TypeCleared() bool {
  30312. _, ok := m.clearedFields[usagedetail.FieldType]
  30313. return ok
  30314. }
  30315. // ResetType resets all changes to the "type" field.
  30316. func (m *UsageDetailMutation) ResetType() {
  30317. m._type = nil
  30318. m.add_type = nil
  30319. delete(m.clearedFields, usagedetail.FieldType)
  30320. }
  30321. // SetBotID sets the "bot_id" field.
  30322. func (m *UsageDetailMutation) SetBotID(s string) {
  30323. m.bot_id = &s
  30324. }
  30325. // BotID returns the value of the "bot_id" field in the mutation.
  30326. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  30327. v := m.bot_id
  30328. if v == nil {
  30329. return
  30330. }
  30331. return *v, true
  30332. }
  30333. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  30334. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30336. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  30337. if !m.op.Is(OpUpdateOne) {
  30338. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30339. }
  30340. if m.id == nil || m.oldValue == nil {
  30341. return v, errors.New("OldBotID requires an ID field in the mutation")
  30342. }
  30343. oldValue, err := m.oldValue(ctx)
  30344. if err != nil {
  30345. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30346. }
  30347. return oldValue.BotID, nil
  30348. }
  30349. // ResetBotID resets all changes to the "bot_id" field.
  30350. func (m *UsageDetailMutation) ResetBotID() {
  30351. m.bot_id = nil
  30352. }
  30353. // SetReceiverID sets the "receiver_id" field.
  30354. func (m *UsageDetailMutation) SetReceiverID(s string) {
  30355. m.receiver_id = &s
  30356. }
  30357. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  30358. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  30359. v := m.receiver_id
  30360. if v == nil {
  30361. return
  30362. }
  30363. return *v, true
  30364. }
  30365. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  30366. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30368. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  30369. if !m.op.Is(OpUpdateOne) {
  30370. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  30371. }
  30372. if m.id == nil || m.oldValue == nil {
  30373. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  30374. }
  30375. oldValue, err := m.oldValue(ctx)
  30376. if err != nil {
  30377. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  30378. }
  30379. return oldValue.ReceiverID, nil
  30380. }
  30381. // ResetReceiverID resets all changes to the "receiver_id" field.
  30382. func (m *UsageDetailMutation) ResetReceiverID() {
  30383. m.receiver_id = nil
  30384. }
  30385. // SetApp sets the "app" field.
  30386. func (m *UsageDetailMutation) SetApp(i int) {
  30387. m.app = &i
  30388. m.addapp = nil
  30389. }
  30390. // App returns the value of the "app" field in the mutation.
  30391. func (m *UsageDetailMutation) App() (r int, exists bool) {
  30392. v := m.app
  30393. if v == nil {
  30394. return
  30395. }
  30396. return *v, true
  30397. }
  30398. // OldApp returns the old "app" field's value of the UsageDetail entity.
  30399. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30401. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  30402. if !m.op.Is(OpUpdateOne) {
  30403. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  30404. }
  30405. if m.id == nil || m.oldValue == nil {
  30406. return v, errors.New("OldApp requires an ID field in the mutation")
  30407. }
  30408. oldValue, err := m.oldValue(ctx)
  30409. if err != nil {
  30410. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  30411. }
  30412. return oldValue.App, nil
  30413. }
  30414. // AddApp adds i to the "app" field.
  30415. func (m *UsageDetailMutation) AddApp(i int) {
  30416. if m.addapp != nil {
  30417. *m.addapp += i
  30418. } else {
  30419. m.addapp = &i
  30420. }
  30421. }
  30422. // AddedApp returns the value that was added to the "app" field in this mutation.
  30423. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  30424. v := m.addapp
  30425. if v == nil {
  30426. return
  30427. }
  30428. return *v, true
  30429. }
  30430. // ClearApp clears the value of the "app" field.
  30431. func (m *UsageDetailMutation) ClearApp() {
  30432. m.app = nil
  30433. m.addapp = nil
  30434. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  30435. }
  30436. // AppCleared returns if the "app" field was cleared in this mutation.
  30437. func (m *UsageDetailMutation) AppCleared() bool {
  30438. _, ok := m.clearedFields[usagedetail.FieldApp]
  30439. return ok
  30440. }
  30441. // ResetApp resets all changes to the "app" field.
  30442. func (m *UsageDetailMutation) ResetApp() {
  30443. m.app = nil
  30444. m.addapp = nil
  30445. delete(m.clearedFields, usagedetail.FieldApp)
  30446. }
  30447. // SetSessionID sets the "session_id" field.
  30448. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  30449. m.session_id = &u
  30450. m.addsession_id = nil
  30451. }
  30452. // SessionID returns the value of the "session_id" field in the mutation.
  30453. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  30454. v := m.session_id
  30455. if v == nil {
  30456. return
  30457. }
  30458. return *v, true
  30459. }
  30460. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  30461. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30463. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  30464. if !m.op.Is(OpUpdateOne) {
  30465. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  30466. }
  30467. if m.id == nil || m.oldValue == nil {
  30468. return v, errors.New("OldSessionID requires an ID field in the mutation")
  30469. }
  30470. oldValue, err := m.oldValue(ctx)
  30471. if err != nil {
  30472. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  30473. }
  30474. return oldValue.SessionID, nil
  30475. }
  30476. // AddSessionID adds u to the "session_id" field.
  30477. func (m *UsageDetailMutation) AddSessionID(u int64) {
  30478. if m.addsession_id != nil {
  30479. *m.addsession_id += u
  30480. } else {
  30481. m.addsession_id = &u
  30482. }
  30483. }
  30484. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  30485. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  30486. v := m.addsession_id
  30487. if v == nil {
  30488. return
  30489. }
  30490. return *v, true
  30491. }
  30492. // ClearSessionID clears the value of the "session_id" field.
  30493. func (m *UsageDetailMutation) ClearSessionID() {
  30494. m.session_id = nil
  30495. m.addsession_id = nil
  30496. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  30497. }
  30498. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  30499. func (m *UsageDetailMutation) SessionIDCleared() bool {
  30500. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  30501. return ok
  30502. }
  30503. // ResetSessionID resets all changes to the "session_id" field.
  30504. func (m *UsageDetailMutation) ResetSessionID() {
  30505. m.session_id = nil
  30506. m.addsession_id = nil
  30507. delete(m.clearedFields, usagedetail.FieldSessionID)
  30508. }
  30509. // SetRequest sets the "request" field.
  30510. func (m *UsageDetailMutation) SetRequest(s string) {
  30511. m.request = &s
  30512. }
  30513. // Request returns the value of the "request" field in the mutation.
  30514. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  30515. v := m.request
  30516. if v == nil {
  30517. return
  30518. }
  30519. return *v, true
  30520. }
  30521. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  30522. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30524. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  30525. if !m.op.Is(OpUpdateOne) {
  30526. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  30527. }
  30528. if m.id == nil || m.oldValue == nil {
  30529. return v, errors.New("OldRequest requires an ID field in the mutation")
  30530. }
  30531. oldValue, err := m.oldValue(ctx)
  30532. if err != nil {
  30533. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  30534. }
  30535. return oldValue.Request, nil
  30536. }
  30537. // ResetRequest resets all changes to the "request" field.
  30538. func (m *UsageDetailMutation) ResetRequest() {
  30539. m.request = nil
  30540. }
  30541. // SetResponse sets the "response" field.
  30542. func (m *UsageDetailMutation) SetResponse(s string) {
  30543. m.response = &s
  30544. }
  30545. // Response returns the value of the "response" field in the mutation.
  30546. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  30547. v := m.response
  30548. if v == nil {
  30549. return
  30550. }
  30551. return *v, true
  30552. }
  30553. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  30554. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30556. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  30557. if !m.op.Is(OpUpdateOne) {
  30558. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  30559. }
  30560. if m.id == nil || m.oldValue == nil {
  30561. return v, errors.New("OldResponse requires an ID field in the mutation")
  30562. }
  30563. oldValue, err := m.oldValue(ctx)
  30564. if err != nil {
  30565. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  30566. }
  30567. return oldValue.Response, nil
  30568. }
  30569. // ResetResponse resets all changes to the "response" field.
  30570. func (m *UsageDetailMutation) ResetResponse() {
  30571. m.response = nil
  30572. }
  30573. // SetOriginalData sets the "original_data" field.
  30574. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  30575. m.original_data = &ctd
  30576. }
  30577. // OriginalData returns the value of the "original_data" field in the mutation.
  30578. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  30579. v := m.original_data
  30580. if v == nil {
  30581. return
  30582. }
  30583. return *v, true
  30584. }
  30585. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  30586. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30588. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  30589. if !m.op.Is(OpUpdateOne) {
  30590. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  30591. }
  30592. if m.id == nil || m.oldValue == nil {
  30593. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  30594. }
  30595. oldValue, err := m.oldValue(ctx)
  30596. if err != nil {
  30597. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  30598. }
  30599. return oldValue.OriginalData, nil
  30600. }
  30601. // ResetOriginalData resets all changes to the "original_data" field.
  30602. func (m *UsageDetailMutation) ResetOriginalData() {
  30603. m.original_data = nil
  30604. }
  30605. // SetTotalTokens sets the "total_tokens" field.
  30606. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  30607. m.total_tokens = &u
  30608. m.addtotal_tokens = nil
  30609. }
  30610. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  30611. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  30612. v := m.total_tokens
  30613. if v == nil {
  30614. return
  30615. }
  30616. return *v, true
  30617. }
  30618. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  30619. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30621. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  30622. if !m.op.Is(OpUpdateOne) {
  30623. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  30624. }
  30625. if m.id == nil || m.oldValue == nil {
  30626. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  30627. }
  30628. oldValue, err := m.oldValue(ctx)
  30629. if err != nil {
  30630. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  30631. }
  30632. return oldValue.TotalTokens, nil
  30633. }
  30634. // AddTotalTokens adds u to the "total_tokens" field.
  30635. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  30636. if m.addtotal_tokens != nil {
  30637. *m.addtotal_tokens += u
  30638. } else {
  30639. m.addtotal_tokens = &u
  30640. }
  30641. }
  30642. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  30643. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  30644. v := m.addtotal_tokens
  30645. if v == nil {
  30646. return
  30647. }
  30648. return *v, true
  30649. }
  30650. // ClearTotalTokens clears the value of the "total_tokens" field.
  30651. func (m *UsageDetailMutation) ClearTotalTokens() {
  30652. m.total_tokens = nil
  30653. m.addtotal_tokens = nil
  30654. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  30655. }
  30656. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  30657. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  30658. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  30659. return ok
  30660. }
  30661. // ResetTotalTokens resets all changes to the "total_tokens" field.
  30662. func (m *UsageDetailMutation) ResetTotalTokens() {
  30663. m.total_tokens = nil
  30664. m.addtotal_tokens = nil
  30665. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  30666. }
  30667. // SetPromptTokens sets the "prompt_tokens" field.
  30668. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  30669. m.prompt_tokens = &u
  30670. m.addprompt_tokens = nil
  30671. }
  30672. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  30673. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  30674. v := m.prompt_tokens
  30675. if v == nil {
  30676. return
  30677. }
  30678. return *v, true
  30679. }
  30680. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  30681. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30683. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  30684. if !m.op.Is(OpUpdateOne) {
  30685. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  30686. }
  30687. if m.id == nil || m.oldValue == nil {
  30688. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  30689. }
  30690. oldValue, err := m.oldValue(ctx)
  30691. if err != nil {
  30692. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  30693. }
  30694. return oldValue.PromptTokens, nil
  30695. }
  30696. // AddPromptTokens adds u to the "prompt_tokens" field.
  30697. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  30698. if m.addprompt_tokens != nil {
  30699. *m.addprompt_tokens += u
  30700. } else {
  30701. m.addprompt_tokens = &u
  30702. }
  30703. }
  30704. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  30705. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  30706. v := m.addprompt_tokens
  30707. if v == nil {
  30708. return
  30709. }
  30710. return *v, true
  30711. }
  30712. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  30713. func (m *UsageDetailMutation) ClearPromptTokens() {
  30714. m.prompt_tokens = nil
  30715. m.addprompt_tokens = nil
  30716. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  30717. }
  30718. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  30719. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  30720. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  30721. return ok
  30722. }
  30723. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  30724. func (m *UsageDetailMutation) ResetPromptTokens() {
  30725. m.prompt_tokens = nil
  30726. m.addprompt_tokens = nil
  30727. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  30728. }
  30729. // SetCompletionTokens sets the "completion_tokens" field.
  30730. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  30731. m.completion_tokens = &u
  30732. m.addcompletion_tokens = nil
  30733. }
  30734. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  30735. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  30736. v := m.completion_tokens
  30737. if v == nil {
  30738. return
  30739. }
  30740. return *v, true
  30741. }
  30742. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  30743. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30745. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  30746. if !m.op.Is(OpUpdateOne) {
  30747. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  30748. }
  30749. if m.id == nil || m.oldValue == nil {
  30750. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  30751. }
  30752. oldValue, err := m.oldValue(ctx)
  30753. if err != nil {
  30754. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  30755. }
  30756. return oldValue.CompletionTokens, nil
  30757. }
  30758. // AddCompletionTokens adds u to the "completion_tokens" field.
  30759. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  30760. if m.addcompletion_tokens != nil {
  30761. *m.addcompletion_tokens += u
  30762. } else {
  30763. m.addcompletion_tokens = &u
  30764. }
  30765. }
  30766. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  30767. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  30768. v := m.addcompletion_tokens
  30769. if v == nil {
  30770. return
  30771. }
  30772. return *v, true
  30773. }
  30774. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  30775. func (m *UsageDetailMutation) ClearCompletionTokens() {
  30776. m.completion_tokens = nil
  30777. m.addcompletion_tokens = nil
  30778. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  30779. }
  30780. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  30781. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  30782. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  30783. return ok
  30784. }
  30785. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  30786. func (m *UsageDetailMutation) ResetCompletionTokens() {
  30787. m.completion_tokens = nil
  30788. m.addcompletion_tokens = nil
  30789. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  30790. }
  30791. // SetOrganizationID sets the "organization_id" field.
  30792. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  30793. m.organization_id = &u
  30794. m.addorganization_id = nil
  30795. }
  30796. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30797. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  30798. v := m.organization_id
  30799. if v == nil {
  30800. return
  30801. }
  30802. return *v, true
  30803. }
  30804. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  30805. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  30806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30807. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30808. if !m.op.Is(OpUpdateOne) {
  30809. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30810. }
  30811. if m.id == nil || m.oldValue == nil {
  30812. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30813. }
  30814. oldValue, err := m.oldValue(ctx)
  30815. if err != nil {
  30816. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30817. }
  30818. return oldValue.OrganizationID, nil
  30819. }
  30820. // AddOrganizationID adds u to the "organization_id" field.
  30821. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  30822. if m.addorganization_id != nil {
  30823. *m.addorganization_id += u
  30824. } else {
  30825. m.addorganization_id = &u
  30826. }
  30827. }
  30828. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30829. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  30830. v := m.addorganization_id
  30831. if v == nil {
  30832. return
  30833. }
  30834. return *v, true
  30835. }
  30836. // ClearOrganizationID clears the value of the "organization_id" field.
  30837. func (m *UsageDetailMutation) ClearOrganizationID() {
  30838. m.organization_id = nil
  30839. m.addorganization_id = nil
  30840. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  30841. }
  30842. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30843. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  30844. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  30845. return ok
  30846. }
  30847. // ResetOrganizationID resets all changes to the "organization_id" field.
  30848. func (m *UsageDetailMutation) ResetOrganizationID() {
  30849. m.organization_id = nil
  30850. m.addorganization_id = nil
  30851. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  30852. }
  30853. // Where appends a list predicates to the UsageDetailMutation builder.
  30854. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  30855. m.predicates = append(m.predicates, ps...)
  30856. }
  30857. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  30858. // users can use type-assertion to append predicates that do not depend on any generated package.
  30859. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  30860. p := make([]predicate.UsageDetail, len(ps))
  30861. for i := range ps {
  30862. p[i] = ps[i]
  30863. }
  30864. m.Where(p...)
  30865. }
  30866. // Op returns the operation name.
  30867. func (m *UsageDetailMutation) Op() Op {
  30868. return m.op
  30869. }
  30870. // SetOp allows setting the mutation operation.
  30871. func (m *UsageDetailMutation) SetOp(op Op) {
  30872. m.op = op
  30873. }
  30874. // Type returns the node type of this mutation (UsageDetail).
  30875. func (m *UsageDetailMutation) Type() string {
  30876. return m.typ
  30877. }
  30878. // Fields returns all fields that were changed during this mutation. Note that in
  30879. // order to get all numeric fields that were incremented/decremented, call
  30880. // AddedFields().
  30881. func (m *UsageDetailMutation) Fields() []string {
  30882. fields := make([]string, 0, 15)
  30883. if m.created_at != nil {
  30884. fields = append(fields, usagedetail.FieldCreatedAt)
  30885. }
  30886. if m.updated_at != nil {
  30887. fields = append(fields, usagedetail.FieldUpdatedAt)
  30888. }
  30889. if m.status != nil {
  30890. fields = append(fields, usagedetail.FieldStatus)
  30891. }
  30892. if m._type != nil {
  30893. fields = append(fields, usagedetail.FieldType)
  30894. }
  30895. if m.bot_id != nil {
  30896. fields = append(fields, usagedetail.FieldBotID)
  30897. }
  30898. if m.receiver_id != nil {
  30899. fields = append(fields, usagedetail.FieldReceiverID)
  30900. }
  30901. if m.app != nil {
  30902. fields = append(fields, usagedetail.FieldApp)
  30903. }
  30904. if m.session_id != nil {
  30905. fields = append(fields, usagedetail.FieldSessionID)
  30906. }
  30907. if m.request != nil {
  30908. fields = append(fields, usagedetail.FieldRequest)
  30909. }
  30910. if m.response != nil {
  30911. fields = append(fields, usagedetail.FieldResponse)
  30912. }
  30913. if m.original_data != nil {
  30914. fields = append(fields, usagedetail.FieldOriginalData)
  30915. }
  30916. if m.total_tokens != nil {
  30917. fields = append(fields, usagedetail.FieldTotalTokens)
  30918. }
  30919. if m.prompt_tokens != nil {
  30920. fields = append(fields, usagedetail.FieldPromptTokens)
  30921. }
  30922. if m.completion_tokens != nil {
  30923. fields = append(fields, usagedetail.FieldCompletionTokens)
  30924. }
  30925. if m.organization_id != nil {
  30926. fields = append(fields, usagedetail.FieldOrganizationID)
  30927. }
  30928. return fields
  30929. }
  30930. // Field returns the value of a field with the given name. The second boolean
  30931. // return value indicates that this field was not set, or was not defined in the
  30932. // schema.
  30933. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  30934. switch name {
  30935. case usagedetail.FieldCreatedAt:
  30936. return m.CreatedAt()
  30937. case usagedetail.FieldUpdatedAt:
  30938. return m.UpdatedAt()
  30939. case usagedetail.FieldStatus:
  30940. return m.Status()
  30941. case usagedetail.FieldType:
  30942. return m.GetType()
  30943. case usagedetail.FieldBotID:
  30944. return m.BotID()
  30945. case usagedetail.FieldReceiverID:
  30946. return m.ReceiverID()
  30947. case usagedetail.FieldApp:
  30948. return m.App()
  30949. case usagedetail.FieldSessionID:
  30950. return m.SessionID()
  30951. case usagedetail.FieldRequest:
  30952. return m.Request()
  30953. case usagedetail.FieldResponse:
  30954. return m.Response()
  30955. case usagedetail.FieldOriginalData:
  30956. return m.OriginalData()
  30957. case usagedetail.FieldTotalTokens:
  30958. return m.TotalTokens()
  30959. case usagedetail.FieldPromptTokens:
  30960. return m.PromptTokens()
  30961. case usagedetail.FieldCompletionTokens:
  30962. return m.CompletionTokens()
  30963. case usagedetail.FieldOrganizationID:
  30964. return m.OrganizationID()
  30965. }
  30966. return nil, false
  30967. }
  30968. // OldField returns the old value of the field from the database. An error is
  30969. // returned if the mutation operation is not UpdateOne, or the query to the
  30970. // database failed.
  30971. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30972. switch name {
  30973. case usagedetail.FieldCreatedAt:
  30974. return m.OldCreatedAt(ctx)
  30975. case usagedetail.FieldUpdatedAt:
  30976. return m.OldUpdatedAt(ctx)
  30977. case usagedetail.FieldStatus:
  30978. return m.OldStatus(ctx)
  30979. case usagedetail.FieldType:
  30980. return m.OldType(ctx)
  30981. case usagedetail.FieldBotID:
  30982. return m.OldBotID(ctx)
  30983. case usagedetail.FieldReceiverID:
  30984. return m.OldReceiverID(ctx)
  30985. case usagedetail.FieldApp:
  30986. return m.OldApp(ctx)
  30987. case usagedetail.FieldSessionID:
  30988. return m.OldSessionID(ctx)
  30989. case usagedetail.FieldRequest:
  30990. return m.OldRequest(ctx)
  30991. case usagedetail.FieldResponse:
  30992. return m.OldResponse(ctx)
  30993. case usagedetail.FieldOriginalData:
  30994. return m.OldOriginalData(ctx)
  30995. case usagedetail.FieldTotalTokens:
  30996. return m.OldTotalTokens(ctx)
  30997. case usagedetail.FieldPromptTokens:
  30998. return m.OldPromptTokens(ctx)
  30999. case usagedetail.FieldCompletionTokens:
  31000. return m.OldCompletionTokens(ctx)
  31001. case usagedetail.FieldOrganizationID:
  31002. return m.OldOrganizationID(ctx)
  31003. }
  31004. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  31005. }
  31006. // SetField sets the value of a field with the given name. It returns an error if
  31007. // the field is not defined in the schema, or if the type mismatched the field
  31008. // type.
  31009. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  31010. switch name {
  31011. case usagedetail.FieldCreatedAt:
  31012. v, ok := value.(time.Time)
  31013. if !ok {
  31014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31015. }
  31016. m.SetCreatedAt(v)
  31017. return nil
  31018. case usagedetail.FieldUpdatedAt:
  31019. v, ok := value.(time.Time)
  31020. if !ok {
  31021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31022. }
  31023. m.SetUpdatedAt(v)
  31024. return nil
  31025. case usagedetail.FieldStatus:
  31026. v, ok := value.(uint8)
  31027. if !ok {
  31028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31029. }
  31030. m.SetStatus(v)
  31031. return nil
  31032. case usagedetail.FieldType:
  31033. v, ok := value.(int)
  31034. if !ok {
  31035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31036. }
  31037. m.SetType(v)
  31038. return nil
  31039. case usagedetail.FieldBotID:
  31040. v, ok := value.(string)
  31041. if !ok {
  31042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31043. }
  31044. m.SetBotID(v)
  31045. return nil
  31046. case usagedetail.FieldReceiverID:
  31047. v, ok := value.(string)
  31048. if !ok {
  31049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31050. }
  31051. m.SetReceiverID(v)
  31052. return nil
  31053. case usagedetail.FieldApp:
  31054. v, ok := value.(int)
  31055. if !ok {
  31056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31057. }
  31058. m.SetApp(v)
  31059. return nil
  31060. case usagedetail.FieldSessionID:
  31061. v, ok := value.(uint64)
  31062. if !ok {
  31063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31064. }
  31065. m.SetSessionID(v)
  31066. return nil
  31067. case usagedetail.FieldRequest:
  31068. v, ok := value.(string)
  31069. if !ok {
  31070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31071. }
  31072. m.SetRequest(v)
  31073. return nil
  31074. case usagedetail.FieldResponse:
  31075. v, ok := value.(string)
  31076. if !ok {
  31077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31078. }
  31079. m.SetResponse(v)
  31080. return nil
  31081. case usagedetail.FieldOriginalData:
  31082. v, ok := value.(custom_types.OriginalData)
  31083. if !ok {
  31084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31085. }
  31086. m.SetOriginalData(v)
  31087. return nil
  31088. case usagedetail.FieldTotalTokens:
  31089. v, ok := value.(uint64)
  31090. if !ok {
  31091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31092. }
  31093. m.SetTotalTokens(v)
  31094. return nil
  31095. case usagedetail.FieldPromptTokens:
  31096. v, ok := value.(uint64)
  31097. if !ok {
  31098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31099. }
  31100. m.SetPromptTokens(v)
  31101. return nil
  31102. case usagedetail.FieldCompletionTokens:
  31103. v, ok := value.(uint64)
  31104. if !ok {
  31105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31106. }
  31107. m.SetCompletionTokens(v)
  31108. return nil
  31109. case usagedetail.FieldOrganizationID:
  31110. v, ok := value.(uint64)
  31111. if !ok {
  31112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31113. }
  31114. m.SetOrganizationID(v)
  31115. return nil
  31116. }
  31117. return fmt.Errorf("unknown UsageDetail field %s", name)
  31118. }
  31119. // AddedFields returns all numeric fields that were incremented/decremented during
  31120. // this mutation.
  31121. func (m *UsageDetailMutation) AddedFields() []string {
  31122. var fields []string
  31123. if m.addstatus != nil {
  31124. fields = append(fields, usagedetail.FieldStatus)
  31125. }
  31126. if m.add_type != nil {
  31127. fields = append(fields, usagedetail.FieldType)
  31128. }
  31129. if m.addapp != nil {
  31130. fields = append(fields, usagedetail.FieldApp)
  31131. }
  31132. if m.addsession_id != nil {
  31133. fields = append(fields, usagedetail.FieldSessionID)
  31134. }
  31135. if m.addtotal_tokens != nil {
  31136. fields = append(fields, usagedetail.FieldTotalTokens)
  31137. }
  31138. if m.addprompt_tokens != nil {
  31139. fields = append(fields, usagedetail.FieldPromptTokens)
  31140. }
  31141. if m.addcompletion_tokens != nil {
  31142. fields = append(fields, usagedetail.FieldCompletionTokens)
  31143. }
  31144. if m.addorganization_id != nil {
  31145. fields = append(fields, usagedetail.FieldOrganizationID)
  31146. }
  31147. return fields
  31148. }
  31149. // AddedField returns the numeric value that was incremented/decremented on a field
  31150. // with the given name. The second boolean return value indicates that this field
  31151. // was not set, or was not defined in the schema.
  31152. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  31153. switch name {
  31154. case usagedetail.FieldStatus:
  31155. return m.AddedStatus()
  31156. case usagedetail.FieldType:
  31157. return m.AddedType()
  31158. case usagedetail.FieldApp:
  31159. return m.AddedApp()
  31160. case usagedetail.FieldSessionID:
  31161. return m.AddedSessionID()
  31162. case usagedetail.FieldTotalTokens:
  31163. return m.AddedTotalTokens()
  31164. case usagedetail.FieldPromptTokens:
  31165. return m.AddedPromptTokens()
  31166. case usagedetail.FieldCompletionTokens:
  31167. return m.AddedCompletionTokens()
  31168. case usagedetail.FieldOrganizationID:
  31169. return m.AddedOrganizationID()
  31170. }
  31171. return nil, false
  31172. }
  31173. // AddField adds the value to the field with the given name. It returns an error if
  31174. // the field is not defined in the schema, or if the type mismatched the field
  31175. // type.
  31176. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  31177. switch name {
  31178. case usagedetail.FieldStatus:
  31179. v, ok := value.(int8)
  31180. if !ok {
  31181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31182. }
  31183. m.AddStatus(v)
  31184. return nil
  31185. case usagedetail.FieldType:
  31186. v, ok := value.(int)
  31187. if !ok {
  31188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31189. }
  31190. m.AddType(v)
  31191. return nil
  31192. case usagedetail.FieldApp:
  31193. v, ok := value.(int)
  31194. if !ok {
  31195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31196. }
  31197. m.AddApp(v)
  31198. return nil
  31199. case usagedetail.FieldSessionID:
  31200. v, ok := value.(int64)
  31201. if !ok {
  31202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31203. }
  31204. m.AddSessionID(v)
  31205. return nil
  31206. case usagedetail.FieldTotalTokens:
  31207. v, ok := value.(int64)
  31208. if !ok {
  31209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31210. }
  31211. m.AddTotalTokens(v)
  31212. return nil
  31213. case usagedetail.FieldPromptTokens:
  31214. v, ok := value.(int64)
  31215. if !ok {
  31216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31217. }
  31218. m.AddPromptTokens(v)
  31219. return nil
  31220. case usagedetail.FieldCompletionTokens:
  31221. v, ok := value.(int64)
  31222. if !ok {
  31223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31224. }
  31225. m.AddCompletionTokens(v)
  31226. return nil
  31227. case usagedetail.FieldOrganizationID:
  31228. v, ok := value.(int64)
  31229. if !ok {
  31230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31231. }
  31232. m.AddOrganizationID(v)
  31233. return nil
  31234. }
  31235. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  31236. }
  31237. // ClearedFields returns all nullable fields that were cleared during this
  31238. // mutation.
  31239. func (m *UsageDetailMutation) ClearedFields() []string {
  31240. var fields []string
  31241. if m.FieldCleared(usagedetail.FieldStatus) {
  31242. fields = append(fields, usagedetail.FieldStatus)
  31243. }
  31244. if m.FieldCleared(usagedetail.FieldType) {
  31245. fields = append(fields, usagedetail.FieldType)
  31246. }
  31247. if m.FieldCleared(usagedetail.FieldApp) {
  31248. fields = append(fields, usagedetail.FieldApp)
  31249. }
  31250. if m.FieldCleared(usagedetail.FieldSessionID) {
  31251. fields = append(fields, usagedetail.FieldSessionID)
  31252. }
  31253. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  31254. fields = append(fields, usagedetail.FieldTotalTokens)
  31255. }
  31256. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  31257. fields = append(fields, usagedetail.FieldPromptTokens)
  31258. }
  31259. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  31260. fields = append(fields, usagedetail.FieldCompletionTokens)
  31261. }
  31262. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  31263. fields = append(fields, usagedetail.FieldOrganizationID)
  31264. }
  31265. return fields
  31266. }
  31267. // FieldCleared returns a boolean indicating if a field with the given name was
  31268. // cleared in this mutation.
  31269. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  31270. _, ok := m.clearedFields[name]
  31271. return ok
  31272. }
  31273. // ClearField clears the value of the field with the given name. It returns an
  31274. // error if the field is not defined in the schema.
  31275. func (m *UsageDetailMutation) ClearField(name string) error {
  31276. switch name {
  31277. case usagedetail.FieldStatus:
  31278. m.ClearStatus()
  31279. return nil
  31280. case usagedetail.FieldType:
  31281. m.ClearType()
  31282. return nil
  31283. case usagedetail.FieldApp:
  31284. m.ClearApp()
  31285. return nil
  31286. case usagedetail.FieldSessionID:
  31287. m.ClearSessionID()
  31288. return nil
  31289. case usagedetail.FieldTotalTokens:
  31290. m.ClearTotalTokens()
  31291. return nil
  31292. case usagedetail.FieldPromptTokens:
  31293. m.ClearPromptTokens()
  31294. return nil
  31295. case usagedetail.FieldCompletionTokens:
  31296. m.ClearCompletionTokens()
  31297. return nil
  31298. case usagedetail.FieldOrganizationID:
  31299. m.ClearOrganizationID()
  31300. return nil
  31301. }
  31302. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  31303. }
  31304. // ResetField resets all changes in the mutation for the field with the given name.
  31305. // It returns an error if the field is not defined in the schema.
  31306. func (m *UsageDetailMutation) ResetField(name string) error {
  31307. switch name {
  31308. case usagedetail.FieldCreatedAt:
  31309. m.ResetCreatedAt()
  31310. return nil
  31311. case usagedetail.FieldUpdatedAt:
  31312. m.ResetUpdatedAt()
  31313. return nil
  31314. case usagedetail.FieldStatus:
  31315. m.ResetStatus()
  31316. return nil
  31317. case usagedetail.FieldType:
  31318. m.ResetType()
  31319. return nil
  31320. case usagedetail.FieldBotID:
  31321. m.ResetBotID()
  31322. return nil
  31323. case usagedetail.FieldReceiverID:
  31324. m.ResetReceiverID()
  31325. return nil
  31326. case usagedetail.FieldApp:
  31327. m.ResetApp()
  31328. return nil
  31329. case usagedetail.FieldSessionID:
  31330. m.ResetSessionID()
  31331. return nil
  31332. case usagedetail.FieldRequest:
  31333. m.ResetRequest()
  31334. return nil
  31335. case usagedetail.FieldResponse:
  31336. m.ResetResponse()
  31337. return nil
  31338. case usagedetail.FieldOriginalData:
  31339. m.ResetOriginalData()
  31340. return nil
  31341. case usagedetail.FieldTotalTokens:
  31342. m.ResetTotalTokens()
  31343. return nil
  31344. case usagedetail.FieldPromptTokens:
  31345. m.ResetPromptTokens()
  31346. return nil
  31347. case usagedetail.FieldCompletionTokens:
  31348. m.ResetCompletionTokens()
  31349. return nil
  31350. case usagedetail.FieldOrganizationID:
  31351. m.ResetOrganizationID()
  31352. return nil
  31353. }
  31354. return fmt.Errorf("unknown UsageDetail field %s", name)
  31355. }
  31356. // AddedEdges returns all edge names that were set/added in this mutation.
  31357. func (m *UsageDetailMutation) AddedEdges() []string {
  31358. edges := make([]string, 0, 0)
  31359. return edges
  31360. }
  31361. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31362. // name in this mutation.
  31363. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  31364. return nil
  31365. }
  31366. // RemovedEdges returns all edge names that were removed in this mutation.
  31367. func (m *UsageDetailMutation) RemovedEdges() []string {
  31368. edges := make([]string, 0, 0)
  31369. return edges
  31370. }
  31371. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31372. // the given name in this mutation.
  31373. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  31374. return nil
  31375. }
  31376. // ClearedEdges returns all edge names that were cleared in this mutation.
  31377. func (m *UsageDetailMutation) ClearedEdges() []string {
  31378. edges := make([]string, 0, 0)
  31379. return edges
  31380. }
  31381. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31382. // was cleared in this mutation.
  31383. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  31384. return false
  31385. }
  31386. // ClearEdge clears the value of the edge with the given name. It returns an error
  31387. // if that edge is not defined in the schema.
  31388. func (m *UsageDetailMutation) ClearEdge(name string) error {
  31389. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  31390. }
  31391. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31392. // It returns an error if the edge is not defined in the schema.
  31393. func (m *UsageDetailMutation) ResetEdge(name string) error {
  31394. return fmt.Errorf("unknown UsageDetail edge %s", name)
  31395. }
  31396. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  31397. type UsageStatisticDayMutation struct {
  31398. config
  31399. op Op
  31400. typ string
  31401. id *uint64
  31402. created_at *time.Time
  31403. updated_at *time.Time
  31404. status *uint8
  31405. addstatus *int8
  31406. deleted_at *time.Time
  31407. addtime *uint64
  31408. addaddtime *int64
  31409. _type *int
  31410. add_type *int
  31411. bot_id *string
  31412. organization_id *uint64
  31413. addorganization_id *int64
  31414. ai_response *uint64
  31415. addai_response *int64
  31416. sop_run *uint64
  31417. addsop_run *int64
  31418. total_friend *uint64
  31419. addtotal_friend *int64
  31420. total_group *uint64
  31421. addtotal_group *int64
  31422. account_balance *uint64
  31423. addaccount_balance *int64
  31424. consume_token *uint64
  31425. addconsume_token *int64
  31426. active_user *uint64
  31427. addactive_user *int64
  31428. new_user *int64
  31429. addnew_user *int64
  31430. label_dist *[]custom_types.LabelDist
  31431. appendlabel_dist []custom_types.LabelDist
  31432. clearedFields map[string]struct{}
  31433. done bool
  31434. oldValue func(context.Context) (*UsageStatisticDay, error)
  31435. predicates []predicate.UsageStatisticDay
  31436. }
  31437. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  31438. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  31439. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  31440. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  31441. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  31442. m := &UsageStatisticDayMutation{
  31443. config: c,
  31444. op: op,
  31445. typ: TypeUsageStatisticDay,
  31446. clearedFields: make(map[string]struct{}),
  31447. }
  31448. for _, opt := range opts {
  31449. opt(m)
  31450. }
  31451. return m
  31452. }
  31453. // withUsageStatisticDayID sets the ID field of the mutation.
  31454. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  31455. return func(m *UsageStatisticDayMutation) {
  31456. var (
  31457. err error
  31458. once sync.Once
  31459. value *UsageStatisticDay
  31460. )
  31461. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  31462. once.Do(func() {
  31463. if m.done {
  31464. err = errors.New("querying old values post mutation is not allowed")
  31465. } else {
  31466. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  31467. }
  31468. })
  31469. return value, err
  31470. }
  31471. m.id = &id
  31472. }
  31473. }
  31474. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  31475. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  31476. return func(m *UsageStatisticDayMutation) {
  31477. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  31478. return node, nil
  31479. }
  31480. m.id = &node.ID
  31481. }
  31482. }
  31483. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31484. // executed in a transaction (ent.Tx), a transactional client is returned.
  31485. func (m UsageStatisticDayMutation) Client() *Client {
  31486. client := &Client{config: m.config}
  31487. client.init()
  31488. return client
  31489. }
  31490. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31491. // it returns an error otherwise.
  31492. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  31493. if _, ok := m.driver.(*txDriver); !ok {
  31494. return nil, errors.New("ent: mutation is not running in a transaction")
  31495. }
  31496. tx := &Tx{config: m.config}
  31497. tx.init()
  31498. return tx, nil
  31499. }
  31500. // SetID sets the value of the id field. Note that this
  31501. // operation is only accepted on creation of UsageStatisticDay entities.
  31502. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  31503. m.id = &id
  31504. }
  31505. // ID returns the ID value in the mutation. Note that the ID is only available
  31506. // if it was provided to the builder or after it was returned from the database.
  31507. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  31508. if m.id == nil {
  31509. return
  31510. }
  31511. return *m.id, true
  31512. }
  31513. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31514. // That means, if the mutation is applied within a transaction with an isolation level such
  31515. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31516. // or updated by the mutation.
  31517. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  31518. switch {
  31519. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31520. id, exists := m.ID()
  31521. if exists {
  31522. return []uint64{id}, nil
  31523. }
  31524. fallthrough
  31525. case m.op.Is(OpUpdate | OpDelete):
  31526. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  31527. default:
  31528. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31529. }
  31530. }
  31531. // SetCreatedAt sets the "created_at" field.
  31532. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  31533. m.created_at = &t
  31534. }
  31535. // CreatedAt returns the value of the "created_at" field in the mutation.
  31536. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  31537. v := m.created_at
  31538. if v == nil {
  31539. return
  31540. }
  31541. return *v, true
  31542. }
  31543. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  31544. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31546. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31547. if !m.op.Is(OpUpdateOne) {
  31548. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31549. }
  31550. if m.id == nil || m.oldValue == nil {
  31551. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31552. }
  31553. oldValue, err := m.oldValue(ctx)
  31554. if err != nil {
  31555. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31556. }
  31557. return oldValue.CreatedAt, nil
  31558. }
  31559. // ResetCreatedAt resets all changes to the "created_at" field.
  31560. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  31561. m.created_at = nil
  31562. }
  31563. // SetUpdatedAt sets the "updated_at" field.
  31564. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  31565. m.updated_at = &t
  31566. }
  31567. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31568. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  31569. v := m.updated_at
  31570. if v == nil {
  31571. return
  31572. }
  31573. return *v, true
  31574. }
  31575. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  31576. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31577. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31578. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31579. if !m.op.Is(OpUpdateOne) {
  31580. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31581. }
  31582. if m.id == nil || m.oldValue == nil {
  31583. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31584. }
  31585. oldValue, err := m.oldValue(ctx)
  31586. if err != nil {
  31587. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31588. }
  31589. return oldValue.UpdatedAt, nil
  31590. }
  31591. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31592. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  31593. m.updated_at = nil
  31594. }
  31595. // SetStatus sets the "status" field.
  31596. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  31597. m.status = &u
  31598. m.addstatus = nil
  31599. }
  31600. // Status returns the value of the "status" field in the mutation.
  31601. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  31602. v := m.status
  31603. if v == nil {
  31604. return
  31605. }
  31606. return *v, true
  31607. }
  31608. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  31609. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31611. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31612. if !m.op.Is(OpUpdateOne) {
  31613. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31614. }
  31615. if m.id == nil || m.oldValue == nil {
  31616. return v, errors.New("OldStatus requires an ID field in the mutation")
  31617. }
  31618. oldValue, err := m.oldValue(ctx)
  31619. if err != nil {
  31620. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31621. }
  31622. return oldValue.Status, nil
  31623. }
  31624. // AddStatus adds u to the "status" field.
  31625. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  31626. if m.addstatus != nil {
  31627. *m.addstatus += u
  31628. } else {
  31629. m.addstatus = &u
  31630. }
  31631. }
  31632. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31633. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  31634. v := m.addstatus
  31635. if v == nil {
  31636. return
  31637. }
  31638. return *v, true
  31639. }
  31640. // ClearStatus clears the value of the "status" field.
  31641. func (m *UsageStatisticDayMutation) ClearStatus() {
  31642. m.status = nil
  31643. m.addstatus = nil
  31644. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  31645. }
  31646. // StatusCleared returns if the "status" field was cleared in this mutation.
  31647. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  31648. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  31649. return ok
  31650. }
  31651. // ResetStatus resets all changes to the "status" field.
  31652. func (m *UsageStatisticDayMutation) ResetStatus() {
  31653. m.status = nil
  31654. m.addstatus = nil
  31655. delete(m.clearedFields, usagestatisticday.FieldStatus)
  31656. }
  31657. // SetDeletedAt sets the "deleted_at" field.
  31658. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  31659. m.deleted_at = &t
  31660. }
  31661. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31662. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  31663. v := m.deleted_at
  31664. if v == nil {
  31665. return
  31666. }
  31667. return *v, true
  31668. }
  31669. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  31670. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31672. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31673. if !m.op.Is(OpUpdateOne) {
  31674. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31675. }
  31676. if m.id == nil || m.oldValue == nil {
  31677. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31678. }
  31679. oldValue, err := m.oldValue(ctx)
  31680. if err != nil {
  31681. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31682. }
  31683. return oldValue.DeletedAt, nil
  31684. }
  31685. // ClearDeletedAt clears the value of the "deleted_at" field.
  31686. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  31687. m.deleted_at = nil
  31688. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  31689. }
  31690. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31691. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  31692. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  31693. return ok
  31694. }
  31695. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31696. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  31697. m.deleted_at = nil
  31698. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  31699. }
  31700. // SetAddtime sets the "addtime" field.
  31701. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  31702. m.addtime = &u
  31703. m.addaddtime = nil
  31704. }
  31705. // Addtime returns the value of the "addtime" field in the mutation.
  31706. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  31707. v := m.addtime
  31708. if v == nil {
  31709. return
  31710. }
  31711. return *v, true
  31712. }
  31713. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  31714. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31716. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31717. if !m.op.Is(OpUpdateOne) {
  31718. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31719. }
  31720. if m.id == nil || m.oldValue == nil {
  31721. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31722. }
  31723. oldValue, err := m.oldValue(ctx)
  31724. if err != nil {
  31725. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31726. }
  31727. return oldValue.Addtime, nil
  31728. }
  31729. // AddAddtime adds u to the "addtime" field.
  31730. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  31731. if m.addaddtime != nil {
  31732. *m.addaddtime += u
  31733. } else {
  31734. m.addaddtime = &u
  31735. }
  31736. }
  31737. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31738. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  31739. v := m.addaddtime
  31740. if v == nil {
  31741. return
  31742. }
  31743. return *v, true
  31744. }
  31745. // ResetAddtime resets all changes to the "addtime" field.
  31746. func (m *UsageStatisticDayMutation) ResetAddtime() {
  31747. m.addtime = nil
  31748. m.addaddtime = nil
  31749. }
  31750. // SetType sets the "type" field.
  31751. func (m *UsageStatisticDayMutation) SetType(i int) {
  31752. m._type = &i
  31753. m.add_type = nil
  31754. }
  31755. // GetType returns the value of the "type" field in the mutation.
  31756. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  31757. v := m._type
  31758. if v == nil {
  31759. return
  31760. }
  31761. return *v, true
  31762. }
  31763. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  31764. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31766. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  31767. if !m.op.Is(OpUpdateOne) {
  31768. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31769. }
  31770. if m.id == nil || m.oldValue == nil {
  31771. return v, errors.New("OldType requires an ID field in the mutation")
  31772. }
  31773. oldValue, err := m.oldValue(ctx)
  31774. if err != nil {
  31775. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31776. }
  31777. return oldValue.Type, nil
  31778. }
  31779. // AddType adds i to the "type" field.
  31780. func (m *UsageStatisticDayMutation) AddType(i int) {
  31781. if m.add_type != nil {
  31782. *m.add_type += i
  31783. } else {
  31784. m.add_type = &i
  31785. }
  31786. }
  31787. // AddedType returns the value that was added to the "type" field in this mutation.
  31788. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  31789. v := m.add_type
  31790. if v == nil {
  31791. return
  31792. }
  31793. return *v, true
  31794. }
  31795. // ResetType resets all changes to the "type" field.
  31796. func (m *UsageStatisticDayMutation) ResetType() {
  31797. m._type = nil
  31798. m.add_type = nil
  31799. }
  31800. // SetBotID sets the "bot_id" field.
  31801. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  31802. m.bot_id = &s
  31803. }
  31804. // BotID returns the value of the "bot_id" field in the mutation.
  31805. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  31806. v := m.bot_id
  31807. if v == nil {
  31808. return
  31809. }
  31810. return *v, true
  31811. }
  31812. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  31813. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31815. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  31816. if !m.op.Is(OpUpdateOne) {
  31817. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31818. }
  31819. if m.id == nil || m.oldValue == nil {
  31820. return v, errors.New("OldBotID requires an ID field in the mutation")
  31821. }
  31822. oldValue, err := m.oldValue(ctx)
  31823. if err != nil {
  31824. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31825. }
  31826. return oldValue.BotID, nil
  31827. }
  31828. // ClearBotID clears the value of the "bot_id" field.
  31829. func (m *UsageStatisticDayMutation) ClearBotID() {
  31830. m.bot_id = nil
  31831. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  31832. }
  31833. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31834. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  31835. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  31836. return ok
  31837. }
  31838. // ResetBotID resets all changes to the "bot_id" field.
  31839. func (m *UsageStatisticDayMutation) ResetBotID() {
  31840. m.bot_id = nil
  31841. delete(m.clearedFields, usagestatisticday.FieldBotID)
  31842. }
  31843. // SetOrganizationID sets the "organization_id" field.
  31844. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  31845. m.organization_id = &u
  31846. m.addorganization_id = nil
  31847. }
  31848. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31849. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  31850. v := m.organization_id
  31851. if v == nil {
  31852. return
  31853. }
  31854. return *v, true
  31855. }
  31856. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  31857. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31859. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31860. if !m.op.Is(OpUpdateOne) {
  31861. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31862. }
  31863. if m.id == nil || m.oldValue == nil {
  31864. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31865. }
  31866. oldValue, err := m.oldValue(ctx)
  31867. if err != nil {
  31868. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31869. }
  31870. return oldValue.OrganizationID, nil
  31871. }
  31872. // AddOrganizationID adds u to the "organization_id" field.
  31873. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  31874. if m.addorganization_id != nil {
  31875. *m.addorganization_id += u
  31876. } else {
  31877. m.addorganization_id = &u
  31878. }
  31879. }
  31880. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31881. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  31882. v := m.addorganization_id
  31883. if v == nil {
  31884. return
  31885. }
  31886. return *v, true
  31887. }
  31888. // ClearOrganizationID clears the value of the "organization_id" field.
  31889. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  31890. m.organization_id = nil
  31891. m.addorganization_id = nil
  31892. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  31893. }
  31894. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31895. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  31896. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  31897. return ok
  31898. }
  31899. // ResetOrganizationID resets all changes to the "organization_id" field.
  31900. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  31901. m.organization_id = nil
  31902. m.addorganization_id = nil
  31903. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  31904. }
  31905. // SetAiResponse sets the "ai_response" field.
  31906. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  31907. m.ai_response = &u
  31908. m.addai_response = nil
  31909. }
  31910. // AiResponse returns the value of the "ai_response" field in the mutation.
  31911. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  31912. v := m.ai_response
  31913. if v == nil {
  31914. return
  31915. }
  31916. return *v, true
  31917. }
  31918. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  31919. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31921. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31922. if !m.op.Is(OpUpdateOne) {
  31923. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31924. }
  31925. if m.id == nil || m.oldValue == nil {
  31926. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31927. }
  31928. oldValue, err := m.oldValue(ctx)
  31929. if err != nil {
  31930. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31931. }
  31932. return oldValue.AiResponse, nil
  31933. }
  31934. // AddAiResponse adds u to the "ai_response" field.
  31935. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  31936. if m.addai_response != nil {
  31937. *m.addai_response += u
  31938. } else {
  31939. m.addai_response = &u
  31940. }
  31941. }
  31942. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31943. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  31944. v := m.addai_response
  31945. if v == nil {
  31946. return
  31947. }
  31948. return *v, true
  31949. }
  31950. // ResetAiResponse resets all changes to the "ai_response" field.
  31951. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  31952. m.ai_response = nil
  31953. m.addai_response = nil
  31954. }
  31955. // SetSopRun sets the "sop_run" field.
  31956. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  31957. m.sop_run = &u
  31958. m.addsop_run = nil
  31959. }
  31960. // SopRun returns the value of the "sop_run" field in the mutation.
  31961. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  31962. v := m.sop_run
  31963. if v == nil {
  31964. return
  31965. }
  31966. return *v, true
  31967. }
  31968. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  31969. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  31970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31971. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31972. if !m.op.Is(OpUpdateOne) {
  31973. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31974. }
  31975. if m.id == nil || m.oldValue == nil {
  31976. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31977. }
  31978. oldValue, err := m.oldValue(ctx)
  31979. if err != nil {
  31980. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31981. }
  31982. return oldValue.SopRun, nil
  31983. }
  31984. // AddSopRun adds u to the "sop_run" field.
  31985. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  31986. if m.addsop_run != nil {
  31987. *m.addsop_run += u
  31988. } else {
  31989. m.addsop_run = &u
  31990. }
  31991. }
  31992. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31993. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  31994. v := m.addsop_run
  31995. if v == nil {
  31996. return
  31997. }
  31998. return *v, true
  31999. }
  32000. // ResetSopRun resets all changes to the "sop_run" field.
  32001. func (m *UsageStatisticDayMutation) ResetSopRun() {
  32002. m.sop_run = nil
  32003. m.addsop_run = nil
  32004. }
  32005. // SetTotalFriend sets the "total_friend" field.
  32006. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  32007. m.total_friend = &u
  32008. m.addtotal_friend = nil
  32009. }
  32010. // TotalFriend returns the value of the "total_friend" field in the mutation.
  32011. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  32012. v := m.total_friend
  32013. if v == nil {
  32014. return
  32015. }
  32016. return *v, true
  32017. }
  32018. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  32019. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32021. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  32022. if !m.op.Is(OpUpdateOne) {
  32023. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  32024. }
  32025. if m.id == nil || m.oldValue == nil {
  32026. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  32027. }
  32028. oldValue, err := m.oldValue(ctx)
  32029. if err != nil {
  32030. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  32031. }
  32032. return oldValue.TotalFriend, nil
  32033. }
  32034. // AddTotalFriend adds u to the "total_friend" field.
  32035. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  32036. if m.addtotal_friend != nil {
  32037. *m.addtotal_friend += u
  32038. } else {
  32039. m.addtotal_friend = &u
  32040. }
  32041. }
  32042. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  32043. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  32044. v := m.addtotal_friend
  32045. if v == nil {
  32046. return
  32047. }
  32048. return *v, true
  32049. }
  32050. // ResetTotalFriend resets all changes to the "total_friend" field.
  32051. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  32052. m.total_friend = nil
  32053. m.addtotal_friend = nil
  32054. }
  32055. // SetTotalGroup sets the "total_group" field.
  32056. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  32057. m.total_group = &u
  32058. m.addtotal_group = nil
  32059. }
  32060. // TotalGroup returns the value of the "total_group" field in the mutation.
  32061. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  32062. v := m.total_group
  32063. if v == nil {
  32064. return
  32065. }
  32066. return *v, true
  32067. }
  32068. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  32069. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32071. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  32072. if !m.op.Is(OpUpdateOne) {
  32073. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  32074. }
  32075. if m.id == nil || m.oldValue == nil {
  32076. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  32077. }
  32078. oldValue, err := m.oldValue(ctx)
  32079. if err != nil {
  32080. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  32081. }
  32082. return oldValue.TotalGroup, nil
  32083. }
  32084. // AddTotalGroup adds u to the "total_group" field.
  32085. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  32086. if m.addtotal_group != nil {
  32087. *m.addtotal_group += u
  32088. } else {
  32089. m.addtotal_group = &u
  32090. }
  32091. }
  32092. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  32093. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  32094. v := m.addtotal_group
  32095. if v == nil {
  32096. return
  32097. }
  32098. return *v, true
  32099. }
  32100. // ResetTotalGroup resets all changes to the "total_group" field.
  32101. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  32102. m.total_group = nil
  32103. m.addtotal_group = nil
  32104. }
  32105. // SetAccountBalance sets the "account_balance" field.
  32106. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  32107. m.account_balance = &u
  32108. m.addaccount_balance = nil
  32109. }
  32110. // AccountBalance returns the value of the "account_balance" field in the mutation.
  32111. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  32112. v := m.account_balance
  32113. if v == nil {
  32114. return
  32115. }
  32116. return *v, true
  32117. }
  32118. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  32119. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32121. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  32122. if !m.op.Is(OpUpdateOne) {
  32123. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  32124. }
  32125. if m.id == nil || m.oldValue == nil {
  32126. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  32127. }
  32128. oldValue, err := m.oldValue(ctx)
  32129. if err != nil {
  32130. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  32131. }
  32132. return oldValue.AccountBalance, nil
  32133. }
  32134. // AddAccountBalance adds u to the "account_balance" field.
  32135. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  32136. if m.addaccount_balance != nil {
  32137. *m.addaccount_balance += u
  32138. } else {
  32139. m.addaccount_balance = &u
  32140. }
  32141. }
  32142. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  32143. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  32144. v := m.addaccount_balance
  32145. if v == nil {
  32146. return
  32147. }
  32148. return *v, true
  32149. }
  32150. // ResetAccountBalance resets all changes to the "account_balance" field.
  32151. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  32152. m.account_balance = nil
  32153. m.addaccount_balance = nil
  32154. }
  32155. // SetConsumeToken sets the "consume_token" field.
  32156. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  32157. m.consume_token = &u
  32158. m.addconsume_token = nil
  32159. }
  32160. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  32161. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  32162. v := m.consume_token
  32163. if v == nil {
  32164. return
  32165. }
  32166. return *v, true
  32167. }
  32168. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  32169. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32171. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  32172. if !m.op.Is(OpUpdateOne) {
  32173. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  32174. }
  32175. if m.id == nil || m.oldValue == nil {
  32176. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  32177. }
  32178. oldValue, err := m.oldValue(ctx)
  32179. if err != nil {
  32180. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  32181. }
  32182. return oldValue.ConsumeToken, nil
  32183. }
  32184. // AddConsumeToken adds u to the "consume_token" field.
  32185. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  32186. if m.addconsume_token != nil {
  32187. *m.addconsume_token += u
  32188. } else {
  32189. m.addconsume_token = &u
  32190. }
  32191. }
  32192. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  32193. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  32194. v := m.addconsume_token
  32195. if v == nil {
  32196. return
  32197. }
  32198. return *v, true
  32199. }
  32200. // ResetConsumeToken resets all changes to the "consume_token" field.
  32201. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  32202. m.consume_token = nil
  32203. m.addconsume_token = nil
  32204. }
  32205. // SetActiveUser sets the "active_user" field.
  32206. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  32207. m.active_user = &u
  32208. m.addactive_user = nil
  32209. }
  32210. // ActiveUser returns the value of the "active_user" field in the mutation.
  32211. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  32212. v := m.active_user
  32213. if v == nil {
  32214. return
  32215. }
  32216. return *v, true
  32217. }
  32218. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  32219. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32221. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  32222. if !m.op.Is(OpUpdateOne) {
  32223. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  32224. }
  32225. if m.id == nil || m.oldValue == nil {
  32226. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  32227. }
  32228. oldValue, err := m.oldValue(ctx)
  32229. if err != nil {
  32230. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32231. }
  32232. return oldValue.ActiveUser, nil
  32233. }
  32234. // AddActiveUser adds u to the "active_user" field.
  32235. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  32236. if m.addactive_user != nil {
  32237. *m.addactive_user += u
  32238. } else {
  32239. m.addactive_user = &u
  32240. }
  32241. }
  32242. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32243. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  32244. v := m.addactive_user
  32245. if v == nil {
  32246. return
  32247. }
  32248. return *v, true
  32249. }
  32250. // ResetActiveUser resets all changes to the "active_user" field.
  32251. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  32252. m.active_user = nil
  32253. m.addactive_user = nil
  32254. }
  32255. // SetNewUser sets the "new_user" field.
  32256. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  32257. m.new_user = &i
  32258. m.addnew_user = nil
  32259. }
  32260. // NewUser returns the value of the "new_user" field in the mutation.
  32261. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  32262. v := m.new_user
  32263. if v == nil {
  32264. return
  32265. }
  32266. return *v, true
  32267. }
  32268. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  32269. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32271. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32272. if !m.op.Is(OpUpdateOne) {
  32273. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32274. }
  32275. if m.id == nil || m.oldValue == nil {
  32276. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32277. }
  32278. oldValue, err := m.oldValue(ctx)
  32279. if err != nil {
  32280. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32281. }
  32282. return oldValue.NewUser, nil
  32283. }
  32284. // AddNewUser adds i to the "new_user" field.
  32285. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  32286. if m.addnew_user != nil {
  32287. *m.addnew_user += i
  32288. } else {
  32289. m.addnew_user = &i
  32290. }
  32291. }
  32292. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32293. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  32294. v := m.addnew_user
  32295. if v == nil {
  32296. return
  32297. }
  32298. return *v, true
  32299. }
  32300. // ResetNewUser resets all changes to the "new_user" field.
  32301. func (m *UsageStatisticDayMutation) ResetNewUser() {
  32302. m.new_user = nil
  32303. m.addnew_user = nil
  32304. }
  32305. // SetLabelDist sets the "label_dist" field.
  32306. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32307. m.label_dist = &ctd
  32308. m.appendlabel_dist = nil
  32309. }
  32310. // LabelDist returns the value of the "label_dist" field in the mutation.
  32311. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32312. v := m.label_dist
  32313. if v == nil {
  32314. return
  32315. }
  32316. return *v, true
  32317. }
  32318. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  32319. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  32320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32321. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32322. if !m.op.Is(OpUpdateOne) {
  32323. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32324. }
  32325. if m.id == nil || m.oldValue == nil {
  32326. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32327. }
  32328. oldValue, err := m.oldValue(ctx)
  32329. if err != nil {
  32330. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32331. }
  32332. return oldValue.LabelDist, nil
  32333. }
  32334. // AppendLabelDist adds ctd to the "label_dist" field.
  32335. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32336. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32337. }
  32338. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32339. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32340. if len(m.appendlabel_dist) == 0 {
  32341. return nil, false
  32342. }
  32343. return m.appendlabel_dist, true
  32344. }
  32345. // ResetLabelDist resets all changes to the "label_dist" field.
  32346. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  32347. m.label_dist = nil
  32348. m.appendlabel_dist = nil
  32349. }
  32350. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  32351. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  32352. m.predicates = append(m.predicates, ps...)
  32353. }
  32354. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  32355. // users can use type-assertion to append predicates that do not depend on any generated package.
  32356. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  32357. p := make([]predicate.UsageStatisticDay, len(ps))
  32358. for i := range ps {
  32359. p[i] = ps[i]
  32360. }
  32361. m.Where(p...)
  32362. }
  32363. // Op returns the operation name.
  32364. func (m *UsageStatisticDayMutation) Op() Op {
  32365. return m.op
  32366. }
  32367. // SetOp allows setting the mutation operation.
  32368. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  32369. m.op = op
  32370. }
  32371. // Type returns the node type of this mutation (UsageStatisticDay).
  32372. func (m *UsageStatisticDayMutation) Type() string {
  32373. return m.typ
  32374. }
  32375. // Fields returns all fields that were changed during this mutation. Note that in
  32376. // order to get all numeric fields that were incremented/decremented, call
  32377. // AddedFields().
  32378. func (m *UsageStatisticDayMutation) Fields() []string {
  32379. fields := make([]string, 0, 17)
  32380. if m.created_at != nil {
  32381. fields = append(fields, usagestatisticday.FieldCreatedAt)
  32382. }
  32383. if m.updated_at != nil {
  32384. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  32385. }
  32386. if m.status != nil {
  32387. fields = append(fields, usagestatisticday.FieldStatus)
  32388. }
  32389. if m.deleted_at != nil {
  32390. fields = append(fields, usagestatisticday.FieldDeletedAt)
  32391. }
  32392. if m.addtime != nil {
  32393. fields = append(fields, usagestatisticday.FieldAddtime)
  32394. }
  32395. if m._type != nil {
  32396. fields = append(fields, usagestatisticday.FieldType)
  32397. }
  32398. if m.bot_id != nil {
  32399. fields = append(fields, usagestatisticday.FieldBotID)
  32400. }
  32401. if m.organization_id != nil {
  32402. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32403. }
  32404. if m.ai_response != nil {
  32405. fields = append(fields, usagestatisticday.FieldAiResponse)
  32406. }
  32407. if m.sop_run != nil {
  32408. fields = append(fields, usagestatisticday.FieldSopRun)
  32409. }
  32410. if m.total_friend != nil {
  32411. fields = append(fields, usagestatisticday.FieldTotalFriend)
  32412. }
  32413. if m.total_group != nil {
  32414. fields = append(fields, usagestatisticday.FieldTotalGroup)
  32415. }
  32416. if m.account_balance != nil {
  32417. fields = append(fields, usagestatisticday.FieldAccountBalance)
  32418. }
  32419. if m.consume_token != nil {
  32420. fields = append(fields, usagestatisticday.FieldConsumeToken)
  32421. }
  32422. if m.active_user != nil {
  32423. fields = append(fields, usagestatisticday.FieldActiveUser)
  32424. }
  32425. if m.new_user != nil {
  32426. fields = append(fields, usagestatisticday.FieldNewUser)
  32427. }
  32428. if m.label_dist != nil {
  32429. fields = append(fields, usagestatisticday.FieldLabelDist)
  32430. }
  32431. return fields
  32432. }
  32433. // Field returns the value of a field with the given name. The second boolean
  32434. // return value indicates that this field was not set, or was not defined in the
  32435. // schema.
  32436. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  32437. switch name {
  32438. case usagestatisticday.FieldCreatedAt:
  32439. return m.CreatedAt()
  32440. case usagestatisticday.FieldUpdatedAt:
  32441. return m.UpdatedAt()
  32442. case usagestatisticday.FieldStatus:
  32443. return m.Status()
  32444. case usagestatisticday.FieldDeletedAt:
  32445. return m.DeletedAt()
  32446. case usagestatisticday.FieldAddtime:
  32447. return m.Addtime()
  32448. case usagestatisticday.FieldType:
  32449. return m.GetType()
  32450. case usagestatisticday.FieldBotID:
  32451. return m.BotID()
  32452. case usagestatisticday.FieldOrganizationID:
  32453. return m.OrganizationID()
  32454. case usagestatisticday.FieldAiResponse:
  32455. return m.AiResponse()
  32456. case usagestatisticday.FieldSopRun:
  32457. return m.SopRun()
  32458. case usagestatisticday.FieldTotalFriend:
  32459. return m.TotalFriend()
  32460. case usagestatisticday.FieldTotalGroup:
  32461. return m.TotalGroup()
  32462. case usagestatisticday.FieldAccountBalance:
  32463. return m.AccountBalance()
  32464. case usagestatisticday.FieldConsumeToken:
  32465. return m.ConsumeToken()
  32466. case usagestatisticday.FieldActiveUser:
  32467. return m.ActiveUser()
  32468. case usagestatisticday.FieldNewUser:
  32469. return m.NewUser()
  32470. case usagestatisticday.FieldLabelDist:
  32471. return m.LabelDist()
  32472. }
  32473. return nil, false
  32474. }
  32475. // OldField returns the old value of the field from the database. An error is
  32476. // returned if the mutation operation is not UpdateOne, or the query to the
  32477. // database failed.
  32478. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32479. switch name {
  32480. case usagestatisticday.FieldCreatedAt:
  32481. return m.OldCreatedAt(ctx)
  32482. case usagestatisticday.FieldUpdatedAt:
  32483. return m.OldUpdatedAt(ctx)
  32484. case usagestatisticday.FieldStatus:
  32485. return m.OldStatus(ctx)
  32486. case usagestatisticday.FieldDeletedAt:
  32487. return m.OldDeletedAt(ctx)
  32488. case usagestatisticday.FieldAddtime:
  32489. return m.OldAddtime(ctx)
  32490. case usagestatisticday.FieldType:
  32491. return m.OldType(ctx)
  32492. case usagestatisticday.FieldBotID:
  32493. return m.OldBotID(ctx)
  32494. case usagestatisticday.FieldOrganizationID:
  32495. return m.OldOrganizationID(ctx)
  32496. case usagestatisticday.FieldAiResponse:
  32497. return m.OldAiResponse(ctx)
  32498. case usagestatisticday.FieldSopRun:
  32499. return m.OldSopRun(ctx)
  32500. case usagestatisticday.FieldTotalFriend:
  32501. return m.OldTotalFriend(ctx)
  32502. case usagestatisticday.FieldTotalGroup:
  32503. return m.OldTotalGroup(ctx)
  32504. case usagestatisticday.FieldAccountBalance:
  32505. return m.OldAccountBalance(ctx)
  32506. case usagestatisticday.FieldConsumeToken:
  32507. return m.OldConsumeToken(ctx)
  32508. case usagestatisticday.FieldActiveUser:
  32509. return m.OldActiveUser(ctx)
  32510. case usagestatisticday.FieldNewUser:
  32511. return m.OldNewUser(ctx)
  32512. case usagestatisticday.FieldLabelDist:
  32513. return m.OldLabelDist(ctx)
  32514. }
  32515. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32516. }
  32517. // SetField sets the value of a field with the given name. It returns an error if
  32518. // the field is not defined in the schema, or if the type mismatched the field
  32519. // type.
  32520. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  32521. switch name {
  32522. case usagestatisticday.FieldCreatedAt:
  32523. v, ok := value.(time.Time)
  32524. if !ok {
  32525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32526. }
  32527. m.SetCreatedAt(v)
  32528. return nil
  32529. case usagestatisticday.FieldUpdatedAt:
  32530. v, ok := value.(time.Time)
  32531. if !ok {
  32532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32533. }
  32534. m.SetUpdatedAt(v)
  32535. return nil
  32536. case usagestatisticday.FieldStatus:
  32537. v, ok := value.(uint8)
  32538. if !ok {
  32539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32540. }
  32541. m.SetStatus(v)
  32542. return nil
  32543. case usagestatisticday.FieldDeletedAt:
  32544. v, ok := value.(time.Time)
  32545. if !ok {
  32546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32547. }
  32548. m.SetDeletedAt(v)
  32549. return nil
  32550. case usagestatisticday.FieldAddtime:
  32551. v, ok := value.(uint64)
  32552. if !ok {
  32553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32554. }
  32555. m.SetAddtime(v)
  32556. return nil
  32557. case usagestatisticday.FieldType:
  32558. v, ok := value.(int)
  32559. if !ok {
  32560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32561. }
  32562. m.SetType(v)
  32563. return nil
  32564. case usagestatisticday.FieldBotID:
  32565. v, ok := value.(string)
  32566. if !ok {
  32567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32568. }
  32569. m.SetBotID(v)
  32570. return nil
  32571. case usagestatisticday.FieldOrganizationID:
  32572. v, ok := value.(uint64)
  32573. if !ok {
  32574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32575. }
  32576. m.SetOrganizationID(v)
  32577. return nil
  32578. case usagestatisticday.FieldAiResponse:
  32579. v, ok := value.(uint64)
  32580. if !ok {
  32581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32582. }
  32583. m.SetAiResponse(v)
  32584. return nil
  32585. case usagestatisticday.FieldSopRun:
  32586. v, ok := value.(uint64)
  32587. if !ok {
  32588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32589. }
  32590. m.SetSopRun(v)
  32591. return nil
  32592. case usagestatisticday.FieldTotalFriend:
  32593. v, ok := value.(uint64)
  32594. if !ok {
  32595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32596. }
  32597. m.SetTotalFriend(v)
  32598. return nil
  32599. case usagestatisticday.FieldTotalGroup:
  32600. v, ok := value.(uint64)
  32601. if !ok {
  32602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32603. }
  32604. m.SetTotalGroup(v)
  32605. return nil
  32606. case usagestatisticday.FieldAccountBalance:
  32607. v, ok := value.(uint64)
  32608. if !ok {
  32609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32610. }
  32611. m.SetAccountBalance(v)
  32612. return nil
  32613. case usagestatisticday.FieldConsumeToken:
  32614. v, ok := value.(uint64)
  32615. if !ok {
  32616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32617. }
  32618. m.SetConsumeToken(v)
  32619. return nil
  32620. case usagestatisticday.FieldActiveUser:
  32621. v, ok := value.(uint64)
  32622. if !ok {
  32623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32624. }
  32625. m.SetActiveUser(v)
  32626. return nil
  32627. case usagestatisticday.FieldNewUser:
  32628. v, ok := value.(int64)
  32629. if !ok {
  32630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32631. }
  32632. m.SetNewUser(v)
  32633. return nil
  32634. case usagestatisticday.FieldLabelDist:
  32635. v, ok := value.([]custom_types.LabelDist)
  32636. if !ok {
  32637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32638. }
  32639. m.SetLabelDist(v)
  32640. return nil
  32641. }
  32642. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32643. }
  32644. // AddedFields returns all numeric fields that were incremented/decremented during
  32645. // this mutation.
  32646. func (m *UsageStatisticDayMutation) AddedFields() []string {
  32647. var fields []string
  32648. if m.addstatus != nil {
  32649. fields = append(fields, usagestatisticday.FieldStatus)
  32650. }
  32651. if m.addaddtime != nil {
  32652. fields = append(fields, usagestatisticday.FieldAddtime)
  32653. }
  32654. if m.add_type != nil {
  32655. fields = append(fields, usagestatisticday.FieldType)
  32656. }
  32657. if m.addorganization_id != nil {
  32658. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32659. }
  32660. if m.addai_response != nil {
  32661. fields = append(fields, usagestatisticday.FieldAiResponse)
  32662. }
  32663. if m.addsop_run != nil {
  32664. fields = append(fields, usagestatisticday.FieldSopRun)
  32665. }
  32666. if m.addtotal_friend != nil {
  32667. fields = append(fields, usagestatisticday.FieldTotalFriend)
  32668. }
  32669. if m.addtotal_group != nil {
  32670. fields = append(fields, usagestatisticday.FieldTotalGroup)
  32671. }
  32672. if m.addaccount_balance != nil {
  32673. fields = append(fields, usagestatisticday.FieldAccountBalance)
  32674. }
  32675. if m.addconsume_token != nil {
  32676. fields = append(fields, usagestatisticday.FieldConsumeToken)
  32677. }
  32678. if m.addactive_user != nil {
  32679. fields = append(fields, usagestatisticday.FieldActiveUser)
  32680. }
  32681. if m.addnew_user != nil {
  32682. fields = append(fields, usagestatisticday.FieldNewUser)
  32683. }
  32684. return fields
  32685. }
  32686. // AddedField returns the numeric value that was incremented/decremented on a field
  32687. // with the given name. The second boolean return value indicates that this field
  32688. // was not set, or was not defined in the schema.
  32689. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  32690. switch name {
  32691. case usagestatisticday.FieldStatus:
  32692. return m.AddedStatus()
  32693. case usagestatisticday.FieldAddtime:
  32694. return m.AddedAddtime()
  32695. case usagestatisticday.FieldType:
  32696. return m.AddedType()
  32697. case usagestatisticday.FieldOrganizationID:
  32698. return m.AddedOrganizationID()
  32699. case usagestatisticday.FieldAiResponse:
  32700. return m.AddedAiResponse()
  32701. case usagestatisticday.FieldSopRun:
  32702. return m.AddedSopRun()
  32703. case usagestatisticday.FieldTotalFriend:
  32704. return m.AddedTotalFriend()
  32705. case usagestatisticday.FieldTotalGroup:
  32706. return m.AddedTotalGroup()
  32707. case usagestatisticday.FieldAccountBalance:
  32708. return m.AddedAccountBalance()
  32709. case usagestatisticday.FieldConsumeToken:
  32710. return m.AddedConsumeToken()
  32711. case usagestatisticday.FieldActiveUser:
  32712. return m.AddedActiveUser()
  32713. case usagestatisticday.FieldNewUser:
  32714. return m.AddedNewUser()
  32715. }
  32716. return nil, false
  32717. }
  32718. // AddField adds the value to the field with the given name. It returns an error if
  32719. // the field is not defined in the schema, or if the type mismatched the field
  32720. // type.
  32721. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  32722. switch name {
  32723. case usagestatisticday.FieldStatus:
  32724. v, ok := value.(int8)
  32725. if !ok {
  32726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32727. }
  32728. m.AddStatus(v)
  32729. return nil
  32730. case usagestatisticday.FieldAddtime:
  32731. v, ok := value.(int64)
  32732. if !ok {
  32733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32734. }
  32735. m.AddAddtime(v)
  32736. return nil
  32737. case usagestatisticday.FieldType:
  32738. v, ok := value.(int)
  32739. if !ok {
  32740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32741. }
  32742. m.AddType(v)
  32743. return nil
  32744. case usagestatisticday.FieldOrganizationID:
  32745. v, ok := value.(int64)
  32746. if !ok {
  32747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32748. }
  32749. m.AddOrganizationID(v)
  32750. return nil
  32751. case usagestatisticday.FieldAiResponse:
  32752. v, ok := value.(int64)
  32753. if !ok {
  32754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32755. }
  32756. m.AddAiResponse(v)
  32757. return nil
  32758. case usagestatisticday.FieldSopRun:
  32759. v, ok := value.(int64)
  32760. if !ok {
  32761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32762. }
  32763. m.AddSopRun(v)
  32764. return nil
  32765. case usagestatisticday.FieldTotalFriend:
  32766. v, ok := value.(int64)
  32767. if !ok {
  32768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32769. }
  32770. m.AddTotalFriend(v)
  32771. return nil
  32772. case usagestatisticday.FieldTotalGroup:
  32773. v, ok := value.(int64)
  32774. if !ok {
  32775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32776. }
  32777. m.AddTotalGroup(v)
  32778. return nil
  32779. case usagestatisticday.FieldAccountBalance:
  32780. v, ok := value.(int64)
  32781. if !ok {
  32782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32783. }
  32784. m.AddAccountBalance(v)
  32785. return nil
  32786. case usagestatisticday.FieldConsumeToken:
  32787. v, ok := value.(int64)
  32788. if !ok {
  32789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32790. }
  32791. m.AddConsumeToken(v)
  32792. return nil
  32793. case usagestatisticday.FieldActiveUser:
  32794. v, ok := value.(int64)
  32795. if !ok {
  32796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32797. }
  32798. m.AddActiveUser(v)
  32799. return nil
  32800. case usagestatisticday.FieldNewUser:
  32801. v, ok := value.(int64)
  32802. if !ok {
  32803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32804. }
  32805. m.AddNewUser(v)
  32806. return nil
  32807. }
  32808. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  32809. }
  32810. // ClearedFields returns all nullable fields that were cleared during this
  32811. // mutation.
  32812. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  32813. var fields []string
  32814. if m.FieldCleared(usagestatisticday.FieldStatus) {
  32815. fields = append(fields, usagestatisticday.FieldStatus)
  32816. }
  32817. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  32818. fields = append(fields, usagestatisticday.FieldDeletedAt)
  32819. }
  32820. if m.FieldCleared(usagestatisticday.FieldBotID) {
  32821. fields = append(fields, usagestatisticday.FieldBotID)
  32822. }
  32823. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  32824. fields = append(fields, usagestatisticday.FieldOrganizationID)
  32825. }
  32826. return fields
  32827. }
  32828. // FieldCleared returns a boolean indicating if a field with the given name was
  32829. // cleared in this mutation.
  32830. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  32831. _, ok := m.clearedFields[name]
  32832. return ok
  32833. }
  32834. // ClearField clears the value of the field with the given name. It returns an
  32835. // error if the field is not defined in the schema.
  32836. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  32837. switch name {
  32838. case usagestatisticday.FieldStatus:
  32839. m.ClearStatus()
  32840. return nil
  32841. case usagestatisticday.FieldDeletedAt:
  32842. m.ClearDeletedAt()
  32843. return nil
  32844. case usagestatisticday.FieldBotID:
  32845. m.ClearBotID()
  32846. return nil
  32847. case usagestatisticday.FieldOrganizationID:
  32848. m.ClearOrganizationID()
  32849. return nil
  32850. }
  32851. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  32852. }
  32853. // ResetField resets all changes in the mutation for the field with the given name.
  32854. // It returns an error if the field is not defined in the schema.
  32855. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  32856. switch name {
  32857. case usagestatisticday.FieldCreatedAt:
  32858. m.ResetCreatedAt()
  32859. return nil
  32860. case usagestatisticday.FieldUpdatedAt:
  32861. m.ResetUpdatedAt()
  32862. return nil
  32863. case usagestatisticday.FieldStatus:
  32864. m.ResetStatus()
  32865. return nil
  32866. case usagestatisticday.FieldDeletedAt:
  32867. m.ResetDeletedAt()
  32868. return nil
  32869. case usagestatisticday.FieldAddtime:
  32870. m.ResetAddtime()
  32871. return nil
  32872. case usagestatisticday.FieldType:
  32873. m.ResetType()
  32874. return nil
  32875. case usagestatisticday.FieldBotID:
  32876. m.ResetBotID()
  32877. return nil
  32878. case usagestatisticday.FieldOrganizationID:
  32879. m.ResetOrganizationID()
  32880. return nil
  32881. case usagestatisticday.FieldAiResponse:
  32882. m.ResetAiResponse()
  32883. return nil
  32884. case usagestatisticday.FieldSopRun:
  32885. m.ResetSopRun()
  32886. return nil
  32887. case usagestatisticday.FieldTotalFriend:
  32888. m.ResetTotalFriend()
  32889. return nil
  32890. case usagestatisticday.FieldTotalGroup:
  32891. m.ResetTotalGroup()
  32892. return nil
  32893. case usagestatisticday.FieldAccountBalance:
  32894. m.ResetAccountBalance()
  32895. return nil
  32896. case usagestatisticday.FieldConsumeToken:
  32897. m.ResetConsumeToken()
  32898. return nil
  32899. case usagestatisticday.FieldActiveUser:
  32900. m.ResetActiveUser()
  32901. return nil
  32902. case usagestatisticday.FieldNewUser:
  32903. m.ResetNewUser()
  32904. return nil
  32905. case usagestatisticday.FieldLabelDist:
  32906. m.ResetLabelDist()
  32907. return nil
  32908. }
  32909. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  32910. }
  32911. // AddedEdges returns all edge names that were set/added in this mutation.
  32912. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  32913. edges := make([]string, 0, 0)
  32914. return edges
  32915. }
  32916. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32917. // name in this mutation.
  32918. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  32919. return nil
  32920. }
  32921. // RemovedEdges returns all edge names that were removed in this mutation.
  32922. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  32923. edges := make([]string, 0, 0)
  32924. return edges
  32925. }
  32926. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32927. // the given name in this mutation.
  32928. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  32929. return nil
  32930. }
  32931. // ClearedEdges returns all edge names that were cleared in this mutation.
  32932. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  32933. edges := make([]string, 0, 0)
  32934. return edges
  32935. }
  32936. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32937. // was cleared in this mutation.
  32938. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  32939. return false
  32940. }
  32941. // ClearEdge clears the value of the edge with the given name. It returns an error
  32942. // if that edge is not defined in the schema.
  32943. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  32944. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  32945. }
  32946. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32947. // It returns an error if the edge is not defined in the schema.
  32948. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  32949. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  32950. }
  32951. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  32952. type UsageStatisticHourMutation struct {
  32953. config
  32954. op Op
  32955. typ string
  32956. id *uint64
  32957. created_at *time.Time
  32958. updated_at *time.Time
  32959. status *uint8
  32960. addstatus *int8
  32961. deleted_at *time.Time
  32962. addtime *uint64
  32963. addaddtime *int64
  32964. _type *int
  32965. add_type *int
  32966. bot_id *string
  32967. organization_id *uint64
  32968. addorganization_id *int64
  32969. ai_response *uint64
  32970. addai_response *int64
  32971. sop_run *uint64
  32972. addsop_run *int64
  32973. total_friend *uint64
  32974. addtotal_friend *int64
  32975. total_group *uint64
  32976. addtotal_group *int64
  32977. account_balance *uint64
  32978. addaccount_balance *int64
  32979. consume_token *uint64
  32980. addconsume_token *int64
  32981. active_user *uint64
  32982. addactive_user *int64
  32983. new_user *int64
  32984. addnew_user *int64
  32985. label_dist *[]custom_types.LabelDist
  32986. appendlabel_dist []custom_types.LabelDist
  32987. clearedFields map[string]struct{}
  32988. done bool
  32989. oldValue func(context.Context) (*UsageStatisticHour, error)
  32990. predicates []predicate.UsageStatisticHour
  32991. }
  32992. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  32993. // usagestatistichourOption allows management of the mutation configuration using functional options.
  32994. type usagestatistichourOption func(*UsageStatisticHourMutation)
  32995. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  32996. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  32997. m := &UsageStatisticHourMutation{
  32998. config: c,
  32999. op: op,
  33000. typ: TypeUsageStatisticHour,
  33001. clearedFields: make(map[string]struct{}),
  33002. }
  33003. for _, opt := range opts {
  33004. opt(m)
  33005. }
  33006. return m
  33007. }
  33008. // withUsageStatisticHourID sets the ID field of the mutation.
  33009. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  33010. return func(m *UsageStatisticHourMutation) {
  33011. var (
  33012. err error
  33013. once sync.Once
  33014. value *UsageStatisticHour
  33015. )
  33016. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  33017. once.Do(func() {
  33018. if m.done {
  33019. err = errors.New("querying old values post mutation is not allowed")
  33020. } else {
  33021. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  33022. }
  33023. })
  33024. return value, err
  33025. }
  33026. m.id = &id
  33027. }
  33028. }
  33029. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  33030. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  33031. return func(m *UsageStatisticHourMutation) {
  33032. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  33033. return node, nil
  33034. }
  33035. m.id = &node.ID
  33036. }
  33037. }
  33038. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33039. // executed in a transaction (ent.Tx), a transactional client is returned.
  33040. func (m UsageStatisticHourMutation) Client() *Client {
  33041. client := &Client{config: m.config}
  33042. client.init()
  33043. return client
  33044. }
  33045. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33046. // it returns an error otherwise.
  33047. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  33048. if _, ok := m.driver.(*txDriver); !ok {
  33049. return nil, errors.New("ent: mutation is not running in a transaction")
  33050. }
  33051. tx := &Tx{config: m.config}
  33052. tx.init()
  33053. return tx, nil
  33054. }
  33055. // SetID sets the value of the id field. Note that this
  33056. // operation is only accepted on creation of UsageStatisticHour entities.
  33057. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  33058. m.id = &id
  33059. }
  33060. // ID returns the ID value in the mutation. Note that the ID is only available
  33061. // if it was provided to the builder or after it was returned from the database.
  33062. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  33063. if m.id == nil {
  33064. return
  33065. }
  33066. return *m.id, true
  33067. }
  33068. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33069. // That means, if the mutation is applied within a transaction with an isolation level such
  33070. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33071. // or updated by the mutation.
  33072. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  33073. switch {
  33074. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33075. id, exists := m.ID()
  33076. if exists {
  33077. return []uint64{id}, nil
  33078. }
  33079. fallthrough
  33080. case m.op.Is(OpUpdate | OpDelete):
  33081. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  33082. default:
  33083. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33084. }
  33085. }
  33086. // SetCreatedAt sets the "created_at" field.
  33087. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  33088. m.created_at = &t
  33089. }
  33090. // CreatedAt returns the value of the "created_at" field in the mutation.
  33091. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  33092. v := m.created_at
  33093. if v == nil {
  33094. return
  33095. }
  33096. return *v, true
  33097. }
  33098. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  33099. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33101. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33102. if !m.op.Is(OpUpdateOne) {
  33103. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33104. }
  33105. if m.id == nil || m.oldValue == nil {
  33106. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33107. }
  33108. oldValue, err := m.oldValue(ctx)
  33109. if err != nil {
  33110. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33111. }
  33112. return oldValue.CreatedAt, nil
  33113. }
  33114. // ResetCreatedAt resets all changes to the "created_at" field.
  33115. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  33116. m.created_at = nil
  33117. }
  33118. // SetUpdatedAt sets the "updated_at" field.
  33119. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  33120. m.updated_at = &t
  33121. }
  33122. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33123. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  33124. v := m.updated_at
  33125. if v == nil {
  33126. return
  33127. }
  33128. return *v, true
  33129. }
  33130. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  33131. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33133. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33134. if !m.op.Is(OpUpdateOne) {
  33135. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33136. }
  33137. if m.id == nil || m.oldValue == nil {
  33138. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33139. }
  33140. oldValue, err := m.oldValue(ctx)
  33141. if err != nil {
  33142. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33143. }
  33144. return oldValue.UpdatedAt, nil
  33145. }
  33146. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33147. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  33148. m.updated_at = nil
  33149. }
  33150. // SetStatus sets the "status" field.
  33151. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  33152. m.status = &u
  33153. m.addstatus = nil
  33154. }
  33155. // Status returns the value of the "status" field in the mutation.
  33156. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  33157. v := m.status
  33158. if v == nil {
  33159. return
  33160. }
  33161. return *v, true
  33162. }
  33163. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  33164. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33166. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33167. if !m.op.Is(OpUpdateOne) {
  33168. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33169. }
  33170. if m.id == nil || m.oldValue == nil {
  33171. return v, errors.New("OldStatus requires an ID field in the mutation")
  33172. }
  33173. oldValue, err := m.oldValue(ctx)
  33174. if err != nil {
  33175. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33176. }
  33177. return oldValue.Status, nil
  33178. }
  33179. // AddStatus adds u to the "status" field.
  33180. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  33181. if m.addstatus != nil {
  33182. *m.addstatus += u
  33183. } else {
  33184. m.addstatus = &u
  33185. }
  33186. }
  33187. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33188. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  33189. v := m.addstatus
  33190. if v == nil {
  33191. return
  33192. }
  33193. return *v, true
  33194. }
  33195. // ClearStatus clears the value of the "status" field.
  33196. func (m *UsageStatisticHourMutation) ClearStatus() {
  33197. m.status = nil
  33198. m.addstatus = nil
  33199. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  33200. }
  33201. // StatusCleared returns if the "status" field was cleared in this mutation.
  33202. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  33203. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  33204. return ok
  33205. }
  33206. // ResetStatus resets all changes to the "status" field.
  33207. func (m *UsageStatisticHourMutation) ResetStatus() {
  33208. m.status = nil
  33209. m.addstatus = nil
  33210. delete(m.clearedFields, usagestatistichour.FieldStatus)
  33211. }
  33212. // SetDeletedAt sets the "deleted_at" field.
  33213. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  33214. m.deleted_at = &t
  33215. }
  33216. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33217. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  33218. v := m.deleted_at
  33219. if v == nil {
  33220. return
  33221. }
  33222. return *v, true
  33223. }
  33224. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  33225. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33227. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33228. if !m.op.Is(OpUpdateOne) {
  33229. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33230. }
  33231. if m.id == nil || m.oldValue == nil {
  33232. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33233. }
  33234. oldValue, err := m.oldValue(ctx)
  33235. if err != nil {
  33236. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33237. }
  33238. return oldValue.DeletedAt, nil
  33239. }
  33240. // ClearDeletedAt clears the value of the "deleted_at" field.
  33241. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  33242. m.deleted_at = nil
  33243. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  33244. }
  33245. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33246. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  33247. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  33248. return ok
  33249. }
  33250. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33251. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  33252. m.deleted_at = nil
  33253. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  33254. }
  33255. // SetAddtime sets the "addtime" field.
  33256. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  33257. m.addtime = &u
  33258. m.addaddtime = nil
  33259. }
  33260. // Addtime returns the value of the "addtime" field in the mutation.
  33261. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  33262. v := m.addtime
  33263. if v == nil {
  33264. return
  33265. }
  33266. return *v, true
  33267. }
  33268. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  33269. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33271. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  33272. if !m.op.Is(OpUpdateOne) {
  33273. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  33274. }
  33275. if m.id == nil || m.oldValue == nil {
  33276. return v, errors.New("OldAddtime requires an ID field in the mutation")
  33277. }
  33278. oldValue, err := m.oldValue(ctx)
  33279. if err != nil {
  33280. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  33281. }
  33282. return oldValue.Addtime, nil
  33283. }
  33284. // AddAddtime adds u to the "addtime" field.
  33285. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  33286. if m.addaddtime != nil {
  33287. *m.addaddtime += u
  33288. } else {
  33289. m.addaddtime = &u
  33290. }
  33291. }
  33292. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  33293. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  33294. v := m.addaddtime
  33295. if v == nil {
  33296. return
  33297. }
  33298. return *v, true
  33299. }
  33300. // ResetAddtime resets all changes to the "addtime" field.
  33301. func (m *UsageStatisticHourMutation) ResetAddtime() {
  33302. m.addtime = nil
  33303. m.addaddtime = nil
  33304. }
  33305. // SetType sets the "type" field.
  33306. func (m *UsageStatisticHourMutation) SetType(i int) {
  33307. m._type = &i
  33308. m.add_type = nil
  33309. }
  33310. // GetType returns the value of the "type" field in the mutation.
  33311. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  33312. v := m._type
  33313. if v == nil {
  33314. return
  33315. }
  33316. return *v, true
  33317. }
  33318. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  33319. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33321. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  33322. if !m.op.Is(OpUpdateOne) {
  33323. return v, errors.New("OldType is only allowed on UpdateOne operations")
  33324. }
  33325. if m.id == nil || m.oldValue == nil {
  33326. return v, errors.New("OldType requires an ID field in the mutation")
  33327. }
  33328. oldValue, err := m.oldValue(ctx)
  33329. if err != nil {
  33330. return v, fmt.Errorf("querying old value for OldType: %w", err)
  33331. }
  33332. return oldValue.Type, nil
  33333. }
  33334. // AddType adds i to the "type" field.
  33335. func (m *UsageStatisticHourMutation) AddType(i int) {
  33336. if m.add_type != nil {
  33337. *m.add_type += i
  33338. } else {
  33339. m.add_type = &i
  33340. }
  33341. }
  33342. // AddedType returns the value that was added to the "type" field in this mutation.
  33343. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  33344. v := m.add_type
  33345. if v == nil {
  33346. return
  33347. }
  33348. return *v, true
  33349. }
  33350. // ResetType resets all changes to the "type" field.
  33351. func (m *UsageStatisticHourMutation) ResetType() {
  33352. m._type = nil
  33353. m.add_type = nil
  33354. }
  33355. // SetBotID sets the "bot_id" field.
  33356. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  33357. m.bot_id = &s
  33358. }
  33359. // BotID returns the value of the "bot_id" field in the mutation.
  33360. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  33361. v := m.bot_id
  33362. if v == nil {
  33363. return
  33364. }
  33365. return *v, true
  33366. }
  33367. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  33368. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33370. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  33371. if !m.op.Is(OpUpdateOne) {
  33372. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33373. }
  33374. if m.id == nil || m.oldValue == nil {
  33375. return v, errors.New("OldBotID requires an ID field in the mutation")
  33376. }
  33377. oldValue, err := m.oldValue(ctx)
  33378. if err != nil {
  33379. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33380. }
  33381. return oldValue.BotID, nil
  33382. }
  33383. // ClearBotID clears the value of the "bot_id" field.
  33384. func (m *UsageStatisticHourMutation) ClearBotID() {
  33385. m.bot_id = nil
  33386. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  33387. }
  33388. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  33389. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  33390. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  33391. return ok
  33392. }
  33393. // ResetBotID resets all changes to the "bot_id" field.
  33394. func (m *UsageStatisticHourMutation) ResetBotID() {
  33395. m.bot_id = nil
  33396. delete(m.clearedFields, usagestatistichour.FieldBotID)
  33397. }
  33398. // SetOrganizationID sets the "organization_id" field.
  33399. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  33400. m.organization_id = &u
  33401. m.addorganization_id = nil
  33402. }
  33403. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33404. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  33405. v := m.organization_id
  33406. if v == nil {
  33407. return
  33408. }
  33409. return *v, true
  33410. }
  33411. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  33412. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33414. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33415. if !m.op.Is(OpUpdateOne) {
  33416. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33417. }
  33418. if m.id == nil || m.oldValue == nil {
  33419. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33420. }
  33421. oldValue, err := m.oldValue(ctx)
  33422. if err != nil {
  33423. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33424. }
  33425. return oldValue.OrganizationID, nil
  33426. }
  33427. // AddOrganizationID adds u to the "organization_id" field.
  33428. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  33429. if m.addorganization_id != nil {
  33430. *m.addorganization_id += u
  33431. } else {
  33432. m.addorganization_id = &u
  33433. }
  33434. }
  33435. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33436. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  33437. v := m.addorganization_id
  33438. if v == nil {
  33439. return
  33440. }
  33441. return *v, true
  33442. }
  33443. // ClearOrganizationID clears the value of the "organization_id" field.
  33444. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  33445. m.organization_id = nil
  33446. m.addorganization_id = nil
  33447. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  33448. }
  33449. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33450. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  33451. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  33452. return ok
  33453. }
  33454. // ResetOrganizationID resets all changes to the "organization_id" field.
  33455. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  33456. m.organization_id = nil
  33457. m.addorganization_id = nil
  33458. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  33459. }
  33460. // SetAiResponse sets the "ai_response" field.
  33461. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  33462. m.ai_response = &u
  33463. m.addai_response = nil
  33464. }
  33465. // AiResponse returns the value of the "ai_response" field in the mutation.
  33466. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  33467. v := m.ai_response
  33468. if v == nil {
  33469. return
  33470. }
  33471. return *v, true
  33472. }
  33473. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  33474. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33476. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  33477. if !m.op.Is(OpUpdateOne) {
  33478. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  33479. }
  33480. if m.id == nil || m.oldValue == nil {
  33481. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  33482. }
  33483. oldValue, err := m.oldValue(ctx)
  33484. if err != nil {
  33485. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  33486. }
  33487. return oldValue.AiResponse, nil
  33488. }
  33489. // AddAiResponse adds u to the "ai_response" field.
  33490. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  33491. if m.addai_response != nil {
  33492. *m.addai_response += u
  33493. } else {
  33494. m.addai_response = &u
  33495. }
  33496. }
  33497. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  33498. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  33499. v := m.addai_response
  33500. if v == nil {
  33501. return
  33502. }
  33503. return *v, true
  33504. }
  33505. // ResetAiResponse resets all changes to the "ai_response" field.
  33506. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  33507. m.ai_response = nil
  33508. m.addai_response = nil
  33509. }
  33510. // SetSopRun sets the "sop_run" field.
  33511. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  33512. m.sop_run = &u
  33513. m.addsop_run = nil
  33514. }
  33515. // SopRun returns the value of the "sop_run" field in the mutation.
  33516. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  33517. v := m.sop_run
  33518. if v == nil {
  33519. return
  33520. }
  33521. return *v, true
  33522. }
  33523. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  33524. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33526. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  33527. if !m.op.Is(OpUpdateOne) {
  33528. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  33529. }
  33530. if m.id == nil || m.oldValue == nil {
  33531. return v, errors.New("OldSopRun requires an ID field in the mutation")
  33532. }
  33533. oldValue, err := m.oldValue(ctx)
  33534. if err != nil {
  33535. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  33536. }
  33537. return oldValue.SopRun, nil
  33538. }
  33539. // AddSopRun adds u to the "sop_run" field.
  33540. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  33541. if m.addsop_run != nil {
  33542. *m.addsop_run += u
  33543. } else {
  33544. m.addsop_run = &u
  33545. }
  33546. }
  33547. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  33548. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  33549. v := m.addsop_run
  33550. if v == nil {
  33551. return
  33552. }
  33553. return *v, true
  33554. }
  33555. // ResetSopRun resets all changes to the "sop_run" field.
  33556. func (m *UsageStatisticHourMutation) ResetSopRun() {
  33557. m.sop_run = nil
  33558. m.addsop_run = nil
  33559. }
  33560. // SetTotalFriend sets the "total_friend" field.
  33561. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  33562. m.total_friend = &u
  33563. m.addtotal_friend = nil
  33564. }
  33565. // TotalFriend returns the value of the "total_friend" field in the mutation.
  33566. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  33567. v := m.total_friend
  33568. if v == nil {
  33569. return
  33570. }
  33571. return *v, true
  33572. }
  33573. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  33574. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33576. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  33577. if !m.op.Is(OpUpdateOne) {
  33578. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  33579. }
  33580. if m.id == nil || m.oldValue == nil {
  33581. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  33582. }
  33583. oldValue, err := m.oldValue(ctx)
  33584. if err != nil {
  33585. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  33586. }
  33587. return oldValue.TotalFriend, nil
  33588. }
  33589. // AddTotalFriend adds u to the "total_friend" field.
  33590. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  33591. if m.addtotal_friend != nil {
  33592. *m.addtotal_friend += u
  33593. } else {
  33594. m.addtotal_friend = &u
  33595. }
  33596. }
  33597. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  33598. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  33599. v := m.addtotal_friend
  33600. if v == nil {
  33601. return
  33602. }
  33603. return *v, true
  33604. }
  33605. // ResetTotalFriend resets all changes to the "total_friend" field.
  33606. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  33607. m.total_friend = nil
  33608. m.addtotal_friend = nil
  33609. }
  33610. // SetTotalGroup sets the "total_group" field.
  33611. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  33612. m.total_group = &u
  33613. m.addtotal_group = nil
  33614. }
  33615. // TotalGroup returns the value of the "total_group" field in the mutation.
  33616. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  33617. v := m.total_group
  33618. if v == nil {
  33619. return
  33620. }
  33621. return *v, true
  33622. }
  33623. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  33624. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33626. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  33627. if !m.op.Is(OpUpdateOne) {
  33628. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  33629. }
  33630. if m.id == nil || m.oldValue == nil {
  33631. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  33632. }
  33633. oldValue, err := m.oldValue(ctx)
  33634. if err != nil {
  33635. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  33636. }
  33637. return oldValue.TotalGroup, nil
  33638. }
  33639. // AddTotalGroup adds u to the "total_group" field.
  33640. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  33641. if m.addtotal_group != nil {
  33642. *m.addtotal_group += u
  33643. } else {
  33644. m.addtotal_group = &u
  33645. }
  33646. }
  33647. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  33648. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  33649. v := m.addtotal_group
  33650. if v == nil {
  33651. return
  33652. }
  33653. return *v, true
  33654. }
  33655. // ResetTotalGroup resets all changes to the "total_group" field.
  33656. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  33657. m.total_group = nil
  33658. m.addtotal_group = nil
  33659. }
  33660. // SetAccountBalance sets the "account_balance" field.
  33661. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  33662. m.account_balance = &u
  33663. m.addaccount_balance = nil
  33664. }
  33665. // AccountBalance returns the value of the "account_balance" field in the mutation.
  33666. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  33667. v := m.account_balance
  33668. if v == nil {
  33669. return
  33670. }
  33671. return *v, true
  33672. }
  33673. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  33674. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33676. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  33677. if !m.op.Is(OpUpdateOne) {
  33678. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  33679. }
  33680. if m.id == nil || m.oldValue == nil {
  33681. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  33682. }
  33683. oldValue, err := m.oldValue(ctx)
  33684. if err != nil {
  33685. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  33686. }
  33687. return oldValue.AccountBalance, nil
  33688. }
  33689. // AddAccountBalance adds u to the "account_balance" field.
  33690. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  33691. if m.addaccount_balance != nil {
  33692. *m.addaccount_balance += u
  33693. } else {
  33694. m.addaccount_balance = &u
  33695. }
  33696. }
  33697. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  33698. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  33699. v := m.addaccount_balance
  33700. if v == nil {
  33701. return
  33702. }
  33703. return *v, true
  33704. }
  33705. // ResetAccountBalance resets all changes to the "account_balance" field.
  33706. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  33707. m.account_balance = nil
  33708. m.addaccount_balance = nil
  33709. }
  33710. // SetConsumeToken sets the "consume_token" field.
  33711. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  33712. m.consume_token = &u
  33713. m.addconsume_token = nil
  33714. }
  33715. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  33716. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  33717. v := m.consume_token
  33718. if v == nil {
  33719. return
  33720. }
  33721. return *v, true
  33722. }
  33723. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  33724. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33726. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  33727. if !m.op.Is(OpUpdateOne) {
  33728. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  33729. }
  33730. if m.id == nil || m.oldValue == nil {
  33731. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  33732. }
  33733. oldValue, err := m.oldValue(ctx)
  33734. if err != nil {
  33735. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  33736. }
  33737. return oldValue.ConsumeToken, nil
  33738. }
  33739. // AddConsumeToken adds u to the "consume_token" field.
  33740. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  33741. if m.addconsume_token != nil {
  33742. *m.addconsume_token += u
  33743. } else {
  33744. m.addconsume_token = &u
  33745. }
  33746. }
  33747. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  33748. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  33749. v := m.addconsume_token
  33750. if v == nil {
  33751. return
  33752. }
  33753. return *v, true
  33754. }
  33755. // ResetConsumeToken resets all changes to the "consume_token" field.
  33756. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  33757. m.consume_token = nil
  33758. m.addconsume_token = nil
  33759. }
  33760. // SetActiveUser sets the "active_user" field.
  33761. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  33762. m.active_user = &u
  33763. m.addactive_user = nil
  33764. }
  33765. // ActiveUser returns the value of the "active_user" field in the mutation.
  33766. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  33767. v := m.active_user
  33768. if v == nil {
  33769. return
  33770. }
  33771. return *v, true
  33772. }
  33773. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  33774. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33776. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  33777. if !m.op.Is(OpUpdateOne) {
  33778. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  33779. }
  33780. if m.id == nil || m.oldValue == nil {
  33781. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  33782. }
  33783. oldValue, err := m.oldValue(ctx)
  33784. if err != nil {
  33785. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  33786. }
  33787. return oldValue.ActiveUser, nil
  33788. }
  33789. // AddActiveUser adds u to the "active_user" field.
  33790. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  33791. if m.addactive_user != nil {
  33792. *m.addactive_user += u
  33793. } else {
  33794. m.addactive_user = &u
  33795. }
  33796. }
  33797. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  33798. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  33799. v := m.addactive_user
  33800. if v == nil {
  33801. return
  33802. }
  33803. return *v, true
  33804. }
  33805. // ResetActiveUser resets all changes to the "active_user" field.
  33806. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  33807. m.active_user = nil
  33808. m.addactive_user = nil
  33809. }
  33810. // SetNewUser sets the "new_user" field.
  33811. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  33812. m.new_user = &i
  33813. m.addnew_user = nil
  33814. }
  33815. // NewUser returns the value of the "new_user" field in the mutation.
  33816. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  33817. v := m.new_user
  33818. if v == nil {
  33819. return
  33820. }
  33821. return *v, true
  33822. }
  33823. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  33824. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33826. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  33827. if !m.op.Is(OpUpdateOne) {
  33828. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  33829. }
  33830. if m.id == nil || m.oldValue == nil {
  33831. return v, errors.New("OldNewUser requires an ID field in the mutation")
  33832. }
  33833. oldValue, err := m.oldValue(ctx)
  33834. if err != nil {
  33835. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  33836. }
  33837. return oldValue.NewUser, nil
  33838. }
  33839. // AddNewUser adds i to the "new_user" field.
  33840. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  33841. if m.addnew_user != nil {
  33842. *m.addnew_user += i
  33843. } else {
  33844. m.addnew_user = &i
  33845. }
  33846. }
  33847. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  33848. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  33849. v := m.addnew_user
  33850. if v == nil {
  33851. return
  33852. }
  33853. return *v, true
  33854. }
  33855. // ResetNewUser resets all changes to the "new_user" field.
  33856. func (m *UsageStatisticHourMutation) ResetNewUser() {
  33857. m.new_user = nil
  33858. m.addnew_user = nil
  33859. }
  33860. // SetLabelDist sets the "label_dist" field.
  33861. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  33862. m.label_dist = &ctd
  33863. m.appendlabel_dist = nil
  33864. }
  33865. // LabelDist returns the value of the "label_dist" field in the mutation.
  33866. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  33867. v := m.label_dist
  33868. if v == nil {
  33869. return
  33870. }
  33871. return *v, true
  33872. }
  33873. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  33874. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  33875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33876. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  33877. if !m.op.Is(OpUpdateOne) {
  33878. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  33879. }
  33880. if m.id == nil || m.oldValue == nil {
  33881. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  33882. }
  33883. oldValue, err := m.oldValue(ctx)
  33884. if err != nil {
  33885. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  33886. }
  33887. return oldValue.LabelDist, nil
  33888. }
  33889. // AppendLabelDist adds ctd to the "label_dist" field.
  33890. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  33891. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  33892. }
  33893. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  33894. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  33895. if len(m.appendlabel_dist) == 0 {
  33896. return nil, false
  33897. }
  33898. return m.appendlabel_dist, true
  33899. }
  33900. // ResetLabelDist resets all changes to the "label_dist" field.
  33901. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  33902. m.label_dist = nil
  33903. m.appendlabel_dist = nil
  33904. }
  33905. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  33906. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  33907. m.predicates = append(m.predicates, ps...)
  33908. }
  33909. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  33910. // users can use type-assertion to append predicates that do not depend on any generated package.
  33911. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  33912. p := make([]predicate.UsageStatisticHour, len(ps))
  33913. for i := range ps {
  33914. p[i] = ps[i]
  33915. }
  33916. m.Where(p...)
  33917. }
  33918. // Op returns the operation name.
  33919. func (m *UsageStatisticHourMutation) Op() Op {
  33920. return m.op
  33921. }
  33922. // SetOp allows setting the mutation operation.
  33923. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  33924. m.op = op
  33925. }
  33926. // Type returns the node type of this mutation (UsageStatisticHour).
  33927. func (m *UsageStatisticHourMutation) Type() string {
  33928. return m.typ
  33929. }
  33930. // Fields returns all fields that were changed during this mutation. Note that in
  33931. // order to get all numeric fields that were incremented/decremented, call
  33932. // AddedFields().
  33933. func (m *UsageStatisticHourMutation) Fields() []string {
  33934. fields := make([]string, 0, 17)
  33935. if m.created_at != nil {
  33936. fields = append(fields, usagestatistichour.FieldCreatedAt)
  33937. }
  33938. if m.updated_at != nil {
  33939. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  33940. }
  33941. if m.status != nil {
  33942. fields = append(fields, usagestatistichour.FieldStatus)
  33943. }
  33944. if m.deleted_at != nil {
  33945. fields = append(fields, usagestatistichour.FieldDeletedAt)
  33946. }
  33947. if m.addtime != nil {
  33948. fields = append(fields, usagestatistichour.FieldAddtime)
  33949. }
  33950. if m._type != nil {
  33951. fields = append(fields, usagestatistichour.FieldType)
  33952. }
  33953. if m.bot_id != nil {
  33954. fields = append(fields, usagestatistichour.FieldBotID)
  33955. }
  33956. if m.organization_id != nil {
  33957. fields = append(fields, usagestatistichour.FieldOrganizationID)
  33958. }
  33959. if m.ai_response != nil {
  33960. fields = append(fields, usagestatistichour.FieldAiResponse)
  33961. }
  33962. if m.sop_run != nil {
  33963. fields = append(fields, usagestatistichour.FieldSopRun)
  33964. }
  33965. if m.total_friend != nil {
  33966. fields = append(fields, usagestatistichour.FieldTotalFriend)
  33967. }
  33968. if m.total_group != nil {
  33969. fields = append(fields, usagestatistichour.FieldTotalGroup)
  33970. }
  33971. if m.account_balance != nil {
  33972. fields = append(fields, usagestatistichour.FieldAccountBalance)
  33973. }
  33974. if m.consume_token != nil {
  33975. fields = append(fields, usagestatistichour.FieldConsumeToken)
  33976. }
  33977. if m.active_user != nil {
  33978. fields = append(fields, usagestatistichour.FieldActiveUser)
  33979. }
  33980. if m.new_user != nil {
  33981. fields = append(fields, usagestatistichour.FieldNewUser)
  33982. }
  33983. if m.label_dist != nil {
  33984. fields = append(fields, usagestatistichour.FieldLabelDist)
  33985. }
  33986. return fields
  33987. }
  33988. // Field returns the value of a field with the given name. The second boolean
  33989. // return value indicates that this field was not set, or was not defined in the
  33990. // schema.
  33991. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  33992. switch name {
  33993. case usagestatistichour.FieldCreatedAt:
  33994. return m.CreatedAt()
  33995. case usagestatistichour.FieldUpdatedAt:
  33996. return m.UpdatedAt()
  33997. case usagestatistichour.FieldStatus:
  33998. return m.Status()
  33999. case usagestatistichour.FieldDeletedAt:
  34000. return m.DeletedAt()
  34001. case usagestatistichour.FieldAddtime:
  34002. return m.Addtime()
  34003. case usagestatistichour.FieldType:
  34004. return m.GetType()
  34005. case usagestatistichour.FieldBotID:
  34006. return m.BotID()
  34007. case usagestatistichour.FieldOrganizationID:
  34008. return m.OrganizationID()
  34009. case usagestatistichour.FieldAiResponse:
  34010. return m.AiResponse()
  34011. case usagestatistichour.FieldSopRun:
  34012. return m.SopRun()
  34013. case usagestatistichour.FieldTotalFriend:
  34014. return m.TotalFriend()
  34015. case usagestatistichour.FieldTotalGroup:
  34016. return m.TotalGroup()
  34017. case usagestatistichour.FieldAccountBalance:
  34018. return m.AccountBalance()
  34019. case usagestatistichour.FieldConsumeToken:
  34020. return m.ConsumeToken()
  34021. case usagestatistichour.FieldActiveUser:
  34022. return m.ActiveUser()
  34023. case usagestatistichour.FieldNewUser:
  34024. return m.NewUser()
  34025. case usagestatistichour.FieldLabelDist:
  34026. return m.LabelDist()
  34027. }
  34028. return nil, false
  34029. }
  34030. // OldField returns the old value of the field from the database. An error is
  34031. // returned if the mutation operation is not UpdateOne, or the query to the
  34032. // database failed.
  34033. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34034. switch name {
  34035. case usagestatistichour.FieldCreatedAt:
  34036. return m.OldCreatedAt(ctx)
  34037. case usagestatistichour.FieldUpdatedAt:
  34038. return m.OldUpdatedAt(ctx)
  34039. case usagestatistichour.FieldStatus:
  34040. return m.OldStatus(ctx)
  34041. case usagestatistichour.FieldDeletedAt:
  34042. return m.OldDeletedAt(ctx)
  34043. case usagestatistichour.FieldAddtime:
  34044. return m.OldAddtime(ctx)
  34045. case usagestatistichour.FieldType:
  34046. return m.OldType(ctx)
  34047. case usagestatistichour.FieldBotID:
  34048. return m.OldBotID(ctx)
  34049. case usagestatistichour.FieldOrganizationID:
  34050. return m.OldOrganizationID(ctx)
  34051. case usagestatistichour.FieldAiResponse:
  34052. return m.OldAiResponse(ctx)
  34053. case usagestatistichour.FieldSopRun:
  34054. return m.OldSopRun(ctx)
  34055. case usagestatistichour.FieldTotalFriend:
  34056. return m.OldTotalFriend(ctx)
  34057. case usagestatistichour.FieldTotalGroup:
  34058. return m.OldTotalGroup(ctx)
  34059. case usagestatistichour.FieldAccountBalance:
  34060. return m.OldAccountBalance(ctx)
  34061. case usagestatistichour.FieldConsumeToken:
  34062. return m.OldConsumeToken(ctx)
  34063. case usagestatistichour.FieldActiveUser:
  34064. return m.OldActiveUser(ctx)
  34065. case usagestatistichour.FieldNewUser:
  34066. return m.OldNewUser(ctx)
  34067. case usagestatistichour.FieldLabelDist:
  34068. return m.OldLabelDist(ctx)
  34069. }
  34070. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34071. }
  34072. // SetField sets the value of a field with the given name. It returns an error if
  34073. // the field is not defined in the schema, or if the type mismatched the field
  34074. // type.
  34075. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  34076. switch name {
  34077. case usagestatistichour.FieldCreatedAt:
  34078. v, ok := value.(time.Time)
  34079. if !ok {
  34080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34081. }
  34082. m.SetCreatedAt(v)
  34083. return nil
  34084. case usagestatistichour.FieldUpdatedAt:
  34085. v, ok := value.(time.Time)
  34086. if !ok {
  34087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34088. }
  34089. m.SetUpdatedAt(v)
  34090. return nil
  34091. case usagestatistichour.FieldStatus:
  34092. v, ok := value.(uint8)
  34093. if !ok {
  34094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34095. }
  34096. m.SetStatus(v)
  34097. return nil
  34098. case usagestatistichour.FieldDeletedAt:
  34099. v, ok := value.(time.Time)
  34100. if !ok {
  34101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34102. }
  34103. m.SetDeletedAt(v)
  34104. return nil
  34105. case usagestatistichour.FieldAddtime:
  34106. v, ok := value.(uint64)
  34107. if !ok {
  34108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34109. }
  34110. m.SetAddtime(v)
  34111. return nil
  34112. case usagestatistichour.FieldType:
  34113. v, ok := value.(int)
  34114. if !ok {
  34115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34116. }
  34117. m.SetType(v)
  34118. return nil
  34119. case usagestatistichour.FieldBotID:
  34120. v, ok := value.(string)
  34121. if !ok {
  34122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34123. }
  34124. m.SetBotID(v)
  34125. return nil
  34126. case usagestatistichour.FieldOrganizationID:
  34127. v, ok := value.(uint64)
  34128. if !ok {
  34129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34130. }
  34131. m.SetOrganizationID(v)
  34132. return nil
  34133. case usagestatistichour.FieldAiResponse:
  34134. v, ok := value.(uint64)
  34135. if !ok {
  34136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34137. }
  34138. m.SetAiResponse(v)
  34139. return nil
  34140. case usagestatistichour.FieldSopRun:
  34141. v, ok := value.(uint64)
  34142. if !ok {
  34143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34144. }
  34145. m.SetSopRun(v)
  34146. return nil
  34147. case usagestatistichour.FieldTotalFriend:
  34148. v, ok := value.(uint64)
  34149. if !ok {
  34150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34151. }
  34152. m.SetTotalFriend(v)
  34153. return nil
  34154. case usagestatistichour.FieldTotalGroup:
  34155. v, ok := value.(uint64)
  34156. if !ok {
  34157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34158. }
  34159. m.SetTotalGroup(v)
  34160. return nil
  34161. case usagestatistichour.FieldAccountBalance:
  34162. v, ok := value.(uint64)
  34163. if !ok {
  34164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34165. }
  34166. m.SetAccountBalance(v)
  34167. return nil
  34168. case usagestatistichour.FieldConsumeToken:
  34169. v, ok := value.(uint64)
  34170. if !ok {
  34171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34172. }
  34173. m.SetConsumeToken(v)
  34174. return nil
  34175. case usagestatistichour.FieldActiveUser:
  34176. v, ok := value.(uint64)
  34177. if !ok {
  34178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34179. }
  34180. m.SetActiveUser(v)
  34181. return nil
  34182. case usagestatistichour.FieldNewUser:
  34183. v, ok := value.(int64)
  34184. if !ok {
  34185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34186. }
  34187. m.SetNewUser(v)
  34188. return nil
  34189. case usagestatistichour.FieldLabelDist:
  34190. v, ok := value.([]custom_types.LabelDist)
  34191. if !ok {
  34192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34193. }
  34194. m.SetLabelDist(v)
  34195. return nil
  34196. }
  34197. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34198. }
  34199. // AddedFields returns all numeric fields that were incremented/decremented during
  34200. // this mutation.
  34201. func (m *UsageStatisticHourMutation) AddedFields() []string {
  34202. var fields []string
  34203. if m.addstatus != nil {
  34204. fields = append(fields, usagestatistichour.FieldStatus)
  34205. }
  34206. if m.addaddtime != nil {
  34207. fields = append(fields, usagestatistichour.FieldAddtime)
  34208. }
  34209. if m.add_type != nil {
  34210. fields = append(fields, usagestatistichour.FieldType)
  34211. }
  34212. if m.addorganization_id != nil {
  34213. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34214. }
  34215. if m.addai_response != nil {
  34216. fields = append(fields, usagestatistichour.FieldAiResponse)
  34217. }
  34218. if m.addsop_run != nil {
  34219. fields = append(fields, usagestatistichour.FieldSopRun)
  34220. }
  34221. if m.addtotal_friend != nil {
  34222. fields = append(fields, usagestatistichour.FieldTotalFriend)
  34223. }
  34224. if m.addtotal_group != nil {
  34225. fields = append(fields, usagestatistichour.FieldTotalGroup)
  34226. }
  34227. if m.addaccount_balance != nil {
  34228. fields = append(fields, usagestatistichour.FieldAccountBalance)
  34229. }
  34230. if m.addconsume_token != nil {
  34231. fields = append(fields, usagestatistichour.FieldConsumeToken)
  34232. }
  34233. if m.addactive_user != nil {
  34234. fields = append(fields, usagestatistichour.FieldActiveUser)
  34235. }
  34236. if m.addnew_user != nil {
  34237. fields = append(fields, usagestatistichour.FieldNewUser)
  34238. }
  34239. return fields
  34240. }
  34241. // AddedField returns the numeric value that was incremented/decremented on a field
  34242. // with the given name. The second boolean return value indicates that this field
  34243. // was not set, or was not defined in the schema.
  34244. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  34245. switch name {
  34246. case usagestatistichour.FieldStatus:
  34247. return m.AddedStatus()
  34248. case usagestatistichour.FieldAddtime:
  34249. return m.AddedAddtime()
  34250. case usagestatistichour.FieldType:
  34251. return m.AddedType()
  34252. case usagestatistichour.FieldOrganizationID:
  34253. return m.AddedOrganizationID()
  34254. case usagestatistichour.FieldAiResponse:
  34255. return m.AddedAiResponse()
  34256. case usagestatistichour.FieldSopRun:
  34257. return m.AddedSopRun()
  34258. case usagestatistichour.FieldTotalFriend:
  34259. return m.AddedTotalFriend()
  34260. case usagestatistichour.FieldTotalGroup:
  34261. return m.AddedTotalGroup()
  34262. case usagestatistichour.FieldAccountBalance:
  34263. return m.AddedAccountBalance()
  34264. case usagestatistichour.FieldConsumeToken:
  34265. return m.AddedConsumeToken()
  34266. case usagestatistichour.FieldActiveUser:
  34267. return m.AddedActiveUser()
  34268. case usagestatistichour.FieldNewUser:
  34269. return m.AddedNewUser()
  34270. }
  34271. return nil, false
  34272. }
  34273. // AddField adds the value to the field with the given name. It returns an error if
  34274. // the field is not defined in the schema, or if the type mismatched the field
  34275. // type.
  34276. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  34277. switch name {
  34278. case usagestatistichour.FieldStatus:
  34279. v, ok := value.(int8)
  34280. if !ok {
  34281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34282. }
  34283. m.AddStatus(v)
  34284. return nil
  34285. case usagestatistichour.FieldAddtime:
  34286. v, ok := value.(int64)
  34287. if !ok {
  34288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34289. }
  34290. m.AddAddtime(v)
  34291. return nil
  34292. case usagestatistichour.FieldType:
  34293. v, ok := value.(int)
  34294. if !ok {
  34295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34296. }
  34297. m.AddType(v)
  34298. return nil
  34299. case usagestatistichour.FieldOrganizationID:
  34300. v, ok := value.(int64)
  34301. if !ok {
  34302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34303. }
  34304. m.AddOrganizationID(v)
  34305. return nil
  34306. case usagestatistichour.FieldAiResponse:
  34307. v, ok := value.(int64)
  34308. if !ok {
  34309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34310. }
  34311. m.AddAiResponse(v)
  34312. return nil
  34313. case usagestatistichour.FieldSopRun:
  34314. v, ok := value.(int64)
  34315. if !ok {
  34316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34317. }
  34318. m.AddSopRun(v)
  34319. return nil
  34320. case usagestatistichour.FieldTotalFriend:
  34321. v, ok := value.(int64)
  34322. if !ok {
  34323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34324. }
  34325. m.AddTotalFriend(v)
  34326. return nil
  34327. case usagestatistichour.FieldTotalGroup:
  34328. v, ok := value.(int64)
  34329. if !ok {
  34330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34331. }
  34332. m.AddTotalGroup(v)
  34333. return nil
  34334. case usagestatistichour.FieldAccountBalance:
  34335. v, ok := value.(int64)
  34336. if !ok {
  34337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34338. }
  34339. m.AddAccountBalance(v)
  34340. return nil
  34341. case usagestatistichour.FieldConsumeToken:
  34342. v, ok := value.(int64)
  34343. if !ok {
  34344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34345. }
  34346. m.AddConsumeToken(v)
  34347. return nil
  34348. case usagestatistichour.FieldActiveUser:
  34349. v, ok := value.(int64)
  34350. if !ok {
  34351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34352. }
  34353. m.AddActiveUser(v)
  34354. return nil
  34355. case usagestatistichour.FieldNewUser:
  34356. v, ok := value.(int64)
  34357. if !ok {
  34358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34359. }
  34360. m.AddNewUser(v)
  34361. return nil
  34362. }
  34363. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  34364. }
  34365. // ClearedFields returns all nullable fields that were cleared during this
  34366. // mutation.
  34367. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  34368. var fields []string
  34369. if m.FieldCleared(usagestatistichour.FieldStatus) {
  34370. fields = append(fields, usagestatistichour.FieldStatus)
  34371. }
  34372. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  34373. fields = append(fields, usagestatistichour.FieldDeletedAt)
  34374. }
  34375. if m.FieldCleared(usagestatistichour.FieldBotID) {
  34376. fields = append(fields, usagestatistichour.FieldBotID)
  34377. }
  34378. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  34379. fields = append(fields, usagestatistichour.FieldOrganizationID)
  34380. }
  34381. return fields
  34382. }
  34383. // FieldCleared returns a boolean indicating if a field with the given name was
  34384. // cleared in this mutation.
  34385. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  34386. _, ok := m.clearedFields[name]
  34387. return ok
  34388. }
  34389. // ClearField clears the value of the field with the given name. It returns an
  34390. // error if the field is not defined in the schema.
  34391. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  34392. switch name {
  34393. case usagestatistichour.FieldStatus:
  34394. m.ClearStatus()
  34395. return nil
  34396. case usagestatistichour.FieldDeletedAt:
  34397. m.ClearDeletedAt()
  34398. return nil
  34399. case usagestatistichour.FieldBotID:
  34400. m.ClearBotID()
  34401. return nil
  34402. case usagestatistichour.FieldOrganizationID:
  34403. m.ClearOrganizationID()
  34404. return nil
  34405. }
  34406. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  34407. }
  34408. // ResetField resets all changes in the mutation for the field with the given name.
  34409. // It returns an error if the field is not defined in the schema.
  34410. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  34411. switch name {
  34412. case usagestatistichour.FieldCreatedAt:
  34413. m.ResetCreatedAt()
  34414. return nil
  34415. case usagestatistichour.FieldUpdatedAt:
  34416. m.ResetUpdatedAt()
  34417. return nil
  34418. case usagestatistichour.FieldStatus:
  34419. m.ResetStatus()
  34420. return nil
  34421. case usagestatistichour.FieldDeletedAt:
  34422. m.ResetDeletedAt()
  34423. return nil
  34424. case usagestatistichour.FieldAddtime:
  34425. m.ResetAddtime()
  34426. return nil
  34427. case usagestatistichour.FieldType:
  34428. m.ResetType()
  34429. return nil
  34430. case usagestatistichour.FieldBotID:
  34431. m.ResetBotID()
  34432. return nil
  34433. case usagestatistichour.FieldOrganizationID:
  34434. m.ResetOrganizationID()
  34435. return nil
  34436. case usagestatistichour.FieldAiResponse:
  34437. m.ResetAiResponse()
  34438. return nil
  34439. case usagestatistichour.FieldSopRun:
  34440. m.ResetSopRun()
  34441. return nil
  34442. case usagestatistichour.FieldTotalFriend:
  34443. m.ResetTotalFriend()
  34444. return nil
  34445. case usagestatistichour.FieldTotalGroup:
  34446. m.ResetTotalGroup()
  34447. return nil
  34448. case usagestatistichour.FieldAccountBalance:
  34449. m.ResetAccountBalance()
  34450. return nil
  34451. case usagestatistichour.FieldConsumeToken:
  34452. m.ResetConsumeToken()
  34453. return nil
  34454. case usagestatistichour.FieldActiveUser:
  34455. m.ResetActiveUser()
  34456. return nil
  34457. case usagestatistichour.FieldNewUser:
  34458. m.ResetNewUser()
  34459. return nil
  34460. case usagestatistichour.FieldLabelDist:
  34461. m.ResetLabelDist()
  34462. return nil
  34463. }
  34464. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  34465. }
  34466. // AddedEdges returns all edge names that were set/added in this mutation.
  34467. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  34468. edges := make([]string, 0, 0)
  34469. return edges
  34470. }
  34471. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34472. // name in this mutation.
  34473. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  34474. return nil
  34475. }
  34476. // RemovedEdges returns all edge names that were removed in this mutation.
  34477. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  34478. edges := make([]string, 0, 0)
  34479. return edges
  34480. }
  34481. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34482. // the given name in this mutation.
  34483. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  34484. return nil
  34485. }
  34486. // ClearedEdges returns all edge names that were cleared in this mutation.
  34487. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  34488. edges := make([]string, 0, 0)
  34489. return edges
  34490. }
  34491. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34492. // was cleared in this mutation.
  34493. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  34494. return false
  34495. }
  34496. // ClearEdge clears the value of the edge with the given name. It returns an error
  34497. // if that edge is not defined in the schema.
  34498. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  34499. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  34500. }
  34501. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34502. // It returns an error if the edge is not defined in the schema.
  34503. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  34504. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  34505. }
  34506. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  34507. type UsageStatisticMonthMutation struct {
  34508. config
  34509. op Op
  34510. typ string
  34511. id *uint64
  34512. created_at *time.Time
  34513. updated_at *time.Time
  34514. status *uint8
  34515. addstatus *int8
  34516. deleted_at *time.Time
  34517. addtime *uint64
  34518. addaddtime *int64
  34519. _type *int
  34520. add_type *int
  34521. bot_id *string
  34522. organization_id *uint64
  34523. addorganization_id *int64
  34524. ai_response *uint64
  34525. addai_response *int64
  34526. sop_run *uint64
  34527. addsop_run *int64
  34528. total_friend *uint64
  34529. addtotal_friend *int64
  34530. total_group *uint64
  34531. addtotal_group *int64
  34532. account_balance *uint64
  34533. addaccount_balance *int64
  34534. consume_token *uint64
  34535. addconsume_token *int64
  34536. active_user *uint64
  34537. addactive_user *int64
  34538. new_user *int64
  34539. addnew_user *int64
  34540. label_dist *[]custom_types.LabelDist
  34541. appendlabel_dist []custom_types.LabelDist
  34542. clearedFields map[string]struct{}
  34543. done bool
  34544. oldValue func(context.Context) (*UsageStatisticMonth, error)
  34545. predicates []predicate.UsageStatisticMonth
  34546. }
  34547. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  34548. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  34549. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  34550. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  34551. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  34552. m := &UsageStatisticMonthMutation{
  34553. config: c,
  34554. op: op,
  34555. typ: TypeUsageStatisticMonth,
  34556. clearedFields: make(map[string]struct{}),
  34557. }
  34558. for _, opt := range opts {
  34559. opt(m)
  34560. }
  34561. return m
  34562. }
  34563. // withUsageStatisticMonthID sets the ID field of the mutation.
  34564. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  34565. return func(m *UsageStatisticMonthMutation) {
  34566. var (
  34567. err error
  34568. once sync.Once
  34569. value *UsageStatisticMonth
  34570. )
  34571. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  34572. once.Do(func() {
  34573. if m.done {
  34574. err = errors.New("querying old values post mutation is not allowed")
  34575. } else {
  34576. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  34577. }
  34578. })
  34579. return value, err
  34580. }
  34581. m.id = &id
  34582. }
  34583. }
  34584. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  34585. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  34586. return func(m *UsageStatisticMonthMutation) {
  34587. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  34588. return node, nil
  34589. }
  34590. m.id = &node.ID
  34591. }
  34592. }
  34593. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34594. // executed in a transaction (ent.Tx), a transactional client is returned.
  34595. func (m UsageStatisticMonthMutation) Client() *Client {
  34596. client := &Client{config: m.config}
  34597. client.init()
  34598. return client
  34599. }
  34600. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34601. // it returns an error otherwise.
  34602. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  34603. if _, ok := m.driver.(*txDriver); !ok {
  34604. return nil, errors.New("ent: mutation is not running in a transaction")
  34605. }
  34606. tx := &Tx{config: m.config}
  34607. tx.init()
  34608. return tx, nil
  34609. }
  34610. // SetID sets the value of the id field. Note that this
  34611. // operation is only accepted on creation of UsageStatisticMonth entities.
  34612. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  34613. m.id = &id
  34614. }
  34615. // ID returns the ID value in the mutation. Note that the ID is only available
  34616. // if it was provided to the builder or after it was returned from the database.
  34617. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  34618. if m.id == nil {
  34619. return
  34620. }
  34621. return *m.id, true
  34622. }
  34623. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34624. // That means, if the mutation is applied within a transaction with an isolation level such
  34625. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34626. // or updated by the mutation.
  34627. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  34628. switch {
  34629. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34630. id, exists := m.ID()
  34631. if exists {
  34632. return []uint64{id}, nil
  34633. }
  34634. fallthrough
  34635. case m.op.Is(OpUpdate | OpDelete):
  34636. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  34637. default:
  34638. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34639. }
  34640. }
  34641. // SetCreatedAt sets the "created_at" field.
  34642. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  34643. m.created_at = &t
  34644. }
  34645. // CreatedAt returns the value of the "created_at" field in the mutation.
  34646. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  34647. v := m.created_at
  34648. if v == nil {
  34649. return
  34650. }
  34651. return *v, true
  34652. }
  34653. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  34654. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34656. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34657. if !m.op.Is(OpUpdateOne) {
  34658. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34659. }
  34660. if m.id == nil || m.oldValue == nil {
  34661. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34662. }
  34663. oldValue, err := m.oldValue(ctx)
  34664. if err != nil {
  34665. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34666. }
  34667. return oldValue.CreatedAt, nil
  34668. }
  34669. // ResetCreatedAt resets all changes to the "created_at" field.
  34670. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  34671. m.created_at = nil
  34672. }
  34673. // SetUpdatedAt sets the "updated_at" field.
  34674. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  34675. m.updated_at = &t
  34676. }
  34677. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34678. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  34679. v := m.updated_at
  34680. if v == nil {
  34681. return
  34682. }
  34683. return *v, true
  34684. }
  34685. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  34686. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34688. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34689. if !m.op.Is(OpUpdateOne) {
  34690. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34691. }
  34692. if m.id == nil || m.oldValue == nil {
  34693. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34694. }
  34695. oldValue, err := m.oldValue(ctx)
  34696. if err != nil {
  34697. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34698. }
  34699. return oldValue.UpdatedAt, nil
  34700. }
  34701. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34702. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  34703. m.updated_at = nil
  34704. }
  34705. // SetStatus sets the "status" field.
  34706. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  34707. m.status = &u
  34708. m.addstatus = nil
  34709. }
  34710. // Status returns the value of the "status" field in the mutation.
  34711. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  34712. v := m.status
  34713. if v == nil {
  34714. return
  34715. }
  34716. return *v, true
  34717. }
  34718. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  34719. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34721. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34722. if !m.op.Is(OpUpdateOne) {
  34723. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34724. }
  34725. if m.id == nil || m.oldValue == nil {
  34726. return v, errors.New("OldStatus requires an ID field in the mutation")
  34727. }
  34728. oldValue, err := m.oldValue(ctx)
  34729. if err != nil {
  34730. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34731. }
  34732. return oldValue.Status, nil
  34733. }
  34734. // AddStatus adds u to the "status" field.
  34735. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  34736. if m.addstatus != nil {
  34737. *m.addstatus += u
  34738. } else {
  34739. m.addstatus = &u
  34740. }
  34741. }
  34742. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34743. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  34744. v := m.addstatus
  34745. if v == nil {
  34746. return
  34747. }
  34748. return *v, true
  34749. }
  34750. // ClearStatus clears the value of the "status" field.
  34751. func (m *UsageStatisticMonthMutation) ClearStatus() {
  34752. m.status = nil
  34753. m.addstatus = nil
  34754. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  34755. }
  34756. // StatusCleared returns if the "status" field was cleared in this mutation.
  34757. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  34758. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  34759. return ok
  34760. }
  34761. // ResetStatus resets all changes to the "status" field.
  34762. func (m *UsageStatisticMonthMutation) ResetStatus() {
  34763. m.status = nil
  34764. m.addstatus = nil
  34765. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  34766. }
  34767. // SetDeletedAt sets the "deleted_at" field.
  34768. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  34769. m.deleted_at = &t
  34770. }
  34771. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34772. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  34773. v := m.deleted_at
  34774. if v == nil {
  34775. return
  34776. }
  34777. return *v, true
  34778. }
  34779. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  34780. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34782. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34783. if !m.op.Is(OpUpdateOne) {
  34784. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34785. }
  34786. if m.id == nil || m.oldValue == nil {
  34787. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34788. }
  34789. oldValue, err := m.oldValue(ctx)
  34790. if err != nil {
  34791. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34792. }
  34793. return oldValue.DeletedAt, nil
  34794. }
  34795. // ClearDeletedAt clears the value of the "deleted_at" field.
  34796. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  34797. m.deleted_at = nil
  34798. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  34799. }
  34800. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34801. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  34802. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  34803. return ok
  34804. }
  34805. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34806. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  34807. m.deleted_at = nil
  34808. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  34809. }
  34810. // SetAddtime sets the "addtime" field.
  34811. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  34812. m.addtime = &u
  34813. m.addaddtime = nil
  34814. }
  34815. // Addtime returns the value of the "addtime" field in the mutation.
  34816. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  34817. v := m.addtime
  34818. if v == nil {
  34819. return
  34820. }
  34821. return *v, true
  34822. }
  34823. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  34824. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34826. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  34827. if !m.op.Is(OpUpdateOne) {
  34828. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  34829. }
  34830. if m.id == nil || m.oldValue == nil {
  34831. return v, errors.New("OldAddtime requires an ID field in the mutation")
  34832. }
  34833. oldValue, err := m.oldValue(ctx)
  34834. if err != nil {
  34835. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  34836. }
  34837. return oldValue.Addtime, nil
  34838. }
  34839. // AddAddtime adds u to the "addtime" field.
  34840. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  34841. if m.addaddtime != nil {
  34842. *m.addaddtime += u
  34843. } else {
  34844. m.addaddtime = &u
  34845. }
  34846. }
  34847. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  34848. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  34849. v := m.addaddtime
  34850. if v == nil {
  34851. return
  34852. }
  34853. return *v, true
  34854. }
  34855. // ResetAddtime resets all changes to the "addtime" field.
  34856. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  34857. m.addtime = nil
  34858. m.addaddtime = nil
  34859. }
  34860. // SetType sets the "type" field.
  34861. func (m *UsageStatisticMonthMutation) SetType(i int) {
  34862. m._type = &i
  34863. m.add_type = nil
  34864. }
  34865. // GetType returns the value of the "type" field in the mutation.
  34866. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  34867. v := m._type
  34868. if v == nil {
  34869. return
  34870. }
  34871. return *v, true
  34872. }
  34873. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  34874. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34876. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  34877. if !m.op.Is(OpUpdateOne) {
  34878. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34879. }
  34880. if m.id == nil || m.oldValue == nil {
  34881. return v, errors.New("OldType requires an ID field in the mutation")
  34882. }
  34883. oldValue, err := m.oldValue(ctx)
  34884. if err != nil {
  34885. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34886. }
  34887. return oldValue.Type, nil
  34888. }
  34889. // AddType adds i to the "type" field.
  34890. func (m *UsageStatisticMonthMutation) AddType(i int) {
  34891. if m.add_type != nil {
  34892. *m.add_type += i
  34893. } else {
  34894. m.add_type = &i
  34895. }
  34896. }
  34897. // AddedType returns the value that was added to the "type" field in this mutation.
  34898. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  34899. v := m.add_type
  34900. if v == nil {
  34901. return
  34902. }
  34903. return *v, true
  34904. }
  34905. // ResetType resets all changes to the "type" field.
  34906. func (m *UsageStatisticMonthMutation) ResetType() {
  34907. m._type = nil
  34908. m.add_type = nil
  34909. }
  34910. // SetBotID sets the "bot_id" field.
  34911. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  34912. m.bot_id = &s
  34913. }
  34914. // BotID returns the value of the "bot_id" field in the mutation.
  34915. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  34916. v := m.bot_id
  34917. if v == nil {
  34918. return
  34919. }
  34920. return *v, true
  34921. }
  34922. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  34923. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34925. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  34926. if !m.op.Is(OpUpdateOne) {
  34927. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34928. }
  34929. if m.id == nil || m.oldValue == nil {
  34930. return v, errors.New("OldBotID requires an ID field in the mutation")
  34931. }
  34932. oldValue, err := m.oldValue(ctx)
  34933. if err != nil {
  34934. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34935. }
  34936. return oldValue.BotID, nil
  34937. }
  34938. // ClearBotID clears the value of the "bot_id" field.
  34939. func (m *UsageStatisticMonthMutation) ClearBotID() {
  34940. m.bot_id = nil
  34941. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  34942. }
  34943. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  34944. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  34945. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  34946. return ok
  34947. }
  34948. // ResetBotID resets all changes to the "bot_id" field.
  34949. func (m *UsageStatisticMonthMutation) ResetBotID() {
  34950. m.bot_id = nil
  34951. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  34952. }
  34953. // SetOrganizationID sets the "organization_id" field.
  34954. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  34955. m.organization_id = &u
  34956. m.addorganization_id = nil
  34957. }
  34958. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34959. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  34960. v := m.organization_id
  34961. if v == nil {
  34962. return
  34963. }
  34964. return *v, true
  34965. }
  34966. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  34967. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  34968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34969. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34970. if !m.op.Is(OpUpdateOne) {
  34971. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34972. }
  34973. if m.id == nil || m.oldValue == nil {
  34974. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34975. }
  34976. oldValue, err := m.oldValue(ctx)
  34977. if err != nil {
  34978. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34979. }
  34980. return oldValue.OrganizationID, nil
  34981. }
  34982. // AddOrganizationID adds u to the "organization_id" field.
  34983. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  34984. if m.addorganization_id != nil {
  34985. *m.addorganization_id += u
  34986. } else {
  34987. m.addorganization_id = &u
  34988. }
  34989. }
  34990. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34991. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  34992. v := m.addorganization_id
  34993. if v == nil {
  34994. return
  34995. }
  34996. return *v, true
  34997. }
  34998. // ClearOrganizationID clears the value of the "organization_id" field.
  34999. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  35000. m.organization_id = nil
  35001. m.addorganization_id = nil
  35002. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  35003. }
  35004. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35005. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  35006. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  35007. return ok
  35008. }
  35009. // ResetOrganizationID resets all changes to the "organization_id" field.
  35010. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  35011. m.organization_id = nil
  35012. m.addorganization_id = nil
  35013. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  35014. }
  35015. // SetAiResponse sets the "ai_response" field.
  35016. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  35017. m.ai_response = &u
  35018. m.addai_response = nil
  35019. }
  35020. // AiResponse returns the value of the "ai_response" field in the mutation.
  35021. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  35022. v := m.ai_response
  35023. if v == nil {
  35024. return
  35025. }
  35026. return *v, true
  35027. }
  35028. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  35029. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35031. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  35032. if !m.op.Is(OpUpdateOne) {
  35033. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  35034. }
  35035. if m.id == nil || m.oldValue == nil {
  35036. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  35037. }
  35038. oldValue, err := m.oldValue(ctx)
  35039. if err != nil {
  35040. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  35041. }
  35042. return oldValue.AiResponse, nil
  35043. }
  35044. // AddAiResponse adds u to the "ai_response" field.
  35045. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  35046. if m.addai_response != nil {
  35047. *m.addai_response += u
  35048. } else {
  35049. m.addai_response = &u
  35050. }
  35051. }
  35052. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  35053. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  35054. v := m.addai_response
  35055. if v == nil {
  35056. return
  35057. }
  35058. return *v, true
  35059. }
  35060. // ResetAiResponse resets all changes to the "ai_response" field.
  35061. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  35062. m.ai_response = nil
  35063. m.addai_response = nil
  35064. }
  35065. // SetSopRun sets the "sop_run" field.
  35066. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  35067. m.sop_run = &u
  35068. m.addsop_run = nil
  35069. }
  35070. // SopRun returns the value of the "sop_run" field in the mutation.
  35071. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  35072. v := m.sop_run
  35073. if v == nil {
  35074. return
  35075. }
  35076. return *v, true
  35077. }
  35078. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  35079. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35081. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  35082. if !m.op.Is(OpUpdateOne) {
  35083. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  35084. }
  35085. if m.id == nil || m.oldValue == nil {
  35086. return v, errors.New("OldSopRun requires an ID field in the mutation")
  35087. }
  35088. oldValue, err := m.oldValue(ctx)
  35089. if err != nil {
  35090. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  35091. }
  35092. return oldValue.SopRun, nil
  35093. }
  35094. // AddSopRun adds u to the "sop_run" field.
  35095. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  35096. if m.addsop_run != nil {
  35097. *m.addsop_run += u
  35098. } else {
  35099. m.addsop_run = &u
  35100. }
  35101. }
  35102. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  35103. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  35104. v := m.addsop_run
  35105. if v == nil {
  35106. return
  35107. }
  35108. return *v, true
  35109. }
  35110. // ResetSopRun resets all changes to the "sop_run" field.
  35111. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  35112. m.sop_run = nil
  35113. m.addsop_run = nil
  35114. }
  35115. // SetTotalFriend sets the "total_friend" field.
  35116. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  35117. m.total_friend = &u
  35118. m.addtotal_friend = nil
  35119. }
  35120. // TotalFriend returns the value of the "total_friend" field in the mutation.
  35121. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  35122. v := m.total_friend
  35123. if v == nil {
  35124. return
  35125. }
  35126. return *v, true
  35127. }
  35128. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  35129. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35131. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  35132. if !m.op.Is(OpUpdateOne) {
  35133. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  35134. }
  35135. if m.id == nil || m.oldValue == nil {
  35136. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  35137. }
  35138. oldValue, err := m.oldValue(ctx)
  35139. if err != nil {
  35140. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  35141. }
  35142. return oldValue.TotalFriend, nil
  35143. }
  35144. // AddTotalFriend adds u to the "total_friend" field.
  35145. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  35146. if m.addtotal_friend != nil {
  35147. *m.addtotal_friend += u
  35148. } else {
  35149. m.addtotal_friend = &u
  35150. }
  35151. }
  35152. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  35153. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  35154. v := m.addtotal_friend
  35155. if v == nil {
  35156. return
  35157. }
  35158. return *v, true
  35159. }
  35160. // ResetTotalFriend resets all changes to the "total_friend" field.
  35161. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  35162. m.total_friend = nil
  35163. m.addtotal_friend = nil
  35164. }
  35165. // SetTotalGroup sets the "total_group" field.
  35166. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  35167. m.total_group = &u
  35168. m.addtotal_group = nil
  35169. }
  35170. // TotalGroup returns the value of the "total_group" field in the mutation.
  35171. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  35172. v := m.total_group
  35173. if v == nil {
  35174. return
  35175. }
  35176. return *v, true
  35177. }
  35178. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  35179. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35180. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35181. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  35182. if !m.op.Is(OpUpdateOne) {
  35183. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  35184. }
  35185. if m.id == nil || m.oldValue == nil {
  35186. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  35187. }
  35188. oldValue, err := m.oldValue(ctx)
  35189. if err != nil {
  35190. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  35191. }
  35192. return oldValue.TotalGroup, nil
  35193. }
  35194. // AddTotalGroup adds u to the "total_group" field.
  35195. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  35196. if m.addtotal_group != nil {
  35197. *m.addtotal_group += u
  35198. } else {
  35199. m.addtotal_group = &u
  35200. }
  35201. }
  35202. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  35203. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  35204. v := m.addtotal_group
  35205. if v == nil {
  35206. return
  35207. }
  35208. return *v, true
  35209. }
  35210. // ResetTotalGroup resets all changes to the "total_group" field.
  35211. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  35212. m.total_group = nil
  35213. m.addtotal_group = nil
  35214. }
  35215. // SetAccountBalance sets the "account_balance" field.
  35216. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  35217. m.account_balance = &u
  35218. m.addaccount_balance = nil
  35219. }
  35220. // AccountBalance returns the value of the "account_balance" field in the mutation.
  35221. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  35222. v := m.account_balance
  35223. if v == nil {
  35224. return
  35225. }
  35226. return *v, true
  35227. }
  35228. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  35229. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35231. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  35232. if !m.op.Is(OpUpdateOne) {
  35233. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  35234. }
  35235. if m.id == nil || m.oldValue == nil {
  35236. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  35237. }
  35238. oldValue, err := m.oldValue(ctx)
  35239. if err != nil {
  35240. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  35241. }
  35242. return oldValue.AccountBalance, nil
  35243. }
  35244. // AddAccountBalance adds u to the "account_balance" field.
  35245. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  35246. if m.addaccount_balance != nil {
  35247. *m.addaccount_balance += u
  35248. } else {
  35249. m.addaccount_balance = &u
  35250. }
  35251. }
  35252. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  35253. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  35254. v := m.addaccount_balance
  35255. if v == nil {
  35256. return
  35257. }
  35258. return *v, true
  35259. }
  35260. // ResetAccountBalance resets all changes to the "account_balance" field.
  35261. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  35262. m.account_balance = nil
  35263. m.addaccount_balance = nil
  35264. }
  35265. // SetConsumeToken sets the "consume_token" field.
  35266. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  35267. m.consume_token = &u
  35268. m.addconsume_token = nil
  35269. }
  35270. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  35271. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  35272. v := m.consume_token
  35273. if v == nil {
  35274. return
  35275. }
  35276. return *v, true
  35277. }
  35278. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  35279. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35281. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  35282. if !m.op.Is(OpUpdateOne) {
  35283. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  35284. }
  35285. if m.id == nil || m.oldValue == nil {
  35286. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  35287. }
  35288. oldValue, err := m.oldValue(ctx)
  35289. if err != nil {
  35290. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  35291. }
  35292. return oldValue.ConsumeToken, nil
  35293. }
  35294. // AddConsumeToken adds u to the "consume_token" field.
  35295. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  35296. if m.addconsume_token != nil {
  35297. *m.addconsume_token += u
  35298. } else {
  35299. m.addconsume_token = &u
  35300. }
  35301. }
  35302. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  35303. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  35304. v := m.addconsume_token
  35305. if v == nil {
  35306. return
  35307. }
  35308. return *v, true
  35309. }
  35310. // ResetConsumeToken resets all changes to the "consume_token" field.
  35311. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  35312. m.consume_token = nil
  35313. m.addconsume_token = nil
  35314. }
  35315. // SetActiveUser sets the "active_user" field.
  35316. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  35317. m.active_user = &u
  35318. m.addactive_user = nil
  35319. }
  35320. // ActiveUser returns the value of the "active_user" field in the mutation.
  35321. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  35322. v := m.active_user
  35323. if v == nil {
  35324. return
  35325. }
  35326. return *v, true
  35327. }
  35328. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  35329. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35331. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  35332. if !m.op.Is(OpUpdateOne) {
  35333. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  35334. }
  35335. if m.id == nil || m.oldValue == nil {
  35336. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  35337. }
  35338. oldValue, err := m.oldValue(ctx)
  35339. if err != nil {
  35340. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  35341. }
  35342. return oldValue.ActiveUser, nil
  35343. }
  35344. // AddActiveUser adds u to the "active_user" field.
  35345. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  35346. if m.addactive_user != nil {
  35347. *m.addactive_user += u
  35348. } else {
  35349. m.addactive_user = &u
  35350. }
  35351. }
  35352. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  35353. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  35354. v := m.addactive_user
  35355. if v == nil {
  35356. return
  35357. }
  35358. return *v, true
  35359. }
  35360. // ResetActiveUser resets all changes to the "active_user" field.
  35361. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  35362. m.active_user = nil
  35363. m.addactive_user = nil
  35364. }
  35365. // SetNewUser sets the "new_user" field.
  35366. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  35367. m.new_user = &i
  35368. m.addnew_user = nil
  35369. }
  35370. // NewUser returns the value of the "new_user" field in the mutation.
  35371. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  35372. v := m.new_user
  35373. if v == nil {
  35374. return
  35375. }
  35376. return *v, true
  35377. }
  35378. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  35379. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35381. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  35382. if !m.op.Is(OpUpdateOne) {
  35383. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  35384. }
  35385. if m.id == nil || m.oldValue == nil {
  35386. return v, errors.New("OldNewUser requires an ID field in the mutation")
  35387. }
  35388. oldValue, err := m.oldValue(ctx)
  35389. if err != nil {
  35390. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  35391. }
  35392. return oldValue.NewUser, nil
  35393. }
  35394. // AddNewUser adds i to the "new_user" field.
  35395. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  35396. if m.addnew_user != nil {
  35397. *m.addnew_user += i
  35398. } else {
  35399. m.addnew_user = &i
  35400. }
  35401. }
  35402. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  35403. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  35404. v := m.addnew_user
  35405. if v == nil {
  35406. return
  35407. }
  35408. return *v, true
  35409. }
  35410. // ResetNewUser resets all changes to the "new_user" field.
  35411. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  35412. m.new_user = nil
  35413. m.addnew_user = nil
  35414. }
  35415. // SetLabelDist sets the "label_dist" field.
  35416. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  35417. m.label_dist = &ctd
  35418. m.appendlabel_dist = nil
  35419. }
  35420. // LabelDist returns the value of the "label_dist" field in the mutation.
  35421. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  35422. v := m.label_dist
  35423. if v == nil {
  35424. return
  35425. }
  35426. return *v, true
  35427. }
  35428. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  35429. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  35430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35431. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  35432. if !m.op.Is(OpUpdateOne) {
  35433. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  35434. }
  35435. if m.id == nil || m.oldValue == nil {
  35436. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  35437. }
  35438. oldValue, err := m.oldValue(ctx)
  35439. if err != nil {
  35440. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  35441. }
  35442. return oldValue.LabelDist, nil
  35443. }
  35444. // AppendLabelDist adds ctd to the "label_dist" field.
  35445. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  35446. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  35447. }
  35448. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  35449. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  35450. if len(m.appendlabel_dist) == 0 {
  35451. return nil, false
  35452. }
  35453. return m.appendlabel_dist, true
  35454. }
  35455. // ResetLabelDist resets all changes to the "label_dist" field.
  35456. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  35457. m.label_dist = nil
  35458. m.appendlabel_dist = nil
  35459. }
  35460. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  35461. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  35462. m.predicates = append(m.predicates, ps...)
  35463. }
  35464. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  35465. // users can use type-assertion to append predicates that do not depend on any generated package.
  35466. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  35467. p := make([]predicate.UsageStatisticMonth, len(ps))
  35468. for i := range ps {
  35469. p[i] = ps[i]
  35470. }
  35471. m.Where(p...)
  35472. }
  35473. // Op returns the operation name.
  35474. func (m *UsageStatisticMonthMutation) Op() Op {
  35475. return m.op
  35476. }
  35477. // SetOp allows setting the mutation operation.
  35478. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  35479. m.op = op
  35480. }
  35481. // Type returns the node type of this mutation (UsageStatisticMonth).
  35482. func (m *UsageStatisticMonthMutation) Type() string {
  35483. return m.typ
  35484. }
  35485. // Fields returns all fields that were changed during this mutation. Note that in
  35486. // order to get all numeric fields that were incremented/decremented, call
  35487. // AddedFields().
  35488. func (m *UsageStatisticMonthMutation) Fields() []string {
  35489. fields := make([]string, 0, 17)
  35490. if m.created_at != nil {
  35491. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  35492. }
  35493. if m.updated_at != nil {
  35494. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  35495. }
  35496. if m.status != nil {
  35497. fields = append(fields, usagestatisticmonth.FieldStatus)
  35498. }
  35499. if m.deleted_at != nil {
  35500. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  35501. }
  35502. if m.addtime != nil {
  35503. fields = append(fields, usagestatisticmonth.FieldAddtime)
  35504. }
  35505. if m._type != nil {
  35506. fields = append(fields, usagestatisticmonth.FieldType)
  35507. }
  35508. if m.bot_id != nil {
  35509. fields = append(fields, usagestatisticmonth.FieldBotID)
  35510. }
  35511. if m.organization_id != nil {
  35512. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35513. }
  35514. if m.ai_response != nil {
  35515. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  35516. }
  35517. if m.sop_run != nil {
  35518. fields = append(fields, usagestatisticmonth.FieldSopRun)
  35519. }
  35520. if m.total_friend != nil {
  35521. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  35522. }
  35523. if m.total_group != nil {
  35524. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  35525. }
  35526. if m.account_balance != nil {
  35527. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  35528. }
  35529. if m.consume_token != nil {
  35530. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  35531. }
  35532. if m.active_user != nil {
  35533. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  35534. }
  35535. if m.new_user != nil {
  35536. fields = append(fields, usagestatisticmonth.FieldNewUser)
  35537. }
  35538. if m.label_dist != nil {
  35539. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  35540. }
  35541. return fields
  35542. }
  35543. // Field returns the value of a field with the given name. The second boolean
  35544. // return value indicates that this field was not set, or was not defined in the
  35545. // schema.
  35546. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  35547. switch name {
  35548. case usagestatisticmonth.FieldCreatedAt:
  35549. return m.CreatedAt()
  35550. case usagestatisticmonth.FieldUpdatedAt:
  35551. return m.UpdatedAt()
  35552. case usagestatisticmonth.FieldStatus:
  35553. return m.Status()
  35554. case usagestatisticmonth.FieldDeletedAt:
  35555. return m.DeletedAt()
  35556. case usagestatisticmonth.FieldAddtime:
  35557. return m.Addtime()
  35558. case usagestatisticmonth.FieldType:
  35559. return m.GetType()
  35560. case usagestatisticmonth.FieldBotID:
  35561. return m.BotID()
  35562. case usagestatisticmonth.FieldOrganizationID:
  35563. return m.OrganizationID()
  35564. case usagestatisticmonth.FieldAiResponse:
  35565. return m.AiResponse()
  35566. case usagestatisticmonth.FieldSopRun:
  35567. return m.SopRun()
  35568. case usagestatisticmonth.FieldTotalFriend:
  35569. return m.TotalFriend()
  35570. case usagestatisticmonth.FieldTotalGroup:
  35571. return m.TotalGroup()
  35572. case usagestatisticmonth.FieldAccountBalance:
  35573. return m.AccountBalance()
  35574. case usagestatisticmonth.FieldConsumeToken:
  35575. return m.ConsumeToken()
  35576. case usagestatisticmonth.FieldActiveUser:
  35577. return m.ActiveUser()
  35578. case usagestatisticmonth.FieldNewUser:
  35579. return m.NewUser()
  35580. case usagestatisticmonth.FieldLabelDist:
  35581. return m.LabelDist()
  35582. }
  35583. return nil, false
  35584. }
  35585. // OldField returns the old value of the field from the database. An error is
  35586. // returned if the mutation operation is not UpdateOne, or the query to the
  35587. // database failed.
  35588. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35589. switch name {
  35590. case usagestatisticmonth.FieldCreatedAt:
  35591. return m.OldCreatedAt(ctx)
  35592. case usagestatisticmonth.FieldUpdatedAt:
  35593. return m.OldUpdatedAt(ctx)
  35594. case usagestatisticmonth.FieldStatus:
  35595. return m.OldStatus(ctx)
  35596. case usagestatisticmonth.FieldDeletedAt:
  35597. return m.OldDeletedAt(ctx)
  35598. case usagestatisticmonth.FieldAddtime:
  35599. return m.OldAddtime(ctx)
  35600. case usagestatisticmonth.FieldType:
  35601. return m.OldType(ctx)
  35602. case usagestatisticmonth.FieldBotID:
  35603. return m.OldBotID(ctx)
  35604. case usagestatisticmonth.FieldOrganizationID:
  35605. return m.OldOrganizationID(ctx)
  35606. case usagestatisticmonth.FieldAiResponse:
  35607. return m.OldAiResponse(ctx)
  35608. case usagestatisticmonth.FieldSopRun:
  35609. return m.OldSopRun(ctx)
  35610. case usagestatisticmonth.FieldTotalFriend:
  35611. return m.OldTotalFriend(ctx)
  35612. case usagestatisticmonth.FieldTotalGroup:
  35613. return m.OldTotalGroup(ctx)
  35614. case usagestatisticmonth.FieldAccountBalance:
  35615. return m.OldAccountBalance(ctx)
  35616. case usagestatisticmonth.FieldConsumeToken:
  35617. return m.OldConsumeToken(ctx)
  35618. case usagestatisticmonth.FieldActiveUser:
  35619. return m.OldActiveUser(ctx)
  35620. case usagestatisticmonth.FieldNewUser:
  35621. return m.OldNewUser(ctx)
  35622. case usagestatisticmonth.FieldLabelDist:
  35623. return m.OldLabelDist(ctx)
  35624. }
  35625. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35626. }
  35627. // SetField sets the value of a field with the given name. It returns an error if
  35628. // the field is not defined in the schema, or if the type mismatched the field
  35629. // type.
  35630. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  35631. switch name {
  35632. case usagestatisticmonth.FieldCreatedAt:
  35633. v, ok := value.(time.Time)
  35634. if !ok {
  35635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35636. }
  35637. m.SetCreatedAt(v)
  35638. return nil
  35639. case usagestatisticmonth.FieldUpdatedAt:
  35640. v, ok := value.(time.Time)
  35641. if !ok {
  35642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35643. }
  35644. m.SetUpdatedAt(v)
  35645. return nil
  35646. case usagestatisticmonth.FieldStatus:
  35647. v, ok := value.(uint8)
  35648. if !ok {
  35649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35650. }
  35651. m.SetStatus(v)
  35652. return nil
  35653. case usagestatisticmonth.FieldDeletedAt:
  35654. v, ok := value.(time.Time)
  35655. if !ok {
  35656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35657. }
  35658. m.SetDeletedAt(v)
  35659. return nil
  35660. case usagestatisticmonth.FieldAddtime:
  35661. v, ok := value.(uint64)
  35662. if !ok {
  35663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35664. }
  35665. m.SetAddtime(v)
  35666. return nil
  35667. case usagestatisticmonth.FieldType:
  35668. v, ok := value.(int)
  35669. if !ok {
  35670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35671. }
  35672. m.SetType(v)
  35673. return nil
  35674. case usagestatisticmonth.FieldBotID:
  35675. v, ok := value.(string)
  35676. if !ok {
  35677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35678. }
  35679. m.SetBotID(v)
  35680. return nil
  35681. case usagestatisticmonth.FieldOrganizationID:
  35682. v, ok := value.(uint64)
  35683. if !ok {
  35684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35685. }
  35686. m.SetOrganizationID(v)
  35687. return nil
  35688. case usagestatisticmonth.FieldAiResponse:
  35689. v, ok := value.(uint64)
  35690. if !ok {
  35691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35692. }
  35693. m.SetAiResponse(v)
  35694. return nil
  35695. case usagestatisticmonth.FieldSopRun:
  35696. v, ok := value.(uint64)
  35697. if !ok {
  35698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35699. }
  35700. m.SetSopRun(v)
  35701. return nil
  35702. case usagestatisticmonth.FieldTotalFriend:
  35703. v, ok := value.(uint64)
  35704. if !ok {
  35705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35706. }
  35707. m.SetTotalFriend(v)
  35708. return nil
  35709. case usagestatisticmonth.FieldTotalGroup:
  35710. v, ok := value.(uint64)
  35711. if !ok {
  35712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35713. }
  35714. m.SetTotalGroup(v)
  35715. return nil
  35716. case usagestatisticmonth.FieldAccountBalance:
  35717. v, ok := value.(uint64)
  35718. if !ok {
  35719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35720. }
  35721. m.SetAccountBalance(v)
  35722. return nil
  35723. case usagestatisticmonth.FieldConsumeToken:
  35724. v, ok := value.(uint64)
  35725. if !ok {
  35726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35727. }
  35728. m.SetConsumeToken(v)
  35729. return nil
  35730. case usagestatisticmonth.FieldActiveUser:
  35731. v, ok := value.(uint64)
  35732. if !ok {
  35733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35734. }
  35735. m.SetActiveUser(v)
  35736. return nil
  35737. case usagestatisticmonth.FieldNewUser:
  35738. v, ok := value.(int64)
  35739. if !ok {
  35740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35741. }
  35742. m.SetNewUser(v)
  35743. return nil
  35744. case usagestatisticmonth.FieldLabelDist:
  35745. v, ok := value.([]custom_types.LabelDist)
  35746. if !ok {
  35747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35748. }
  35749. m.SetLabelDist(v)
  35750. return nil
  35751. }
  35752. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  35753. }
  35754. // AddedFields returns all numeric fields that were incremented/decremented during
  35755. // this mutation.
  35756. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  35757. var fields []string
  35758. if m.addstatus != nil {
  35759. fields = append(fields, usagestatisticmonth.FieldStatus)
  35760. }
  35761. if m.addaddtime != nil {
  35762. fields = append(fields, usagestatisticmonth.FieldAddtime)
  35763. }
  35764. if m.add_type != nil {
  35765. fields = append(fields, usagestatisticmonth.FieldType)
  35766. }
  35767. if m.addorganization_id != nil {
  35768. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35769. }
  35770. if m.addai_response != nil {
  35771. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  35772. }
  35773. if m.addsop_run != nil {
  35774. fields = append(fields, usagestatisticmonth.FieldSopRun)
  35775. }
  35776. if m.addtotal_friend != nil {
  35777. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  35778. }
  35779. if m.addtotal_group != nil {
  35780. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  35781. }
  35782. if m.addaccount_balance != nil {
  35783. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  35784. }
  35785. if m.addconsume_token != nil {
  35786. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  35787. }
  35788. if m.addactive_user != nil {
  35789. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  35790. }
  35791. if m.addnew_user != nil {
  35792. fields = append(fields, usagestatisticmonth.FieldNewUser)
  35793. }
  35794. return fields
  35795. }
  35796. // AddedField returns the numeric value that was incremented/decremented on a field
  35797. // with the given name. The second boolean return value indicates that this field
  35798. // was not set, or was not defined in the schema.
  35799. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  35800. switch name {
  35801. case usagestatisticmonth.FieldStatus:
  35802. return m.AddedStatus()
  35803. case usagestatisticmonth.FieldAddtime:
  35804. return m.AddedAddtime()
  35805. case usagestatisticmonth.FieldType:
  35806. return m.AddedType()
  35807. case usagestatisticmonth.FieldOrganizationID:
  35808. return m.AddedOrganizationID()
  35809. case usagestatisticmonth.FieldAiResponse:
  35810. return m.AddedAiResponse()
  35811. case usagestatisticmonth.FieldSopRun:
  35812. return m.AddedSopRun()
  35813. case usagestatisticmonth.FieldTotalFriend:
  35814. return m.AddedTotalFriend()
  35815. case usagestatisticmonth.FieldTotalGroup:
  35816. return m.AddedTotalGroup()
  35817. case usagestatisticmonth.FieldAccountBalance:
  35818. return m.AddedAccountBalance()
  35819. case usagestatisticmonth.FieldConsumeToken:
  35820. return m.AddedConsumeToken()
  35821. case usagestatisticmonth.FieldActiveUser:
  35822. return m.AddedActiveUser()
  35823. case usagestatisticmonth.FieldNewUser:
  35824. return m.AddedNewUser()
  35825. }
  35826. return nil, false
  35827. }
  35828. // AddField adds the value to the field with the given name. It returns an error if
  35829. // the field is not defined in the schema, or if the type mismatched the field
  35830. // type.
  35831. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  35832. switch name {
  35833. case usagestatisticmonth.FieldStatus:
  35834. v, ok := value.(int8)
  35835. if !ok {
  35836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35837. }
  35838. m.AddStatus(v)
  35839. return nil
  35840. case usagestatisticmonth.FieldAddtime:
  35841. v, ok := value.(int64)
  35842. if !ok {
  35843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35844. }
  35845. m.AddAddtime(v)
  35846. return nil
  35847. case usagestatisticmonth.FieldType:
  35848. v, ok := value.(int)
  35849. if !ok {
  35850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35851. }
  35852. m.AddType(v)
  35853. return nil
  35854. case usagestatisticmonth.FieldOrganizationID:
  35855. v, ok := value.(int64)
  35856. if !ok {
  35857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35858. }
  35859. m.AddOrganizationID(v)
  35860. return nil
  35861. case usagestatisticmonth.FieldAiResponse:
  35862. v, ok := value.(int64)
  35863. if !ok {
  35864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35865. }
  35866. m.AddAiResponse(v)
  35867. return nil
  35868. case usagestatisticmonth.FieldSopRun:
  35869. v, ok := value.(int64)
  35870. if !ok {
  35871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35872. }
  35873. m.AddSopRun(v)
  35874. return nil
  35875. case usagestatisticmonth.FieldTotalFriend:
  35876. v, ok := value.(int64)
  35877. if !ok {
  35878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35879. }
  35880. m.AddTotalFriend(v)
  35881. return nil
  35882. case usagestatisticmonth.FieldTotalGroup:
  35883. v, ok := value.(int64)
  35884. if !ok {
  35885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35886. }
  35887. m.AddTotalGroup(v)
  35888. return nil
  35889. case usagestatisticmonth.FieldAccountBalance:
  35890. v, ok := value.(int64)
  35891. if !ok {
  35892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35893. }
  35894. m.AddAccountBalance(v)
  35895. return nil
  35896. case usagestatisticmonth.FieldConsumeToken:
  35897. v, ok := value.(int64)
  35898. if !ok {
  35899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35900. }
  35901. m.AddConsumeToken(v)
  35902. return nil
  35903. case usagestatisticmonth.FieldActiveUser:
  35904. v, ok := value.(int64)
  35905. if !ok {
  35906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35907. }
  35908. m.AddActiveUser(v)
  35909. return nil
  35910. case usagestatisticmonth.FieldNewUser:
  35911. v, ok := value.(int64)
  35912. if !ok {
  35913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35914. }
  35915. m.AddNewUser(v)
  35916. return nil
  35917. }
  35918. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  35919. }
  35920. // ClearedFields returns all nullable fields that were cleared during this
  35921. // mutation.
  35922. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  35923. var fields []string
  35924. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  35925. fields = append(fields, usagestatisticmonth.FieldStatus)
  35926. }
  35927. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  35928. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  35929. }
  35930. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  35931. fields = append(fields, usagestatisticmonth.FieldBotID)
  35932. }
  35933. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  35934. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  35935. }
  35936. return fields
  35937. }
  35938. // FieldCleared returns a boolean indicating if a field with the given name was
  35939. // cleared in this mutation.
  35940. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  35941. _, ok := m.clearedFields[name]
  35942. return ok
  35943. }
  35944. // ClearField clears the value of the field with the given name. It returns an
  35945. // error if the field is not defined in the schema.
  35946. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  35947. switch name {
  35948. case usagestatisticmonth.FieldStatus:
  35949. m.ClearStatus()
  35950. return nil
  35951. case usagestatisticmonth.FieldDeletedAt:
  35952. m.ClearDeletedAt()
  35953. return nil
  35954. case usagestatisticmonth.FieldBotID:
  35955. m.ClearBotID()
  35956. return nil
  35957. case usagestatisticmonth.FieldOrganizationID:
  35958. m.ClearOrganizationID()
  35959. return nil
  35960. }
  35961. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  35962. }
  35963. // ResetField resets all changes in the mutation for the field with the given name.
  35964. // It returns an error if the field is not defined in the schema.
  35965. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  35966. switch name {
  35967. case usagestatisticmonth.FieldCreatedAt:
  35968. m.ResetCreatedAt()
  35969. return nil
  35970. case usagestatisticmonth.FieldUpdatedAt:
  35971. m.ResetUpdatedAt()
  35972. return nil
  35973. case usagestatisticmonth.FieldStatus:
  35974. m.ResetStatus()
  35975. return nil
  35976. case usagestatisticmonth.FieldDeletedAt:
  35977. m.ResetDeletedAt()
  35978. return nil
  35979. case usagestatisticmonth.FieldAddtime:
  35980. m.ResetAddtime()
  35981. return nil
  35982. case usagestatisticmonth.FieldType:
  35983. m.ResetType()
  35984. return nil
  35985. case usagestatisticmonth.FieldBotID:
  35986. m.ResetBotID()
  35987. return nil
  35988. case usagestatisticmonth.FieldOrganizationID:
  35989. m.ResetOrganizationID()
  35990. return nil
  35991. case usagestatisticmonth.FieldAiResponse:
  35992. m.ResetAiResponse()
  35993. return nil
  35994. case usagestatisticmonth.FieldSopRun:
  35995. m.ResetSopRun()
  35996. return nil
  35997. case usagestatisticmonth.FieldTotalFriend:
  35998. m.ResetTotalFriend()
  35999. return nil
  36000. case usagestatisticmonth.FieldTotalGroup:
  36001. m.ResetTotalGroup()
  36002. return nil
  36003. case usagestatisticmonth.FieldAccountBalance:
  36004. m.ResetAccountBalance()
  36005. return nil
  36006. case usagestatisticmonth.FieldConsumeToken:
  36007. m.ResetConsumeToken()
  36008. return nil
  36009. case usagestatisticmonth.FieldActiveUser:
  36010. m.ResetActiveUser()
  36011. return nil
  36012. case usagestatisticmonth.FieldNewUser:
  36013. m.ResetNewUser()
  36014. return nil
  36015. case usagestatisticmonth.FieldLabelDist:
  36016. m.ResetLabelDist()
  36017. return nil
  36018. }
  36019. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  36020. }
  36021. // AddedEdges returns all edge names that were set/added in this mutation.
  36022. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  36023. edges := make([]string, 0, 0)
  36024. return edges
  36025. }
  36026. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36027. // name in this mutation.
  36028. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  36029. return nil
  36030. }
  36031. // RemovedEdges returns all edge names that were removed in this mutation.
  36032. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  36033. edges := make([]string, 0, 0)
  36034. return edges
  36035. }
  36036. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36037. // the given name in this mutation.
  36038. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  36039. return nil
  36040. }
  36041. // ClearedEdges returns all edge names that were cleared in this mutation.
  36042. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  36043. edges := make([]string, 0, 0)
  36044. return edges
  36045. }
  36046. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36047. // was cleared in this mutation.
  36048. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  36049. return false
  36050. }
  36051. // ClearEdge clears the value of the edge with the given name. It returns an error
  36052. // if that edge is not defined in the schema.
  36053. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  36054. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  36055. }
  36056. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36057. // It returns an error if the edge is not defined in the schema.
  36058. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  36059. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  36060. }
  36061. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  36062. type UsageTotalMutation struct {
  36063. config
  36064. op Op
  36065. typ string
  36066. id *uint64
  36067. created_at *time.Time
  36068. updated_at *time.Time
  36069. status *uint8
  36070. addstatus *int8
  36071. _type *int
  36072. add_type *int
  36073. bot_id *string
  36074. total_tokens *uint64
  36075. addtotal_tokens *int64
  36076. start_index *uint64
  36077. addstart_index *int64
  36078. end_index *uint64
  36079. addend_index *int64
  36080. organization_id *uint64
  36081. addorganization_id *int64
  36082. clearedFields map[string]struct{}
  36083. done bool
  36084. oldValue func(context.Context) (*UsageTotal, error)
  36085. predicates []predicate.UsageTotal
  36086. }
  36087. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  36088. // usagetotalOption allows management of the mutation configuration using functional options.
  36089. type usagetotalOption func(*UsageTotalMutation)
  36090. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  36091. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  36092. m := &UsageTotalMutation{
  36093. config: c,
  36094. op: op,
  36095. typ: TypeUsageTotal,
  36096. clearedFields: make(map[string]struct{}),
  36097. }
  36098. for _, opt := range opts {
  36099. opt(m)
  36100. }
  36101. return m
  36102. }
  36103. // withUsageTotalID sets the ID field of the mutation.
  36104. func withUsageTotalID(id uint64) usagetotalOption {
  36105. return func(m *UsageTotalMutation) {
  36106. var (
  36107. err error
  36108. once sync.Once
  36109. value *UsageTotal
  36110. )
  36111. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  36112. once.Do(func() {
  36113. if m.done {
  36114. err = errors.New("querying old values post mutation is not allowed")
  36115. } else {
  36116. value, err = m.Client().UsageTotal.Get(ctx, id)
  36117. }
  36118. })
  36119. return value, err
  36120. }
  36121. m.id = &id
  36122. }
  36123. }
  36124. // withUsageTotal sets the old UsageTotal of the mutation.
  36125. func withUsageTotal(node *UsageTotal) usagetotalOption {
  36126. return func(m *UsageTotalMutation) {
  36127. m.oldValue = func(context.Context) (*UsageTotal, error) {
  36128. return node, nil
  36129. }
  36130. m.id = &node.ID
  36131. }
  36132. }
  36133. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36134. // executed in a transaction (ent.Tx), a transactional client is returned.
  36135. func (m UsageTotalMutation) Client() *Client {
  36136. client := &Client{config: m.config}
  36137. client.init()
  36138. return client
  36139. }
  36140. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36141. // it returns an error otherwise.
  36142. func (m UsageTotalMutation) Tx() (*Tx, error) {
  36143. if _, ok := m.driver.(*txDriver); !ok {
  36144. return nil, errors.New("ent: mutation is not running in a transaction")
  36145. }
  36146. tx := &Tx{config: m.config}
  36147. tx.init()
  36148. return tx, nil
  36149. }
  36150. // SetID sets the value of the id field. Note that this
  36151. // operation is only accepted on creation of UsageTotal entities.
  36152. func (m *UsageTotalMutation) SetID(id uint64) {
  36153. m.id = &id
  36154. }
  36155. // ID returns the ID value in the mutation. Note that the ID is only available
  36156. // if it was provided to the builder or after it was returned from the database.
  36157. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  36158. if m.id == nil {
  36159. return
  36160. }
  36161. return *m.id, true
  36162. }
  36163. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36164. // That means, if the mutation is applied within a transaction with an isolation level such
  36165. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36166. // or updated by the mutation.
  36167. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  36168. switch {
  36169. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36170. id, exists := m.ID()
  36171. if exists {
  36172. return []uint64{id}, nil
  36173. }
  36174. fallthrough
  36175. case m.op.Is(OpUpdate | OpDelete):
  36176. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  36177. default:
  36178. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36179. }
  36180. }
  36181. // SetCreatedAt sets the "created_at" field.
  36182. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  36183. m.created_at = &t
  36184. }
  36185. // CreatedAt returns the value of the "created_at" field in the mutation.
  36186. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  36187. v := m.created_at
  36188. if v == nil {
  36189. return
  36190. }
  36191. return *v, true
  36192. }
  36193. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  36194. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36196. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36197. if !m.op.Is(OpUpdateOne) {
  36198. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36199. }
  36200. if m.id == nil || m.oldValue == nil {
  36201. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36202. }
  36203. oldValue, err := m.oldValue(ctx)
  36204. if err != nil {
  36205. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36206. }
  36207. return oldValue.CreatedAt, nil
  36208. }
  36209. // ResetCreatedAt resets all changes to the "created_at" field.
  36210. func (m *UsageTotalMutation) ResetCreatedAt() {
  36211. m.created_at = nil
  36212. }
  36213. // SetUpdatedAt sets the "updated_at" field.
  36214. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  36215. m.updated_at = &t
  36216. }
  36217. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36218. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  36219. v := m.updated_at
  36220. if v == nil {
  36221. return
  36222. }
  36223. return *v, true
  36224. }
  36225. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  36226. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36228. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36229. if !m.op.Is(OpUpdateOne) {
  36230. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36231. }
  36232. if m.id == nil || m.oldValue == nil {
  36233. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36234. }
  36235. oldValue, err := m.oldValue(ctx)
  36236. if err != nil {
  36237. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36238. }
  36239. return oldValue.UpdatedAt, nil
  36240. }
  36241. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36242. func (m *UsageTotalMutation) ResetUpdatedAt() {
  36243. m.updated_at = nil
  36244. }
  36245. // SetStatus sets the "status" field.
  36246. func (m *UsageTotalMutation) SetStatus(u uint8) {
  36247. m.status = &u
  36248. m.addstatus = nil
  36249. }
  36250. // Status returns the value of the "status" field in the mutation.
  36251. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  36252. v := m.status
  36253. if v == nil {
  36254. return
  36255. }
  36256. return *v, true
  36257. }
  36258. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  36259. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36261. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36262. if !m.op.Is(OpUpdateOne) {
  36263. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36264. }
  36265. if m.id == nil || m.oldValue == nil {
  36266. return v, errors.New("OldStatus requires an ID field in the mutation")
  36267. }
  36268. oldValue, err := m.oldValue(ctx)
  36269. if err != nil {
  36270. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36271. }
  36272. return oldValue.Status, nil
  36273. }
  36274. // AddStatus adds u to the "status" field.
  36275. func (m *UsageTotalMutation) AddStatus(u int8) {
  36276. if m.addstatus != nil {
  36277. *m.addstatus += u
  36278. } else {
  36279. m.addstatus = &u
  36280. }
  36281. }
  36282. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36283. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  36284. v := m.addstatus
  36285. if v == nil {
  36286. return
  36287. }
  36288. return *v, true
  36289. }
  36290. // ClearStatus clears the value of the "status" field.
  36291. func (m *UsageTotalMutation) ClearStatus() {
  36292. m.status = nil
  36293. m.addstatus = nil
  36294. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  36295. }
  36296. // StatusCleared returns if the "status" field was cleared in this mutation.
  36297. func (m *UsageTotalMutation) StatusCleared() bool {
  36298. _, ok := m.clearedFields[usagetotal.FieldStatus]
  36299. return ok
  36300. }
  36301. // ResetStatus resets all changes to the "status" field.
  36302. func (m *UsageTotalMutation) ResetStatus() {
  36303. m.status = nil
  36304. m.addstatus = nil
  36305. delete(m.clearedFields, usagetotal.FieldStatus)
  36306. }
  36307. // SetType sets the "type" field.
  36308. func (m *UsageTotalMutation) SetType(i int) {
  36309. m._type = &i
  36310. m.add_type = nil
  36311. }
  36312. // GetType returns the value of the "type" field in the mutation.
  36313. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  36314. v := m._type
  36315. if v == nil {
  36316. return
  36317. }
  36318. return *v, true
  36319. }
  36320. // OldType returns the old "type" field's value of the UsageTotal entity.
  36321. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36323. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  36324. if !m.op.Is(OpUpdateOne) {
  36325. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36326. }
  36327. if m.id == nil || m.oldValue == nil {
  36328. return v, errors.New("OldType requires an ID field in the mutation")
  36329. }
  36330. oldValue, err := m.oldValue(ctx)
  36331. if err != nil {
  36332. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36333. }
  36334. return oldValue.Type, nil
  36335. }
  36336. // AddType adds i to the "type" field.
  36337. func (m *UsageTotalMutation) AddType(i int) {
  36338. if m.add_type != nil {
  36339. *m.add_type += i
  36340. } else {
  36341. m.add_type = &i
  36342. }
  36343. }
  36344. // AddedType returns the value that was added to the "type" field in this mutation.
  36345. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  36346. v := m.add_type
  36347. if v == nil {
  36348. return
  36349. }
  36350. return *v, true
  36351. }
  36352. // ClearType clears the value of the "type" field.
  36353. func (m *UsageTotalMutation) ClearType() {
  36354. m._type = nil
  36355. m.add_type = nil
  36356. m.clearedFields[usagetotal.FieldType] = struct{}{}
  36357. }
  36358. // TypeCleared returns if the "type" field was cleared in this mutation.
  36359. func (m *UsageTotalMutation) TypeCleared() bool {
  36360. _, ok := m.clearedFields[usagetotal.FieldType]
  36361. return ok
  36362. }
  36363. // ResetType resets all changes to the "type" field.
  36364. func (m *UsageTotalMutation) ResetType() {
  36365. m._type = nil
  36366. m.add_type = nil
  36367. delete(m.clearedFields, usagetotal.FieldType)
  36368. }
  36369. // SetBotID sets the "bot_id" field.
  36370. func (m *UsageTotalMutation) SetBotID(s string) {
  36371. m.bot_id = &s
  36372. }
  36373. // BotID returns the value of the "bot_id" field in the mutation.
  36374. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  36375. v := m.bot_id
  36376. if v == nil {
  36377. return
  36378. }
  36379. return *v, true
  36380. }
  36381. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  36382. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36384. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  36385. if !m.op.Is(OpUpdateOne) {
  36386. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36387. }
  36388. if m.id == nil || m.oldValue == nil {
  36389. return v, errors.New("OldBotID requires an ID field in the mutation")
  36390. }
  36391. oldValue, err := m.oldValue(ctx)
  36392. if err != nil {
  36393. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36394. }
  36395. return oldValue.BotID, nil
  36396. }
  36397. // ResetBotID resets all changes to the "bot_id" field.
  36398. func (m *UsageTotalMutation) ResetBotID() {
  36399. m.bot_id = nil
  36400. }
  36401. // SetTotalTokens sets the "total_tokens" field.
  36402. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  36403. m.total_tokens = &u
  36404. m.addtotal_tokens = nil
  36405. }
  36406. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  36407. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  36408. v := m.total_tokens
  36409. if v == nil {
  36410. return
  36411. }
  36412. return *v, true
  36413. }
  36414. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  36415. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36417. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  36418. if !m.op.Is(OpUpdateOne) {
  36419. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  36420. }
  36421. if m.id == nil || m.oldValue == nil {
  36422. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  36423. }
  36424. oldValue, err := m.oldValue(ctx)
  36425. if err != nil {
  36426. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  36427. }
  36428. return oldValue.TotalTokens, nil
  36429. }
  36430. // AddTotalTokens adds u to the "total_tokens" field.
  36431. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  36432. if m.addtotal_tokens != nil {
  36433. *m.addtotal_tokens += u
  36434. } else {
  36435. m.addtotal_tokens = &u
  36436. }
  36437. }
  36438. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  36439. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  36440. v := m.addtotal_tokens
  36441. if v == nil {
  36442. return
  36443. }
  36444. return *v, true
  36445. }
  36446. // ClearTotalTokens clears the value of the "total_tokens" field.
  36447. func (m *UsageTotalMutation) ClearTotalTokens() {
  36448. m.total_tokens = nil
  36449. m.addtotal_tokens = nil
  36450. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  36451. }
  36452. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  36453. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  36454. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  36455. return ok
  36456. }
  36457. // ResetTotalTokens resets all changes to the "total_tokens" field.
  36458. func (m *UsageTotalMutation) ResetTotalTokens() {
  36459. m.total_tokens = nil
  36460. m.addtotal_tokens = nil
  36461. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  36462. }
  36463. // SetStartIndex sets the "start_index" field.
  36464. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  36465. m.start_index = &u
  36466. m.addstart_index = nil
  36467. }
  36468. // StartIndex returns the value of the "start_index" field in the mutation.
  36469. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  36470. v := m.start_index
  36471. if v == nil {
  36472. return
  36473. }
  36474. return *v, true
  36475. }
  36476. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  36477. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36479. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  36480. if !m.op.Is(OpUpdateOne) {
  36481. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  36482. }
  36483. if m.id == nil || m.oldValue == nil {
  36484. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  36485. }
  36486. oldValue, err := m.oldValue(ctx)
  36487. if err != nil {
  36488. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  36489. }
  36490. return oldValue.StartIndex, nil
  36491. }
  36492. // AddStartIndex adds u to the "start_index" field.
  36493. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  36494. if m.addstart_index != nil {
  36495. *m.addstart_index += u
  36496. } else {
  36497. m.addstart_index = &u
  36498. }
  36499. }
  36500. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  36501. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  36502. v := m.addstart_index
  36503. if v == nil {
  36504. return
  36505. }
  36506. return *v, true
  36507. }
  36508. // ClearStartIndex clears the value of the "start_index" field.
  36509. func (m *UsageTotalMutation) ClearStartIndex() {
  36510. m.start_index = nil
  36511. m.addstart_index = nil
  36512. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  36513. }
  36514. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  36515. func (m *UsageTotalMutation) StartIndexCleared() bool {
  36516. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  36517. return ok
  36518. }
  36519. // ResetStartIndex resets all changes to the "start_index" field.
  36520. func (m *UsageTotalMutation) ResetStartIndex() {
  36521. m.start_index = nil
  36522. m.addstart_index = nil
  36523. delete(m.clearedFields, usagetotal.FieldStartIndex)
  36524. }
  36525. // SetEndIndex sets the "end_index" field.
  36526. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  36527. m.end_index = &u
  36528. m.addend_index = nil
  36529. }
  36530. // EndIndex returns the value of the "end_index" field in the mutation.
  36531. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  36532. v := m.end_index
  36533. if v == nil {
  36534. return
  36535. }
  36536. return *v, true
  36537. }
  36538. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  36539. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36541. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  36542. if !m.op.Is(OpUpdateOne) {
  36543. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  36544. }
  36545. if m.id == nil || m.oldValue == nil {
  36546. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  36547. }
  36548. oldValue, err := m.oldValue(ctx)
  36549. if err != nil {
  36550. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  36551. }
  36552. return oldValue.EndIndex, nil
  36553. }
  36554. // AddEndIndex adds u to the "end_index" field.
  36555. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  36556. if m.addend_index != nil {
  36557. *m.addend_index += u
  36558. } else {
  36559. m.addend_index = &u
  36560. }
  36561. }
  36562. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  36563. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  36564. v := m.addend_index
  36565. if v == nil {
  36566. return
  36567. }
  36568. return *v, true
  36569. }
  36570. // ClearEndIndex clears the value of the "end_index" field.
  36571. func (m *UsageTotalMutation) ClearEndIndex() {
  36572. m.end_index = nil
  36573. m.addend_index = nil
  36574. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  36575. }
  36576. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  36577. func (m *UsageTotalMutation) EndIndexCleared() bool {
  36578. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  36579. return ok
  36580. }
  36581. // ResetEndIndex resets all changes to the "end_index" field.
  36582. func (m *UsageTotalMutation) ResetEndIndex() {
  36583. m.end_index = nil
  36584. m.addend_index = nil
  36585. delete(m.clearedFields, usagetotal.FieldEndIndex)
  36586. }
  36587. // SetOrganizationID sets the "organization_id" field.
  36588. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  36589. m.organization_id = &u
  36590. m.addorganization_id = nil
  36591. }
  36592. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36593. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  36594. v := m.organization_id
  36595. if v == nil {
  36596. return
  36597. }
  36598. return *v, true
  36599. }
  36600. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  36601. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  36602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36603. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36604. if !m.op.Is(OpUpdateOne) {
  36605. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36606. }
  36607. if m.id == nil || m.oldValue == nil {
  36608. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36609. }
  36610. oldValue, err := m.oldValue(ctx)
  36611. if err != nil {
  36612. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36613. }
  36614. return oldValue.OrganizationID, nil
  36615. }
  36616. // AddOrganizationID adds u to the "organization_id" field.
  36617. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  36618. if m.addorganization_id != nil {
  36619. *m.addorganization_id += u
  36620. } else {
  36621. m.addorganization_id = &u
  36622. }
  36623. }
  36624. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36625. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  36626. v := m.addorganization_id
  36627. if v == nil {
  36628. return
  36629. }
  36630. return *v, true
  36631. }
  36632. // ClearOrganizationID clears the value of the "organization_id" field.
  36633. func (m *UsageTotalMutation) ClearOrganizationID() {
  36634. m.organization_id = nil
  36635. m.addorganization_id = nil
  36636. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  36637. }
  36638. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36639. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  36640. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  36641. return ok
  36642. }
  36643. // ResetOrganizationID resets all changes to the "organization_id" field.
  36644. func (m *UsageTotalMutation) ResetOrganizationID() {
  36645. m.organization_id = nil
  36646. m.addorganization_id = nil
  36647. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  36648. }
  36649. // Where appends a list predicates to the UsageTotalMutation builder.
  36650. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  36651. m.predicates = append(m.predicates, ps...)
  36652. }
  36653. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  36654. // users can use type-assertion to append predicates that do not depend on any generated package.
  36655. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  36656. p := make([]predicate.UsageTotal, len(ps))
  36657. for i := range ps {
  36658. p[i] = ps[i]
  36659. }
  36660. m.Where(p...)
  36661. }
  36662. // Op returns the operation name.
  36663. func (m *UsageTotalMutation) Op() Op {
  36664. return m.op
  36665. }
  36666. // SetOp allows setting the mutation operation.
  36667. func (m *UsageTotalMutation) SetOp(op Op) {
  36668. m.op = op
  36669. }
  36670. // Type returns the node type of this mutation (UsageTotal).
  36671. func (m *UsageTotalMutation) Type() string {
  36672. return m.typ
  36673. }
  36674. // Fields returns all fields that were changed during this mutation. Note that in
  36675. // order to get all numeric fields that were incremented/decremented, call
  36676. // AddedFields().
  36677. func (m *UsageTotalMutation) Fields() []string {
  36678. fields := make([]string, 0, 9)
  36679. if m.created_at != nil {
  36680. fields = append(fields, usagetotal.FieldCreatedAt)
  36681. }
  36682. if m.updated_at != nil {
  36683. fields = append(fields, usagetotal.FieldUpdatedAt)
  36684. }
  36685. if m.status != nil {
  36686. fields = append(fields, usagetotal.FieldStatus)
  36687. }
  36688. if m._type != nil {
  36689. fields = append(fields, usagetotal.FieldType)
  36690. }
  36691. if m.bot_id != nil {
  36692. fields = append(fields, usagetotal.FieldBotID)
  36693. }
  36694. if m.total_tokens != nil {
  36695. fields = append(fields, usagetotal.FieldTotalTokens)
  36696. }
  36697. if m.start_index != nil {
  36698. fields = append(fields, usagetotal.FieldStartIndex)
  36699. }
  36700. if m.end_index != nil {
  36701. fields = append(fields, usagetotal.FieldEndIndex)
  36702. }
  36703. if m.organization_id != nil {
  36704. fields = append(fields, usagetotal.FieldOrganizationID)
  36705. }
  36706. return fields
  36707. }
  36708. // Field returns the value of a field with the given name. The second boolean
  36709. // return value indicates that this field was not set, or was not defined in the
  36710. // schema.
  36711. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  36712. switch name {
  36713. case usagetotal.FieldCreatedAt:
  36714. return m.CreatedAt()
  36715. case usagetotal.FieldUpdatedAt:
  36716. return m.UpdatedAt()
  36717. case usagetotal.FieldStatus:
  36718. return m.Status()
  36719. case usagetotal.FieldType:
  36720. return m.GetType()
  36721. case usagetotal.FieldBotID:
  36722. return m.BotID()
  36723. case usagetotal.FieldTotalTokens:
  36724. return m.TotalTokens()
  36725. case usagetotal.FieldStartIndex:
  36726. return m.StartIndex()
  36727. case usagetotal.FieldEndIndex:
  36728. return m.EndIndex()
  36729. case usagetotal.FieldOrganizationID:
  36730. return m.OrganizationID()
  36731. }
  36732. return nil, false
  36733. }
  36734. // OldField returns the old value of the field from the database. An error is
  36735. // returned if the mutation operation is not UpdateOne, or the query to the
  36736. // database failed.
  36737. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36738. switch name {
  36739. case usagetotal.FieldCreatedAt:
  36740. return m.OldCreatedAt(ctx)
  36741. case usagetotal.FieldUpdatedAt:
  36742. return m.OldUpdatedAt(ctx)
  36743. case usagetotal.FieldStatus:
  36744. return m.OldStatus(ctx)
  36745. case usagetotal.FieldType:
  36746. return m.OldType(ctx)
  36747. case usagetotal.FieldBotID:
  36748. return m.OldBotID(ctx)
  36749. case usagetotal.FieldTotalTokens:
  36750. return m.OldTotalTokens(ctx)
  36751. case usagetotal.FieldStartIndex:
  36752. return m.OldStartIndex(ctx)
  36753. case usagetotal.FieldEndIndex:
  36754. return m.OldEndIndex(ctx)
  36755. case usagetotal.FieldOrganizationID:
  36756. return m.OldOrganizationID(ctx)
  36757. }
  36758. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  36759. }
  36760. // SetField sets the value of a field with the given name. It returns an error if
  36761. // the field is not defined in the schema, or if the type mismatched the field
  36762. // type.
  36763. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  36764. switch name {
  36765. case usagetotal.FieldCreatedAt:
  36766. v, ok := value.(time.Time)
  36767. if !ok {
  36768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36769. }
  36770. m.SetCreatedAt(v)
  36771. return nil
  36772. case usagetotal.FieldUpdatedAt:
  36773. v, ok := value.(time.Time)
  36774. if !ok {
  36775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36776. }
  36777. m.SetUpdatedAt(v)
  36778. return nil
  36779. case usagetotal.FieldStatus:
  36780. v, ok := value.(uint8)
  36781. if !ok {
  36782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36783. }
  36784. m.SetStatus(v)
  36785. return nil
  36786. case usagetotal.FieldType:
  36787. v, ok := value.(int)
  36788. if !ok {
  36789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36790. }
  36791. m.SetType(v)
  36792. return nil
  36793. case usagetotal.FieldBotID:
  36794. v, ok := value.(string)
  36795. if !ok {
  36796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36797. }
  36798. m.SetBotID(v)
  36799. return nil
  36800. case usagetotal.FieldTotalTokens:
  36801. v, ok := value.(uint64)
  36802. if !ok {
  36803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36804. }
  36805. m.SetTotalTokens(v)
  36806. return nil
  36807. case usagetotal.FieldStartIndex:
  36808. v, ok := value.(uint64)
  36809. if !ok {
  36810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36811. }
  36812. m.SetStartIndex(v)
  36813. return nil
  36814. case usagetotal.FieldEndIndex:
  36815. v, ok := value.(uint64)
  36816. if !ok {
  36817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36818. }
  36819. m.SetEndIndex(v)
  36820. return nil
  36821. case usagetotal.FieldOrganizationID:
  36822. v, ok := value.(uint64)
  36823. if !ok {
  36824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36825. }
  36826. m.SetOrganizationID(v)
  36827. return nil
  36828. }
  36829. return fmt.Errorf("unknown UsageTotal field %s", name)
  36830. }
  36831. // AddedFields returns all numeric fields that were incremented/decremented during
  36832. // this mutation.
  36833. func (m *UsageTotalMutation) AddedFields() []string {
  36834. var fields []string
  36835. if m.addstatus != nil {
  36836. fields = append(fields, usagetotal.FieldStatus)
  36837. }
  36838. if m.add_type != nil {
  36839. fields = append(fields, usagetotal.FieldType)
  36840. }
  36841. if m.addtotal_tokens != nil {
  36842. fields = append(fields, usagetotal.FieldTotalTokens)
  36843. }
  36844. if m.addstart_index != nil {
  36845. fields = append(fields, usagetotal.FieldStartIndex)
  36846. }
  36847. if m.addend_index != nil {
  36848. fields = append(fields, usagetotal.FieldEndIndex)
  36849. }
  36850. if m.addorganization_id != nil {
  36851. fields = append(fields, usagetotal.FieldOrganizationID)
  36852. }
  36853. return fields
  36854. }
  36855. // AddedField returns the numeric value that was incremented/decremented on a field
  36856. // with the given name. The second boolean return value indicates that this field
  36857. // was not set, or was not defined in the schema.
  36858. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  36859. switch name {
  36860. case usagetotal.FieldStatus:
  36861. return m.AddedStatus()
  36862. case usagetotal.FieldType:
  36863. return m.AddedType()
  36864. case usagetotal.FieldTotalTokens:
  36865. return m.AddedTotalTokens()
  36866. case usagetotal.FieldStartIndex:
  36867. return m.AddedStartIndex()
  36868. case usagetotal.FieldEndIndex:
  36869. return m.AddedEndIndex()
  36870. case usagetotal.FieldOrganizationID:
  36871. return m.AddedOrganizationID()
  36872. }
  36873. return nil, false
  36874. }
  36875. // AddField adds the value to the field with the given name. It returns an error if
  36876. // the field is not defined in the schema, or if the type mismatched the field
  36877. // type.
  36878. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  36879. switch name {
  36880. case usagetotal.FieldStatus:
  36881. v, ok := value.(int8)
  36882. if !ok {
  36883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36884. }
  36885. m.AddStatus(v)
  36886. return nil
  36887. case usagetotal.FieldType:
  36888. v, ok := value.(int)
  36889. if !ok {
  36890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36891. }
  36892. m.AddType(v)
  36893. return nil
  36894. case usagetotal.FieldTotalTokens:
  36895. v, ok := value.(int64)
  36896. if !ok {
  36897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36898. }
  36899. m.AddTotalTokens(v)
  36900. return nil
  36901. case usagetotal.FieldStartIndex:
  36902. v, ok := value.(int64)
  36903. if !ok {
  36904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36905. }
  36906. m.AddStartIndex(v)
  36907. return nil
  36908. case usagetotal.FieldEndIndex:
  36909. v, ok := value.(int64)
  36910. if !ok {
  36911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36912. }
  36913. m.AddEndIndex(v)
  36914. return nil
  36915. case usagetotal.FieldOrganizationID:
  36916. v, ok := value.(int64)
  36917. if !ok {
  36918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36919. }
  36920. m.AddOrganizationID(v)
  36921. return nil
  36922. }
  36923. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  36924. }
  36925. // ClearedFields returns all nullable fields that were cleared during this
  36926. // mutation.
  36927. func (m *UsageTotalMutation) ClearedFields() []string {
  36928. var fields []string
  36929. if m.FieldCleared(usagetotal.FieldStatus) {
  36930. fields = append(fields, usagetotal.FieldStatus)
  36931. }
  36932. if m.FieldCleared(usagetotal.FieldType) {
  36933. fields = append(fields, usagetotal.FieldType)
  36934. }
  36935. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  36936. fields = append(fields, usagetotal.FieldTotalTokens)
  36937. }
  36938. if m.FieldCleared(usagetotal.FieldStartIndex) {
  36939. fields = append(fields, usagetotal.FieldStartIndex)
  36940. }
  36941. if m.FieldCleared(usagetotal.FieldEndIndex) {
  36942. fields = append(fields, usagetotal.FieldEndIndex)
  36943. }
  36944. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  36945. fields = append(fields, usagetotal.FieldOrganizationID)
  36946. }
  36947. return fields
  36948. }
  36949. // FieldCleared returns a boolean indicating if a field with the given name was
  36950. // cleared in this mutation.
  36951. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  36952. _, ok := m.clearedFields[name]
  36953. return ok
  36954. }
  36955. // ClearField clears the value of the field with the given name. It returns an
  36956. // error if the field is not defined in the schema.
  36957. func (m *UsageTotalMutation) ClearField(name string) error {
  36958. switch name {
  36959. case usagetotal.FieldStatus:
  36960. m.ClearStatus()
  36961. return nil
  36962. case usagetotal.FieldType:
  36963. m.ClearType()
  36964. return nil
  36965. case usagetotal.FieldTotalTokens:
  36966. m.ClearTotalTokens()
  36967. return nil
  36968. case usagetotal.FieldStartIndex:
  36969. m.ClearStartIndex()
  36970. return nil
  36971. case usagetotal.FieldEndIndex:
  36972. m.ClearEndIndex()
  36973. return nil
  36974. case usagetotal.FieldOrganizationID:
  36975. m.ClearOrganizationID()
  36976. return nil
  36977. }
  36978. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  36979. }
  36980. // ResetField resets all changes in the mutation for the field with the given name.
  36981. // It returns an error if the field is not defined in the schema.
  36982. func (m *UsageTotalMutation) ResetField(name string) error {
  36983. switch name {
  36984. case usagetotal.FieldCreatedAt:
  36985. m.ResetCreatedAt()
  36986. return nil
  36987. case usagetotal.FieldUpdatedAt:
  36988. m.ResetUpdatedAt()
  36989. return nil
  36990. case usagetotal.FieldStatus:
  36991. m.ResetStatus()
  36992. return nil
  36993. case usagetotal.FieldType:
  36994. m.ResetType()
  36995. return nil
  36996. case usagetotal.FieldBotID:
  36997. m.ResetBotID()
  36998. return nil
  36999. case usagetotal.FieldTotalTokens:
  37000. m.ResetTotalTokens()
  37001. return nil
  37002. case usagetotal.FieldStartIndex:
  37003. m.ResetStartIndex()
  37004. return nil
  37005. case usagetotal.FieldEndIndex:
  37006. m.ResetEndIndex()
  37007. return nil
  37008. case usagetotal.FieldOrganizationID:
  37009. m.ResetOrganizationID()
  37010. return nil
  37011. }
  37012. return fmt.Errorf("unknown UsageTotal field %s", name)
  37013. }
  37014. // AddedEdges returns all edge names that were set/added in this mutation.
  37015. func (m *UsageTotalMutation) AddedEdges() []string {
  37016. edges := make([]string, 0, 0)
  37017. return edges
  37018. }
  37019. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37020. // name in this mutation.
  37021. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  37022. return nil
  37023. }
  37024. // RemovedEdges returns all edge names that were removed in this mutation.
  37025. func (m *UsageTotalMutation) RemovedEdges() []string {
  37026. edges := make([]string, 0, 0)
  37027. return edges
  37028. }
  37029. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37030. // the given name in this mutation.
  37031. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  37032. return nil
  37033. }
  37034. // ClearedEdges returns all edge names that were cleared in this mutation.
  37035. func (m *UsageTotalMutation) ClearedEdges() []string {
  37036. edges := make([]string, 0, 0)
  37037. return edges
  37038. }
  37039. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37040. // was cleared in this mutation.
  37041. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  37042. return false
  37043. }
  37044. // ClearEdge clears the value of the edge with the given name. It returns an error
  37045. // if that edge is not defined in the schema.
  37046. func (m *UsageTotalMutation) ClearEdge(name string) error {
  37047. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  37048. }
  37049. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37050. // It returns an error if the edge is not defined in the schema.
  37051. func (m *UsageTotalMutation) ResetEdge(name string) error {
  37052. return fmt.Errorf("unknown UsageTotal edge %s", name)
  37053. }
  37054. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  37055. type WhatsappMutation struct {
  37056. config
  37057. op Op
  37058. typ string
  37059. id *uint64
  37060. created_at *time.Time
  37061. updated_at *time.Time
  37062. status *uint8
  37063. addstatus *int8
  37064. deleted_at *time.Time
  37065. wa_id *string
  37066. wa_name *string
  37067. callback *string
  37068. account *string
  37069. cc *string
  37070. phone *string
  37071. cc_phone *string
  37072. phone_name *string
  37073. phone_status *int8
  37074. addphone_status *int8
  37075. organization_id *uint64
  37076. addorganization_id *int64
  37077. api_base *string
  37078. api_key *string
  37079. allow_list *[]string
  37080. appendallow_list []string
  37081. group_allow_list *[]string
  37082. appendgroup_allow_list []string
  37083. block_list *[]string
  37084. appendblock_list []string
  37085. group_block_list *[]string
  37086. appendgroup_block_list []string
  37087. clearedFields map[string]struct{}
  37088. agent *uint64
  37089. clearedagent bool
  37090. done bool
  37091. oldValue func(context.Context) (*Whatsapp, error)
  37092. predicates []predicate.Whatsapp
  37093. }
  37094. var _ ent.Mutation = (*WhatsappMutation)(nil)
  37095. // whatsappOption allows management of the mutation configuration using functional options.
  37096. type whatsappOption func(*WhatsappMutation)
  37097. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  37098. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  37099. m := &WhatsappMutation{
  37100. config: c,
  37101. op: op,
  37102. typ: TypeWhatsapp,
  37103. clearedFields: make(map[string]struct{}),
  37104. }
  37105. for _, opt := range opts {
  37106. opt(m)
  37107. }
  37108. return m
  37109. }
  37110. // withWhatsappID sets the ID field of the mutation.
  37111. func withWhatsappID(id uint64) whatsappOption {
  37112. return func(m *WhatsappMutation) {
  37113. var (
  37114. err error
  37115. once sync.Once
  37116. value *Whatsapp
  37117. )
  37118. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  37119. once.Do(func() {
  37120. if m.done {
  37121. err = errors.New("querying old values post mutation is not allowed")
  37122. } else {
  37123. value, err = m.Client().Whatsapp.Get(ctx, id)
  37124. }
  37125. })
  37126. return value, err
  37127. }
  37128. m.id = &id
  37129. }
  37130. }
  37131. // withWhatsapp sets the old Whatsapp of the mutation.
  37132. func withWhatsapp(node *Whatsapp) whatsappOption {
  37133. return func(m *WhatsappMutation) {
  37134. m.oldValue = func(context.Context) (*Whatsapp, error) {
  37135. return node, nil
  37136. }
  37137. m.id = &node.ID
  37138. }
  37139. }
  37140. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37141. // executed in a transaction (ent.Tx), a transactional client is returned.
  37142. func (m WhatsappMutation) Client() *Client {
  37143. client := &Client{config: m.config}
  37144. client.init()
  37145. return client
  37146. }
  37147. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37148. // it returns an error otherwise.
  37149. func (m WhatsappMutation) Tx() (*Tx, error) {
  37150. if _, ok := m.driver.(*txDriver); !ok {
  37151. return nil, errors.New("ent: mutation is not running in a transaction")
  37152. }
  37153. tx := &Tx{config: m.config}
  37154. tx.init()
  37155. return tx, nil
  37156. }
  37157. // SetID sets the value of the id field. Note that this
  37158. // operation is only accepted on creation of Whatsapp entities.
  37159. func (m *WhatsappMutation) SetID(id uint64) {
  37160. m.id = &id
  37161. }
  37162. // ID returns the ID value in the mutation. Note that the ID is only available
  37163. // if it was provided to the builder or after it was returned from the database.
  37164. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  37165. if m.id == nil {
  37166. return
  37167. }
  37168. return *m.id, true
  37169. }
  37170. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37171. // That means, if the mutation is applied within a transaction with an isolation level such
  37172. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37173. // or updated by the mutation.
  37174. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  37175. switch {
  37176. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37177. id, exists := m.ID()
  37178. if exists {
  37179. return []uint64{id}, nil
  37180. }
  37181. fallthrough
  37182. case m.op.Is(OpUpdate | OpDelete):
  37183. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  37184. default:
  37185. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37186. }
  37187. }
  37188. // SetCreatedAt sets the "created_at" field.
  37189. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  37190. m.created_at = &t
  37191. }
  37192. // CreatedAt returns the value of the "created_at" field in the mutation.
  37193. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  37194. v := m.created_at
  37195. if v == nil {
  37196. return
  37197. }
  37198. return *v, true
  37199. }
  37200. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  37201. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37203. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37204. if !m.op.Is(OpUpdateOne) {
  37205. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37206. }
  37207. if m.id == nil || m.oldValue == nil {
  37208. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37209. }
  37210. oldValue, err := m.oldValue(ctx)
  37211. if err != nil {
  37212. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37213. }
  37214. return oldValue.CreatedAt, nil
  37215. }
  37216. // ResetCreatedAt resets all changes to the "created_at" field.
  37217. func (m *WhatsappMutation) ResetCreatedAt() {
  37218. m.created_at = nil
  37219. }
  37220. // SetUpdatedAt sets the "updated_at" field.
  37221. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  37222. m.updated_at = &t
  37223. }
  37224. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37225. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  37226. v := m.updated_at
  37227. if v == nil {
  37228. return
  37229. }
  37230. return *v, true
  37231. }
  37232. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  37233. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37235. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37236. if !m.op.Is(OpUpdateOne) {
  37237. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37238. }
  37239. if m.id == nil || m.oldValue == nil {
  37240. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37241. }
  37242. oldValue, err := m.oldValue(ctx)
  37243. if err != nil {
  37244. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37245. }
  37246. return oldValue.UpdatedAt, nil
  37247. }
  37248. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37249. func (m *WhatsappMutation) ResetUpdatedAt() {
  37250. m.updated_at = nil
  37251. }
  37252. // SetStatus sets the "status" field.
  37253. func (m *WhatsappMutation) SetStatus(u uint8) {
  37254. m.status = &u
  37255. m.addstatus = nil
  37256. }
  37257. // Status returns the value of the "status" field in the mutation.
  37258. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  37259. v := m.status
  37260. if v == nil {
  37261. return
  37262. }
  37263. return *v, true
  37264. }
  37265. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  37266. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37268. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37269. if !m.op.Is(OpUpdateOne) {
  37270. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37271. }
  37272. if m.id == nil || m.oldValue == nil {
  37273. return v, errors.New("OldStatus requires an ID field in the mutation")
  37274. }
  37275. oldValue, err := m.oldValue(ctx)
  37276. if err != nil {
  37277. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37278. }
  37279. return oldValue.Status, nil
  37280. }
  37281. // AddStatus adds u to the "status" field.
  37282. func (m *WhatsappMutation) AddStatus(u int8) {
  37283. if m.addstatus != nil {
  37284. *m.addstatus += u
  37285. } else {
  37286. m.addstatus = &u
  37287. }
  37288. }
  37289. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37290. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  37291. v := m.addstatus
  37292. if v == nil {
  37293. return
  37294. }
  37295. return *v, true
  37296. }
  37297. // ClearStatus clears the value of the "status" field.
  37298. func (m *WhatsappMutation) ClearStatus() {
  37299. m.status = nil
  37300. m.addstatus = nil
  37301. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  37302. }
  37303. // StatusCleared returns if the "status" field was cleared in this mutation.
  37304. func (m *WhatsappMutation) StatusCleared() bool {
  37305. _, ok := m.clearedFields[whatsapp.FieldStatus]
  37306. return ok
  37307. }
  37308. // ResetStatus resets all changes to the "status" field.
  37309. func (m *WhatsappMutation) ResetStatus() {
  37310. m.status = nil
  37311. m.addstatus = nil
  37312. delete(m.clearedFields, whatsapp.FieldStatus)
  37313. }
  37314. // SetDeletedAt sets the "deleted_at" field.
  37315. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  37316. m.deleted_at = &t
  37317. }
  37318. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37319. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  37320. v := m.deleted_at
  37321. if v == nil {
  37322. return
  37323. }
  37324. return *v, true
  37325. }
  37326. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  37327. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37329. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37330. if !m.op.Is(OpUpdateOne) {
  37331. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37332. }
  37333. if m.id == nil || m.oldValue == nil {
  37334. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37335. }
  37336. oldValue, err := m.oldValue(ctx)
  37337. if err != nil {
  37338. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37339. }
  37340. return oldValue.DeletedAt, nil
  37341. }
  37342. // ClearDeletedAt clears the value of the "deleted_at" field.
  37343. func (m *WhatsappMutation) ClearDeletedAt() {
  37344. m.deleted_at = nil
  37345. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  37346. }
  37347. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37348. func (m *WhatsappMutation) DeletedAtCleared() bool {
  37349. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  37350. return ok
  37351. }
  37352. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37353. func (m *WhatsappMutation) ResetDeletedAt() {
  37354. m.deleted_at = nil
  37355. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  37356. }
  37357. // SetWaID sets the "wa_id" field.
  37358. func (m *WhatsappMutation) SetWaID(s string) {
  37359. m.wa_id = &s
  37360. }
  37361. // WaID returns the value of the "wa_id" field in the mutation.
  37362. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  37363. v := m.wa_id
  37364. if v == nil {
  37365. return
  37366. }
  37367. return *v, true
  37368. }
  37369. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  37370. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37372. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  37373. if !m.op.Is(OpUpdateOne) {
  37374. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  37375. }
  37376. if m.id == nil || m.oldValue == nil {
  37377. return v, errors.New("OldWaID requires an ID field in the mutation")
  37378. }
  37379. oldValue, err := m.oldValue(ctx)
  37380. if err != nil {
  37381. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  37382. }
  37383. return oldValue.WaID, nil
  37384. }
  37385. // ClearWaID clears the value of the "wa_id" field.
  37386. func (m *WhatsappMutation) ClearWaID() {
  37387. m.wa_id = nil
  37388. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  37389. }
  37390. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  37391. func (m *WhatsappMutation) WaIDCleared() bool {
  37392. _, ok := m.clearedFields[whatsapp.FieldWaID]
  37393. return ok
  37394. }
  37395. // ResetWaID resets all changes to the "wa_id" field.
  37396. func (m *WhatsappMutation) ResetWaID() {
  37397. m.wa_id = nil
  37398. delete(m.clearedFields, whatsapp.FieldWaID)
  37399. }
  37400. // SetWaName sets the "wa_name" field.
  37401. func (m *WhatsappMutation) SetWaName(s string) {
  37402. m.wa_name = &s
  37403. }
  37404. // WaName returns the value of the "wa_name" field in the mutation.
  37405. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  37406. v := m.wa_name
  37407. if v == nil {
  37408. return
  37409. }
  37410. return *v, true
  37411. }
  37412. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  37413. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37415. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  37416. if !m.op.Is(OpUpdateOne) {
  37417. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  37418. }
  37419. if m.id == nil || m.oldValue == nil {
  37420. return v, errors.New("OldWaName requires an ID field in the mutation")
  37421. }
  37422. oldValue, err := m.oldValue(ctx)
  37423. if err != nil {
  37424. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  37425. }
  37426. return oldValue.WaName, nil
  37427. }
  37428. // ClearWaName clears the value of the "wa_name" field.
  37429. func (m *WhatsappMutation) ClearWaName() {
  37430. m.wa_name = nil
  37431. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  37432. }
  37433. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  37434. func (m *WhatsappMutation) WaNameCleared() bool {
  37435. _, ok := m.clearedFields[whatsapp.FieldWaName]
  37436. return ok
  37437. }
  37438. // ResetWaName resets all changes to the "wa_name" field.
  37439. func (m *WhatsappMutation) ResetWaName() {
  37440. m.wa_name = nil
  37441. delete(m.clearedFields, whatsapp.FieldWaName)
  37442. }
  37443. // SetCallback sets the "callback" field.
  37444. func (m *WhatsappMutation) SetCallback(s string) {
  37445. m.callback = &s
  37446. }
  37447. // Callback returns the value of the "callback" field in the mutation.
  37448. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  37449. v := m.callback
  37450. if v == nil {
  37451. return
  37452. }
  37453. return *v, true
  37454. }
  37455. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  37456. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37458. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  37459. if !m.op.Is(OpUpdateOne) {
  37460. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37461. }
  37462. if m.id == nil || m.oldValue == nil {
  37463. return v, errors.New("OldCallback requires an ID field in the mutation")
  37464. }
  37465. oldValue, err := m.oldValue(ctx)
  37466. if err != nil {
  37467. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37468. }
  37469. return oldValue.Callback, nil
  37470. }
  37471. // ClearCallback clears the value of the "callback" field.
  37472. func (m *WhatsappMutation) ClearCallback() {
  37473. m.callback = nil
  37474. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  37475. }
  37476. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  37477. func (m *WhatsappMutation) CallbackCleared() bool {
  37478. _, ok := m.clearedFields[whatsapp.FieldCallback]
  37479. return ok
  37480. }
  37481. // ResetCallback resets all changes to the "callback" field.
  37482. func (m *WhatsappMutation) ResetCallback() {
  37483. m.callback = nil
  37484. delete(m.clearedFields, whatsapp.FieldCallback)
  37485. }
  37486. // SetAgentID sets the "agent_id" field.
  37487. func (m *WhatsappMutation) SetAgentID(u uint64) {
  37488. m.agent = &u
  37489. }
  37490. // AgentID returns the value of the "agent_id" field in the mutation.
  37491. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  37492. v := m.agent
  37493. if v == nil {
  37494. return
  37495. }
  37496. return *v, true
  37497. }
  37498. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  37499. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37501. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  37502. if !m.op.Is(OpUpdateOne) {
  37503. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  37504. }
  37505. if m.id == nil || m.oldValue == nil {
  37506. return v, errors.New("OldAgentID requires an ID field in the mutation")
  37507. }
  37508. oldValue, err := m.oldValue(ctx)
  37509. if err != nil {
  37510. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  37511. }
  37512. return oldValue.AgentID, nil
  37513. }
  37514. // ResetAgentID resets all changes to the "agent_id" field.
  37515. func (m *WhatsappMutation) ResetAgentID() {
  37516. m.agent = nil
  37517. }
  37518. // SetAccount sets the "account" field.
  37519. func (m *WhatsappMutation) SetAccount(s string) {
  37520. m.account = &s
  37521. }
  37522. // Account returns the value of the "account" field in the mutation.
  37523. func (m *WhatsappMutation) Account() (r string, exists bool) {
  37524. v := m.account
  37525. if v == nil {
  37526. return
  37527. }
  37528. return *v, true
  37529. }
  37530. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  37531. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37533. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  37534. if !m.op.Is(OpUpdateOne) {
  37535. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37536. }
  37537. if m.id == nil || m.oldValue == nil {
  37538. return v, errors.New("OldAccount requires an ID field in the mutation")
  37539. }
  37540. oldValue, err := m.oldValue(ctx)
  37541. if err != nil {
  37542. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37543. }
  37544. return oldValue.Account, nil
  37545. }
  37546. // ClearAccount clears the value of the "account" field.
  37547. func (m *WhatsappMutation) ClearAccount() {
  37548. m.account = nil
  37549. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  37550. }
  37551. // AccountCleared returns if the "account" field was cleared in this mutation.
  37552. func (m *WhatsappMutation) AccountCleared() bool {
  37553. _, ok := m.clearedFields[whatsapp.FieldAccount]
  37554. return ok
  37555. }
  37556. // ResetAccount resets all changes to the "account" field.
  37557. func (m *WhatsappMutation) ResetAccount() {
  37558. m.account = nil
  37559. delete(m.clearedFields, whatsapp.FieldAccount)
  37560. }
  37561. // SetCc sets the "cc" field.
  37562. func (m *WhatsappMutation) SetCc(s string) {
  37563. m.cc = &s
  37564. }
  37565. // Cc returns the value of the "cc" field in the mutation.
  37566. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  37567. v := m.cc
  37568. if v == nil {
  37569. return
  37570. }
  37571. return *v, true
  37572. }
  37573. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  37574. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37576. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  37577. if !m.op.Is(OpUpdateOne) {
  37578. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  37579. }
  37580. if m.id == nil || m.oldValue == nil {
  37581. return v, errors.New("OldCc requires an ID field in the mutation")
  37582. }
  37583. oldValue, err := m.oldValue(ctx)
  37584. if err != nil {
  37585. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  37586. }
  37587. return oldValue.Cc, nil
  37588. }
  37589. // ResetCc resets all changes to the "cc" field.
  37590. func (m *WhatsappMutation) ResetCc() {
  37591. m.cc = nil
  37592. }
  37593. // SetPhone sets the "phone" field.
  37594. func (m *WhatsappMutation) SetPhone(s string) {
  37595. m.phone = &s
  37596. }
  37597. // Phone returns the value of the "phone" field in the mutation.
  37598. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  37599. v := m.phone
  37600. if v == nil {
  37601. return
  37602. }
  37603. return *v, true
  37604. }
  37605. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  37606. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37608. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  37609. if !m.op.Is(OpUpdateOne) {
  37610. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  37611. }
  37612. if m.id == nil || m.oldValue == nil {
  37613. return v, errors.New("OldPhone requires an ID field in the mutation")
  37614. }
  37615. oldValue, err := m.oldValue(ctx)
  37616. if err != nil {
  37617. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  37618. }
  37619. return oldValue.Phone, nil
  37620. }
  37621. // ResetPhone resets all changes to the "phone" field.
  37622. func (m *WhatsappMutation) ResetPhone() {
  37623. m.phone = nil
  37624. }
  37625. // SetCcPhone sets the "cc_phone" field.
  37626. func (m *WhatsappMutation) SetCcPhone(s string) {
  37627. m.cc_phone = &s
  37628. }
  37629. // CcPhone returns the value of the "cc_phone" field in the mutation.
  37630. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  37631. v := m.cc_phone
  37632. if v == nil {
  37633. return
  37634. }
  37635. return *v, true
  37636. }
  37637. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  37638. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37640. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  37641. if !m.op.Is(OpUpdateOne) {
  37642. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  37643. }
  37644. if m.id == nil || m.oldValue == nil {
  37645. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  37646. }
  37647. oldValue, err := m.oldValue(ctx)
  37648. if err != nil {
  37649. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  37650. }
  37651. return oldValue.CcPhone, nil
  37652. }
  37653. // ResetCcPhone resets all changes to the "cc_phone" field.
  37654. func (m *WhatsappMutation) ResetCcPhone() {
  37655. m.cc_phone = nil
  37656. }
  37657. // SetPhoneName sets the "phone_name" field.
  37658. func (m *WhatsappMutation) SetPhoneName(s string) {
  37659. m.phone_name = &s
  37660. }
  37661. // PhoneName returns the value of the "phone_name" field in the mutation.
  37662. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  37663. v := m.phone_name
  37664. if v == nil {
  37665. return
  37666. }
  37667. return *v, true
  37668. }
  37669. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  37670. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37672. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  37673. if !m.op.Is(OpUpdateOne) {
  37674. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  37675. }
  37676. if m.id == nil || m.oldValue == nil {
  37677. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  37678. }
  37679. oldValue, err := m.oldValue(ctx)
  37680. if err != nil {
  37681. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  37682. }
  37683. return oldValue.PhoneName, nil
  37684. }
  37685. // ResetPhoneName resets all changes to the "phone_name" field.
  37686. func (m *WhatsappMutation) ResetPhoneName() {
  37687. m.phone_name = nil
  37688. }
  37689. // SetPhoneStatus sets the "phone_status" field.
  37690. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  37691. m.phone_status = &i
  37692. m.addphone_status = nil
  37693. }
  37694. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  37695. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  37696. v := m.phone_status
  37697. if v == nil {
  37698. return
  37699. }
  37700. return *v, true
  37701. }
  37702. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  37703. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37705. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  37706. if !m.op.Is(OpUpdateOne) {
  37707. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  37708. }
  37709. if m.id == nil || m.oldValue == nil {
  37710. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  37711. }
  37712. oldValue, err := m.oldValue(ctx)
  37713. if err != nil {
  37714. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  37715. }
  37716. return oldValue.PhoneStatus, nil
  37717. }
  37718. // AddPhoneStatus adds i to the "phone_status" field.
  37719. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  37720. if m.addphone_status != nil {
  37721. *m.addphone_status += i
  37722. } else {
  37723. m.addphone_status = &i
  37724. }
  37725. }
  37726. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  37727. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  37728. v := m.addphone_status
  37729. if v == nil {
  37730. return
  37731. }
  37732. return *v, true
  37733. }
  37734. // ResetPhoneStatus resets all changes to the "phone_status" field.
  37735. func (m *WhatsappMutation) ResetPhoneStatus() {
  37736. m.phone_status = nil
  37737. m.addphone_status = nil
  37738. }
  37739. // SetOrganizationID sets the "organization_id" field.
  37740. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  37741. m.organization_id = &u
  37742. m.addorganization_id = nil
  37743. }
  37744. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37745. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  37746. v := m.organization_id
  37747. if v == nil {
  37748. return
  37749. }
  37750. return *v, true
  37751. }
  37752. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  37753. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37755. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37756. if !m.op.Is(OpUpdateOne) {
  37757. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37758. }
  37759. if m.id == nil || m.oldValue == nil {
  37760. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37761. }
  37762. oldValue, err := m.oldValue(ctx)
  37763. if err != nil {
  37764. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37765. }
  37766. return oldValue.OrganizationID, nil
  37767. }
  37768. // AddOrganizationID adds u to the "organization_id" field.
  37769. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  37770. if m.addorganization_id != nil {
  37771. *m.addorganization_id += u
  37772. } else {
  37773. m.addorganization_id = &u
  37774. }
  37775. }
  37776. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37777. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  37778. v := m.addorganization_id
  37779. if v == nil {
  37780. return
  37781. }
  37782. return *v, true
  37783. }
  37784. // ClearOrganizationID clears the value of the "organization_id" field.
  37785. func (m *WhatsappMutation) ClearOrganizationID() {
  37786. m.organization_id = nil
  37787. m.addorganization_id = nil
  37788. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  37789. }
  37790. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37791. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  37792. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  37793. return ok
  37794. }
  37795. // ResetOrganizationID resets all changes to the "organization_id" field.
  37796. func (m *WhatsappMutation) ResetOrganizationID() {
  37797. m.organization_id = nil
  37798. m.addorganization_id = nil
  37799. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  37800. }
  37801. // SetAPIBase sets the "api_base" field.
  37802. func (m *WhatsappMutation) SetAPIBase(s string) {
  37803. m.api_base = &s
  37804. }
  37805. // APIBase returns the value of the "api_base" field in the mutation.
  37806. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  37807. v := m.api_base
  37808. if v == nil {
  37809. return
  37810. }
  37811. return *v, true
  37812. }
  37813. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  37814. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37816. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  37817. if !m.op.Is(OpUpdateOne) {
  37818. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  37819. }
  37820. if m.id == nil || m.oldValue == nil {
  37821. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  37822. }
  37823. oldValue, err := m.oldValue(ctx)
  37824. if err != nil {
  37825. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  37826. }
  37827. return oldValue.APIBase, nil
  37828. }
  37829. // ClearAPIBase clears the value of the "api_base" field.
  37830. func (m *WhatsappMutation) ClearAPIBase() {
  37831. m.api_base = nil
  37832. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  37833. }
  37834. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  37835. func (m *WhatsappMutation) APIBaseCleared() bool {
  37836. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  37837. return ok
  37838. }
  37839. // ResetAPIBase resets all changes to the "api_base" field.
  37840. func (m *WhatsappMutation) ResetAPIBase() {
  37841. m.api_base = nil
  37842. delete(m.clearedFields, whatsapp.FieldAPIBase)
  37843. }
  37844. // SetAPIKey sets the "api_key" field.
  37845. func (m *WhatsappMutation) SetAPIKey(s string) {
  37846. m.api_key = &s
  37847. }
  37848. // APIKey returns the value of the "api_key" field in the mutation.
  37849. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  37850. v := m.api_key
  37851. if v == nil {
  37852. return
  37853. }
  37854. return *v, true
  37855. }
  37856. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  37857. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37859. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  37860. if !m.op.Is(OpUpdateOne) {
  37861. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  37862. }
  37863. if m.id == nil || m.oldValue == nil {
  37864. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  37865. }
  37866. oldValue, err := m.oldValue(ctx)
  37867. if err != nil {
  37868. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  37869. }
  37870. return oldValue.APIKey, nil
  37871. }
  37872. // ClearAPIKey clears the value of the "api_key" field.
  37873. func (m *WhatsappMutation) ClearAPIKey() {
  37874. m.api_key = nil
  37875. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  37876. }
  37877. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  37878. func (m *WhatsappMutation) APIKeyCleared() bool {
  37879. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  37880. return ok
  37881. }
  37882. // ResetAPIKey resets all changes to the "api_key" field.
  37883. func (m *WhatsappMutation) ResetAPIKey() {
  37884. m.api_key = nil
  37885. delete(m.clearedFields, whatsapp.FieldAPIKey)
  37886. }
  37887. // SetAllowList sets the "allow_list" field.
  37888. func (m *WhatsappMutation) SetAllowList(s []string) {
  37889. m.allow_list = &s
  37890. m.appendallow_list = nil
  37891. }
  37892. // AllowList returns the value of the "allow_list" field in the mutation.
  37893. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  37894. v := m.allow_list
  37895. if v == nil {
  37896. return
  37897. }
  37898. return *v, true
  37899. }
  37900. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  37901. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37903. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  37904. if !m.op.Is(OpUpdateOne) {
  37905. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  37906. }
  37907. if m.id == nil || m.oldValue == nil {
  37908. return v, errors.New("OldAllowList requires an ID field in the mutation")
  37909. }
  37910. oldValue, err := m.oldValue(ctx)
  37911. if err != nil {
  37912. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  37913. }
  37914. return oldValue.AllowList, nil
  37915. }
  37916. // AppendAllowList adds s to the "allow_list" field.
  37917. func (m *WhatsappMutation) AppendAllowList(s []string) {
  37918. m.appendallow_list = append(m.appendallow_list, s...)
  37919. }
  37920. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  37921. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  37922. if len(m.appendallow_list) == 0 {
  37923. return nil, false
  37924. }
  37925. return m.appendallow_list, true
  37926. }
  37927. // ClearAllowList clears the value of the "allow_list" field.
  37928. func (m *WhatsappMutation) ClearAllowList() {
  37929. m.allow_list = nil
  37930. m.appendallow_list = nil
  37931. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  37932. }
  37933. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  37934. func (m *WhatsappMutation) AllowListCleared() bool {
  37935. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  37936. return ok
  37937. }
  37938. // ResetAllowList resets all changes to the "allow_list" field.
  37939. func (m *WhatsappMutation) ResetAllowList() {
  37940. m.allow_list = nil
  37941. m.appendallow_list = nil
  37942. delete(m.clearedFields, whatsapp.FieldAllowList)
  37943. }
  37944. // SetGroupAllowList sets the "group_allow_list" field.
  37945. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  37946. m.group_allow_list = &s
  37947. m.appendgroup_allow_list = nil
  37948. }
  37949. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  37950. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  37951. v := m.group_allow_list
  37952. if v == nil {
  37953. return
  37954. }
  37955. return *v, true
  37956. }
  37957. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  37958. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  37959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37960. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  37961. if !m.op.Is(OpUpdateOne) {
  37962. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  37963. }
  37964. if m.id == nil || m.oldValue == nil {
  37965. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  37966. }
  37967. oldValue, err := m.oldValue(ctx)
  37968. if err != nil {
  37969. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  37970. }
  37971. return oldValue.GroupAllowList, nil
  37972. }
  37973. // AppendGroupAllowList adds s to the "group_allow_list" field.
  37974. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  37975. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  37976. }
  37977. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  37978. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  37979. if len(m.appendgroup_allow_list) == 0 {
  37980. return nil, false
  37981. }
  37982. return m.appendgroup_allow_list, true
  37983. }
  37984. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  37985. func (m *WhatsappMutation) ClearGroupAllowList() {
  37986. m.group_allow_list = nil
  37987. m.appendgroup_allow_list = nil
  37988. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  37989. }
  37990. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  37991. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  37992. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  37993. return ok
  37994. }
  37995. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  37996. func (m *WhatsappMutation) ResetGroupAllowList() {
  37997. m.group_allow_list = nil
  37998. m.appendgroup_allow_list = nil
  37999. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  38000. }
  38001. // SetBlockList sets the "block_list" field.
  38002. func (m *WhatsappMutation) SetBlockList(s []string) {
  38003. m.block_list = &s
  38004. m.appendblock_list = nil
  38005. }
  38006. // BlockList returns the value of the "block_list" field in the mutation.
  38007. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  38008. v := m.block_list
  38009. if v == nil {
  38010. return
  38011. }
  38012. return *v, true
  38013. }
  38014. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  38015. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38017. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38018. if !m.op.Is(OpUpdateOne) {
  38019. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38020. }
  38021. if m.id == nil || m.oldValue == nil {
  38022. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38023. }
  38024. oldValue, err := m.oldValue(ctx)
  38025. if err != nil {
  38026. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38027. }
  38028. return oldValue.BlockList, nil
  38029. }
  38030. // AppendBlockList adds s to the "block_list" field.
  38031. func (m *WhatsappMutation) AppendBlockList(s []string) {
  38032. m.appendblock_list = append(m.appendblock_list, s...)
  38033. }
  38034. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38035. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  38036. if len(m.appendblock_list) == 0 {
  38037. return nil, false
  38038. }
  38039. return m.appendblock_list, true
  38040. }
  38041. // ClearBlockList clears the value of the "block_list" field.
  38042. func (m *WhatsappMutation) ClearBlockList() {
  38043. m.block_list = nil
  38044. m.appendblock_list = nil
  38045. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  38046. }
  38047. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  38048. func (m *WhatsappMutation) BlockListCleared() bool {
  38049. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  38050. return ok
  38051. }
  38052. // ResetBlockList resets all changes to the "block_list" field.
  38053. func (m *WhatsappMutation) ResetBlockList() {
  38054. m.block_list = nil
  38055. m.appendblock_list = nil
  38056. delete(m.clearedFields, whatsapp.FieldBlockList)
  38057. }
  38058. // SetGroupBlockList sets the "group_block_list" field.
  38059. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  38060. m.group_block_list = &s
  38061. m.appendgroup_block_list = nil
  38062. }
  38063. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38064. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  38065. v := m.group_block_list
  38066. if v == nil {
  38067. return
  38068. }
  38069. return *v, true
  38070. }
  38071. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  38072. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  38073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38074. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38075. if !m.op.Is(OpUpdateOne) {
  38076. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38077. }
  38078. if m.id == nil || m.oldValue == nil {
  38079. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38080. }
  38081. oldValue, err := m.oldValue(ctx)
  38082. if err != nil {
  38083. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38084. }
  38085. return oldValue.GroupBlockList, nil
  38086. }
  38087. // AppendGroupBlockList adds s to the "group_block_list" field.
  38088. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  38089. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38090. }
  38091. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38092. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  38093. if len(m.appendgroup_block_list) == 0 {
  38094. return nil, false
  38095. }
  38096. return m.appendgroup_block_list, true
  38097. }
  38098. // ClearGroupBlockList clears the value of the "group_block_list" field.
  38099. func (m *WhatsappMutation) ClearGroupBlockList() {
  38100. m.group_block_list = nil
  38101. m.appendgroup_block_list = nil
  38102. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  38103. }
  38104. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  38105. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  38106. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  38107. return ok
  38108. }
  38109. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38110. func (m *WhatsappMutation) ResetGroupBlockList() {
  38111. m.group_block_list = nil
  38112. m.appendgroup_block_list = nil
  38113. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  38114. }
  38115. // ClearAgent clears the "agent" edge to the Agent entity.
  38116. func (m *WhatsappMutation) ClearAgent() {
  38117. m.clearedagent = true
  38118. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  38119. }
  38120. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38121. func (m *WhatsappMutation) AgentCleared() bool {
  38122. return m.clearedagent
  38123. }
  38124. // AgentIDs returns the "agent" edge IDs in the mutation.
  38125. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38126. // AgentID instead. It exists only for internal usage by the builders.
  38127. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  38128. if id := m.agent; id != nil {
  38129. ids = append(ids, *id)
  38130. }
  38131. return
  38132. }
  38133. // ResetAgent resets all changes to the "agent" edge.
  38134. func (m *WhatsappMutation) ResetAgent() {
  38135. m.agent = nil
  38136. m.clearedagent = false
  38137. }
  38138. // Where appends a list predicates to the WhatsappMutation builder.
  38139. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  38140. m.predicates = append(m.predicates, ps...)
  38141. }
  38142. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  38143. // users can use type-assertion to append predicates that do not depend on any generated package.
  38144. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  38145. p := make([]predicate.Whatsapp, len(ps))
  38146. for i := range ps {
  38147. p[i] = ps[i]
  38148. }
  38149. m.Where(p...)
  38150. }
  38151. // Op returns the operation name.
  38152. func (m *WhatsappMutation) Op() Op {
  38153. return m.op
  38154. }
  38155. // SetOp allows setting the mutation operation.
  38156. func (m *WhatsappMutation) SetOp(op Op) {
  38157. m.op = op
  38158. }
  38159. // Type returns the node type of this mutation (Whatsapp).
  38160. func (m *WhatsappMutation) Type() string {
  38161. return m.typ
  38162. }
  38163. // Fields returns all fields that were changed during this mutation. Note that in
  38164. // order to get all numeric fields that were incremented/decremented, call
  38165. // AddedFields().
  38166. func (m *WhatsappMutation) Fields() []string {
  38167. fields := make([]string, 0, 21)
  38168. if m.created_at != nil {
  38169. fields = append(fields, whatsapp.FieldCreatedAt)
  38170. }
  38171. if m.updated_at != nil {
  38172. fields = append(fields, whatsapp.FieldUpdatedAt)
  38173. }
  38174. if m.status != nil {
  38175. fields = append(fields, whatsapp.FieldStatus)
  38176. }
  38177. if m.deleted_at != nil {
  38178. fields = append(fields, whatsapp.FieldDeletedAt)
  38179. }
  38180. if m.wa_id != nil {
  38181. fields = append(fields, whatsapp.FieldWaID)
  38182. }
  38183. if m.wa_name != nil {
  38184. fields = append(fields, whatsapp.FieldWaName)
  38185. }
  38186. if m.callback != nil {
  38187. fields = append(fields, whatsapp.FieldCallback)
  38188. }
  38189. if m.agent != nil {
  38190. fields = append(fields, whatsapp.FieldAgentID)
  38191. }
  38192. if m.account != nil {
  38193. fields = append(fields, whatsapp.FieldAccount)
  38194. }
  38195. if m.cc != nil {
  38196. fields = append(fields, whatsapp.FieldCc)
  38197. }
  38198. if m.phone != nil {
  38199. fields = append(fields, whatsapp.FieldPhone)
  38200. }
  38201. if m.cc_phone != nil {
  38202. fields = append(fields, whatsapp.FieldCcPhone)
  38203. }
  38204. if m.phone_name != nil {
  38205. fields = append(fields, whatsapp.FieldPhoneName)
  38206. }
  38207. if m.phone_status != nil {
  38208. fields = append(fields, whatsapp.FieldPhoneStatus)
  38209. }
  38210. if m.organization_id != nil {
  38211. fields = append(fields, whatsapp.FieldOrganizationID)
  38212. }
  38213. if m.api_base != nil {
  38214. fields = append(fields, whatsapp.FieldAPIBase)
  38215. }
  38216. if m.api_key != nil {
  38217. fields = append(fields, whatsapp.FieldAPIKey)
  38218. }
  38219. if m.allow_list != nil {
  38220. fields = append(fields, whatsapp.FieldAllowList)
  38221. }
  38222. if m.group_allow_list != nil {
  38223. fields = append(fields, whatsapp.FieldGroupAllowList)
  38224. }
  38225. if m.block_list != nil {
  38226. fields = append(fields, whatsapp.FieldBlockList)
  38227. }
  38228. if m.group_block_list != nil {
  38229. fields = append(fields, whatsapp.FieldGroupBlockList)
  38230. }
  38231. return fields
  38232. }
  38233. // Field returns the value of a field with the given name. The second boolean
  38234. // return value indicates that this field was not set, or was not defined in the
  38235. // schema.
  38236. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  38237. switch name {
  38238. case whatsapp.FieldCreatedAt:
  38239. return m.CreatedAt()
  38240. case whatsapp.FieldUpdatedAt:
  38241. return m.UpdatedAt()
  38242. case whatsapp.FieldStatus:
  38243. return m.Status()
  38244. case whatsapp.FieldDeletedAt:
  38245. return m.DeletedAt()
  38246. case whatsapp.FieldWaID:
  38247. return m.WaID()
  38248. case whatsapp.FieldWaName:
  38249. return m.WaName()
  38250. case whatsapp.FieldCallback:
  38251. return m.Callback()
  38252. case whatsapp.FieldAgentID:
  38253. return m.AgentID()
  38254. case whatsapp.FieldAccount:
  38255. return m.Account()
  38256. case whatsapp.FieldCc:
  38257. return m.Cc()
  38258. case whatsapp.FieldPhone:
  38259. return m.Phone()
  38260. case whatsapp.FieldCcPhone:
  38261. return m.CcPhone()
  38262. case whatsapp.FieldPhoneName:
  38263. return m.PhoneName()
  38264. case whatsapp.FieldPhoneStatus:
  38265. return m.PhoneStatus()
  38266. case whatsapp.FieldOrganizationID:
  38267. return m.OrganizationID()
  38268. case whatsapp.FieldAPIBase:
  38269. return m.APIBase()
  38270. case whatsapp.FieldAPIKey:
  38271. return m.APIKey()
  38272. case whatsapp.FieldAllowList:
  38273. return m.AllowList()
  38274. case whatsapp.FieldGroupAllowList:
  38275. return m.GroupAllowList()
  38276. case whatsapp.FieldBlockList:
  38277. return m.BlockList()
  38278. case whatsapp.FieldGroupBlockList:
  38279. return m.GroupBlockList()
  38280. }
  38281. return nil, false
  38282. }
  38283. // OldField returns the old value of the field from the database. An error is
  38284. // returned if the mutation operation is not UpdateOne, or the query to the
  38285. // database failed.
  38286. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38287. switch name {
  38288. case whatsapp.FieldCreatedAt:
  38289. return m.OldCreatedAt(ctx)
  38290. case whatsapp.FieldUpdatedAt:
  38291. return m.OldUpdatedAt(ctx)
  38292. case whatsapp.FieldStatus:
  38293. return m.OldStatus(ctx)
  38294. case whatsapp.FieldDeletedAt:
  38295. return m.OldDeletedAt(ctx)
  38296. case whatsapp.FieldWaID:
  38297. return m.OldWaID(ctx)
  38298. case whatsapp.FieldWaName:
  38299. return m.OldWaName(ctx)
  38300. case whatsapp.FieldCallback:
  38301. return m.OldCallback(ctx)
  38302. case whatsapp.FieldAgentID:
  38303. return m.OldAgentID(ctx)
  38304. case whatsapp.FieldAccount:
  38305. return m.OldAccount(ctx)
  38306. case whatsapp.FieldCc:
  38307. return m.OldCc(ctx)
  38308. case whatsapp.FieldPhone:
  38309. return m.OldPhone(ctx)
  38310. case whatsapp.FieldCcPhone:
  38311. return m.OldCcPhone(ctx)
  38312. case whatsapp.FieldPhoneName:
  38313. return m.OldPhoneName(ctx)
  38314. case whatsapp.FieldPhoneStatus:
  38315. return m.OldPhoneStatus(ctx)
  38316. case whatsapp.FieldOrganizationID:
  38317. return m.OldOrganizationID(ctx)
  38318. case whatsapp.FieldAPIBase:
  38319. return m.OldAPIBase(ctx)
  38320. case whatsapp.FieldAPIKey:
  38321. return m.OldAPIKey(ctx)
  38322. case whatsapp.FieldAllowList:
  38323. return m.OldAllowList(ctx)
  38324. case whatsapp.FieldGroupAllowList:
  38325. return m.OldGroupAllowList(ctx)
  38326. case whatsapp.FieldBlockList:
  38327. return m.OldBlockList(ctx)
  38328. case whatsapp.FieldGroupBlockList:
  38329. return m.OldGroupBlockList(ctx)
  38330. }
  38331. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  38332. }
  38333. // SetField sets the value of a field with the given name. It returns an error if
  38334. // the field is not defined in the schema, or if the type mismatched the field
  38335. // type.
  38336. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  38337. switch name {
  38338. case whatsapp.FieldCreatedAt:
  38339. v, ok := value.(time.Time)
  38340. if !ok {
  38341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38342. }
  38343. m.SetCreatedAt(v)
  38344. return nil
  38345. case whatsapp.FieldUpdatedAt:
  38346. v, ok := value.(time.Time)
  38347. if !ok {
  38348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38349. }
  38350. m.SetUpdatedAt(v)
  38351. return nil
  38352. case whatsapp.FieldStatus:
  38353. v, ok := value.(uint8)
  38354. if !ok {
  38355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38356. }
  38357. m.SetStatus(v)
  38358. return nil
  38359. case whatsapp.FieldDeletedAt:
  38360. v, ok := value.(time.Time)
  38361. if !ok {
  38362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38363. }
  38364. m.SetDeletedAt(v)
  38365. return nil
  38366. case whatsapp.FieldWaID:
  38367. v, ok := value.(string)
  38368. if !ok {
  38369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38370. }
  38371. m.SetWaID(v)
  38372. return nil
  38373. case whatsapp.FieldWaName:
  38374. v, ok := value.(string)
  38375. if !ok {
  38376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38377. }
  38378. m.SetWaName(v)
  38379. return nil
  38380. case whatsapp.FieldCallback:
  38381. v, ok := value.(string)
  38382. if !ok {
  38383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38384. }
  38385. m.SetCallback(v)
  38386. return nil
  38387. case whatsapp.FieldAgentID:
  38388. v, ok := value.(uint64)
  38389. if !ok {
  38390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38391. }
  38392. m.SetAgentID(v)
  38393. return nil
  38394. case whatsapp.FieldAccount:
  38395. v, ok := value.(string)
  38396. if !ok {
  38397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38398. }
  38399. m.SetAccount(v)
  38400. return nil
  38401. case whatsapp.FieldCc:
  38402. v, ok := value.(string)
  38403. if !ok {
  38404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38405. }
  38406. m.SetCc(v)
  38407. return nil
  38408. case whatsapp.FieldPhone:
  38409. v, ok := value.(string)
  38410. if !ok {
  38411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38412. }
  38413. m.SetPhone(v)
  38414. return nil
  38415. case whatsapp.FieldCcPhone:
  38416. v, ok := value.(string)
  38417. if !ok {
  38418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38419. }
  38420. m.SetCcPhone(v)
  38421. return nil
  38422. case whatsapp.FieldPhoneName:
  38423. v, ok := value.(string)
  38424. if !ok {
  38425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38426. }
  38427. m.SetPhoneName(v)
  38428. return nil
  38429. case whatsapp.FieldPhoneStatus:
  38430. v, ok := value.(int8)
  38431. if !ok {
  38432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38433. }
  38434. m.SetPhoneStatus(v)
  38435. return nil
  38436. case whatsapp.FieldOrganizationID:
  38437. v, ok := value.(uint64)
  38438. if !ok {
  38439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38440. }
  38441. m.SetOrganizationID(v)
  38442. return nil
  38443. case whatsapp.FieldAPIBase:
  38444. v, ok := value.(string)
  38445. if !ok {
  38446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38447. }
  38448. m.SetAPIBase(v)
  38449. return nil
  38450. case whatsapp.FieldAPIKey:
  38451. v, ok := value.(string)
  38452. if !ok {
  38453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38454. }
  38455. m.SetAPIKey(v)
  38456. return nil
  38457. case whatsapp.FieldAllowList:
  38458. v, ok := value.([]string)
  38459. if !ok {
  38460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38461. }
  38462. m.SetAllowList(v)
  38463. return nil
  38464. case whatsapp.FieldGroupAllowList:
  38465. v, ok := value.([]string)
  38466. if !ok {
  38467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38468. }
  38469. m.SetGroupAllowList(v)
  38470. return nil
  38471. case whatsapp.FieldBlockList:
  38472. v, ok := value.([]string)
  38473. if !ok {
  38474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38475. }
  38476. m.SetBlockList(v)
  38477. return nil
  38478. case whatsapp.FieldGroupBlockList:
  38479. v, ok := value.([]string)
  38480. if !ok {
  38481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38482. }
  38483. m.SetGroupBlockList(v)
  38484. return nil
  38485. }
  38486. return fmt.Errorf("unknown Whatsapp field %s", name)
  38487. }
  38488. // AddedFields returns all numeric fields that were incremented/decremented during
  38489. // this mutation.
  38490. func (m *WhatsappMutation) AddedFields() []string {
  38491. var fields []string
  38492. if m.addstatus != nil {
  38493. fields = append(fields, whatsapp.FieldStatus)
  38494. }
  38495. if m.addphone_status != nil {
  38496. fields = append(fields, whatsapp.FieldPhoneStatus)
  38497. }
  38498. if m.addorganization_id != nil {
  38499. fields = append(fields, whatsapp.FieldOrganizationID)
  38500. }
  38501. return fields
  38502. }
  38503. // AddedField returns the numeric value that was incremented/decremented on a field
  38504. // with the given name. The second boolean return value indicates that this field
  38505. // was not set, or was not defined in the schema.
  38506. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  38507. switch name {
  38508. case whatsapp.FieldStatus:
  38509. return m.AddedStatus()
  38510. case whatsapp.FieldPhoneStatus:
  38511. return m.AddedPhoneStatus()
  38512. case whatsapp.FieldOrganizationID:
  38513. return m.AddedOrganizationID()
  38514. }
  38515. return nil, false
  38516. }
  38517. // AddField adds the value to the field with the given name. It returns an error if
  38518. // the field is not defined in the schema, or if the type mismatched the field
  38519. // type.
  38520. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  38521. switch name {
  38522. case whatsapp.FieldStatus:
  38523. v, ok := value.(int8)
  38524. if !ok {
  38525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38526. }
  38527. m.AddStatus(v)
  38528. return nil
  38529. case whatsapp.FieldPhoneStatus:
  38530. v, ok := value.(int8)
  38531. if !ok {
  38532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38533. }
  38534. m.AddPhoneStatus(v)
  38535. return nil
  38536. case whatsapp.FieldOrganizationID:
  38537. v, ok := value.(int64)
  38538. if !ok {
  38539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38540. }
  38541. m.AddOrganizationID(v)
  38542. return nil
  38543. }
  38544. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  38545. }
  38546. // ClearedFields returns all nullable fields that were cleared during this
  38547. // mutation.
  38548. func (m *WhatsappMutation) ClearedFields() []string {
  38549. var fields []string
  38550. if m.FieldCleared(whatsapp.FieldStatus) {
  38551. fields = append(fields, whatsapp.FieldStatus)
  38552. }
  38553. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  38554. fields = append(fields, whatsapp.FieldDeletedAt)
  38555. }
  38556. if m.FieldCleared(whatsapp.FieldWaID) {
  38557. fields = append(fields, whatsapp.FieldWaID)
  38558. }
  38559. if m.FieldCleared(whatsapp.FieldWaName) {
  38560. fields = append(fields, whatsapp.FieldWaName)
  38561. }
  38562. if m.FieldCleared(whatsapp.FieldCallback) {
  38563. fields = append(fields, whatsapp.FieldCallback)
  38564. }
  38565. if m.FieldCleared(whatsapp.FieldAccount) {
  38566. fields = append(fields, whatsapp.FieldAccount)
  38567. }
  38568. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  38569. fields = append(fields, whatsapp.FieldOrganizationID)
  38570. }
  38571. if m.FieldCleared(whatsapp.FieldAPIBase) {
  38572. fields = append(fields, whatsapp.FieldAPIBase)
  38573. }
  38574. if m.FieldCleared(whatsapp.FieldAPIKey) {
  38575. fields = append(fields, whatsapp.FieldAPIKey)
  38576. }
  38577. if m.FieldCleared(whatsapp.FieldAllowList) {
  38578. fields = append(fields, whatsapp.FieldAllowList)
  38579. }
  38580. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  38581. fields = append(fields, whatsapp.FieldGroupAllowList)
  38582. }
  38583. if m.FieldCleared(whatsapp.FieldBlockList) {
  38584. fields = append(fields, whatsapp.FieldBlockList)
  38585. }
  38586. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  38587. fields = append(fields, whatsapp.FieldGroupBlockList)
  38588. }
  38589. return fields
  38590. }
  38591. // FieldCleared returns a boolean indicating if a field with the given name was
  38592. // cleared in this mutation.
  38593. func (m *WhatsappMutation) FieldCleared(name string) bool {
  38594. _, ok := m.clearedFields[name]
  38595. return ok
  38596. }
  38597. // ClearField clears the value of the field with the given name. It returns an
  38598. // error if the field is not defined in the schema.
  38599. func (m *WhatsappMutation) ClearField(name string) error {
  38600. switch name {
  38601. case whatsapp.FieldStatus:
  38602. m.ClearStatus()
  38603. return nil
  38604. case whatsapp.FieldDeletedAt:
  38605. m.ClearDeletedAt()
  38606. return nil
  38607. case whatsapp.FieldWaID:
  38608. m.ClearWaID()
  38609. return nil
  38610. case whatsapp.FieldWaName:
  38611. m.ClearWaName()
  38612. return nil
  38613. case whatsapp.FieldCallback:
  38614. m.ClearCallback()
  38615. return nil
  38616. case whatsapp.FieldAccount:
  38617. m.ClearAccount()
  38618. return nil
  38619. case whatsapp.FieldOrganizationID:
  38620. m.ClearOrganizationID()
  38621. return nil
  38622. case whatsapp.FieldAPIBase:
  38623. m.ClearAPIBase()
  38624. return nil
  38625. case whatsapp.FieldAPIKey:
  38626. m.ClearAPIKey()
  38627. return nil
  38628. case whatsapp.FieldAllowList:
  38629. m.ClearAllowList()
  38630. return nil
  38631. case whatsapp.FieldGroupAllowList:
  38632. m.ClearGroupAllowList()
  38633. return nil
  38634. case whatsapp.FieldBlockList:
  38635. m.ClearBlockList()
  38636. return nil
  38637. case whatsapp.FieldGroupBlockList:
  38638. m.ClearGroupBlockList()
  38639. return nil
  38640. }
  38641. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  38642. }
  38643. // ResetField resets all changes in the mutation for the field with the given name.
  38644. // It returns an error if the field is not defined in the schema.
  38645. func (m *WhatsappMutation) ResetField(name string) error {
  38646. switch name {
  38647. case whatsapp.FieldCreatedAt:
  38648. m.ResetCreatedAt()
  38649. return nil
  38650. case whatsapp.FieldUpdatedAt:
  38651. m.ResetUpdatedAt()
  38652. return nil
  38653. case whatsapp.FieldStatus:
  38654. m.ResetStatus()
  38655. return nil
  38656. case whatsapp.FieldDeletedAt:
  38657. m.ResetDeletedAt()
  38658. return nil
  38659. case whatsapp.FieldWaID:
  38660. m.ResetWaID()
  38661. return nil
  38662. case whatsapp.FieldWaName:
  38663. m.ResetWaName()
  38664. return nil
  38665. case whatsapp.FieldCallback:
  38666. m.ResetCallback()
  38667. return nil
  38668. case whatsapp.FieldAgentID:
  38669. m.ResetAgentID()
  38670. return nil
  38671. case whatsapp.FieldAccount:
  38672. m.ResetAccount()
  38673. return nil
  38674. case whatsapp.FieldCc:
  38675. m.ResetCc()
  38676. return nil
  38677. case whatsapp.FieldPhone:
  38678. m.ResetPhone()
  38679. return nil
  38680. case whatsapp.FieldCcPhone:
  38681. m.ResetCcPhone()
  38682. return nil
  38683. case whatsapp.FieldPhoneName:
  38684. m.ResetPhoneName()
  38685. return nil
  38686. case whatsapp.FieldPhoneStatus:
  38687. m.ResetPhoneStatus()
  38688. return nil
  38689. case whatsapp.FieldOrganizationID:
  38690. m.ResetOrganizationID()
  38691. return nil
  38692. case whatsapp.FieldAPIBase:
  38693. m.ResetAPIBase()
  38694. return nil
  38695. case whatsapp.FieldAPIKey:
  38696. m.ResetAPIKey()
  38697. return nil
  38698. case whatsapp.FieldAllowList:
  38699. m.ResetAllowList()
  38700. return nil
  38701. case whatsapp.FieldGroupAllowList:
  38702. m.ResetGroupAllowList()
  38703. return nil
  38704. case whatsapp.FieldBlockList:
  38705. m.ResetBlockList()
  38706. return nil
  38707. case whatsapp.FieldGroupBlockList:
  38708. m.ResetGroupBlockList()
  38709. return nil
  38710. }
  38711. return fmt.Errorf("unknown Whatsapp field %s", name)
  38712. }
  38713. // AddedEdges returns all edge names that were set/added in this mutation.
  38714. func (m *WhatsappMutation) AddedEdges() []string {
  38715. edges := make([]string, 0, 1)
  38716. if m.agent != nil {
  38717. edges = append(edges, whatsapp.EdgeAgent)
  38718. }
  38719. return edges
  38720. }
  38721. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38722. // name in this mutation.
  38723. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  38724. switch name {
  38725. case whatsapp.EdgeAgent:
  38726. if id := m.agent; id != nil {
  38727. return []ent.Value{*id}
  38728. }
  38729. }
  38730. return nil
  38731. }
  38732. // RemovedEdges returns all edge names that were removed in this mutation.
  38733. func (m *WhatsappMutation) RemovedEdges() []string {
  38734. edges := make([]string, 0, 1)
  38735. return edges
  38736. }
  38737. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38738. // the given name in this mutation.
  38739. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  38740. return nil
  38741. }
  38742. // ClearedEdges returns all edge names that were cleared in this mutation.
  38743. func (m *WhatsappMutation) ClearedEdges() []string {
  38744. edges := make([]string, 0, 1)
  38745. if m.clearedagent {
  38746. edges = append(edges, whatsapp.EdgeAgent)
  38747. }
  38748. return edges
  38749. }
  38750. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38751. // was cleared in this mutation.
  38752. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  38753. switch name {
  38754. case whatsapp.EdgeAgent:
  38755. return m.clearedagent
  38756. }
  38757. return false
  38758. }
  38759. // ClearEdge clears the value of the edge with the given name. It returns an error
  38760. // if that edge is not defined in the schema.
  38761. func (m *WhatsappMutation) ClearEdge(name string) error {
  38762. switch name {
  38763. case whatsapp.EdgeAgent:
  38764. m.ClearAgent()
  38765. return nil
  38766. }
  38767. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  38768. }
  38769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38770. // It returns an error if the edge is not defined in the schema.
  38771. func (m *WhatsappMutation) ResetEdge(name string) error {
  38772. switch name {
  38773. case whatsapp.EdgeAgent:
  38774. m.ResetAgent()
  38775. return nil
  38776. }
  38777. return fmt.Errorf("unknown Whatsapp edge %s", name)
  38778. }
  38779. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  38780. type WhatsappChannelMutation struct {
  38781. config
  38782. op Op
  38783. typ string
  38784. id *uint64
  38785. created_at *time.Time
  38786. updated_at *time.Time
  38787. status *uint8
  38788. addstatus *int8
  38789. deleted_at *time.Time
  38790. ak *string
  38791. sk *string
  38792. wa_id *string
  38793. wa_name *string
  38794. waba_id *uint64
  38795. addwaba_id *int64
  38796. business_id *uint64
  38797. addbusiness_id *int64
  38798. organization_id *uint64
  38799. addorganization_id *int64
  38800. verify_account *string
  38801. clearedFields map[string]struct{}
  38802. done bool
  38803. oldValue func(context.Context) (*WhatsappChannel, error)
  38804. predicates []predicate.WhatsappChannel
  38805. }
  38806. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  38807. // whatsappchannelOption allows management of the mutation configuration using functional options.
  38808. type whatsappchannelOption func(*WhatsappChannelMutation)
  38809. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  38810. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  38811. m := &WhatsappChannelMutation{
  38812. config: c,
  38813. op: op,
  38814. typ: TypeWhatsappChannel,
  38815. clearedFields: make(map[string]struct{}),
  38816. }
  38817. for _, opt := range opts {
  38818. opt(m)
  38819. }
  38820. return m
  38821. }
  38822. // withWhatsappChannelID sets the ID field of the mutation.
  38823. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  38824. return func(m *WhatsappChannelMutation) {
  38825. var (
  38826. err error
  38827. once sync.Once
  38828. value *WhatsappChannel
  38829. )
  38830. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  38831. once.Do(func() {
  38832. if m.done {
  38833. err = errors.New("querying old values post mutation is not allowed")
  38834. } else {
  38835. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  38836. }
  38837. })
  38838. return value, err
  38839. }
  38840. m.id = &id
  38841. }
  38842. }
  38843. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  38844. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  38845. return func(m *WhatsappChannelMutation) {
  38846. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  38847. return node, nil
  38848. }
  38849. m.id = &node.ID
  38850. }
  38851. }
  38852. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38853. // executed in a transaction (ent.Tx), a transactional client is returned.
  38854. func (m WhatsappChannelMutation) Client() *Client {
  38855. client := &Client{config: m.config}
  38856. client.init()
  38857. return client
  38858. }
  38859. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38860. // it returns an error otherwise.
  38861. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  38862. if _, ok := m.driver.(*txDriver); !ok {
  38863. return nil, errors.New("ent: mutation is not running in a transaction")
  38864. }
  38865. tx := &Tx{config: m.config}
  38866. tx.init()
  38867. return tx, nil
  38868. }
  38869. // SetID sets the value of the id field. Note that this
  38870. // operation is only accepted on creation of WhatsappChannel entities.
  38871. func (m *WhatsappChannelMutation) SetID(id uint64) {
  38872. m.id = &id
  38873. }
  38874. // ID returns the ID value in the mutation. Note that the ID is only available
  38875. // if it was provided to the builder or after it was returned from the database.
  38876. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  38877. if m.id == nil {
  38878. return
  38879. }
  38880. return *m.id, true
  38881. }
  38882. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38883. // That means, if the mutation is applied within a transaction with an isolation level such
  38884. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38885. // or updated by the mutation.
  38886. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  38887. switch {
  38888. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38889. id, exists := m.ID()
  38890. if exists {
  38891. return []uint64{id}, nil
  38892. }
  38893. fallthrough
  38894. case m.op.Is(OpUpdate | OpDelete):
  38895. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  38896. default:
  38897. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38898. }
  38899. }
  38900. // SetCreatedAt sets the "created_at" field.
  38901. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  38902. m.created_at = &t
  38903. }
  38904. // CreatedAt returns the value of the "created_at" field in the mutation.
  38905. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  38906. v := m.created_at
  38907. if v == nil {
  38908. return
  38909. }
  38910. return *v, true
  38911. }
  38912. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  38913. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38915. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38916. if !m.op.Is(OpUpdateOne) {
  38917. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38918. }
  38919. if m.id == nil || m.oldValue == nil {
  38920. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38921. }
  38922. oldValue, err := m.oldValue(ctx)
  38923. if err != nil {
  38924. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38925. }
  38926. return oldValue.CreatedAt, nil
  38927. }
  38928. // ResetCreatedAt resets all changes to the "created_at" field.
  38929. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  38930. m.created_at = nil
  38931. }
  38932. // SetUpdatedAt sets the "updated_at" field.
  38933. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  38934. m.updated_at = &t
  38935. }
  38936. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38937. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  38938. v := m.updated_at
  38939. if v == nil {
  38940. return
  38941. }
  38942. return *v, true
  38943. }
  38944. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  38945. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38947. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38948. if !m.op.Is(OpUpdateOne) {
  38949. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38950. }
  38951. if m.id == nil || m.oldValue == nil {
  38952. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38953. }
  38954. oldValue, err := m.oldValue(ctx)
  38955. if err != nil {
  38956. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38957. }
  38958. return oldValue.UpdatedAt, nil
  38959. }
  38960. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38961. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  38962. m.updated_at = nil
  38963. }
  38964. // SetStatus sets the "status" field.
  38965. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  38966. m.status = &u
  38967. m.addstatus = nil
  38968. }
  38969. // Status returns the value of the "status" field in the mutation.
  38970. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  38971. v := m.status
  38972. if v == nil {
  38973. return
  38974. }
  38975. return *v, true
  38976. }
  38977. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  38978. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  38979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38980. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  38981. if !m.op.Is(OpUpdateOne) {
  38982. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  38983. }
  38984. if m.id == nil || m.oldValue == nil {
  38985. return v, errors.New("OldStatus requires an ID field in the mutation")
  38986. }
  38987. oldValue, err := m.oldValue(ctx)
  38988. if err != nil {
  38989. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  38990. }
  38991. return oldValue.Status, nil
  38992. }
  38993. // AddStatus adds u to the "status" field.
  38994. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  38995. if m.addstatus != nil {
  38996. *m.addstatus += u
  38997. } else {
  38998. m.addstatus = &u
  38999. }
  39000. }
  39001. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39002. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  39003. v := m.addstatus
  39004. if v == nil {
  39005. return
  39006. }
  39007. return *v, true
  39008. }
  39009. // ClearStatus clears the value of the "status" field.
  39010. func (m *WhatsappChannelMutation) ClearStatus() {
  39011. m.status = nil
  39012. m.addstatus = nil
  39013. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  39014. }
  39015. // StatusCleared returns if the "status" field was cleared in this mutation.
  39016. func (m *WhatsappChannelMutation) StatusCleared() bool {
  39017. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  39018. return ok
  39019. }
  39020. // ResetStatus resets all changes to the "status" field.
  39021. func (m *WhatsappChannelMutation) ResetStatus() {
  39022. m.status = nil
  39023. m.addstatus = nil
  39024. delete(m.clearedFields, whatsappchannel.FieldStatus)
  39025. }
  39026. // SetDeletedAt sets the "deleted_at" field.
  39027. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  39028. m.deleted_at = &t
  39029. }
  39030. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39031. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  39032. v := m.deleted_at
  39033. if v == nil {
  39034. return
  39035. }
  39036. return *v, true
  39037. }
  39038. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  39039. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39041. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39042. if !m.op.Is(OpUpdateOne) {
  39043. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39044. }
  39045. if m.id == nil || m.oldValue == nil {
  39046. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39047. }
  39048. oldValue, err := m.oldValue(ctx)
  39049. if err != nil {
  39050. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39051. }
  39052. return oldValue.DeletedAt, nil
  39053. }
  39054. // ClearDeletedAt clears the value of the "deleted_at" field.
  39055. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  39056. m.deleted_at = nil
  39057. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  39058. }
  39059. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39060. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  39061. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  39062. return ok
  39063. }
  39064. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39065. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  39066. m.deleted_at = nil
  39067. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  39068. }
  39069. // SetAk sets the "ak" field.
  39070. func (m *WhatsappChannelMutation) SetAk(s string) {
  39071. m.ak = &s
  39072. }
  39073. // Ak returns the value of the "ak" field in the mutation.
  39074. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  39075. v := m.ak
  39076. if v == nil {
  39077. return
  39078. }
  39079. return *v, true
  39080. }
  39081. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  39082. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39084. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  39085. if !m.op.Is(OpUpdateOne) {
  39086. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  39087. }
  39088. if m.id == nil || m.oldValue == nil {
  39089. return v, errors.New("OldAk requires an ID field in the mutation")
  39090. }
  39091. oldValue, err := m.oldValue(ctx)
  39092. if err != nil {
  39093. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  39094. }
  39095. return oldValue.Ak, nil
  39096. }
  39097. // ClearAk clears the value of the "ak" field.
  39098. func (m *WhatsappChannelMutation) ClearAk() {
  39099. m.ak = nil
  39100. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  39101. }
  39102. // AkCleared returns if the "ak" field was cleared in this mutation.
  39103. func (m *WhatsappChannelMutation) AkCleared() bool {
  39104. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  39105. return ok
  39106. }
  39107. // ResetAk resets all changes to the "ak" field.
  39108. func (m *WhatsappChannelMutation) ResetAk() {
  39109. m.ak = nil
  39110. delete(m.clearedFields, whatsappchannel.FieldAk)
  39111. }
  39112. // SetSk sets the "sk" field.
  39113. func (m *WhatsappChannelMutation) SetSk(s string) {
  39114. m.sk = &s
  39115. }
  39116. // Sk returns the value of the "sk" field in the mutation.
  39117. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  39118. v := m.sk
  39119. if v == nil {
  39120. return
  39121. }
  39122. return *v, true
  39123. }
  39124. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  39125. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39127. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  39128. if !m.op.Is(OpUpdateOne) {
  39129. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  39130. }
  39131. if m.id == nil || m.oldValue == nil {
  39132. return v, errors.New("OldSk requires an ID field in the mutation")
  39133. }
  39134. oldValue, err := m.oldValue(ctx)
  39135. if err != nil {
  39136. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  39137. }
  39138. return oldValue.Sk, nil
  39139. }
  39140. // ResetSk resets all changes to the "sk" field.
  39141. func (m *WhatsappChannelMutation) ResetSk() {
  39142. m.sk = nil
  39143. }
  39144. // SetWaID sets the "wa_id" field.
  39145. func (m *WhatsappChannelMutation) SetWaID(s string) {
  39146. m.wa_id = &s
  39147. }
  39148. // WaID returns the value of the "wa_id" field in the mutation.
  39149. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  39150. v := m.wa_id
  39151. if v == nil {
  39152. return
  39153. }
  39154. return *v, true
  39155. }
  39156. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  39157. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39159. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  39160. if !m.op.Is(OpUpdateOne) {
  39161. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  39162. }
  39163. if m.id == nil || m.oldValue == nil {
  39164. return v, errors.New("OldWaID requires an ID field in the mutation")
  39165. }
  39166. oldValue, err := m.oldValue(ctx)
  39167. if err != nil {
  39168. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  39169. }
  39170. return oldValue.WaID, nil
  39171. }
  39172. // ClearWaID clears the value of the "wa_id" field.
  39173. func (m *WhatsappChannelMutation) ClearWaID() {
  39174. m.wa_id = nil
  39175. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  39176. }
  39177. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  39178. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  39179. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  39180. return ok
  39181. }
  39182. // ResetWaID resets all changes to the "wa_id" field.
  39183. func (m *WhatsappChannelMutation) ResetWaID() {
  39184. m.wa_id = nil
  39185. delete(m.clearedFields, whatsappchannel.FieldWaID)
  39186. }
  39187. // SetWaName sets the "wa_name" field.
  39188. func (m *WhatsappChannelMutation) SetWaName(s string) {
  39189. m.wa_name = &s
  39190. }
  39191. // WaName returns the value of the "wa_name" field in the mutation.
  39192. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  39193. v := m.wa_name
  39194. if v == nil {
  39195. return
  39196. }
  39197. return *v, true
  39198. }
  39199. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  39200. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39202. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  39203. if !m.op.Is(OpUpdateOne) {
  39204. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  39205. }
  39206. if m.id == nil || m.oldValue == nil {
  39207. return v, errors.New("OldWaName requires an ID field in the mutation")
  39208. }
  39209. oldValue, err := m.oldValue(ctx)
  39210. if err != nil {
  39211. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  39212. }
  39213. return oldValue.WaName, nil
  39214. }
  39215. // ClearWaName clears the value of the "wa_name" field.
  39216. func (m *WhatsappChannelMutation) ClearWaName() {
  39217. m.wa_name = nil
  39218. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  39219. }
  39220. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  39221. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  39222. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  39223. return ok
  39224. }
  39225. // ResetWaName resets all changes to the "wa_name" field.
  39226. func (m *WhatsappChannelMutation) ResetWaName() {
  39227. m.wa_name = nil
  39228. delete(m.clearedFields, whatsappchannel.FieldWaName)
  39229. }
  39230. // SetWabaID sets the "waba_id" field.
  39231. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  39232. m.waba_id = &u
  39233. m.addwaba_id = nil
  39234. }
  39235. // WabaID returns the value of the "waba_id" field in the mutation.
  39236. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  39237. v := m.waba_id
  39238. if v == nil {
  39239. return
  39240. }
  39241. return *v, true
  39242. }
  39243. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  39244. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39246. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  39247. if !m.op.Is(OpUpdateOne) {
  39248. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  39249. }
  39250. if m.id == nil || m.oldValue == nil {
  39251. return v, errors.New("OldWabaID requires an ID field in the mutation")
  39252. }
  39253. oldValue, err := m.oldValue(ctx)
  39254. if err != nil {
  39255. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  39256. }
  39257. return oldValue.WabaID, nil
  39258. }
  39259. // AddWabaID adds u to the "waba_id" field.
  39260. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  39261. if m.addwaba_id != nil {
  39262. *m.addwaba_id += u
  39263. } else {
  39264. m.addwaba_id = &u
  39265. }
  39266. }
  39267. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  39268. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  39269. v := m.addwaba_id
  39270. if v == nil {
  39271. return
  39272. }
  39273. return *v, true
  39274. }
  39275. // ResetWabaID resets all changes to the "waba_id" field.
  39276. func (m *WhatsappChannelMutation) ResetWabaID() {
  39277. m.waba_id = nil
  39278. m.addwaba_id = nil
  39279. }
  39280. // SetBusinessID sets the "business_id" field.
  39281. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  39282. m.business_id = &u
  39283. m.addbusiness_id = nil
  39284. }
  39285. // BusinessID returns the value of the "business_id" field in the mutation.
  39286. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  39287. v := m.business_id
  39288. if v == nil {
  39289. return
  39290. }
  39291. return *v, true
  39292. }
  39293. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  39294. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39296. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  39297. if !m.op.Is(OpUpdateOne) {
  39298. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  39299. }
  39300. if m.id == nil || m.oldValue == nil {
  39301. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  39302. }
  39303. oldValue, err := m.oldValue(ctx)
  39304. if err != nil {
  39305. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  39306. }
  39307. return oldValue.BusinessID, nil
  39308. }
  39309. // AddBusinessID adds u to the "business_id" field.
  39310. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  39311. if m.addbusiness_id != nil {
  39312. *m.addbusiness_id += u
  39313. } else {
  39314. m.addbusiness_id = &u
  39315. }
  39316. }
  39317. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  39318. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  39319. v := m.addbusiness_id
  39320. if v == nil {
  39321. return
  39322. }
  39323. return *v, true
  39324. }
  39325. // ResetBusinessID resets all changes to the "business_id" field.
  39326. func (m *WhatsappChannelMutation) ResetBusinessID() {
  39327. m.business_id = nil
  39328. m.addbusiness_id = nil
  39329. }
  39330. // SetOrganizationID sets the "organization_id" field.
  39331. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  39332. m.organization_id = &u
  39333. m.addorganization_id = nil
  39334. }
  39335. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39336. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  39337. v := m.organization_id
  39338. if v == nil {
  39339. return
  39340. }
  39341. return *v, true
  39342. }
  39343. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  39344. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39346. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39347. if !m.op.Is(OpUpdateOne) {
  39348. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39349. }
  39350. if m.id == nil || m.oldValue == nil {
  39351. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39352. }
  39353. oldValue, err := m.oldValue(ctx)
  39354. if err != nil {
  39355. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39356. }
  39357. return oldValue.OrganizationID, nil
  39358. }
  39359. // AddOrganizationID adds u to the "organization_id" field.
  39360. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  39361. if m.addorganization_id != nil {
  39362. *m.addorganization_id += u
  39363. } else {
  39364. m.addorganization_id = &u
  39365. }
  39366. }
  39367. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39368. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  39369. v := m.addorganization_id
  39370. if v == nil {
  39371. return
  39372. }
  39373. return *v, true
  39374. }
  39375. // ClearOrganizationID clears the value of the "organization_id" field.
  39376. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  39377. m.organization_id = nil
  39378. m.addorganization_id = nil
  39379. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  39380. }
  39381. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39382. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  39383. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  39384. return ok
  39385. }
  39386. // ResetOrganizationID resets all changes to the "organization_id" field.
  39387. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  39388. m.organization_id = nil
  39389. m.addorganization_id = nil
  39390. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  39391. }
  39392. // SetVerifyAccount sets the "verify_account" field.
  39393. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  39394. m.verify_account = &s
  39395. }
  39396. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  39397. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  39398. v := m.verify_account
  39399. if v == nil {
  39400. return
  39401. }
  39402. return *v, true
  39403. }
  39404. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  39405. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  39406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39407. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  39408. if !m.op.Is(OpUpdateOne) {
  39409. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  39410. }
  39411. if m.id == nil || m.oldValue == nil {
  39412. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  39413. }
  39414. oldValue, err := m.oldValue(ctx)
  39415. if err != nil {
  39416. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  39417. }
  39418. return oldValue.VerifyAccount, nil
  39419. }
  39420. // ResetVerifyAccount resets all changes to the "verify_account" field.
  39421. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  39422. m.verify_account = nil
  39423. }
  39424. // Where appends a list predicates to the WhatsappChannelMutation builder.
  39425. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  39426. m.predicates = append(m.predicates, ps...)
  39427. }
  39428. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  39429. // users can use type-assertion to append predicates that do not depend on any generated package.
  39430. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  39431. p := make([]predicate.WhatsappChannel, len(ps))
  39432. for i := range ps {
  39433. p[i] = ps[i]
  39434. }
  39435. m.Where(p...)
  39436. }
  39437. // Op returns the operation name.
  39438. func (m *WhatsappChannelMutation) Op() Op {
  39439. return m.op
  39440. }
  39441. // SetOp allows setting the mutation operation.
  39442. func (m *WhatsappChannelMutation) SetOp(op Op) {
  39443. m.op = op
  39444. }
  39445. // Type returns the node type of this mutation (WhatsappChannel).
  39446. func (m *WhatsappChannelMutation) Type() string {
  39447. return m.typ
  39448. }
  39449. // Fields returns all fields that were changed during this mutation. Note that in
  39450. // order to get all numeric fields that were incremented/decremented, call
  39451. // AddedFields().
  39452. func (m *WhatsappChannelMutation) Fields() []string {
  39453. fields := make([]string, 0, 12)
  39454. if m.created_at != nil {
  39455. fields = append(fields, whatsappchannel.FieldCreatedAt)
  39456. }
  39457. if m.updated_at != nil {
  39458. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  39459. }
  39460. if m.status != nil {
  39461. fields = append(fields, whatsappchannel.FieldStatus)
  39462. }
  39463. if m.deleted_at != nil {
  39464. fields = append(fields, whatsappchannel.FieldDeletedAt)
  39465. }
  39466. if m.ak != nil {
  39467. fields = append(fields, whatsappchannel.FieldAk)
  39468. }
  39469. if m.sk != nil {
  39470. fields = append(fields, whatsappchannel.FieldSk)
  39471. }
  39472. if m.wa_id != nil {
  39473. fields = append(fields, whatsappchannel.FieldWaID)
  39474. }
  39475. if m.wa_name != nil {
  39476. fields = append(fields, whatsappchannel.FieldWaName)
  39477. }
  39478. if m.waba_id != nil {
  39479. fields = append(fields, whatsappchannel.FieldWabaID)
  39480. }
  39481. if m.business_id != nil {
  39482. fields = append(fields, whatsappchannel.FieldBusinessID)
  39483. }
  39484. if m.organization_id != nil {
  39485. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39486. }
  39487. if m.verify_account != nil {
  39488. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  39489. }
  39490. return fields
  39491. }
  39492. // Field returns the value of a field with the given name. The second boolean
  39493. // return value indicates that this field was not set, or was not defined in the
  39494. // schema.
  39495. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  39496. switch name {
  39497. case whatsappchannel.FieldCreatedAt:
  39498. return m.CreatedAt()
  39499. case whatsappchannel.FieldUpdatedAt:
  39500. return m.UpdatedAt()
  39501. case whatsappchannel.FieldStatus:
  39502. return m.Status()
  39503. case whatsappchannel.FieldDeletedAt:
  39504. return m.DeletedAt()
  39505. case whatsappchannel.FieldAk:
  39506. return m.Ak()
  39507. case whatsappchannel.FieldSk:
  39508. return m.Sk()
  39509. case whatsappchannel.FieldWaID:
  39510. return m.WaID()
  39511. case whatsappchannel.FieldWaName:
  39512. return m.WaName()
  39513. case whatsappchannel.FieldWabaID:
  39514. return m.WabaID()
  39515. case whatsappchannel.FieldBusinessID:
  39516. return m.BusinessID()
  39517. case whatsappchannel.FieldOrganizationID:
  39518. return m.OrganizationID()
  39519. case whatsappchannel.FieldVerifyAccount:
  39520. return m.VerifyAccount()
  39521. }
  39522. return nil, false
  39523. }
  39524. // OldField returns the old value of the field from the database. An error is
  39525. // returned if the mutation operation is not UpdateOne, or the query to the
  39526. // database failed.
  39527. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39528. switch name {
  39529. case whatsappchannel.FieldCreatedAt:
  39530. return m.OldCreatedAt(ctx)
  39531. case whatsappchannel.FieldUpdatedAt:
  39532. return m.OldUpdatedAt(ctx)
  39533. case whatsappchannel.FieldStatus:
  39534. return m.OldStatus(ctx)
  39535. case whatsappchannel.FieldDeletedAt:
  39536. return m.OldDeletedAt(ctx)
  39537. case whatsappchannel.FieldAk:
  39538. return m.OldAk(ctx)
  39539. case whatsappchannel.FieldSk:
  39540. return m.OldSk(ctx)
  39541. case whatsappchannel.FieldWaID:
  39542. return m.OldWaID(ctx)
  39543. case whatsappchannel.FieldWaName:
  39544. return m.OldWaName(ctx)
  39545. case whatsappchannel.FieldWabaID:
  39546. return m.OldWabaID(ctx)
  39547. case whatsappchannel.FieldBusinessID:
  39548. return m.OldBusinessID(ctx)
  39549. case whatsappchannel.FieldOrganizationID:
  39550. return m.OldOrganizationID(ctx)
  39551. case whatsappchannel.FieldVerifyAccount:
  39552. return m.OldVerifyAccount(ctx)
  39553. }
  39554. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  39555. }
  39556. // SetField sets the value of a field with the given name. It returns an error if
  39557. // the field is not defined in the schema, or if the type mismatched the field
  39558. // type.
  39559. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  39560. switch name {
  39561. case whatsappchannel.FieldCreatedAt:
  39562. v, ok := value.(time.Time)
  39563. if !ok {
  39564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39565. }
  39566. m.SetCreatedAt(v)
  39567. return nil
  39568. case whatsappchannel.FieldUpdatedAt:
  39569. v, ok := value.(time.Time)
  39570. if !ok {
  39571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39572. }
  39573. m.SetUpdatedAt(v)
  39574. return nil
  39575. case whatsappchannel.FieldStatus:
  39576. v, ok := value.(uint8)
  39577. if !ok {
  39578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39579. }
  39580. m.SetStatus(v)
  39581. return nil
  39582. case whatsappchannel.FieldDeletedAt:
  39583. v, ok := value.(time.Time)
  39584. if !ok {
  39585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39586. }
  39587. m.SetDeletedAt(v)
  39588. return nil
  39589. case whatsappchannel.FieldAk:
  39590. v, ok := value.(string)
  39591. if !ok {
  39592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39593. }
  39594. m.SetAk(v)
  39595. return nil
  39596. case whatsappchannel.FieldSk:
  39597. v, ok := value.(string)
  39598. if !ok {
  39599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39600. }
  39601. m.SetSk(v)
  39602. return nil
  39603. case whatsappchannel.FieldWaID:
  39604. v, ok := value.(string)
  39605. if !ok {
  39606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39607. }
  39608. m.SetWaID(v)
  39609. return nil
  39610. case whatsappchannel.FieldWaName:
  39611. v, ok := value.(string)
  39612. if !ok {
  39613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39614. }
  39615. m.SetWaName(v)
  39616. return nil
  39617. case whatsappchannel.FieldWabaID:
  39618. v, ok := value.(uint64)
  39619. if !ok {
  39620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39621. }
  39622. m.SetWabaID(v)
  39623. return nil
  39624. case whatsappchannel.FieldBusinessID:
  39625. v, ok := value.(uint64)
  39626. if !ok {
  39627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39628. }
  39629. m.SetBusinessID(v)
  39630. return nil
  39631. case whatsappchannel.FieldOrganizationID:
  39632. v, ok := value.(uint64)
  39633. if !ok {
  39634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39635. }
  39636. m.SetOrganizationID(v)
  39637. return nil
  39638. case whatsappchannel.FieldVerifyAccount:
  39639. v, ok := value.(string)
  39640. if !ok {
  39641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39642. }
  39643. m.SetVerifyAccount(v)
  39644. return nil
  39645. }
  39646. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  39647. }
  39648. // AddedFields returns all numeric fields that were incremented/decremented during
  39649. // this mutation.
  39650. func (m *WhatsappChannelMutation) AddedFields() []string {
  39651. var fields []string
  39652. if m.addstatus != nil {
  39653. fields = append(fields, whatsappchannel.FieldStatus)
  39654. }
  39655. if m.addwaba_id != nil {
  39656. fields = append(fields, whatsappchannel.FieldWabaID)
  39657. }
  39658. if m.addbusiness_id != nil {
  39659. fields = append(fields, whatsappchannel.FieldBusinessID)
  39660. }
  39661. if m.addorganization_id != nil {
  39662. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39663. }
  39664. return fields
  39665. }
  39666. // AddedField returns the numeric value that was incremented/decremented on a field
  39667. // with the given name. The second boolean return value indicates that this field
  39668. // was not set, or was not defined in the schema.
  39669. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  39670. switch name {
  39671. case whatsappchannel.FieldStatus:
  39672. return m.AddedStatus()
  39673. case whatsappchannel.FieldWabaID:
  39674. return m.AddedWabaID()
  39675. case whatsappchannel.FieldBusinessID:
  39676. return m.AddedBusinessID()
  39677. case whatsappchannel.FieldOrganizationID:
  39678. return m.AddedOrganizationID()
  39679. }
  39680. return nil, false
  39681. }
  39682. // AddField adds the value to the field with the given name. It returns an error if
  39683. // the field is not defined in the schema, or if the type mismatched the field
  39684. // type.
  39685. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  39686. switch name {
  39687. case whatsappchannel.FieldStatus:
  39688. v, ok := value.(int8)
  39689. if !ok {
  39690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39691. }
  39692. m.AddStatus(v)
  39693. return nil
  39694. case whatsappchannel.FieldWabaID:
  39695. v, ok := value.(int64)
  39696. if !ok {
  39697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39698. }
  39699. m.AddWabaID(v)
  39700. return nil
  39701. case whatsappchannel.FieldBusinessID:
  39702. v, ok := value.(int64)
  39703. if !ok {
  39704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39705. }
  39706. m.AddBusinessID(v)
  39707. return nil
  39708. case whatsappchannel.FieldOrganizationID:
  39709. v, ok := value.(int64)
  39710. if !ok {
  39711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39712. }
  39713. m.AddOrganizationID(v)
  39714. return nil
  39715. }
  39716. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  39717. }
  39718. // ClearedFields returns all nullable fields that were cleared during this
  39719. // mutation.
  39720. func (m *WhatsappChannelMutation) ClearedFields() []string {
  39721. var fields []string
  39722. if m.FieldCleared(whatsappchannel.FieldStatus) {
  39723. fields = append(fields, whatsappchannel.FieldStatus)
  39724. }
  39725. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  39726. fields = append(fields, whatsappchannel.FieldDeletedAt)
  39727. }
  39728. if m.FieldCleared(whatsappchannel.FieldAk) {
  39729. fields = append(fields, whatsappchannel.FieldAk)
  39730. }
  39731. if m.FieldCleared(whatsappchannel.FieldWaID) {
  39732. fields = append(fields, whatsappchannel.FieldWaID)
  39733. }
  39734. if m.FieldCleared(whatsappchannel.FieldWaName) {
  39735. fields = append(fields, whatsappchannel.FieldWaName)
  39736. }
  39737. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  39738. fields = append(fields, whatsappchannel.FieldOrganizationID)
  39739. }
  39740. return fields
  39741. }
  39742. // FieldCleared returns a boolean indicating if a field with the given name was
  39743. // cleared in this mutation.
  39744. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  39745. _, ok := m.clearedFields[name]
  39746. return ok
  39747. }
  39748. // ClearField clears the value of the field with the given name. It returns an
  39749. // error if the field is not defined in the schema.
  39750. func (m *WhatsappChannelMutation) ClearField(name string) error {
  39751. switch name {
  39752. case whatsappchannel.FieldStatus:
  39753. m.ClearStatus()
  39754. return nil
  39755. case whatsappchannel.FieldDeletedAt:
  39756. m.ClearDeletedAt()
  39757. return nil
  39758. case whatsappchannel.FieldAk:
  39759. m.ClearAk()
  39760. return nil
  39761. case whatsappchannel.FieldWaID:
  39762. m.ClearWaID()
  39763. return nil
  39764. case whatsappchannel.FieldWaName:
  39765. m.ClearWaName()
  39766. return nil
  39767. case whatsappchannel.FieldOrganizationID:
  39768. m.ClearOrganizationID()
  39769. return nil
  39770. }
  39771. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  39772. }
  39773. // ResetField resets all changes in the mutation for the field with the given name.
  39774. // It returns an error if the field is not defined in the schema.
  39775. func (m *WhatsappChannelMutation) ResetField(name string) error {
  39776. switch name {
  39777. case whatsappchannel.FieldCreatedAt:
  39778. m.ResetCreatedAt()
  39779. return nil
  39780. case whatsappchannel.FieldUpdatedAt:
  39781. m.ResetUpdatedAt()
  39782. return nil
  39783. case whatsappchannel.FieldStatus:
  39784. m.ResetStatus()
  39785. return nil
  39786. case whatsappchannel.FieldDeletedAt:
  39787. m.ResetDeletedAt()
  39788. return nil
  39789. case whatsappchannel.FieldAk:
  39790. m.ResetAk()
  39791. return nil
  39792. case whatsappchannel.FieldSk:
  39793. m.ResetSk()
  39794. return nil
  39795. case whatsappchannel.FieldWaID:
  39796. m.ResetWaID()
  39797. return nil
  39798. case whatsappchannel.FieldWaName:
  39799. m.ResetWaName()
  39800. return nil
  39801. case whatsappchannel.FieldWabaID:
  39802. m.ResetWabaID()
  39803. return nil
  39804. case whatsappchannel.FieldBusinessID:
  39805. m.ResetBusinessID()
  39806. return nil
  39807. case whatsappchannel.FieldOrganizationID:
  39808. m.ResetOrganizationID()
  39809. return nil
  39810. case whatsappchannel.FieldVerifyAccount:
  39811. m.ResetVerifyAccount()
  39812. return nil
  39813. }
  39814. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  39815. }
  39816. // AddedEdges returns all edge names that were set/added in this mutation.
  39817. func (m *WhatsappChannelMutation) AddedEdges() []string {
  39818. edges := make([]string, 0, 0)
  39819. return edges
  39820. }
  39821. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39822. // name in this mutation.
  39823. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  39824. return nil
  39825. }
  39826. // RemovedEdges returns all edge names that were removed in this mutation.
  39827. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  39828. edges := make([]string, 0, 0)
  39829. return edges
  39830. }
  39831. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39832. // the given name in this mutation.
  39833. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  39834. return nil
  39835. }
  39836. // ClearedEdges returns all edge names that were cleared in this mutation.
  39837. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  39838. edges := make([]string, 0, 0)
  39839. return edges
  39840. }
  39841. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39842. // was cleared in this mutation.
  39843. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  39844. return false
  39845. }
  39846. // ClearEdge clears the value of the edge with the given name. It returns an error
  39847. // if that edge is not defined in the schema.
  39848. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  39849. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  39850. }
  39851. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39852. // It returns an error if the edge is not defined in the schema.
  39853. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  39854. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  39855. }
  39856. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  39857. type WorkExperienceMutation struct {
  39858. config
  39859. op Op
  39860. typ string
  39861. id *uint64
  39862. created_at *time.Time
  39863. updated_at *time.Time
  39864. deleted_at *time.Time
  39865. start_date *time.Time
  39866. end_date *time.Time
  39867. company *string
  39868. experience *string
  39869. organization_id *uint64
  39870. addorganization_id *int64
  39871. clearedFields map[string]struct{}
  39872. employee *uint64
  39873. clearedemployee bool
  39874. done bool
  39875. oldValue func(context.Context) (*WorkExperience, error)
  39876. predicates []predicate.WorkExperience
  39877. }
  39878. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  39879. // workexperienceOption allows management of the mutation configuration using functional options.
  39880. type workexperienceOption func(*WorkExperienceMutation)
  39881. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  39882. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  39883. m := &WorkExperienceMutation{
  39884. config: c,
  39885. op: op,
  39886. typ: TypeWorkExperience,
  39887. clearedFields: make(map[string]struct{}),
  39888. }
  39889. for _, opt := range opts {
  39890. opt(m)
  39891. }
  39892. return m
  39893. }
  39894. // withWorkExperienceID sets the ID field of the mutation.
  39895. func withWorkExperienceID(id uint64) workexperienceOption {
  39896. return func(m *WorkExperienceMutation) {
  39897. var (
  39898. err error
  39899. once sync.Once
  39900. value *WorkExperience
  39901. )
  39902. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  39903. once.Do(func() {
  39904. if m.done {
  39905. err = errors.New("querying old values post mutation is not allowed")
  39906. } else {
  39907. value, err = m.Client().WorkExperience.Get(ctx, id)
  39908. }
  39909. })
  39910. return value, err
  39911. }
  39912. m.id = &id
  39913. }
  39914. }
  39915. // withWorkExperience sets the old WorkExperience of the mutation.
  39916. func withWorkExperience(node *WorkExperience) workexperienceOption {
  39917. return func(m *WorkExperienceMutation) {
  39918. m.oldValue = func(context.Context) (*WorkExperience, error) {
  39919. return node, nil
  39920. }
  39921. m.id = &node.ID
  39922. }
  39923. }
  39924. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39925. // executed in a transaction (ent.Tx), a transactional client is returned.
  39926. func (m WorkExperienceMutation) Client() *Client {
  39927. client := &Client{config: m.config}
  39928. client.init()
  39929. return client
  39930. }
  39931. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39932. // it returns an error otherwise.
  39933. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  39934. if _, ok := m.driver.(*txDriver); !ok {
  39935. return nil, errors.New("ent: mutation is not running in a transaction")
  39936. }
  39937. tx := &Tx{config: m.config}
  39938. tx.init()
  39939. return tx, nil
  39940. }
  39941. // SetID sets the value of the id field. Note that this
  39942. // operation is only accepted on creation of WorkExperience entities.
  39943. func (m *WorkExperienceMutation) SetID(id uint64) {
  39944. m.id = &id
  39945. }
  39946. // ID returns the ID value in the mutation. Note that the ID is only available
  39947. // if it was provided to the builder or after it was returned from the database.
  39948. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  39949. if m.id == nil {
  39950. return
  39951. }
  39952. return *m.id, true
  39953. }
  39954. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39955. // That means, if the mutation is applied within a transaction with an isolation level such
  39956. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39957. // or updated by the mutation.
  39958. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  39959. switch {
  39960. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39961. id, exists := m.ID()
  39962. if exists {
  39963. return []uint64{id}, nil
  39964. }
  39965. fallthrough
  39966. case m.op.Is(OpUpdate | OpDelete):
  39967. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  39968. default:
  39969. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39970. }
  39971. }
  39972. // SetCreatedAt sets the "created_at" field.
  39973. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  39974. m.created_at = &t
  39975. }
  39976. // CreatedAt returns the value of the "created_at" field in the mutation.
  39977. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  39978. v := m.created_at
  39979. if v == nil {
  39980. return
  39981. }
  39982. return *v, true
  39983. }
  39984. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  39985. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  39986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39987. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39988. if !m.op.Is(OpUpdateOne) {
  39989. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39990. }
  39991. if m.id == nil || m.oldValue == nil {
  39992. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39993. }
  39994. oldValue, err := m.oldValue(ctx)
  39995. if err != nil {
  39996. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39997. }
  39998. return oldValue.CreatedAt, nil
  39999. }
  40000. // ResetCreatedAt resets all changes to the "created_at" field.
  40001. func (m *WorkExperienceMutation) ResetCreatedAt() {
  40002. m.created_at = nil
  40003. }
  40004. // SetUpdatedAt sets the "updated_at" field.
  40005. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  40006. m.updated_at = &t
  40007. }
  40008. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40009. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  40010. v := m.updated_at
  40011. if v == nil {
  40012. return
  40013. }
  40014. return *v, true
  40015. }
  40016. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  40017. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40019. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40020. if !m.op.Is(OpUpdateOne) {
  40021. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40022. }
  40023. if m.id == nil || m.oldValue == nil {
  40024. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40025. }
  40026. oldValue, err := m.oldValue(ctx)
  40027. if err != nil {
  40028. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40029. }
  40030. return oldValue.UpdatedAt, nil
  40031. }
  40032. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40033. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  40034. m.updated_at = nil
  40035. }
  40036. // SetDeletedAt sets the "deleted_at" field.
  40037. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  40038. m.deleted_at = &t
  40039. }
  40040. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40041. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  40042. v := m.deleted_at
  40043. if v == nil {
  40044. return
  40045. }
  40046. return *v, true
  40047. }
  40048. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  40049. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40051. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40052. if !m.op.Is(OpUpdateOne) {
  40053. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40054. }
  40055. if m.id == nil || m.oldValue == nil {
  40056. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40057. }
  40058. oldValue, err := m.oldValue(ctx)
  40059. if err != nil {
  40060. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40061. }
  40062. return oldValue.DeletedAt, nil
  40063. }
  40064. // ClearDeletedAt clears the value of the "deleted_at" field.
  40065. func (m *WorkExperienceMutation) ClearDeletedAt() {
  40066. m.deleted_at = nil
  40067. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  40068. }
  40069. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40070. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  40071. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  40072. return ok
  40073. }
  40074. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40075. func (m *WorkExperienceMutation) ResetDeletedAt() {
  40076. m.deleted_at = nil
  40077. delete(m.clearedFields, workexperience.FieldDeletedAt)
  40078. }
  40079. // SetEmployeeID sets the "employee_id" field.
  40080. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  40081. m.employee = &u
  40082. }
  40083. // EmployeeID returns the value of the "employee_id" field in the mutation.
  40084. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  40085. v := m.employee
  40086. if v == nil {
  40087. return
  40088. }
  40089. return *v, true
  40090. }
  40091. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  40092. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40094. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  40095. if !m.op.Is(OpUpdateOne) {
  40096. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  40097. }
  40098. if m.id == nil || m.oldValue == nil {
  40099. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  40100. }
  40101. oldValue, err := m.oldValue(ctx)
  40102. if err != nil {
  40103. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  40104. }
  40105. return oldValue.EmployeeID, nil
  40106. }
  40107. // ResetEmployeeID resets all changes to the "employee_id" field.
  40108. func (m *WorkExperienceMutation) ResetEmployeeID() {
  40109. m.employee = nil
  40110. }
  40111. // SetStartDate sets the "start_date" field.
  40112. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  40113. m.start_date = &t
  40114. }
  40115. // StartDate returns the value of the "start_date" field in the mutation.
  40116. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  40117. v := m.start_date
  40118. if v == nil {
  40119. return
  40120. }
  40121. return *v, true
  40122. }
  40123. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  40124. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40126. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  40127. if !m.op.Is(OpUpdateOne) {
  40128. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  40129. }
  40130. if m.id == nil || m.oldValue == nil {
  40131. return v, errors.New("OldStartDate requires an ID field in the mutation")
  40132. }
  40133. oldValue, err := m.oldValue(ctx)
  40134. if err != nil {
  40135. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  40136. }
  40137. return oldValue.StartDate, nil
  40138. }
  40139. // ResetStartDate resets all changes to the "start_date" field.
  40140. func (m *WorkExperienceMutation) ResetStartDate() {
  40141. m.start_date = nil
  40142. }
  40143. // SetEndDate sets the "end_date" field.
  40144. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  40145. m.end_date = &t
  40146. }
  40147. // EndDate returns the value of the "end_date" field in the mutation.
  40148. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  40149. v := m.end_date
  40150. if v == nil {
  40151. return
  40152. }
  40153. return *v, true
  40154. }
  40155. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  40156. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40158. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  40159. if !m.op.Is(OpUpdateOne) {
  40160. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  40161. }
  40162. if m.id == nil || m.oldValue == nil {
  40163. return v, errors.New("OldEndDate requires an ID field in the mutation")
  40164. }
  40165. oldValue, err := m.oldValue(ctx)
  40166. if err != nil {
  40167. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  40168. }
  40169. return oldValue.EndDate, nil
  40170. }
  40171. // ResetEndDate resets all changes to the "end_date" field.
  40172. func (m *WorkExperienceMutation) ResetEndDate() {
  40173. m.end_date = nil
  40174. }
  40175. // SetCompany sets the "company" field.
  40176. func (m *WorkExperienceMutation) SetCompany(s string) {
  40177. m.company = &s
  40178. }
  40179. // Company returns the value of the "company" field in the mutation.
  40180. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  40181. v := m.company
  40182. if v == nil {
  40183. return
  40184. }
  40185. return *v, true
  40186. }
  40187. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  40188. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40190. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  40191. if !m.op.Is(OpUpdateOne) {
  40192. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  40193. }
  40194. if m.id == nil || m.oldValue == nil {
  40195. return v, errors.New("OldCompany requires an ID field in the mutation")
  40196. }
  40197. oldValue, err := m.oldValue(ctx)
  40198. if err != nil {
  40199. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  40200. }
  40201. return oldValue.Company, nil
  40202. }
  40203. // ResetCompany resets all changes to the "company" field.
  40204. func (m *WorkExperienceMutation) ResetCompany() {
  40205. m.company = nil
  40206. }
  40207. // SetExperience sets the "experience" field.
  40208. func (m *WorkExperienceMutation) SetExperience(s string) {
  40209. m.experience = &s
  40210. }
  40211. // Experience returns the value of the "experience" field in the mutation.
  40212. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  40213. v := m.experience
  40214. if v == nil {
  40215. return
  40216. }
  40217. return *v, true
  40218. }
  40219. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  40220. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40222. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  40223. if !m.op.Is(OpUpdateOne) {
  40224. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  40225. }
  40226. if m.id == nil || m.oldValue == nil {
  40227. return v, errors.New("OldExperience requires an ID field in the mutation")
  40228. }
  40229. oldValue, err := m.oldValue(ctx)
  40230. if err != nil {
  40231. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  40232. }
  40233. return oldValue.Experience, nil
  40234. }
  40235. // ResetExperience resets all changes to the "experience" field.
  40236. func (m *WorkExperienceMutation) ResetExperience() {
  40237. m.experience = nil
  40238. }
  40239. // SetOrganizationID sets the "organization_id" field.
  40240. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  40241. m.organization_id = &u
  40242. m.addorganization_id = nil
  40243. }
  40244. // OrganizationID returns the value of the "organization_id" field in the mutation.
  40245. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  40246. v := m.organization_id
  40247. if v == nil {
  40248. return
  40249. }
  40250. return *v, true
  40251. }
  40252. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  40253. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  40254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40255. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  40256. if !m.op.Is(OpUpdateOne) {
  40257. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  40258. }
  40259. if m.id == nil || m.oldValue == nil {
  40260. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  40261. }
  40262. oldValue, err := m.oldValue(ctx)
  40263. if err != nil {
  40264. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  40265. }
  40266. return oldValue.OrganizationID, nil
  40267. }
  40268. // AddOrganizationID adds u to the "organization_id" field.
  40269. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  40270. if m.addorganization_id != nil {
  40271. *m.addorganization_id += u
  40272. } else {
  40273. m.addorganization_id = &u
  40274. }
  40275. }
  40276. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  40277. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  40278. v := m.addorganization_id
  40279. if v == nil {
  40280. return
  40281. }
  40282. return *v, true
  40283. }
  40284. // ResetOrganizationID resets all changes to the "organization_id" field.
  40285. func (m *WorkExperienceMutation) ResetOrganizationID() {
  40286. m.organization_id = nil
  40287. m.addorganization_id = nil
  40288. }
  40289. // ClearEmployee clears the "employee" edge to the Employee entity.
  40290. func (m *WorkExperienceMutation) ClearEmployee() {
  40291. m.clearedemployee = true
  40292. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  40293. }
  40294. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  40295. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  40296. return m.clearedemployee
  40297. }
  40298. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  40299. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  40300. // EmployeeID instead. It exists only for internal usage by the builders.
  40301. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  40302. if id := m.employee; id != nil {
  40303. ids = append(ids, *id)
  40304. }
  40305. return
  40306. }
  40307. // ResetEmployee resets all changes to the "employee" edge.
  40308. func (m *WorkExperienceMutation) ResetEmployee() {
  40309. m.employee = nil
  40310. m.clearedemployee = false
  40311. }
  40312. // Where appends a list predicates to the WorkExperienceMutation builder.
  40313. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  40314. m.predicates = append(m.predicates, ps...)
  40315. }
  40316. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  40317. // users can use type-assertion to append predicates that do not depend on any generated package.
  40318. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  40319. p := make([]predicate.WorkExperience, len(ps))
  40320. for i := range ps {
  40321. p[i] = ps[i]
  40322. }
  40323. m.Where(p...)
  40324. }
  40325. // Op returns the operation name.
  40326. func (m *WorkExperienceMutation) Op() Op {
  40327. return m.op
  40328. }
  40329. // SetOp allows setting the mutation operation.
  40330. func (m *WorkExperienceMutation) SetOp(op Op) {
  40331. m.op = op
  40332. }
  40333. // Type returns the node type of this mutation (WorkExperience).
  40334. func (m *WorkExperienceMutation) Type() string {
  40335. return m.typ
  40336. }
  40337. // Fields returns all fields that were changed during this mutation. Note that in
  40338. // order to get all numeric fields that were incremented/decremented, call
  40339. // AddedFields().
  40340. func (m *WorkExperienceMutation) Fields() []string {
  40341. fields := make([]string, 0, 9)
  40342. if m.created_at != nil {
  40343. fields = append(fields, workexperience.FieldCreatedAt)
  40344. }
  40345. if m.updated_at != nil {
  40346. fields = append(fields, workexperience.FieldUpdatedAt)
  40347. }
  40348. if m.deleted_at != nil {
  40349. fields = append(fields, workexperience.FieldDeletedAt)
  40350. }
  40351. if m.employee != nil {
  40352. fields = append(fields, workexperience.FieldEmployeeID)
  40353. }
  40354. if m.start_date != nil {
  40355. fields = append(fields, workexperience.FieldStartDate)
  40356. }
  40357. if m.end_date != nil {
  40358. fields = append(fields, workexperience.FieldEndDate)
  40359. }
  40360. if m.company != nil {
  40361. fields = append(fields, workexperience.FieldCompany)
  40362. }
  40363. if m.experience != nil {
  40364. fields = append(fields, workexperience.FieldExperience)
  40365. }
  40366. if m.organization_id != nil {
  40367. fields = append(fields, workexperience.FieldOrganizationID)
  40368. }
  40369. return fields
  40370. }
  40371. // Field returns the value of a field with the given name. The second boolean
  40372. // return value indicates that this field was not set, or was not defined in the
  40373. // schema.
  40374. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  40375. switch name {
  40376. case workexperience.FieldCreatedAt:
  40377. return m.CreatedAt()
  40378. case workexperience.FieldUpdatedAt:
  40379. return m.UpdatedAt()
  40380. case workexperience.FieldDeletedAt:
  40381. return m.DeletedAt()
  40382. case workexperience.FieldEmployeeID:
  40383. return m.EmployeeID()
  40384. case workexperience.FieldStartDate:
  40385. return m.StartDate()
  40386. case workexperience.FieldEndDate:
  40387. return m.EndDate()
  40388. case workexperience.FieldCompany:
  40389. return m.Company()
  40390. case workexperience.FieldExperience:
  40391. return m.Experience()
  40392. case workexperience.FieldOrganizationID:
  40393. return m.OrganizationID()
  40394. }
  40395. return nil, false
  40396. }
  40397. // OldField returns the old value of the field from the database. An error is
  40398. // returned if the mutation operation is not UpdateOne, or the query to the
  40399. // database failed.
  40400. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40401. switch name {
  40402. case workexperience.FieldCreatedAt:
  40403. return m.OldCreatedAt(ctx)
  40404. case workexperience.FieldUpdatedAt:
  40405. return m.OldUpdatedAt(ctx)
  40406. case workexperience.FieldDeletedAt:
  40407. return m.OldDeletedAt(ctx)
  40408. case workexperience.FieldEmployeeID:
  40409. return m.OldEmployeeID(ctx)
  40410. case workexperience.FieldStartDate:
  40411. return m.OldStartDate(ctx)
  40412. case workexperience.FieldEndDate:
  40413. return m.OldEndDate(ctx)
  40414. case workexperience.FieldCompany:
  40415. return m.OldCompany(ctx)
  40416. case workexperience.FieldExperience:
  40417. return m.OldExperience(ctx)
  40418. case workexperience.FieldOrganizationID:
  40419. return m.OldOrganizationID(ctx)
  40420. }
  40421. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  40422. }
  40423. // SetField sets the value of a field with the given name. It returns an error if
  40424. // the field is not defined in the schema, or if the type mismatched the field
  40425. // type.
  40426. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  40427. switch name {
  40428. case workexperience.FieldCreatedAt:
  40429. v, ok := value.(time.Time)
  40430. if !ok {
  40431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40432. }
  40433. m.SetCreatedAt(v)
  40434. return nil
  40435. case workexperience.FieldUpdatedAt:
  40436. v, ok := value.(time.Time)
  40437. if !ok {
  40438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40439. }
  40440. m.SetUpdatedAt(v)
  40441. return nil
  40442. case workexperience.FieldDeletedAt:
  40443. v, ok := value.(time.Time)
  40444. if !ok {
  40445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40446. }
  40447. m.SetDeletedAt(v)
  40448. return nil
  40449. case workexperience.FieldEmployeeID:
  40450. v, ok := value.(uint64)
  40451. if !ok {
  40452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40453. }
  40454. m.SetEmployeeID(v)
  40455. return nil
  40456. case workexperience.FieldStartDate:
  40457. v, ok := value.(time.Time)
  40458. if !ok {
  40459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40460. }
  40461. m.SetStartDate(v)
  40462. return nil
  40463. case workexperience.FieldEndDate:
  40464. v, ok := value.(time.Time)
  40465. if !ok {
  40466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40467. }
  40468. m.SetEndDate(v)
  40469. return nil
  40470. case workexperience.FieldCompany:
  40471. v, ok := value.(string)
  40472. if !ok {
  40473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40474. }
  40475. m.SetCompany(v)
  40476. return nil
  40477. case workexperience.FieldExperience:
  40478. v, ok := value.(string)
  40479. if !ok {
  40480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40481. }
  40482. m.SetExperience(v)
  40483. return nil
  40484. case workexperience.FieldOrganizationID:
  40485. v, ok := value.(uint64)
  40486. if !ok {
  40487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40488. }
  40489. m.SetOrganizationID(v)
  40490. return nil
  40491. }
  40492. return fmt.Errorf("unknown WorkExperience field %s", name)
  40493. }
  40494. // AddedFields returns all numeric fields that were incremented/decremented during
  40495. // this mutation.
  40496. func (m *WorkExperienceMutation) AddedFields() []string {
  40497. var fields []string
  40498. if m.addorganization_id != nil {
  40499. fields = append(fields, workexperience.FieldOrganizationID)
  40500. }
  40501. return fields
  40502. }
  40503. // AddedField returns the numeric value that was incremented/decremented on a field
  40504. // with the given name. The second boolean return value indicates that this field
  40505. // was not set, or was not defined in the schema.
  40506. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  40507. switch name {
  40508. case workexperience.FieldOrganizationID:
  40509. return m.AddedOrganizationID()
  40510. }
  40511. return nil, false
  40512. }
  40513. // AddField adds the value to the field with the given name. It returns an error if
  40514. // the field is not defined in the schema, or if the type mismatched the field
  40515. // type.
  40516. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  40517. switch name {
  40518. case workexperience.FieldOrganizationID:
  40519. v, ok := value.(int64)
  40520. if !ok {
  40521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40522. }
  40523. m.AddOrganizationID(v)
  40524. return nil
  40525. }
  40526. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  40527. }
  40528. // ClearedFields returns all nullable fields that were cleared during this
  40529. // mutation.
  40530. func (m *WorkExperienceMutation) ClearedFields() []string {
  40531. var fields []string
  40532. if m.FieldCleared(workexperience.FieldDeletedAt) {
  40533. fields = append(fields, workexperience.FieldDeletedAt)
  40534. }
  40535. return fields
  40536. }
  40537. // FieldCleared returns a boolean indicating if a field with the given name was
  40538. // cleared in this mutation.
  40539. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  40540. _, ok := m.clearedFields[name]
  40541. return ok
  40542. }
  40543. // ClearField clears the value of the field with the given name. It returns an
  40544. // error if the field is not defined in the schema.
  40545. func (m *WorkExperienceMutation) ClearField(name string) error {
  40546. switch name {
  40547. case workexperience.FieldDeletedAt:
  40548. m.ClearDeletedAt()
  40549. return nil
  40550. }
  40551. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  40552. }
  40553. // ResetField resets all changes in the mutation for the field with the given name.
  40554. // It returns an error if the field is not defined in the schema.
  40555. func (m *WorkExperienceMutation) ResetField(name string) error {
  40556. switch name {
  40557. case workexperience.FieldCreatedAt:
  40558. m.ResetCreatedAt()
  40559. return nil
  40560. case workexperience.FieldUpdatedAt:
  40561. m.ResetUpdatedAt()
  40562. return nil
  40563. case workexperience.FieldDeletedAt:
  40564. m.ResetDeletedAt()
  40565. return nil
  40566. case workexperience.FieldEmployeeID:
  40567. m.ResetEmployeeID()
  40568. return nil
  40569. case workexperience.FieldStartDate:
  40570. m.ResetStartDate()
  40571. return nil
  40572. case workexperience.FieldEndDate:
  40573. m.ResetEndDate()
  40574. return nil
  40575. case workexperience.FieldCompany:
  40576. m.ResetCompany()
  40577. return nil
  40578. case workexperience.FieldExperience:
  40579. m.ResetExperience()
  40580. return nil
  40581. case workexperience.FieldOrganizationID:
  40582. m.ResetOrganizationID()
  40583. return nil
  40584. }
  40585. return fmt.Errorf("unknown WorkExperience field %s", name)
  40586. }
  40587. // AddedEdges returns all edge names that were set/added in this mutation.
  40588. func (m *WorkExperienceMutation) AddedEdges() []string {
  40589. edges := make([]string, 0, 1)
  40590. if m.employee != nil {
  40591. edges = append(edges, workexperience.EdgeEmployee)
  40592. }
  40593. return edges
  40594. }
  40595. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40596. // name in this mutation.
  40597. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  40598. switch name {
  40599. case workexperience.EdgeEmployee:
  40600. if id := m.employee; id != nil {
  40601. return []ent.Value{*id}
  40602. }
  40603. }
  40604. return nil
  40605. }
  40606. // RemovedEdges returns all edge names that were removed in this mutation.
  40607. func (m *WorkExperienceMutation) RemovedEdges() []string {
  40608. edges := make([]string, 0, 1)
  40609. return edges
  40610. }
  40611. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40612. // the given name in this mutation.
  40613. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  40614. return nil
  40615. }
  40616. // ClearedEdges returns all edge names that were cleared in this mutation.
  40617. func (m *WorkExperienceMutation) ClearedEdges() []string {
  40618. edges := make([]string, 0, 1)
  40619. if m.clearedemployee {
  40620. edges = append(edges, workexperience.EdgeEmployee)
  40621. }
  40622. return edges
  40623. }
  40624. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40625. // was cleared in this mutation.
  40626. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  40627. switch name {
  40628. case workexperience.EdgeEmployee:
  40629. return m.clearedemployee
  40630. }
  40631. return false
  40632. }
  40633. // ClearEdge clears the value of the edge with the given name. It returns an error
  40634. // if that edge is not defined in the schema.
  40635. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  40636. switch name {
  40637. case workexperience.EdgeEmployee:
  40638. m.ClearEmployee()
  40639. return nil
  40640. }
  40641. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  40642. }
  40643. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40644. // It returns an error if the edge is not defined in the schema.
  40645. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  40646. switch name {
  40647. case workexperience.EdgeEmployee:
  40648. m.ResetEmployee()
  40649. return nil
  40650. }
  40651. return fmt.Errorf("unknown WorkExperience edge %s", name)
  40652. }
  40653. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  40654. type WpChatroomMutation struct {
  40655. config
  40656. op Op
  40657. typ string
  40658. id *uint64
  40659. created_at *time.Time
  40660. updated_at *time.Time
  40661. status *uint8
  40662. addstatus *int8
  40663. wx_wxid *string
  40664. chatroom_id *string
  40665. nickname *string
  40666. owner *string
  40667. avatar *string
  40668. member_list *[]string
  40669. appendmember_list []string
  40670. clearedFields map[string]struct{}
  40671. done bool
  40672. oldValue func(context.Context) (*WpChatroom, error)
  40673. predicates []predicate.WpChatroom
  40674. }
  40675. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  40676. // wpchatroomOption allows management of the mutation configuration using functional options.
  40677. type wpchatroomOption func(*WpChatroomMutation)
  40678. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  40679. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  40680. m := &WpChatroomMutation{
  40681. config: c,
  40682. op: op,
  40683. typ: TypeWpChatroom,
  40684. clearedFields: make(map[string]struct{}),
  40685. }
  40686. for _, opt := range opts {
  40687. opt(m)
  40688. }
  40689. return m
  40690. }
  40691. // withWpChatroomID sets the ID field of the mutation.
  40692. func withWpChatroomID(id uint64) wpchatroomOption {
  40693. return func(m *WpChatroomMutation) {
  40694. var (
  40695. err error
  40696. once sync.Once
  40697. value *WpChatroom
  40698. )
  40699. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  40700. once.Do(func() {
  40701. if m.done {
  40702. err = errors.New("querying old values post mutation is not allowed")
  40703. } else {
  40704. value, err = m.Client().WpChatroom.Get(ctx, id)
  40705. }
  40706. })
  40707. return value, err
  40708. }
  40709. m.id = &id
  40710. }
  40711. }
  40712. // withWpChatroom sets the old WpChatroom of the mutation.
  40713. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  40714. return func(m *WpChatroomMutation) {
  40715. m.oldValue = func(context.Context) (*WpChatroom, error) {
  40716. return node, nil
  40717. }
  40718. m.id = &node.ID
  40719. }
  40720. }
  40721. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40722. // executed in a transaction (ent.Tx), a transactional client is returned.
  40723. func (m WpChatroomMutation) Client() *Client {
  40724. client := &Client{config: m.config}
  40725. client.init()
  40726. return client
  40727. }
  40728. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40729. // it returns an error otherwise.
  40730. func (m WpChatroomMutation) Tx() (*Tx, error) {
  40731. if _, ok := m.driver.(*txDriver); !ok {
  40732. return nil, errors.New("ent: mutation is not running in a transaction")
  40733. }
  40734. tx := &Tx{config: m.config}
  40735. tx.init()
  40736. return tx, nil
  40737. }
  40738. // SetID sets the value of the id field. Note that this
  40739. // operation is only accepted on creation of WpChatroom entities.
  40740. func (m *WpChatroomMutation) SetID(id uint64) {
  40741. m.id = &id
  40742. }
  40743. // ID returns the ID value in the mutation. Note that the ID is only available
  40744. // if it was provided to the builder or after it was returned from the database.
  40745. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  40746. if m.id == nil {
  40747. return
  40748. }
  40749. return *m.id, true
  40750. }
  40751. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40752. // That means, if the mutation is applied within a transaction with an isolation level such
  40753. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40754. // or updated by the mutation.
  40755. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  40756. switch {
  40757. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40758. id, exists := m.ID()
  40759. if exists {
  40760. return []uint64{id}, nil
  40761. }
  40762. fallthrough
  40763. case m.op.Is(OpUpdate | OpDelete):
  40764. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  40765. default:
  40766. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40767. }
  40768. }
  40769. // SetCreatedAt sets the "created_at" field.
  40770. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  40771. m.created_at = &t
  40772. }
  40773. // CreatedAt returns the value of the "created_at" field in the mutation.
  40774. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  40775. v := m.created_at
  40776. if v == nil {
  40777. return
  40778. }
  40779. return *v, true
  40780. }
  40781. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  40782. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40784. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40785. if !m.op.Is(OpUpdateOne) {
  40786. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40787. }
  40788. if m.id == nil || m.oldValue == nil {
  40789. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40790. }
  40791. oldValue, err := m.oldValue(ctx)
  40792. if err != nil {
  40793. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40794. }
  40795. return oldValue.CreatedAt, nil
  40796. }
  40797. // ResetCreatedAt resets all changes to the "created_at" field.
  40798. func (m *WpChatroomMutation) ResetCreatedAt() {
  40799. m.created_at = nil
  40800. }
  40801. // SetUpdatedAt sets the "updated_at" field.
  40802. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  40803. m.updated_at = &t
  40804. }
  40805. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40806. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  40807. v := m.updated_at
  40808. if v == nil {
  40809. return
  40810. }
  40811. return *v, true
  40812. }
  40813. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  40814. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40816. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40817. if !m.op.Is(OpUpdateOne) {
  40818. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40819. }
  40820. if m.id == nil || m.oldValue == nil {
  40821. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40822. }
  40823. oldValue, err := m.oldValue(ctx)
  40824. if err != nil {
  40825. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40826. }
  40827. return oldValue.UpdatedAt, nil
  40828. }
  40829. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40830. func (m *WpChatroomMutation) ResetUpdatedAt() {
  40831. m.updated_at = nil
  40832. }
  40833. // SetStatus sets the "status" field.
  40834. func (m *WpChatroomMutation) SetStatus(u uint8) {
  40835. m.status = &u
  40836. m.addstatus = nil
  40837. }
  40838. // Status returns the value of the "status" field in the mutation.
  40839. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  40840. v := m.status
  40841. if v == nil {
  40842. return
  40843. }
  40844. return *v, true
  40845. }
  40846. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  40847. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40849. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40850. if !m.op.Is(OpUpdateOne) {
  40851. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40852. }
  40853. if m.id == nil || m.oldValue == nil {
  40854. return v, errors.New("OldStatus requires an ID field in the mutation")
  40855. }
  40856. oldValue, err := m.oldValue(ctx)
  40857. if err != nil {
  40858. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40859. }
  40860. return oldValue.Status, nil
  40861. }
  40862. // AddStatus adds u to the "status" field.
  40863. func (m *WpChatroomMutation) AddStatus(u int8) {
  40864. if m.addstatus != nil {
  40865. *m.addstatus += u
  40866. } else {
  40867. m.addstatus = &u
  40868. }
  40869. }
  40870. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40871. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  40872. v := m.addstatus
  40873. if v == nil {
  40874. return
  40875. }
  40876. return *v, true
  40877. }
  40878. // ClearStatus clears the value of the "status" field.
  40879. func (m *WpChatroomMutation) ClearStatus() {
  40880. m.status = nil
  40881. m.addstatus = nil
  40882. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  40883. }
  40884. // StatusCleared returns if the "status" field was cleared in this mutation.
  40885. func (m *WpChatroomMutation) StatusCleared() bool {
  40886. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  40887. return ok
  40888. }
  40889. // ResetStatus resets all changes to the "status" field.
  40890. func (m *WpChatroomMutation) ResetStatus() {
  40891. m.status = nil
  40892. m.addstatus = nil
  40893. delete(m.clearedFields, wpchatroom.FieldStatus)
  40894. }
  40895. // SetWxWxid sets the "wx_wxid" field.
  40896. func (m *WpChatroomMutation) SetWxWxid(s string) {
  40897. m.wx_wxid = &s
  40898. }
  40899. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  40900. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  40901. v := m.wx_wxid
  40902. if v == nil {
  40903. return
  40904. }
  40905. return *v, true
  40906. }
  40907. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  40908. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40910. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  40911. if !m.op.Is(OpUpdateOne) {
  40912. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  40913. }
  40914. if m.id == nil || m.oldValue == nil {
  40915. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  40916. }
  40917. oldValue, err := m.oldValue(ctx)
  40918. if err != nil {
  40919. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  40920. }
  40921. return oldValue.WxWxid, nil
  40922. }
  40923. // ResetWxWxid resets all changes to the "wx_wxid" field.
  40924. func (m *WpChatroomMutation) ResetWxWxid() {
  40925. m.wx_wxid = nil
  40926. }
  40927. // SetChatroomID sets the "chatroom_id" field.
  40928. func (m *WpChatroomMutation) SetChatroomID(s string) {
  40929. m.chatroom_id = &s
  40930. }
  40931. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  40932. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  40933. v := m.chatroom_id
  40934. if v == nil {
  40935. return
  40936. }
  40937. return *v, true
  40938. }
  40939. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  40940. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40942. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  40943. if !m.op.Is(OpUpdateOne) {
  40944. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  40945. }
  40946. if m.id == nil || m.oldValue == nil {
  40947. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  40948. }
  40949. oldValue, err := m.oldValue(ctx)
  40950. if err != nil {
  40951. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  40952. }
  40953. return oldValue.ChatroomID, nil
  40954. }
  40955. // ResetChatroomID resets all changes to the "chatroom_id" field.
  40956. func (m *WpChatroomMutation) ResetChatroomID() {
  40957. m.chatroom_id = nil
  40958. }
  40959. // SetNickname sets the "nickname" field.
  40960. func (m *WpChatroomMutation) SetNickname(s string) {
  40961. m.nickname = &s
  40962. }
  40963. // Nickname returns the value of the "nickname" field in the mutation.
  40964. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  40965. v := m.nickname
  40966. if v == nil {
  40967. return
  40968. }
  40969. return *v, true
  40970. }
  40971. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  40972. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  40973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40974. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  40975. if !m.op.Is(OpUpdateOne) {
  40976. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40977. }
  40978. if m.id == nil || m.oldValue == nil {
  40979. return v, errors.New("OldNickname requires an ID field in the mutation")
  40980. }
  40981. oldValue, err := m.oldValue(ctx)
  40982. if err != nil {
  40983. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40984. }
  40985. return oldValue.Nickname, nil
  40986. }
  40987. // ResetNickname resets all changes to the "nickname" field.
  40988. func (m *WpChatroomMutation) ResetNickname() {
  40989. m.nickname = nil
  40990. }
  40991. // SetOwner sets the "owner" field.
  40992. func (m *WpChatroomMutation) SetOwner(s string) {
  40993. m.owner = &s
  40994. }
  40995. // Owner returns the value of the "owner" field in the mutation.
  40996. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  40997. v := m.owner
  40998. if v == nil {
  40999. return
  41000. }
  41001. return *v, true
  41002. }
  41003. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  41004. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41006. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  41007. if !m.op.Is(OpUpdateOne) {
  41008. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  41009. }
  41010. if m.id == nil || m.oldValue == nil {
  41011. return v, errors.New("OldOwner requires an ID field in the mutation")
  41012. }
  41013. oldValue, err := m.oldValue(ctx)
  41014. if err != nil {
  41015. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  41016. }
  41017. return oldValue.Owner, nil
  41018. }
  41019. // ResetOwner resets all changes to the "owner" field.
  41020. func (m *WpChatroomMutation) ResetOwner() {
  41021. m.owner = nil
  41022. }
  41023. // SetAvatar sets the "avatar" field.
  41024. func (m *WpChatroomMutation) SetAvatar(s string) {
  41025. m.avatar = &s
  41026. }
  41027. // Avatar returns the value of the "avatar" field in the mutation.
  41028. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  41029. v := m.avatar
  41030. if v == nil {
  41031. return
  41032. }
  41033. return *v, true
  41034. }
  41035. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  41036. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41037. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41038. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41039. if !m.op.Is(OpUpdateOne) {
  41040. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41041. }
  41042. if m.id == nil || m.oldValue == nil {
  41043. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41044. }
  41045. oldValue, err := m.oldValue(ctx)
  41046. if err != nil {
  41047. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41048. }
  41049. return oldValue.Avatar, nil
  41050. }
  41051. // ResetAvatar resets all changes to the "avatar" field.
  41052. func (m *WpChatroomMutation) ResetAvatar() {
  41053. m.avatar = nil
  41054. }
  41055. // SetMemberList sets the "member_list" field.
  41056. func (m *WpChatroomMutation) SetMemberList(s []string) {
  41057. m.member_list = &s
  41058. m.appendmember_list = nil
  41059. }
  41060. // MemberList returns the value of the "member_list" field in the mutation.
  41061. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  41062. v := m.member_list
  41063. if v == nil {
  41064. return
  41065. }
  41066. return *v, true
  41067. }
  41068. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  41069. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  41070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41071. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  41072. if !m.op.Is(OpUpdateOne) {
  41073. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  41074. }
  41075. if m.id == nil || m.oldValue == nil {
  41076. return v, errors.New("OldMemberList requires an ID field in the mutation")
  41077. }
  41078. oldValue, err := m.oldValue(ctx)
  41079. if err != nil {
  41080. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  41081. }
  41082. return oldValue.MemberList, nil
  41083. }
  41084. // AppendMemberList adds s to the "member_list" field.
  41085. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  41086. m.appendmember_list = append(m.appendmember_list, s...)
  41087. }
  41088. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  41089. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  41090. if len(m.appendmember_list) == 0 {
  41091. return nil, false
  41092. }
  41093. return m.appendmember_list, true
  41094. }
  41095. // ResetMemberList resets all changes to the "member_list" field.
  41096. func (m *WpChatroomMutation) ResetMemberList() {
  41097. m.member_list = nil
  41098. m.appendmember_list = nil
  41099. }
  41100. // Where appends a list predicates to the WpChatroomMutation builder.
  41101. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  41102. m.predicates = append(m.predicates, ps...)
  41103. }
  41104. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  41105. // users can use type-assertion to append predicates that do not depend on any generated package.
  41106. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  41107. p := make([]predicate.WpChatroom, len(ps))
  41108. for i := range ps {
  41109. p[i] = ps[i]
  41110. }
  41111. m.Where(p...)
  41112. }
  41113. // Op returns the operation name.
  41114. func (m *WpChatroomMutation) Op() Op {
  41115. return m.op
  41116. }
  41117. // SetOp allows setting the mutation operation.
  41118. func (m *WpChatroomMutation) SetOp(op Op) {
  41119. m.op = op
  41120. }
  41121. // Type returns the node type of this mutation (WpChatroom).
  41122. func (m *WpChatroomMutation) Type() string {
  41123. return m.typ
  41124. }
  41125. // Fields returns all fields that were changed during this mutation. Note that in
  41126. // order to get all numeric fields that were incremented/decremented, call
  41127. // AddedFields().
  41128. func (m *WpChatroomMutation) Fields() []string {
  41129. fields := make([]string, 0, 9)
  41130. if m.created_at != nil {
  41131. fields = append(fields, wpchatroom.FieldCreatedAt)
  41132. }
  41133. if m.updated_at != nil {
  41134. fields = append(fields, wpchatroom.FieldUpdatedAt)
  41135. }
  41136. if m.status != nil {
  41137. fields = append(fields, wpchatroom.FieldStatus)
  41138. }
  41139. if m.wx_wxid != nil {
  41140. fields = append(fields, wpchatroom.FieldWxWxid)
  41141. }
  41142. if m.chatroom_id != nil {
  41143. fields = append(fields, wpchatroom.FieldChatroomID)
  41144. }
  41145. if m.nickname != nil {
  41146. fields = append(fields, wpchatroom.FieldNickname)
  41147. }
  41148. if m.owner != nil {
  41149. fields = append(fields, wpchatroom.FieldOwner)
  41150. }
  41151. if m.avatar != nil {
  41152. fields = append(fields, wpchatroom.FieldAvatar)
  41153. }
  41154. if m.member_list != nil {
  41155. fields = append(fields, wpchatroom.FieldMemberList)
  41156. }
  41157. return fields
  41158. }
  41159. // Field returns the value of a field with the given name. The second boolean
  41160. // return value indicates that this field was not set, or was not defined in the
  41161. // schema.
  41162. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  41163. switch name {
  41164. case wpchatroom.FieldCreatedAt:
  41165. return m.CreatedAt()
  41166. case wpchatroom.FieldUpdatedAt:
  41167. return m.UpdatedAt()
  41168. case wpchatroom.FieldStatus:
  41169. return m.Status()
  41170. case wpchatroom.FieldWxWxid:
  41171. return m.WxWxid()
  41172. case wpchatroom.FieldChatroomID:
  41173. return m.ChatroomID()
  41174. case wpchatroom.FieldNickname:
  41175. return m.Nickname()
  41176. case wpchatroom.FieldOwner:
  41177. return m.Owner()
  41178. case wpchatroom.FieldAvatar:
  41179. return m.Avatar()
  41180. case wpchatroom.FieldMemberList:
  41181. return m.MemberList()
  41182. }
  41183. return nil, false
  41184. }
  41185. // OldField returns the old value of the field from the database. An error is
  41186. // returned if the mutation operation is not UpdateOne, or the query to the
  41187. // database failed.
  41188. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41189. switch name {
  41190. case wpchatroom.FieldCreatedAt:
  41191. return m.OldCreatedAt(ctx)
  41192. case wpchatroom.FieldUpdatedAt:
  41193. return m.OldUpdatedAt(ctx)
  41194. case wpchatroom.FieldStatus:
  41195. return m.OldStatus(ctx)
  41196. case wpchatroom.FieldWxWxid:
  41197. return m.OldWxWxid(ctx)
  41198. case wpchatroom.FieldChatroomID:
  41199. return m.OldChatroomID(ctx)
  41200. case wpchatroom.FieldNickname:
  41201. return m.OldNickname(ctx)
  41202. case wpchatroom.FieldOwner:
  41203. return m.OldOwner(ctx)
  41204. case wpchatroom.FieldAvatar:
  41205. return m.OldAvatar(ctx)
  41206. case wpchatroom.FieldMemberList:
  41207. return m.OldMemberList(ctx)
  41208. }
  41209. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  41210. }
  41211. // SetField sets the value of a field with the given name. It returns an error if
  41212. // the field is not defined in the schema, or if the type mismatched the field
  41213. // type.
  41214. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  41215. switch name {
  41216. case wpchatroom.FieldCreatedAt:
  41217. v, ok := value.(time.Time)
  41218. if !ok {
  41219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41220. }
  41221. m.SetCreatedAt(v)
  41222. return nil
  41223. case wpchatroom.FieldUpdatedAt:
  41224. v, ok := value.(time.Time)
  41225. if !ok {
  41226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41227. }
  41228. m.SetUpdatedAt(v)
  41229. return nil
  41230. case wpchatroom.FieldStatus:
  41231. v, ok := value.(uint8)
  41232. if !ok {
  41233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41234. }
  41235. m.SetStatus(v)
  41236. return nil
  41237. case wpchatroom.FieldWxWxid:
  41238. v, ok := value.(string)
  41239. if !ok {
  41240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41241. }
  41242. m.SetWxWxid(v)
  41243. return nil
  41244. case wpchatroom.FieldChatroomID:
  41245. v, ok := value.(string)
  41246. if !ok {
  41247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41248. }
  41249. m.SetChatroomID(v)
  41250. return nil
  41251. case wpchatroom.FieldNickname:
  41252. v, ok := value.(string)
  41253. if !ok {
  41254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41255. }
  41256. m.SetNickname(v)
  41257. return nil
  41258. case wpchatroom.FieldOwner:
  41259. v, ok := value.(string)
  41260. if !ok {
  41261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41262. }
  41263. m.SetOwner(v)
  41264. return nil
  41265. case wpchatroom.FieldAvatar:
  41266. v, ok := value.(string)
  41267. if !ok {
  41268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41269. }
  41270. m.SetAvatar(v)
  41271. return nil
  41272. case wpchatroom.FieldMemberList:
  41273. v, ok := value.([]string)
  41274. if !ok {
  41275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41276. }
  41277. m.SetMemberList(v)
  41278. return nil
  41279. }
  41280. return fmt.Errorf("unknown WpChatroom field %s", name)
  41281. }
  41282. // AddedFields returns all numeric fields that were incremented/decremented during
  41283. // this mutation.
  41284. func (m *WpChatroomMutation) AddedFields() []string {
  41285. var fields []string
  41286. if m.addstatus != nil {
  41287. fields = append(fields, wpchatroom.FieldStatus)
  41288. }
  41289. return fields
  41290. }
  41291. // AddedField returns the numeric value that was incremented/decremented on a field
  41292. // with the given name. The second boolean return value indicates that this field
  41293. // was not set, or was not defined in the schema.
  41294. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  41295. switch name {
  41296. case wpchatroom.FieldStatus:
  41297. return m.AddedStatus()
  41298. }
  41299. return nil, false
  41300. }
  41301. // AddField adds the value to the field with the given name. It returns an error if
  41302. // the field is not defined in the schema, or if the type mismatched the field
  41303. // type.
  41304. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  41305. switch name {
  41306. case wpchatroom.FieldStatus:
  41307. v, ok := value.(int8)
  41308. if !ok {
  41309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41310. }
  41311. m.AddStatus(v)
  41312. return nil
  41313. }
  41314. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  41315. }
  41316. // ClearedFields returns all nullable fields that were cleared during this
  41317. // mutation.
  41318. func (m *WpChatroomMutation) ClearedFields() []string {
  41319. var fields []string
  41320. if m.FieldCleared(wpchatroom.FieldStatus) {
  41321. fields = append(fields, wpchatroom.FieldStatus)
  41322. }
  41323. return fields
  41324. }
  41325. // FieldCleared returns a boolean indicating if a field with the given name was
  41326. // cleared in this mutation.
  41327. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  41328. _, ok := m.clearedFields[name]
  41329. return ok
  41330. }
  41331. // ClearField clears the value of the field with the given name. It returns an
  41332. // error if the field is not defined in the schema.
  41333. func (m *WpChatroomMutation) ClearField(name string) error {
  41334. switch name {
  41335. case wpchatroom.FieldStatus:
  41336. m.ClearStatus()
  41337. return nil
  41338. }
  41339. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  41340. }
  41341. // ResetField resets all changes in the mutation for the field with the given name.
  41342. // It returns an error if the field is not defined in the schema.
  41343. func (m *WpChatroomMutation) ResetField(name string) error {
  41344. switch name {
  41345. case wpchatroom.FieldCreatedAt:
  41346. m.ResetCreatedAt()
  41347. return nil
  41348. case wpchatroom.FieldUpdatedAt:
  41349. m.ResetUpdatedAt()
  41350. return nil
  41351. case wpchatroom.FieldStatus:
  41352. m.ResetStatus()
  41353. return nil
  41354. case wpchatroom.FieldWxWxid:
  41355. m.ResetWxWxid()
  41356. return nil
  41357. case wpchatroom.FieldChatroomID:
  41358. m.ResetChatroomID()
  41359. return nil
  41360. case wpchatroom.FieldNickname:
  41361. m.ResetNickname()
  41362. return nil
  41363. case wpchatroom.FieldOwner:
  41364. m.ResetOwner()
  41365. return nil
  41366. case wpchatroom.FieldAvatar:
  41367. m.ResetAvatar()
  41368. return nil
  41369. case wpchatroom.FieldMemberList:
  41370. m.ResetMemberList()
  41371. return nil
  41372. }
  41373. return fmt.Errorf("unknown WpChatroom field %s", name)
  41374. }
  41375. // AddedEdges returns all edge names that were set/added in this mutation.
  41376. func (m *WpChatroomMutation) AddedEdges() []string {
  41377. edges := make([]string, 0, 0)
  41378. return edges
  41379. }
  41380. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41381. // name in this mutation.
  41382. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  41383. return nil
  41384. }
  41385. // RemovedEdges returns all edge names that were removed in this mutation.
  41386. func (m *WpChatroomMutation) RemovedEdges() []string {
  41387. edges := make([]string, 0, 0)
  41388. return edges
  41389. }
  41390. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41391. // the given name in this mutation.
  41392. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  41393. return nil
  41394. }
  41395. // ClearedEdges returns all edge names that were cleared in this mutation.
  41396. func (m *WpChatroomMutation) ClearedEdges() []string {
  41397. edges := make([]string, 0, 0)
  41398. return edges
  41399. }
  41400. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41401. // was cleared in this mutation.
  41402. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  41403. return false
  41404. }
  41405. // ClearEdge clears the value of the edge with the given name. It returns an error
  41406. // if that edge is not defined in the schema.
  41407. func (m *WpChatroomMutation) ClearEdge(name string) error {
  41408. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  41409. }
  41410. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41411. // It returns an error if the edge is not defined in the schema.
  41412. func (m *WpChatroomMutation) ResetEdge(name string) error {
  41413. return fmt.Errorf("unknown WpChatroom edge %s", name)
  41414. }
  41415. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  41416. type WpChatroomMemberMutation struct {
  41417. config
  41418. op Op
  41419. typ string
  41420. id *uint64
  41421. created_at *time.Time
  41422. updated_at *time.Time
  41423. status *uint8
  41424. addstatus *int8
  41425. wx_wxid *string
  41426. wxid *string
  41427. nickname *string
  41428. avatar *string
  41429. clearedFields map[string]struct{}
  41430. done bool
  41431. oldValue func(context.Context) (*WpChatroomMember, error)
  41432. predicates []predicate.WpChatroomMember
  41433. }
  41434. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  41435. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  41436. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  41437. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  41438. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  41439. m := &WpChatroomMemberMutation{
  41440. config: c,
  41441. op: op,
  41442. typ: TypeWpChatroomMember,
  41443. clearedFields: make(map[string]struct{}),
  41444. }
  41445. for _, opt := range opts {
  41446. opt(m)
  41447. }
  41448. return m
  41449. }
  41450. // withWpChatroomMemberID sets the ID field of the mutation.
  41451. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  41452. return func(m *WpChatroomMemberMutation) {
  41453. var (
  41454. err error
  41455. once sync.Once
  41456. value *WpChatroomMember
  41457. )
  41458. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  41459. once.Do(func() {
  41460. if m.done {
  41461. err = errors.New("querying old values post mutation is not allowed")
  41462. } else {
  41463. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  41464. }
  41465. })
  41466. return value, err
  41467. }
  41468. m.id = &id
  41469. }
  41470. }
  41471. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  41472. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  41473. return func(m *WpChatroomMemberMutation) {
  41474. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  41475. return node, nil
  41476. }
  41477. m.id = &node.ID
  41478. }
  41479. }
  41480. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41481. // executed in a transaction (ent.Tx), a transactional client is returned.
  41482. func (m WpChatroomMemberMutation) Client() *Client {
  41483. client := &Client{config: m.config}
  41484. client.init()
  41485. return client
  41486. }
  41487. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41488. // it returns an error otherwise.
  41489. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  41490. if _, ok := m.driver.(*txDriver); !ok {
  41491. return nil, errors.New("ent: mutation is not running in a transaction")
  41492. }
  41493. tx := &Tx{config: m.config}
  41494. tx.init()
  41495. return tx, nil
  41496. }
  41497. // SetID sets the value of the id field. Note that this
  41498. // operation is only accepted on creation of WpChatroomMember entities.
  41499. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  41500. m.id = &id
  41501. }
  41502. // ID returns the ID value in the mutation. Note that the ID is only available
  41503. // if it was provided to the builder or after it was returned from the database.
  41504. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  41505. if m.id == nil {
  41506. return
  41507. }
  41508. return *m.id, true
  41509. }
  41510. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41511. // That means, if the mutation is applied within a transaction with an isolation level such
  41512. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41513. // or updated by the mutation.
  41514. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  41515. switch {
  41516. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41517. id, exists := m.ID()
  41518. if exists {
  41519. return []uint64{id}, nil
  41520. }
  41521. fallthrough
  41522. case m.op.Is(OpUpdate | OpDelete):
  41523. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  41524. default:
  41525. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41526. }
  41527. }
  41528. // SetCreatedAt sets the "created_at" field.
  41529. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  41530. m.created_at = &t
  41531. }
  41532. // CreatedAt returns the value of the "created_at" field in the mutation.
  41533. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  41534. v := m.created_at
  41535. if v == nil {
  41536. return
  41537. }
  41538. return *v, true
  41539. }
  41540. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  41541. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41543. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41544. if !m.op.Is(OpUpdateOne) {
  41545. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41546. }
  41547. if m.id == nil || m.oldValue == nil {
  41548. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41549. }
  41550. oldValue, err := m.oldValue(ctx)
  41551. if err != nil {
  41552. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41553. }
  41554. return oldValue.CreatedAt, nil
  41555. }
  41556. // ResetCreatedAt resets all changes to the "created_at" field.
  41557. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  41558. m.created_at = nil
  41559. }
  41560. // SetUpdatedAt sets the "updated_at" field.
  41561. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  41562. m.updated_at = &t
  41563. }
  41564. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41565. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  41566. v := m.updated_at
  41567. if v == nil {
  41568. return
  41569. }
  41570. return *v, true
  41571. }
  41572. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  41573. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41575. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41576. if !m.op.Is(OpUpdateOne) {
  41577. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41578. }
  41579. if m.id == nil || m.oldValue == nil {
  41580. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41581. }
  41582. oldValue, err := m.oldValue(ctx)
  41583. if err != nil {
  41584. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41585. }
  41586. return oldValue.UpdatedAt, nil
  41587. }
  41588. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41589. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  41590. m.updated_at = nil
  41591. }
  41592. // SetStatus sets the "status" field.
  41593. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  41594. m.status = &u
  41595. m.addstatus = nil
  41596. }
  41597. // Status returns the value of the "status" field in the mutation.
  41598. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  41599. v := m.status
  41600. if v == nil {
  41601. return
  41602. }
  41603. return *v, true
  41604. }
  41605. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  41606. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41608. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  41609. if !m.op.Is(OpUpdateOne) {
  41610. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  41611. }
  41612. if m.id == nil || m.oldValue == nil {
  41613. return v, errors.New("OldStatus requires an ID field in the mutation")
  41614. }
  41615. oldValue, err := m.oldValue(ctx)
  41616. if err != nil {
  41617. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  41618. }
  41619. return oldValue.Status, nil
  41620. }
  41621. // AddStatus adds u to the "status" field.
  41622. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  41623. if m.addstatus != nil {
  41624. *m.addstatus += u
  41625. } else {
  41626. m.addstatus = &u
  41627. }
  41628. }
  41629. // AddedStatus returns the value that was added to the "status" field in this mutation.
  41630. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  41631. v := m.addstatus
  41632. if v == nil {
  41633. return
  41634. }
  41635. return *v, true
  41636. }
  41637. // ClearStatus clears the value of the "status" field.
  41638. func (m *WpChatroomMemberMutation) ClearStatus() {
  41639. m.status = nil
  41640. m.addstatus = nil
  41641. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  41642. }
  41643. // StatusCleared returns if the "status" field was cleared in this mutation.
  41644. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  41645. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  41646. return ok
  41647. }
  41648. // ResetStatus resets all changes to the "status" field.
  41649. func (m *WpChatroomMemberMutation) ResetStatus() {
  41650. m.status = nil
  41651. m.addstatus = nil
  41652. delete(m.clearedFields, wpchatroommember.FieldStatus)
  41653. }
  41654. // SetWxWxid sets the "wx_wxid" field.
  41655. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  41656. m.wx_wxid = &s
  41657. }
  41658. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  41659. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  41660. v := m.wx_wxid
  41661. if v == nil {
  41662. return
  41663. }
  41664. return *v, true
  41665. }
  41666. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  41667. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41669. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  41670. if !m.op.Is(OpUpdateOne) {
  41671. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  41672. }
  41673. if m.id == nil || m.oldValue == nil {
  41674. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  41675. }
  41676. oldValue, err := m.oldValue(ctx)
  41677. if err != nil {
  41678. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  41679. }
  41680. return oldValue.WxWxid, nil
  41681. }
  41682. // ResetWxWxid resets all changes to the "wx_wxid" field.
  41683. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  41684. m.wx_wxid = nil
  41685. }
  41686. // SetWxid sets the "wxid" field.
  41687. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  41688. m.wxid = &s
  41689. }
  41690. // Wxid returns the value of the "wxid" field in the mutation.
  41691. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  41692. v := m.wxid
  41693. if v == nil {
  41694. return
  41695. }
  41696. return *v, true
  41697. }
  41698. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  41699. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41701. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  41702. if !m.op.Is(OpUpdateOne) {
  41703. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  41704. }
  41705. if m.id == nil || m.oldValue == nil {
  41706. return v, errors.New("OldWxid requires an ID field in the mutation")
  41707. }
  41708. oldValue, err := m.oldValue(ctx)
  41709. if err != nil {
  41710. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  41711. }
  41712. return oldValue.Wxid, nil
  41713. }
  41714. // ResetWxid resets all changes to the "wxid" field.
  41715. func (m *WpChatroomMemberMutation) ResetWxid() {
  41716. m.wxid = nil
  41717. }
  41718. // SetNickname sets the "nickname" field.
  41719. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  41720. m.nickname = &s
  41721. }
  41722. // Nickname returns the value of the "nickname" field in the mutation.
  41723. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  41724. v := m.nickname
  41725. if v == nil {
  41726. return
  41727. }
  41728. return *v, true
  41729. }
  41730. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  41731. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41733. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  41734. if !m.op.Is(OpUpdateOne) {
  41735. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  41736. }
  41737. if m.id == nil || m.oldValue == nil {
  41738. return v, errors.New("OldNickname requires an ID field in the mutation")
  41739. }
  41740. oldValue, err := m.oldValue(ctx)
  41741. if err != nil {
  41742. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  41743. }
  41744. return oldValue.Nickname, nil
  41745. }
  41746. // ResetNickname resets all changes to the "nickname" field.
  41747. func (m *WpChatroomMemberMutation) ResetNickname() {
  41748. m.nickname = nil
  41749. }
  41750. // SetAvatar sets the "avatar" field.
  41751. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  41752. m.avatar = &s
  41753. }
  41754. // Avatar returns the value of the "avatar" field in the mutation.
  41755. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  41756. v := m.avatar
  41757. if v == nil {
  41758. return
  41759. }
  41760. return *v, true
  41761. }
  41762. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  41763. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  41764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41765. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  41766. if !m.op.Is(OpUpdateOne) {
  41767. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  41768. }
  41769. if m.id == nil || m.oldValue == nil {
  41770. return v, errors.New("OldAvatar requires an ID field in the mutation")
  41771. }
  41772. oldValue, err := m.oldValue(ctx)
  41773. if err != nil {
  41774. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  41775. }
  41776. return oldValue.Avatar, nil
  41777. }
  41778. // ResetAvatar resets all changes to the "avatar" field.
  41779. func (m *WpChatroomMemberMutation) ResetAvatar() {
  41780. m.avatar = nil
  41781. }
  41782. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  41783. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  41784. m.predicates = append(m.predicates, ps...)
  41785. }
  41786. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  41787. // users can use type-assertion to append predicates that do not depend on any generated package.
  41788. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  41789. p := make([]predicate.WpChatroomMember, len(ps))
  41790. for i := range ps {
  41791. p[i] = ps[i]
  41792. }
  41793. m.Where(p...)
  41794. }
  41795. // Op returns the operation name.
  41796. func (m *WpChatroomMemberMutation) Op() Op {
  41797. return m.op
  41798. }
  41799. // SetOp allows setting the mutation operation.
  41800. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  41801. m.op = op
  41802. }
  41803. // Type returns the node type of this mutation (WpChatroomMember).
  41804. func (m *WpChatroomMemberMutation) Type() string {
  41805. return m.typ
  41806. }
  41807. // Fields returns all fields that were changed during this mutation. Note that in
  41808. // order to get all numeric fields that were incremented/decremented, call
  41809. // AddedFields().
  41810. func (m *WpChatroomMemberMutation) Fields() []string {
  41811. fields := make([]string, 0, 7)
  41812. if m.created_at != nil {
  41813. fields = append(fields, wpchatroommember.FieldCreatedAt)
  41814. }
  41815. if m.updated_at != nil {
  41816. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  41817. }
  41818. if m.status != nil {
  41819. fields = append(fields, wpchatroommember.FieldStatus)
  41820. }
  41821. if m.wx_wxid != nil {
  41822. fields = append(fields, wpchatroommember.FieldWxWxid)
  41823. }
  41824. if m.wxid != nil {
  41825. fields = append(fields, wpchatroommember.FieldWxid)
  41826. }
  41827. if m.nickname != nil {
  41828. fields = append(fields, wpchatroommember.FieldNickname)
  41829. }
  41830. if m.avatar != nil {
  41831. fields = append(fields, wpchatroommember.FieldAvatar)
  41832. }
  41833. return fields
  41834. }
  41835. // Field returns the value of a field with the given name. The second boolean
  41836. // return value indicates that this field was not set, or was not defined in the
  41837. // schema.
  41838. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  41839. switch name {
  41840. case wpchatroommember.FieldCreatedAt:
  41841. return m.CreatedAt()
  41842. case wpchatroommember.FieldUpdatedAt:
  41843. return m.UpdatedAt()
  41844. case wpchatroommember.FieldStatus:
  41845. return m.Status()
  41846. case wpchatroommember.FieldWxWxid:
  41847. return m.WxWxid()
  41848. case wpchatroommember.FieldWxid:
  41849. return m.Wxid()
  41850. case wpchatroommember.FieldNickname:
  41851. return m.Nickname()
  41852. case wpchatroommember.FieldAvatar:
  41853. return m.Avatar()
  41854. }
  41855. return nil, false
  41856. }
  41857. // OldField returns the old value of the field from the database. An error is
  41858. // returned if the mutation operation is not UpdateOne, or the query to the
  41859. // database failed.
  41860. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41861. switch name {
  41862. case wpchatroommember.FieldCreatedAt:
  41863. return m.OldCreatedAt(ctx)
  41864. case wpchatroommember.FieldUpdatedAt:
  41865. return m.OldUpdatedAt(ctx)
  41866. case wpchatroommember.FieldStatus:
  41867. return m.OldStatus(ctx)
  41868. case wpchatroommember.FieldWxWxid:
  41869. return m.OldWxWxid(ctx)
  41870. case wpchatroommember.FieldWxid:
  41871. return m.OldWxid(ctx)
  41872. case wpchatroommember.FieldNickname:
  41873. return m.OldNickname(ctx)
  41874. case wpchatroommember.FieldAvatar:
  41875. return m.OldAvatar(ctx)
  41876. }
  41877. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  41878. }
  41879. // SetField sets the value of a field with the given name. It returns an error if
  41880. // the field is not defined in the schema, or if the type mismatched the field
  41881. // type.
  41882. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  41883. switch name {
  41884. case wpchatroommember.FieldCreatedAt:
  41885. v, ok := value.(time.Time)
  41886. if !ok {
  41887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41888. }
  41889. m.SetCreatedAt(v)
  41890. return nil
  41891. case wpchatroommember.FieldUpdatedAt:
  41892. v, ok := value.(time.Time)
  41893. if !ok {
  41894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41895. }
  41896. m.SetUpdatedAt(v)
  41897. return nil
  41898. case wpchatroommember.FieldStatus:
  41899. v, ok := value.(uint8)
  41900. if !ok {
  41901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41902. }
  41903. m.SetStatus(v)
  41904. return nil
  41905. case wpchatroommember.FieldWxWxid:
  41906. v, ok := value.(string)
  41907. if !ok {
  41908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41909. }
  41910. m.SetWxWxid(v)
  41911. return nil
  41912. case wpchatroommember.FieldWxid:
  41913. v, ok := value.(string)
  41914. if !ok {
  41915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41916. }
  41917. m.SetWxid(v)
  41918. return nil
  41919. case wpchatroommember.FieldNickname:
  41920. v, ok := value.(string)
  41921. if !ok {
  41922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41923. }
  41924. m.SetNickname(v)
  41925. return nil
  41926. case wpchatroommember.FieldAvatar:
  41927. v, ok := value.(string)
  41928. if !ok {
  41929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41930. }
  41931. m.SetAvatar(v)
  41932. return nil
  41933. }
  41934. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  41935. }
  41936. // AddedFields returns all numeric fields that were incremented/decremented during
  41937. // this mutation.
  41938. func (m *WpChatroomMemberMutation) AddedFields() []string {
  41939. var fields []string
  41940. if m.addstatus != nil {
  41941. fields = append(fields, wpchatroommember.FieldStatus)
  41942. }
  41943. return fields
  41944. }
  41945. // AddedField returns the numeric value that was incremented/decremented on a field
  41946. // with the given name. The second boolean return value indicates that this field
  41947. // was not set, or was not defined in the schema.
  41948. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  41949. switch name {
  41950. case wpchatroommember.FieldStatus:
  41951. return m.AddedStatus()
  41952. }
  41953. return nil, false
  41954. }
  41955. // AddField adds the value to the field with the given name. It returns an error if
  41956. // the field is not defined in the schema, or if the type mismatched the field
  41957. // type.
  41958. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  41959. switch name {
  41960. case wpchatroommember.FieldStatus:
  41961. v, ok := value.(int8)
  41962. if !ok {
  41963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41964. }
  41965. m.AddStatus(v)
  41966. return nil
  41967. }
  41968. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  41969. }
  41970. // ClearedFields returns all nullable fields that were cleared during this
  41971. // mutation.
  41972. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  41973. var fields []string
  41974. if m.FieldCleared(wpchatroommember.FieldStatus) {
  41975. fields = append(fields, wpchatroommember.FieldStatus)
  41976. }
  41977. return fields
  41978. }
  41979. // FieldCleared returns a boolean indicating if a field with the given name was
  41980. // cleared in this mutation.
  41981. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  41982. _, ok := m.clearedFields[name]
  41983. return ok
  41984. }
  41985. // ClearField clears the value of the field with the given name. It returns an
  41986. // error if the field is not defined in the schema.
  41987. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  41988. switch name {
  41989. case wpchatroommember.FieldStatus:
  41990. m.ClearStatus()
  41991. return nil
  41992. }
  41993. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  41994. }
  41995. // ResetField resets all changes in the mutation for the field with the given name.
  41996. // It returns an error if the field is not defined in the schema.
  41997. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  41998. switch name {
  41999. case wpchatroommember.FieldCreatedAt:
  42000. m.ResetCreatedAt()
  42001. return nil
  42002. case wpchatroommember.FieldUpdatedAt:
  42003. m.ResetUpdatedAt()
  42004. return nil
  42005. case wpchatroommember.FieldStatus:
  42006. m.ResetStatus()
  42007. return nil
  42008. case wpchatroommember.FieldWxWxid:
  42009. m.ResetWxWxid()
  42010. return nil
  42011. case wpchatroommember.FieldWxid:
  42012. m.ResetWxid()
  42013. return nil
  42014. case wpchatroommember.FieldNickname:
  42015. m.ResetNickname()
  42016. return nil
  42017. case wpchatroommember.FieldAvatar:
  42018. m.ResetAvatar()
  42019. return nil
  42020. }
  42021. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  42022. }
  42023. // AddedEdges returns all edge names that were set/added in this mutation.
  42024. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  42025. edges := make([]string, 0, 0)
  42026. return edges
  42027. }
  42028. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42029. // name in this mutation.
  42030. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  42031. return nil
  42032. }
  42033. // RemovedEdges returns all edge names that were removed in this mutation.
  42034. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  42035. edges := make([]string, 0, 0)
  42036. return edges
  42037. }
  42038. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42039. // the given name in this mutation.
  42040. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  42041. return nil
  42042. }
  42043. // ClearedEdges returns all edge names that were cleared in this mutation.
  42044. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  42045. edges := make([]string, 0, 0)
  42046. return edges
  42047. }
  42048. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42049. // was cleared in this mutation.
  42050. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  42051. return false
  42052. }
  42053. // ClearEdge clears the value of the edge with the given name. It returns an error
  42054. // if that edge is not defined in the schema.
  42055. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  42056. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  42057. }
  42058. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42059. // It returns an error if the edge is not defined in the schema.
  42060. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  42061. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  42062. }
  42063. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  42064. type WxMutation struct {
  42065. config
  42066. op Op
  42067. typ string
  42068. id *uint64
  42069. created_at *time.Time
  42070. updated_at *time.Time
  42071. status *uint8
  42072. addstatus *int8
  42073. deleted_at *time.Time
  42074. port *string
  42075. process_id *string
  42076. callback *string
  42077. wxid *string
  42078. account *string
  42079. nickname *string
  42080. tel *string
  42081. head_big *string
  42082. organization_id *uint64
  42083. addorganization_id *int64
  42084. api_base *string
  42085. api_key *string
  42086. allow_list *[]string
  42087. appendallow_list []string
  42088. group_allow_list *[]string
  42089. appendgroup_allow_list []string
  42090. block_list *[]string
  42091. appendblock_list []string
  42092. group_block_list *[]string
  42093. appendgroup_block_list []string
  42094. ctype *uint64
  42095. addctype *int64
  42096. clearedFields map[string]struct{}
  42097. server *uint64
  42098. clearedserver bool
  42099. agent *uint64
  42100. clearedagent bool
  42101. done bool
  42102. oldValue func(context.Context) (*Wx, error)
  42103. predicates []predicate.Wx
  42104. }
  42105. var _ ent.Mutation = (*WxMutation)(nil)
  42106. // wxOption allows management of the mutation configuration using functional options.
  42107. type wxOption func(*WxMutation)
  42108. // newWxMutation creates new mutation for the Wx entity.
  42109. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  42110. m := &WxMutation{
  42111. config: c,
  42112. op: op,
  42113. typ: TypeWx,
  42114. clearedFields: make(map[string]struct{}),
  42115. }
  42116. for _, opt := range opts {
  42117. opt(m)
  42118. }
  42119. return m
  42120. }
  42121. // withWxID sets the ID field of the mutation.
  42122. func withWxID(id uint64) wxOption {
  42123. return func(m *WxMutation) {
  42124. var (
  42125. err error
  42126. once sync.Once
  42127. value *Wx
  42128. )
  42129. m.oldValue = func(ctx context.Context) (*Wx, error) {
  42130. once.Do(func() {
  42131. if m.done {
  42132. err = errors.New("querying old values post mutation is not allowed")
  42133. } else {
  42134. value, err = m.Client().Wx.Get(ctx, id)
  42135. }
  42136. })
  42137. return value, err
  42138. }
  42139. m.id = &id
  42140. }
  42141. }
  42142. // withWx sets the old Wx of the mutation.
  42143. func withWx(node *Wx) wxOption {
  42144. return func(m *WxMutation) {
  42145. m.oldValue = func(context.Context) (*Wx, error) {
  42146. return node, nil
  42147. }
  42148. m.id = &node.ID
  42149. }
  42150. }
  42151. // Client returns a new `ent.Client` from the mutation. If the mutation was
  42152. // executed in a transaction (ent.Tx), a transactional client is returned.
  42153. func (m WxMutation) Client() *Client {
  42154. client := &Client{config: m.config}
  42155. client.init()
  42156. return client
  42157. }
  42158. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  42159. // it returns an error otherwise.
  42160. func (m WxMutation) Tx() (*Tx, error) {
  42161. if _, ok := m.driver.(*txDriver); !ok {
  42162. return nil, errors.New("ent: mutation is not running in a transaction")
  42163. }
  42164. tx := &Tx{config: m.config}
  42165. tx.init()
  42166. return tx, nil
  42167. }
  42168. // SetID sets the value of the id field. Note that this
  42169. // operation is only accepted on creation of Wx entities.
  42170. func (m *WxMutation) SetID(id uint64) {
  42171. m.id = &id
  42172. }
  42173. // ID returns the ID value in the mutation. Note that the ID is only available
  42174. // if it was provided to the builder or after it was returned from the database.
  42175. func (m *WxMutation) ID() (id uint64, exists bool) {
  42176. if m.id == nil {
  42177. return
  42178. }
  42179. return *m.id, true
  42180. }
  42181. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  42182. // That means, if the mutation is applied within a transaction with an isolation level such
  42183. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  42184. // or updated by the mutation.
  42185. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  42186. switch {
  42187. case m.op.Is(OpUpdateOne | OpDeleteOne):
  42188. id, exists := m.ID()
  42189. if exists {
  42190. return []uint64{id}, nil
  42191. }
  42192. fallthrough
  42193. case m.op.Is(OpUpdate | OpDelete):
  42194. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  42195. default:
  42196. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  42197. }
  42198. }
  42199. // SetCreatedAt sets the "created_at" field.
  42200. func (m *WxMutation) SetCreatedAt(t time.Time) {
  42201. m.created_at = &t
  42202. }
  42203. // CreatedAt returns the value of the "created_at" field in the mutation.
  42204. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  42205. v := m.created_at
  42206. if v == nil {
  42207. return
  42208. }
  42209. return *v, true
  42210. }
  42211. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  42212. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42214. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42215. if !m.op.Is(OpUpdateOne) {
  42216. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42217. }
  42218. if m.id == nil || m.oldValue == nil {
  42219. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42220. }
  42221. oldValue, err := m.oldValue(ctx)
  42222. if err != nil {
  42223. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42224. }
  42225. return oldValue.CreatedAt, nil
  42226. }
  42227. // ResetCreatedAt resets all changes to the "created_at" field.
  42228. func (m *WxMutation) ResetCreatedAt() {
  42229. m.created_at = nil
  42230. }
  42231. // SetUpdatedAt sets the "updated_at" field.
  42232. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  42233. m.updated_at = &t
  42234. }
  42235. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42236. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  42237. v := m.updated_at
  42238. if v == nil {
  42239. return
  42240. }
  42241. return *v, true
  42242. }
  42243. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  42244. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42246. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42247. if !m.op.Is(OpUpdateOne) {
  42248. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42249. }
  42250. if m.id == nil || m.oldValue == nil {
  42251. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42252. }
  42253. oldValue, err := m.oldValue(ctx)
  42254. if err != nil {
  42255. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42256. }
  42257. return oldValue.UpdatedAt, nil
  42258. }
  42259. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42260. func (m *WxMutation) ResetUpdatedAt() {
  42261. m.updated_at = nil
  42262. }
  42263. // SetStatus sets the "status" field.
  42264. func (m *WxMutation) SetStatus(u uint8) {
  42265. m.status = &u
  42266. m.addstatus = nil
  42267. }
  42268. // Status returns the value of the "status" field in the mutation.
  42269. func (m *WxMutation) Status() (r uint8, exists bool) {
  42270. v := m.status
  42271. if v == nil {
  42272. return
  42273. }
  42274. return *v, true
  42275. }
  42276. // OldStatus returns the old "status" field's value of the Wx entity.
  42277. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42279. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42280. if !m.op.Is(OpUpdateOne) {
  42281. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42282. }
  42283. if m.id == nil || m.oldValue == nil {
  42284. return v, errors.New("OldStatus requires an ID field in the mutation")
  42285. }
  42286. oldValue, err := m.oldValue(ctx)
  42287. if err != nil {
  42288. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42289. }
  42290. return oldValue.Status, nil
  42291. }
  42292. // AddStatus adds u to the "status" field.
  42293. func (m *WxMutation) AddStatus(u int8) {
  42294. if m.addstatus != nil {
  42295. *m.addstatus += u
  42296. } else {
  42297. m.addstatus = &u
  42298. }
  42299. }
  42300. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42301. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  42302. v := m.addstatus
  42303. if v == nil {
  42304. return
  42305. }
  42306. return *v, true
  42307. }
  42308. // ClearStatus clears the value of the "status" field.
  42309. func (m *WxMutation) ClearStatus() {
  42310. m.status = nil
  42311. m.addstatus = nil
  42312. m.clearedFields[wx.FieldStatus] = struct{}{}
  42313. }
  42314. // StatusCleared returns if the "status" field was cleared in this mutation.
  42315. func (m *WxMutation) StatusCleared() bool {
  42316. _, ok := m.clearedFields[wx.FieldStatus]
  42317. return ok
  42318. }
  42319. // ResetStatus resets all changes to the "status" field.
  42320. func (m *WxMutation) ResetStatus() {
  42321. m.status = nil
  42322. m.addstatus = nil
  42323. delete(m.clearedFields, wx.FieldStatus)
  42324. }
  42325. // SetDeletedAt sets the "deleted_at" field.
  42326. func (m *WxMutation) SetDeletedAt(t time.Time) {
  42327. m.deleted_at = &t
  42328. }
  42329. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42330. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  42331. v := m.deleted_at
  42332. if v == nil {
  42333. return
  42334. }
  42335. return *v, true
  42336. }
  42337. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  42338. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42340. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42341. if !m.op.Is(OpUpdateOne) {
  42342. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42343. }
  42344. if m.id == nil || m.oldValue == nil {
  42345. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42346. }
  42347. oldValue, err := m.oldValue(ctx)
  42348. if err != nil {
  42349. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42350. }
  42351. return oldValue.DeletedAt, nil
  42352. }
  42353. // ClearDeletedAt clears the value of the "deleted_at" field.
  42354. func (m *WxMutation) ClearDeletedAt() {
  42355. m.deleted_at = nil
  42356. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  42357. }
  42358. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42359. func (m *WxMutation) DeletedAtCleared() bool {
  42360. _, ok := m.clearedFields[wx.FieldDeletedAt]
  42361. return ok
  42362. }
  42363. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42364. func (m *WxMutation) ResetDeletedAt() {
  42365. m.deleted_at = nil
  42366. delete(m.clearedFields, wx.FieldDeletedAt)
  42367. }
  42368. // SetServerID sets the "server_id" field.
  42369. func (m *WxMutation) SetServerID(u uint64) {
  42370. m.server = &u
  42371. }
  42372. // ServerID returns the value of the "server_id" field in the mutation.
  42373. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  42374. v := m.server
  42375. if v == nil {
  42376. return
  42377. }
  42378. return *v, true
  42379. }
  42380. // OldServerID returns the old "server_id" field's value of the Wx entity.
  42381. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42383. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  42384. if !m.op.Is(OpUpdateOne) {
  42385. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  42386. }
  42387. if m.id == nil || m.oldValue == nil {
  42388. return v, errors.New("OldServerID requires an ID field in the mutation")
  42389. }
  42390. oldValue, err := m.oldValue(ctx)
  42391. if err != nil {
  42392. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  42393. }
  42394. return oldValue.ServerID, nil
  42395. }
  42396. // ClearServerID clears the value of the "server_id" field.
  42397. func (m *WxMutation) ClearServerID() {
  42398. m.server = nil
  42399. m.clearedFields[wx.FieldServerID] = struct{}{}
  42400. }
  42401. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  42402. func (m *WxMutation) ServerIDCleared() bool {
  42403. _, ok := m.clearedFields[wx.FieldServerID]
  42404. return ok
  42405. }
  42406. // ResetServerID resets all changes to the "server_id" field.
  42407. func (m *WxMutation) ResetServerID() {
  42408. m.server = nil
  42409. delete(m.clearedFields, wx.FieldServerID)
  42410. }
  42411. // SetPort sets the "port" field.
  42412. func (m *WxMutation) SetPort(s string) {
  42413. m.port = &s
  42414. }
  42415. // Port returns the value of the "port" field in the mutation.
  42416. func (m *WxMutation) Port() (r string, exists bool) {
  42417. v := m.port
  42418. if v == nil {
  42419. return
  42420. }
  42421. return *v, true
  42422. }
  42423. // OldPort returns the old "port" field's value of the Wx entity.
  42424. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42426. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  42427. if !m.op.Is(OpUpdateOne) {
  42428. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  42429. }
  42430. if m.id == nil || m.oldValue == nil {
  42431. return v, errors.New("OldPort requires an ID field in the mutation")
  42432. }
  42433. oldValue, err := m.oldValue(ctx)
  42434. if err != nil {
  42435. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  42436. }
  42437. return oldValue.Port, nil
  42438. }
  42439. // ResetPort resets all changes to the "port" field.
  42440. func (m *WxMutation) ResetPort() {
  42441. m.port = nil
  42442. }
  42443. // SetProcessID sets the "process_id" field.
  42444. func (m *WxMutation) SetProcessID(s string) {
  42445. m.process_id = &s
  42446. }
  42447. // ProcessID returns the value of the "process_id" field in the mutation.
  42448. func (m *WxMutation) ProcessID() (r string, exists bool) {
  42449. v := m.process_id
  42450. if v == nil {
  42451. return
  42452. }
  42453. return *v, true
  42454. }
  42455. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  42456. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42458. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  42459. if !m.op.Is(OpUpdateOne) {
  42460. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  42461. }
  42462. if m.id == nil || m.oldValue == nil {
  42463. return v, errors.New("OldProcessID requires an ID field in the mutation")
  42464. }
  42465. oldValue, err := m.oldValue(ctx)
  42466. if err != nil {
  42467. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  42468. }
  42469. return oldValue.ProcessID, nil
  42470. }
  42471. // ResetProcessID resets all changes to the "process_id" field.
  42472. func (m *WxMutation) ResetProcessID() {
  42473. m.process_id = nil
  42474. }
  42475. // SetCallback sets the "callback" field.
  42476. func (m *WxMutation) SetCallback(s string) {
  42477. m.callback = &s
  42478. }
  42479. // Callback returns the value of the "callback" field in the mutation.
  42480. func (m *WxMutation) Callback() (r string, exists bool) {
  42481. v := m.callback
  42482. if v == nil {
  42483. return
  42484. }
  42485. return *v, true
  42486. }
  42487. // OldCallback returns the old "callback" field's value of the Wx entity.
  42488. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42489. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42490. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  42491. if !m.op.Is(OpUpdateOne) {
  42492. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42493. }
  42494. if m.id == nil || m.oldValue == nil {
  42495. return v, errors.New("OldCallback requires an ID field in the mutation")
  42496. }
  42497. oldValue, err := m.oldValue(ctx)
  42498. if err != nil {
  42499. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42500. }
  42501. return oldValue.Callback, nil
  42502. }
  42503. // ResetCallback resets all changes to the "callback" field.
  42504. func (m *WxMutation) ResetCallback() {
  42505. m.callback = nil
  42506. }
  42507. // SetWxid sets the "wxid" field.
  42508. func (m *WxMutation) SetWxid(s string) {
  42509. m.wxid = &s
  42510. }
  42511. // Wxid returns the value of the "wxid" field in the mutation.
  42512. func (m *WxMutation) Wxid() (r string, exists bool) {
  42513. v := m.wxid
  42514. if v == nil {
  42515. return
  42516. }
  42517. return *v, true
  42518. }
  42519. // OldWxid returns the old "wxid" field's value of the Wx entity.
  42520. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42522. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  42523. if !m.op.Is(OpUpdateOne) {
  42524. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  42525. }
  42526. if m.id == nil || m.oldValue == nil {
  42527. return v, errors.New("OldWxid requires an ID field in the mutation")
  42528. }
  42529. oldValue, err := m.oldValue(ctx)
  42530. if err != nil {
  42531. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  42532. }
  42533. return oldValue.Wxid, nil
  42534. }
  42535. // ResetWxid resets all changes to the "wxid" field.
  42536. func (m *WxMutation) ResetWxid() {
  42537. m.wxid = nil
  42538. }
  42539. // SetAccount sets the "account" field.
  42540. func (m *WxMutation) SetAccount(s string) {
  42541. m.account = &s
  42542. }
  42543. // Account returns the value of the "account" field in the mutation.
  42544. func (m *WxMutation) Account() (r string, exists bool) {
  42545. v := m.account
  42546. if v == nil {
  42547. return
  42548. }
  42549. return *v, true
  42550. }
  42551. // OldAccount returns the old "account" field's value of the Wx entity.
  42552. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42554. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  42555. if !m.op.Is(OpUpdateOne) {
  42556. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42557. }
  42558. if m.id == nil || m.oldValue == nil {
  42559. return v, errors.New("OldAccount requires an ID field in the mutation")
  42560. }
  42561. oldValue, err := m.oldValue(ctx)
  42562. if err != nil {
  42563. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42564. }
  42565. return oldValue.Account, nil
  42566. }
  42567. // ResetAccount resets all changes to the "account" field.
  42568. func (m *WxMutation) ResetAccount() {
  42569. m.account = nil
  42570. }
  42571. // SetNickname sets the "nickname" field.
  42572. func (m *WxMutation) SetNickname(s string) {
  42573. m.nickname = &s
  42574. }
  42575. // Nickname returns the value of the "nickname" field in the mutation.
  42576. func (m *WxMutation) Nickname() (r string, exists bool) {
  42577. v := m.nickname
  42578. if v == nil {
  42579. return
  42580. }
  42581. return *v, true
  42582. }
  42583. // OldNickname returns the old "nickname" field's value of the Wx entity.
  42584. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42586. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  42587. if !m.op.Is(OpUpdateOne) {
  42588. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  42589. }
  42590. if m.id == nil || m.oldValue == nil {
  42591. return v, errors.New("OldNickname requires an ID field in the mutation")
  42592. }
  42593. oldValue, err := m.oldValue(ctx)
  42594. if err != nil {
  42595. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  42596. }
  42597. return oldValue.Nickname, nil
  42598. }
  42599. // ResetNickname resets all changes to the "nickname" field.
  42600. func (m *WxMutation) ResetNickname() {
  42601. m.nickname = nil
  42602. }
  42603. // SetTel sets the "tel" field.
  42604. func (m *WxMutation) SetTel(s string) {
  42605. m.tel = &s
  42606. }
  42607. // Tel returns the value of the "tel" field in the mutation.
  42608. func (m *WxMutation) Tel() (r string, exists bool) {
  42609. v := m.tel
  42610. if v == nil {
  42611. return
  42612. }
  42613. return *v, true
  42614. }
  42615. // OldTel returns the old "tel" field's value of the Wx entity.
  42616. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42618. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  42619. if !m.op.Is(OpUpdateOne) {
  42620. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  42621. }
  42622. if m.id == nil || m.oldValue == nil {
  42623. return v, errors.New("OldTel requires an ID field in the mutation")
  42624. }
  42625. oldValue, err := m.oldValue(ctx)
  42626. if err != nil {
  42627. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  42628. }
  42629. return oldValue.Tel, nil
  42630. }
  42631. // ResetTel resets all changes to the "tel" field.
  42632. func (m *WxMutation) ResetTel() {
  42633. m.tel = nil
  42634. }
  42635. // SetHeadBig sets the "head_big" field.
  42636. func (m *WxMutation) SetHeadBig(s string) {
  42637. m.head_big = &s
  42638. }
  42639. // HeadBig returns the value of the "head_big" field in the mutation.
  42640. func (m *WxMutation) HeadBig() (r string, exists bool) {
  42641. v := m.head_big
  42642. if v == nil {
  42643. return
  42644. }
  42645. return *v, true
  42646. }
  42647. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  42648. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42650. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  42651. if !m.op.Is(OpUpdateOne) {
  42652. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  42653. }
  42654. if m.id == nil || m.oldValue == nil {
  42655. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  42656. }
  42657. oldValue, err := m.oldValue(ctx)
  42658. if err != nil {
  42659. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  42660. }
  42661. return oldValue.HeadBig, nil
  42662. }
  42663. // ResetHeadBig resets all changes to the "head_big" field.
  42664. func (m *WxMutation) ResetHeadBig() {
  42665. m.head_big = nil
  42666. }
  42667. // SetOrganizationID sets the "organization_id" field.
  42668. func (m *WxMutation) SetOrganizationID(u uint64) {
  42669. m.organization_id = &u
  42670. m.addorganization_id = nil
  42671. }
  42672. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42673. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  42674. v := m.organization_id
  42675. if v == nil {
  42676. return
  42677. }
  42678. return *v, true
  42679. }
  42680. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  42681. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42683. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42684. if !m.op.Is(OpUpdateOne) {
  42685. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42686. }
  42687. if m.id == nil || m.oldValue == nil {
  42688. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42689. }
  42690. oldValue, err := m.oldValue(ctx)
  42691. if err != nil {
  42692. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42693. }
  42694. return oldValue.OrganizationID, nil
  42695. }
  42696. // AddOrganizationID adds u to the "organization_id" field.
  42697. func (m *WxMutation) AddOrganizationID(u int64) {
  42698. if m.addorganization_id != nil {
  42699. *m.addorganization_id += u
  42700. } else {
  42701. m.addorganization_id = &u
  42702. }
  42703. }
  42704. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42705. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  42706. v := m.addorganization_id
  42707. if v == nil {
  42708. return
  42709. }
  42710. return *v, true
  42711. }
  42712. // ClearOrganizationID clears the value of the "organization_id" field.
  42713. func (m *WxMutation) ClearOrganizationID() {
  42714. m.organization_id = nil
  42715. m.addorganization_id = nil
  42716. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  42717. }
  42718. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42719. func (m *WxMutation) OrganizationIDCleared() bool {
  42720. _, ok := m.clearedFields[wx.FieldOrganizationID]
  42721. return ok
  42722. }
  42723. // ResetOrganizationID resets all changes to the "organization_id" field.
  42724. func (m *WxMutation) ResetOrganizationID() {
  42725. m.organization_id = nil
  42726. m.addorganization_id = nil
  42727. delete(m.clearedFields, wx.FieldOrganizationID)
  42728. }
  42729. // SetAgentID sets the "agent_id" field.
  42730. func (m *WxMutation) SetAgentID(u uint64) {
  42731. m.agent = &u
  42732. }
  42733. // AgentID returns the value of the "agent_id" field in the mutation.
  42734. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  42735. v := m.agent
  42736. if v == nil {
  42737. return
  42738. }
  42739. return *v, true
  42740. }
  42741. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  42742. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42744. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42745. if !m.op.Is(OpUpdateOne) {
  42746. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42747. }
  42748. if m.id == nil || m.oldValue == nil {
  42749. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42750. }
  42751. oldValue, err := m.oldValue(ctx)
  42752. if err != nil {
  42753. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42754. }
  42755. return oldValue.AgentID, nil
  42756. }
  42757. // ResetAgentID resets all changes to the "agent_id" field.
  42758. func (m *WxMutation) ResetAgentID() {
  42759. m.agent = nil
  42760. }
  42761. // SetAPIBase sets the "api_base" field.
  42762. func (m *WxMutation) SetAPIBase(s string) {
  42763. m.api_base = &s
  42764. }
  42765. // APIBase returns the value of the "api_base" field in the mutation.
  42766. func (m *WxMutation) APIBase() (r string, exists bool) {
  42767. v := m.api_base
  42768. if v == nil {
  42769. return
  42770. }
  42771. return *v, true
  42772. }
  42773. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  42774. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42776. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42777. if !m.op.Is(OpUpdateOne) {
  42778. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42779. }
  42780. if m.id == nil || m.oldValue == nil {
  42781. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42782. }
  42783. oldValue, err := m.oldValue(ctx)
  42784. if err != nil {
  42785. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42786. }
  42787. return oldValue.APIBase, nil
  42788. }
  42789. // ClearAPIBase clears the value of the "api_base" field.
  42790. func (m *WxMutation) ClearAPIBase() {
  42791. m.api_base = nil
  42792. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  42793. }
  42794. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42795. func (m *WxMutation) APIBaseCleared() bool {
  42796. _, ok := m.clearedFields[wx.FieldAPIBase]
  42797. return ok
  42798. }
  42799. // ResetAPIBase resets all changes to the "api_base" field.
  42800. func (m *WxMutation) ResetAPIBase() {
  42801. m.api_base = nil
  42802. delete(m.clearedFields, wx.FieldAPIBase)
  42803. }
  42804. // SetAPIKey sets the "api_key" field.
  42805. func (m *WxMutation) SetAPIKey(s string) {
  42806. m.api_key = &s
  42807. }
  42808. // APIKey returns the value of the "api_key" field in the mutation.
  42809. func (m *WxMutation) APIKey() (r string, exists bool) {
  42810. v := m.api_key
  42811. if v == nil {
  42812. return
  42813. }
  42814. return *v, true
  42815. }
  42816. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  42817. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42819. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42820. if !m.op.Is(OpUpdateOne) {
  42821. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42822. }
  42823. if m.id == nil || m.oldValue == nil {
  42824. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42825. }
  42826. oldValue, err := m.oldValue(ctx)
  42827. if err != nil {
  42828. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42829. }
  42830. return oldValue.APIKey, nil
  42831. }
  42832. // ClearAPIKey clears the value of the "api_key" field.
  42833. func (m *WxMutation) ClearAPIKey() {
  42834. m.api_key = nil
  42835. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  42836. }
  42837. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42838. func (m *WxMutation) APIKeyCleared() bool {
  42839. _, ok := m.clearedFields[wx.FieldAPIKey]
  42840. return ok
  42841. }
  42842. // ResetAPIKey resets all changes to the "api_key" field.
  42843. func (m *WxMutation) ResetAPIKey() {
  42844. m.api_key = nil
  42845. delete(m.clearedFields, wx.FieldAPIKey)
  42846. }
  42847. // SetAllowList sets the "allow_list" field.
  42848. func (m *WxMutation) SetAllowList(s []string) {
  42849. m.allow_list = &s
  42850. m.appendallow_list = nil
  42851. }
  42852. // AllowList returns the value of the "allow_list" field in the mutation.
  42853. func (m *WxMutation) AllowList() (r []string, exists bool) {
  42854. v := m.allow_list
  42855. if v == nil {
  42856. return
  42857. }
  42858. return *v, true
  42859. }
  42860. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  42861. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42862. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42863. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42864. if !m.op.Is(OpUpdateOne) {
  42865. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42866. }
  42867. if m.id == nil || m.oldValue == nil {
  42868. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42869. }
  42870. oldValue, err := m.oldValue(ctx)
  42871. if err != nil {
  42872. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42873. }
  42874. return oldValue.AllowList, nil
  42875. }
  42876. // AppendAllowList adds s to the "allow_list" field.
  42877. func (m *WxMutation) AppendAllowList(s []string) {
  42878. m.appendallow_list = append(m.appendallow_list, s...)
  42879. }
  42880. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42881. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  42882. if len(m.appendallow_list) == 0 {
  42883. return nil, false
  42884. }
  42885. return m.appendallow_list, true
  42886. }
  42887. // ResetAllowList resets all changes to the "allow_list" field.
  42888. func (m *WxMutation) ResetAllowList() {
  42889. m.allow_list = nil
  42890. m.appendallow_list = nil
  42891. }
  42892. // SetGroupAllowList sets the "group_allow_list" field.
  42893. func (m *WxMutation) SetGroupAllowList(s []string) {
  42894. m.group_allow_list = &s
  42895. m.appendgroup_allow_list = nil
  42896. }
  42897. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42898. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  42899. v := m.group_allow_list
  42900. if v == nil {
  42901. return
  42902. }
  42903. return *v, true
  42904. }
  42905. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  42906. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42908. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42909. if !m.op.Is(OpUpdateOne) {
  42910. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42911. }
  42912. if m.id == nil || m.oldValue == nil {
  42913. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42914. }
  42915. oldValue, err := m.oldValue(ctx)
  42916. if err != nil {
  42917. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42918. }
  42919. return oldValue.GroupAllowList, nil
  42920. }
  42921. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42922. func (m *WxMutation) AppendGroupAllowList(s []string) {
  42923. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42924. }
  42925. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42926. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  42927. if len(m.appendgroup_allow_list) == 0 {
  42928. return nil, false
  42929. }
  42930. return m.appendgroup_allow_list, true
  42931. }
  42932. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42933. func (m *WxMutation) ResetGroupAllowList() {
  42934. m.group_allow_list = nil
  42935. m.appendgroup_allow_list = nil
  42936. }
  42937. // SetBlockList sets the "block_list" field.
  42938. func (m *WxMutation) SetBlockList(s []string) {
  42939. m.block_list = &s
  42940. m.appendblock_list = nil
  42941. }
  42942. // BlockList returns the value of the "block_list" field in the mutation.
  42943. func (m *WxMutation) BlockList() (r []string, exists bool) {
  42944. v := m.block_list
  42945. if v == nil {
  42946. return
  42947. }
  42948. return *v, true
  42949. }
  42950. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  42951. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42953. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42954. if !m.op.Is(OpUpdateOne) {
  42955. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42956. }
  42957. if m.id == nil || m.oldValue == nil {
  42958. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42959. }
  42960. oldValue, err := m.oldValue(ctx)
  42961. if err != nil {
  42962. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42963. }
  42964. return oldValue.BlockList, nil
  42965. }
  42966. // AppendBlockList adds s to the "block_list" field.
  42967. func (m *WxMutation) AppendBlockList(s []string) {
  42968. m.appendblock_list = append(m.appendblock_list, s...)
  42969. }
  42970. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42971. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  42972. if len(m.appendblock_list) == 0 {
  42973. return nil, false
  42974. }
  42975. return m.appendblock_list, true
  42976. }
  42977. // ResetBlockList resets all changes to the "block_list" field.
  42978. func (m *WxMutation) ResetBlockList() {
  42979. m.block_list = nil
  42980. m.appendblock_list = nil
  42981. }
  42982. // SetGroupBlockList sets the "group_block_list" field.
  42983. func (m *WxMutation) SetGroupBlockList(s []string) {
  42984. m.group_block_list = &s
  42985. m.appendgroup_block_list = nil
  42986. }
  42987. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42988. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  42989. v := m.group_block_list
  42990. if v == nil {
  42991. return
  42992. }
  42993. return *v, true
  42994. }
  42995. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  42996. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  42997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42998. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42999. if !m.op.Is(OpUpdateOne) {
  43000. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  43001. }
  43002. if m.id == nil || m.oldValue == nil {
  43003. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  43004. }
  43005. oldValue, err := m.oldValue(ctx)
  43006. if err != nil {
  43007. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  43008. }
  43009. return oldValue.GroupBlockList, nil
  43010. }
  43011. // AppendGroupBlockList adds s to the "group_block_list" field.
  43012. func (m *WxMutation) AppendGroupBlockList(s []string) {
  43013. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  43014. }
  43015. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  43016. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  43017. if len(m.appendgroup_block_list) == 0 {
  43018. return nil, false
  43019. }
  43020. return m.appendgroup_block_list, true
  43021. }
  43022. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  43023. func (m *WxMutation) ResetGroupBlockList() {
  43024. m.group_block_list = nil
  43025. m.appendgroup_block_list = nil
  43026. }
  43027. // SetCtype sets the "ctype" field.
  43028. func (m *WxMutation) SetCtype(u uint64) {
  43029. m.ctype = &u
  43030. m.addctype = nil
  43031. }
  43032. // Ctype returns the value of the "ctype" field in the mutation.
  43033. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  43034. v := m.ctype
  43035. if v == nil {
  43036. return
  43037. }
  43038. return *v, true
  43039. }
  43040. // OldCtype returns the old "ctype" field's value of the Wx entity.
  43041. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  43042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43043. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  43044. if !m.op.Is(OpUpdateOne) {
  43045. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  43046. }
  43047. if m.id == nil || m.oldValue == nil {
  43048. return v, errors.New("OldCtype requires an ID field in the mutation")
  43049. }
  43050. oldValue, err := m.oldValue(ctx)
  43051. if err != nil {
  43052. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  43053. }
  43054. return oldValue.Ctype, nil
  43055. }
  43056. // AddCtype adds u to the "ctype" field.
  43057. func (m *WxMutation) AddCtype(u int64) {
  43058. if m.addctype != nil {
  43059. *m.addctype += u
  43060. } else {
  43061. m.addctype = &u
  43062. }
  43063. }
  43064. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  43065. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  43066. v := m.addctype
  43067. if v == nil {
  43068. return
  43069. }
  43070. return *v, true
  43071. }
  43072. // ClearCtype clears the value of the "ctype" field.
  43073. func (m *WxMutation) ClearCtype() {
  43074. m.ctype = nil
  43075. m.addctype = nil
  43076. m.clearedFields[wx.FieldCtype] = struct{}{}
  43077. }
  43078. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  43079. func (m *WxMutation) CtypeCleared() bool {
  43080. _, ok := m.clearedFields[wx.FieldCtype]
  43081. return ok
  43082. }
  43083. // ResetCtype resets all changes to the "ctype" field.
  43084. func (m *WxMutation) ResetCtype() {
  43085. m.ctype = nil
  43086. m.addctype = nil
  43087. delete(m.clearedFields, wx.FieldCtype)
  43088. }
  43089. // ClearServer clears the "server" edge to the Server entity.
  43090. func (m *WxMutation) ClearServer() {
  43091. m.clearedserver = true
  43092. m.clearedFields[wx.FieldServerID] = struct{}{}
  43093. }
  43094. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  43095. func (m *WxMutation) ServerCleared() bool {
  43096. return m.ServerIDCleared() || m.clearedserver
  43097. }
  43098. // ServerIDs returns the "server" edge IDs in the mutation.
  43099. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43100. // ServerID instead. It exists only for internal usage by the builders.
  43101. func (m *WxMutation) ServerIDs() (ids []uint64) {
  43102. if id := m.server; id != nil {
  43103. ids = append(ids, *id)
  43104. }
  43105. return
  43106. }
  43107. // ResetServer resets all changes to the "server" edge.
  43108. func (m *WxMutation) ResetServer() {
  43109. m.server = nil
  43110. m.clearedserver = false
  43111. }
  43112. // ClearAgent clears the "agent" edge to the Agent entity.
  43113. func (m *WxMutation) ClearAgent() {
  43114. m.clearedagent = true
  43115. m.clearedFields[wx.FieldAgentID] = struct{}{}
  43116. }
  43117. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  43118. func (m *WxMutation) AgentCleared() bool {
  43119. return m.clearedagent
  43120. }
  43121. // AgentIDs returns the "agent" edge IDs in the mutation.
  43122. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  43123. // AgentID instead. It exists only for internal usage by the builders.
  43124. func (m *WxMutation) AgentIDs() (ids []uint64) {
  43125. if id := m.agent; id != nil {
  43126. ids = append(ids, *id)
  43127. }
  43128. return
  43129. }
  43130. // ResetAgent resets all changes to the "agent" edge.
  43131. func (m *WxMutation) ResetAgent() {
  43132. m.agent = nil
  43133. m.clearedagent = false
  43134. }
  43135. // Where appends a list predicates to the WxMutation builder.
  43136. func (m *WxMutation) Where(ps ...predicate.Wx) {
  43137. m.predicates = append(m.predicates, ps...)
  43138. }
  43139. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  43140. // users can use type-assertion to append predicates that do not depend on any generated package.
  43141. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  43142. p := make([]predicate.Wx, len(ps))
  43143. for i := range ps {
  43144. p[i] = ps[i]
  43145. }
  43146. m.Where(p...)
  43147. }
  43148. // Op returns the operation name.
  43149. func (m *WxMutation) Op() Op {
  43150. return m.op
  43151. }
  43152. // SetOp allows setting the mutation operation.
  43153. func (m *WxMutation) SetOp(op Op) {
  43154. m.op = op
  43155. }
  43156. // Type returns the node type of this mutation (Wx).
  43157. func (m *WxMutation) Type() string {
  43158. return m.typ
  43159. }
  43160. // Fields returns all fields that were changed during this mutation. Note that in
  43161. // order to get all numeric fields that were incremented/decremented, call
  43162. // AddedFields().
  43163. func (m *WxMutation) Fields() []string {
  43164. fields := make([]string, 0, 22)
  43165. if m.created_at != nil {
  43166. fields = append(fields, wx.FieldCreatedAt)
  43167. }
  43168. if m.updated_at != nil {
  43169. fields = append(fields, wx.FieldUpdatedAt)
  43170. }
  43171. if m.status != nil {
  43172. fields = append(fields, wx.FieldStatus)
  43173. }
  43174. if m.deleted_at != nil {
  43175. fields = append(fields, wx.FieldDeletedAt)
  43176. }
  43177. if m.server != nil {
  43178. fields = append(fields, wx.FieldServerID)
  43179. }
  43180. if m.port != nil {
  43181. fields = append(fields, wx.FieldPort)
  43182. }
  43183. if m.process_id != nil {
  43184. fields = append(fields, wx.FieldProcessID)
  43185. }
  43186. if m.callback != nil {
  43187. fields = append(fields, wx.FieldCallback)
  43188. }
  43189. if m.wxid != nil {
  43190. fields = append(fields, wx.FieldWxid)
  43191. }
  43192. if m.account != nil {
  43193. fields = append(fields, wx.FieldAccount)
  43194. }
  43195. if m.nickname != nil {
  43196. fields = append(fields, wx.FieldNickname)
  43197. }
  43198. if m.tel != nil {
  43199. fields = append(fields, wx.FieldTel)
  43200. }
  43201. if m.head_big != nil {
  43202. fields = append(fields, wx.FieldHeadBig)
  43203. }
  43204. if m.organization_id != nil {
  43205. fields = append(fields, wx.FieldOrganizationID)
  43206. }
  43207. if m.agent != nil {
  43208. fields = append(fields, wx.FieldAgentID)
  43209. }
  43210. if m.api_base != nil {
  43211. fields = append(fields, wx.FieldAPIBase)
  43212. }
  43213. if m.api_key != nil {
  43214. fields = append(fields, wx.FieldAPIKey)
  43215. }
  43216. if m.allow_list != nil {
  43217. fields = append(fields, wx.FieldAllowList)
  43218. }
  43219. if m.group_allow_list != nil {
  43220. fields = append(fields, wx.FieldGroupAllowList)
  43221. }
  43222. if m.block_list != nil {
  43223. fields = append(fields, wx.FieldBlockList)
  43224. }
  43225. if m.group_block_list != nil {
  43226. fields = append(fields, wx.FieldGroupBlockList)
  43227. }
  43228. if m.ctype != nil {
  43229. fields = append(fields, wx.FieldCtype)
  43230. }
  43231. return fields
  43232. }
  43233. // Field returns the value of a field with the given name. The second boolean
  43234. // return value indicates that this field was not set, or was not defined in the
  43235. // schema.
  43236. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  43237. switch name {
  43238. case wx.FieldCreatedAt:
  43239. return m.CreatedAt()
  43240. case wx.FieldUpdatedAt:
  43241. return m.UpdatedAt()
  43242. case wx.FieldStatus:
  43243. return m.Status()
  43244. case wx.FieldDeletedAt:
  43245. return m.DeletedAt()
  43246. case wx.FieldServerID:
  43247. return m.ServerID()
  43248. case wx.FieldPort:
  43249. return m.Port()
  43250. case wx.FieldProcessID:
  43251. return m.ProcessID()
  43252. case wx.FieldCallback:
  43253. return m.Callback()
  43254. case wx.FieldWxid:
  43255. return m.Wxid()
  43256. case wx.FieldAccount:
  43257. return m.Account()
  43258. case wx.FieldNickname:
  43259. return m.Nickname()
  43260. case wx.FieldTel:
  43261. return m.Tel()
  43262. case wx.FieldHeadBig:
  43263. return m.HeadBig()
  43264. case wx.FieldOrganizationID:
  43265. return m.OrganizationID()
  43266. case wx.FieldAgentID:
  43267. return m.AgentID()
  43268. case wx.FieldAPIBase:
  43269. return m.APIBase()
  43270. case wx.FieldAPIKey:
  43271. return m.APIKey()
  43272. case wx.FieldAllowList:
  43273. return m.AllowList()
  43274. case wx.FieldGroupAllowList:
  43275. return m.GroupAllowList()
  43276. case wx.FieldBlockList:
  43277. return m.BlockList()
  43278. case wx.FieldGroupBlockList:
  43279. return m.GroupBlockList()
  43280. case wx.FieldCtype:
  43281. return m.Ctype()
  43282. }
  43283. return nil, false
  43284. }
  43285. // OldField returns the old value of the field from the database. An error is
  43286. // returned if the mutation operation is not UpdateOne, or the query to the
  43287. // database failed.
  43288. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43289. switch name {
  43290. case wx.FieldCreatedAt:
  43291. return m.OldCreatedAt(ctx)
  43292. case wx.FieldUpdatedAt:
  43293. return m.OldUpdatedAt(ctx)
  43294. case wx.FieldStatus:
  43295. return m.OldStatus(ctx)
  43296. case wx.FieldDeletedAt:
  43297. return m.OldDeletedAt(ctx)
  43298. case wx.FieldServerID:
  43299. return m.OldServerID(ctx)
  43300. case wx.FieldPort:
  43301. return m.OldPort(ctx)
  43302. case wx.FieldProcessID:
  43303. return m.OldProcessID(ctx)
  43304. case wx.FieldCallback:
  43305. return m.OldCallback(ctx)
  43306. case wx.FieldWxid:
  43307. return m.OldWxid(ctx)
  43308. case wx.FieldAccount:
  43309. return m.OldAccount(ctx)
  43310. case wx.FieldNickname:
  43311. return m.OldNickname(ctx)
  43312. case wx.FieldTel:
  43313. return m.OldTel(ctx)
  43314. case wx.FieldHeadBig:
  43315. return m.OldHeadBig(ctx)
  43316. case wx.FieldOrganizationID:
  43317. return m.OldOrganizationID(ctx)
  43318. case wx.FieldAgentID:
  43319. return m.OldAgentID(ctx)
  43320. case wx.FieldAPIBase:
  43321. return m.OldAPIBase(ctx)
  43322. case wx.FieldAPIKey:
  43323. return m.OldAPIKey(ctx)
  43324. case wx.FieldAllowList:
  43325. return m.OldAllowList(ctx)
  43326. case wx.FieldGroupAllowList:
  43327. return m.OldGroupAllowList(ctx)
  43328. case wx.FieldBlockList:
  43329. return m.OldBlockList(ctx)
  43330. case wx.FieldGroupBlockList:
  43331. return m.OldGroupBlockList(ctx)
  43332. case wx.FieldCtype:
  43333. return m.OldCtype(ctx)
  43334. }
  43335. return nil, fmt.Errorf("unknown Wx field %s", name)
  43336. }
  43337. // SetField sets the value of a field with the given name. It returns an error if
  43338. // the field is not defined in the schema, or if the type mismatched the field
  43339. // type.
  43340. func (m *WxMutation) SetField(name string, value ent.Value) error {
  43341. switch name {
  43342. case wx.FieldCreatedAt:
  43343. v, ok := value.(time.Time)
  43344. if !ok {
  43345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43346. }
  43347. m.SetCreatedAt(v)
  43348. return nil
  43349. case wx.FieldUpdatedAt:
  43350. v, ok := value.(time.Time)
  43351. if !ok {
  43352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43353. }
  43354. m.SetUpdatedAt(v)
  43355. return nil
  43356. case wx.FieldStatus:
  43357. v, ok := value.(uint8)
  43358. if !ok {
  43359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43360. }
  43361. m.SetStatus(v)
  43362. return nil
  43363. case wx.FieldDeletedAt:
  43364. v, ok := value.(time.Time)
  43365. if !ok {
  43366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43367. }
  43368. m.SetDeletedAt(v)
  43369. return nil
  43370. case wx.FieldServerID:
  43371. v, ok := value.(uint64)
  43372. if !ok {
  43373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43374. }
  43375. m.SetServerID(v)
  43376. return nil
  43377. case wx.FieldPort:
  43378. v, ok := value.(string)
  43379. if !ok {
  43380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43381. }
  43382. m.SetPort(v)
  43383. return nil
  43384. case wx.FieldProcessID:
  43385. v, ok := value.(string)
  43386. if !ok {
  43387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43388. }
  43389. m.SetProcessID(v)
  43390. return nil
  43391. case wx.FieldCallback:
  43392. v, ok := value.(string)
  43393. if !ok {
  43394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43395. }
  43396. m.SetCallback(v)
  43397. return nil
  43398. case wx.FieldWxid:
  43399. v, ok := value.(string)
  43400. if !ok {
  43401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43402. }
  43403. m.SetWxid(v)
  43404. return nil
  43405. case wx.FieldAccount:
  43406. v, ok := value.(string)
  43407. if !ok {
  43408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43409. }
  43410. m.SetAccount(v)
  43411. return nil
  43412. case wx.FieldNickname:
  43413. v, ok := value.(string)
  43414. if !ok {
  43415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43416. }
  43417. m.SetNickname(v)
  43418. return nil
  43419. case wx.FieldTel:
  43420. v, ok := value.(string)
  43421. if !ok {
  43422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43423. }
  43424. m.SetTel(v)
  43425. return nil
  43426. case wx.FieldHeadBig:
  43427. v, ok := value.(string)
  43428. if !ok {
  43429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43430. }
  43431. m.SetHeadBig(v)
  43432. return nil
  43433. case wx.FieldOrganizationID:
  43434. v, ok := value.(uint64)
  43435. if !ok {
  43436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43437. }
  43438. m.SetOrganizationID(v)
  43439. return nil
  43440. case wx.FieldAgentID:
  43441. v, ok := value.(uint64)
  43442. if !ok {
  43443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43444. }
  43445. m.SetAgentID(v)
  43446. return nil
  43447. case wx.FieldAPIBase:
  43448. v, ok := value.(string)
  43449. if !ok {
  43450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43451. }
  43452. m.SetAPIBase(v)
  43453. return nil
  43454. case wx.FieldAPIKey:
  43455. v, ok := value.(string)
  43456. if !ok {
  43457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43458. }
  43459. m.SetAPIKey(v)
  43460. return nil
  43461. case wx.FieldAllowList:
  43462. v, ok := value.([]string)
  43463. if !ok {
  43464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43465. }
  43466. m.SetAllowList(v)
  43467. return nil
  43468. case wx.FieldGroupAllowList:
  43469. v, ok := value.([]string)
  43470. if !ok {
  43471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43472. }
  43473. m.SetGroupAllowList(v)
  43474. return nil
  43475. case wx.FieldBlockList:
  43476. v, ok := value.([]string)
  43477. if !ok {
  43478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43479. }
  43480. m.SetBlockList(v)
  43481. return nil
  43482. case wx.FieldGroupBlockList:
  43483. v, ok := value.([]string)
  43484. if !ok {
  43485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43486. }
  43487. m.SetGroupBlockList(v)
  43488. return nil
  43489. case wx.FieldCtype:
  43490. v, ok := value.(uint64)
  43491. if !ok {
  43492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43493. }
  43494. m.SetCtype(v)
  43495. return nil
  43496. }
  43497. return fmt.Errorf("unknown Wx field %s", name)
  43498. }
  43499. // AddedFields returns all numeric fields that were incremented/decremented during
  43500. // this mutation.
  43501. func (m *WxMutation) AddedFields() []string {
  43502. var fields []string
  43503. if m.addstatus != nil {
  43504. fields = append(fields, wx.FieldStatus)
  43505. }
  43506. if m.addorganization_id != nil {
  43507. fields = append(fields, wx.FieldOrganizationID)
  43508. }
  43509. if m.addctype != nil {
  43510. fields = append(fields, wx.FieldCtype)
  43511. }
  43512. return fields
  43513. }
  43514. // AddedField returns the numeric value that was incremented/decremented on a field
  43515. // with the given name. The second boolean return value indicates that this field
  43516. // was not set, or was not defined in the schema.
  43517. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  43518. switch name {
  43519. case wx.FieldStatus:
  43520. return m.AddedStatus()
  43521. case wx.FieldOrganizationID:
  43522. return m.AddedOrganizationID()
  43523. case wx.FieldCtype:
  43524. return m.AddedCtype()
  43525. }
  43526. return nil, false
  43527. }
  43528. // AddField adds the value to the field with the given name. It returns an error if
  43529. // the field is not defined in the schema, or if the type mismatched the field
  43530. // type.
  43531. func (m *WxMutation) AddField(name string, value ent.Value) error {
  43532. switch name {
  43533. case wx.FieldStatus:
  43534. v, ok := value.(int8)
  43535. if !ok {
  43536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43537. }
  43538. m.AddStatus(v)
  43539. return nil
  43540. case wx.FieldOrganizationID:
  43541. v, ok := value.(int64)
  43542. if !ok {
  43543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43544. }
  43545. m.AddOrganizationID(v)
  43546. return nil
  43547. case wx.FieldCtype:
  43548. v, ok := value.(int64)
  43549. if !ok {
  43550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43551. }
  43552. m.AddCtype(v)
  43553. return nil
  43554. }
  43555. return fmt.Errorf("unknown Wx numeric field %s", name)
  43556. }
  43557. // ClearedFields returns all nullable fields that were cleared during this
  43558. // mutation.
  43559. func (m *WxMutation) ClearedFields() []string {
  43560. var fields []string
  43561. if m.FieldCleared(wx.FieldStatus) {
  43562. fields = append(fields, wx.FieldStatus)
  43563. }
  43564. if m.FieldCleared(wx.FieldDeletedAt) {
  43565. fields = append(fields, wx.FieldDeletedAt)
  43566. }
  43567. if m.FieldCleared(wx.FieldServerID) {
  43568. fields = append(fields, wx.FieldServerID)
  43569. }
  43570. if m.FieldCleared(wx.FieldOrganizationID) {
  43571. fields = append(fields, wx.FieldOrganizationID)
  43572. }
  43573. if m.FieldCleared(wx.FieldAPIBase) {
  43574. fields = append(fields, wx.FieldAPIBase)
  43575. }
  43576. if m.FieldCleared(wx.FieldAPIKey) {
  43577. fields = append(fields, wx.FieldAPIKey)
  43578. }
  43579. if m.FieldCleared(wx.FieldCtype) {
  43580. fields = append(fields, wx.FieldCtype)
  43581. }
  43582. return fields
  43583. }
  43584. // FieldCleared returns a boolean indicating if a field with the given name was
  43585. // cleared in this mutation.
  43586. func (m *WxMutation) FieldCleared(name string) bool {
  43587. _, ok := m.clearedFields[name]
  43588. return ok
  43589. }
  43590. // ClearField clears the value of the field with the given name. It returns an
  43591. // error if the field is not defined in the schema.
  43592. func (m *WxMutation) ClearField(name string) error {
  43593. switch name {
  43594. case wx.FieldStatus:
  43595. m.ClearStatus()
  43596. return nil
  43597. case wx.FieldDeletedAt:
  43598. m.ClearDeletedAt()
  43599. return nil
  43600. case wx.FieldServerID:
  43601. m.ClearServerID()
  43602. return nil
  43603. case wx.FieldOrganizationID:
  43604. m.ClearOrganizationID()
  43605. return nil
  43606. case wx.FieldAPIBase:
  43607. m.ClearAPIBase()
  43608. return nil
  43609. case wx.FieldAPIKey:
  43610. m.ClearAPIKey()
  43611. return nil
  43612. case wx.FieldCtype:
  43613. m.ClearCtype()
  43614. return nil
  43615. }
  43616. return fmt.Errorf("unknown Wx nullable field %s", name)
  43617. }
  43618. // ResetField resets all changes in the mutation for the field with the given name.
  43619. // It returns an error if the field is not defined in the schema.
  43620. func (m *WxMutation) ResetField(name string) error {
  43621. switch name {
  43622. case wx.FieldCreatedAt:
  43623. m.ResetCreatedAt()
  43624. return nil
  43625. case wx.FieldUpdatedAt:
  43626. m.ResetUpdatedAt()
  43627. return nil
  43628. case wx.FieldStatus:
  43629. m.ResetStatus()
  43630. return nil
  43631. case wx.FieldDeletedAt:
  43632. m.ResetDeletedAt()
  43633. return nil
  43634. case wx.FieldServerID:
  43635. m.ResetServerID()
  43636. return nil
  43637. case wx.FieldPort:
  43638. m.ResetPort()
  43639. return nil
  43640. case wx.FieldProcessID:
  43641. m.ResetProcessID()
  43642. return nil
  43643. case wx.FieldCallback:
  43644. m.ResetCallback()
  43645. return nil
  43646. case wx.FieldWxid:
  43647. m.ResetWxid()
  43648. return nil
  43649. case wx.FieldAccount:
  43650. m.ResetAccount()
  43651. return nil
  43652. case wx.FieldNickname:
  43653. m.ResetNickname()
  43654. return nil
  43655. case wx.FieldTel:
  43656. m.ResetTel()
  43657. return nil
  43658. case wx.FieldHeadBig:
  43659. m.ResetHeadBig()
  43660. return nil
  43661. case wx.FieldOrganizationID:
  43662. m.ResetOrganizationID()
  43663. return nil
  43664. case wx.FieldAgentID:
  43665. m.ResetAgentID()
  43666. return nil
  43667. case wx.FieldAPIBase:
  43668. m.ResetAPIBase()
  43669. return nil
  43670. case wx.FieldAPIKey:
  43671. m.ResetAPIKey()
  43672. return nil
  43673. case wx.FieldAllowList:
  43674. m.ResetAllowList()
  43675. return nil
  43676. case wx.FieldGroupAllowList:
  43677. m.ResetGroupAllowList()
  43678. return nil
  43679. case wx.FieldBlockList:
  43680. m.ResetBlockList()
  43681. return nil
  43682. case wx.FieldGroupBlockList:
  43683. m.ResetGroupBlockList()
  43684. return nil
  43685. case wx.FieldCtype:
  43686. m.ResetCtype()
  43687. return nil
  43688. }
  43689. return fmt.Errorf("unknown Wx field %s", name)
  43690. }
  43691. // AddedEdges returns all edge names that were set/added in this mutation.
  43692. func (m *WxMutation) AddedEdges() []string {
  43693. edges := make([]string, 0, 2)
  43694. if m.server != nil {
  43695. edges = append(edges, wx.EdgeServer)
  43696. }
  43697. if m.agent != nil {
  43698. edges = append(edges, wx.EdgeAgent)
  43699. }
  43700. return edges
  43701. }
  43702. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43703. // name in this mutation.
  43704. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  43705. switch name {
  43706. case wx.EdgeServer:
  43707. if id := m.server; id != nil {
  43708. return []ent.Value{*id}
  43709. }
  43710. case wx.EdgeAgent:
  43711. if id := m.agent; id != nil {
  43712. return []ent.Value{*id}
  43713. }
  43714. }
  43715. return nil
  43716. }
  43717. // RemovedEdges returns all edge names that were removed in this mutation.
  43718. func (m *WxMutation) RemovedEdges() []string {
  43719. edges := make([]string, 0, 2)
  43720. return edges
  43721. }
  43722. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43723. // the given name in this mutation.
  43724. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  43725. return nil
  43726. }
  43727. // ClearedEdges returns all edge names that were cleared in this mutation.
  43728. func (m *WxMutation) ClearedEdges() []string {
  43729. edges := make([]string, 0, 2)
  43730. if m.clearedserver {
  43731. edges = append(edges, wx.EdgeServer)
  43732. }
  43733. if m.clearedagent {
  43734. edges = append(edges, wx.EdgeAgent)
  43735. }
  43736. return edges
  43737. }
  43738. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43739. // was cleared in this mutation.
  43740. func (m *WxMutation) EdgeCleared(name string) bool {
  43741. switch name {
  43742. case wx.EdgeServer:
  43743. return m.clearedserver
  43744. case wx.EdgeAgent:
  43745. return m.clearedagent
  43746. }
  43747. return false
  43748. }
  43749. // ClearEdge clears the value of the edge with the given name. It returns an error
  43750. // if that edge is not defined in the schema.
  43751. func (m *WxMutation) ClearEdge(name string) error {
  43752. switch name {
  43753. case wx.EdgeServer:
  43754. m.ClearServer()
  43755. return nil
  43756. case wx.EdgeAgent:
  43757. m.ClearAgent()
  43758. return nil
  43759. }
  43760. return fmt.Errorf("unknown Wx unique edge %s", name)
  43761. }
  43762. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43763. // It returns an error if the edge is not defined in the schema.
  43764. func (m *WxMutation) ResetEdge(name string) error {
  43765. switch name {
  43766. case wx.EdgeServer:
  43767. m.ResetServer()
  43768. return nil
  43769. case wx.EdgeAgent:
  43770. m.ResetAgent()
  43771. return nil
  43772. }
  43773. return fmt.Errorf("unknown Wx edge %s", name)
  43774. }
  43775. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  43776. type WxCardMutation struct {
  43777. config
  43778. op Op
  43779. typ string
  43780. id *uint64
  43781. created_at *time.Time
  43782. updated_at *time.Time
  43783. deleted_at *time.Time
  43784. user_id *uint64
  43785. adduser_id *int64
  43786. wx_user_id *uint64
  43787. addwx_user_id *int64
  43788. avatar *string
  43789. logo *string
  43790. name *string
  43791. company *string
  43792. address *string
  43793. phone *string
  43794. official_account *string
  43795. wechat_account *string
  43796. email *string
  43797. api_base *string
  43798. api_key *string
  43799. ai_info *string
  43800. intro *string
  43801. clearedFields map[string]struct{}
  43802. done bool
  43803. oldValue func(context.Context) (*WxCard, error)
  43804. predicates []predicate.WxCard
  43805. }
  43806. var _ ent.Mutation = (*WxCardMutation)(nil)
  43807. // wxcardOption allows management of the mutation configuration using functional options.
  43808. type wxcardOption func(*WxCardMutation)
  43809. // newWxCardMutation creates new mutation for the WxCard entity.
  43810. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  43811. m := &WxCardMutation{
  43812. config: c,
  43813. op: op,
  43814. typ: TypeWxCard,
  43815. clearedFields: make(map[string]struct{}),
  43816. }
  43817. for _, opt := range opts {
  43818. opt(m)
  43819. }
  43820. return m
  43821. }
  43822. // withWxCardID sets the ID field of the mutation.
  43823. func withWxCardID(id uint64) wxcardOption {
  43824. return func(m *WxCardMutation) {
  43825. var (
  43826. err error
  43827. once sync.Once
  43828. value *WxCard
  43829. )
  43830. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  43831. once.Do(func() {
  43832. if m.done {
  43833. err = errors.New("querying old values post mutation is not allowed")
  43834. } else {
  43835. value, err = m.Client().WxCard.Get(ctx, id)
  43836. }
  43837. })
  43838. return value, err
  43839. }
  43840. m.id = &id
  43841. }
  43842. }
  43843. // withWxCard sets the old WxCard of the mutation.
  43844. func withWxCard(node *WxCard) wxcardOption {
  43845. return func(m *WxCardMutation) {
  43846. m.oldValue = func(context.Context) (*WxCard, error) {
  43847. return node, nil
  43848. }
  43849. m.id = &node.ID
  43850. }
  43851. }
  43852. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43853. // executed in a transaction (ent.Tx), a transactional client is returned.
  43854. func (m WxCardMutation) Client() *Client {
  43855. client := &Client{config: m.config}
  43856. client.init()
  43857. return client
  43858. }
  43859. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43860. // it returns an error otherwise.
  43861. func (m WxCardMutation) Tx() (*Tx, error) {
  43862. if _, ok := m.driver.(*txDriver); !ok {
  43863. return nil, errors.New("ent: mutation is not running in a transaction")
  43864. }
  43865. tx := &Tx{config: m.config}
  43866. tx.init()
  43867. return tx, nil
  43868. }
  43869. // SetID sets the value of the id field. Note that this
  43870. // operation is only accepted on creation of WxCard entities.
  43871. func (m *WxCardMutation) SetID(id uint64) {
  43872. m.id = &id
  43873. }
  43874. // ID returns the ID value in the mutation. Note that the ID is only available
  43875. // if it was provided to the builder or after it was returned from the database.
  43876. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  43877. if m.id == nil {
  43878. return
  43879. }
  43880. return *m.id, true
  43881. }
  43882. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43883. // That means, if the mutation is applied within a transaction with an isolation level such
  43884. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43885. // or updated by the mutation.
  43886. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  43887. switch {
  43888. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43889. id, exists := m.ID()
  43890. if exists {
  43891. return []uint64{id}, nil
  43892. }
  43893. fallthrough
  43894. case m.op.Is(OpUpdate | OpDelete):
  43895. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  43896. default:
  43897. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43898. }
  43899. }
  43900. // SetCreatedAt sets the "created_at" field.
  43901. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  43902. m.created_at = &t
  43903. }
  43904. // CreatedAt returns the value of the "created_at" field in the mutation.
  43905. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  43906. v := m.created_at
  43907. if v == nil {
  43908. return
  43909. }
  43910. return *v, true
  43911. }
  43912. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  43913. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43915. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43916. if !m.op.Is(OpUpdateOne) {
  43917. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43918. }
  43919. if m.id == nil || m.oldValue == nil {
  43920. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43921. }
  43922. oldValue, err := m.oldValue(ctx)
  43923. if err != nil {
  43924. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43925. }
  43926. return oldValue.CreatedAt, nil
  43927. }
  43928. // ResetCreatedAt resets all changes to the "created_at" field.
  43929. func (m *WxCardMutation) ResetCreatedAt() {
  43930. m.created_at = nil
  43931. }
  43932. // SetUpdatedAt sets the "updated_at" field.
  43933. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  43934. m.updated_at = &t
  43935. }
  43936. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43937. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  43938. v := m.updated_at
  43939. if v == nil {
  43940. return
  43941. }
  43942. return *v, true
  43943. }
  43944. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  43945. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43947. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43948. if !m.op.Is(OpUpdateOne) {
  43949. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43950. }
  43951. if m.id == nil || m.oldValue == nil {
  43952. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43953. }
  43954. oldValue, err := m.oldValue(ctx)
  43955. if err != nil {
  43956. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43957. }
  43958. return oldValue.UpdatedAt, nil
  43959. }
  43960. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43961. func (m *WxCardMutation) ResetUpdatedAt() {
  43962. m.updated_at = nil
  43963. }
  43964. // SetDeletedAt sets the "deleted_at" field.
  43965. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  43966. m.deleted_at = &t
  43967. }
  43968. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43969. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  43970. v := m.deleted_at
  43971. if v == nil {
  43972. return
  43973. }
  43974. return *v, true
  43975. }
  43976. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  43977. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  43978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43979. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43980. if !m.op.Is(OpUpdateOne) {
  43981. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43982. }
  43983. if m.id == nil || m.oldValue == nil {
  43984. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43985. }
  43986. oldValue, err := m.oldValue(ctx)
  43987. if err != nil {
  43988. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43989. }
  43990. return oldValue.DeletedAt, nil
  43991. }
  43992. // ClearDeletedAt clears the value of the "deleted_at" field.
  43993. func (m *WxCardMutation) ClearDeletedAt() {
  43994. m.deleted_at = nil
  43995. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  43996. }
  43997. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43998. func (m *WxCardMutation) DeletedAtCleared() bool {
  43999. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  44000. return ok
  44001. }
  44002. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44003. func (m *WxCardMutation) ResetDeletedAt() {
  44004. m.deleted_at = nil
  44005. delete(m.clearedFields, wxcard.FieldDeletedAt)
  44006. }
  44007. // SetUserID sets the "user_id" field.
  44008. func (m *WxCardMutation) SetUserID(u uint64) {
  44009. m.user_id = &u
  44010. m.adduser_id = nil
  44011. }
  44012. // UserID returns the value of the "user_id" field in the mutation.
  44013. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  44014. v := m.user_id
  44015. if v == nil {
  44016. return
  44017. }
  44018. return *v, true
  44019. }
  44020. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  44021. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44023. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  44024. if !m.op.Is(OpUpdateOne) {
  44025. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  44026. }
  44027. if m.id == nil || m.oldValue == nil {
  44028. return v, errors.New("OldUserID requires an ID field in the mutation")
  44029. }
  44030. oldValue, err := m.oldValue(ctx)
  44031. if err != nil {
  44032. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  44033. }
  44034. return oldValue.UserID, nil
  44035. }
  44036. // AddUserID adds u to the "user_id" field.
  44037. func (m *WxCardMutation) AddUserID(u int64) {
  44038. if m.adduser_id != nil {
  44039. *m.adduser_id += u
  44040. } else {
  44041. m.adduser_id = &u
  44042. }
  44043. }
  44044. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  44045. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  44046. v := m.adduser_id
  44047. if v == nil {
  44048. return
  44049. }
  44050. return *v, true
  44051. }
  44052. // ClearUserID clears the value of the "user_id" field.
  44053. func (m *WxCardMutation) ClearUserID() {
  44054. m.user_id = nil
  44055. m.adduser_id = nil
  44056. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  44057. }
  44058. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  44059. func (m *WxCardMutation) UserIDCleared() bool {
  44060. _, ok := m.clearedFields[wxcard.FieldUserID]
  44061. return ok
  44062. }
  44063. // ResetUserID resets all changes to the "user_id" field.
  44064. func (m *WxCardMutation) ResetUserID() {
  44065. m.user_id = nil
  44066. m.adduser_id = nil
  44067. delete(m.clearedFields, wxcard.FieldUserID)
  44068. }
  44069. // SetWxUserID sets the "wx_user_id" field.
  44070. func (m *WxCardMutation) SetWxUserID(u uint64) {
  44071. m.wx_user_id = &u
  44072. m.addwx_user_id = nil
  44073. }
  44074. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  44075. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  44076. v := m.wx_user_id
  44077. if v == nil {
  44078. return
  44079. }
  44080. return *v, true
  44081. }
  44082. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  44083. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44085. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  44086. if !m.op.Is(OpUpdateOne) {
  44087. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  44088. }
  44089. if m.id == nil || m.oldValue == nil {
  44090. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  44091. }
  44092. oldValue, err := m.oldValue(ctx)
  44093. if err != nil {
  44094. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  44095. }
  44096. return oldValue.WxUserID, nil
  44097. }
  44098. // AddWxUserID adds u to the "wx_user_id" field.
  44099. func (m *WxCardMutation) AddWxUserID(u int64) {
  44100. if m.addwx_user_id != nil {
  44101. *m.addwx_user_id += u
  44102. } else {
  44103. m.addwx_user_id = &u
  44104. }
  44105. }
  44106. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  44107. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  44108. v := m.addwx_user_id
  44109. if v == nil {
  44110. return
  44111. }
  44112. return *v, true
  44113. }
  44114. // ClearWxUserID clears the value of the "wx_user_id" field.
  44115. func (m *WxCardMutation) ClearWxUserID() {
  44116. m.wx_user_id = nil
  44117. m.addwx_user_id = nil
  44118. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  44119. }
  44120. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  44121. func (m *WxCardMutation) WxUserIDCleared() bool {
  44122. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  44123. return ok
  44124. }
  44125. // ResetWxUserID resets all changes to the "wx_user_id" field.
  44126. func (m *WxCardMutation) ResetWxUserID() {
  44127. m.wx_user_id = nil
  44128. m.addwx_user_id = nil
  44129. delete(m.clearedFields, wxcard.FieldWxUserID)
  44130. }
  44131. // SetAvatar sets the "avatar" field.
  44132. func (m *WxCardMutation) SetAvatar(s string) {
  44133. m.avatar = &s
  44134. }
  44135. // Avatar returns the value of the "avatar" field in the mutation.
  44136. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  44137. v := m.avatar
  44138. if v == nil {
  44139. return
  44140. }
  44141. return *v, true
  44142. }
  44143. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  44144. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44146. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  44147. if !m.op.Is(OpUpdateOne) {
  44148. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  44149. }
  44150. if m.id == nil || m.oldValue == nil {
  44151. return v, errors.New("OldAvatar requires an ID field in the mutation")
  44152. }
  44153. oldValue, err := m.oldValue(ctx)
  44154. if err != nil {
  44155. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  44156. }
  44157. return oldValue.Avatar, nil
  44158. }
  44159. // ResetAvatar resets all changes to the "avatar" field.
  44160. func (m *WxCardMutation) ResetAvatar() {
  44161. m.avatar = nil
  44162. }
  44163. // SetLogo sets the "logo" field.
  44164. func (m *WxCardMutation) SetLogo(s string) {
  44165. m.logo = &s
  44166. }
  44167. // Logo returns the value of the "logo" field in the mutation.
  44168. func (m *WxCardMutation) Logo() (r string, exists bool) {
  44169. v := m.logo
  44170. if v == nil {
  44171. return
  44172. }
  44173. return *v, true
  44174. }
  44175. // OldLogo returns the old "logo" field's value of the WxCard entity.
  44176. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44178. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  44179. if !m.op.Is(OpUpdateOne) {
  44180. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  44181. }
  44182. if m.id == nil || m.oldValue == nil {
  44183. return v, errors.New("OldLogo requires an ID field in the mutation")
  44184. }
  44185. oldValue, err := m.oldValue(ctx)
  44186. if err != nil {
  44187. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  44188. }
  44189. return oldValue.Logo, nil
  44190. }
  44191. // ResetLogo resets all changes to the "logo" field.
  44192. func (m *WxCardMutation) ResetLogo() {
  44193. m.logo = nil
  44194. }
  44195. // SetName sets the "name" field.
  44196. func (m *WxCardMutation) SetName(s string) {
  44197. m.name = &s
  44198. }
  44199. // Name returns the value of the "name" field in the mutation.
  44200. func (m *WxCardMutation) Name() (r string, exists bool) {
  44201. v := m.name
  44202. if v == nil {
  44203. return
  44204. }
  44205. return *v, true
  44206. }
  44207. // OldName returns the old "name" field's value of the WxCard entity.
  44208. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44210. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  44211. if !m.op.Is(OpUpdateOne) {
  44212. return v, errors.New("OldName is only allowed on UpdateOne operations")
  44213. }
  44214. if m.id == nil || m.oldValue == nil {
  44215. return v, errors.New("OldName requires an ID field in the mutation")
  44216. }
  44217. oldValue, err := m.oldValue(ctx)
  44218. if err != nil {
  44219. return v, fmt.Errorf("querying old value for OldName: %w", err)
  44220. }
  44221. return oldValue.Name, nil
  44222. }
  44223. // ResetName resets all changes to the "name" field.
  44224. func (m *WxCardMutation) ResetName() {
  44225. m.name = nil
  44226. }
  44227. // SetCompany sets the "company" field.
  44228. func (m *WxCardMutation) SetCompany(s string) {
  44229. m.company = &s
  44230. }
  44231. // Company returns the value of the "company" field in the mutation.
  44232. func (m *WxCardMutation) Company() (r string, exists bool) {
  44233. v := m.company
  44234. if v == nil {
  44235. return
  44236. }
  44237. return *v, true
  44238. }
  44239. // OldCompany returns the old "company" field's value of the WxCard entity.
  44240. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44242. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  44243. if !m.op.Is(OpUpdateOne) {
  44244. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  44245. }
  44246. if m.id == nil || m.oldValue == nil {
  44247. return v, errors.New("OldCompany requires an ID field in the mutation")
  44248. }
  44249. oldValue, err := m.oldValue(ctx)
  44250. if err != nil {
  44251. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  44252. }
  44253. return oldValue.Company, nil
  44254. }
  44255. // ResetCompany resets all changes to the "company" field.
  44256. func (m *WxCardMutation) ResetCompany() {
  44257. m.company = nil
  44258. }
  44259. // SetAddress sets the "address" field.
  44260. func (m *WxCardMutation) SetAddress(s string) {
  44261. m.address = &s
  44262. }
  44263. // Address returns the value of the "address" field in the mutation.
  44264. func (m *WxCardMutation) Address() (r string, exists bool) {
  44265. v := m.address
  44266. if v == nil {
  44267. return
  44268. }
  44269. return *v, true
  44270. }
  44271. // OldAddress returns the old "address" field's value of the WxCard entity.
  44272. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44274. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  44275. if !m.op.Is(OpUpdateOne) {
  44276. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  44277. }
  44278. if m.id == nil || m.oldValue == nil {
  44279. return v, errors.New("OldAddress requires an ID field in the mutation")
  44280. }
  44281. oldValue, err := m.oldValue(ctx)
  44282. if err != nil {
  44283. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  44284. }
  44285. return oldValue.Address, nil
  44286. }
  44287. // ResetAddress resets all changes to the "address" field.
  44288. func (m *WxCardMutation) ResetAddress() {
  44289. m.address = nil
  44290. }
  44291. // SetPhone sets the "phone" field.
  44292. func (m *WxCardMutation) SetPhone(s string) {
  44293. m.phone = &s
  44294. }
  44295. // Phone returns the value of the "phone" field in the mutation.
  44296. func (m *WxCardMutation) Phone() (r string, exists bool) {
  44297. v := m.phone
  44298. if v == nil {
  44299. return
  44300. }
  44301. return *v, true
  44302. }
  44303. // OldPhone returns the old "phone" field's value of the WxCard entity.
  44304. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44306. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  44307. if !m.op.Is(OpUpdateOne) {
  44308. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  44309. }
  44310. if m.id == nil || m.oldValue == nil {
  44311. return v, errors.New("OldPhone requires an ID field in the mutation")
  44312. }
  44313. oldValue, err := m.oldValue(ctx)
  44314. if err != nil {
  44315. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  44316. }
  44317. return oldValue.Phone, nil
  44318. }
  44319. // ResetPhone resets all changes to the "phone" field.
  44320. func (m *WxCardMutation) ResetPhone() {
  44321. m.phone = nil
  44322. }
  44323. // SetOfficialAccount sets the "official_account" field.
  44324. func (m *WxCardMutation) SetOfficialAccount(s string) {
  44325. m.official_account = &s
  44326. }
  44327. // OfficialAccount returns the value of the "official_account" field in the mutation.
  44328. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  44329. v := m.official_account
  44330. if v == nil {
  44331. return
  44332. }
  44333. return *v, true
  44334. }
  44335. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  44336. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44338. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  44339. if !m.op.Is(OpUpdateOne) {
  44340. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  44341. }
  44342. if m.id == nil || m.oldValue == nil {
  44343. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  44344. }
  44345. oldValue, err := m.oldValue(ctx)
  44346. if err != nil {
  44347. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  44348. }
  44349. return oldValue.OfficialAccount, nil
  44350. }
  44351. // ResetOfficialAccount resets all changes to the "official_account" field.
  44352. func (m *WxCardMutation) ResetOfficialAccount() {
  44353. m.official_account = nil
  44354. }
  44355. // SetWechatAccount sets the "wechat_account" field.
  44356. func (m *WxCardMutation) SetWechatAccount(s string) {
  44357. m.wechat_account = &s
  44358. }
  44359. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  44360. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  44361. v := m.wechat_account
  44362. if v == nil {
  44363. return
  44364. }
  44365. return *v, true
  44366. }
  44367. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  44368. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44370. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  44371. if !m.op.Is(OpUpdateOne) {
  44372. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  44373. }
  44374. if m.id == nil || m.oldValue == nil {
  44375. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  44376. }
  44377. oldValue, err := m.oldValue(ctx)
  44378. if err != nil {
  44379. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  44380. }
  44381. return oldValue.WechatAccount, nil
  44382. }
  44383. // ResetWechatAccount resets all changes to the "wechat_account" field.
  44384. func (m *WxCardMutation) ResetWechatAccount() {
  44385. m.wechat_account = nil
  44386. }
  44387. // SetEmail sets the "email" field.
  44388. func (m *WxCardMutation) SetEmail(s string) {
  44389. m.email = &s
  44390. }
  44391. // Email returns the value of the "email" field in the mutation.
  44392. func (m *WxCardMutation) Email() (r string, exists bool) {
  44393. v := m.email
  44394. if v == nil {
  44395. return
  44396. }
  44397. return *v, true
  44398. }
  44399. // OldEmail returns the old "email" field's value of the WxCard entity.
  44400. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44402. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  44403. if !m.op.Is(OpUpdateOne) {
  44404. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  44405. }
  44406. if m.id == nil || m.oldValue == nil {
  44407. return v, errors.New("OldEmail requires an ID field in the mutation")
  44408. }
  44409. oldValue, err := m.oldValue(ctx)
  44410. if err != nil {
  44411. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  44412. }
  44413. return oldValue.Email, nil
  44414. }
  44415. // ClearEmail clears the value of the "email" field.
  44416. func (m *WxCardMutation) ClearEmail() {
  44417. m.email = nil
  44418. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  44419. }
  44420. // EmailCleared returns if the "email" field was cleared in this mutation.
  44421. func (m *WxCardMutation) EmailCleared() bool {
  44422. _, ok := m.clearedFields[wxcard.FieldEmail]
  44423. return ok
  44424. }
  44425. // ResetEmail resets all changes to the "email" field.
  44426. func (m *WxCardMutation) ResetEmail() {
  44427. m.email = nil
  44428. delete(m.clearedFields, wxcard.FieldEmail)
  44429. }
  44430. // SetAPIBase sets the "api_base" field.
  44431. func (m *WxCardMutation) SetAPIBase(s string) {
  44432. m.api_base = &s
  44433. }
  44434. // APIBase returns the value of the "api_base" field in the mutation.
  44435. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  44436. v := m.api_base
  44437. if v == nil {
  44438. return
  44439. }
  44440. return *v, true
  44441. }
  44442. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  44443. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44445. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  44446. if !m.op.Is(OpUpdateOne) {
  44447. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  44448. }
  44449. if m.id == nil || m.oldValue == nil {
  44450. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  44451. }
  44452. oldValue, err := m.oldValue(ctx)
  44453. if err != nil {
  44454. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  44455. }
  44456. return oldValue.APIBase, nil
  44457. }
  44458. // ClearAPIBase clears the value of the "api_base" field.
  44459. func (m *WxCardMutation) ClearAPIBase() {
  44460. m.api_base = nil
  44461. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  44462. }
  44463. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  44464. func (m *WxCardMutation) APIBaseCleared() bool {
  44465. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  44466. return ok
  44467. }
  44468. // ResetAPIBase resets all changes to the "api_base" field.
  44469. func (m *WxCardMutation) ResetAPIBase() {
  44470. m.api_base = nil
  44471. delete(m.clearedFields, wxcard.FieldAPIBase)
  44472. }
  44473. // SetAPIKey sets the "api_key" field.
  44474. func (m *WxCardMutation) SetAPIKey(s string) {
  44475. m.api_key = &s
  44476. }
  44477. // APIKey returns the value of the "api_key" field in the mutation.
  44478. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  44479. v := m.api_key
  44480. if v == nil {
  44481. return
  44482. }
  44483. return *v, true
  44484. }
  44485. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  44486. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44488. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  44489. if !m.op.Is(OpUpdateOne) {
  44490. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  44491. }
  44492. if m.id == nil || m.oldValue == nil {
  44493. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  44494. }
  44495. oldValue, err := m.oldValue(ctx)
  44496. if err != nil {
  44497. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  44498. }
  44499. return oldValue.APIKey, nil
  44500. }
  44501. // ClearAPIKey clears the value of the "api_key" field.
  44502. func (m *WxCardMutation) ClearAPIKey() {
  44503. m.api_key = nil
  44504. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  44505. }
  44506. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  44507. func (m *WxCardMutation) APIKeyCleared() bool {
  44508. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  44509. return ok
  44510. }
  44511. // ResetAPIKey resets all changes to the "api_key" field.
  44512. func (m *WxCardMutation) ResetAPIKey() {
  44513. m.api_key = nil
  44514. delete(m.clearedFields, wxcard.FieldAPIKey)
  44515. }
  44516. // SetAiInfo sets the "ai_info" field.
  44517. func (m *WxCardMutation) SetAiInfo(s string) {
  44518. m.ai_info = &s
  44519. }
  44520. // AiInfo returns the value of the "ai_info" field in the mutation.
  44521. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  44522. v := m.ai_info
  44523. if v == nil {
  44524. return
  44525. }
  44526. return *v, true
  44527. }
  44528. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  44529. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44531. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  44532. if !m.op.Is(OpUpdateOne) {
  44533. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  44534. }
  44535. if m.id == nil || m.oldValue == nil {
  44536. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  44537. }
  44538. oldValue, err := m.oldValue(ctx)
  44539. if err != nil {
  44540. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  44541. }
  44542. return oldValue.AiInfo, nil
  44543. }
  44544. // ClearAiInfo clears the value of the "ai_info" field.
  44545. func (m *WxCardMutation) ClearAiInfo() {
  44546. m.ai_info = nil
  44547. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  44548. }
  44549. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  44550. func (m *WxCardMutation) AiInfoCleared() bool {
  44551. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  44552. return ok
  44553. }
  44554. // ResetAiInfo resets all changes to the "ai_info" field.
  44555. func (m *WxCardMutation) ResetAiInfo() {
  44556. m.ai_info = nil
  44557. delete(m.clearedFields, wxcard.FieldAiInfo)
  44558. }
  44559. // SetIntro sets the "intro" field.
  44560. func (m *WxCardMutation) SetIntro(s string) {
  44561. m.intro = &s
  44562. }
  44563. // Intro returns the value of the "intro" field in the mutation.
  44564. func (m *WxCardMutation) Intro() (r string, exists bool) {
  44565. v := m.intro
  44566. if v == nil {
  44567. return
  44568. }
  44569. return *v, true
  44570. }
  44571. // OldIntro returns the old "intro" field's value of the WxCard entity.
  44572. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  44573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44574. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  44575. if !m.op.Is(OpUpdateOne) {
  44576. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  44577. }
  44578. if m.id == nil || m.oldValue == nil {
  44579. return v, errors.New("OldIntro requires an ID field in the mutation")
  44580. }
  44581. oldValue, err := m.oldValue(ctx)
  44582. if err != nil {
  44583. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  44584. }
  44585. return oldValue.Intro, nil
  44586. }
  44587. // ClearIntro clears the value of the "intro" field.
  44588. func (m *WxCardMutation) ClearIntro() {
  44589. m.intro = nil
  44590. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  44591. }
  44592. // IntroCleared returns if the "intro" field was cleared in this mutation.
  44593. func (m *WxCardMutation) IntroCleared() bool {
  44594. _, ok := m.clearedFields[wxcard.FieldIntro]
  44595. return ok
  44596. }
  44597. // ResetIntro resets all changes to the "intro" field.
  44598. func (m *WxCardMutation) ResetIntro() {
  44599. m.intro = nil
  44600. delete(m.clearedFields, wxcard.FieldIntro)
  44601. }
  44602. // Where appends a list predicates to the WxCardMutation builder.
  44603. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  44604. m.predicates = append(m.predicates, ps...)
  44605. }
  44606. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  44607. // users can use type-assertion to append predicates that do not depend on any generated package.
  44608. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  44609. p := make([]predicate.WxCard, len(ps))
  44610. for i := range ps {
  44611. p[i] = ps[i]
  44612. }
  44613. m.Where(p...)
  44614. }
  44615. // Op returns the operation name.
  44616. func (m *WxCardMutation) Op() Op {
  44617. return m.op
  44618. }
  44619. // SetOp allows setting the mutation operation.
  44620. func (m *WxCardMutation) SetOp(op Op) {
  44621. m.op = op
  44622. }
  44623. // Type returns the node type of this mutation (WxCard).
  44624. func (m *WxCardMutation) Type() string {
  44625. return m.typ
  44626. }
  44627. // Fields returns all fields that were changed during this mutation. Note that in
  44628. // order to get all numeric fields that were incremented/decremented, call
  44629. // AddedFields().
  44630. func (m *WxCardMutation) Fields() []string {
  44631. fields := make([]string, 0, 18)
  44632. if m.created_at != nil {
  44633. fields = append(fields, wxcard.FieldCreatedAt)
  44634. }
  44635. if m.updated_at != nil {
  44636. fields = append(fields, wxcard.FieldUpdatedAt)
  44637. }
  44638. if m.deleted_at != nil {
  44639. fields = append(fields, wxcard.FieldDeletedAt)
  44640. }
  44641. if m.user_id != nil {
  44642. fields = append(fields, wxcard.FieldUserID)
  44643. }
  44644. if m.wx_user_id != nil {
  44645. fields = append(fields, wxcard.FieldWxUserID)
  44646. }
  44647. if m.avatar != nil {
  44648. fields = append(fields, wxcard.FieldAvatar)
  44649. }
  44650. if m.logo != nil {
  44651. fields = append(fields, wxcard.FieldLogo)
  44652. }
  44653. if m.name != nil {
  44654. fields = append(fields, wxcard.FieldName)
  44655. }
  44656. if m.company != nil {
  44657. fields = append(fields, wxcard.FieldCompany)
  44658. }
  44659. if m.address != nil {
  44660. fields = append(fields, wxcard.FieldAddress)
  44661. }
  44662. if m.phone != nil {
  44663. fields = append(fields, wxcard.FieldPhone)
  44664. }
  44665. if m.official_account != nil {
  44666. fields = append(fields, wxcard.FieldOfficialAccount)
  44667. }
  44668. if m.wechat_account != nil {
  44669. fields = append(fields, wxcard.FieldWechatAccount)
  44670. }
  44671. if m.email != nil {
  44672. fields = append(fields, wxcard.FieldEmail)
  44673. }
  44674. if m.api_base != nil {
  44675. fields = append(fields, wxcard.FieldAPIBase)
  44676. }
  44677. if m.api_key != nil {
  44678. fields = append(fields, wxcard.FieldAPIKey)
  44679. }
  44680. if m.ai_info != nil {
  44681. fields = append(fields, wxcard.FieldAiInfo)
  44682. }
  44683. if m.intro != nil {
  44684. fields = append(fields, wxcard.FieldIntro)
  44685. }
  44686. return fields
  44687. }
  44688. // Field returns the value of a field with the given name. The second boolean
  44689. // return value indicates that this field was not set, or was not defined in the
  44690. // schema.
  44691. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  44692. switch name {
  44693. case wxcard.FieldCreatedAt:
  44694. return m.CreatedAt()
  44695. case wxcard.FieldUpdatedAt:
  44696. return m.UpdatedAt()
  44697. case wxcard.FieldDeletedAt:
  44698. return m.DeletedAt()
  44699. case wxcard.FieldUserID:
  44700. return m.UserID()
  44701. case wxcard.FieldWxUserID:
  44702. return m.WxUserID()
  44703. case wxcard.FieldAvatar:
  44704. return m.Avatar()
  44705. case wxcard.FieldLogo:
  44706. return m.Logo()
  44707. case wxcard.FieldName:
  44708. return m.Name()
  44709. case wxcard.FieldCompany:
  44710. return m.Company()
  44711. case wxcard.FieldAddress:
  44712. return m.Address()
  44713. case wxcard.FieldPhone:
  44714. return m.Phone()
  44715. case wxcard.FieldOfficialAccount:
  44716. return m.OfficialAccount()
  44717. case wxcard.FieldWechatAccount:
  44718. return m.WechatAccount()
  44719. case wxcard.FieldEmail:
  44720. return m.Email()
  44721. case wxcard.FieldAPIBase:
  44722. return m.APIBase()
  44723. case wxcard.FieldAPIKey:
  44724. return m.APIKey()
  44725. case wxcard.FieldAiInfo:
  44726. return m.AiInfo()
  44727. case wxcard.FieldIntro:
  44728. return m.Intro()
  44729. }
  44730. return nil, false
  44731. }
  44732. // OldField returns the old value of the field from the database. An error is
  44733. // returned if the mutation operation is not UpdateOne, or the query to the
  44734. // database failed.
  44735. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44736. switch name {
  44737. case wxcard.FieldCreatedAt:
  44738. return m.OldCreatedAt(ctx)
  44739. case wxcard.FieldUpdatedAt:
  44740. return m.OldUpdatedAt(ctx)
  44741. case wxcard.FieldDeletedAt:
  44742. return m.OldDeletedAt(ctx)
  44743. case wxcard.FieldUserID:
  44744. return m.OldUserID(ctx)
  44745. case wxcard.FieldWxUserID:
  44746. return m.OldWxUserID(ctx)
  44747. case wxcard.FieldAvatar:
  44748. return m.OldAvatar(ctx)
  44749. case wxcard.FieldLogo:
  44750. return m.OldLogo(ctx)
  44751. case wxcard.FieldName:
  44752. return m.OldName(ctx)
  44753. case wxcard.FieldCompany:
  44754. return m.OldCompany(ctx)
  44755. case wxcard.FieldAddress:
  44756. return m.OldAddress(ctx)
  44757. case wxcard.FieldPhone:
  44758. return m.OldPhone(ctx)
  44759. case wxcard.FieldOfficialAccount:
  44760. return m.OldOfficialAccount(ctx)
  44761. case wxcard.FieldWechatAccount:
  44762. return m.OldWechatAccount(ctx)
  44763. case wxcard.FieldEmail:
  44764. return m.OldEmail(ctx)
  44765. case wxcard.FieldAPIBase:
  44766. return m.OldAPIBase(ctx)
  44767. case wxcard.FieldAPIKey:
  44768. return m.OldAPIKey(ctx)
  44769. case wxcard.FieldAiInfo:
  44770. return m.OldAiInfo(ctx)
  44771. case wxcard.FieldIntro:
  44772. return m.OldIntro(ctx)
  44773. }
  44774. return nil, fmt.Errorf("unknown WxCard field %s", name)
  44775. }
  44776. // SetField sets the value of a field with the given name. It returns an error if
  44777. // the field is not defined in the schema, or if the type mismatched the field
  44778. // type.
  44779. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  44780. switch name {
  44781. case wxcard.FieldCreatedAt:
  44782. v, ok := value.(time.Time)
  44783. if !ok {
  44784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44785. }
  44786. m.SetCreatedAt(v)
  44787. return nil
  44788. case wxcard.FieldUpdatedAt:
  44789. v, ok := value.(time.Time)
  44790. if !ok {
  44791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44792. }
  44793. m.SetUpdatedAt(v)
  44794. return nil
  44795. case wxcard.FieldDeletedAt:
  44796. v, ok := value.(time.Time)
  44797. if !ok {
  44798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44799. }
  44800. m.SetDeletedAt(v)
  44801. return nil
  44802. case wxcard.FieldUserID:
  44803. v, ok := value.(uint64)
  44804. if !ok {
  44805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44806. }
  44807. m.SetUserID(v)
  44808. return nil
  44809. case wxcard.FieldWxUserID:
  44810. v, ok := value.(uint64)
  44811. if !ok {
  44812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44813. }
  44814. m.SetWxUserID(v)
  44815. return nil
  44816. case wxcard.FieldAvatar:
  44817. v, ok := value.(string)
  44818. if !ok {
  44819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44820. }
  44821. m.SetAvatar(v)
  44822. return nil
  44823. case wxcard.FieldLogo:
  44824. v, ok := value.(string)
  44825. if !ok {
  44826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44827. }
  44828. m.SetLogo(v)
  44829. return nil
  44830. case wxcard.FieldName:
  44831. v, ok := value.(string)
  44832. if !ok {
  44833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44834. }
  44835. m.SetName(v)
  44836. return nil
  44837. case wxcard.FieldCompany:
  44838. v, ok := value.(string)
  44839. if !ok {
  44840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44841. }
  44842. m.SetCompany(v)
  44843. return nil
  44844. case wxcard.FieldAddress:
  44845. v, ok := value.(string)
  44846. if !ok {
  44847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44848. }
  44849. m.SetAddress(v)
  44850. return nil
  44851. case wxcard.FieldPhone:
  44852. v, ok := value.(string)
  44853. if !ok {
  44854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44855. }
  44856. m.SetPhone(v)
  44857. return nil
  44858. case wxcard.FieldOfficialAccount:
  44859. v, ok := value.(string)
  44860. if !ok {
  44861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44862. }
  44863. m.SetOfficialAccount(v)
  44864. return nil
  44865. case wxcard.FieldWechatAccount:
  44866. v, ok := value.(string)
  44867. if !ok {
  44868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44869. }
  44870. m.SetWechatAccount(v)
  44871. return nil
  44872. case wxcard.FieldEmail:
  44873. v, ok := value.(string)
  44874. if !ok {
  44875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44876. }
  44877. m.SetEmail(v)
  44878. return nil
  44879. case wxcard.FieldAPIBase:
  44880. v, ok := value.(string)
  44881. if !ok {
  44882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44883. }
  44884. m.SetAPIBase(v)
  44885. return nil
  44886. case wxcard.FieldAPIKey:
  44887. v, ok := value.(string)
  44888. if !ok {
  44889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44890. }
  44891. m.SetAPIKey(v)
  44892. return nil
  44893. case wxcard.FieldAiInfo:
  44894. v, ok := value.(string)
  44895. if !ok {
  44896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44897. }
  44898. m.SetAiInfo(v)
  44899. return nil
  44900. case wxcard.FieldIntro:
  44901. v, ok := value.(string)
  44902. if !ok {
  44903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44904. }
  44905. m.SetIntro(v)
  44906. return nil
  44907. }
  44908. return fmt.Errorf("unknown WxCard field %s", name)
  44909. }
  44910. // AddedFields returns all numeric fields that were incremented/decremented during
  44911. // this mutation.
  44912. func (m *WxCardMutation) AddedFields() []string {
  44913. var fields []string
  44914. if m.adduser_id != nil {
  44915. fields = append(fields, wxcard.FieldUserID)
  44916. }
  44917. if m.addwx_user_id != nil {
  44918. fields = append(fields, wxcard.FieldWxUserID)
  44919. }
  44920. return fields
  44921. }
  44922. // AddedField returns the numeric value that was incremented/decremented on a field
  44923. // with the given name. The second boolean return value indicates that this field
  44924. // was not set, or was not defined in the schema.
  44925. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  44926. switch name {
  44927. case wxcard.FieldUserID:
  44928. return m.AddedUserID()
  44929. case wxcard.FieldWxUserID:
  44930. return m.AddedWxUserID()
  44931. }
  44932. return nil, false
  44933. }
  44934. // AddField adds the value to the field with the given name. It returns an error if
  44935. // the field is not defined in the schema, or if the type mismatched the field
  44936. // type.
  44937. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  44938. switch name {
  44939. case wxcard.FieldUserID:
  44940. v, ok := value.(int64)
  44941. if !ok {
  44942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44943. }
  44944. m.AddUserID(v)
  44945. return nil
  44946. case wxcard.FieldWxUserID:
  44947. v, ok := value.(int64)
  44948. if !ok {
  44949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44950. }
  44951. m.AddWxUserID(v)
  44952. return nil
  44953. }
  44954. return fmt.Errorf("unknown WxCard numeric field %s", name)
  44955. }
  44956. // ClearedFields returns all nullable fields that were cleared during this
  44957. // mutation.
  44958. func (m *WxCardMutation) ClearedFields() []string {
  44959. var fields []string
  44960. if m.FieldCleared(wxcard.FieldDeletedAt) {
  44961. fields = append(fields, wxcard.FieldDeletedAt)
  44962. }
  44963. if m.FieldCleared(wxcard.FieldUserID) {
  44964. fields = append(fields, wxcard.FieldUserID)
  44965. }
  44966. if m.FieldCleared(wxcard.FieldWxUserID) {
  44967. fields = append(fields, wxcard.FieldWxUserID)
  44968. }
  44969. if m.FieldCleared(wxcard.FieldEmail) {
  44970. fields = append(fields, wxcard.FieldEmail)
  44971. }
  44972. if m.FieldCleared(wxcard.FieldAPIBase) {
  44973. fields = append(fields, wxcard.FieldAPIBase)
  44974. }
  44975. if m.FieldCleared(wxcard.FieldAPIKey) {
  44976. fields = append(fields, wxcard.FieldAPIKey)
  44977. }
  44978. if m.FieldCleared(wxcard.FieldAiInfo) {
  44979. fields = append(fields, wxcard.FieldAiInfo)
  44980. }
  44981. if m.FieldCleared(wxcard.FieldIntro) {
  44982. fields = append(fields, wxcard.FieldIntro)
  44983. }
  44984. return fields
  44985. }
  44986. // FieldCleared returns a boolean indicating if a field with the given name was
  44987. // cleared in this mutation.
  44988. func (m *WxCardMutation) FieldCleared(name string) bool {
  44989. _, ok := m.clearedFields[name]
  44990. return ok
  44991. }
  44992. // ClearField clears the value of the field with the given name. It returns an
  44993. // error if the field is not defined in the schema.
  44994. func (m *WxCardMutation) ClearField(name string) error {
  44995. switch name {
  44996. case wxcard.FieldDeletedAt:
  44997. m.ClearDeletedAt()
  44998. return nil
  44999. case wxcard.FieldUserID:
  45000. m.ClearUserID()
  45001. return nil
  45002. case wxcard.FieldWxUserID:
  45003. m.ClearWxUserID()
  45004. return nil
  45005. case wxcard.FieldEmail:
  45006. m.ClearEmail()
  45007. return nil
  45008. case wxcard.FieldAPIBase:
  45009. m.ClearAPIBase()
  45010. return nil
  45011. case wxcard.FieldAPIKey:
  45012. m.ClearAPIKey()
  45013. return nil
  45014. case wxcard.FieldAiInfo:
  45015. m.ClearAiInfo()
  45016. return nil
  45017. case wxcard.FieldIntro:
  45018. m.ClearIntro()
  45019. return nil
  45020. }
  45021. return fmt.Errorf("unknown WxCard nullable field %s", name)
  45022. }
  45023. // ResetField resets all changes in the mutation for the field with the given name.
  45024. // It returns an error if the field is not defined in the schema.
  45025. func (m *WxCardMutation) ResetField(name string) error {
  45026. switch name {
  45027. case wxcard.FieldCreatedAt:
  45028. m.ResetCreatedAt()
  45029. return nil
  45030. case wxcard.FieldUpdatedAt:
  45031. m.ResetUpdatedAt()
  45032. return nil
  45033. case wxcard.FieldDeletedAt:
  45034. m.ResetDeletedAt()
  45035. return nil
  45036. case wxcard.FieldUserID:
  45037. m.ResetUserID()
  45038. return nil
  45039. case wxcard.FieldWxUserID:
  45040. m.ResetWxUserID()
  45041. return nil
  45042. case wxcard.FieldAvatar:
  45043. m.ResetAvatar()
  45044. return nil
  45045. case wxcard.FieldLogo:
  45046. m.ResetLogo()
  45047. return nil
  45048. case wxcard.FieldName:
  45049. m.ResetName()
  45050. return nil
  45051. case wxcard.FieldCompany:
  45052. m.ResetCompany()
  45053. return nil
  45054. case wxcard.FieldAddress:
  45055. m.ResetAddress()
  45056. return nil
  45057. case wxcard.FieldPhone:
  45058. m.ResetPhone()
  45059. return nil
  45060. case wxcard.FieldOfficialAccount:
  45061. m.ResetOfficialAccount()
  45062. return nil
  45063. case wxcard.FieldWechatAccount:
  45064. m.ResetWechatAccount()
  45065. return nil
  45066. case wxcard.FieldEmail:
  45067. m.ResetEmail()
  45068. return nil
  45069. case wxcard.FieldAPIBase:
  45070. m.ResetAPIBase()
  45071. return nil
  45072. case wxcard.FieldAPIKey:
  45073. m.ResetAPIKey()
  45074. return nil
  45075. case wxcard.FieldAiInfo:
  45076. m.ResetAiInfo()
  45077. return nil
  45078. case wxcard.FieldIntro:
  45079. m.ResetIntro()
  45080. return nil
  45081. }
  45082. return fmt.Errorf("unknown WxCard field %s", name)
  45083. }
  45084. // AddedEdges returns all edge names that were set/added in this mutation.
  45085. func (m *WxCardMutation) AddedEdges() []string {
  45086. edges := make([]string, 0, 0)
  45087. return edges
  45088. }
  45089. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45090. // name in this mutation.
  45091. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  45092. return nil
  45093. }
  45094. // RemovedEdges returns all edge names that were removed in this mutation.
  45095. func (m *WxCardMutation) RemovedEdges() []string {
  45096. edges := make([]string, 0, 0)
  45097. return edges
  45098. }
  45099. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45100. // the given name in this mutation.
  45101. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  45102. return nil
  45103. }
  45104. // ClearedEdges returns all edge names that were cleared in this mutation.
  45105. func (m *WxCardMutation) ClearedEdges() []string {
  45106. edges := make([]string, 0, 0)
  45107. return edges
  45108. }
  45109. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45110. // was cleared in this mutation.
  45111. func (m *WxCardMutation) EdgeCleared(name string) bool {
  45112. return false
  45113. }
  45114. // ClearEdge clears the value of the edge with the given name. It returns an error
  45115. // if that edge is not defined in the schema.
  45116. func (m *WxCardMutation) ClearEdge(name string) error {
  45117. return fmt.Errorf("unknown WxCard unique edge %s", name)
  45118. }
  45119. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45120. // It returns an error if the edge is not defined in the schema.
  45121. func (m *WxCardMutation) ResetEdge(name string) error {
  45122. return fmt.Errorf("unknown WxCard edge %s", name)
  45123. }
  45124. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  45125. type WxCardUserMutation struct {
  45126. config
  45127. op Op
  45128. typ string
  45129. id *uint64
  45130. created_at *time.Time
  45131. updated_at *time.Time
  45132. deleted_at *time.Time
  45133. wxid *string
  45134. account *string
  45135. avatar *string
  45136. nickname *string
  45137. remark *string
  45138. phone *string
  45139. open_id *string
  45140. union_id *string
  45141. session_key *string
  45142. is_vip *int
  45143. addis_vip *int
  45144. clearedFields map[string]struct{}
  45145. done bool
  45146. oldValue func(context.Context) (*WxCardUser, error)
  45147. predicates []predicate.WxCardUser
  45148. }
  45149. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  45150. // wxcarduserOption allows management of the mutation configuration using functional options.
  45151. type wxcarduserOption func(*WxCardUserMutation)
  45152. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  45153. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  45154. m := &WxCardUserMutation{
  45155. config: c,
  45156. op: op,
  45157. typ: TypeWxCardUser,
  45158. clearedFields: make(map[string]struct{}),
  45159. }
  45160. for _, opt := range opts {
  45161. opt(m)
  45162. }
  45163. return m
  45164. }
  45165. // withWxCardUserID sets the ID field of the mutation.
  45166. func withWxCardUserID(id uint64) wxcarduserOption {
  45167. return func(m *WxCardUserMutation) {
  45168. var (
  45169. err error
  45170. once sync.Once
  45171. value *WxCardUser
  45172. )
  45173. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  45174. once.Do(func() {
  45175. if m.done {
  45176. err = errors.New("querying old values post mutation is not allowed")
  45177. } else {
  45178. value, err = m.Client().WxCardUser.Get(ctx, id)
  45179. }
  45180. })
  45181. return value, err
  45182. }
  45183. m.id = &id
  45184. }
  45185. }
  45186. // withWxCardUser sets the old WxCardUser of the mutation.
  45187. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  45188. return func(m *WxCardUserMutation) {
  45189. m.oldValue = func(context.Context) (*WxCardUser, error) {
  45190. return node, nil
  45191. }
  45192. m.id = &node.ID
  45193. }
  45194. }
  45195. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45196. // executed in a transaction (ent.Tx), a transactional client is returned.
  45197. func (m WxCardUserMutation) Client() *Client {
  45198. client := &Client{config: m.config}
  45199. client.init()
  45200. return client
  45201. }
  45202. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45203. // it returns an error otherwise.
  45204. func (m WxCardUserMutation) Tx() (*Tx, error) {
  45205. if _, ok := m.driver.(*txDriver); !ok {
  45206. return nil, errors.New("ent: mutation is not running in a transaction")
  45207. }
  45208. tx := &Tx{config: m.config}
  45209. tx.init()
  45210. return tx, nil
  45211. }
  45212. // SetID sets the value of the id field. Note that this
  45213. // operation is only accepted on creation of WxCardUser entities.
  45214. func (m *WxCardUserMutation) SetID(id uint64) {
  45215. m.id = &id
  45216. }
  45217. // ID returns the ID value in the mutation. Note that the ID is only available
  45218. // if it was provided to the builder or after it was returned from the database.
  45219. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  45220. if m.id == nil {
  45221. return
  45222. }
  45223. return *m.id, true
  45224. }
  45225. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45226. // That means, if the mutation is applied within a transaction with an isolation level such
  45227. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45228. // or updated by the mutation.
  45229. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  45230. switch {
  45231. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45232. id, exists := m.ID()
  45233. if exists {
  45234. return []uint64{id}, nil
  45235. }
  45236. fallthrough
  45237. case m.op.Is(OpUpdate | OpDelete):
  45238. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  45239. default:
  45240. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45241. }
  45242. }
  45243. // SetCreatedAt sets the "created_at" field.
  45244. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  45245. m.created_at = &t
  45246. }
  45247. // CreatedAt returns the value of the "created_at" field in the mutation.
  45248. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  45249. v := m.created_at
  45250. if v == nil {
  45251. return
  45252. }
  45253. return *v, true
  45254. }
  45255. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  45256. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45258. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45259. if !m.op.Is(OpUpdateOne) {
  45260. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45261. }
  45262. if m.id == nil || m.oldValue == nil {
  45263. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45264. }
  45265. oldValue, err := m.oldValue(ctx)
  45266. if err != nil {
  45267. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45268. }
  45269. return oldValue.CreatedAt, nil
  45270. }
  45271. // ResetCreatedAt resets all changes to the "created_at" field.
  45272. func (m *WxCardUserMutation) ResetCreatedAt() {
  45273. m.created_at = nil
  45274. }
  45275. // SetUpdatedAt sets the "updated_at" field.
  45276. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  45277. m.updated_at = &t
  45278. }
  45279. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45280. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  45281. v := m.updated_at
  45282. if v == nil {
  45283. return
  45284. }
  45285. return *v, true
  45286. }
  45287. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  45288. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45290. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45291. if !m.op.Is(OpUpdateOne) {
  45292. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45293. }
  45294. if m.id == nil || m.oldValue == nil {
  45295. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45296. }
  45297. oldValue, err := m.oldValue(ctx)
  45298. if err != nil {
  45299. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45300. }
  45301. return oldValue.UpdatedAt, nil
  45302. }
  45303. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45304. func (m *WxCardUserMutation) ResetUpdatedAt() {
  45305. m.updated_at = nil
  45306. }
  45307. // SetDeletedAt sets the "deleted_at" field.
  45308. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  45309. m.deleted_at = &t
  45310. }
  45311. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  45312. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  45313. v := m.deleted_at
  45314. if v == nil {
  45315. return
  45316. }
  45317. return *v, true
  45318. }
  45319. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  45320. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45322. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  45323. if !m.op.Is(OpUpdateOne) {
  45324. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  45325. }
  45326. if m.id == nil || m.oldValue == nil {
  45327. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  45328. }
  45329. oldValue, err := m.oldValue(ctx)
  45330. if err != nil {
  45331. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  45332. }
  45333. return oldValue.DeletedAt, nil
  45334. }
  45335. // ClearDeletedAt clears the value of the "deleted_at" field.
  45336. func (m *WxCardUserMutation) ClearDeletedAt() {
  45337. m.deleted_at = nil
  45338. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  45339. }
  45340. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  45341. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  45342. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  45343. return ok
  45344. }
  45345. // ResetDeletedAt resets all changes to the "deleted_at" field.
  45346. func (m *WxCardUserMutation) ResetDeletedAt() {
  45347. m.deleted_at = nil
  45348. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  45349. }
  45350. // SetWxid sets the "wxid" field.
  45351. func (m *WxCardUserMutation) SetWxid(s string) {
  45352. m.wxid = &s
  45353. }
  45354. // Wxid returns the value of the "wxid" field in the mutation.
  45355. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  45356. v := m.wxid
  45357. if v == nil {
  45358. return
  45359. }
  45360. return *v, true
  45361. }
  45362. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  45363. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45365. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  45366. if !m.op.Is(OpUpdateOne) {
  45367. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  45368. }
  45369. if m.id == nil || m.oldValue == nil {
  45370. return v, errors.New("OldWxid requires an ID field in the mutation")
  45371. }
  45372. oldValue, err := m.oldValue(ctx)
  45373. if err != nil {
  45374. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  45375. }
  45376. return oldValue.Wxid, nil
  45377. }
  45378. // ResetWxid resets all changes to the "wxid" field.
  45379. func (m *WxCardUserMutation) ResetWxid() {
  45380. m.wxid = nil
  45381. }
  45382. // SetAccount sets the "account" field.
  45383. func (m *WxCardUserMutation) SetAccount(s string) {
  45384. m.account = &s
  45385. }
  45386. // Account returns the value of the "account" field in the mutation.
  45387. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  45388. v := m.account
  45389. if v == nil {
  45390. return
  45391. }
  45392. return *v, true
  45393. }
  45394. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  45395. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45397. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  45398. if !m.op.Is(OpUpdateOne) {
  45399. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  45400. }
  45401. if m.id == nil || m.oldValue == nil {
  45402. return v, errors.New("OldAccount requires an ID field in the mutation")
  45403. }
  45404. oldValue, err := m.oldValue(ctx)
  45405. if err != nil {
  45406. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  45407. }
  45408. return oldValue.Account, nil
  45409. }
  45410. // ResetAccount resets all changes to the "account" field.
  45411. func (m *WxCardUserMutation) ResetAccount() {
  45412. m.account = nil
  45413. }
  45414. // SetAvatar sets the "avatar" field.
  45415. func (m *WxCardUserMutation) SetAvatar(s string) {
  45416. m.avatar = &s
  45417. }
  45418. // Avatar returns the value of the "avatar" field in the mutation.
  45419. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  45420. v := m.avatar
  45421. if v == nil {
  45422. return
  45423. }
  45424. return *v, true
  45425. }
  45426. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  45427. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45429. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45430. if !m.op.Is(OpUpdateOne) {
  45431. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45432. }
  45433. if m.id == nil || m.oldValue == nil {
  45434. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45435. }
  45436. oldValue, err := m.oldValue(ctx)
  45437. if err != nil {
  45438. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45439. }
  45440. return oldValue.Avatar, nil
  45441. }
  45442. // ResetAvatar resets all changes to the "avatar" field.
  45443. func (m *WxCardUserMutation) ResetAvatar() {
  45444. m.avatar = nil
  45445. }
  45446. // SetNickname sets the "nickname" field.
  45447. func (m *WxCardUserMutation) SetNickname(s string) {
  45448. m.nickname = &s
  45449. }
  45450. // Nickname returns the value of the "nickname" field in the mutation.
  45451. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  45452. v := m.nickname
  45453. if v == nil {
  45454. return
  45455. }
  45456. return *v, true
  45457. }
  45458. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  45459. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45461. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  45462. if !m.op.Is(OpUpdateOne) {
  45463. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45464. }
  45465. if m.id == nil || m.oldValue == nil {
  45466. return v, errors.New("OldNickname requires an ID field in the mutation")
  45467. }
  45468. oldValue, err := m.oldValue(ctx)
  45469. if err != nil {
  45470. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45471. }
  45472. return oldValue.Nickname, nil
  45473. }
  45474. // ResetNickname resets all changes to the "nickname" field.
  45475. func (m *WxCardUserMutation) ResetNickname() {
  45476. m.nickname = nil
  45477. }
  45478. // SetRemark sets the "remark" field.
  45479. func (m *WxCardUserMutation) SetRemark(s string) {
  45480. m.remark = &s
  45481. }
  45482. // Remark returns the value of the "remark" field in the mutation.
  45483. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  45484. v := m.remark
  45485. if v == nil {
  45486. return
  45487. }
  45488. return *v, true
  45489. }
  45490. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  45491. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45493. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  45494. if !m.op.Is(OpUpdateOne) {
  45495. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  45496. }
  45497. if m.id == nil || m.oldValue == nil {
  45498. return v, errors.New("OldRemark requires an ID field in the mutation")
  45499. }
  45500. oldValue, err := m.oldValue(ctx)
  45501. if err != nil {
  45502. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  45503. }
  45504. return oldValue.Remark, nil
  45505. }
  45506. // ResetRemark resets all changes to the "remark" field.
  45507. func (m *WxCardUserMutation) ResetRemark() {
  45508. m.remark = nil
  45509. }
  45510. // SetPhone sets the "phone" field.
  45511. func (m *WxCardUserMutation) SetPhone(s string) {
  45512. m.phone = &s
  45513. }
  45514. // Phone returns the value of the "phone" field in the mutation.
  45515. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  45516. v := m.phone
  45517. if v == nil {
  45518. return
  45519. }
  45520. return *v, true
  45521. }
  45522. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  45523. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45525. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  45526. if !m.op.Is(OpUpdateOne) {
  45527. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  45528. }
  45529. if m.id == nil || m.oldValue == nil {
  45530. return v, errors.New("OldPhone requires an ID field in the mutation")
  45531. }
  45532. oldValue, err := m.oldValue(ctx)
  45533. if err != nil {
  45534. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  45535. }
  45536. return oldValue.Phone, nil
  45537. }
  45538. // ResetPhone resets all changes to the "phone" field.
  45539. func (m *WxCardUserMutation) ResetPhone() {
  45540. m.phone = nil
  45541. }
  45542. // SetOpenID sets the "open_id" field.
  45543. func (m *WxCardUserMutation) SetOpenID(s string) {
  45544. m.open_id = &s
  45545. }
  45546. // OpenID returns the value of the "open_id" field in the mutation.
  45547. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  45548. v := m.open_id
  45549. if v == nil {
  45550. return
  45551. }
  45552. return *v, true
  45553. }
  45554. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  45555. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45557. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  45558. if !m.op.Is(OpUpdateOne) {
  45559. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  45560. }
  45561. if m.id == nil || m.oldValue == nil {
  45562. return v, errors.New("OldOpenID requires an ID field in the mutation")
  45563. }
  45564. oldValue, err := m.oldValue(ctx)
  45565. if err != nil {
  45566. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  45567. }
  45568. return oldValue.OpenID, nil
  45569. }
  45570. // ResetOpenID resets all changes to the "open_id" field.
  45571. func (m *WxCardUserMutation) ResetOpenID() {
  45572. m.open_id = nil
  45573. }
  45574. // SetUnionID sets the "union_id" field.
  45575. func (m *WxCardUserMutation) SetUnionID(s string) {
  45576. m.union_id = &s
  45577. }
  45578. // UnionID returns the value of the "union_id" field in the mutation.
  45579. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  45580. v := m.union_id
  45581. if v == nil {
  45582. return
  45583. }
  45584. return *v, true
  45585. }
  45586. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  45587. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45589. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  45590. if !m.op.Is(OpUpdateOne) {
  45591. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  45592. }
  45593. if m.id == nil || m.oldValue == nil {
  45594. return v, errors.New("OldUnionID requires an ID field in the mutation")
  45595. }
  45596. oldValue, err := m.oldValue(ctx)
  45597. if err != nil {
  45598. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  45599. }
  45600. return oldValue.UnionID, nil
  45601. }
  45602. // ResetUnionID resets all changes to the "union_id" field.
  45603. func (m *WxCardUserMutation) ResetUnionID() {
  45604. m.union_id = nil
  45605. }
  45606. // SetSessionKey sets the "session_key" field.
  45607. func (m *WxCardUserMutation) SetSessionKey(s string) {
  45608. m.session_key = &s
  45609. }
  45610. // SessionKey returns the value of the "session_key" field in the mutation.
  45611. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  45612. v := m.session_key
  45613. if v == nil {
  45614. return
  45615. }
  45616. return *v, true
  45617. }
  45618. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  45619. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45621. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  45622. if !m.op.Is(OpUpdateOne) {
  45623. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  45624. }
  45625. if m.id == nil || m.oldValue == nil {
  45626. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  45627. }
  45628. oldValue, err := m.oldValue(ctx)
  45629. if err != nil {
  45630. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  45631. }
  45632. return oldValue.SessionKey, nil
  45633. }
  45634. // ResetSessionKey resets all changes to the "session_key" field.
  45635. func (m *WxCardUserMutation) ResetSessionKey() {
  45636. m.session_key = nil
  45637. }
  45638. // SetIsVip sets the "is_vip" field.
  45639. func (m *WxCardUserMutation) SetIsVip(i int) {
  45640. m.is_vip = &i
  45641. m.addis_vip = nil
  45642. }
  45643. // IsVip returns the value of the "is_vip" field in the mutation.
  45644. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  45645. v := m.is_vip
  45646. if v == nil {
  45647. return
  45648. }
  45649. return *v, true
  45650. }
  45651. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  45652. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  45653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45654. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  45655. if !m.op.Is(OpUpdateOne) {
  45656. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  45657. }
  45658. if m.id == nil || m.oldValue == nil {
  45659. return v, errors.New("OldIsVip requires an ID field in the mutation")
  45660. }
  45661. oldValue, err := m.oldValue(ctx)
  45662. if err != nil {
  45663. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  45664. }
  45665. return oldValue.IsVip, nil
  45666. }
  45667. // AddIsVip adds i to the "is_vip" field.
  45668. func (m *WxCardUserMutation) AddIsVip(i int) {
  45669. if m.addis_vip != nil {
  45670. *m.addis_vip += i
  45671. } else {
  45672. m.addis_vip = &i
  45673. }
  45674. }
  45675. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  45676. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  45677. v := m.addis_vip
  45678. if v == nil {
  45679. return
  45680. }
  45681. return *v, true
  45682. }
  45683. // ResetIsVip resets all changes to the "is_vip" field.
  45684. func (m *WxCardUserMutation) ResetIsVip() {
  45685. m.is_vip = nil
  45686. m.addis_vip = nil
  45687. }
  45688. // Where appends a list predicates to the WxCardUserMutation builder.
  45689. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  45690. m.predicates = append(m.predicates, ps...)
  45691. }
  45692. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  45693. // users can use type-assertion to append predicates that do not depend on any generated package.
  45694. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  45695. p := make([]predicate.WxCardUser, len(ps))
  45696. for i := range ps {
  45697. p[i] = ps[i]
  45698. }
  45699. m.Where(p...)
  45700. }
  45701. // Op returns the operation name.
  45702. func (m *WxCardUserMutation) Op() Op {
  45703. return m.op
  45704. }
  45705. // SetOp allows setting the mutation operation.
  45706. func (m *WxCardUserMutation) SetOp(op Op) {
  45707. m.op = op
  45708. }
  45709. // Type returns the node type of this mutation (WxCardUser).
  45710. func (m *WxCardUserMutation) Type() string {
  45711. return m.typ
  45712. }
  45713. // Fields returns all fields that were changed during this mutation. Note that in
  45714. // order to get all numeric fields that were incremented/decremented, call
  45715. // AddedFields().
  45716. func (m *WxCardUserMutation) Fields() []string {
  45717. fields := make([]string, 0, 13)
  45718. if m.created_at != nil {
  45719. fields = append(fields, wxcarduser.FieldCreatedAt)
  45720. }
  45721. if m.updated_at != nil {
  45722. fields = append(fields, wxcarduser.FieldUpdatedAt)
  45723. }
  45724. if m.deleted_at != nil {
  45725. fields = append(fields, wxcarduser.FieldDeletedAt)
  45726. }
  45727. if m.wxid != nil {
  45728. fields = append(fields, wxcarduser.FieldWxid)
  45729. }
  45730. if m.account != nil {
  45731. fields = append(fields, wxcarduser.FieldAccount)
  45732. }
  45733. if m.avatar != nil {
  45734. fields = append(fields, wxcarduser.FieldAvatar)
  45735. }
  45736. if m.nickname != nil {
  45737. fields = append(fields, wxcarduser.FieldNickname)
  45738. }
  45739. if m.remark != nil {
  45740. fields = append(fields, wxcarduser.FieldRemark)
  45741. }
  45742. if m.phone != nil {
  45743. fields = append(fields, wxcarduser.FieldPhone)
  45744. }
  45745. if m.open_id != nil {
  45746. fields = append(fields, wxcarduser.FieldOpenID)
  45747. }
  45748. if m.union_id != nil {
  45749. fields = append(fields, wxcarduser.FieldUnionID)
  45750. }
  45751. if m.session_key != nil {
  45752. fields = append(fields, wxcarduser.FieldSessionKey)
  45753. }
  45754. if m.is_vip != nil {
  45755. fields = append(fields, wxcarduser.FieldIsVip)
  45756. }
  45757. return fields
  45758. }
  45759. // Field returns the value of a field with the given name. The second boolean
  45760. // return value indicates that this field was not set, or was not defined in the
  45761. // schema.
  45762. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  45763. switch name {
  45764. case wxcarduser.FieldCreatedAt:
  45765. return m.CreatedAt()
  45766. case wxcarduser.FieldUpdatedAt:
  45767. return m.UpdatedAt()
  45768. case wxcarduser.FieldDeletedAt:
  45769. return m.DeletedAt()
  45770. case wxcarduser.FieldWxid:
  45771. return m.Wxid()
  45772. case wxcarduser.FieldAccount:
  45773. return m.Account()
  45774. case wxcarduser.FieldAvatar:
  45775. return m.Avatar()
  45776. case wxcarduser.FieldNickname:
  45777. return m.Nickname()
  45778. case wxcarduser.FieldRemark:
  45779. return m.Remark()
  45780. case wxcarduser.FieldPhone:
  45781. return m.Phone()
  45782. case wxcarduser.FieldOpenID:
  45783. return m.OpenID()
  45784. case wxcarduser.FieldUnionID:
  45785. return m.UnionID()
  45786. case wxcarduser.FieldSessionKey:
  45787. return m.SessionKey()
  45788. case wxcarduser.FieldIsVip:
  45789. return m.IsVip()
  45790. }
  45791. return nil, false
  45792. }
  45793. // OldField returns the old value of the field from the database. An error is
  45794. // returned if the mutation operation is not UpdateOne, or the query to the
  45795. // database failed.
  45796. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45797. switch name {
  45798. case wxcarduser.FieldCreatedAt:
  45799. return m.OldCreatedAt(ctx)
  45800. case wxcarduser.FieldUpdatedAt:
  45801. return m.OldUpdatedAt(ctx)
  45802. case wxcarduser.FieldDeletedAt:
  45803. return m.OldDeletedAt(ctx)
  45804. case wxcarduser.FieldWxid:
  45805. return m.OldWxid(ctx)
  45806. case wxcarduser.FieldAccount:
  45807. return m.OldAccount(ctx)
  45808. case wxcarduser.FieldAvatar:
  45809. return m.OldAvatar(ctx)
  45810. case wxcarduser.FieldNickname:
  45811. return m.OldNickname(ctx)
  45812. case wxcarduser.FieldRemark:
  45813. return m.OldRemark(ctx)
  45814. case wxcarduser.FieldPhone:
  45815. return m.OldPhone(ctx)
  45816. case wxcarduser.FieldOpenID:
  45817. return m.OldOpenID(ctx)
  45818. case wxcarduser.FieldUnionID:
  45819. return m.OldUnionID(ctx)
  45820. case wxcarduser.FieldSessionKey:
  45821. return m.OldSessionKey(ctx)
  45822. case wxcarduser.FieldIsVip:
  45823. return m.OldIsVip(ctx)
  45824. }
  45825. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  45826. }
  45827. // SetField sets the value of a field with the given name. It returns an error if
  45828. // the field is not defined in the schema, or if the type mismatched the field
  45829. // type.
  45830. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  45831. switch name {
  45832. case wxcarduser.FieldCreatedAt:
  45833. v, ok := value.(time.Time)
  45834. if !ok {
  45835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45836. }
  45837. m.SetCreatedAt(v)
  45838. return nil
  45839. case wxcarduser.FieldUpdatedAt:
  45840. v, ok := value.(time.Time)
  45841. if !ok {
  45842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45843. }
  45844. m.SetUpdatedAt(v)
  45845. return nil
  45846. case wxcarduser.FieldDeletedAt:
  45847. v, ok := value.(time.Time)
  45848. if !ok {
  45849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45850. }
  45851. m.SetDeletedAt(v)
  45852. return nil
  45853. case wxcarduser.FieldWxid:
  45854. v, ok := value.(string)
  45855. if !ok {
  45856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45857. }
  45858. m.SetWxid(v)
  45859. return nil
  45860. case wxcarduser.FieldAccount:
  45861. v, ok := value.(string)
  45862. if !ok {
  45863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45864. }
  45865. m.SetAccount(v)
  45866. return nil
  45867. case wxcarduser.FieldAvatar:
  45868. v, ok := value.(string)
  45869. if !ok {
  45870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45871. }
  45872. m.SetAvatar(v)
  45873. return nil
  45874. case wxcarduser.FieldNickname:
  45875. v, ok := value.(string)
  45876. if !ok {
  45877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45878. }
  45879. m.SetNickname(v)
  45880. return nil
  45881. case wxcarduser.FieldRemark:
  45882. v, ok := value.(string)
  45883. if !ok {
  45884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45885. }
  45886. m.SetRemark(v)
  45887. return nil
  45888. case wxcarduser.FieldPhone:
  45889. v, ok := value.(string)
  45890. if !ok {
  45891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45892. }
  45893. m.SetPhone(v)
  45894. return nil
  45895. case wxcarduser.FieldOpenID:
  45896. v, ok := value.(string)
  45897. if !ok {
  45898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45899. }
  45900. m.SetOpenID(v)
  45901. return nil
  45902. case wxcarduser.FieldUnionID:
  45903. v, ok := value.(string)
  45904. if !ok {
  45905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45906. }
  45907. m.SetUnionID(v)
  45908. return nil
  45909. case wxcarduser.FieldSessionKey:
  45910. v, ok := value.(string)
  45911. if !ok {
  45912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45913. }
  45914. m.SetSessionKey(v)
  45915. return nil
  45916. case wxcarduser.FieldIsVip:
  45917. v, ok := value.(int)
  45918. if !ok {
  45919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45920. }
  45921. m.SetIsVip(v)
  45922. return nil
  45923. }
  45924. return fmt.Errorf("unknown WxCardUser field %s", name)
  45925. }
  45926. // AddedFields returns all numeric fields that were incremented/decremented during
  45927. // this mutation.
  45928. func (m *WxCardUserMutation) AddedFields() []string {
  45929. var fields []string
  45930. if m.addis_vip != nil {
  45931. fields = append(fields, wxcarduser.FieldIsVip)
  45932. }
  45933. return fields
  45934. }
  45935. // AddedField returns the numeric value that was incremented/decremented on a field
  45936. // with the given name. The second boolean return value indicates that this field
  45937. // was not set, or was not defined in the schema.
  45938. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  45939. switch name {
  45940. case wxcarduser.FieldIsVip:
  45941. return m.AddedIsVip()
  45942. }
  45943. return nil, false
  45944. }
  45945. // AddField adds the value to the field with the given name. It returns an error if
  45946. // the field is not defined in the schema, or if the type mismatched the field
  45947. // type.
  45948. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  45949. switch name {
  45950. case wxcarduser.FieldIsVip:
  45951. v, ok := value.(int)
  45952. if !ok {
  45953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45954. }
  45955. m.AddIsVip(v)
  45956. return nil
  45957. }
  45958. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  45959. }
  45960. // ClearedFields returns all nullable fields that were cleared during this
  45961. // mutation.
  45962. func (m *WxCardUserMutation) ClearedFields() []string {
  45963. var fields []string
  45964. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  45965. fields = append(fields, wxcarduser.FieldDeletedAt)
  45966. }
  45967. return fields
  45968. }
  45969. // FieldCleared returns a boolean indicating if a field with the given name was
  45970. // cleared in this mutation.
  45971. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  45972. _, ok := m.clearedFields[name]
  45973. return ok
  45974. }
  45975. // ClearField clears the value of the field with the given name. It returns an
  45976. // error if the field is not defined in the schema.
  45977. func (m *WxCardUserMutation) ClearField(name string) error {
  45978. switch name {
  45979. case wxcarduser.FieldDeletedAt:
  45980. m.ClearDeletedAt()
  45981. return nil
  45982. }
  45983. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  45984. }
  45985. // ResetField resets all changes in the mutation for the field with the given name.
  45986. // It returns an error if the field is not defined in the schema.
  45987. func (m *WxCardUserMutation) ResetField(name string) error {
  45988. switch name {
  45989. case wxcarduser.FieldCreatedAt:
  45990. m.ResetCreatedAt()
  45991. return nil
  45992. case wxcarduser.FieldUpdatedAt:
  45993. m.ResetUpdatedAt()
  45994. return nil
  45995. case wxcarduser.FieldDeletedAt:
  45996. m.ResetDeletedAt()
  45997. return nil
  45998. case wxcarduser.FieldWxid:
  45999. m.ResetWxid()
  46000. return nil
  46001. case wxcarduser.FieldAccount:
  46002. m.ResetAccount()
  46003. return nil
  46004. case wxcarduser.FieldAvatar:
  46005. m.ResetAvatar()
  46006. return nil
  46007. case wxcarduser.FieldNickname:
  46008. m.ResetNickname()
  46009. return nil
  46010. case wxcarduser.FieldRemark:
  46011. m.ResetRemark()
  46012. return nil
  46013. case wxcarduser.FieldPhone:
  46014. m.ResetPhone()
  46015. return nil
  46016. case wxcarduser.FieldOpenID:
  46017. m.ResetOpenID()
  46018. return nil
  46019. case wxcarduser.FieldUnionID:
  46020. m.ResetUnionID()
  46021. return nil
  46022. case wxcarduser.FieldSessionKey:
  46023. m.ResetSessionKey()
  46024. return nil
  46025. case wxcarduser.FieldIsVip:
  46026. m.ResetIsVip()
  46027. return nil
  46028. }
  46029. return fmt.Errorf("unknown WxCardUser field %s", name)
  46030. }
  46031. // AddedEdges returns all edge names that were set/added in this mutation.
  46032. func (m *WxCardUserMutation) AddedEdges() []string {
  46033. edges := make([]string, 0, 0)
  46034. return edges
  46035. }
  46036. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46037. // name in this mutation.
  46038. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  46039. return nil
  46040. }
  46041. // RemovedEdges returns all edge names that were removed in this mutation.
  46042. func (m *WxCardUserMutation) RemovedEdges() []string {
  46043. edges := make([]string, 0, 0)
  46044. return edges
  46045. }
  46046. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46047. // the given name in this mutation.
  46048. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  46049. return nil
  46050. }
  46051. // ClearedEdges returns all edge names that were cleared in this mutation.
  46052. func (m *WxCardUserMutation) ClearedEdges() []string {
  46053. edges := make([]string, 0, 0)
  46054. return edges
  46055. }
  46056. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46057. // was cleared in this mutation.
  46058. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  46059. return false
  46060. }
  46061. // ClearEdge clears the value of the edge with the given name. It returns an error
  46062. // if that edge is not defined in the schema.
  46063. func (m *WxCardUserMutation) ClearEdge(name string) error {
  46064. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  46065. }
  46066. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46067. // It returns an error if the edge is not defined in the schema.
  46068. func (m *WxCardUserMutation) ResetEdge(name string) error {
  46069. return fmt.Errorf("unknown WxCardUser edge %s", name)
  46070. }
  46071. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  46072. type WxCardVisitMutation struct {
  46073. config
  46074. op Op
  46075. typ string
  46076. id *uint64
  46077. created_at *time.Time
  46078. updated_at *time.Time
  46079. deleted_at *time.Time
  46080. user_id *uint64
  46081. adduser_id *int64
  46082. bot_id *uint64
  46083. addbot_id *int64
  46084. bot_type *uint8
  46085. addbot_type *int8
  46086. clearedFields map[string]struct{}
  46087. done bool
  46088. oldValue func(context.Context) (*WxCardVisit, error)
  46089. predicates []predicate.WxCardVisit
  46090. }
  46091. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  46092. // wxcardvisitOption allows management of the mutation configuration using functional options.
  46093. type wxcardvisitOption func(*WxCardVisitMutation)
  46094. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  46095. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  46096. m := &WxCardVisitMutation{
  46097. config: c,
  46098. op: op,
  46099. typ: TypeWxCardVisit,
  46100. clearedFields: make(map[string]struct{}),
  46101. }
  46102. for _, opt := range opts {
  46103. opt(m)
  46104. }
  46105. return m
  46106. }
  46107. // withWxCardVisitID sets the ID field of the mutation.
  46108. func withWxCardVisitID(id uint64) wxcardvisitOption {
  46109. return func(m *WxCardVisitMutation) {
  46110. var (
  46111. err error
  46112. once sync.Once
  46113. value *WxCardVisit
  46114. )
  46115. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  46116. once.Do(func() {
  46117. if m.done {
  46118. err = errors.New("querying old values post mutation is not allowed")
  46119. } else {
  46120. value, err = m.Client().WxCardVisit.Get(ctx, id)
  46121. }
  46122. })
  46123. return value, err
  46124. }
  46125. m.id = &id
  46126. }
  46127. }
  46128. // withWxCardVisit sets the old WxCardVisit of the mutation.
  46129. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  46130. return func(m *WxCardVisitMutation) {
  46131. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  46132. return node, nil
  46133. }
  46134. m.id = &node.ID
  46135. }
  46136. }
  46137. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46138. // executed in a transaction (ent.Tx), a transactional client is returned.
  46139. func (m WxCardVisitMutation) Client() *Client {
  46140. client := &Client{config: m.config}
  46141. client.init()
  46142. return client
  46143. }
  46144. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46145. // it returns an error otherwise.
  46146. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  46147. if _, ok := m.driver.(*txDriver); !ok {
  46148. return nil, errors.New("ent: mutation is not running in a transaction")
  46149. }
  46150. tx := &Tx{config: m.config}
  46151. tx.init()
  46152. return tx, nil
  46153. }
  46154. // SetID sets the value of the id field. Note that this
  46155. // operation is only accepted on creation of WxCardVisit entities.
  46156. func (m *WxCardVisitMutation) SetID(id uint64) {
  46157. m.id = &id
  46158. }
  46159. // ID returns the ID value in the mutation. Note that the ID is only available
  46160. // if it was provided to the builder or after it was returned from the database.
  46161. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  46162. if m.id == nil {
  46163. return
  46164. }
  46165. return *m.id, true
  46166. }
  46167. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46168. // That means, if the mutation is applied within a transaction with an isolation level such
  46169. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46170. // or updated by the mutation.
  46171. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  46172. switch {
  46173. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46174. id, exists := m.ID()
  46175. if exists {
  46176. return []uint64{id}, nil
  46177. }
  46178. fallthrough
  46179. case m.op.Is(OpUpdate | OpDelete):
  46180. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  46181. default:
  46182. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46183. }
  46184. }
  46185. // SetCreatedAt sets the "created_at" field.
  46186. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  46187. m.created_at = &t
  46188. }
  46189. // CreatedAt returns the value of the "created_at" field in the mutation.
  46190. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  46191. v := m.created_at
  46192. if v == nil {
  46193. return
  46194. }
  46195. return *v, true
  46196. }
  46197. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  46198. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46200. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46201. if !m.op.Is(OpUpdateOne) {
  46202. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46203. }
  46204. if m.id == nil || m.oldValue == nil {
  46205. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46206. }
  46207. oldValue, err := m.oldValue(ctx)
  46208. if err != nil {
  46209. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46210. }
  46211. return oldValue.CreatedAt, nil
  46212. }
  46213. // ResetCreatedAt resets all changes to the "created_at" field.
  46214. func (m *WxCardVisitMutation) ResetCreatedAt() {
  46215. m.created_at = nil
  46216. }
  46217. // SetUpdatedAt sets the "updated_at" field.
  46218. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  46219. m.updated_at = &t
  46220. }
  46221. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46222. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  46223. v := m.updated_at
  46224. if v == nil {
  46225. return
  46226. }
  46227. return *v, true
  46228. }
  46229. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  46230. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46232. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46233. if !m.op.Is(OpUpdateOne) {
  46234. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46235. }
  46236. if m.id == nil || m.oldValue == nil {
  46237. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46238. }
  46239. oldValue, err := m.oldValue(ctx)
  46240. if err != nil {
  46241. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46242. }
  46243. return oldValue.UpdatedAt, nil
  46244. }
  46245. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46246. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  46247. m.updated_at = nil
  46248. }
  46249. // SetDeletedAt sets the "deleted_at" field.
  46250. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  46251. m.deleted_at = &t
  46252. }
  46253. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  46254. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  46255. v := m.deleted_at
  46256. if v == nil {
  46257. return
  46258. }
  46259. return *v, true
  46260. }
  46261. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  46262. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46264. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  46265. if !m.op.Is(OpUpdateOne) {
  46266. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  46267. }
  46268. if m.id == nil || m.oldValue == nil {
  46269. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  46270. }
  46271. oldValue, err := m.oldValue(ctx)
  46272. if err != nil {
  46273. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  46274. }
  46275. return oldValue.DeletedAt, nil
  46276. }
  46277. // ClearDeletedAt clears the value of the "deleted_at" field.
  46278. func (m *WxCardVisitMutation) ClearDeletedAt() {
  46279. m.deleted_at = nil
  46280. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  46281. }
  46282. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  46283. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  46284. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  46285. return ok
  46286. }
  46287. // ResetDeletedAt resets all changes to the "deleted_at" field.
  46288. func (m *WxCardVisitMutation) ResetDeletedAt() {
  46289. m.deleted_at = nil
  46290. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  46291. }
  46292. // SetUserID sets the "user_id" field.
  46293. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  46294. m.user_id = &u
  46295. m.adduser_id = nil
  46296. }
  46297. // UserID returns the value of the "user_id" field in the mutation.
  46298. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  46299. v := m.user_id
  46300. if v == nil {
  46301. return
  46302. }
  46303. return *v, true
  46304. }
  46305. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  46306. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46308. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  46309. if !m.op.Is(OpUpdateOne) {
  46310. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  46311. }
  46312. if m.id == nil || m.oldValue == nil {
  46313. return v, errors.New("OldUserID requires an ID field in the mutation")
  46314. }
  46315. oldValue, err := m.oldValue(ctx)
  46316. if err != nil {
  46317. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  46318. }
  46319. return oldValue.UserID, nil
  46320. }
  46321. // AddUserID adds u to the "user_id" field.
  46322. func (m *WxCardVisitMutation) AddUserID(u int64) {
  46323. if m.adduser_id != nil {
  46324. *m.adduser_id += u
  46325. } else {
  46326. m.adduser_id = &u
  46327. }
  46328. }
  46329. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  46330. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  46331. v := m.adduser_id
  46332. if v == nil {
  46333. return
  46334. }
  46335. return *v, true
  46336. }
  46337. // ClearUserID clears the value of the "user_id" field.
  46338. func (m *WxCardVisitMutation) ClearUserID() {
  46339. m.user_id = nil
  46340. m.adduser_id = nil
  46341. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  46342. }
  46343. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  46344. func (m *WxCardVisitMutation) UserIDCleared() bool {
  46345. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  46346. return ok
  46347. }
  46348. // ResetUserID resets all changes to the "user_id" field.
  46349. func (m *WxCardVisitMutation) ResetUserID() {
  46350. m.user_id = nil
  46351. m.adduser_id = nil
  46352. delete(m.clearedFields, wxcardvisit.FieldUserID)
  46353. }
  46354. // SetBotID sets the "bot_id" field.
  46355. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  46356. m.bot_id = &u
  46357. m.addbot_id = nil
  46358. }
  46359. // BotID returns the value of the "bot_id" field in the mutation.
  46360. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  46361. v := m.bot_id
  46362. if v == nil {
  46363. return
  46364. }
  46365. return *v, true
  46366. }
  46367. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  46368. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46370. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  46371. if !m.op.Is(OpUpdateOne) {
  46372. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  46373. }
  46374. if m.id == nil || m.oldValue == nil {
  46375. return v, errors.New("OldBotID requires an ID field in the mutation")
  46376. }
  46377. oldValue, err := m.oldValue(ctx)
  46378. if err != nil {
  46379. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  46380. }
  46381. return oldValue.BotID, nil
  46382. }
  46383. // AddBotID adds u to the "bot_id" field.
  46384. func (m *WxCardVisitMutation) AddBotID(u int64) {
  46385. if m.addbot_id != nil {
  46386. *m.addbot_id += u
  46387. } else {
  46388. m.addbot_id = &u
  46389. }
  46390. }
  46391. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  46392. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  46393. v := m.addbot_id
  46394. if v == nil {
  46395. return
  46396. }
  46397. return *v, true
  46398. }
  46399. // ResetBotID resets all changes to the "bot_id" field.
  46400. func (m *WxCardVisitMutation) ResetBotID() {
  46401. m.bot_id = nil
  46402. m.addbot_id = nil
  46403. }
  46404. // SetBotType sets the "bot_type" field.
  46405. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  46406. m.bot_type = &u
  46407. m.addbot_type = nil
  46408. }
  46409. // BotType returns the value of the "bot_type" field in the mutation.
  46410. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  46411. v := m.bot_type
  46412. if v == nil {
  46413. return
  46414. }
  46415. return *v, true
  46416. }
  46417. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  46418. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  46419. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46420. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  46421. if !m.op.Is(OpUpdateOne) {
  46422. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  46423. }
  46424. if m.id == nil || m.oldValue == nil {
  46425. return v, errors.New("OldBotType requires an ID field in the mutation")
  46426. }
  46427. oldValue, err := m.oldValue(ctx)
  46428. if err != nil {
  46429. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  46430. }
  46431. return oldValue.BotType, nil
  46432. }
  46433. // AddBotType adds u to the "bot_type" field.
  46434. func (m *WxCardVisitMutation) AddBotType(u int8) {
  46435. if m.addbot_type != nil {
  46436. *m.addbot_type += u
  46437. } else {
  46438. m.addbot_type = &u
  46439. }
  46440. }
  46441. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  46442. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  46443. v := m.addbot_type
  46444. if v == nil {
  46445. return
  46446. }
  46447. return *v, true
  46448. }
  46449. // ResetBotType resets all changes to the "bot_type" field.
  46450. func (m *WxCardVisitMutation) ResetBotType() {
  46451. m.bot_type = nil
  46452. m.addbot_type = nil
  46453. }
  46454. // Where appends a list predicates to the WxCardVisitMutation builder.
  46455. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  46456. m.predicates = append(m.predicates, ps...)
  46457. }
  46458. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  46459. // users can use type-assertion to append predicates that do not depend on any generated package.
  46460. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  46461. p := make([]predicate.WxCardVisit, len(ps))
  46462. for i := range ps {
  46463. p[i] = ps[i]
  46464. }
  46465. m.Where(p...)
  46466. }
  46467. // Op returns the operation name.
  46468. func (m *WxCardVisitMutation) Op() Op {
  46469. return m.op
  46470. }
  46471. // SetOp allows setting the mutation operation.
  46472. func (m *WxCardVisitMutation) SetOp(op Op) {
  46473. m.op = op
  46474. }
  46475. // Type returns the node type of this mutation (WxCardVisit).
  46476. func (m *WxCardVisitMutation) Type() string {
  46477. return m.typ
  46478. }
  46479. // Fields returns all fields that were changed during this mutation. Note that in
  46480. // order to get all numeric fields that were incremented/decremented, call
  46481. // AddedFields().
  46482. func (m *WxCardVisitMutation) Fields() []string {
  46483. fields := make([]string, 0, 6)
  46484. if m.created_at != nil {
  46485. fields = append(fields, wxcardvisit.FieldCreatedAt)
  46486. }
  46487. if m.updated_at != nil {
  46488. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  46489. }
  46490. if m.deleted_at != nil {
  46491. fields = append(fields, wxcardvisit.FieldDeletedAt)
  46492. }
  46493. if m.user_id != nil {
  46494. fields = append(fields, wxcardvisit.FieldUserID)
  46495. }
  46496. if m.bot_id != nil {
  46497. fields = append(fields, wxcardvisit.FieldBotID)
  46498. }
  46499. if m.bot_type != nil {
  46500. fields = append(fields, wxcardvisit.FieldBotType)
  46501. }
  46502. return fields
  46503. }
  46504. // Field returns the value of a field with the given name. The second boolean
  46505. // return value indicates that this field was not set, or was not defined in the
  46506. // schema.
  46507. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  46508. switch name {
  46509. case wxcardvisit.FieldCreatedAt:
  46510. return m.CreatedAt()
  46511. case wxcardvisit.FieldUpdatedAt:
  46512. return m.UpdatedAt()
  46513. case wxcardvisit.FieldDeletedAt:
  46514. return m.DeletedAt()
  46515. case wxcardvisit.FieldUserID:
  46516. return m.UserID()
  46517. case wxcardvisit.FieldBotID:
  46518. return m.BotID()
  46519. case wxcardvisit.FieldBotType:
  46520. return m.BotType()
  46521. }
  46522. return nil, false
  46523. }
  46524. // OldField returns the old value of the field from the database. An error is
  46525. // returned if the mutation operation is not UpdateOne, or the query to the
  46526. // database failed.
  46527. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46528. switch name {
  46529. case wxcardvisit.FieldCreatedAt:
  46530. return m.OldCreatedAt(ctx)
  46531. case wxcardvisit.FieldUpdatedAt:
  46532. return m.OldUpdatedAt(ctx)
  46533. case wxcardvisit.FieldDeletedAt:
  46534. return m.OldDeletedAt(ctx)
  46535. case wxcardvisit.FieldUserID:
  46536. return m.OldUserID(ctx)
  46537. case wxcardvisit.FieldBotID:
  46538. return m.OldBotID(ctx)
  46539. case wxcardvisit.FieldBotType:
  46540. return m.OldBotType(ctx)
  46541. }
  46542. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  46543. }
  46544. // SetField sets the value of a field with the given name. It returns an error if
  46545. // the field is not defined in the schema, or if the type mismatched the field
  46546. // type.
  46547. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  46548. switch name {
  46549. case wxcardvisit.FieldCreatedAt:
  46550. v, ok := value.(time.Time)
  46551. if !ok {
  46552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46553. }
  46554. m.SetCreatedAt(v)
  46555. return nil
  46556. case wxcardvisit.FieldUpdatedAt:
  46557. v, ok := value.(time.Time)
  46558. if !ok {
  46559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46560. }
  46561. m.SetUpdatedAt(v)
  46562. return nil
  46563. case wxcardvisit.FieldDeletedAt:
  46564. v, ok := value.(time.Time)
  46565. if !ok {
  46566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46567. }
  46568. m.SetDeletedAt(v)
  46569. return nil
  46570. case wxcardvisit.FieldUserID:
  46571. v, ok := value.(uint64)
  46572. if !ok {
  46573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46574. }
  46575. m.SetUserID(v)
  46576. return nil
  46577. case wxcardvisit.FieldBotID:
  46578. v, ok := value.(uint64)
  46579. if !ok {
  46580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46581. }
  46582. m.SetBotID(v)
  46583. return nil
  46584. case wxcardvisit.FieldBotType:
  46585. v, ok := value.(uint8)
  46586. if !ok {
  46587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46588. }
  46589. m.SetBotType(v)
  46590. return nil
  46591. }
  46592. return fmt.Errorf("unknown WxCardVisit field %s", name)
  46593. }
  46594. // AddedFields returns all numeric fields that were incremented/decremented during
  46595. // this mutation.
  46596. func (m *WxCardVisitMutation) AddedFields() []string {
  46597. var fields []string
  46598. if m.adduser_id != nil {
  46599. fields = append(fields, wxcardvisit.FieldUserID)
  46600. }
  46601. if m.addbot_id != nil {
  46602. fields = append(fields, wxcardvisit.FieldBotID)
  46603. }
  46604. if m.addbot_type != nil {
  46605. fields = append(fields, wxcardvisit.FieldBotType)
  46606. }
  46607. return fields
  46608. }
  46609. // AddedField returns the numeric value that was incremented/decremented on a field
  46610. // with the given name. The second boolean return value indicates that this field
  46611. // was not set, or was not defined in the schema.
  46612. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  46613. switch name {
  46614. case wxcardvisit.FieldUserID:
  46615. return m.AddedUserID()
  46616. case wxcardvisit.FieldBotID:
  46617. return m.AddedBotID()
  46618. case wxcardvisit.FieldBotType:
  46619. return m.AddedBotType()
  46620. }
  46621. return nil, false
  46622. }
  46623. // AddField adds the value to the field with the given name. It returns an error if
  46624. // the field is not defined in the schema, or if the type mismatched the field
  46625. // type.
  46626. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  46627. switch name {
  46628. case wxcardvisit.FieldUserID:
  46629. v, ok := value.(int64)
  46630. if !ok {
  46631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46632. }
  46633. m.AddUserID(v)
  46634. return nil
  46635. case wxcardvisit.FieldBotID:
  46636. v, ok := value.(int64)
  46637. if !ok {
  46638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46639. }
  46640. m.AddBotID(v)
  46641. return nil
  46642. case wxcardvisit.FieldBotType:
  46643. v, ok := value.(int8)
  46644. if !ok {
  46645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46646. }
  46647. m.AddBotType(v)
  46648. return nil
  46649. }
  46650. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  46651. }
  46652. // ClearedFields returns all nullable fields that were cleared during this
  46653. // mutation.
  46654. func (m *WxCardVisitMutation) ClearedFields() []string {
  46655. var fields []string
  46656. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  46657. fields = append(fields, wxcardvisit.FieldDeletedAt)
  46658. }
  46659. if m.FieldCleared(wxcardvisit.FieldUserID) {
  46660. fields = append(fields, wxcardvisit.FieldUserID)
  46661. }
  46662. return fields
  46663. }
  46664. // FieldCleared returns a boolean indicating if a field with the given name was
  46665. // cleared in this mutation.
  46666. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  46667. _, ok := m.clearedFields[name]
  46668. return ok
  46669. }
  46670. // ClearField clears the value of the field with the given name. It returns an
  46671. // error if the field is not defined in the schema.
  46672. func (m *WxCardVisitMutation) ClearField(name string) error {
  46673. switch name {
  46674. case wxcardvisit.FieldDeletedAt:
  46675. m.ClearDeletedAt()
  46676. return nil
  46677. case wxcardvisit.FieldUserID:
  46678. m.ClearUserID()
  46679. return nil
  46680. }
  46681. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  46682. }
  46683. // ResetField resets all changes in the mutation for the field with the given name.
  46684. // It returns an error if the field is not defined in the schema.
  46685. func (m *WxCardVisitMutation) ResetField(name string) error {
  46686. switch name {
  46687. case wxcardvisit.FieldCreatedAt:
  46688. m.ResetCreatedAt()
  46689. return nil
  46690. case wxcardvisit.FieldUpdatedAt:
  46691. m.ResetUpdatedAt()
  46692. return nil
  46693. case wxcardvisit.FieldDeletedAt:
  46694. m.ResetDeletedAt()
  46695. return nil
  46696. case wxcardvisit.FieldUserID:
  46697. m.ResetUserID()
  46698. return nil
  46699. case wxcardvisit.FieldBotID:
  46700. m.ResetBotID()
  46701. return nil
  46702. case wxcardvisit.FieldBotType:
  46703. m.ResetBotType()
  46704. return nil
  46705. }
  46706. return fmt.Errorf("unknown WxCardVisit field %s", name)
  46707. }
  46708. // AddedEdges returns all edge names that were set/added in this mutation.
  46709. func (m *WxCardVisitMutation) AddedEdges() []string {
  46710. edges := make([]string, 0, 0)
  46711. return edges
  46712. }
  46713. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46714. // name in this mutation.
  46715. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  46716. return nil
  46717. }
  46718. // RemovedEdges returns all edge names that were removed in this mutation.
  46719. func (m *WxCardVisitMutation) RemovedEdges() []string {
  46720. edges := make([]string, 0, 0)
  46721. return edges
  46722. }
  46723. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46724. // the given name in this mutation.
  46725. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  46726. return nil
  46727. }
  46728. // ClearedEdges returns all edge names that were cleared in this mutation.
  46729. func (m *WxCardVisitMutation) ClearedEdges() []string {
  46730. edges := make([]string, 0, 0)
  46731. return edges
  46732. }
  46733. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46734. // was cleared in this mutation.
  46735. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  46736. return false
  46737. }
  46738. // ClearEdge clears the value of the edge with the given name. It returns an error
  46739. // if that edge is not defined in the schema.
  46740. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  46741. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  46742. }
  46743. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46744. // It returns an error if the edge is not defined in the schema.
  46745. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  46746. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  46747. }