mutation.go 1.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467
  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/addwechatfriendlog"
  10. "wechat-api/ent/agent"
  11. "wechat-api/ent/agentbase"
  12. "wechat-api/ent/aliyunavatar"
  13. "wechat-api/ent/allocagent"
  14. "wechat-api/ent/apikey"
  15. "wechat-api/ent/batchmsg"
  16. "wechat-api/ent/category"
  17. "wechat-api/ent/chatrecords"
  18. "wechat-api/ent/chatsession"
  19. "wechat-api/ent/compapiasynctask"
  20. "wechat-api/ent/contact"
  21. "wechat-api/ent/contactfield"
  22. "wechat-api/ent/contactfieldtemplate"
  23. "wechat-api/ent/creditbalance"
  24. "wechat-api/ent/creditusage"
  25. "wechat-api/ent/custom_types"
  26. "wechat-api/ent/employee"
  27. "wechat-api/ent/employeeconfig"
  28. "wechat-api/ent/label"
  29. "wechat-api/ent/labellog"
  30. "wechat-api/ent/labelrelationship"
  31. "wechat-api/ent/labeltagging"
  32. "wechat-api/ent/message"
  33. "wechat-api/ent/messagerecords"
  34. "wechat-api/ent/msg"
  35. "wechat-api/ent/payrecharge"
  36. "wechat-api/ent/predicate"
  37. "wechat-api/ent/server"
  38. "wechat-api/ent/sopnode"
  39. "wechat-api/ent/sopstage"
  40. "wechat-api/ent/soptask"
  41. "wechat-api/ent/token"
  42. "wechat-api/ent/tutorial"
  43. "wechat-api/ent/usagedetail"
  44. "wechat-api/ent/usagestatisticday"
  45. "wechat-api/ent/usagestatistichour"
  46. "wechat-api/ent/usagestatisticmonth"
  47. "wechat-api/ent/usagetotal"
  48. "wechat-api/ent/whatsapp"
  49. "wechat-api/ent/whatsappchannel"
  50. "wechat-api/ent/workexperience"
  51. "wechat-api/ent/wpchatroom"
  52. "wechat-api/ent/wpchatroommember"
  53. "wechat-api/ent/wx"
  54. "wechat-api/ent/wxcard"
  55. "wechat-api/ent/wxcarduser"
  56. "wechat-api/ent/wxcardvisit"
  57. "wechat-api/ent/xunji"
  58. "wechat-api/ent/xunjiservice"
  59. "entgo.io/ent"
  60. "entgo.io/ent/dialect/sql"
  61. )
  62. const (
  63. // Operation types.
  64. OpCreate = ent.OpCreate
  65. OpDelete = ent.OpDelete
  66. OpDeleteOne = ent.OpDeleteOne
  67. OpUpdate = ent.OpUpdate
  68. OpUpdateOne = ent.OpUpdateOne
  69. // Node types.
  70. TypeAddWechatFriendLog = "AddWechatFriendLog"
  71. TypeAgent = "Agent"
  72. TypeAgentBase = "AgentBase"
  73. TypeAliyunAvatar = "AliyunAvatar"
  74. TypeAllocAgent = "AllocAgent"
  75. TypeApiKey = "ApiKey"
  76. TypeBatchMsg = "BatchMsg"
  77. TypeCategory = "Category"
  78. TypeChatRecords = "ChatRecords"
  79. TypeChatSession = "ChatSession"
  80. TypeCompapiAsynctask = "CompapiAsynctask"
  81. TypeContact = "Contact"
  82. TypeContactField = "ContactField"
  83. TypeContactFieldTemplate = "ContactFieldTemplate"
  84. TypeCreditBalance = "CreditBalance"
  85. TypeCreditUsage = "CreditUsage"
  86. TypeEmployee = "Employee"
  87. TypeEmployeeConfig = "EmployeeConfig"
  88. TypeLabel = "Label"
  89. TypeLabelLog = "LabelLog"
  90. TypeLabelRelationship = "LabelRelationship"
  91. TypeLabelTagging = "LabelTagging"
  92. TypeMessage = "Message"
  93. TypeMessageRecords = "MessageRecords"
  94. TypeMsg = "Msg"
  95. TypePayRecharge = "PayRecharge"
  96. TypeServer = "Server"
  97. TypeSopNode = "SopNode"
  98. TypeSopStage = "SopStage"
  99. TypeSopTask = "SopTask"
  100. TypeToken = "Token"
  101. TypeTutorial = "Tutorial"
  102. TypeUsageDetail = "UsageDetail"
  103. TypeUsageStatisticDay = "UsageStatisticDay"
  104. TypeUsageStatisticHour = "UsageStatisticHour"
  105. TypeUsageStatisticMonth = "UsageStatisticMonth"
  106. TypeUsageTotal = "UsageTotal"
  107. TypeWhatsapp = "Whatsapp"
  108. TypeWhatsappChannel = "WhatsappChannel"
  109. TypeWorkExperience = "WorkExperience"
  110. TypeWpChatroom = "WpChatroom"
  111. TypeWpChatroomMember = "WpChatroomMember"
  112. TypeWx = "Wx"
  113. TypeWxCard = "WxCard"
  114. TypeWxCardUser = "WxCardUser"
  115. TypeWxCardVisit = "WxCardVisit"
  116. TypeXunji = "Xunji"
  117. TypeXunjiService = "XunjiService"
  118. )
  119. // AddWechatFriendLogMutation represents an operation that mutates the AddWechatFriendLog nodes in the graph.
  120. type AddWechatFriendLogMutation struct {
  121. config
  122. op Op
  123. typ string
  124. id *int64
  125. owner_wx_id *string
  126. owner_wx_type *int
  127. addowner_wx_type *int
  128. find_content *string
  129. message *string
  130. find_request *map[string]interface{}
  131. find_result *map[string]interface{}
  132. is_can_add *int
  133. addis_can_add *int
  134. task_count *int
  135. addtask_count *int
  136. task_id *int64
  137. addtask_id *int64
  138. add_request *map[string]interface{}
  139. add_result *map[string]interface{}
  140. created_at *int64
  141. addcreated_at *int64
  142. updated_at *int64
  143. addupdated_at *int64
  144. clearedFields map[string]struct{}
  145. done bool
  146. oldValue func(context.Context) (*AddWechatFriendLog, error)
  147. predicates []predicate.AddWechatFriendLog
  148. }
  149. var _ ent.Mutation = (*AddWechatFriendLogMutation)(nil)
  150. // addwechatfriendlogOption allows management of the mutation configuration using functional options.
  151. type addwechatfriendlogOption func(*AddWechatFriendLogMutation)
  152. // newAddWechatFriendLogMutation creates new mutation for the AddWechatFriendLog entity.
  153. func newAddWechatFriendLogMutation(c config, op Op, opts ...addwechatfriendlogOption) *AddWechatFriendLogMutation {
  154. m := &AddWechatFriendLogMutation{
  155. config: c,
  156. op: op,
  157. typ: TypeAddWechatFriendLog,
  158. clearedFields: make(map[string]struct{}),
  159. }
  160. for _, opt := range opts {
  161. opt(m)
  162. }
  163. return m
  164. }
  165. // withAddWechatFriendLogID sets the ID field of the mutation.
  166. func withAddWechatFriendLogID(id int64) addwechatfriendlogOption {
  167. return func(m *AddWechatFriendLogMutation) {
  168. var (
  169. err error
  170. once sync.Once
  171. value *AddWechatFriendLog
  172. )
  173. m.oldValue = func(ctx context.Context) (*AddWechatFriendLog, error) {
  174. once.Do(func() {
  175. if m.done {
  176. err = errors.New("querying old values post mutation is not allowed")
  177. } else {
  178. value, err = m.Client().AddWechatFriendLog.Get(ctx, id)
  179. }
  180. })
  181. return value, err
  182. }
  183. m.id = &id
  184. }
  185. }
  186. // withAddWechatFriendLog sets the old AddWechatFriendLog of the mutation.
  187. func withAddWechatFriendLog(node *AddWechatFriendLog) addwechatfriendlogOption {
  188. return func(m *AddWechatFriendLogMutation) {
  189. m.oldValue = func(context.Context) (*AddWechatFriendLog, error) {
  190. return node, nil
  191. }
  192. m.id = &node.ID
  193. }
  194. }
  195. // Client returns a new `ent.Client` from the mutation. If the mutation was
  196. // executed in a transaction (ent.Tx), a transactional client is returned.
  197. func (m AddWechatFriendLogMutation) Client() *Client {
  198. client := &Client{config: m.config}
  199. client.init()
  200. return client
  201. }
  202. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  203. // it returns an error otherwise.
  204. func (m AddWechatFriendLogMutation) Tx() (*Tx, error) {
  205. if _, ok := m.driver.(*txDriver); !ok {
  206. return nil, errors.New("ent: mutation is not running in a transaction")
  207. }
  208. tx := &Tx{config: m.config}
  209. tx.init()
  210. return tx, nil
  211. }
  212. // SetID sets the value of the id field. Note that this
  213. // operation is only accepted on creation of AddWechatFriendLog entities.
  214. func (m *AddWechatFriendLogMutation) SetID(id int64) {
  215. m.id = &id
  216. }
  217. // ID returns the ID value in the mutation. Note that the ID is only available
  218. // if it was provided to the builder or after it was returned from the database.
  219. func (m *AddWechatFriendLogMutation) ID() (id int64, exists bool) {
  220. if m.id == nil {
  221. return
  222. }
  223. return *m.id, true
  224. }
  225. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  226. // That means, if the mutation is applied within a transaction with an isolation level such
  227. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  228. // or updated by the mutation.
  229. func (m *AddWechatFriendLogMutation) IDs(ctx context.Context) ([]int64, error) {
  230. switch {
  231. case m.op.Is(OpUpdateOne | OpDeleteOne):
  232. id, exists := m.ID()
  233. if exists {
  234. return []int64{id}, nil
  235. }
  236. fallthrough
  237. case m.op.Is(OpUpdate | OpDelete):
  238. return m.Client().AddWechatFriendLog.Query().Where(m.predicates...).IDs(ctx)
  239. default:
  240. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  241. }
  242. }
  243. // SetOwnerWxID sets the "owner_wx_id" field.
  244. func (m *AddWechatFriendLogMutation) SetOwnerWxID(s string) {
  245. m.owner_wx_id = &s
  246. }
  247. // OwnerWxID returns the value of the "owner_wx_id" field in the mutation.
  248. func (m *AddWechatFriendLogMutation) OwnerWxID() (r string, exists bool) {
  249. v := m.owner_wx_id
  250. if v == nil {
  251. return
  252. }
  253. return *v, true
  254. }
  255. // OldOwnerWxID returns the old "owner_wx_id" field's value of the AddWechatFriendLog entity.
  256. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  258. func (m *AddWechatFriendLogMutation) OldOwnerWxID(ctx context.Context) (v string, err error) {
  259. if !m.op.Is(OpUpdateOne) {
  260. return v, errors.New("OldOwnerWxID is only allowed on UpdateOne operations")
  261. }
  262. if m.id == nil || m.oldValue == nil {
  263. return v, errors.New("OldOwnerWxID requires an ID field in the mutation")
  264. }
  265. oldValue, err := m.oldValue(ctx)
  266. if err != nil {
  267. return v, fmt.Errorf("querying old value for OldOwnerWxID: %w", err)
  268. }
  269. return oldValue.OwnerWxID, nil
  270. }
  271. // ResetOwnerWxID resets all changes to the "owner_wx_id" field.
  272. func (m *AddWechatFriendLogMutation) ResetOwnerWxID() {
  273. m.owner_wx_id = nil
  274. }
  275. // SetOwnerWxType sets the "owner_wx_type" field.
  276. func (m *AddWechatFriendLogMutation) SetOwnerWxType(i int) {
  277. m.owner_wx_type = &i
  278. m.addowner_wx_type = nil
  279. }
  280. // OwnerWxType returns the value of the "owner_wx_type" field in the mutation.
  281. func (m *AddWechatFriendLogMutation) OwnerWxType() (r int, exists bool) {
  282. v := m.owner_wx_type
  283. if v == nil {
  284. return
  285. }
  286. return *v, true
  287. }
  288. // OldOwnerWxType returns the old "owner_wx_type" field's value of the AddWechatFriendLog entity.
  289. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  291. func (m *AddWechatFriendLogMutation) OldOwnerWxType(ctx context.Context) (v int, err error) {
  292. if !m.op.Is(OpUpdateOne) {
  293. return v, errors.New("OldOwnerWxType is only allowed on UpdateOne operations")
  294. }
  295. if m.id == nil || m.oldValue == nil {
  296. return v, errors.New("OldOwnerWxType requires an ID field in the mutation")
  297. }
  298. oldValue, err := m.oldValue(ctx)
  299. if err != nil {
  300. return v, fmt.Errorf("querying old value for OldOwnerWxType: %w", err)
  301. }
  302. return oldValue.OwnerWxType, nil
  303. }
  304. // AddOwnerWxType adds i to the "owner_wx_type" field.
  305. func (m *AddWechatFriendLogMutation) AddOwnerWxType(i int) {
  306. if m.addowner_wx_type != nil {
  307. *m.addowner_wx_type += i
  308. } else {
  309. m.addowner_wx_type = &i
  310. }
  311. }
  312. // AddedOwnerWxType returns the value that was added to the "owner_wx_type" field in this mutation.
  313. func (m *AddWechatFriendLogMutation) AddedOwnerWxType() (r int, exists bool) {
  314. v := m.addowner_wx_type
  315. if v == nil {
  316. return
  317. }
  318. return *v, true
  319. }
  320. // ResetOwnerWxType resets all changes to the "owner_wx_type" field.
  321. func (m *AddWechatFriendLogMutation) ResetOwnerWxType() {
  322. m.owner_wx_type = nil
  323. m.addowner_wx_type = nil
  324. }
  325. // SetFindContent sets the "find_content" field.
  326. func (m *AddWechatFriendLogMutation) SetFindContent(s string) {
  327. m.find_content = &s
  328. }
  329. // FindContent returns the value of the "find_content" field in the mutation.
  330. func (m *AddWechatFriendLogMutation) FindContent() (r string, exists bool) {
  331. v := m.find_content
  332. if v == nil {
  333. return
  334. }
  335. return *v, true
  336. }
  337. // OldFindContent returns the old "find_content" field's value of the AddWechatFriendLog entity.
  338. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  339. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  340. func (m *AddWechatFriendLogMutation) OldFindContent(ctx context.Context) (v string, err error) {
  341. if !m.op.Is(OpUpdateOne) {
  342. return v, errors.New("OldFindContent is only allowed on UpdateOne operations")
  343. }
  344. if m.id == nil || m.oldValue == nil {
  345. return v, errors.New("OldFindContent requires an ID field in the mutation")
  346. }
  347. oldValue, err := m.oldValue(ctx)
  348. if err != nil {
  349. return v, fmt.Errorf("querying old value for OldFindContent: %w", err)
  350. }
  351. return oldValue.FindContent, nil
  352. }
  353. // ResetFindContent resets all changes to the "find_content" field.
  354. func (m *AddWechatFriendLogMutation) ResetFindContent() {
  355. m.find_content = nil
  356. }
  357. // SetMessage sets the "message" field.
  358. func (m *AddWechatFriendLogMutation) SetMessage(s string) {
  359. m.message = &s
  360. }
  361. // Message returns the value of the "message" field in the mutation.
  362. func (m *AddWechatFriendLogMutation) Message() (r string, exists bool) {
  363. v := m.message
  364. if v == nil {
  365. return
  366. }
  367. return *v, true
  368. }
  369. // OldMessage returns the old "message" field's value of the AddWechatFriendLog entity.
  370. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  372. func (m *AddWechatFriendLogMutation) OldMessage(ctx context.Context) (v string, err error) {
  373. if !m.op.Is(OpUpdateOne) {
  374. return v, errors.New("OldMessage is only allowed on UpdateOne operations")
  375. }
  376. if m.id == nil || m.oldValue == nil {
  377. return v, errors.New("OldMessage requires an ID field in the mutation")
  378. }
  379. oldValue, err := m.oldValue(ctx)
  380. if err != nil {
  381. return v, fmt.Errorf("querying old value for OldMessage: %w", err)
  382. }
  383. return oldValue.Message, nil
  384. }
  385. // ResetMessage resets all changes to the "message" field.
  386. func (m *AddWechatFriendLogMutation) ResetMessage() {
  387. m.message = nil
  388. }
  389. // SetFindRequest sets the "find_request" field.
  390. func (m *AddWechatFriendLogMutation) SetFindRequest(value map[string]interface{}) {
  391. m.find_request = &value
  392. }
  393. // FindRequest returns the value of the "find_request" field in the mutation.
  394. func (m *AddWechatFriendLogMutation) FindRequest() (r map[string]interface{}, exists bool) {
  395. v := m.find_request
  396. if v == nil {
  397. return
  398. }
  399. return *v, true
  400. }
  401. // OldFindRequest returns the old "find_request" field's value of the AddWechatFriendLog entity.
  402. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  404. func (m *AddWechatFriendLogMutation) OldFindRequest(ctx context.Context) (v map[string]interface{}, err error) {
  405. if !m.op.Is(OpUpdateOne) {
  406. return v, errors.New("OldFindRequest is only allowed on UpdateOne operations")
  407. }
  408. if m.id == nil || m.oldValue == nil {
  409. return v, errors.New("OldFindRequest requires an ID field in the mutation")
  410. }
  411. oldValue, err := m.oldValue(ctx)
  412. if err != nil {
  413. return v, fmt.Errorf("querying old value for OldFindRequest: %w", err)
  414. }
  415. return oldValue.FindRequest, nil
  416. }
  417. // ClearFindRequest clears the value of the "find_request" field.
  418. func (m *AddWechatFriendLogMutation) ClearFindRequest() {
  419. m.find_request = nil
  420. m.clearedFields[addwechatfriendlog.FieldFindRequest] = struct{}{}
  421. }
  422. // FindRequestCleared returns if the "find_request" field was cleared in this mutation.
  423. func (m *AddWechatFriendLogMutation) FindRequestCleared() bool {
  424. _, ok := m.clearedFields[addwechatfriendlog.FieldFindRequest]
  425. return ok
  426. }
  427. // ResetFindRequest resets all changes to the "find_request" field.
  428. func (m *AddWechatFriendLogMutation) ResetFindRequest() {
  429. m.find_request = nil
  430. delete(m.clearedFields, addwechatfriendlog.FieldFindRequest)
  431. }
  432. // SetFindResult sets the "find_result" field.
  433. func (m *AddWechatFriendLogMutation) SetFindResult(value map[string]interface{}) {
  434. m.find_result = &value
  435. }
  436. // FindResult returns the value of the "find_result" field in the mutation.
  437. func (m *AddWechatFriendLogMutation) FindResult() (r map[string]interface{}, exists bool) {
  438. v := m.find_result
  439. if v == nil {
  440. return
  441. }
  442. return *v, true
  443. }
  444. // OldFindResult returns the old "find_result" field's value of the AddWechatFriendLog entity.
  445. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  447. func (m *AddWechatFriendLogMutation) OldFindResult(ctx context.Context) (v map[string]interface{}, err error) {
  448. if !m.op.Is(OpUpdateOne) {
  449. return v, errors.New("OldFindResult is only allowed on UpdateOne operations")
  450. }
  451. if m.id == nil || m.oldValue == nil {
  452. return v, errors.New("OldFindResult requires an ID field in the mutation")
  453. }
  454. oldValue, err := m.oldValue(ctx)
  455. if err != nil {
  456. return v, fmt.Errorf("querying old value for OldFindResult: %w", err)
  457. }
  458. return oldValue.FindResult, nil
  459. }
  460. // ClearFindResult clears the value of the "find_result" field.
  461. func (m *AddWechatFriendLogMutation) ClearFindResult() {
  462. m.find_result = nil
  463. m.clearedFields[addwechatfriendlog.FieldFindResult] = struct{}{}
  464. }
  465. // FindResultCleared returns if the "find_result" field was cleared in this mutation.
  466. func (m *AddWechatFriendLogMutation) FindResultCleared() bool {
  467. _, ok := m.clearedFields[addwechatfriendlog.FieldFindResult]
  468. return ok
  469. }
  470. // ResetFindResult resets all changes to the "find_result" field.
  471. func (m *AddWechatFriendLogMutation) ResetFindResult() {
  472. m.find_result = nil
  473. delete(m.clearedFields, addwechatfriendlog.FieldFindResult)
  474. }
  475. // SetIsCanAdd sets the "is_can_add" field.
  476. func (m *AddWechatFriendLogMutation) SetIsCanAdd(i int) {
  477. m.is_can_add = &i
  478. m.addis_can_add = nil
  479. }
  480. // IsCanAdd returns the value of the "is_can_add" field in the mutation.
  481. func (m *AddWechatFriendLogMutation) IsCanAdd() (r int, exists bool) {
  482. v := m.is_can_add
  483. if v == nil {
  484. return
  485. }
  486. return *v, true
  487. }
  488. // OldIsCanAdd returns the old "is_can_add" field's value of the AddWechatFriendLog entity.
  489. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  491. func (m *AddWechatFriendLogMutation) OldIsCanAdd(ctx context.Context) (v int, err error) {
  492. if !m.op.Is(OpUpdateOne) {
  493. return v, errors.New("OldIsCanAdd is only allowed on UpdateOne operations")
  494. }
  495. if m.id == nil || m.oldValue == nil {
  496. return v, errors.New("OldIsCanAdd requires an ID field in the mutation")
  497. }
  498. oldValue, err := m.oldValue(ctx)
  499. if err != nil {
  500. return v, fmt.Errorf("querying old value for OldIsCanAdd: %w", err)
  501. }
  502. return oldValue.IsCanAdd, nil
  503. }
  504. // AddIsCanAdd adds i to the "is_can_add" field.
  505. func (m *AddWechatFriendLogMutation) AddIsCanAdd(i int) {
  506. if m.addis_can_add != nil {
  507. *m.addis_can_add += i
  508. } else {
  509. m.addis_can_add = &i
  510. }
  511. }
  512. // AddedIsCanAdd returns the value that was added to the "is_can_add" field in this mutation.
  513. func (m *AddWechatFriendLogMutation) AddedIsCanAdd() (r int, exists bool) {
  514. v := m.addis_can_add
  515. if v == nil {
  516. return
  517. }
  518. return *v, true
  519. }
  520. // ResetIsCanAdd resets all changes to the "is_can_add" field.
  521. func (m *AddWechatFriendLogMutation) ResetIsCanAdd() {
  522. m.is_can_add = nil
  523. m.addis_can_add = nil
  524. }
  525. // SetTaskCount sets the "task_count" field.
  526. func (m *AddWechatFriendLogMutation) SetTaskCount(i int) {
  527. m.task_count = &i
  528. m.addtask_count = nil
  529. }
  530. // TaskCount returns the value of the "task_count" field in the mutation.
  531. func (m *AddWechatFriendLogMutation) TaskCount() (r int, exists bool) {
  532. v := m.task_count
  533. if v == nil {
  534. return
  535. }
  536. return *v, true
  537. }
  538. // OldTaskCount returns the old "task_count" field's value of the AddWechatFriendLog entity.
  539. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  541. func (m *AddWechatFriendLogMutation) OldTaskCount(ctx context.Context) (v int, err error) {
  542. if !m.op.Is(OpUpdateOne) {
  543. return v, errors.New("OldTaskCount is only allowed on UpdateOne operations")
  544. }
  545. if m.id == nil || m.oldValue == nil {
  546. return v, errors.New("OldTaskCount requires an ID field in the mutation")
  547. }
  548. oldValue, err := m.oldValue(ctx)
  549. if err != nil {
  550. return v, fmt.Errorf("querying old value for OldTaskCount: %w", err)
  551. }
  552. return oldValue.TaskCount, nil
  553. }
  554. // AddTaskCount adds i to the "task_count" field.
  555. func (m *AddWechatFriendLogMutation) AddTaskCount(i int) {
  556. if m.addtask_count != nil {
  557. *m.addtask_count += i
  558. } else {
  559. m.addtask_count = &i
  560. }
  561. }
  562. // AddedTaskCount returns the value that was added to the "task_count" field in this mutation.
  563. func (m *AddWechatFriendLogMutation) AddedTaskCount() (r int, exists bool) {
  564. v := m.addtask_count
  565. if v == nil {
  566. return
  567. }
  568. return *v, true
  569. }
  570. // ResetTaskCount resets all changes to the "task_count" field.
  571. func (m *AddWechatFriendLogMutation) ResetTaskCount() {
  572. m.task_count = nil
  573. m.addtask_count = nil
  574. }
  575. // SetTaskID sets the "task_id" field.
  576. func (m *AddWechatFriendLogMutation) SetTaskID(i int64) {
  577. m.task_id = &i
  578. m.addtask_id = nil
  579. }
  580. // TaskID returns the value of the "task_id" field in the mutation.
  581. func (m *AddWechatFriendLogMutation) TaskID() (r int64, exists bool) {
  582. v := m.task_id
  583. if v == nil {
  584. return
  585. }
  586. return *v, true
  587. }
  588. // OldTaskID returns the old "task_id" field's value of the AddWechatFriendLog entity.
  589. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  591. func (m *AddWechatFriendLogMutation) OldTaskID(ctx context.Context) (v int64, err error) {
  592. if !m.op.Is(OpUpdateOne) {
  593. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  594. }
  595. if m.id == nil || m.oldValue == nil {
  596. return v, errors.New("OldTaskID requires an ID field in the mutation")
  597. }
  598. oldValue, err := m.oldValue(ctx)
  599. if err != nil {
  600. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  601. }
  602. return oldValue.TaskID, nil
  603. }
  604. // AddTaskID adds i to the "task_id" field.
  605. func (m *AddWechatFriendLogMutation) AddTaskID(i int64) {
  606. if m.addtask_id != nil {
  607. *m.addtask_id += i
  608. } else {
  609. m.addtask_id = &i
  610. }
  611. }
  612. // AddedTaskID returns the value that was added to the "task_id" field in this mutation.
  613. func (m *AddWechatFriendLogMutation) AddedTaskID() (r int64, exists bool) {
  614. v := m.addtask_id
  615. if v == nil {
  616. return
  617. }
  618. return *v, true
  619. }
  620. // ResetTaskID resets all changes to the "task_id" field.
  621. func (m *AddWechatFriendLogMutation) ResetTaskID() {
  622. m.task_id = nil
  623. m.addtask_id = nil
  624. }
  625. // SetAddRequest sets the "add_request" field.
  626. func (m *AddWechatFriendLogMutation) SetAddRequest(value map[string]interface{}) {
  627. m.add_request = &value
  628. }
  629. // AddRequest returns the value of the "add_request" field in the mutation.
  630. func (m *AddWechatFriendLogMutation) AddRequest() (r map[string]interface{}, exists bool) {
  631. v := m.add_request
  632. if v == nil {
  633. return
  634. }
  635. return *v, true
  636. }
  637. // OldAddRequest returns the old "add_request" field's value of the AddWechatFriendLog entity.
  638. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  640. func (m *AddWechatFriendLogMutation) OldAddRequest(ctx context.Context) (v map[string]interface{}, err error) {
  641. if !m.op.Is(OpUpdateOne) {
  642. return v, errors.New("OldAddRequest is only allowed on UpdateOne operations")
  643. }
  644. if m.id == nil || m.oldValue == nil {
  645. return v, errors.New("OldAddRequest requires an ID field in the mutation")
  646. }
  647. oldValue, err := m.oldValue(ctx)
  648. if err != nil {
  649. return v, fmt.Errorf("querying old value for OldAddRequest: %w", err)
  650. }
  651. return oldValue.AddRequest, nil
  652. }
  653. // ClearAddRequest clears the value of the "add_request" field.
  654. func (m *AddWechatFriendLogMutation) ClearAddRequest() {
  655. m.add_request = nil
  656. m.clearedFields[addwechatfriendlog.FieldAddRequest] = struct{}{}
  657. }
  658. // AddRequestCleared returns if the "add_request" field was cleared in this mutation.
  659. func (m *AddWechatFriendLogMutation) AddRequestCleared() bool {
  660. _, ok := m.clearedFields[addwechatfriendlog.FieldAddRequest]
  661. return ok
  662. }
  663. // ResetAddRequest resets all changes to the "add_request" field.
  664. func (m *AddWechatFriendLogMutation) ResetAddRequest() {
  665. m.add_request = nil
  666. delete(m.clearedFields, addwechatfriendlog.FieldAddRequest)
  667. }
  668. // SetAddResult sets the "add_result" field.
  669. func (m *AddWechatFriendLogMutation) SetAddResult(value map[string]interface{}) {
  670. m.add_result = &value
  671. }
  672. // AddResult returns the value of the "add_result" field in the mutation.
  673. func (m *AddWechatFriendLogMutation) AddResult() (r map[string]interface{}, exists bool) {
  674. v := m.add_result
  675. if v == nil {
  676. return
  677. }
  678. return *v, true
  679. }
  680. // OldAddResult returns the old "add_result" field's value of the AddWechatFriendLog entity.
  681. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  683. func (m *AddWechatFriendLogMutation) OldAddResult(ctx context.Context) (v map[string]interface{}, err error) {
  684. if !m.op.Is(OpUpdateOne) {
  685. return v, errors.New("OldAddResult is only allowed on UpdateOne operations")
  686. }
  687. if m.id == nil || m.oldValue == nil {
  688. return v, errors.New("OldAddResult requires an ID field in the mutation")
  689. }
  690. oldValue, err := m.oldValue(ctx)
  691. if err != nil {
  692. return v, fmt.Errorf("querying old value for OldAddResult: %w", err)
  693. }
  694. return oldValue.AddResult, nil
  695. }
  696. // ClearAddResult clears the value of the "add_result" field.
  697. func (m *AddWechatFriendLogMutation) ClearAddResult() {
  698. m.add_result = nil
  699. m.clearedFields[addwechatfriendlog.FieldAddResult] = struct{}{}
  700. }
  701. // AddResultCleared returns if the "add_result" field was cleared in this mutation.
  702. func (m *AddWechatFriendLogMutation) AddResultCleared() bool {
  703. _, ok := m.clearedFields[addwechatfriendlog.FieldAddResult]
  704. return ok
  705. }
  706. // ResetAddResult resets all changes to the "add_result" field.
  707. func (m *AddWechatFriendLogMutation) ResetAddResult() {
  708. m.add_result = nil
  709. delete(m.clearedFields, addwechatfriendlog.FieldAddResult)
  710. }
  711. // SetCreatedAt sets the "created_at" field.
  712. func (m *AddWechatFriendLogMutation) SetCreatedAt(i int64) {
  713. m.created_at = &i
  714. m.addcreated_at = nil
  715. }
  716. // CreatedAt returns the value of the "created_at" field in the mutation.
  717. func (m *AddWechatFriendLogMutation) CreatedAt() (r int64, exists bool) {
  718. v := m.created_at
  719. if v == nil {
  720. return
  721. }
  722. return *v, true
  723. }
  724. // OldCreatedAt returns the old "created_at" field's value of the AddWechatFriendLog entity.
  725. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  727. func (m *AddWechatFriendLogMutation) OldCreatedAt(ctx context.Context) (v int64, err error) {
  728. if !m.op.Is(OpUpdateOne) {
  729. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  730. }
  731. if m.id == nil || m.oldValue == nil {
  732. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  733. }
  734. oldValue, err := m.oldValue(ctx)
  735. if err != nil {
  736. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  737. }
  738. return oldValue.CreatedAt, nil
  739. }
  740. // AddCreatedAt adds i to the "created_at" field.
  741. func (m *AddWechatFriendLogMutation) AddCreatedAt(i int64) {
  742. if m.addcreated_at != nil {
  743. *m.addcreated_at += i
  744. } else {
  745. m.addcreated_at = &i
  746. }
  747. }
  748. // AddedCreatedAt returns the value that was added to the "created_at" field in this mutation.
  749. func (m *AddWechatFriendLogMutation) AddedCreatedAt() (r int64, exists bool) {
  750. v := m.addcreated_at
  751. if v == nil {
  752. return
  753. }
  754. return *v, true
  755. }
  756. // ResetCreatedAt resets all changes to the "created_at" field.
  757. func (m *AddWechatFriendLogMutation) ResetCreatedAt() {
  758. m.created_at = nil
  759. m.addcreated_at = nil
  760. }
  761. // SetUpdatedAt sets the "updated_at" field.
  762. func (m *AddWechatFriendLogMutation) SetUpdatedAt(i int64) {
  763. m.updated_at = &i
  764. m.addupdated_at = nil
  765. }
  766. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  767. func (m *AddWechatFriendLogMutation) UpdatedAt() (r int64, exists bool) {
  768. v := m.updated_at
  769. if v == nil {
  770. return
  771. }
  772. return *v, true
  773. }
  774. // OldUpdatedAt returns the old "updated_at" field's value of the AddWechatFriendLog entity.
  775. // If the AddWechatFriendLog object wasn't provided to the builder, the object is fetched from the database.
  776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  777. func (m *AddWechatFriendLogMutation) OldUpdatedAt(ctx context.Context) (v int64, err error) {
  778. if !m.op.Is(OpUpdateOne) {
  779. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  780. }
  781. if m.id == nil || m.oldValue == nil {
  782. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  783. }
  784. oldValue, err := m.oldValue(ctx)
  785. if err != nil {
  786. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  787. }
  788. return oldValue.UpdatedAt, nil
  789. }
  790. // AddUpdatedAt adds i to the "updated_at" field.
  791. func (m *AddWechatFriendLogMutation) AddUpdatedAt(i int64) {
  792. if m.addupdated_at != nil {
  793. *m.addupdated_at += i
  794. } else {
  795. m.addupdated_at = &i
  796. }
  797. }
  798. // AddedUpdatedAt returns the value that was added to the "updated_at" field in this mutation.
  799. func (m *AddWechatFriendLogMutation) AddedUpdatedAt() (r int64, exists bool) {
  800. v := m.addupdated_at
  801. if v == nil {
  802. return
  803. }
  804. return *v, true
  805. }
  806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  807. func (m *AddWechatFriendLogMutation) ResetUpdatedAt() {
  808. m.updated_at = nil
  809. m.addupdated_at = nil
  810. }
  811. // Where appends a list predicates to the AddWechatFriendLogMutation builder.
  812. func (m *AddWechatFriendLogMutation) Where(ps ...predicate.AddWechatFriendLog) {
  813. m.predicates = append(m.predicates, ps...)
  814. }
  815. // WhereP appends storage-level predicates to the AddWechatFriendLogMutation builder. Using this method,
  816. // users can use type-assertion to append predicates that do not depend on any generated package.
  817. func (m *AddWechatFriendLogMutation) WhereP(ps ...func(*sql.Selector)) {
  818. p := make([]predicate.AddWechatFriendLog, len(ps))
  819. for i := range ps {
  820. p[i] = ps[i]
  821. }
  822. m.Where(p...)
  823. }
  824. // Op returns the operation name.
  825. func (m *AddWechatFriendLogMutation) Op() Op {
  826. return m.op
  827. }
  828. // SetOp allows setting the mutation operation.
  829. func (m *AddWechatFriendLogMutation) SetOp(op Op) {
  830. m.op = op
  831. }
  832. // Type returns the node type of this mutation (AddWechatFriendLog).
  833. func (m *AddWechatFriendLogMutation) Type() string {
  834. return m.typ
  835. }
  836. // Fields returns all fields that were changed during this mutation. Note that in
  837. // order to get all numeric fields that were incremented/decremented, call
  838. // AddedFields().
  839. func (m *AddWechatFriendLogMutation) Fields() []string {
  840. fields := make([]string, 0, 13)
  841. if m.owner_wx_id != nil {
  842. fields = append(fields, addwechatfriendlog.FieldOwnerWxID)
  843. }
  844. if m.owner_wx_type != nil {
  845. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  846. }
  847. if m.find_content != nil {
  848. fields = append(fields, addwechatfriendlog.FieldFindContent)
  849. }
  850. if m.message != nil {
  851. fields = append(fields, addwechatfriendlog.FieldMessage)
  852. }
  853. if m.find_request != nil {
  854. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  855. }
  856. if m.find_result != nil {
  857. fields = append(fields, addwechatfriendlog.FieldFindResult)
  858. }
  859. if m.is_can_add != nil {
  860. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  861. }
  862. if m.task_count != nil {
  863. fields = append(fields, addwechatfriendlog.FieldTaskCount)
  864. }
  865. if m.task_id != nil {
  866. fields = append(fields, addwechatfriendlog.FieldTaskID)
  867. }
  868. if m.add_request != nil {
  869. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  870. }
  871. if m.add_result != nil {
  872. fields = append(fields, addwechatfriendlog.FieldAddResult)
  873. }
  874. if m.created_at != nil {
  875. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  876. }
  877. if m.updated_at != nil {
  878. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  879. }
  880. return fields
  881. }
  882. // Field returns the value of a field with the given name. The second boolean
  883. // return value indicates that this field was not set, or was not defined in the
  884. // schema.
  885. func (m *AddWechatFriendLogMutation) Field(name string) (ent.Value, bool) {
  886. switch name {
  887. case addwechatfriendlog.FieldOwnerWxID:
  888. return m.OwnerWxID()
  889. case addwechatfriendlog.FieldOwnerWxType:
  890. return m.OwnerWxType()
  891. case addwechatfriendlog.FieldFindContent:
  892. return m.FindContent()
  893. case addwechatfriendlog.FieldMessage:
  894. return m.Message()
  895. case addwechatfriendlog.FieldFindRequest:
  896. return m.FindRequest()
  897. case addwechatfriendlog.FieldFindResult:
  898. return m.FindResult()
  899. case addwechatfriendlog.FieldIsCanAdd:
  900. return m.IsCanAdd()
  901. case addwechatfriendlog.FieldTaskCount:
  902. return m.TaskCount()
  903. case addwechatfriendlog.FieldTaskID:
  904. return m.TaskID()
  905. case addwechatfriendlog.FieldAddRequest:
  906. return m.AddRequest()
  907. case addwechatfriendlog.FieldAddResult:
  908. return m.AddResult()
  909. case addwechatfriendlog.FieldCreatedAt:
  910. return m.CreatedAt()
  911. case addwechatfriendlog.FieldUpdatedAt:
  912. return m.UpdatedAt()
  913. }
  914. return nil, false
  915. }
  916. // OldField returns the old value of the field from the database. An error is
  917. // returned if the mutation operation is not UpdateOne, or the query to the
  918. // database failed.
  919. func (m *AddWechatFriendLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  920. switch name {
  921. case addwechatfriendlog.FieldOwnerWxID:
  922. return m.OldOwnerWxID(ctx)
  923. case addwechatfriendlog.FieldOwnerWxType:
  924. return m.OldOwnerWxType(ctx)
  925. case addwechatfriendlog.FieldFindContent:
  926. return m.OldFindContent(ctx)
  927. case addwechatfriendlog.FieldMessage:
  928. return m.OldMessage(ctx)
  929. case addwechatfriendlog.FieldFindRequest:
  930. return m.OldFindRequest(ctx)
  931. case addwechatfriendlog.FieldFindResult:
  932. return m.OldFindResult(ctx)
  933. case addwechatfriendlog.FieldIsCanAdd:
  934. return m.OldIsCanAdd(ctx)
  935. case addwechatfriendlog.FieldTaskCount:
  936. return m.OldTaskCount(ctx)
  937. case addwechatfriendlog.FieldTaskID:
  938. return m.OldTaskID(ctx)
  939. case addwechatfriendlog.FieldAddRequest:
  940. return m.OldAddRequest(ctx)
  941. case addwechatfriendlog.FieldAddResult:
  942. return m.OldAddResult(ctx)
  943. case addwechatfriendlog.FieldCreatedAt:
  944. return m.OldCreatedAt(ctx)
  945. case addwechatfriendlog.FieldUpdatedAt:
  946. return m.OldUpdatedAt(ctx)
  947. }
  948. return nil, fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  949. }
  950. // SetField sets the value of a field with the given name. It returns an error if
  951. // the field is not defined in the schema, or if the type mismatched the field
  952. // type.
  953. func (m *AddWechatFriendLogMutation) SetField(name string, value ent.Value) error {
  954. switch name {
  955. case addwechatfriendlog.FieldOwnerWxID:
  956. v, ok := value.(string)
  957. if !ok {
  958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  959. }
  960. m.SetOwnerWxID(v)
  961. return nil
  962. case addwechatfriendlog.FieldOwnerWxType:
  963. v, ok := value.(int)
  964. if !ok {
  965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  966. }
  967. m.SetOwnerWxType(v)
  968. return nil
  969. case addwechatfriendlog.FieldFindContent:
  970. v, ok := value.(string)
  971. if !ok {
  972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  973. }
  974. m.SetFindContent(v)
  975. return nil
  976. case addwechatfriendlog.FieldMessage:
  977. v, ok := value.(string)
  978. if !ok {
  979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  980. }
  981. m.SetMessage(v)
  982. return nil
  983. case addwechatfriendlog.FieldFindRequest:
  984. v, ok := value.(map[string]interface{})
  985. if !ok {
  986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  987. }
  988. m.SetFindRequest(v)
  989. return nil
  990. case addwechatfriendlog.FieldFindResult:
  991. v, ok := value.(map[string]interface{})
  992. if !ok {
  993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  994. }
  995. m.SetFindResult(v)
  996. return nil
  997. case addwechatfriendlog.FieldIsCanAdd:
  998. v, ok := value.(int)
  999. if !ok {
  1000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1001. }
  1002. m.SetIsCanAdd(v)
  1003. return nil
  1004. case addwechatfriendlog.FieldTaskCount:
  1005. v, ok := value.(int)
  1006. if !ok {
  1007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1008. }
  1009. m.SetTaskCount(v)
  1010. return nil
  1011. case addwechatfriendlog.FieldTaskID:
  1012. v, ok := value.(int64)
  1013. if !ok {
  1014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1015. }
  1016. m.SetTaskID(v)
  1017. return nil
  1018. case addwechatfriendlog.FieldAddRequest:
  1019. v, ok := value.(map[string]interface{})
  1020. if !ok {
  1021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1022. }
  1023. m.SetAddRequest(v)
  1024. return nil
  1025. case addwechatfriendlog.FieldAddResult:
  1026. v, ok := value.(map[string]interface{})
  1027. if !ok {
  1028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1029. }
  1030. m.SetAddResult(v)
  1031. return nil
  1032. case addwechatfriendlog.FieldCreatedAt:
  1033. v, ok := value.(int64)
  1034. if !ok {
  1035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1036. }
  1037. m.SetCreatedAt(v)
  1038. return nil
  1039. case addwechatfriendlog.FieldUpdatedAt:
  1040. v, ok := value.(int64)
  1041. if !ok {
  1042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1043. }
  1044. m.SetUpdatedAt(v)
  1045. return nil
  1046. }
  1047. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  1048. }
  1049. // AddedFields returns all numeric fields that were incremented/decremented during
  1050. // this mutation.
  1051. func (m *AddWechatFriendLogMutation) AddedFields() []string {
  1052. var fields []string
  1053. if m.addowner_wx_type != nil {
  1054. fields = append(fields, addwechatfriendlog.FieldOwnerWxType)
  1055. }
  1056. if m.addis_can_add != nil {
  1057. fields = append(fields, addwechatfriendlog.FieldIsCanAdd)
  1058. }
  1059. if m.addtask_count != nil {
  1060. fields = append(fields, addwechatfriendlog.FieldTaskCount)
  1061. }
  1062. if m.addtask_id != nil {
  1063. fields = append(fields, addwechatfriendlog.FieldTaskID)
  1064. }
  1065. if m.addcreated_at != nil {
  1066. fields = append(fields, addwechatfriendlog.FieldCreatedAt)
  1067. }
  1068. if m.addupdated_at != nil {
  1069. fields = append(fields, addwechatfriendlog.FieldUpdatedAt)
  1070. }
  1071. return fields
  1072. }
  1073. // AddedField returns the numeric value that was incremented/decremented on a field
  1074. // with the given name. The second boolean return value indicates that this field
  1075. // was not set, or was not defined in the schema.
  1076. func (m *AddWechatFriendLogMutation) AddedField(name string) (ent.Value, bool) {
  1077. switch name {
  1078. case addwechatfriendlog.FieldOwnerWxType:
  1079. return m.AddedOwnerWxType()
  1080. case addwechatfriendlog.FieldIsCanAdd:
  1081. return m.AddedIsCanAdd()
  1082. case addwechatfriendlog.FieldTaskCount:
  1083. return m.AddedTaskCount()
  1084. case addwechatfriendlog.FieldTaskID:
  1085. return m.AddedTaskID()
  1086. case addwechatfriendlog.FieldCreatedAt:
  1087. return m.AddedCreatedAt()
  1088. case addwechatfriendlog.FieldUpdatedAt:
  1089. return m.AddedUpdatedAt()
  1090. }
  1091. return nil, false
  1092. }
  1093. // AddField adds the value to the field with the given name. It returns an error if
  1094. // the field is not defined in the schema, or if the type mismatched the field
  1095. // type.
  1096. func (m *AddWechatFriendLogMutation) AddField(name string, value ent.Value) error {
  1097. switch name {
  1098. case addwechatfriendlog.FieldOwnerWxType:
  1099. v, ok := value.(int)
  1100. if !ok {
  1101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1102. }
  1103. m.AddOwnerWxType(v)
  1104. return nil
  1105. case addwechatfriendlog.FieldIsCanAdd:
  1106. v, ok := value.(int)
  1107. if !ok {
  1108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1109. }
  1110. m.AddIsCanAdd(v)
  1111. return nil
  1112. case addwechatfriendlog.FieldTaskCount:
  1113. v, ok := value.(int)
  1114. if !ok {
  1115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1116. }
  1117. m.AddTaskCount(v)
  1118. return nil
  1119. case addwechatfriendlog.FieldTaskID:
  1120. v, ok := value.(int64)
  1121. if !ok {
  1122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1123. }
  1124. m.AddTaskID(v)
  1125. return nil
  1126. case addwechatfriendlog.FieldCreatedAt:
  1127. v, ok := value.(int64)
  1128. if !ok {
  1129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1130. }
  1131. m.AddCreatedAt(v)
  1132. return nil
  1133. case addwechatfriendlog.FieldUpdatedAt:
  1134. v, ok := value.(int64)
  1135. if !ok {
  1136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1137. }
  1138. m.AddUpdatedAt(v)
  1139. return nil
  1140. }
  1141. return fmt.Errorf("unknown AddWechatFriendLog numeric field %s", name)
  1142. }
  1143. // ClearedFields returns all nullable fields that were cleared during this
  1144. // mutation.
  1145. func (m *AddWechatFriendLogMutation) ClearedFields() []string {
  1146. var fields []string
  1147. if m.FieldCleared(addwechatfriendlog.FieldFindRequest) {
  1148. fields = append(fields, addwechatfriendlog.FieldFindRequest)
  1149. }
  1150. if m.FieldCleared(addwechatfriendlog.FieldFindResult) {
  1151. fields = append(fields, addwechatfriendlog.FieldFindResult)
  1152. }
  1153. if m.FieldCleared(addwechatfriendlog.FieldAddRequest) {
  1154. fields = append(fields, addwechatfriendlog.FieldAddRequest)
  1155. }
  1156. if m.FieldCleared(addwechatfriendlog.FieldAddResult) {
  1157. fields = append(fields, addwechatfriendlog.FieldAddResult)
  1158. }
  1159. return fields
  1160. }
  1161. // FieldCleared returns a boolean indicating if a field with the given name was
  1162. // cleared in this mutation.
  1163. func (m *AddWechatFriendLogMutation) FieldCleared(name string) bool {
  1164. _, ok := m.clearedFields[name]
  1165. return ok
  1166. }
  1167. // ClearField clears the value of the field with the given name. It returns an
  1168. // error if the field is not defined in the schema.
  1169. func (m *AddWechatFriendLogMutation) ClearField(name string) error {
  1170. switch name {
  1171. case addwechatfriendlog.FieldFindRequest:
  1172. m.ClearFindRequest()
  1173. return nil
  1174. case addwechatfriendlog.FieldFindResult:
  1175. m.ClearFindResult()
  1176. return nil
  1177. case addwechatfriendlog.FieldAddRequest:
  1178. m.ClearAddRequest()
  1179. return nil
  1180. case addwechatfriendlog.FieldAddResult:
  1181. m.ClearAddResult()
  1182. return nil
  1183. }
  1184. return fmt.Errorf("unknown AddWechatFriendLog nullable field %s", name)
  1185. }
  1186. // ResetField resets all changes in the mutation for the field with the given name.
  1187. // It returns an error if the field is not defined in the schema.
  1188. func (m *AddWechatFriendLogMutation) ResetField(name string) error {
  1189. switch name {
  1190. case addwechatfriendlog.FieldOwnerWxID:
  1191. m.ResetOwnerWxID()
  1192. return nil
  1193. case addwechatfriendlog.FieldOwnerWxType:
  1194. m.ResetOwnerWxType()
  1195. return nil
  1196. case addwechatfriendlog.FieldFindContent:
  1197. m.ResetFindContent()
  1198. return nil
  1199. case addwechatfriendlog.FieldMessage:
  1200. m.ResetMessage()
  1201. return nil
  1202. case addwechatfriendlog.FieldFindRequest:
  1203. m.ResetFindRequest()
  1204. return nil
  1205. case addwechatfriendlog.FieldFindResult:
  1206. m.ResetFindResult()
  1207. return nil
  1208. case addwechatfriendlog.FieldIsCanAdd:
  1209. m.ResetIsCanAdd()
  1210. return nil
  1211. case addwechatfriendlog.FieldTaskCount:
  1212. m.ResetTaskCount()
  1213. return nil
  1214. case addwechatfriendlog.FieldTaskID:
  1215. m.ResetTaskID()
  1216. return nil
  1217. case addwechatfriendlog.FieldAddRequest:
  1218. m.ResetAddRequest()
  1219. return nil
  1220. case addwechatfriendlog.FieldAddResult:
  1221. m.ResetAddResult()
  1222. return nil
  1223. case addwechatfriendlog.FieldCreatedAt:
  1224. m.ResetCreatedAt()
  1225. return nil
  1226. case addwechatfriendlog.FieldUpdatedAt:
  1227. m.ResetUpdatedAt()
  1228. return nil
  1229. }
  1230. return fmt.Errorf("unknown AddWechatFriendLog field %s", name)
  1231. }
  1232. // AddedEdges returns all edge names that were set/added in this mutation.
  1233. func (m *AddWechatFriendLogMutation) AddedEdges() []string {
  1234. edges := make([]string, 0, 0)
  1235. return edges
  1236. }
  1237. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1238. // name in this mutation.
  1239. func (m *AddWechatFriendLogMutation) AddedIDs(name string) []ent.Value {
  1240. return nil
  1241. }
  1242. // RemovedEdges returns all edge names that were removed in this mutation.
  1243. func (m *AddWechatFriendLogMutation) RemovedEdges() []string {
  1244. edges := make([]string, 0, 0)
  1245. return edges
  1246. }
  1247. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1248. // the given name in this mutation.
  1249. func (m *AddWechatFriendLogMutation) RemovedIDs(name string) []ent.Value {
  1250. return nil
  1251. }
  1252. // ClearedEdges returns all edge names that were cleared in this mutation.
  1253. func (m *AddWechatFriendLogMutation) ClearedEdges() []string {
  1254. edges := make([]string, 0, 0)
  1255. return edges
  1256. }
  1257. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1258. // was cleared in this mutation.
  1259. func (m *AddWechatFriendLogMutation) EdgeCleared(name string) bool {
  1260. return false
  1261. }
  1262. // ClearEdge clears the value of the edge with the given name. It returns an error
  1263. // if that edge is not defined in the schema.
  1264. func (m *AddWechatFriendLogMutation) ClearEdge(name string) error {
  1265. return fmt.Errorf("unknown AddWechatFriendLog unique edge %s", name)
  1266. }
  1267. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1268. // It returns an error if the edge is not defined in the schema.
  1269. func (m *AddWechatFriendLogMutation) ResetEdge(name string) error {
  1270. return fmt.Errorf("unknown AddWechatFriendLog edge %s", name)
  1271. }
  1272. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  1273. type AgentMutation struct {
  1274. config
  1275. op Op
  1276. typ string
  1277. id *uint64
  1278. created_at *time.Time
  1279. updated_at *time.Time
  1280. deleted_at *time.Time
  1281. name *string
  1282. role *string
  1283. status *int
  1284. addstatus *int
  1285. background *string
  1286. examples *string
  1287. organization_id *uint64
  1288. addorganization_id *int64
  1289. dataset_id *string
  1290. collection_id *string
  1291. model *string
  1292. api_base *string
  1293. api_key *string
  1294. _type *int
  1295. add_type *int
  1296. clearedFields map[string]struct{}
  1297. wx_agent map[uint64]struct{}
  1298. removedwx_agent map[uint64]struct{}
  1299. clearedwx_agent bool
  1300. token_agent map[uint64]struct{}
  1301. removedtoken_agent map[uint64]struct{}
  1302. clearedtoken_agent bool
  1303. wa_agent map[uint64]struct{}
  1304. removedwa_agent map[uint64]struct{}
  1305. clearedwa_agent bool
  1306. xjs_agent map[uint64]struct{}
  1307. removedxjs_agent map[uint64]struct{}
  1308. clearedxjs_agent bool
  1309. key_agent map[uint64]struct{}
  1310. removedkey_agent map[uint64]struct{}
  1311. clearedkey_agent bool
  1312. done bool
  1313. oldValue func(context.Context) (*Agent, error)
  1314. predicates []predicate.Agent
  1315. }
  1316. var _ ent.Mutation = (*AgentMutation)(nil)
  1317. // agentOption allows management of the mutation configuration using functional options.
  1318. type agentOption func(*AgentMutation)
  1319. // newAgentMutation creates new mutation for the Agent entity.
  1320. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  1321. m := &AgentMutation{
  1322. config: c,
  1323. op: op,
  1324. typ: TypeAgent,
  1325. clearedFields: make(map[string]struct{}),
  1326. }
  1327. for _, opt := range opts {
  1328. opt(m)
  1329. }
  1330. return m
  1331. }
  1332. // withAgentID sets the ID field of the mutation.
  1333. func withAgentID(id uint64) agentOption {
  1334. return func(m *AgentMutation) {
  1335. var (
  1336. err error
  1337. once sync.Once
  1338. value *Agent
  1339. )
  1340. m.oldValue = func(ctx context.Context) (*Agent, error) {
  1341. once.Do(func() {
  1342. if m.done {
  1343. err = errors.New("querying old values post mutation is not allowed")
  1344. } else {
  1345. value, err = m.Client().Agent.Get(ctx, id)
  1346. }
  1347. })
  1348. return value, err
  1349. }
  1350. m.id = &id
  1351. }
  1352. }
  1353. // withAgent sets the old Agent of the mutation.
  1354. func withAgent(node *Agent) agentOption {
  1355. return func(m *AgentMutation) {
  1356. m.oldValue = func(context.Context) (*Agent, error) {
  1357. return node, nil
  1358. }
  1359. m.id = &node.ID
  1360. }
  1361. }
  1362. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1363. // executed in a transaction (ent.Tx), a transactional client is returned.
  1364. func (m AgentMutation) Client() *Client {
  1365. client := &Client{config: m.config}
  1366. client.init()
  1367. return client
  1368. }
  1369. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1370. // it returns an error otherwise.
  1371. func (m AgentMutation) Tx() (*Tx, error) {
  1372. if _, ok := m.driver.(*txDriver); !ok {
  1373. return nil, errors.New("ent: mutation is not running in a transaction")
  1374. }
  1375. tx := &Tx{config: m.config}
  1376. tx.init()
  1377. return tx, nil
  1378. }
  1379. // SetID sets the value of the id field. Note that this
  1380. // operation is only accepted on creation of Agent entities.
  1381. func (m *AgentMutation) SetID(id uint64) {
  1382. m.id = &id
  1383. }
  1384. // ID returns the ID value in the mutation. Note that the ID is only available
  1385. // if it was provided to the builder or after it was returned from the database.
  1386. func (m *AgentMutation) ID() (id uint64, exists bool) {
  1387. if m.id == nil {
  1388. return
  1389. }
  1390. return *m.id, true
  1391. }
  1392. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1393. // That means, if the mutation is applied within a transaction with an isolation level such
  1394. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1395. // or updated by the mutation.
  1396. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  1397. switch {
  1398. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1399. id, exists := m.ID()
  1400. if exists {
  1401. return []uint64{id}, nil
  1402. }
  1403. fallthrough
  1404. case m.op.Is(OpUpdate | OpDelete):
  1405. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  1406. default:
  1407. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1408. }
  1409. }
  1410. // SetCreatedAt sets the "created_at" field.
  1411. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  1412. m.created_at = &t
  1413. }
  1414. // CreatedAt returns the value of the "created_at" field in the mutation.
  1415. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  1416. v := m.created_at
  1417. if v == nil {
  1418. return
  1419. }
  1420. return *v, true
  1421. }
  1422. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  1423. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1425. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  1426. if !m.op.Is(OpUpdateOne) {
  1427. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  1428. }
  1429. if m.id == nil || m.oldValue == nil {
  1430. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  1431. }
  1432. oldValue, err := m.oldValue(ctx)
  1433. if err != nil {
  1434. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  1435. }
  1436. return oldValue.CreatedAt, nil
  1437. }
  1438. // ResetCreatedAt resets all changes to the "created_at" field.
  1439. func (m *AgentMutation) ResetCreatedAt() {
  1440. m.created_at = nil
  1441. }
  1442. // SetUpdatedAt sets the "updated_at" field.
  1443. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  1444. m.updated_at = &t
  1445. }
  1446. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  1447. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  1448. v := m.updated_at
  1449. if v == nil {
  1450. return
  1451. }
  1452. return *v, true
  1453. }
  1454. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  1455. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1457. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  1458. if !m.op.Is(OpUpdateOne) {
  1459. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  1460. }
  1461. if m.id == nil || m.oldValue == nil {
  1462. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  1463. }
  1464. oldValue, err := m.oldValue(ctx)
  1465. if err != nil {
  1466. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  1467. }
  1468. return oldValue.UpdatedAt, nil
  1469. }
  1470. // ResetUpdatedAt resets all changes to the "updated_at" field.
  1471. func (m *AgentMutation) ResetUpdatedAt() {
  1472. m.updated_at = nil
  1473. }
  1474. // SetDeletedAt sets the "deleted_at" field.
  1475. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  1476. m.deleted_at = &t
  1477. }
  1478. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  1479. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  1480. v := m.deleted_at
  1481. if v == nil {
  1482. return
  1483. }
  1484. return *v, true
  1485. }
  1486. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  1487. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1489. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  1490. if !m.op.Is(OpUpdateOne) {
  1491. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  1492. }
  1493. if m.id == nil || m.oldValue == nil {
  1494. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  1495. }
  1496. oldValue, err := m.oldValue(ctx)
  1497. if err != nil {
  1498. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  1499. }
  1500. return oldValue.DeletedAt, nil
  1501. }
  1502. // ClearDeletedAt clears the value of the "deleted_at" field.
  1503. func (m *AgentMutation) ClearDeletedAt() {
  1504. m.deleted_at = nil
  1505. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  1506. }
  1507. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  1508. func (m *AgentMutation) DeletedAtCleared() bool {
  1509. _, ok := m.clearedFields[agent.FieldDeletedAt]
  1510. return ok
  1511. }
  1512. // ResetDeletedAt resets all changes to the "deleted_at" field.
  1513. func (m *AgentMutation) ResetDeletedAt() {
  1514. m.deleted_at = nil
  1515. delete(m.clearedFields, agent.FieldDeletedAt)
  1516. }
  1517. // SetName sets the "name" field.
  1518. func (m *AgentMutation) SetName(s string) {
  1519. m.name = &s
  1520. }
  1521. // Name returns the value of the "name" field in the mutation.
  1522. func (m *AgentMutation) Name() (r string, exists bool) {
  1523. v := m.name
  1524. if v == nil {
  1525. return
  1526. }
  1527. return *v, true
  1528. }
  1529. // OldName returns the old "name" field's value of the Agent entity.
  1530. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1532. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  1533. if !m.op.Is(OpUpdateOne) {
  1534. return v, errors.New("OldName is only allowed on UpdateOne operations")
  1535. }
  1536. if m.id == nil || m.oldValue == nil {
  1537. return v, errors.New("OldName requires an ID field in the mutation")
  1538. }
  1539. oldValue, err := m.oldValue(ctx)
  1540. if err != nil {
  1541. return v, fmt.Errorf("querying old value for OldName: %w", err)
  1542. }
  1543. return oldValue.Name, nil
  1544. }
  1545. // ResetName resets all changes to the "name" field.
  1546. func (m *AgentMutation) ResetName() {
  1547. m.name = nil
  1548. }
  1549. // SetRole sets the "role" field.
  1550. func (m *AgentMutation) SetRole(s string) {
  1551. m.role = &s
  1552. }
  1553. // Role returns the value of the "role" field in the mutation.
  1554. func (m *AgentMutation) Role() (r string, exists bool) {
  1555. v := m.role
  1556. if v == nil {
  1557. return
  1558. }
  1559. return *v, true
  1560. }
  1561. // OldRole returns the old "role" field's value of the Agent entity.
  1562. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1564. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  1565. if !m.op.Is(OpUpdateOne) {
  1566. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  1567. }
  1568. if m.id == nil || m.oldValue == nil {
  1569. return v, errors.New("OldRole requires an ID field in the mutation")
  1570. }
  1571. oldValue, err := m.oldValue(ctx)
  1572. if err != nil {
  1573. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  1574. }
  1575. return oldValue.Role, nil
  1576. }
  1577. // ClearRole clears the value of the "role" field.
  1578. func (m *AgentMutation) ClearRole() {
  1579. m.role = nil
  1580. m.clearedFields[agent.FieldRole] = struct{}{}
  1581. }
  1582. // RoleCleared returns if the "role" field was cleared in this mutation.
  1583. func (m *AgentMutation) RoleCleared() bool {
  1584. _, ok := m.clearedFields[agent.FieldRole]
  1585. return ok
  1586. }
  1587. // ResetRole resets all changes to the "role" field.
  1588. func (m *AgentMutation) ResetRole() {
  1589. m.role = nil
  1590. delete(m.clearedFields, agent.FieldRole)
  1591. }
  1592. // SetStatus sets the "status" field.
  1593. func (m *AgentMutation) SetStatus(i int) {
  1594. m.status = &i
  1595. m.addstatus = nil
  1596. }
  1597. // Status returns the value of the "status" field in the mutation.
  1598. func (m *AgentMutation) Status() (r int, exists bool) {
  1599. v := m.status
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldStatus returns the old "status" field's value of the Agent entity.
  1606. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldStatus requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  1618. }
  1619. return oldValue.Status, nil
  1620. }
  1621. // AddStatus adds i to the "status" field.
  1622. func (m *AgentMutation) AddStatus(i int) {
  1623. if m.addstatus != nil {
  1624. *m.addstatus += i
  1625. } else {
  1626. m.addstatus = &i
  1627. }
  1628. }
  1629. // AddedStatus returns the value that was added to the "status" field in this mutation.
  1630. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  1631. v := m.addstatus
  1632. if v == nil {
  1633. return
  1634. }
  1635. return *v, true
  1636. }
  1637. // ClearStatus clears the value of the "status" field.
  1638. func (m *AgentMutation) ClearStatus() {
  1639. m.status = nil
  1640. m.addstatus = nil
  1641. m.clearedFields[agent.FieldStatus] = struct{}{}
  1642. }
  1643. // StatusCleared returns if the "status" field was cleared in this mutation.
  1644. func (m *AgentMutation) StatusCleared() bool {
  1645. _, ok := m.clearedFields[agent.FieldStatus]
  1646. return ok
  1647. }
  1648. // ResetStatus resets all changes to the "status" field.
  1649. func (m *AgentMutation) ResetStatus() {
  1650. m.status = nil
  1651. m.addstatus = nil
  1652. delete(m.clearedFields, agent.FieldStatus)
  1653. }
  1654. // SetBackground sets the "background" field.
  1655. func (m *AgentMutation) SetBackground(s string) {
  1656. m.background = &s
  1657. }
  1658. // Background returns the value of the "background" field in the mutation.
  1659. func (m *AgentMutation) Background() (r string, exists bool) {
  1660. v := m.background
  1661. if v == nil {
  1662. return
  1663. }
  1664. return *v, true
  1665. }
  1666. // OldBackground returns the old "background" field's value of the Agent entity.
  1667. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1669. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  1670. if !m.op.Is(OpUpdateOne) {
  1671. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  1672. }
  1673. if m.id == nil || m.oldValue == nil {
  1674. return v, errors.New("OldBackground requires an ID field in the mutation")
  1675. }
  1676. oldValue, err := m.oldValue(ctx)
  1677. if err != nil {
  1678. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  1679. }
  1680. return oldValue.Background, nil
  1681. }
  1682. // ClearBackground clears the value of the "background" field.
  1683. func (m *AgentMutation) ClearBackground() {
  1684. m.background = nil
  1685. m.clearedFields[agent.FieldBackground] = struct{}{}
  1686. }
  1687. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  1688. func (m *AgentMutation) BackgroundCleared() bool {
  1689. _, ok := m.clearedFields[agent.FieldBackground]
  1690. return ok
  1691. }
  1692. // ResetBackground resets all changes to the "background" field.
  1693. func (m *AgentMutation) ResetBackground() {
  1694. m.background = nil
  1695. delete(m.clearedFields, agent.FieldBackground)
  1696. }
  1697. // SetExamples sets the "examples" field.
  1698. func (m *AgentMutation) SetExamples(s string) {
  1699. m.examples = &s
  1700. }
  1701. // Examples returns the value of the "examples" field in the mutation.
  1702. func (m *AgentMutation) Examples() (r string, exists bool) {
  1703. v := m.examples
  1704. if v == nil {
  1705. return
  1706. }
  1707. return *v, true
  1708. }
  1709. // OldExamples returns the old "examples" field's value of the Agent entity.
  1710. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1712. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  1713. if !m.op.Is(OpUpdateOne) {
  1714. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  1715. }
  1716. if m.id == nil || m.oldValue == nil {
  1717. return v, errors.New("OldExamples requires an ID field in the mutation")
  1718. }
  1719. oldValue, err := m.oldValue(ctx)
  1720. if err != nil {
  1721. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  1722. }
  1723. return oldValue.Examples, nil
  1724. }
  1725. // ClearExamples clears the value of the "examples" field.
  1726. func (m *AgentMutation) ClearExamples() {
  1727. m.examples = nil
  1728. m.clearedFields[agent.FieldExamples] = struct{}{}
  1729. }
  1730. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  1731. func (m *AgentMutation) ExamplesCleared() bool {
  1732. _, ok := m.clearedFields[agent.FieldExamples]
  1733. return ok
  1734. }
  1735. // ResetExamples resets all changes to the "examples" field.
  1736. func (m *AgentMutation) ResetExamples() {
  1737. m.examples = nil
  1738. delete(m.clearedFields, agent.FieldExamples)
  1739. }
  1740. // SetOrganizationID sets the "organization_id" field.
  1741. func (m *AgentMutation) SetOrganizationID(u uint64) {
  1742. m.organization_id = &u
  1743. m.addorganization_id = nil
  1744. }
  1745. // OrganizationID returns the value of the "organization_id" field in the mutation.
  1746. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  1747. v := m.organization_id
  1748. if v == nil {
  1749. return
  1750. }
  1751. return *v, true
  1752. }
  1753. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  1754. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1756. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  1757. if !m.op.Is(OpUpdateOne) {
  1758. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  1759. }
  1760. if m.id == nil || m.oldValue == nil {
  1761. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  1762. }
  1763. oldValue, err := m.oldValue(ctx)
  1764. if err != nil {
  1765. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  1766. }
  1767. return oldValue.OrganizationID, nil
  1768. }
  1769. // AddOrganizationID adds u to the "organization_id" field.
  1770. func (m *AgentMutation) AddOrganizationID(u int64) {
  1771. if m.addorganization_id != nil {
  1772. *m.addorganization_id += u
  1773. } else {
  1774. m.addorganization_id = &u
  1775. }
  1776. }
  1777. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  1778. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  1779. v := m.addorganization_id
  1780. if v == nil {
  1781. return
  1782. }
  1783. return *v, true
  1784. }
  1785. // ResetOrganizationID resets all changes to the "organization_id" field.
  1786. func (m *AgentMutation) ResetOrganizationID() {
  1787. m.organization_id = nil
  1788. m.addorganization_id = nil
  1789. }
  1790. // SetDatasetID sets the "dataset_id" field.
  1791. func (m *AgentMutation) SetDatasetID(s string) {
  1792. m.dataset_id = &s
  1793. }
  1794. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1795. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  1796. v := m.dataset_id
  1797. if v == nil {
  1798. return
  1799. }
  1800. return *v, true
  1801. }
  1802. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  1803. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1805. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1806. if !m.op.Is(OpUpdateOne) {
  1807. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1808. }
  1809. if m.id == nil || m.oldValue == nil {
  1810. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1811. }
  1812. oldValue, err := m.oldValue(ctx)
  1813. if err != nil {
  1814. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1815. }
  1816. return oldValue.DatasetID, nil
  1817. }
  1818. // ResetDatasetID resets all changes to the "dataset_id" field.
  1819. func (m *AgentMutation) ResetDatasetID() {
  1820. m.dataset_id = nil
  1821. }
  1822. // SetCollectionID sets the "collection_id" field.
  1823. func (m *AgentMutation) SetCollectionID(s string) {
  1824. m.collection_id = &s
  1825. }
  1826. // CollectionID returns the value of the "collection_id" field in the mutation.
  1827. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  1828. v := m.collection_id
  1829. if v == nil {
  1830. return
  1831. }
  1832. return *v, true
  1833. }
  1834. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  1835. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1837. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1838. if !m.op.Is(OpUpdateOne) {
  1839. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1840. }
  1841. if m.id == nil || m.oldValue == nil {
  1842. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1843. }
  1844. oldValue, err := m.oldValue(ctx)
  1845. if err != nil {
  1846. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1847. }
  1848. return oldValue.CollectionID, nil
  1849. }
  1850. // ResetCollectionID resets all changes to the "collection_id" field.
  1851. func (m *AgentMutation) ResetCollectionID() {
  1852. m.collection_id = nil
  1853. }
  1854. // SetModel sets the "model" field.
  1855. func (m *AgentMutation) SetModel(s string) {
  1856. m.model = &s
  1857. }
  1858. // Model returns the value of the "model" field in the mutation.
  1859. func (m *AgentMutation) Model() (r string, exists bool) {
  1860. v := m.model
  1861. if v == nil {
  1862. return
  1863. }
  1864. return *v, true
  1865. }
  1866. // OldModel returns the old "model" field's value of the Agent entity.
  1867. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1869. func (m *AgentMutation) OldModel(ctx context.Context) (v string, err error) {
  1870. if !m.op.Is(OpUpdateOne) {
  1871. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  1872. }
  1873. if m.id == nil || m.oldValue == nil {
  1874. return v, errors.New("OldModel requires an ID field in the mutation")
  1875. }
  1876. oldValue, err := m.oldValue(ctx)
  1877. if err != nil {
  1878. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  1879. }
  1880. return oldValue.Model, nil
  1881. }
  1882. // ClearModel clears the value of the "model" field.
  1883. func (m *AgentMutation) ClearModel() {
  1884. m.model = nil
  1885. m.clearedFields[agent.FieldModel] = struct{}{}
  1886. }
  1887. // ModelCleared returns if the "model" field was cleared in this mutation.
  1888. func (m *AgentMutation) ModelCleared() bool {
  1889. _, ok := m.clearedFields[agent.FieldModel]
  1890. return ok
  1891. }
  1892. // ResetModel resets all changes to the "model" field.
  1893. func (m *AgentMutation) ResetModel() {
  1894. m.model = nil
  1895. delete(m.clearedFields, agent.FieldModel)
  1896. }
  1897. // SetAPIBase sets the "api_base" field.
  1898. func (m *AgentMutation) SetAPIBase(s string) {
  1899. m.api_base = &s
  1900. }
  1901. // APIBase returns the value of the "api_base" field in the mutation.
  1902. func (m *AgentMutation) APIBase() (r string, exists bool) {
  1903. v := m.api_base
  1904. if v == nil {
  1905. return
  1906. }
  1907. return *v, true
  1908. }
  1909. // OldAPIBase returns the old "api_base" field's value of the Agent entity.
  1910. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1912. func (m *AgentMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  1913. if !m.op.Is(OpUpdateOne) {
  1914. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  1915. }
  1916. if m.id == nil || m.oldValue == nil {
  1917. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  1918. }
  1919. oldValue, err := m.oldValue(ctx)
  1920. if err != nil {
  1921. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  1922. }
  1923. return oldValue.APIBase, nil
  1924. }
  1925. // ClearAPIBase clears the value of the "api_base" field.
  1926. func (m *AgentMutation) ClearAPIBase() {
  1927. m.api_base = nil
  1928. m.clearedFields[agent.FieldAPIBase] = struct{}{}
  1929. }
  1930. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  1931. func (m *AgentMutation) APIBaseCleared() bool {
  1932. _, ok := m.clearedFields[agent.FieldAPIBase]
  1933. return ok
  1934. }
  1935. // ResetAPIBase resets all changes to the "api_base" field.
  1936. func (m *AgentMutation) ResetAPIBase() {
  1937. m.api_base = nil
  1938. delete(m.clearedFields, agent.FieldAPIBase)
  1939. }
  1940. // SetAPIKey sets the "api_key" field.
  1941. func (m *AgentMutation) SetAPIKey(s string) {
  1942. m.api_key = &s
  1943. }
  1944. // APIKey returns the value of the "api_key" field in the mutation.
  1945. func (m *AgentMutation) APIKey() (r string, exists bool) {
  1946. v := m.api_key
  1947. if v == nil {
  1948. return
  1949. }
  1950. return *v, true
  1951. }
  1952. // OldAPIKey returns the old "api_key" field's value of the Agent entity.
  1953. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1955. func (m *AgentMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  1956. if !m.op.Is(OpUpdateOne) {
  1957. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  1958. }
  1959. if m.id == nil || m.oldValue == nil {
  1960. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  1961. }
  1962. oldValue, err := m.oldValue(ctx)
  1963. if err != nil {
  1964. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  1965. }
  1966. return oldValue.APIKey, nil
  1967. }
  1968. // ClearAPIKey clears the value of the "api_key" field.
  1969. func (m *AgentMutation) ClearAPIKey() {
  1970. m.api_key = nil
  1971. m.clearedFields[agent.FieldAPIKey] = struct{}{}
  1972. }
  1973. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  1974. func (m *AgentMutation) APIKeyCleared() bool {
  1975. _, ok := m.clearedFields[agent.FieldAPIKey]
  1976. return ok
  1977. }
  1978. // ResetAPIKey resets all changes to the "api_key" field.
  1979. func (m *AgentMutation) ResetAPIKey() {
  1980. m.api_key = nil
  1981. delete(m.clearedFields, agent.FieldAPIKey)
  1982. }
  1983. // SetType sets the "type" field.
  1984. func (m *AgentMutation) SetType(i int) {
  1985. m._type = &i
  1986. m.add_type = nil
  1987. }
  1988. // GetType returns the value of the "type" field in the mutation.
  1989. func (m *AgentMutation) GetType() (r int, exists bool) {
  1990. v := m._type
  1991. if v == nil {
  1992. return
  1993. }
  1994. return *v, true
  1995. }
  1996. // OldType returns the old "type" field's value of the Agent entity.
  1997. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  1998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1999. func (m *AgentMutation) OldType(ctx context.Context) (v int, err error) {
  2000. if !m.op.Is(OpUpdateOne) {
  2001. return v, errors.New("OldType is only allowed on UpdateOne operations")
  2002. }
  2003. if m.id == nil || m.oldValue == nil {
  2004. return v, errors.New("OldType requires an ID field in the mutation")
  2005. }
  2006. oldValue, err := m.oldValue(ctx)
  2007. if err != nil {
  2008. return v, fmt.Errorf("querying old value for OldType: %w", err)
  2009. }
  2010. return oldValue.Type, nil
  2011. }
  2012. // AddType adds i to the "type" field.
  2013. func (m *AgentMutation) AddType(i int) {
  2014. if m.add_type != nil {
  2015. *m.add_type += i
  2016. } else {
  2017. m.add_type = &i
  2018. }
  2019. }
  2020. // AddedType returns the value that was added to the "type" field in this mutation.
  2021. func (m *AgentMutation) AddedType() (r int, exists bool) {
  2022. v := m.add_type
  2023. if v == nil {
  2024. return
  2025. }
  2026. return *v, true
  2027. }
  2028. // ClearType clears the value of the "type" field.
  2029. func (m *AgentMutation) ClearType() {
  2030. m._type = nil
  2031. m.add_type = nil
  2032. m.clearedFields[agent.FieldType] = struct{}{}
  2033. }
  2034. // TypeCleared returns if the "type" field was cleared in this mutation.
  2035. func (m *AgentMutation) TypeCleared() bool {
  2036. _, ok := m.clearedFields[agent.FieldType]
  2037. return ok
  2038. }
  2039. // ResetType resets all changes to the "type" field.
  2040. func (m *AgentMutation) ResetType() {
  2041. m._type = nil
  2042. m.add_type = nil
  2043. delete(m.clearedFields, agent.FieldType)
  2044. }
  2045. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  2046. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  2047. if m.wx_agent == nil {
  2048. m.wx_agent = make(map[uint64]struct{})
  2049. }
  2050. for i := range ids {
  2051. m.wx_agent[ids[i]] = struct{}{}
  2052. }
  2053. }
  2054. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  2055. func (m *AgentMutation) ClearWxAgent() {
  2056. m.clearedwx_agent = true
  2057. }
  2058. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  2059. func (m *AgentMutation) WxAgentCleared() bool {
  2060. return m.clearedwx_agent
  2061. }
  2062. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  2063. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  2064. if m.removedwx_agent == nil {
  2065. m.removedwx_agent = make(map[uint64]struct{})
  2066. }
  2067. for i := range ids {
  2068. delete(m.wx_agent, ids[i])
  2069. m.removedwx_agent[ids[i]] = struct{}{}
  2070. }
  2071. }
  2072. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  2073. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  2074. for id := range m.removedwx_agent {
  2075. ids = append(ids, id)
  2076. }
  2077. return
  2078. }
  2079. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  2080. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  2081. for id := range m.wx_agent {
  2082. ids = append(ids, id)
  2083. }
  2084. return
  2085. }
  2086. // ResetWxAgent resets all changes to the "wx_agent" edge.
  2087. func (m *AgentMutation) ResetWxAgent() {
  2088. m.wx_agent = nil
  2089. m.clearedwx_agent = false
  2090. m.removedwx_agent = nil
  2091. }
  2092. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  2093. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  2094. if m.token_agent == nil {
  2095. m.token_agent = make(map[uint64]struct{})
  2096. }
  2097. for i := range ids {
  2098. m.token_agent[ids[i]] = struct{}{}
  2099. }
  2100. }
  2101. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  2102. func (m *AgentMutation) ClearTokenAgent() {
  2103. m.clearedtoken_agent = true
  2104. }
  2105. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  2106. func (m *AgentMutation) TokenAgentCleared() bool {
  2107. return m.clearedtoken_agent
  2108. }
  2109. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  2110. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  2111. if m.removedtoken_agent == nil {
  2112. m.removedtoken_agent = make(map[uint64]struct{})
  2113. }
  2114. for i := range ids {
  2115. delete(m.token_agent, ids[i])
  2116. m.removedtoken_agent[ids[i]] = struct{}{}
  2117. }
  2118. }
  2119. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  2120. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  2121. for id := range m.removedtoken_agent {
  2122. ids = append(ids, id)
  2123. }
  2124. return
  2125. }
  2126. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  2127. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  2128. for id := range m.token_agent {
  2129. ids = append(ids, id)
  2130. }
  2131. return
  2132. }
  2133. // ResetTokenAgent resets all changes to the "token_agent" edge.
  2134. func (m *AgentMutation) ResetTokenAgent() {
  2135. m.token_agent = nil
  2136. m.clearedtoken_agent = false
  2137. m.removedtoken_agent = nil
  2138. }
  2139. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  2140. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  2141. if m.wa_agent == nil {
  2142. m.wa_agent = make(map[uint64]struct{})
  2143. }
  2144. for i := range ids {
  2145. m.wa_agent[ids[i]] = struct{}{}
  2146. }
  2147. }
  2148. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  2149. func (m *AgentMutation) ClearWaAgent() {
  2150. m.clearedwa_agent = true
  2151. }
  2152. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  2153. func (m *AgentMutation) WaAgentCleared() bool {
  2154. return m.clearedwa_agent
  2155. }
  2156. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  2157. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  2158. if m.removedwa_agent == nil {
  2159. m.removedwa_agent = make(map[uint64]struct{})
  2160. }
  2161. for i := range ids {
  2162. delete(m.wa_agent, ids[i])
  2163. m.removedwa_agent[ids[i]] = struct{}{}
  2164. }
  2165. }
  2166. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  2167. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  2168. for id := range m.removedwa_agent {
  2169. ids = append(ids, id)
  2170. }
  2171. return
  2172. }
  2173. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  2174. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  2175. for id := range m.wa_agent {
  2176. ids = append(ids, id)
  2177. }
  2178. return
  2179. }
  2180. // ResetWaAgent resets all changes to the "wa_agent" edge.
  2181. func (m *AgentMutation) ResetWaAgent() {
  2182. m.wa_agent = nil
  2183. m.clearedwa_agent = false
  2184. m.removedwa_agent = nil
  2185. }
  2186. // AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
  2187. func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
  2188. if m.xjs_agent == nil {
  2189. m.xjs_agent = make(map[uint64]struct{})
  2190. }
  2191. for i := range ids {
  2192. m.xjs_agent[ids[i]] = struct{}{}
  2193. }
  2194. }
  2195. // ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
  2196. func (m *AgentMutation) ClearXjsAgent() {
  2197. m.clearedxjs_agent = true
  2198. }
  2199. // XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
  2200. func (m *AgentMutation) XjsAgentCleared() bool {
  2201. return m.clearedxjs_agent
  2202. }
  2203. // RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
  2204. func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
  2205. if m.removedxjs_agent == nil {
  2206. m.removedxjs_agent = make(map[uint64]struct{})
  2207. }
  2208. for i := range ids {
  2209. delete(m.xjs_agent, ids[i])
  2210. m.removedxjs_agent[ids[i]] = struct{}{}
  2211. }
  2212. }
  2213. // RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
  2214. func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
  2215. for id := range m.removedxjs_agent {
  2216. ids = append(ids, id)
  2217. }
  2218. return
  2219. }
  2220. // XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
  2221. func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
  2222. for id := range m.xjs_agent {
  2223. ids = append(ids, id)
  2224. }
  2225. return
  2226. }
  2227. // ResetXjsAgent resets all changes to the "xjs_agent" edge.
  2228. func (m *AgentMutation) ResetXjsAgent() {
  2229. m.xjs_agent = nil
  2230. m.clearedxjs_agent = false
  2231. m.removedxjs_agent = nil
  2232. }
  2233. // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
  2234. func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
  2235. if m.key_agent == nil {
  2236. m.key_agent = make(map[uint64]struct{})
  2237. }
  2238. for i := range ids {
  2239. m.key_agent[ids[i]] = struct{}{}
  2240. }
  2241. }
  2242. // ClearKeyAgent clears the "key_agent" edge to the ApiKey entity.
  2243. func (m *AgentMutation) ClearKeyAgent() {
  2244. m.clearedkey_agent = true
  2245. }
  2246. // KeyAgentCleared reports if the "key_agent" edge to the ApiKey entity was cleared.
  2247. func (m *AgentMutation) KeyAgentCleared() bool {
  2248. return m.clearedkey_agent
  2249. }
  2250. // RemoveKeyAgentIDs removes the "key_agent" edge to the ApiKey entity by IDs.
  2251. func (m *AgentMutation) RemoveKeyAgentIDs(ids ...uint64) {
  2252. if m.removedkey_agent == nil {
  2253. m.removedkey_agent = make(map[uint64]struct{})
  2254. }
  2255. for i := range ids {
  2256. delete(m.key_agent, ids[i])
  2257. m.removedkey_agent[ids[i]] = struct{}{}
  2258. }
  2259. }
  2260. // RemovedKeyAgent returns the removed IDs of the "key_agent" edge to the ApiKey entity.
  2261. func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
  2262. for id := range m.removedkey_agent {
  2263. ids = append(ids, id)
  2264. }
  2265. return
  2266. }
  2267. // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
  2268. func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
  2269. for id := range m.key_agent {
  2270. ids = append(ids, id)
  2271. }
  2272. return
  2273. }
  2274. // ResetKeyAgent resets all changes to the "key_agent" edge.
  2275. func (m *AgentMutation) ResetKeyAgent() {
  2276. m.key_agent = nil
  2277. m.clearedkey_agent = false
  2278. m.removedkey_agent = nil
  2279. }
  2280. // Where appends a list predicates to the AgentMutation builder.
  2281. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  2282. m.predicates = append(m.predicates, ps...)
  2283. }
  2284. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  2285. // users can use type-assertion to append predicates that do not depend on any generated package.
  2286. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  2287. p := make([]predicate.Agent, len(ps))
  2288. for i := range ps {
  2289. p[i] = ps[i]
  2290. }
  2291. m.Where(p...)
  2292. }
  2293. // Op returns the operation name.
  2294. func (m *AgentMutation) Op() Op {
  2295. return m.op
  2296. }
  2297. // SetOp allows setting the mutation operation.
  2298. func (m *AgentMutation) SetOp(op Op) {
  2299. m.op = op
  2300. }
  2301. // Type returns the node type of this mutation (Agent).
  2302. func (m *AgentMutation) Type() string {
  2303. return m.typ
  2304. }
  2305. // Fields returns all fields that were changed during this mutation. Note that in
  2306. // order to get all numeric fields that were incremented/decremented, call
  2307. // AddedFields().
  2308. func (m *AgentMutation) Fields() []string {
  2309. fields := make([]string, 0, 15)
  2310. if m.created_at != nil {
  2311. fields = append(fields, agent.FieldCreatedAt)
  2312. }
  2313. if m.updated_at != nil {
  2314. fields = append(fields, agent.FieldUpdatedAt)
  2315. }
  2316. if m.deleted_at != nil {
  2317. fields = append(fields, agent.FieldDeletedAt)
  2318. }
  2319. if m.name != nil {
  2320. fields = append(fields, agent.FieldName)
  2321. }
  2322. if m.role != nil {
  2323. fields = append(fields, agent.FieldRole)
  2324. }
  2325. if m.status != nil {
  2326. fields = append(fields, agent.FieldStatus)
  2327. }
  2328. if m.background != nil {
  2329. fields = append(fields, agent.FieldBackground)
  2330. }
  2331. if m.examples != nil {
  2332. fields = append(fields, agent.FieldExamples)
  2333. }
  2334. if m.organization_id != nil {
  2335. fields = append(fields, agent.FieldOrganizationID)
  2336. }
  2337. if m.dataset_id != nil {
  2338. fields = append(fields, agent.FieldDatasetID)
  2339. }
  2340. if m.collection_id != nil {
  2341. fields = append(fields, agent.FieldCollectionID)
  2342. }
  2343. if m.model != nil {
  2344. fields = append(fields, agent.FieldModel)
  2345. }
  2346. if m.api_base != nil {
  2347. fields = append(fields, agent.FieldAPIBase)
  2348. }
  2349. if m.api_key != nil {
  2350. fields = append(fields, agent.FieldAPIKey)
  2351. }
  2352. if m._type != nil {
  2353. fields = append(fields, agent.FieldType)
  2354. }
  2355. return fields
  2356. }
  2357. // Field returns the value of a field with the given name. The second boolean
  2358. // return value indicates that this field was not set, or was not defined in the
  2359. // schema.
  2360. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  2361. switch name {
  2362. case agent.FieldCreatedAt:
  2363. return m.CreatedAt()
  2364. case agent.FieldUpdatedAt:
  2365. return m.UpdatedAt()
  2366. case agent.FieldDeletedAt:
  2367. return m.DeletedAt()
  2368. case agent.FieldName:
  2369. return m.Name()
  2370. case agent.FieldRole:
  2371. return m.Role()
  2372. case agent.FieldStatus:
  2373. return m.Status()
  2374. case agent.FieldBackground:
  2375. return m.Background()
  2376. case agent.FieldExamples:
  2377. return m.Examples()
  2378. case agent.FieldOrganizationID:
  2379. return m.OrganizationID()
  2380. case agent.FieldDatasetID:
  2381. return m.DatasetID()
  2382. case agent.FieldCollectionID:
  2383. return m.CollectionID()
  2384. case agent.FieldModel:
  2385. return m.Model()
  2386. case agent.FieldAPIBase:
  2387. return m.APIBase()
  2388. case agent.FieldAPIKey:
  2389. return m.APIKey()
  2390. case agent.FieldType:
  2391. return m.GetType()
  2392. }
  2393. return nil, false
  2394. }
  2395. // OldField returns the old value of the field from the database. An error is
  2396. // returned if the mutation operation is not UpdateOne, or the query to the
  2397. // database failed.
  2398. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2399. switch name {
  2400. case agent.FieldCreatedAt:
  2401. return m.OldCreatedAt(ctx)
  2402. case agent.FieldUpdatedAt:
  2403. return m.OldUpdatedAt(ctx)
  2404. case agent.FieldDeletedAt:
  2405. return m.OldDeletedAt(ctx)
  2406. case agent.FieldName:
  2407. return m.OldName(ctx)
  2408. case agent.FieldRole:
  2409. return m.OldRole(ctx)
  2410. case agent.FieldStatus:
  2411. return m.OldStatus(ctx)
  2412. case agent.FieldBackground:
  2413. return m.OldBackground(ctx)
  2414. case agent.FieldExamples:
  2415. return m.OldExamples(ctx)
  2416. case agent.FieldOrganizationID:
  2417. return m.OldOrganizationID(ctx)
  2418. case agent.FieldDatasetID:
  2419. return m.OldDatasetID(ctx)
  2420. case agent.FieldCollectionID:
  2421. return m.OldCollectionID(ctx)
  2422. case agent.FieldModel:
  2423. return m.OldModel(ctx)
  2424. case agent.FieldAPIBase:
  2425. return m.OldAPIBase(ctx)
  2426. case agent.FieldAPIKey:
  2427. return m.OldAPIKey(ctx)
  2428. case agent.FieldType:
  2429. return m.OldType(ctx)
  2430. }
  2431. return nil, fmt.Errorf("unknown Agent field %s", name)
  2432. }
  2433. // SetField sets the value of a field with the given name. It returns an error if
  2434. // the field is not defined in the schema, or if the type mismatched the field
  2435. // type.
  2436. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  2437. switch name {
  2438. case agent.FieldCreatedAt:
  2439. v, ok := value.(time.Time)
  2440. if !ok {
  2441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2442. }
  2443. m.SetCreatedAt(v)
  2444. return nil
  2445. case agent.FieldUpdatedAt:
  2446. v, ok := value.(time.Time)
  2447. if !ok {
  2448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2449. }
  2450. m.SetUpdatedAt(v)
  2451. return nil
  2452. case agent.FieldDeletedAt:
  2453. v, ok := value.(time.Time)
  2454. if !ok {
  2455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2456. }
  2457. m.SetDeletedAt(v)
  2458. return nil
  2459. case agent.FieldName:
  2460. v, ok := value.(string)
  2461. if !ok {
  2462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2463. }
  2464. m.SetName(v)
  2465. return nil
  2466. case agent.FieldRole:
  2467. v, ok := value.(string)
  2468. if !ok {
  2469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2470. }
  2471. m.SetRole(v)
  2472. return nil
  2473. case agent.FieldStatus:
  2474. v, ok := value.(int)
  2475. if !ok {
  2476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2477. }
  2478. m.SetStatus(v)
  2479. return nil
  2480. case agent.FieldBackground:
  2481. v, ok := value.(string)
  2482. if !ok {
  2483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2484. }
  2485. m.SetBackground(v)
  2486. return nil
  2487. case agent.FieldExamples:
  2488. v, ok := value.(string)
  2489. if !ok {
  2490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2491. }
  2492. m.SetExamples(v)
  2493. return nil
  2494. case agent.FieldOrganizationID:
  2495. v, ok := value.(uint64)
  2496. if !ok {
  2497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2498. }
  2499. m.SetOrganizationID(v)
  2500. return nil
  2501. case agent.FieldDatasetID:
  2502. v, ok := value.(string)
  2503. if !ok {
  2504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2505. }
  2506. m.SetDatasetID(v)
  2507. return nil
  2508. case agent.FieldCollectionID:
  2509. v, ok := value.(string)
  2510. if !ok {
  2511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2512. }
  2513. m.SetCollectionID(v)
  2514. return nil
  2515. case agent.FieldModel:
  2516. v, ok := value.(string)
  2517. if !ok {
  2518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2519. }
  2520. m.SetModel(v)
  2521. return nil
  2522. case agent.FieldAPIBase:
  2523. v, ok := value.(string)
  2524. if !ok {
  2525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2526. }
  2527. m.SetAPIBase(v)
  2528. return nil
  2529. case agent.FieldAPIKey:
  2530. v, ok := value.(string)
  2531. if !ok {
  2532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2533. }
  2534. m.SetAPIKey(v)
  2535. return nil
  2536. case agent.FieldType:
  2537. v, ok := value.(int)
  2538. if !ok {
  2539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2540. }
  2541. m.SetType(v)
  2542. return nil
  2543. }
  2544. return fmt.Errorf("unknown Agent field %s", name)
  2545. }
  2546. // AddedFields returns all numeric fields that were incremented/decremented during
  2547. // this mutation.
  2548. func (m *AgentMutation) AddedFields() []string {
  2549. var fields []string
  2550. if m.addstatus != nil {
  2551. fields = append(fields, agent.FieldStatus)
  2552. }
  2553. if m.addorganization_id != nil {
  2554. fields = append(fields, agent.FieldOrganizationID)
  2555. }
  2556. if m.add_type != nil {
  2557. fields = append(fields, agent.FieldType)
  2558. }
  2559. return fields
  2560. }
  2561. // AddedField returns the numeric value that was incremented/decremented on a field
  2562. // with the given name. The second boolean return value indicates that this field
  2563. // was not set, or was not defined in the schema.
  2564. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  2565. switch name {
  2566. case agent.FieldStatus:
  2567. return m.AddedStatus()
  2568. case agent.FieldOrganizationID:
  2569. return m.AddedOrganizationID()
  2570. case agent.FieldType:
  2571. return m.AddedType()
  2572. }
  2573. return nil, false
  2574. }
  2575. // AddField adds the value to the field with the given name. It returns an error if
  2576. // the field is not defined in the schema, or if the type mismatched the field
  2577. // type.
  2578. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  2579. switch name {
  2580. case agent.FieldStatus:
  2581. v, ok := value.(int)
  2582. if !ok {
  2583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2584. }
  2585. m.AddStatus(v)
  2586. return nil
  2587. case agent.FieldOrganizationID:
  2588. v, ok := value.(int64)
  2589. if !ok {
  2590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2591. }
  2592. m.AddOrganizationID(v)
  2593. return nil
  2594. case agent.FieldType:
  2595. v, ok := value.(int)
  2596. if !ok {
  2597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2598. }
  2599. m.AddType(v)
  2600. return nil
  2601. }
  2602. return fmt.Errorf("unknown Agent numeric field %s", name)
  2603. }
  2604. // ClearedFields returns all nullable fields that were cleared during this
  2605. // mutation.
  2606. func (m *AgentMutation) ClearedFields() []string {
  2607. var fields []string
  2608. if m.FieldCleared(agent.FieldDeletedAt) {
  2609. fields = append(fields, agent.FieldDeletedAt)
  2610. }
  2611. if m.FieldCleared(agent.FieldRole) {
  2612. fields = append(fields, agent.FieldRole)
  2613. }
  2614. if m.FieldCleared(agent.FieldStatus) {
  2615. fields = append(fields, agent.FieldStatus)
  2616. }
  2617. if m.FieldCleared(agent.FieldBackground) {
  2618. fields = append(fields, agent.FieldBackground)
  2619. }
  2620. if m.FieldCleared(agent.FieldExamples) {
  2621. fields = append(fields, agent.FieldExamples)
  2622. }
  2623. if m.FieldCleared(agent.FieldModel) {
  2624. fields = append(fields, agent.FieldModel)
  2625. }
  2626. if m.FieldCleared(agent.FieldAPIBase) {
  2627. fields = append(fields, agent.FieldAPIBase)
  2628. }
  2629. if m.FieldCleared(agent.FieldAPIKey) {
  2630. fields = append(fields, agent.FieldAPIKey)
  2631. }
  2632. if m.FieldCleared(agent.FieldType) {
  2633. fields = append(fields, agent.FieldType)
  2634. }
  2635. return fields
  2636. }
  2637. // FieldCleared returns a boolean indicating if a field with the given name was
  2638. // cleared in this mutation.
  2639. func (m *AgentMutation) FieldCleared(name string) bool {
  2640. _, ok := m.clearedFields[name]
  2641. return ok
  2642. }
  2643. // ClearField clears the value of the field with the given name. It returns an
  2644. // error if the field is not defined in the schema.
  2645. func (m *AgentMutation) ClearField(name string) error {
  2646. switch name {
  2647. case agent.FieldDeletedAt:
  2648. m.ClearDeletedAt()
  2649. return nil
  2650. case agent.FieldRole:
  2651. m.ClearRole()
  2652. return nil
  2653. case agent.FieldStatus:
  2654. m.ClearStatus()
  2655. return nil
  2656. case agent.FieldBackground:
  2657. m.ClearBackground()
  2658. return nil
  2659. case agent.FieldExamples:
  2660. m.ClearExamples()
  2661. return nil
  2662. case agent.FieldModel:
  2663. m.ClearModel()
  2664. return nil
  2665. case agent.FieldAPIBase:
  2666. m.ClearAPIBase()
  2667. return nil
  2668. case agent.FieldAPIKey:
  2669. m.ClearAPIKey()
  2670. return nil
  2671. case agent.FieldType:
  2672. m.ClearType()
  2673. return nil
  2674. }
  2675. return fmt.Errorf("unknown Agent nullable field %s", name)
  2676. }
  2677. // ResetField resets all changes in the mutation for the field with the given name.
  2678. // It returns an error if the field is not defined in the schema.
  2679. func (m *AgentMutation) ResetField(name string) error {
  2680. switch name {
  2681. case agent.FieldCreatedAt:
  2682. m.ResetCreatedAt()
  2683. return nil
  2684. case agent.FieldUpdatedAt:
  2685. m.ResetUpdatedAt()
  2686. return nil
  2687. case agent.FieldDeletedAt:
  2688. m.ResetDeletedAt()
  2689. return nil
  2690. case agent.FieldName:
  2691. m.ResetName()
  2692. return nil
  2693. case agent.FieldRole:
  2694. m.ResetRole()
  2695. return nil
  2696. case agent.FieldStatus:
  2697. m.ResetStatus()
  2698. return nil
  2699. case agent.FieldBackground:
  2700. m.ResetBackground()
  2701. return nil
  2702. case agent.FieldExamples:
  2703. m.ResetExamples()
  2704. return nil
  2705. case agent.FieldOrganizationID:
  2706. m.ResetOrganizationID()
  2707. return nil
  2708. case agent.FieldDatasetID:
  2709. m.ResetDatasetID()
  2710. return nil
  2711. case agent.FieldCollectionID:
  2712. m.ResetCollectionID()
  2713. return nil
  2714. case agent.FieldModel:
  2715. m.ResetModel()
  2716. return nil
  2717. case agent.FieldAPIBase:
  2718. m.ResetAPIBase()
  2719. return nil
  2720. case agent.FieldAPIKey:
  2721. m.ResetAPIKey()
  2722. return nil
  2723. case agent.FieldType:
  2724. m.ResetType()
  2725. return nil
  2726. }
  2727. return fmt.Errorf("unknown Agent field %s", name)
  2728. }
  2729. // AddedEdges returns all edge names that were set/added in this mutation.
  2730. func (m *AgentMutation) AddedEdges() []string {
  2731. edges := make([]string, 0, 5)
  2732. if m.wx_agent != nil {
  2733. edges = append(edges, agent.EdgeWxAgent)
  2734. }
  2735. if m.token_agent != nil {
  2736. edges = append(edges, agent.EdgeTokenAgent)
  2737. }
  2738. if m.wa_agent != nil {
  2739. edges = append(edges, agent.EdgeWaAgent)
  2740. }
  2741. if m.xjs_agent != nil {
  2742. edges = append(edges, agent.EdgeXjsAgent)
  2743. }
  2744. if m.key_agent != nil {
  2745. edges = append(edges, agent.EdgeKeyAgent)
  2746. }
  2747. return edges
  2748. }
  2749. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2750. // name in this mutation.
  2751. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  2752. switch name {
  2753. case agent.EdgeWxAgent:
  2754. ids := make([]ent.Value, 0, len(m.wx_agent))
  2755. for id := range m.wx_agent {
  2756. ids = append(ids, id)
  2757. }
  2758. return ids
  2759. case agent.EdgeTokenAgent:
  2760. ids := make([]ent.Value, 0, len(m.token_agent))
  2761. for id := range m.token_agent {
  2762. ids = append(ids, id)
  2763. }
  2764. return ids
  2765. case agent.EdgeWaAgent:
  2766. ids := make([]ent.Value, 0, len(m.wa_agent))
  2767. for id := range m.wa_agent {
  2768. ids = append(ids, id)
  2769. }
  2770. return ids
  2771. case agent.EdgeXjsAgent:
  2772. ids := make([]ent.Value, 0, len(m.xjs_agent))
  2773. for id := range m.xjs_agent {
  2774. ids = append(ids, id)
  2775. }
  2776. return ids
  2777. case agent.EdgeKeyAgent:
  2778. ids := make([]ent.Value, 0, len(m.key_agent))
  2779. for id := range m.key_agent {
  2780. ids = append(ids, id)
  2781. }
  2782. return ids
  2783. }
  2784. return nil
  2785. }
  2786. // RemovedEdges returns all edge names that were removed in this mutation.
  2787. func (m *AgentMutation) RemovedEdges() []string {
  2788. edges := make([]string, 0, 5)
  2789. if m.removedwx_agent != nil {
  2790. edges = append(edges, agent.EdgeWxAgent)
  2791. }
  2792. if m.removedtoken_agent != nil {
  2793. edges = append(edges, agent.EdgeTokenAgent)
  2794. }
  2795. if m.removedwa_agent != nil {
  2796. edges = append(edges, agent.EdgeWaAgent)
  2797. }
  2798. if m.removedxjs_agent != nil {
  2799. edges = append(edges, agent.EdgeXjsAgent)
  2800. }
  2801. if m.removedkey_agent != nil {
  2802. edges = append(edges, agent.EdgeKeyAgent)
  2803. }
  2804. return edges
  2805. }
  2806. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2807. // the given name in this mutation.
  2808. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  2809. switch name {
  2810. case agent.EdgeWxAgent:
  2811. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2812. for id := range m.removedwx_agent {
  2813. ids = append(ids, id)
  2814. }
  2815. return ids
  2816. case agent.EdgeTokenAgent:
  2817. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  2818. for id := range m.removedtoken_agent {
  2819. ids = append(ids, id)
  2820. }
  2821. return ids
  2822. case agent.EdgeWaAgent:
  2823. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  2824. for id := range m.removedwa_agent {
  2825. ids = append(ids, id)
  2826. }
  2827. return ids
  2828. case agent.EdgeXjsAgent:
  2829. ids := make([]ent.Value, 0, len(m.removedxjs_agent))
  2830. for id := range m.removedxjs_agent {
  2831. ids = append(ids, id)
  2832. }
  2833. return ids
  2834. case agent.EdgeKeyAgent:
  2835. ids := make([]ent.Value, 0, len(m.removedkey_agent))
  2836. for id := range m.removedkey_agent {
  2837. ids = append(ids, id)
  2838. }
  2839. return ids
  2840. }
  2841. return nil
  2842. }
  2843. // ClearedEdges returns all edge names that were cleared in this mutation.
  2844. func (m *AgentMutation) ClearedEdges() []string {
  2845. edges := make([]string, 0, 5)
  2846. if m.clearedwx_agent {
  2847. edges = append(edges, agent.EdgeWxAgent)
  2848. }
  2849. if m.clearedtoken_agent {
  2850. edges = append(edges, agent.EdgeTokenAgent)
  2851. }
  2852. if m.clearedwa_agent {
  2853. edges = append(edges, agent.EdgeWaAgent)
  2854. }
  2855. if m.clearedxjs_agent {
  2856. edges = append(edges, agent.EdgeXjsAgent)
  2857. }
  2858. if m.clearedkey_agent {
  2859. edges = append(edges, agent.EdgeKeyAgent)
  2860. }
  2861. return edges
  2862. }
  2863. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2864. // was cleared in this mutation.
  2865. func (m *AgentMutation) EdgeCleared(name string) bool {
  2866. switch name {
  2867. case agent.EdgeWxAgent:
  2868. return m.clearedwx_agent
  2869. case agent.EdgeTokenAgent:
  2870. return m.clearedtoken_agent
  2871. case agent.EdgeWaAgent:
  2872. return m.clearedwa_agent
  2873. case agent.EdgeXjsAgent:
  2874. return m.clearedxjs_agent
  2875. case agent.EdgeKeyAgent:
  2876. return m.clearedkey_agent
  2877. }
  2878. return false
  2879. }
  2880. // ClearEdge clears the value of the edge with the given name. It returns an error
  2881. // if that edge is not defined in the schema.
  2882. func (m *AgentMutation) ClearEdge(name string) error {
  2883. switch name {
  2884. }
  2885. return fmt.Errorf("unknown Agent unique edge %s", name)
  2886. }
  2887. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2888. // It returns an error if the edge is not defined in the schema.
  2889. func (m *AgentMutation) ResetEdge(name string) error {
  2890. switch name {
  2891. case agent.EdgeWxAgent:
  2892. m.ResetWxAgent()
  2893. return nil
  2894. case agent.EdgeTokenAgent:
  2895. m.ResetTokenAgent()
  2896. return nil
  2897. case agent.EdgeWaAgent:
  2898. m.ResetWaAgent()
  2899. return nil
  2900. case agent.EdgeXjsAgent:
  2901. m.ResetXjsAgent()
  2902. return nil
  2903. case agent.EdgeKeyAgent:
  2904. m.ResetKeyAgent()
  2905. return nil
  2906. }
  2907. return fmt.Errorf("unknown Agent edge %s", name)
  2908. }
  2909. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  2910. type AgentBaseMutation struct {
  2911. config
  2912. op Op
  2913. typ string
  2914. id *string
  2915. q *string
  2916. a *string
  2917. chunk_index *uint64
  2918. addchunk_index *int64
  2919. indexes *[]string
  2920. appendindexes []string
  2921. dataset_id *string
  2922. collection_id *string
  2923. source_name *string
  2924. can_write *[]bool
  2925. appendcan_write []bool
  2926. is_owner *[]bool
  2927. appendis_owner []bool
  2928. clearedFields map[string]struct{}
  2929. wx_agent map[uint64]struct{}
  2930. removedwx_agent map[uint64]struct{}
  2931. clearedwx_agent bool
  2932. done bool
  2933. oldValue func(context.Context) (*AgentBase, error)
  2934. predicates []predicate.AgentBase
  2935. }
  2936. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  2937. // agentbaseOption allows management of the mutation configuration using functional options.
  2938. type agentbaseOption func(*AgentBaseMutation)
  2939. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  2940. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  2941. m := &AgentBaseMutation{
  2942. config: c,
  2943. op: op,
  2944. typ: TypeAgentBase,
  2945. clearedFields: make(map[string]struct{}),
  2946. }
  2947. for _, opt := range opts {
  2948. opt(m)
  2949. }
  2950. return m
  2951. }
  2952. // withAgentBaseID sets the ID field of the mutation.
  2953. func withAgentBaseID(id string) agentbaseOption {
  2954. return func(m *AgentBaseMutation) {
  2955. var (
  2956. err error
  2957. once sync.Once
  2958. value *AgentBase
  2959. )
  2960. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  2961. once.Do(func() {
  2962. if m.done {
  2963. err = errors.New("querying old values post mutation is not allowed")
  2964. } else {
  2965. value, err = m.Client().AgentBase.Get(ctx, id)
  2966. }
  2967. })
  2968. return value, err
  2969. }
  2970. m.id = &id
  2971. }
  2972. }
  2973. // withAgentBase sets the old AgentBase of the mutation.
  2974. func withAgentBase(node *AgentBase) agentbaseOption {
  2975. return func(m *AgentBaseMutation) {
  2976. m.oldValue = func(context.Context) (*AgentBase, error) {
  2977. return node, nil
  2978. }
  2979. m.id = &node.ID
  2980. }
  2981. }
  2982. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2983. // executed in a transaction (ent.Tx), a transactional client is returned.
  2984. func (m AgentBaseMutation) Client() *Client {
  2985. client := &Client{config: m.config}
  2986. client.init()
  2987. return client
  2988. }
  2989. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2990. // it returns an error otherwise.
  2991. func (m AgentBaseMutation) Tx() (*Tx, error) {
  2992. if _, ok := m.driver.(*txDriver); !ok {
  2993. return nil, errors.New("ent: mutation is not running in a transaction")
  2994. }
  2995. tx := &Tx{config: m.config}
  2996. tx.init()
  2997. return tx, nil
  2998. }
  2999. // SetID sets the value of the id field. Note that this
  3000. // operation is only accepted on creation of AgentBase entities.
  3001. func (m *AgentBaseMutation) SetID(id string) {
  3002. m.id = &id
  3003. }
  3004. // ID returns the ID value in the mutation. Note that the ID is only available
  3005. // if it was provided to the builder or after it was returned from the database.
  3006. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  3007. if m.id == nil {
  3008. return
  3009. }
  3010. return *m.id, true
  3011. }
  3012. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3013. // That means, if the mutation is applied within a transaction with an isolation level such
  3014. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3015. // or updated by the mutation.
  3016. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  3017. switch {
  3018. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3019. id, exists := m.ID()
  3020. if exists {
  3021. return []string{id}, nil
  3022. }
  3023. fallthrough
  3024. case m.op.Is(OpUpdate | OpDelete):
  3025. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  3026. default:
  3027. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3028. }
  3029. }
  3030. // SetQ sets the "q" field.
  3031. func (m *AgentBaseMutation) SetQ(s string) {
  3032. m.q = &s
  3033. }
  3034. // Q returns the value of the "q" field in the mutation.
  3035. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  3036. v := m.q
  3037. if v == nil {
  3038. return
  3039. }
  3040. return *v, true
  3041. }
  3042. // OldQ returns the old "q" field's value of the AgentBase entity.
  3043. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3045. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  3046. if !m.op.Is(OpUpdateOne) {
  3047. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  3048. }
  3049. if m.id == nil || m.oldValue == nil {
  3050. return v, errors.New("OldQ requires an ID field in the mutation")
  3051. }
  3052. oldValue, err := m.oldValue(ctx)
  3053. if err != nil {
  3054. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  3055. }
  3056. return oldValue.Q, nil
  3057. }
  3058. // ClearQ clears the value of the "q" field.
  3059. func (m *AgentBaseMutation) ClearQ() {
  3060. m.q = nil
  3061. m.clearedFields[agentbase.FieldQ] = struct{}{}
  3062. }
  3063. // QCleared returns if the "q" field was cleared in this mutation.
  3064. func (m *AgentBaseMutation) QCleared() bool {
  3065. _, ok := m.clearedFields[agentbase.FieldQ]
  3066. return ok
  3067. }
  3068. // ResetQ resets all changes to the "q" field.
  3069. func (m *AgentBaseMutation) ResetQ() {
  3070. m.q = nil
  3071. delete(m.clearedFields, agentbase.FieldQ)
  3072. }
  3073. // SetA sets the "a" field.
  3074. func (m *AgentBaseMutation) SetA(s string) {
  3075. m.a = &s
  3076. }
  3077. // A returns the value of the "a" field in the mutation.
  3078. func (m *AgentBaseMutation) A() (r string, exists bool) {
  3079. v := m.a
  3080. if v == nil {
  3081. return
  3082. }
  3083. return *v, true
  3084. }
  3085. // OldA returns the old "a" field's value of the AgentBase entity.
  3086. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3088. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  3089. if !m.op.Is(OpUpdateOne) {
  3090. return v, errors.New("OldA is only allowed on UpdateOne operations")
  3091. }
  3092. if m.id == nil || m.oldValue == nil {
  3093. return v, errors.New("OldA requires an ID field in the mutation")
  3094. }
  3095. oldValue, err := m.oldValue(ctx)
  3096. if err != nil {
  3097. return v, fmt.Errorf("querying old value for OldA: %w", err)
  3098. }
  3099. return oldValue.A, nil
  3100. }
  3101. // ClearA clears the value of the "a" field.
  3102. func (m *AgentBaseMutation) ClearA() {
  3103. m.a = nil
  3104. m.clearedFields[agentbase.FieldA] = struct{}{}
  3105. }
  3106. // ACleared returns if the "a" field was cleared in this mutation.
  3107. func (m *AgentBaseMutation) ACleared() bool {
  3108. _, ok := m.clearedFields[agentbase.FieldA]
  3109. return ok
  3110. }
  3111. // ResetA resets all changes to the "a" field.
  3112. func (m *AgentBaseMutation) ResetA() {
  3113. m.a = nil
  3114. delete(m.clearedFields, agentbase.FieldA)
  3115. }
  3116. // SetChunkIndex sets the "chunk_index" field.
  3117. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  3118. m.chunk_index = &u
  3119. m.addchunk_index = nil
  3120. }
  3121. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  3122. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  3123. v := m.chunk_index
  3124. if v == nil {
  3125. return
  3126. }
  3127. return *v, true
  3128. }
  3129. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  3130. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3132. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  3133. if !m.op.Is(OpUpdateOne) {
  3134. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  3135. }
  3136. if m.id == nil || m.oldValue == nil {
  3137. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  3138. }
  3139. oldValue, err := m.oldValue(ctx)
  3140. if err != nil {
  3141. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  3142. }
  3143. return oldValue.ChunkIndex, nil
  3144. }
  3145. // AddChunkIndex adds u to the "chunk_index" field.
  3146. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  3147. if m.addchunk_index != nil {
  3148. *m.addchunk_index += u
  3149. } else {
  3150. m.addchunk_index = &u
  3151. }
  3152. }
  3153. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  3154. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  3155. v := m.addchunk_index
  3156. if v == nil {
  3157. return
  3158. }
  3159. return *v, true
  3160. }
  3161. // ResetChunkIndex resets all changes to the "chunk_index" field.
  3162. func (m *AgentBaseMutation) ResetChunkIndex() {
  3163. m.chunk_index = nil
  3164. m.addchunk_index = nil
  3165. }
  3166. // SetIndexes sets the "indexes" field.
  3167. func (m *AgentBaseMutation) SetIndexes(s []string) {
  3168. m.indexes = &s
  3169. m.appendindexes = nil
  3170. }
  3171. // Indexes returns the value of the "indexes" field in the mutation.
  3172. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  3173. v := m.indexes
  3174. if v == nil {
  3175. return
  3176. }
  3177. return *v, true
  3178. }
  3179. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  3180. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3182. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  3183. if !m.op.Is(OpUpdateOne) {
  3184. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  3185. }
  3186. if m.id == nil || m.oldValue == nil {
  3187. return v, errors.New("OldIndexes requires an ID field in the mutation")
  3188. }
  3189. oldValue, err := m.oldValue(ctx)
  3190. if err != nil {
  3191. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  3192. }
  3193. return oldValue.Indexes, nil
  3194. }
  3195. // AppendIndexes adds s to the "indexes" field.
  3196. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  3197. m.appendindexes = append(m.appendindexes, s...)
  3198. }
  3199. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  3200. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  3201. if len(m.appendindexes) == 0 {
  3202. return nil, false
  3203. }
  3204. return m.appendindexes, true
  3205. }
  3206. // ClearIndexes clears the value of the "indexes" field.
  3207. func (m *AgentBaseMutation) ClearIndexes() {
  3208. m.indexes = nil
  3209. m.appendindexes = nil
  3210. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  3211. }
  3212. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  3213. func (m *AgentBaseMutation) IndexesCleared() bool {
  3214. _, ok := m.clearedFields[agentbase.FieldIndexes]
  3215. return ok
  3216. }
  3217. // ResetIndexes resets all changes to the "indexes" field.
  3218. func (m *AgentBaseMutation) ResetIndexes() {
  3219. m.indexes = nil
  3220. m.appendindexes = nil
  3221. delete(m.clearedFields, agentbase.FieldIndexes)
  3222. }
  3223. // SetDatasetID sets the "dataset_id" field.
  3224. func (m *AgentBaseMutation) SetDatasetID(s string) {
  3225. m.dataset_id = &s
  3226. }
  3227. // DatasetID returns the value of the "dataset_id" field in the mutation.
  3228. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  3229. v := m.dataset_id
  3230. if v == nil {
  3231. return
  3232. }
  3233. return *v, true
  3234. }
  3235. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  3236. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3238. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  3239. if !m.op.Is(OpUpdateOne) {
  3240. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  3241. }
  3242. if m.id == nil || m.oldValue == nil {
  3243. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  3244. }
  3245. oldValue, err := m.oldValue(ctx)
  3246. if err != nil {
  3247. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  3248. }
  3249. return oldValue.DatasetID, nil
  3250. }
  3251. // ClearDatasetID clears the value of the "dataset_id" field.
  3252. func (m *AgentBaseMutation) ClearDatasetID() {
  3253. m.dataset_id = nil
  3254. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  3255. }
  3256. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  3257. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  3258. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  3259. return ok
  3260. }
  3261. // ResetDatasetID resets all changes to the "dataset_id" field.
  3262. func (m *AgentBaseMutation) ResetDatasetID() {
  3263. m.dataset_id = nil
  3264. delete(m.clearedFields, agentbase.FieldDatasetID)
  3265. }
  3266. // SetCollectionID sets the "collection_id" field.
  3267. func (m *AgentBaseMutation) SetCollectionID(s string) {
  3268. m.collection_id = &s
  3269. }
  3270. // CollectionID returns the value of the "collection_id" field in the mutation.
  3271. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  3272. v := m.collection_id
  3273. if v == nil {
  3274. return
  3275. }
  3276. return *v, true
  3277. }
  3278. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  3279. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3281. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  3282. if !m.op.Is(OpUpdateOne) {
  3283. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  3284. }
  3285. if m.id == nil || m.oldValue == nil {
  3286. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  3287. }
  3288. oldValue, err := m.oldValue(ctx)
  3289. if err != nil {
  3290. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  3291. }
  3292. return oldValue.CollectionID, nil
  3293. }
  3294. // ClearCollectionID clears the value of the "collection_id" field.
  3295. func (m *AgentBaseMutation) ClearCollectionID() {
  3296. m.collection_id = nil
  3297. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  3298. }
  3299. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  3300. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  3301. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  3302. return ok
  3303. }
  3304. // ResetCollectionID resets all changes to the "collection_id" field.
  3305. func (m *AgentBaseMutation) ResetCollectionID() {
  3306. m.collection_id = nil
  3307. delete(m.clearedFields, agentbase.FieldCollectionID)
  3308. }
  3309. // SetSourceName sets the "source_name" field.
  3310. func (m *AgentBaseMutation) SetSourceName(s string) {
  3311. m.source_name = &s
  3312. }
  3313. // SourceName returns the value of the "source_name" field in the mutation.
  3314. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  3315. v := m.source_name
  3316. if v == nil {
  3317. return
  3318. }
  3319. return *v, true
  3320. }
  3321. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  3322. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3324. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  3325. if !m.op.Is(OpUpdateOne) {
  3326. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  3327. }
  3328. if m.id == nil || m.oldValue == nil {
  3329. return v, errors.New("OldSourceName requires an ID field in the mutation")
  3330. }
  3331. oldValue, err := m.oldValue(ctx)
  3332. if err != nil {
  3333. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  3334. }
  3335. return oldValue.SourceName, nil
  3336. }
  3337. // ClearSourceName clears the value of the "source_name" field.
  3338. func (m *AgentBaseMutation) ClearSourceName() {
  3339. m.source_name = nil
  3340. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  3341. }
  3342. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  3343. func (m *AgentBaseMutation) SourceNameCleared() bool {
  3344. _, ok := m.clearedFields[agentbase.FieldSourceName]
  3345. return ok
  3346. }
  3347. // ResetSourceName resets all changes to the "source_name" field.
  3348. func (m *AgentBaseMutation) ResetSourceName() {
  3349. m.source_name = nil
  3350. delete(m.clearedFields, agentbase.FieldSourceName)
  3351. }
  3352. // SetCanWrite sets the "can_write" field.
  3353. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  3354. m.can_write = &b
  3355. m.appendcan_write = nil
  3356. }
  3357. // CanWrite returns the value of the "can_write" field in the mutation.
  3358. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  3359. v := m.can_write
  3360. if v == nil {
  3361. return
  3362. }
  3363. return *v, true
  3364. }
  3365. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  3366. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3368. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  3369. if !m.op.Is(OpUpdateOne) {
  3370. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  3371. }
  3372. if m.id == nil || m.oldValue == nil {
  3373. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  3374. }
  3375. oldValue, err := m.oldValue(ctx)
  3376. if err != nil {
  3377. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  3378. }
  3379. return oldValue.CanWrite, nil
  3380. }
  3381. // AppendCanWrite adds b to the "can_write" field.
  3382. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  3383. m.appendcan_write = append(m.appendcan_write, b...)
  3384. }
  3385. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  3386. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  3387. if len(m.appendcan_write) == 0 {
  3388. return nil, false
  3389. }
  3390. return m.appendcan_write, true
  3391. }
  3392. // ClearCanWrite clears the value of the "can_write" field.
  3393. func (m *AgentBaseMutation) ClearCanWrite() {
  3394. m.can_write = nil
  3395. m.appendcan_write = nil
  3396. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  3397. }
  3398. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  3399. func (m *AgentBaseMutation) CanWriteCleared() bool {
  3400. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  3401. return ok
  3402. }
  3403. // ResetCanWrite resets all changes to the "can_write" field.
  3404. func (m *AgentBaseMutation) ResetCanWrite() {
  3405. m.can_write = nil
  3406. m.appendcan_write = nil
  3407. delete(m.clearedFields, agentbase.FieldCanWrite)
  3408. }
  3409. // SetIsOwner sets the "is_owner" field.
  3410. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  3411. m.is_owner = &b
  3412. m.appendis_owner = nil
  3413. }
  3414. // IsOwner returns the value of the "is_owner" field in the mutation.
  3415. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  3416. v := m.is_owner
  3417. if v == nil {
  3418. return
  3419. }
  3420. return *v, true
  3421. }
  3422. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  3423. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  3424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3425. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  3426. if !m.op.Is(OpUpdateOne) {
  3427. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  3428. }
  3429. if m.id == nil || m.oldValue == nil {
  3430. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  3431. }
  3432. oldValue, err := m.oldValue(ctx)
  3433. if err != nil {
  3434. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  3435. }
  3436. return oldValue.IsOwner, nil
  3437. }
  3438. // AppendIsOwner adds b to the "is_owner" field.
  3439. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  3440. m.appendis_owner = append(m.appendis_owner, b...)
  3441. }
  3442. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  3443. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  3444. if len(m.appendis_owner) == 0 {
  3445. return nil, false
  3446. }
  3447. return m.appendis_owner, true
  3448. }
  3449. // ClearIsOwner clears the value of the "is_owner" field.
  3450. func (m *AgentBaseMutation) ClearIsOwner() {
  3451. m.is_owner = nil
  3452. m.appendis_owner = nil
  3453. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  3454. }
  3455. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  3456. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  3457. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  3458. return ok
  3459. }
  3460. // ResetIsOwner resets all changes to the "is_owner" field.
  3461. func (m *AgentBaseMutation) ResetIsOwner() {
  3462. m.is_owner = nil
  3463. m.appendis_owner = nil
  3464. delete(m.clearedFields, agentbase.FieldIsOwner)
  3465. }
  3466. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  3467. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  3468. if m.wx_agent == nil {
  3469. m.wx_agent = make(map[uint64]struct{})
  3470. }
  3471. for i := range ids {
  3472. m.wx_agent[ids[i]] = struct{}{}
  3473. }
  3474. }
  3475. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  3476. func (m *AgentBaseMutation) ClearWxAgent() {
  3477. m.clearedwx_agent = true
  3478. }
  3479. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  3480. func (m *AgentBaseMutation) WxAgentCleared() bool {
  3481. return m.clearedwx_agent
  3482. }
  3483. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  3484. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  3485. if m.removedwx_agent == nil {
  3486. m.removedwx_agent = make(map[uint64]struct{})
  3487. }
  3488. for i := range ids {
  3489. delete(m.wx_agent, ids[i])
  3490. m.removedwx_agent[ids[i]] = struct{}{}
  3491. }
  3492. }
  3493. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  3494. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  3495. for id := range m.removedwx_agent {
  3496. ids = append(ids, id)
  3497. }
  3498. return
  3499. }
  3500. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  3501. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  3502. for id := range m.wx_agent {
  3503. ids = append(ids, id)
  3504. }
  3505. return
  3506. }
  3507. // ResetWxAgent resets all changes to the "wx_agent" edge.
  3508. func (m *AgentBaseMutation) ResetWxAgent() {
  3509. m.wx_agent = nil
  3510. m.clearedwx_agent = false
  3511. m.removedwx_agent = nil
  3512. }
  3513. // Where appends a list predicates to the AgentBaseMutation builder.
  3514. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  3515. m.predicates = append(m.predicates, ps...)
  3516. }
  3517. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  3518. // users can use type-assertion to append predicates that do not depend on any generated package.
  3519. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  3520. p := make([]predicate.AgentBase, len(ps))
  3521. for i := range ps {
  3522. p[i] = ps[i]
  3523. }
  3524. m.Where(p...)
  3525. }
  3526. // Op returns the operation name.
  3527. func (m *AgentBaseMutation) Op() Op {
  3528. return m.op
  3529. }
  3530. // SetOp allows setting the mutation operation.
  3531. func (m *AgentBaseMutation) SetOp(op Op) {
  3532. m.op = op
  3533. }
  3534. // Type returns the node type of this mutation (AgentBase).
  3535. func (m *AgentBaseMutation) Type() string {
  3536. return m.typ
  3537. }
  3538. // Fields returns all fields that were changed during this mutation. Note that in
  3539. // order to get all numeric fields that were incremented/decremented, call
  3540. // AddedFields().
  3541. func (m *AgentBaseMutation) Fields() []string {
  3542. fields := make([]string, 0, 9)
  3543. if m.q != nil {
  3544. fields = append(fields, agentbase.FieldQ)
  3545. }
  3546. if m.a != nil {
  3547. fields = append(fields, agentbase.FieldA)
  3548. }
  3549. if m.chunk_index != nil {
  3550. fields = append(fields, agentbase.FieldChunkIndex)
  3551. }
  3552. if m.indexes != nil {
  3553. fields = append(fields, agentbase.FieldIndexes)
  3554. }
  3555. if m.dataset_id != nil {
  3556. fields = append(fields, agentbase.FieldDatasetID)
  3557. }
  3558. if m.collection_id != nil {
  3559. fields = append(fields, agentbase.FieldCollectionID)
  3560. }
  3561. if m.source_name != nil {
  3562. fields = append(fields, agentbase.FieldSourceName)
  3563. }
  3564. if m.can_write != nil {
  3565. fields = append(fields, agentbase.FieldCanWrite)
  3566. }
  3567. if m.is_owner != nil {
  3568. fields = append(fields, agentbase.FieldIsOwner)
  3569. }
  3570. return fields
  3571. }
  3572. // Field returns the value of a field with the given name. The second boolean
  3573. // return value indicates that this field was not set, or was not defined in the
  3574. // schema.
  3575. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  3576. switch name {
  3577. case agentbase.FieldQ:
  3578. return m.Q()
  3579. case agentbase.FieldA:
  3580. return m.A()
  3581. case agentbase.FieldChunkIndex:
  3582. return m.ChunkIndex()
  3583. case agentbase.FieldIndexes:
  3584. return m.Indexes()
  3585. case agentbase.FieldDatasetID:
  3586. return m.DatasetID()
  3587. case agentbase.FieldCollectionID:
  3588. return m.CollectionID()
  3589. case agentbase.FieldSourceName:
  3590. return m.SourceName()
  3591. case agentbase.FieldCanWrite:
  3592. return m.CanWrite()
  3593. case agentbase.FieldIsOwner:
  3594. return m.IsOwner()
  3595. }
  3596. return nil, false
  3597. }
  3598. // OldField returns the old value of the field from the database. An error is
  3599. // returned if the mutation operation is not UpdateOne, or the query to the
  3600. // database failed.
  3601. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3602. switch name {
  3603. case agentbase.FieldQ:
  3604. return m.OldQ(ctx)
  3605. case agentbase.FieldA:
  3606. return m.OldA(ctx)
  3607. case agentbase.FieldChunkIndex:
  3608. return m.OldChunkIndex(ctx)
  3609. case agentbase.FieldIndexes:
  3610. return m.OldIndexes(ctx)
  3611. case agentbase.FieldDatasetID:
  3612. return m.OldDatasetID(ctx)
  3613. case agentbase.FieldCollectionID:
  3614. return m.OldCollectionID(ctx)
  3615. case agentbase.FieldSourceName:
  3616. return m.OldSourceName(ctx)
  3617. case agentbase.FieldCanWrite:
  3618. return m.OldCanWrite(ctx)
  3619. case agentbase.FieldIsOwner:
  3620. return m.OldIsOwner(ctx)
  3621. }
  3622. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  3623. }
  3624. // SetField sets the value of a field with the given name. It returns an error if
  3625. // the field is not defined in the schema, or if the type mismatched the field
  3626. // type.
  3627. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  3628. switch name {
  3629. case agentbase.FieldQ:
  3630. v, ok := value.(string)
  3631. if !ok {
  3632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3633. }
  3634. m.SetQ(v)
  3635. return nil
  3636. case agentbase.FieldA:
  3637. v, ok := value.(string)
  3638. if !ok {
  3639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3640. }
  3641. m.SetA(v)
  3642. return nil
  3643. case agentbase.FieldChunkIndex:
  3644. v, ok := value.(uint64)
  3645. if !ok {
  3646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3647. }
  3648. m.SetChunkIndex(v)
  3649. return nil
  3650. case agentbase.FieldIndexes:
  3651. v, ok := value.([]string)
  3652. if !ok {
  3653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3654. }
  3655. m.SetIndexes(v)
  3656. return nil
  3657. case agentbase.FieldDatasetID:
  3658. v, ok := value.(string)
  3659. if !ok {
  3660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3661. }
  3662. m.SetDatasetID(v)
  3663. return nil
  3664. case agentbase.FieldCollectionID:
  3665. v, ok := value.(string)
  3666. if !ok {
  3667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3668. }
  3669. m.SetCollectionID(v)
  3670. return nil
  3671. case agentbase.FieldSourceName:
  3672. v, ok := value.(string)
  3673. if !ok {
  3674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3675. }
  3676. m.SetSourceName(v)
  3677. return nil
  3678. case agentbase.FieldCanWrite:
  3679. v, ok := value.([]bool)
  3680. if !ok {
  3681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3682. }
  3683. m.SetCanWrite(v)
  3684. return nil
  3685. case agentbase.FieldIsOwner:
  3686. v, ok := value.([]bool)
  3687. if !ok {
  3688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3689. }
  3690. m.SetIsOwner(v)
  3691. return nil
  3692. }
  3693. return fmt.Errorf("unknown AgentBase field %s", name)
  3694. }
  3695. // AddedFields returns all numeric fields that were incremented/decremented during
  3696. // this mutation.
  3697. func (m *AgentBaseMutation) AddedFields() []string {
  3698. var fields []string
  3699. if m.addchunk_index != nil {
  3700. fields = append(fields, agentbase.FieldChunkIndex)
  3701. }
  3702. return fields
  3703. }
  3704. // AddedField returns the numeric value that was incremented/decremented on a field
  3705. // with the given name. The second boolean return value indicates that this field
  3706. // was not set, or was not defined in the schema.
  3707. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  3708. switch name {
  3709. case agentbase.FieldChunkIndex:
  3710. return m.AddedChunkIndex()
  3711. }
  3712. return nil, false
  3713. }
  3714. // AddField adds the value to the field with the given name. It returns an error if
  3715. // the field is not defined in the schema, or if the type mismatched the field
  3716. // type.
  3717. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  3718. switch name {
  3719. case agentbase.FieldChunkIndex:
  3720. v, ok := value.(int64)
  3721. if !ok {
  3722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3723. }
  3724. m.AddChunkIndex(v)
  3725. return nil
  3726. }
  3727. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  3728. }
  3729. // ClearedFields returns all nullable fields that were cleared during this
  3730. // mutation.
  3731. func (m *AgentBaseMutation) ClearedFields() []string {
  3732. var fields []string
  3733. if m.FieldCleared(agentbase.FieldQ) {
  3734. fields = append(fields, agentbase.FieldQ)
  3735. }
  3736. if m.FieldCleared(agentbase.FieldA) {
  3737. fields = append(fields, agentbase.FieldA)
  3738. }
  3739. if m.FieldCleared(agentbase.FieldIndexes) {
  3740. fields = append(fields, agentbase.FieldIndexes)
  3741. }
  3742. if m.FieldCleared(agentbase.FieldDatasetID) {
  3743. fields = append(fields, agentbase.FieldDatasetID)
  3744. }
  3745. if m.FieldCleared(agentbase.FieldCollectionID) {
  3746. fields = append(fields, agentbase.FieldCollectionID)
  3747. }
  3748. if m.FieldCleared(agentbase.FieldSourceName) {
  3749. fields = append(fields, agentbase.FieldSourceName)
  3750. }
  3751. if m.FieldCleared(agentbase.FieldCanWrite) {
  3752. fields = append(fields, agentbase.FieldCanWrite)
  3753. }
  3754. if m.FieldCleared(agentbase.FieldIsOwner) {
  3755. fields = append(fields, agentbase.FieldIsOwner)
  3756. }
  3757. return fields
  3758. }
  3759. // FieldCleared returns a boolean indicating if a field with the given name was
  3760. // cleared in this mutation.
  3761. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  3762. _, ok := m.clearedFields[name]
  3763. return ok
  3764. }
  3765. // ClearField clears the value of the field with the given name. It returns an
  3766. // error if the field is not defined in the schema.
  3767. func (m *AgentBaseMutation) ClearField(name string) error {
  3768. switch name {
  3769. case agentbase.FieldQ:
  3770. m.ClearQ()
  3771. return nil
  3772. case agentbase.FieldA:
  3773. m.ClearA()
  3774. return nil
  3775. case agentbase.FieldIndexes:
  3776. m.ClearIndexes()
  3777. return nil
  3778. case agentbase.FieldDatasetID:
  3779. m.ClearDatasetID()
  3780. return nil
  3781. case agentbase.FieldCollectionID:
  3782. m.ClearCollectionID()
  3783. return nil
  3784. case agentbase.FieldSourceName:
  3785. m.ClearSourceName()
  3786. return nil
  3787. case agentbase.FieldCanWrite:
  3788. m.ClearCanWrite()
  3789. return nil
  3790. case agentbase.FieldIsOwner:
  3791. m.ClearIsOwner()
  3792. return nil
  3793. }
  3794. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  3795. }
  3796. // ResetField resets all changes in the mutation for the field with the given name.
  3797. // It returns an error if the field is not defined in the schema.
  3798. func (m *AgentBaseMutation) ResetField(name string) error {
  3799. switch name {
  3800. case agentbase.FieldQ:
  3801. m.ResetQ()
  3802. return nil
  3803. case agentbase.FieldA:
  3804. m.ResetA()
  3805. return nil
  3806. case agentbase.FieldChunkIndex:
  3807. m.ResetChunkIndex()
  3808. return nil
  3809. case agentbase.FieldIndexes:
  3810. m.ResetIndexes()
  3811. return nil
  3812. case agentbase.FieldDatasetID:
  3813. m.ResetDatasetID()
  3814. return nil
  3815. case agentbase.FieldCollectionID:
  3816. m.ResetCollectionID()
  3817. return nil
  3818. case agentbase.FieldSourceName:
  3819. m.ResetSourceName()
  3820. return nil
  3821. case agentbase.FieldCanWrite:
  3822. m.ResetCanWrite()
  3823. return nil
  3824. case agentbase.FieldIsOwner:
  3825. m.ResetIsOwner()
  3826. return nil
  3827. }
  3828. return fmt.Errorf("unknown AgentBase field %s", name)
  3829. }
  3830. // AddedEdges returns all edge names that were set/added in this mutation.
  3831. func (m *AgentBaseMutation) AddedEdges() []string {
  3832. edges := make([]string, 0, 1)
  3833. if m.wx_agent != nil {
  3834. edges = append(edges, agentbase.EdgeWxAgent)
  3835. }
  3836. return edges
  3837. }
  3838. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3839. // name in this mutation.
  3840. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  3841. switch name {
  3842. case agentbase.EdgeWxAgent:
  3843. ids := make([]ent.Value, 0, len(m.wx_agent))
  3844. for id := range m.wx_agent {
  3845. ids = append(ids, id)
  3846. }
  3847. return ids
  3848. }
  3849. return nil
  3850. }
  3851. // RemovedEdges returns all edge names that were removed in this mutation.
  3852. func (m *AgentBaseMutation) RemovedEdges() []string {
  3853. edges := make([]string, 0, 1)
  3854. if m.removedwx_agent != nil {
  3855. edges = append(edges, agentbase.EdgeWxAgent)
  3856. }
  3857. return edges
  3858. }
  3859. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3860. // the given name in this mutation.
  3861. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  3862. switch name {
  3863. case agentbase.EdgeWxAgent:
  3864. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  3865. for id := range m.removedwx_agent {
  3866. ids = append(ids, id)
  3867. }
  3868. return ids
  3869. }
  3870. return nil
  3871. }
  3872. // ClearedEdges returns all edge names that were cleared in this mutation.
  3873. func (m *AgentBaseMutation) ClearedEdges() []string {
  3874. edges := make([]string, 0, 1)
  3875. if m.clearedwx_agent {
  3876. edges = append(edges, agentbase.EdgeWxAgent)
  3877. }
  3878. return edges
  3879. }
  3880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3881. // was cleared in this mutation.
  3882. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  3883. switch name {
  3884. case agentbase.EdgeWxAgent:
  3885. return m.clearedwx_agent
  3886. }
  3887. return false
  3888. }
  3889. // ClearEdge clears the value of the edge with the given name. It returns an error
  3890. // if that edge is not defined in the schema.
  3891. func (m *AgentBaseMutation) ClearEdge(name string) error {
  3892. switch name {
  3893. }
  3894. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  3895. }
  3896. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3897. // It returns an error if the edge is not defined in the schema.
  3898. func (m *AgentBaseMutation) ResetEdge(name string) error {
  3899. switch name {
  3900. case agentbase.EdgeWxAgent:
  3901. m.ResetWxAgent()
  3902. return nil
  3903. }
  3904. return fmt.Errorf("unknown AgentBase edge %s", name)
  3905. }
  3906. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  3907. type AliyunAvatarMutation struct {
  3908. config
  3909. op Op
  3910. typ string
  3911. id *uint64
  3912. created_at *time.Time
  3913. updated_at *time.Time
  3914. deleted_at *time.Time
  3915. user_id *uint64
  3916. adduser_id *int64
  3917. biz_id *string
  3918. access_key_id *string
  3919. access_key_secret *string
  3920. app_id *string
  3921. tenant_id *uint64
  3922. addtenant_id *int64
  3923. response *string
  3924. token *string
  3925. session_id *string
  3926. clearedFields map[string]struct{}
  3927. done bool
  3928. oldValue func(context.Context) (*AliyunAvatar, error)
  3929. predicates []predicate.AliyunAvatar
  3930. }
  3931. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  3932. // aliyunavatarOption allows management of the mutation configuration using functional options.
  3933. type aliyunavatarOption func(*AliyunAvatarMutation)
  3934. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  3935. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  3936. m := &AliyunAvatarMutation{
  3937. config: c,
  3938. op: op,
  3939. typ: TypeAliyunAvatar,
  3940. clearedFields: make(map[string]struct{}),
  3941. }
  3942. for _, opt := range opts {
  3943. opt(m)
  3944. }
  3945. return m
  3946. }
  3947. // withAliyunAvatarID sets the ID field of the mutation.
  3948. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  3949. return func(m *AliyunAvatarMutation) {
  3950. var (
  3951. err error
  3952. once sync.Once
  3953. value *AliyunAvatar
  3954. )
  3955. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  3956. once.Do(func() {
  3957. if m.done {
  3958. err = errors.New("querying old values post mutation is not allowed")
  3959. } else {
  3960. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  3961. }
  3962. })
  3963. return value, err
  3964. }
  3965. m.id = &id
  3966. }
  3967. }
  3968. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  3969. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  3970. return func(m *AliyunAvatarMutation) {
  3971. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  3972. return node, nil
  3973. }
  3974. m.id = &node.ID
  3975. }
  3976. }
  3977. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3978. // executed in a transaction (ent.Tx), a transactional client is returned.
  3979. func (m AliyunAvatarMutation) Client() *Client {
  3980. client := &Client{config: m.config}
  3981. client.init()
  3982. return client
  3983. }
  3984. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3985. // it returns an error otherwise.
  3986. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  3987. if _, ok := m.driver.(*txDriver); !ok {
  3988. return nil, errors.New("ent: mutation is not running in a transaction")
  3989. }
  3990. tx := &Tx{config: m.config}
  3991. tx.init()
  3992. return tx, nil
  3993. }
  3994. // SetID sets the value of the id field. Note that this
  3995. // operation is only accepted on creation of AliyunAvatar entities.
  3996. func (m *AliyunAvatarMutation) SetID(id uint64) {
  3997. m.id = &id
  3998. }
  3999. // ID returns the ID value in the mutation. Note that the ID is only available
  4000. // if it was provided to the builder or after it was returned from the database.
  4001. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  4002. if m.id == nil {
  4003. return
  4004. }
  4005. return *m.id, true
  4006. }
  4007. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4008. // That means, if the mutation is applied within a transaction with an isolation level such
  4009. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4010. // or updated by the mutation.
  4011. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  4012. switch {
  4013. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4014. id, exists := m.ID()
  4015. if exists {
  4016. return []uint64{id}, nil
  4017. }
  4018. fallthrough
  4019. case m.op.Is(OpUpdate | OpDelete):
  4020. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  4021. default:
  4022. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4023. }
  4024. }
  4025. // SetCreatedAt sets the "created_at" field.
  4026. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  4027. m.created_at = &t
  4028. }
  4029. // CreatedAt returns the value of the "created_at" field in the mutation.
  4030. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  4031. v := m.created_at
  4032. if v == nil {
  4033. return
  4034. }
  4035. return *v, true
  4036. }
  4037. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  4038. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4040. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4041. if !m.op.Is(OpUpdateOne) {
  4042. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4043. }
  4044. if m.id == nil || m.oldValue == nil {
  4045. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4046. }
  4047. oldValue, err := m.oldValue(ctx)
  4048. if err != nil {
  4049. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4050. }
  4051. return oldValue.CreatedAt, nil
  4052. }
  4053. // ResetCreatedAt resets all changes to the "created_at" field.
  4054. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  4055. m.created_at = nil
  4056. }
  4057. // SetUpdatedAt sets the "updated_at" field.
  4058. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  4059. m.updated_at = &t
  4060. }
  4061. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4062. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  4063. v := m.updated_at
  4064. if v == nil {
  4065. return
  4066. }
  4067. return *v, true
  4068. }
  4069. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  4070. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4072. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4073. if !m.op.Is(OpUpdateOne) {
  4074. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4075. }
  4076. if m.id == nil || m.oldValue == nil {
  4077. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4078. }
  4079. oldValue, err := m.oldValue(ctx)
  4080. if err != nil {
  4081. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4082. }
  4083. return oldValue.UpdatedAt, nil
  4084. }
  4085. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4086. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  4087. m.updated_at = nil
  4088. }
  4089. // SetDeletedAt sets the "deleted_at" field.
  4090. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  4091. m.deleted_at = &t
  4092. }
  4093. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4094. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  4095. v := m.deleted_at
  4096. if v == nil {
  4097. return
  4098. }
  4099. return *v, true
  4100. }
  4101. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  4102. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4104. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4105. if !m.op.Is(OpUpdateOne) {
  4106. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4107. }
  4108. if m.id == nil || m.oldValue == nil {
  4109. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4110. }
  4111. oldValue, err := m.oldValue(ctx)
  4112. if err != nil {
  4113. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4114. }
  4115. return oldValue.DeletedAt, nil
  4116. }
  4117. // ClearDeletedAt clears the value of the "deleted_at" field.
  4118. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  4119. m.deleted_at = nil
  4120. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  4121. }
  4122. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4123. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  4124. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  4125. return ok
  4126. }
  4127. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4128. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  4129. m.deleted_at = nil
  4130. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  4131. }
  4132. // SetUserID sets the "user_id" field.
  4133. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  4134. m.user_id = &u
  4135. m.adduser_id = nil
  4136. }
  4137. // UserID returns the value of the "user_id" field in the mutation.
  4138. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  4139. v := m.user_id
  4140. if v == nil {
  4141. return
  4142. }
  4143. return *v, true
  4144. }
  4145. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  4146. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4148. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  4149. if !m.op.Is(OpUpdateOne) {
  4150. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  4151. }
  4152. if m.id == nil || m.oldValue == nil {
  4153. return v, errors.New("OldUserID requires an ID field in the mutation")
  4154. }
  4155. oldValue, err := m.oldValue(ctx)
  4156. if err != nil {
  4157. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  4158. }
  4159. return oldValue.UserID, nil
  4160. }
  4161. // AddUserID adds u to the "user_id" field.
  4162. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  4163. if m.adduser_id != nil {
  4164. *m.adduser_id += u
  4165. } else {
  4166. m.adduser_id = &u
  4167. }
  4168. }
  4169. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  4170. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  4171. v := m.adduser_id
  4172. if v == nil {
  4173. return
  4174. }
  4175. return *v, true
  4176. }
  4177. // ResetUserID resets all changes to the "user_id" field.
  4178. func (m *AliyunAvatarMutation) ResetUserID() {
  4179. m.user_id = nil
  4180. m.adduser_id = nil
  4181. }
  4182. // SetBizID sets the "biz_id" field.
  4183. func (m *AliyunAvatarMutation) SetBizID(s string) {
  4184. m.biz_id = &s
  4185. }
  4186. // BizID returns the value of the "biz_id" field in the mutation.
  4187. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  4188. v := m.biz_id
  4189. if v == nil {
  4190. return
  4191. }
  4192. return *v, true
  4193. }
  4194. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  4195. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4197. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  4198. if !m.op.Is(OpUpdateOne) {
  4199. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  4200. }
  4201. if m.id == nil || m.oldValue == nil {
  4202. return v, errors.New("OldBizID requires an ID field in the mutation")
  4203. }
  4204. oldValue, err := m.oldValue(ctx)
  4205. if err != nil {
  4206. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  4207. }
  4208. return oldValue.BizID, nil
  4209. }
  4210. // ResetBizID resets all changes to the "biz_id" field.
  4211. func (m *AliyunAvatarMutation) ResetBizID() {
  4212. m.biz_id = nil
  4213. }
  4214. // SetAccessKeyID sets the "access_key_id" field.
  4215. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  4216. m.access_key_id = &s
  4217. }
  4218. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  4219. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  4220. v := m.access_key_id
  4221. if v == nil {
  4222. return
  4223. }
  4224. return *v, true
  4225. }
  4226. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  4227. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4229. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  4230. if !m.op.Is(OpUpdateOne) {
  4231. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  4232. }
  4233. if m.id == nil || m.oldValue == nil {
  4234. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  4235. }
  4236. oldValue, err := m.oldValue(ctx)
  4237. if err != nil {
  4238. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  4239. }
  4240. return oldValue.AccessKeyID, nil
  4241. }
  4242. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  4243. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  4244. m.access_key_id = nil
  4245. }
  4246. // SetAccessKeySecret sets the "access_key_secret" field.
  4247. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  4248. m.access_key_secret = &s
  4249. }
  4250. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  4251. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  4252. v := m.access_key_secret
  4253. if v == nil {
  4254. return
  4255. }
  4256. return *v, true
  4257. }
  4258. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  4259. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4261. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  4262. if !m.op.Is(OpUpdateOne) {
  4263. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  4264. }
  4265. if m.id == nil || m.oldValue == nil {
  4266. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  4267. }
  4268. oldValue, err := m.oldValue(ctx)
  4269. if err != nil {
  4270. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  4271. }
  4272. return oldValue.AccessKeySecret, nil
  4273. }
  4274. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  4275. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  4276. m.access_key_secret = nil
  4277. }
  4278. // SetAppID sets the "app_id" field.
  4279. func (m *AliyunAvatarMutation) SetAppID(s string) {
  4280. m.app_id = &s
  4281. }
  4282. // AppID returns the value of the "app_id" field in the mutation.
  4283. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  4284. v := m.app_id
  4285. if v == nil {
  4286. return
  4287. }
  4288. return *v, true
  4289. }
  4290. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  4291. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4293. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  4294. if !m.op.Is(OpUpdateOne) {
  4295. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  4296. }
  4297. if m.id == nil || m.oldValue == nil {
  4298. return v, errors.New("OldAppID requires an ID field in the mutation")
  4299. }
  4300. oldValue, err := m.oldValue(ctx)
  4301. if err != nil {
  4302. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  4303. }
  4304. return oldValue.AppID, nil
  4305. }
  4306. // ClearAppID clears the value of the "app_id" field.
  4307. func (m *AliyunAvatarMutation) ClearAppID() {
  4308. m.app_id = nil
  4309. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  4310. }
  4311. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  4312. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  4313. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  4314. return ok
  4315. }
  4316. // ResetAppID resets all changes to the "app_id" field.
  4317. func (m *AliyunAvatarMutation) ResetAppID() {
  4318. m.app_id = nil
  4319. delete(m.clearedFields, aliyunavatar.FieldAppID)
  4320. }
  4321. // SetTenantID sets the "tenant_id" field.
  4322. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  4323. m.tenant_id = &u
  4324. m.addtenant_id = nil
  4325. }
  4326. // TenantID returns the value of the "tenant_id" field in the mutation.
  4327. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  4328. v := m.tenant_id
  4329. if v == nil {
  4330. return
  4331. }
  4332. return *v, true
  4333. }
  4334. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  4335. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4337. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  4338. if !m.op.Is(OpUpdateOne) {
  4339. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  4340. }
  4341. if m.id == nil || m.oldValue == nil {
  4342. return v, errors.New("OldTenantID requires an ID field in the mutation")
  4343. }
  4344. oldValue, err := m.oldValue(ctx)
  4345. if err != nil {
  4346. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  4347. }
  4348. return oldValue.TenantID, nil
  4349. }
  4350. // AddTenantID adds u to the "tenant_id" field.
  4351. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  4352. if m.addtenant_id != nil {
  4353. *m.addtenant_id += u
  4354. } else {
  4355. m.addtenant_id = &u
  4356. }
  4357. }
  4358. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  4359. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  4360. v := m.addtenant_id
  4361. if v == nil {
  4362. return
  4363. }
  4364. return *v, true
  4365. }
  4366. // ResetTenantID resets all changes to the "tenant_id" field.
  4367. func (m *AliyunAvatarMutation) ResetTenantID() {
  4368. m.tenant_id = nil
  4369. m.addtenant_id = nil
  4370. }
  4371. // SetResponse sets the "response" field.
  4372. func (m *AliyunAvatarMutation) SetResponse(s string) {
  4373. m.response = &s
  4374. }
  4375. // Response returns the value of the "response" field in the mutation.
  4376. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  4377. v := m.response
  4378. if v == nil {
  4379. return
  4380. }
  4381. return *v, true
  4382. }
  4383. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  4384. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4386. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  4387. if !m.op.Is(OpUpdateOne) {
  4388. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  4389. }
  4390. if m.id == nil || m.oldValue == nil {
  4391. return v, errors.New("OldResponse requires an ID field in the mutation")
  4392. }
  4393. oldValue, err := m.oldValue(ctx)
  4394. if err != nil {
  4395. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  4396. }
  4397. return oldValue.Response, nil
  4398. }
  4399. // ResetResponse resets all changes to the "response" field.
  4400. func (m *AliyunAvatarMutation) ResetResponse() {
  4401. m.response = nil
  4402. }
  4403. // SetToken sets the "token" field.
  4404. func (m *AliyunAvatarMutation) SetToken(s string) {
  4405. m.token = &s
  4406. }
  4407. // Token returns the value of the "token" field in the mutation.
  4408. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  4409. v := m.token
  4410. if v == nil {
  4411. return
  4412. }
  4413. return *v, true
  4414. }
  4415. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  4416. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4418. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  4419. if !m.op.Is(OpUpdateOne) {
  4420. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  4421. }
  4422. if m.id == nil || m.oldValue == nil {
  4423. return v, errors.New("OldToken requires an ID field in the mutation")
  4424. }
  4425. oldValue, err := m.oldValue(ctx)
  4426. if err != nil {
  4427. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  4428. }
  4429. return oldValue.Token, nil
  4430. }
  4431. // ResetToken resets all changes to the "token" field.
  4432. func (m *AliyunAvatarMutation) ResetToken() {
  4433. m.token = nil
  4434. }
  4435. // SetSessionID sets the "session_id" field.
  4436. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  4437. m.session_id = &s
  4438. }
  4439. // SessionID returns the value of the "session_id" field in the mutation.
  4440. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  4441. v := m.session_id
  4442. if v == nil {
  4443. return
  4444. }
  4445. return *v, true
  4446. }
  4447. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  4448. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  4449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4450. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  4451. if !m.op.Is(OpUpdateOne) {
  4452. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  4453. }
  4454. if m.id == nil || m.oldValue == nil {
  4455. return v, errors.New("OldSessionID requires an ID field in the mutation")
  4456. }
  4457. oldValue, err := m.oldValue(ctx)
  4458. if err != nil {
  4459. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  4460. }
  4461. return oldValue.SessionID, nil
  4462. }
  4463. // ResetSessionID resets all changes to the "session_id" field.
  4464. func (m *AliyunAvatarMutation) ResetSessionID() {
  4465. m.session_id = nil
  4466. }
  4467. // Where appends a list predicates to the AliyunAvatarMutation builder.
  4468. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  4469. m.predicates = append(m.predicates, ps...)
  4470. }
  4471. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  4472. // users can use type-assertion to append predicates that do not depend on any generated package.
  4473. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  4474. p := make([]predicate.AliyunAvatar, len(ps))
  4475. for i := range ps {
  4476. p[i] = ps[i]
  4477. }
  4478. m.Where(p...)
  4479. }
  4480. // Op returns the operation name.
  4481. func (m *AliyunAvatarMutation) Op() Op {
  4482. return m.op
  4483. }
  4484. // SetOp allows setting the mutation operation.
  4485. func (m *AliyunAvatarMutation) SetOp(op Op) {
  4486. m.op = op
  4487. }
  4488. // Type returns the node type of this mutation (AliyunAvatar).
  4489. func (m *AliyunAvatarMutation) Type() string {
  4490. return m.typ
  4491. }
  4492. // Fields returns all fields that were changed during this mutation. Note that in
  4493. // order to get all numeric fields that were incremented/decremented, call
  4494. // AddedFields().
  4495. func (m *AliyunAvatarMutation) Fields() []string {
  4496. fields := make([]string, 0, 12)
  4497. if m.created_at != nil {
  4498. fields = append(fields, aliyunavatar.FieldCreatedAt)
  4499. }
  4500. if m.updated_at != nil {
  4501. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  4502. }
  4503. if m.deleted_at != nil {
  4504. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4505. }
  4506. if m.user_id != nil {
  4507. fields = append(fields, aliyunavatar.FieldUserID)
  4508. }
  4509. if m.biz_id != nil {
  4510. fields = append(fields, aliyunavatar.FieldBizID)
  4511. }
  4512. if m.access_key_id != nil {
  4513. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  4514. }
  4515. if m.access_key_secret != nil {
  4516. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  4517. }
  4518. if m.app_id != nil {
  4519. fields = append(fields, aliyunavatar.FieldAppID)
  4520. }
  4521. if m.tenant_id != nil {
  4522. fields = append(fields, aliyunavatar.FieldTenantID)
  4523. }
  4524. if m.response != nil {
  4525. fields = append(fields, aliyunavatar.FieldResponse)
  4526. }
  4527. if m.token != nil {
  4528. fields = append(fields, aliyunavatar.FieldToken)
  4529. }
  4530. if m.session_id != nil {
  4531. fields = append(fields, aliyunavatar.FieldSessionID)
  4532. }
  4533. return fields
  4534. }
  4535. // Field returns the value of a field with the given name. The second boolean
  4536. // return value indicates that this field was not set, or was not defined in the
  4537. // schema.
  4538. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  4539. switch name {
  4540. case aliyunavatar.FieldCreatedAt:
  4541. return m.CreatedAt()
  4542. case aliyunavatar.FieldUpdatedAt:
  4543. return m.UpdatedAt()
  4544. case aliyunavatar.FieldDeletedAt:
  4545. return m.DeletedAt()
  4546. case aliyunavatar.FieldUserID:
  4547. return m.UserID()
  4548. case aliyunavatar.FieldBizID:
  4549. return m.BizID()
  4550. case aliyunavatar.FieldAccessKeyID:
  4551. return m.AccessKeyID()
  4552. case aliyunavatar.FieldAccessKeySecret:
  4553. return m.AccessKeySecret()
  4554. case aliyunavatar.FieldAppID:
  4555. return m.AppID()
  4556. case aliyunavatar.FieldTenantID:
  4557. return m.TenantID()
  4558. case aliyunavatar.FieldResponse:
  4559. return m.Response()
  4560. case aliyunavatar.FieldToken:
  4561. return m.Token()
  4562. case aliyunavatar.FieldSessionID:
  4563. return m.SessionID()
  4564. }
  4565. return nil, false
  4566. }
  4567. // OldField returns the old value of the field from the database. An error is
  4568. // returned if the mutation operation is not UpdateOne, or the query to the
  4569. // database failed.
  4570. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4571. switch name {
  4572. case aliyunavatar.FieldCreatedAt:
  4573. return m.OldCreatedAt(ctx)
  4574. case aliyunavatar.FieldUpdatedAt:
  4575. return m.OldUpdatedAt(ctx)
  4576. case aliyunavatar.FieldDeletedAt:
  4577. return m.OldDeletedAt(ctx)
  4578. case aliyunavatar.FieldUserID:
  4579. return m.OldUserID(ctx)
  4580. case aliyunavatar.FieldBizID:
  4581. return m.OldBizID(ctx)
  4582. case aliyunavatar.FieldAccessKeyID:
  4583. return m.OldAccessKeyID(ctx)
  4584. case aliyunavatar.FieldAccessKeySecret:
  4585. return m.OldAccessKeySecret(ctx)
  4586. case aliyunavatar.FieldAppID:
  4587. return m.OldAppID(ctx)
  4588. case aliyunavatar.FieldTenantID:
  4589. return m.OldTenantID(ctx)
  4590. case aliyunavatar.FieldResponse:
  4591. return m.OldResponse(ctx)
  4592. case aliyunavatar.FieldToken:
  4593. return m.OldToken(ctx)
  4594. case aliyunavatar.FieldSessionID:
  4595. return m.OldSessionID(ctx)
  4596. }
  4597. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  4598. }
  4599. // SetField sets the value of a field with the given name. It returns an error if
  4600. // the field is not defined in the schema, or if the type mismatched the field
  4601. // type.
  4602. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  4603. switch name {
  4604. case aliyunavatar.FieldCreatedAt:
  4605. v, ok := value.(time.Time)
  4606. if !ok {
  4607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4608. }
  4609. m.SetCreatedAt(v)
  4610. return nil
  4611. case aliyunavatar.FieldUpdatedAt:
  4612. v, ok := value.(time.Time)
  4613. if !ok {
  4614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4615. }
  4616. m.SetUpdatedAt(v)
  4617. return nil
  4618. case aliyunavatar.FieldDeletedAt:
  4619. v, ok := value.(time.Time)
  4620. if !ok {
  4621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4622. }
  4623. m.SetDeletedAt(v)
  4624. return nil
  4625. case aliyunavatar.FieldUserID:
  4626. v, ok := value.(uint64)
  4627. if !ok {
  4628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4629. }
  4630. m.SetUserID(v)
  4631. return nil
  4632. case aliyunavatar.FieldBizID:
  4633. v, ok := value.(string)
  4634. if !ok {
  4635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4636. }
  4637. m.SetBizID(v)
  4638. return nil
  4639. case aliyunavatar.FieldAccessKeyID:
  4640. v, ok := value.(string)
  4641. if !ok {
  4642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4643. }
  4644. m.SetAccessKeyID(v)
  4645. return nil
  4646. case aliyunavatar.FieldAccessKeySecret:
  4647. v, ok := value.(string)
  4648. if !ok {
  4649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4650. }
  4651. m.SetAccessKeySecret(v)
  4652. return nil
  4653. case aliyunavatar.FieldAppID:
  4654. v, ok := value.(string)
  4655. if !ok {
  4656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4657. }
  4658. m.SetAppID(v)
  4659. return nil
  4660. case aliyunavatar.FieldTenantID:
  4661. v, ok := value.(uint64)
  4662. if !ok {
  4663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4664. }
  4665. m.SetTenantID(v)
  4666. return nil
  4667. case aliyunavatar.FieldResponse:
  4668. v, ok := value.(string)
  4669. if !ok {
  4670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4671. }
  4672. m.SetResponse(v)
  4673. return nil
  4674. case aliyunavatar.FieldToken:
  4675. v, ok := value.(string)
  4676. if !ok {
  4677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4678. }
  4679. m.SetToken(v)
  4680. return nil
  4681. case aliyunavatar.FieldSessionID:
  4682. v, ok := value.(string)
  4683. if !ok {
  4684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4685. }
  4686. m.SetSessionID(v)
  4687. return nil
  4688. }
  4689. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4690. }
  4691. // AddedFields returns all numeric fields that were incremented/decremented during
  4692. // this mutation.
  4693. func (m *AliyunAvatarMutation) AddedFields() []string {
  4694. var fields []string
  4695. if m.adduser_id != nil {
  4696. fields = append(fields, aliyunavatar.FieldUserID)
  4697. }
  4698. if m.addtenant_id != nil {
  4699. fields = append(fields, aliyunavatar.FieldTenantID)
  4700. }
  4701. return fields
  4702. }
  4703. // AddedField returns the numeric value that was incremented/decremented on a field
  4704. // with the given name. The second boolean return value indicates that this field
  4705. // was not set, or was not defined in the schema.
  4706. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  4707. switch name {
  4708. case aliyunavatar.FieldUserID:
  4709. return m.AddedUserID()
  4710. case aliyunavatar.FieldTenantID:
  4711. return m.AddedTenantID()
  4712. }
  4713. return nil, false
  4714. }
  4715. // AddField adds the value to the field with the given name. It returns an error if
  4716. // the field is not defined in the schema, or if the type mismatched the field
  4717. // type.
  4718. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  4719. switch name {
  4720. case aliyunavatar.FieldUserID:
  4721. v, ok := value.(int64)
  4722. if !ok {
  4723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4724. }
  4725. m.AddUserID(v)
  4726. return nil
  4727. case aliyunavatar.FieldTenantID:
  4728. v, ok := value.(int64)
  4729. if !ok {
  4730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4731. }
  4732. m.AddTenantID(v)
  4733. return nil
  4734. }
  4735. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  4736. }
  4737. // ClearedFields returns all nullable fields that were cleared during this
  4738. // mutation.
  4739. func (m *AliyunAvatarMutation) ClearedFields() []string {
  4740. var fields []string
  4741. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  4742. fields = append(fields, aliyunavatar.FieldDeletedAt)
  4743. }
  4744. if m.FieldCleared(aliyunavatar.FieldAppID) {
  4745. fields = append(fields, aliyunavatar.FieldAppID)
  4746. }
  4747. return fields
  4748. }
  4749. // FieldCleared returns a boolean indicating if a field with the given name was
  4750. // cleared in this mutation.
  4751. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  4752. _, ok := m.clearedFields[name]
  4753. return ok
  4754. }
  4755. // ClearField clears the value of the field with the given name. It returns an
  4756. // error if the field is not defined in the schema.
  4757. func (m *AliyunAvatarMutation) ClearField(name string) error {
  4758. switch name {
  4759. case aliyunavatar.FieldDeletedAt:
  4760. m.ClearDeletedAt()
  4761. return nil
  4762. case aliyunavatar.FieldAppID:
  4763. m.ClearAppID()
  4764. return nil
  4765. }
  4766. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  4767. }
  4768. // ResetField resets all changes in the mutation for the field with the given name.
  4769. // It returns an error if the field is not defined in the schema.
  4770. func (m *AliyunAvatarMutation) ResetField(name string) error {
  4771. switch name {
  4772. case aliyunavatar.FieldCreatedAt:
  4773. m.ResetCreatedAt()
  4774. return nil
  4775. case aliyunavatar.FieldUpdatedAt:
  4776. m.ResetUpdatedAt()
  4777. return nil
  4778. case aliyunavatar.FieldDeletedAt:
  4779. m.ResetDeletedAt()
  4780. return nil
  4781. case aliyunavatar.FieldUserID:
  4782. m.ResetUserID()
  4783. return nil
  4784. case aliyunavatar.FieldBizID:
  4785. m.ResetBizID()
  4786. return nil
  4787. case aliyunavatar.FieldAccessKeyID:
  4788. m.ResetAccessKeyID()
  4789. return nil
  4790. case aliyunavatar.FieldAccessKeySecret:
  4791. m.ResetAccessKeySecret()
  4792. return nil
  4793. case aliyunavatar.FieldAppID:
  4794. m.ResetAppID()
  4795. return nil
  4796. case aliyunavatar.FieldTenantID:
  4797. m.ResetTenantID()
  4798. return nil
  4799. case aliyunavatar.FieldResponse:
  4800. m.ResetResponse()
  4801. return nil
  4802. case aliyunavatar.FieldToken:
  4803. m.ResetToken()
  4804. return nil
  4805. case aliyunavatar.FieldSessionID:
  4806. m.ResetSessionID()
  4807. return nil
  4808. }
  4809. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  4810. }
  4811. // AddedEdges returns all edge names that were set/added in this mutation.
  4812. func (m *AliyunAvatarMutation) AddedEdges() []string {
  4813. edges := make([]string, 0, 0)
  4814. return edges
  4815. }
  4816. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4817. // name in this mutation.
  4818. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  4819. return nil
  4820. }
  4821. // RemovedEdges returns all edge names that were removed in this mutation.
  4822. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  4823. edges := make([]string, 0, 0)
  4824. return edges
  4825. }
  4826. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4827. // the given name in this mutation.
  4828. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  4829. return nil
  4830. }
  4831. // ClearedEdges returns all edge names that were cleared in this mutation.
  4832. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  4833. edges := make([]string, 0, 0)
  4834. return edges
  4835. }
  4836. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4837. // was cleared in this mutation.
  4838. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  4839. return false
  4840. }
  4841. // ClearEdge clears the value of the edge with the given name. It returns an error
  4842. // if that edge is not defined in the schema.
  4843. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  4844. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  4845. }
  4846. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4847. // It returns an error if the edge is not defined in the schema.
  4848. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  4849. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  4850. }
  4851. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  4852. type AllocAgentMutation struct {
  4853. config
  4854. op Op
  4855. typ string
  4856. id *uint64
  4857. created_at *time.Time
  4858. updated_at *time.Time
  4859. deleted_at *time.Time
  4860. user_id *string
  4861. organization_id *uint64
  4862. addorganization_id *int64
  4863. agents *[]uint64
  4864. appendagents []uint64
  4865. status *int
  4866. addstatus *int
  4867. clearedFields map[string]struct{}
  4868. done bool
  4869. oldValue func(context.Context) (*AllocAgent, error)
  4870. predicates []predicate.AllocAgent
  4871. }
  4872. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  4873. // allocagentOption allows management of the mutation configuration using functional options.
  4874. type allocagentOption func(*AllocAgentMutation)
  4875. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  4876. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  4877. m := &AllocAgentMutation{
  4878. config: c,
  4879. op: op,
  4880. typ: TypeAllocAgent,
  4881. clearedFields: make(map[string]struct{}),
  4882. }
  4883. for _, opt := range opts {
  4884. opt(m)
  4885. }
  4886. return m
  4887. }
  4888. // withAllocAgentID sets the ID field of the mutation.
  4889. func withAllocAgentID(id uint64) allocagentOption {
  4890. return func(m *AllocAgentMutation) {
  4891. var (
  4892. err error
  4893. once sync.Once
  4894. value *AllocAgent
  4895. )
  4896. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  4897. once.Do(func() {
  4898. if m.done {
  4899. err = errors.New("querying old values post mutation is not allowed")
  4900. } else {
  4901. value, err = m.Client().AllocAgent.Get(ctx, id)
  4902. }
  4903. })
  4904. return value, err
  4905. }
  4906. m.id = &id
  4907. }
  4908. }
  4909. // withAllocAgent sets the old AllocAgent of the mutation.
  4910. func withAllocAgent(node *AllocAgent) allocagentOption {
  4911. return func(m *AllocAgentMutation) {
  4912. m.oldValue = func(context.Context) (*AllocAgent, error) {
  4913. return node, nil
  4914. }
  4915. m.id = &node.ID
  4916. }
  4917. }
  4918. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4919. // executed in a transaction (ent.Tx), a transactional client is returned.
  4920. func (m AllocAgentMutation) Client() *Client {
  4921. client := &Client{config: m.config}
  4922. client.init()
  4923. return client
  4924. }
  4925. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4926. // it returns an error otherwise.
  4927. func (m AllocAgentMutation) Tx() (*Tx, error) {
  4928. if _, ok := m.driver.(*txDriver); !ok {
  4929. return nil, errors.New("ent: mutation is not running in a transaction")
  4930. }
  4931. tx := &Tx{config: m.config}
  4932. tx.init()
  4933. return tx, nil
  4934. }
  4935. // SetID sets the value of the id field. Note that this
  4936. // operation is only accepted on creation of AllocAgent entities.
  4937. func (m *AllocAgentMutation) SetID(id uint64) {
  4938. m.id = &id
  4939. }
  4940. // ID returns the ID value in the mutation. Note that the ID is only available
  4941. // if it was provided to the builder or after it was returned from the database.
  4942. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  4943. if m.id == nil {
  4944. return
  4945. }
  4946. return *m.id, true
  4947. }
  4948. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4949. // That means, if the mutation is applied within a transaction with an isolation level such
  4950. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4951. // or updated by the mutation.
  4952. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  4953. switch {
  4954. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4955. id, exists := m.ID()
  4956. if exists {
  4957. return []uint64{id}, nil
  4958. }
  4959. fallthrough
  4960. case m.op.Is(OpUpdate | OpDelete):
  4961. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  4962. default:
  4963. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4964. }
  4965. }
  4966. // SetCreatedAt sets the "created_at" field.
  4967. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  4968. m.created_at = &t
  4969. }
  4970. // CreatedAt returns the value of the "created_at" field in the mutation.
  4971. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  4972. v := m.created_at
  4973. if v == nil {
  4974. return
  4975. }
  4976. return *v, true
  4977. }
  4978. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  4979. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  4980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4981. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4982. if !m.op.Is(OpUpdateOne) {
  4983. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4984. }
  4985. if m.id == nil || m.oldValue == nil {
  4986. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4987. }
  4988. oldValue, err := m.oldValue(ctx)
  4989. if err != nil {
  4990. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4991. }
  4992. return oldValue.CreatedAt, nil
  4993. }
  4994. // ResetCreatedAt resets all changes to the "created_at" field.
  4995. func (m *AllocAgentMutation) ResetCreatedAt() {
  4996. m.created_at = nil
  4997. }
  4998. // SetUpdatedAt sets the "updated_at" field.
  4999. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  5000. m.updated_at = &t
  5001. }
  5002. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5003. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  5004. v := m.updated_at
  5005. if v == nil {
  5006. return
  5007. }
  5008. return *v, true
  5009. }
  5010. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  5011. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5013. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5014. if !m.op.Is(OpUpdateOne) {
  5015. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5016. }
  5017. if m.id == nil || m.oldValue == nil {
  5018. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5019. }
  5020. oldValue, err := m.oldValue(ctx)
  5021. if err != nil {
  5022. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5023. }
  5024. return oldValue.UpdatedAt, nil
  5025. }
  5026. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5027. func (m *AllocAgentMutation) ResetUpdatedAt() {
  5028. m.updated_at = nil
  5029. }
  5030. // SetDeletedAt sets the "deleted_at" field.
  5031. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  5032. m.deleted_at = &t
  5033. }
  5034. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5035. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  5036. v := m.deleted_at
  5037. if v == nil {
  5038. return
  5039. }
  5040. return *v, true
  5041. }
  5042. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  5043. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5045. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5046. if !m.op.Is(OpUpdateOne) {
  5047. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5048. }
  5049. if m.id == nil || m.oldValue == nil {
  5050. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5051. }
  5052. oldValue, err := m.oldValue(ctx)
  5053. if err != nil {
  5054. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5055. }
  5056. return oldValue.DeletedAt, nil
  5057. }
  5058. // ClearDeletedAt clears the value of the "deleted_at" field.
  5059. func (m *AllocAgentMutation) ClearDeletedAt() {
  5060. m.deleted_at = nil
  5061. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  5062. }
  5063. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5064. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  5065. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  5066. return ok
  5067. }
  5068. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5069. func (m *AllocAgentMutation) ResetDeletedAt() {
  5070. m.deleted_at = nil
  5071. delete(m.clearedFields, allocagent.FieldDeletedAt)
  5072. }
  5073. // SetUserID sets the "user_id" field.
  5074. func (m *AllocAgentMutation) SetUserID(s string) {
  5075. m.user_id = &s
  5076. }
  5077. // UserID returns the value of the "user_id" field in the mutation.
  5078. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  5079. v := m.user_id
  5080. if v == nil {
  5081. return
  5082. }
  5083. return *v, true
  5084. }
  5085. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  5086. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5088. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  5089. if !m.op.Is(OpUpdateOne) {
  5090. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5091. }
  5092. if m.id == nil || m.oldValue == nil {
  5093. return v, errors.New("OldUserID requires an ID field in the mutation")
  5094. }
  5095. oldValue, err := m.oldValue(ctx)
  5096. if err != nil {
  5097. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5098. }
  5099. return oldValue.UserID, nil
  5100. }
  5101. // ClearUserID clears the value of the "user_id" field.
  5102. func (m *AllocAgentMutation) ClearUserID() {
  5103. m.user_id = nil
  5104. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  5105. }
  5106. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  5107. func (m *AllocAgentMutation) UserIDCleared() bool {
  5108. _, ok := m.clearedFields[allocagent.FieldUserID]
  5109. return ok
  5110. }
  5111. // ResetUserID resets all changes to the "user_id" field.
  5112. func (m *AllocAgentMutation) ResetUserID() {
  5113. m.user_id = nil
  5114. delete(m.clearedFields, allocagent.FieldUserID)
  5115. }
  5116. // SetOrganizationID sets the "organization_id" field.
  5117. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  5118. m.organization_id = &u
  5119. m.addorganization_id = nil
  5120. }
  5121. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5122. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  5123. v := m.organization_id
  5124. if v == nil {
  5125. return
  5126. }
  5127. return *v, true
  5128. }
  5129. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  5130. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5132. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5133. if !m.op.Is(OpUpdateOne) {
  5134. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5135. }
  5136. if m.id == nil || m.oldValue == nil {
  5137. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5138. }
  5139. oldValue, err := m.oldValue(ctx)
  5140. if err != nil {
  5141. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5142. }
  5143. return oldValue.OrganizationID, nil
  5144. }
  5145. // AddOrganizationID adds u to the "organization_id" field.
  5146. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  5147. if m.addorganization_id != nil {
  5148. *m.addorganization_id += u
  5149. } else {
  5150. m.addorganization_id = &u
  5151. }
  5152. }
  5153. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5154. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  5155. v := m.addorganization_id
  5156. if v == nil {
  5157. return
  5158. }
  5159. return *v, true
  5160. }
  5161. // ClearOrganizationID clears the value of the "organization_id" field.
  5162. func (m *AllocAgentMutation) ClearOrganizationID() {
  5163. m.organization_id = nil
  5164. m.addorganization_id = nil
  5165. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  5166. }
  5167. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  5168. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  5169. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  5170. return ok
  5171. }
  5172. // ResetOrganizationID resets all changes to the "organization_id" field.
  5173. func (m *AllocAgentMutation) ResetOrganizationID() {
  5174. m.organization_id = nil
  5175. m.addorganization_id = nil
  5176. delete(m.clearedFields, allocagent.FieldOrganizationID)
  5177. }
  5178. // SetAgents sets the "agents" field.
  5179. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  5180. m.agents = &u
  5181. m.appendagents = nil
  5182. }
  5183. // Agents returns the value of the "agents" field in the mutation.
  5184. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  5185. v := m.agents
  5186. if v == nil {
  5187. return
  5188. }
  5189. return *v, true
  5190. }
  5191. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  5192. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5194. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  5195. if !m.op.Is(OpUpdateOne) {
  5196. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  5197. }
  5198. if m.id == nil || m.oldValue == nil {
  5199. return v, errors.New("OldAgents requires an ID field in the mutation")
  5200. }
  5201. oldValue, err := m.oldValue(ctx)
  5202. if err != nil {
  5203. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  5204. }
  5205. return oldValue.Agents, nil
  5206. }
  5207. // AppendAgents adds u to the "agents" field.
  5208. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  5209. m.appendagents = append(m.appendagents, u...)
  5210. }
  5211. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  5212. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  5213. if len(m.appendagents) == 0 {
  5214. return nil, false
  5215. }
  5216. return m.appendagents, true
  5217. }
  5218. // ResetAgents resets all changes to the "agents" field.
  5219. func (m *AllocAgentMutation) ResetAgents() {
  5220. m.agents = nil
  5221. m.appendagents = nil
  5222. }
  5223. // SetStatus sets the "status" field.
  5224. func (m *AllocAgentMutation) SetStatus(i int) {
  5225. m.status = &i
  5226. m.addstatus = nil
  5227. }
  5228. // Status returns the value of the "status" field in the mutation.
  5229. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  5230. v := m.status
  5231. if v == nil {
  5232. return
  5233. }
  5234. return *v, true
  5235. }
  5236. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  5237. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  5238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5239. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  5240. if !m.op.Is(OpUpdateOne) {
  5241. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  5242. }
  5243. if m.id == nil || m.oldValue == nil {
  5244. return v, errors.New("OldStatus requires an ID field in the mutation")
  5245. }
  5246. oldValue, err := m.oldValue(ctx)
  5247. if err != nil {
  5248. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  5249. }
  5250. return oldValue.Status, nil
  5251. }
  5252. // AddStatus adds i to the "status" field.
  5253. func (m *AllocAgentMutation) AddStatus(i int) {
  5254. if m.addstatus != nil {
  5255. *m.addstatus += i
  5256. } else {
  5257. m.addstatus = &i
  5258. }
  5259. }
  5260. // AddedStatus returns the value that was added to the "status" field in this mutation.
  5261. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  5262. v := m.addstatus
  5263. if v == nil {
  5264. return
  5265. }
  5266. return *v, true
  5267. }
  5268. // ClearStatus clears the value of the "status" field.
  5269. func (m *AllocAgentMutation) ClearStatus() {
  5270. m.status = nil
  5271. m.addstatus = nil
  5272. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  5273. }
  5274. // StatusCleared returns if the "status" field was cleared in this mutation.
  5275. func (m *AllocAgentMutation) StatusCleared() bool {
  5276. _, ok := m.clearedFields[allocagent.FieldStatus]
  5277. return ok
  5278. }
  5279. // ResetStatus resets all changes to the "status" field.
  5280. func (m *AllocAgentMutation) ResetStatus() {
  5281. m.status = nil
  5282. m.addstatus = nil
  5283. delete(m.clearedFields, allocagent.FieldStatus)
  5284. }
  5285. // Where appends a list predicates to the AllocAgentMutation builder.
  5286. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  5287. m.predicates = append(m.predicates, ps...)
  5288. }
  5289. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  5290. // users can use type-assertion to append predicates that do not depend on any generated package.
  5291. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  5292. p := make([]predicate.AllocAgent, len(ps))
  5293. for i := range ps {
  5294. p[i] = ps[i]
  5295. }
  5296. m.Where(p...)
  5297. }
  5298. // Op returns the operation name.
  5299. func (m *AllocAgentMutation) Op() Op {
  5300. return m.op
  5301. }
  5302. // SetOp allows setting the mutation operation.
  5303. func (m *AllocAgentMutation) SetOp(op Op) {
  5304. m.op = op
  5305. }
  5306. // Type returns the node type of this mutation (AllocAgent).
  5307. func (m *AllocAgentMutation) Type() string {
  5308. return m.typ
  5309. }
  5310. // Fields returns all fields that were changed during this mutation. Note that in
  5311. // order to get all numeric fields that were incremented/decremented, call
  5312. // AddedFields().
  5313. func (m *AllocAgentMutation) Fields() []string {
  5314. fields := make([]string, 0, 7)
  5315. if m.created_at != nil {
  5316. fields = append(fields, allocagent.FieldCreatedAt)
  5317. }
  5318. if m.updated_at != nil {
  5319. fields = append(fields, allocagent.FieldUpdatedAt)
  5320. }
  5321. if m.deleted_at != nil {
  5322. fields = append(fields, allocagent.FieldDeletedAt)
  5323. }
  5324. if m.user_id != nil {
  5325. fields = append(fields, allocagent.FieldUserID)
  5326. }
  5327. if m.organization_id != nil {
  5328. fields = append(fields, allocagent.FieldOrganizationID)
  5329. }
  5330. if m.agents != nil {
  5331. fields = append(fields, allocagent.FieldAgents)
  5332. }
  5333. if m.status != nil {
  5334. fields = append(fields, allocagent.FieldStatus)
  5335. }
  5336. return fields
  5337. }
  5338. // Field returns the value of a field with the given name. The second boolean
  5339. // return value indicates that this field was not set, or was not defined in the
  5340. // schema.
  5341. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  5342. switch name {
  5343. case allocagent.FieldCreatedAt:
  5344. return m.CreatedAt()
  5345. case allocagent.FieldUpdatedAt:
  5346. return m.UpdatedAt()
  5347. case allocagent.FieldDeletedAt:
  5348. return m.DeletedAt()
  5349. case allocagent.FieldUserID:
  5350. return m.UserID()
  5351. case allocagent.FieldOrganizationID:
  5352. return m.OrganizationID()
  5353. case allocagent.FieldAgents:
  5354. return m.Agents()
  5355. case allocagent.FieldStatus:
  5356. return m.Status()
  5357. }
  5358. return nil, false
  5359. }
  5360. // OldField returns the old value of the field from the database. An error is
  5361. // returned if the mutation operation is not UpdateOne, or the query to the
  5362. // database failed.
  5363. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5364. switch name {
  5365. case allocagent.FieldCreatedAt:
  5366. return m.OldCreatedAt(ctx)
  5367. case allocagent.FieldUpdatedAt:
  5368. return m.OldUpdatedAt(ctx)
  5369. case allocagent.FieldDeletedAt:
  5370. return m.OldDeletedAt(ctx)
  5371. case allocagent.FieldUserID:
  5372. return m.OldUserID(ctx)
  5373. case allocagent.FieldOrganizationID:
  5374. return m.OldOrganizationID(ctx)
  5375. case allocagent.FieldAgents:
  5376. return m.OldAgents(ctx)
  5377. case allocagent.FieldStatus:
  5378. return m.OldStatus(ctx)
  5379. }
  5380. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  5381. }
  5382. // SetField sets the value of a field with the given name. It returns an error if
  5383. // the field is not defined in the schema, or if the type mismatched the field
  5384. // type.
  5385. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  5386. switch name {
  5387. case allocagent.FieldCreatedAt:
  5388. v, ok := value.(time.Time)
  5389. if !ok {
  5390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5391. }
  5392. m.SetCreatedAt(v)
  5393. return nil
  5394. case allocagent.FieldUpdatedAt:
  5395. v, ok := value.(time.Time)
  5396. if !ok {
  5397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5398. }
  5399. m.SetUpdatedAt(v)
  5400. return nil
  5401. case allocagent.FieldDeletedAt:
  5402. v, ok := value.(time.Time)
  5403. if !ok {
  5404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5405. }
  5406. m.SetDeletedAt(v)
  5407. return nil
  5408. case allocagent.FieldUserID:
  5409. v, ok := value.(string)
  5410. if !ok {
  5411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5412. }
  5413. m.SetUserID(v)
  5414. return nil
  5415. case allocagent.FieldOrganizationID:
  5416. v, ok := value.(uint64)
  5417. if !ok {
  5418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5419. }
  5420. m.SetOrganizationID(v)
  5421. return nil
  5422. case allocagent.FieldAgents:
  5423. v, ok := value.([]uint64)
  5424. if !ok {
  5425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5426. }
  5427. m.SetAgents(v)
  5428. return nil
  5429. case allocagent.FieldStatus:
  5430. v, ok := value.(int)
  5431. if !ok {
  5432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5433. }
  5434. m.SetStatus(v)
  5435. return nil
  5436. }
  5437. return fmt.Errorf("unknown AllocAgent field %s", name)
  5438. }
  5439. // AddedFields returns all numeric fields that were incremented/decremented during
  5440. // this mutation.
  5441. func (m *AllocAgentMutation) AddedFields() []string {
  5442. var fields []string
  5443. if m.addorganization_id != nil {
  5444. fields = append(fields, allocagent.FieldOrganizationID)
  5445. }
  5446. if m.addstatus != nil {
  5447. fields = append(fields, allocagent.FieldStatus)
  5448. }
  5449. return fields
  5450. }
  5451. // AddedField returns the numeric value that was incremented/decremented on a field
  5452. // with the given name. The second boolean return value indicates that this field
  5453. // was not set, or was not defined in the schema.
  5454. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  5455. switch name {
  5456. case allocagent.FieldOrganizationID:
  5457. return m.AddedOrganizationID()
  5458. case allocagent.FieldStatus:
  5459. return m.AddedStatus()
  5460. }
  5461. return nil, false
  5462. }
  5463. // AddField adds the value to the field with the given name. It returns an error if
  5464. // the field is not defined in the schema, or if the type mismatched the field
  5465. // type.
  5466. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  5467. switch name {
  5468. case allocagent.FieldOrganizationID:
  5469. v, ok := value.(int64)
  5470. if !ok {
  5471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5472. }
  5473. m.AddOrganizationID(v)
  5474. return nil
  5475. case allocagent.FieldStatus:
  5476. v, ok := value.(int)
  5477. if !ok {
  5478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5479. }
  5480. m.AddStatus(v)
  5481. return nil
  5482. }
  5483. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  5484. }
  5485. // ClearedFields returns all nullable fields that were cleared during this
  5486. // mutation.
  5487. func (m *AllocAgentMutation) ClearedFields() []string {
  5488. var fields []string
  5489. if m.FieldCleared(allocagent.FieldDeletedAt) {
  5490. fields = append(fields, allocagent.FieldDeletedAt)
  5491. }
  5492. if m.FieldCleared(allocagent.FieldUserID) {
  5493. fields = append(fields, allocagent.FieldUserID)
  5494. }
  5495. if m.FieldCleared(allocagent.FieldOrganizationID) {
  5496. fields = append(fields, allocagent.FieldOrganizationID)
  5497. }
  5498. if m.FieldCleared(allocagent.FieldStatus) {
  5499. fields = append(fields, allocagent.FieldStatus)
  5500. }
  5501. return fields
  5502. }
  5503. // FieldCleared returns a boolean indicating if a field with the given name was
  5504. // cleared in this mutation.
  5505. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  5506. _, ok := m.clearedFields[name]
  5507. return ok
  5508. }
  5509. // ClearField clears the value of the field with the given name. It returns an
  5510. // error if the field is not defined in the schema.
  5511. func (m *AllocAgentMutation) ClearField(name string) error {
  5512. switch name {
  5513. case allocagent.FieldDeletedAt:
  5514. m.ClearDeletedAt()
  5515. return nil
  5516. case allocagent.FieldUserID:
  5517. m.ClearUserID()
  5518. return nil
  5519. case allocagent.FieldOrganizationID:
  5520. m.ClearOrganizationID()
  5521. return nil
  5522. case allocagent.FieldStatus:
  5523. m.ClearStatus()
  5524. return nil
  5525. }
  5526. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  5527. }
  5528. // ResetField resets all changes in the mutation for the field with the given name.
  5529. // It returns an error if the field is not defined in the schema.
  5530. func (m *AllocAgentMutation) ResetField(name string) error {
  5531. switch name {
  5532. case allocagent.FieldCreatedAt:
  5533. m.ResetCreatedAt()
  5534. return nil
  5535. case allocagent.FieldUpdatedAt:
  5536. m.ResetUpdatedAt()
  5537. return nil
  5538. case allocagent.FieldDeletedAt:
  5539. m.ResetDeletedAt()
  5540. return nil
  5541. case allocagent.FieldUserID:
  5542. m.ResetUserID()
  5543. return nil
  5544. case allocagent.FieldOrganizationID:
  5545. m.ResetOrganizationID()
  5546. return nil
  5547. case allocagent.FieldAgents:
  5548. m.ResetAgents()
  5549. return nil
  5550. case allocagent.FieldStatus:
  5551. m.ResetStatus()
  5552. return nil
  5553. }
  5554. return fmt.Errorf("unknown AllocAgent field %s", name)
  5555. }
  5556. // AddedEdges returns all edge names that were set/added in this mutation.
  5557. func (m *AllocAgentMutation) AddedEdges() []string {
  5558. edges := make([]string, 0, 0)
  5559. return edges
  5560. }
  5561. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5562. // name in this mutation.
  5563. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  5564. return nil
  5565. }
  5566. // RemovedEdges returns all edge names that were removed in this mutation.
  5567. func (m *AllocAgentMutation) RemovedEdges() []string {
  5568. edges := make([]string, 0, 0)
  5569. return edges
  5570. }
  5571. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5572. // the given name in this mutation.
  5573. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  5574. return nil
  5575. }
  5576. // ClearedEdges returns all edge names that were cleared in this mutation.
  5577. func (m *AllocAgentMutation) ClearedEdges() []string {
  5578. edges := make([]string, 0, 0)
  5579. return edges
  5580. }
  5581. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5582. // was cleared in this mutation.
  5583. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  5584. return false
  5585. }
  5586. // ClearEdge clears the value of the edge with the given name. It returns an error
  5587. // if that edge is not defined in the schema.
  5588. func (m *AllocAgentMutation) ClearEdge(name string) error {
  5589. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  5590. }
  5591. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5592. // It returns an error if the edge is not defined in the schema.
  5593. func (m *AllocAgentMutation) ResetEdge(name string) error {
  5594. return fmt.Errorf("unknown AllocAgent edge %s", name)
  5595. }
  5596. // ApiKeyMutation represents an operation that mutates the ApiKey nodes in the graph.
  5597. type ApiKeyMutation struct {
  5598. config
  5599. op Op
  5600. typ string
  5601. id *uint64
  5602. created_at *time.Time
  5603. updated_at *time.Time
  5604. deleted_at *time.Time
  5605. title *string
  5606. key *string
  5607. organization_id *uint64
  5608. addorganization_id *int64
  5609. custom_agent_base *string
  5610. custom_agent_key *string
  5611. openai_base *string
  5612. openai_key *string
  5613. clearedFields map[string]struct{}
  5614. agent *uint64
  5615. clearedagent bool
  5616. done bool
  5617. oldValue func(context.Context) (*ApiKey, error)
  5618. predicates []predicate.ApiKey
  5619. }
  5620. var _ ent.Mutation = (*ApiKeyMutation)(nil)
  5621. // apikeyOption allows management of the mutation configuration using functional options.
  5622. type apikeyOption func(*ApiKeyMutation)
  5623. // newApiKeyMutation creates new mutation for the ApiKey entity.
  5624. func newApiKeyMutation(c config, op Op, opts ...apikeyOption) *ApiKeyMutation {
  5625. m := &ApiKeyMutation{
  5626. config: c,
  5627. op: op,
  5628. typ: TypeApiKey,
  5629. clearedFields: make(map[string]struct{}),
  5630. }
  5631. for _, opt := range opts {
  5632. opt(m)
  5633. }
  5634. return m
  5635. }
  5636. // withApiKeyID sets the ID field of the mutation.
  5637. func withApiKeyID(id uint64) apikeyOption {
  5638. return func(m *ApiKeyMutation) {
  5639. var (
  5640. err error
  5641. once sync.Once
  5642. value *ApiKey
  5643. )
  5644. m.oldValue = func(ctx context.Context) (*ApiKey, error) {
  5645. once.Do(func() {
  5646. if m.done {
  5647. err = errors.New("querying old values post mutation is not allowed")
  5648. } else {
  5649. value, err = m.Client().ApiKey.Get(ctx, id)
  5650. }
  5651. })
  5652. return value, err
  5653. }
  5654. m.id = &id
  5655. }
  5656. }
  5657. // withApiKey sets the old ApiKey of the mutation.
  5658. func withApiKey(node *ApiKey) apikeyOption {
  5659. return func(m *ApiKeyMutation) {
  5660. m.oldValue = func(context.Context) (*ApiKey, error) {
  5661. return node, nil
  5662. }
  5663. m.id = &node.ID
  5664. }
  5665. }
  5666. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5667. // executed in a transaction (ent.Tx), a transactional client is returned.
  5668. func (m ApiKeyMutation) Client() *Client {
  5669. client := &Client{config: m.config}
  5670. client.init()
  5671. return client
  5672. }
  5673. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5674. // it returns an error otherwise.
  5675. func (m ApiKeyMutation) Tx() (*Tx, error) {
  5676. if _, ok := m.driver.(*txDriver); !ok {
  5677. return nil, errors.New("ent: mutation is not running in a transaction")
  5678. }
  5679. tx := &Tx{config: m.config}
  5680. tx.init()
  5681. return tx, nil
  5682. }
  5683. // SetID sets the value of the id field. Note that this
  5684. // operation is only accepted on creation of ApiKey entities.
  5685. func (m *ApiKeyMutation) SetID(id uint64) {
  5686. m.id = &id
  5687. }
  5688. // ID returns the ID value in the mutation. Note that the ID is only available
  5689. // if it was provided to the builder or after it was returned from the database.
  5690. func (m *ApiKeyMutation) ID() (id uint64, exists bool) {
  5691. if m.id == nil {
  5692. return
  5693. }
  5694. return *m.id, true
  5695. }
  5696. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5697. // That means, if the mutation is applied within a transaction with an isolation level such
  5698. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5699. // or updated by the mutation.
  5700. func (m *ApiKeyMutation) IDs(ctx context.Context) ([]uint64, error) {
  5701. switch {
  5702. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5703. id, exists := m.ID()
  5704. if exists {
  5705. return []uint64{id}, nil
  5706. }
  5707. fallthrough
  5708. case m.op.Is(OpUpdate | OpDelete):
  5709. return m.Client().ApiKey.Query().Where(m.predicates...).IDs(ctx)
  5710. default:
  5711. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5712. }
  5713. }
  5714. // SetCreatedAt sets the "created_at" field.
  5715. func (m *ApiKeyMutation) SetCreatedAt(t time.Time) {
  5716. m.created_at = &t
  5717. }
  5718. // CreatedAt returns the value of the "created_at" field in the mutation.
  5719. func (m *ApiKeyMutation) CreatedAt() (r time.Time, exists bool) {
  5720. v := m.created_at
  5721. if v == nil {
  5722. return
  5723. }
  5724. return *v, true
  5725. }
  5726. // OldCreatedAt returns the old "created_at" field's value of the ApiKey entity.
  5727. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5729. func (m *ApiKeyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5730. if !m.op.Is(OpUpdateOne) {
  5731. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5732. }
  5733. if m.id == nil || m.oldValue == nil {
  5734. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5735. }
  5736. oldValue, err := m.oldValue(ctx)
  5737. if err != nil {
  5738. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5739. }
  5740. return oldValue.CreatedAt, nil
  5741. }
  5742. // ResetCreatedAt resets all changes to the "created_at" field.
  5743. func (m *ApiKeyMutation) ResetCreatedAt() {
  5744. m.created_at = nil
  5745. }
  5746. // SetUpdatedAt sets the "updated_at" field.
  5747. func (m *ApiKeyMutation) SetUpdatedAt(t time.Time) {
  5748. m.updated_at = &t
  5749. }
  5750. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5751. func (m *ApiKeyMutation) UpdatedAt() (r time.Time, exists bool) {
  5752. v := m.updated_at
  5753. if v == nil {
  5754. return
  5755. }
  5756. return *v, true
  5757. }
  5758. // OldUpdatedAt returns the old "updated_at" field's value of the ApiKey entity.
  5759. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5761. func (m *ApiKeyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5762. if !m.op.Is(OpUpdateOne) {
  5763. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5764. }
  5765. if m.id == nil || m.oldValue == nil {
  5766. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5767. }
  5768. oldValue, err := m.oldValue(ctx)
  5769. if err != nil {
  5770. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5771. }
  5772. return oldValue.UpdatedAt, nil
  5773. }
  5774. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5775. func (m *ApiKeyMutation) ResetUpdatedAt() {
  5776. m.updated_at = nil
  5777. }
  5778. // SetDeletedAt sets the "deleted_at" field.
  5779. func (m *ApiKeyMutation) SetDeletedAt(t time.Time) {
  5780. m.deleted_at = &t
  5781. }
  5782. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5783. func (m *ApiKeyMutation) DeletedAt() (r time.Time, exists bool) {
  5784. v := m.deleted_at
  5785. if v == nil {
  5786. return
  5787. }
  5788. return *v, true
  5789. }
  5790. // OldDeletedAt returns the old "deleted_at" field's value of the ApiKey entity.
  5791. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5793. func (m *ApiKeyMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5794. if !m.op.Is(OpUpdateOne) {
  5795. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5796. }
  5797. if m.id == nil || m.oldValue == nil {
  5798. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5799. }
  5800. oldValue, err := m.oldValue(ctx)
  5801. if err != nil {
  5802. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5803. }
  5804. return oldValue.DeletedAt, nil
  5805. }
  5806. // ClearDeletedAt clears the value of the "deleted_at" field.
  5807. func (m *ApiKeyMutation) ClearDeletedAt() {
  5808. m.deleted_at = nil
  5809. m.clearedFields[apikey.FieldDeletedAt] = struct{}{}
  5810. }
  5811. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5812. func (m *ApiKeyMutation) DeletedAtCleared() bool {
  5813. _, ok := m.clearedFields[apikey.FieldDeletedAt]
  5814. return ok
  5815. }
  5816. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5817. func (m *ApiKeyMutation) ResetDeletedAt() {
  5818. m.deleted_at = nil
  5819. delete(m.clearedFields, apikey.FieldDeletedAt)
  5820. }
  5821. // SetTitle sets the "title" field.
  5822. func (m *ApiKeyMutation) SetTitle(s string) {
  5823. m.title = &s
  5824. }
  5825. // Title returns the value of the "title" field in the mutation.
  5826. func (m *ApiKeyMutation) Title() (r string, exists bool) {
  5827. v := m.title
  5828. if v == nil {
  5829. return
  5830. }
  5831. return *v, true
  5832. }
  5833. // OldTitle returns the old "title" field's value of the ApiKey entity.
  5834. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5836. func (m *ApiKeyMutation) OldTitle(ctx context.Context) (v string, err error) {
  5837. if !m.op.Is(OpUpdateOne) {
  5838. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  5839. }
  5840. if m.id == nil || m.oldValue == nil {
  5841. return v, errors.New("OldTitle requires an ID field in the mutation")
  5842. }
  5843. oldValue, err := m.oldValue(ctx)
  5844. if err != nil {
  5845. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  5846. }
  5847. return oldValue.Title, nil
  5848. }
  5849. // ClearTitle clears the value of the "title" field.
  5850. func (m *ApiKeyMutation) ClearTitle() {
  5851. m.title = nil
  5852. m.clearedFields[apikey.FieldTitle] = struct{}{}
  5853. }
  5854. // TitleCleared returns if the "title" field was cleared in this mutation.
  5855. func (m *ApiKeyMutation) TitleCleared() bool {
  5856. _, ok := m.clearedFields[apikey.FieldTitle]
  5857. return ok
  5858. }
  5859. // ResetTitle resets all changes to the "title" field.
  5860. func (m *ApiKeyMutation) ResetTitle() {
  5861. m.title = nil
  5862. delete(m.clearedFields, apikey.FieldTitle)
  5863. }
  5864. // SetKey sets the "key" field.
  5865. func (m *ApiKeyMutation) SetKey(s string) {
  5866. m.key = &s
  5867. }
  5868. // Key returns the value of the "key" field in the mutation.
  5869. func (m *ApiKeyMutation) Key() (r string, exists bool) {
  5870. v := m.key
  5871. if v == nil {
  5872. return
  5873. }
  5874. return *v, true
  5875. }
  5876. // OldKey returns the old "key" field's value of the ApiKey entity.
  5877. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5879. func (m *ApiKeyMutation) OldKey(ctx context.Context) (v string, err error) {
  5880. if !m.op.Is(OpUpdateOne) {
  5881. return v, errors.New("OldKey is only allowed on UpdateOne operations")
  5882. }
  5883. if m.id == nil || m.oldValue == nil {
  5884. return v, errors.New("OldKey requires an ID field in the mutation")
  5885. }
  5886. oldValue, err := m.oldValue(ctx)
  5887. if err != nil {
  5888. return v, fmt.Errorf("querying old value for OldKey: %w", err)
  5889. }
  5890. return oldValue.Key, nil
  5891. }
  5892. // ClearKey clears the value of the "key" field.
  5893. func (m *ApiKeyMutation) ClearKey() {
  5894. m.key = nil
  5895. m.clearedFields[apikey.FieldKey] = struct{}{}
  5896. }
  5897. // KeyCleared returns if the "key" field was cleared in this mutation.
  5898. func (m *ApiKeyMutation) KeyCleared() bool {
  5899. _, ok := m.clearedFields[apikey.FieldKey]
  5900. return ok
  5901. }
  5902. // ResetKey resets all changes to the "key" field.
  5903. func (m *ApiKeyMutation) ResetKey() {
  5904. m.key = nil
  5905. delete(m.clearedFields, apikey.FieldKey)
  5906. }
  5907. // SetOrganizationID sets the "organization_id" field.
  5908. func (m *ApiKeyMutation) SetOrganizationID(u uint64) {
  5909. m.organization_id = &u
  5910. m.addorganization_id = nil
  5911. }
  5912. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5913. func (m *ApiKeyMutation) OrganizationID() (r uint64, exists bool) {
  5914. v := m.organization_id
  5915. if v == nil {
  5916. return
  5917. }
  5918. return *v, true
  5919. }
  5920. // OldOrganizationID returns the old "organization_id" field's value of the ApiKey entity.
  5921. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5923. func (m *ApiKeyMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5924. if !m.op.Is(OpUpdateOne) {
  5925. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5926. }
  5927. if m.id == nil || m.oldValue == nil {
  5928. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5929. }
  5930. oldValue, err := m.oldValue(ctx)
  5931. if err != nil {
  5932. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5933. }
  5934. return oldValue.OrganizationID, nil
  5935. }
  5936. // AddOrganizationID adds u to the "organization_id" field.
  5937. func (m *ApiKeyMutation) AddOrganizationID(u int64) {
  5938. if m.addorganization_id != nil {
  5939. *m.addorganization_id += u
  5940. } else {
  5941. m.addorganization_id = &u
  5942. }
  5943. }
  5944. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5945. func (m *ApiKeyMutation) AddedOrganizationID() (r int64, exists bool) {
  5946. v := m.addorganization_id
  5947. if v == nil {
  5948. return
  5949. }
  5950. return *v, true
  5951. }
  5952. // ResetOrganizationID resets all changes to the "organization_id" field.
  5953. func (m *ApiKeyMutation) ResetOrganizationID() {
  5954. m.organization_id = nil
  5955. m.addorganization_id = nil
  5956. }
  5957. // SetAgentID sets the "agent_id" field.
  5958. func (m *ApiKeyMutation) SetAgentID(u uint64) {
  5959. m.agent = &u
  5960. }
  5961. // AgentID returns the value of the "agent_id" field in the mutation.
  5962. func (m *ApiKeyMutation) AgentID() (r uint64, exists bool) {
  5963. v := m.agent
  5964. if v == nil {
  5965. return
  5966. }
  5967. return *v, true
  5968. }
  5969. // OldAgentID returns the old "agent_id" field's value of the ApiKey entity.
  5970. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  5971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5972. func (m *ApiKeyMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  5973. if !m.op.Is(OpUpdateOne) {
  5974. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  5975. }
  5976. if m.id == nil || m.oldValue == nil {
  5977. return v, errors.New("OldAgentID requires an ID field in the mutation")
  5978. }
  5979. oldValue, err := m.oldValue(ctx)
  5980. if err != nil {
  5981. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  5982. }
  5983. return oldValue.AgentID, nil
  5984. }
  5985. // ResetAgentID resets all changes to the "agent_id" field.
  5986. func (m *ApiKeyMutation) ResetAgentID() {
  5987. m.agent = nil
  5988. }
  5989. // SetCustomAgentBase sets the "custom_agent_base" field.
  5990. func (m *ApiKeyMutation) SetCustomAgentBase(s string) {
  5991. m.custom_agent_base = &s
  5992. }
  5993. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  5994. func (m *ApiKeyMutation) CustomAgentBase() (r string, exists bool) {
  5995. v := m.custom_agent_base
  5996. if v == nil {
  5997. return
  5998. }
  5999. return *v, true
  6000. }
  6001. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the ApiKey entity.
  6002. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6004. func (m *ApiKeyMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  6005. if !m.op.Is(OpUpdateOne) {
  6006. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  6007. }
  6008. if m.id == nil || m.oldValue == nil {
  6009. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  6010. }
  6011. oldValue, err := m.oldValue(ctx)
  6012. if err != nil {
  6013. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  6014. }
  6015. return oldValue.CustomAgentBase, nil
  6016. }
  6017. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  6018. func (m *ApiKeyMutation) ClearCustomAgentBase() {
  6019. m.custom_agent_base = nil
  6020. m.clearedFields[apikey.FieldCustomAgentBase] = struct{}{}
  6021. }
  6022. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  6023. func (m *ApiKeyMutation) CustomAgentBaseCleared() bool {
  6024. _, ok := m.clearedFields[apikey.FieldCustomAgentBase]
  6025. return ok
  6026. }
  6027. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  6028. func (m *ApiKeyMutation) ResetCustomAgentBase() {
  6029. m.custom_agent_base = nil
  6030. delete(m.clearedFields, apikey.FieldCustomAgentBase)
  6031. }
  6032. // SetCustomAgentKey sets the "custom_agent_key" field.
  6033. func (m *ApiKeyMutation) SetCustomAgentKey(s string) {
  6034. m.custom_agent_key = &s
  6035. }
  6036. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  6037. func (m *ApiKeyMutation) CustomAgentKey() (r string, exists bool) {
  6038. v := m.custom_agent_key
  6039. if v == nil {
  6040. return
  6041. }
  6042. return *v, true
  6043. }
  6044. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the ApiKey entity.
  6045. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6047. func (m *ApiKeyMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  6048. if !m.op.Is(OpUpdateOne) {
  6049. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  6050. }
  6051. if m.id == nil || m.oldValue == nil {
  6052. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  6053. }
  6054. oldValue, err := m.oldValue(ctx)
  6055. if err != nil {
  6056. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  6057. }
  6058. return oldValue.CustomAgentKey, nil
  6059. }
  6060. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  6061. func (m *ApiKeyMutation) ClearCustomAgentKey() {
  6062. m.custom_agent_key = nil
  6063. m.clearedFields[apikey.FieldCustomAgentKey] = struct{}{}
  6064. }
  6065. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  6066. func (m *ApiKeyMutation) CustomAgentKeyCleared() bool {
  6067. _, ok := m.clearedFields[apikey.FieldCustomAgentKey]
  6068. return ok
  6069. }
  6070. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  6071. func (m *ApiKeyMutation) ResetCustomAgentKey() {
  6072. m.custom_agent_key = nil
  6073. delete(m.clearedFields, apikey.FieldCustomAgentKey)
  6074. }
  6075. // SetOpenaiBase sets the "openai_base" field.
  6076. func (m *ApiKeyMutation) SetOpenaiBase(s string) {
  6077. m.openai_base = &s
  6078. }
  6079. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  6080. func (m *ApiKeyMutation) OpenaiBase() (r string, exists bool) {
  6081. v := m.openai_base
  6082. if v == nil {
  6083. return
  6084. }
  6085. return *v, true
  6086. }
  6087. // OldOpenaiBase returns the old "openai_base" field's value of the ApiKey entity.
  6088. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6090. func (m *ApiKeyMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  6091. if !m.op.Is(OpUpdateOne) {
  6092. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  6093. }
  6094. if m.id == nil || m.oldValue == nil {
  6095. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  6096. }
  6097. oldValue, err := m.oldValue(ctx)
  6098. if err != nil {
  6099. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  6100. }
  6101. return oldValue.OpenaiBase, nil
  6102. }
  6103. // ClearOpenaiBase clears the value of the "openai_base" field.
  6104. func (m *ApiKeyMutation) ClearOpenaiBase() {
  6105. m.openai_base = nil
  6106. m.clearedFields[apikey.FieldOpenaiBase] = struct{}{}
  6107. }
  6108. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  6109. func (m *ApiKeyMutation) OpenaiBaseCleared() bool {
  6110. _, ok := m.clearedFields[apikey.FieldOpenaiBase]
  6111. return ok
  6112. }
  6113. // ResetOpenaiBase resets all changes to the "openai_base" field.
  6114. func (m *ApiKeyMutation) ResetOpenaiBase() {
  6115. m.openai_base = nil
  6116. delete(m.clearedFields, apikey.FieldOpenaiBase)
  6117. }
  6118. // SetOpenaiKey sets the "openai_key" field.
  6119. func (m *ApiKeyMutation) SetOpenaiKey(s string) {
  6120. m.openai_key = &s
  6121. }
  6122. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  6123. func (m *ApiKeyMutation) OpenaiKey() (r string, exists bool) {
  6124. v := m.openai_key
  6125. if v == nil {
  6126. return
  6127. }
  6128. return *v, true
  6129. }
  6130. // OldOpenaiKey returns the old "openai_key" field's value of the ApiKey entity.
  6131. // If the ApiKey object wasn't provided to the builder, the object is fetched from the database.
  6132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6133. func (m *ApiKeyMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  6134. if !m.op.Is(OpUpdateOne) {
  6135. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  6136. }
  6137. if m.id == nil || m.oldValue == nil {
  6138. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  6139. }
  6140. oldValue, err := m.oldValue(ctx)
  6141. if err != nil {
  6142. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  6143. }
  6144. return oldValue.OpenaiKey, nil
  6145. }
  6146. // ClearOpenaiKey clears the value of the "openai_key" field.
  6147. func (m *ApiKeyMutation) ClearOpenaiKey() {
  6148. m.openai_key = nil
  6149. m.clearedFields[apikey.FieldOpenaiKey] = struct{}{}
  6150. }
  6151. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  6152. func (m *ApiKeyMutation) OpenaiKeyCleared() bool {
  6153. _, ok := m.clearedFields[apikey.FieldOpenaiKey]
  6154. return ok
  6155. }
  6156. // ResetOpenaiKey resets all changes to the "openai_key" field.
  6157. func (m *ApiKeyMutation) ResetOpenaiKey() {
  6158. m.openai_key = nil
  6159. delete(m.clearedFields, apikey.FieldOpenaiKey)
  6160. }
  6161. // ClearAgent clears the "agent" edge to the Agent entity.
  6162. func (m *ApiKeyMutation) ClearAgent() {
  6163. m.clearedagent = true
  6164. m.clearedFields[apikey.FieldAgentID] = struct{}{}
  6165. }
  6166. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  6167. func (m *ApiKeyMutation) AgentCleared() bool {
  6168. return m.clearedagent
  6169. }
  6170. // AgentIDs returns the "agent" edge IDs in the mutation.
  6171. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  6172. // AgentID instead. It exists only for internal usage by the builders.
  6173. func (m *ApiKeyMutation) AgentIDs() (ids []uint64) {
  6174. if id := m.agent; id != nil {
  6175. ids = append(ids, *id)
  6176. }
  6177. return
  6178. }
  6179. // ResetAgent resets all changes to the "agent" edge.
  6180. func (m *ApiKeyMutation) ResetAgent() {
  6181. m.agent = nil
  6182. m.clearedagent = false
  6183. }
  6184. // Where appends a list predicates to the ApiKeyMutation builder.
  6185. func (m *ApiKeyMutation) Where(ps ...predicate.ApiKey) {
  6186. m.predicates = append(m.predicates, ps...)
  6187. }
  6188. // WhereP appends storage-level predicates to the ApiKeyMutation builder. Using this method,
  6189. // users can use type-assertion to append predicates that do not depend on any generated package.
  6190. func (m *ApiKeyMutation) WhereP(ps ...func(*sql.Selector)) {
  6191. p := make([]predicate.ApiKey, len(ps))
  6192. for i := range ps {
  6193. p[i] = ps[i]
  6194. }
  6195. m.Where(p...)
  6196. }
  6197. // Op returns the operation name.
  6198. func (m *ApiKeyMutation) Op() Op {
  6199. return m.op
  6200. }
  6201. // SetOp allows setting the mutation operation.
  6202. func (m *ApiKeyMutation) SetOp(op Op) {
  6203. m.op = op
  6204. }
  6205. // Type returns the node type of this mutation (ApiKey).
  6206. func (m *ApiKeyMutation) Type() string {
  6207. return m.typ
  6208. }
  6209. // Fields returns all fields that were changed during this mutation. Note that in
  6210. // order to get all numeric fields that were incremented/decremented, call
  6211. // AddedFields().
  6212. func (m *ApiKeyMutation) Fields() []string {
  6213. fields := make([]string, 0, 11)
  6214. if m.created_at != nil {
  6215. fields = append(fields, apikey.FieldCreatedAt)
  6216. }
  6217. if m.updated_at != nil {
  6218. fields = append(fields, apikey.FieldUpdatedAt)
  6219. }
  6220. if m.deleted_at != nil {
  6221. fields = append(fields, apikey.FieldDeletedAt)
  6222. }
  6223. if m.title != nil {
  6224. fields = append(fields, apikey.FieldTitle)
  6225. }
  6226. if m.key != nil {
  6227. fields = append(fields, apikey.FieldKey)
  6228. }
  6229. if m.organization_id != nil {
  6230. fields = append(fields, apikey.FieldOrganizationID)
  6231. }
  6232. if m.agent != nil {
  6233. fields = append(fields, apikey.FieldAgentID)
  6234. }
  6235. if m.custom_agent_base != nil {
  6236. fields = append(fields, apikey.FieldCustomAgentBase)
  6237. }
  6238. if m.custom_agent_key != nil {
  6239. fields = append(fields, apikey.FieldCustomAgentKey)
  6240. }
  6241. if m.openai_base != nil {
  6242. fields = append(fields, apikey.FieldOpenaiBase)
  6243. }
  6244. if m.openai_key != nil {
  6245. fields = append(fields, apikey.FieldOpenaiKey)
  6246. }
  6247. return fields
  6248. }
  6249. // Field returns the value of a field with the given name. The second boolean
  6250. // return value indicates that this field was not set, or was not defined in the
  6251. // schema.
  6252. func (m *ApiKeyMutation) Field(name string) (ent.Value, bool) {
  6253. switch name {
  6254. case apikey.FieldCreatedAt:
  6255. return m.CreatedAt()
  6256. case apikey.FieldUpdatedAt:
  6257. return m.UpdatedAt()
  6258. case apikey.FieldDeletedAt:
  6259. return m.DeletedAt()
  6260. case apikey.FieldTitle:
  6261. return m.Title()
  6262. case apikey.FieldKey:
  6263. return m.Key()
  6264. case apikey.FieldOrganizationID:
  6265. return m.OrganizationID()
  6266. case apikey.FieldAgentID:
  6267. return m.AgentID()
  6268. case apikey.FieldCustomAgentBase:
  6269. return m.CustomAgentBase()
  6270. case apikey.FieldCustomAgentKey:
  6271. return m.CustomAgentKey()
  6272. case apikey.FieldOpenaiBase:
  6273. return m.OpenaiBase()
  6274. case apikey.FieldOpenaiKey:
  6275. return m.OpenaiKey()
  6276. }
  6277. return nil, false
  6278. }
  6279. // OldField returns the old value of the field from the database. An error is
  6280. // returned if the mutation operation is not UpdateOne, or the query to the
  6281. // database failed.
  6282. func (m *ApiKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6283. switch name {
  6284. case apikey.FieldCreatedAt:
  6285. return m.OldCreatedAt(ctx)
  6286. case apikey.FieldUpdatedAt:
  6287. return m.OldUpdatedAt(ctx)
  6288. case apikey.FieldDeletedAt:
  6289. return m.OldDeletedAt(ctx)
  6290. case apikey.FieldTitle:
  6291. return m.OldTitle(ctx)
  6292. case apikey.FieldKey:
  6293. return m.OldKey(ctx)
  6294. case apikey.FieldOrganizationID:
  6295. return m.OldOrganizationID(ctx)
  6296. case apikey.FieldAgentID:
  6297. return m.OldAgentID(ctx)
  6298. case apikey.FieldCustomAgentBase:
  6299. return m.OldCustomAgentBase(ctx)
  6300. case apikey.FieldCustomAgentKey:
  6301. return m.OldCustomAgentKey(ctx)
  6302. case apikey.FieldOpenaiBase:
  6303. return m.OldOpenaiBase(ctx)
  6304. case apikey.FieldOpenaiKey:
  6305. return m.OldOpenaiKey(ctx)
  6306. }
  6307. return nil, fmt.Errorf("unknown ApiKey field %s", name)
  6308. }
  6309. // SetField sets the value of a field with the given name. It returns an error if
  6310. // the field is not defined in the schema, or if the type mismatched the field
  6311. // type.
  6312. func (m *ApiKeyMutation) SetField(name string, value ent.Value) error {
  6313. switch name {
  6314. case apikey.FieldCreatedAt:
  6315. v, ok := value.(time.Time)
  6316. if !ok {
  6317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6318. }
  6319. m.SetCreatedAt(v)
  6320. return nil
  6321. case apikey.FieldUpdatedAt:
  6322. v, ok := value.(time.Time)
  6323. if !ok {
  6324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6325. }
  6326. m.SetUpdatedAt(v)
  6327. return nil
  6328. case apikey.FieldDeletedAt:
  6329. v, ok := value.(time.Time)
  6330. if !ok {
  6331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6332. }
  6333. m.SetDeletedAt(v)
  6334. return nil
  6335. case apikey.FieldTitle:
  6336. v, ok := value.(string)
  6337. if !ok {
  6338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6339. }
  6340. m.SetTitle(v)
  6341. return nil
  6342. case apikey.FieldKey:
  6343. v, ok := value.(string)
  6344. if !ok {
  6345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6346. }
  6347. m.SetKey(v)
  6348. return nil
  6349. case apikey.FieldOrganizationID:
  6350. v, ok := value.(uint64)
  6351. if !ok {
  6352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6353. }
  6354. m.SetOrganizationID(v)
  6355. return nil
  6356. case apikey.FieldAgentID:
  6357. v, ok := value.(uint64)
  6358. if !ok {
  6359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6360. }
  6361. m.SetAgentID(v)
  6362. return nil
  6363. case apikey.FieldCustomAgentBase:
  6364. v, ok := value.(string)
  6365. if !ok {
  6366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6367. }
  6368. m.SetCustomAgentBase(v)
  6369. return nil
  6370. case apikey.FieldCustomAgentKey:
  6371. v, ok := value.(string)
  6372. if !ok {
  6373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6374. }
  6375. m.SetCustomAgentKey(v)
  6376. return nil
  6377. case apikey.FieldOpenaiBase:
  6378. v, ok := value.(string)
  6379. if !ok {
  6380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6381. }
  6382. m.SetOpenaiBase(v)
  6383. return nil
  6384. case apikey.FieldOpenaiKey:
  6385. v, ok := value.(string)
  6386. if !ok {
  6387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6388. }
  6389. m.SetOpenaiKey(v)
  6390. return nil
  6391. }
  6392. return fmt.Errorf("unknown ApiKey field %s", name)
  6393. }
  6394. // AddedFields returns all numeric fields that were incremented/decremented during
  6395. // this mutation.
  6396. func (m *ApiKeyMutation) AddedFields() []string {
  6397. var fields []string
  6398. if m.addorganization_id != nil {
  6399. fields = append(fields, apikey.FieldOrganizationID)
  6400. }
  6401. return fields
  6402. }
  6403. // AddedField returns the numeric value that was incremented/decremented on a field
  6404. // with the given name. The second boolean return value indicates that this field
  6405. // was not set, or was not defined in the schema.
  6406. func (m *ApiKeyMutation) AddedField(name string) (ent.Value, bool) {
  6407. switch name {
  6408. case apikey.FieldOrganizationID:
  6409. return m.AddedOrganizationID()
  6410. }
  6411. return nil, false
  6412. }
  6413. // AddField adds the value to the field with the given name. It returns an error if
  6414. // the field is not defined in the schema, or if the type mismatched the field
  6415. // type.
  6416. func (m *ApiKeyMutation) AddField(name string, value ent.Value) error {
  6417. switch name {
  6418. case apikey.FieldOrganizationID:
  6419. v, ok := value.(int64)
  6420. if !ok {
  6421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6422. }
  6423. m.AddOrganizationID(v)
  6424. return nil
  6425. }
  6426. return fmt.Errorf("unknown ApiKey numeric field %s", name)
  6427. }
  6428. // ClearedFields returns all nullable fields that were cleared during this
  6429. // mutation.
  6430. func (m *ApiKeyMutation) ClearedFields() []string {
  6431. var fields []string
  6432. if m.FieldCleared(apikey.FieldDeletedAt) {
  6433. fields = append(fields, apikey.FieldDeletedAt)
  6434. }
  6435. if m.FieldCleared(apikey.FieldTitle) {
  6436. fields = append(fields, apikey.FieldTitle)
  6437. }
  6438. if m.FieldCleared(apikey.FieldKey) {
  6439. fields = append(fields, apikey.FieldKey)
  6440. }
  6441. if m.FieldCleared(apikey.FieldCustomAgentBase) {
  6442. fields = append(fields, apikey.FieldCustomAgentBase)
  6443. }
  6444. if m.FieldCleared(apikey.FieldCustomAgentKey) {
  6445. fields = append(fields, apikey.FieldCustomAgentKey)
  6446. }
  6447. if m.FieldCleared(apikey.FieldOpenaiBase) {
  6448. fields = append(fields, apikey.FieldOpenaiBase)
  6449. }
  6450. if m.FieldCleared(apikey.FieldOpenaiKey) {
  6451. fields = append(fields, apikey.FieldOpenaiKey)
  6452. }
  6453. return fields
  6454. }
  6455. // FieldCleared returns a boolean indicating if a field with the given name was
  6456. // cleared in this mutation.
  6457. func (m *ApiKeyMutation) FieldCleared(name string) bool {
  6458. _, ok := m.clearedFields[name]
  6459. return ok
  6460. }
  6461. // ClearField clears the value of the field with the given name. It returns an
  6462. // error if the field is not defined in the schema.
  6463. func (m *ApiKeyMutation) ClearField(name string) error {
  6464. switch name {
  6465. case apikey.FieldDeletedAt:
  6466. m.ClearDeletedAt()
  6467. return nil
  6468. case apikey.FieldTitle:
  6469. m.ClearTitle()
  6470. return nil
  6471. case apikey.FieldKey:
  6472. m.ClearKey()
  6473. return nil
  6474. case apikey.FieldCustomAgentBase:
  6475. m.ClearCustomAgentBase()
  6476. return nil
  6477. case apikey.FieldCustomAgentKey:
  6478. m.ClearCustomAgentKey()
  6479. return nil
  6480. case apikey.FieldOpenaiBase:
  6481. m.ClearOpenaiBase()
  6482. return nil
  6483. case apikey.FieldOpenaiKey:
  6484. m.ClearOpenaiKey()
  6485. return nil
  6486. }
  6487. return fmt.Errorf("unknown ApiKey nullable field %s", name)
  6488. }
  6489. // ResetField resets all changes in the mutation for the field with the given name.
  6490. // It returns an error if the field is not defined in the schema.
  6491. func (m *ApiKeyMutation) ResetField(name string) error {
  6492. switch name {
  6493. case apikey.FieldCreatedAt:
  6494. m.ResetCreatedAt()
  6495. return nil
  6496. case apikey.FieldUpdatedAt:
  6497. m.ResetUpdatedAt()
  6498. return nil
  6499. case apikey.FieldDeletedAt:
  6500. m.ResetDeletedAt()
  6501. return nil
  6502. case apikey.FieldTitle:
  6503. m.ResetTitle()
  6504. return nil
  6505. case apikey.FieldKey:
  6506. m.ResetKey()
  6507. return nil
  6508. case apikey.FieldOrganizationID:
  6509. m.ResetOrganizationID()
  6510. return nil
  6511. case apikey.FieldAgentID:
  6512. m.ResetAgentID()
  6513. return nil
  6514. case apikey.FieldCustomAgentBase:
  6515. m.ResetCustomAgentBase()
  6516. return nil
  6517. case apikey.FieldCustomAgentKey:
  6518. m.ResetCustomAgentKey()
  6519. return nil
  6520. case apikey.FieldOpenaiBase:
  6521. m.ResetOpenaiBase()
  6522. return nil
  6523. case apikey.FieldOpenaiKey:
  6524. m.ResetOpenaiKey()
  6525. return nil
  6526. }
  6527. return fmt.Errorf("unknown ApiKey field %s", name)
  6528. }
  6529. // AddedEdges returns all edge names that were set/added in this mutation.
  6530. func (m *ApiKeyMutation) AddedEdges() []string {
  6531. edges := make([]string, 0, 1)
  6532. if m.agent != nil {
  6533. edges = append(edges, apikey.EdgeAgent)
  6534. }
  6535. return edges
  6536. }
  6537. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6538. // name in this mutation.
  6539. func (m *ApiKeyMutation) AddedIDs(name string) []ent.Value {
  6540. switch name {
  6541. case apikey.EdgeAgent:
  6542. if id := m.agent; id != nil {
  6543. return []ent.Value{*id}
  6544. }
  6545. }
  6546. return nil
  6547. }
  6548. // RemovedEdges returns all edge names that were removed in this mutation.
  6549. func (m *ApiKeyMutation) RemovedEdges() []string {
  6550. edges := make([]string, 0, 1)
  6551. return edges
  6552. }
  6553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6554. // the given name in this mutation.
  6555. func (m *ApiKeyMutation) RemovedIDs(name string) []ent.Value {
  6556. return nil
  6557. }
  6558. // ClearedEdges returns all edge names that were cleared in this mutation.
  6559. func (m *ApiKeyMutation) ClearedEdges() []string {
  6560. edges := make([]string, 0, 1)
  6561. if m.clearedagent {
  6562. edges = append(edges, apikey.EdgeAgent)
  6563. }
  6564. return edges
  6565. }
  6566. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6567. // was cleared in this mutation.
  6568. func (m *ApiKeyMutation) EdgeCleared(name string) bool {
  6569. switch name {
  6570. case apikey.EdgeAgent:
  6571. return m.clearedagent
  6572. }
  6573. return false
  6574. }
  6575. // ClearEdge clears the value of the edge with the given name. It returns an error
  6576. // if that edge is not defined in the schema.
  6577. func (m *ApiKeyMutation) ClearEdge(name string) error {
  6578. switch name {
  6579. case apikey.EdgeAgent:
  6580. m.ClearAgent()
  6581. return nil
  6582. }
  6583. return fmt.Errorf("unknown ApiKey unique edge %s", name)
  6584. }
  6585. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6586. // It returns an error if the edge is not defined in the schema.
  6587. func (m *ApiKeyMutation) ResetEdge(name string) error {
  6588. switch name {
  6589. case apikey.EdgeAgent:
  6590. m.ResetAgent()
  6591. return nil
  6592. }
  6593. return fmt.Errorf("unknown ApiKey edge %s", name)
  6594. }
  6595. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  6596. type BatchMsgMutation struct {
  6597. config
  6598. op Op
  6599. typ string
  6600. id *uint64
  6601. created_at *time.Time
  6602. updated_at *time.Time
  6603. deleted_at *time.Time
  6604. status *uint8
  6605. addstatus *int8
  6606. batch_no *string
  6607. task_name *string
  6608. fromwxid *string
  6609. msg *string
  6610. tag *string
  6611. tagids *string
  6612. total *int32
  6613. addtotal *int32
  6614. success *int32
  6615. addsuccess *int32
  6616. fail *int32
  6617. addfail *int32
  6618. start_time *time.Time
  6619. stop_time *time.Time
  6620. send_time *time.Time
  6621. _type *int32
  6622. add_type *int32
  6623. organization_id *uint64
  6624. addorganization_id *int64
  6625. ctype *uint64
  6626. addctype *int64
  6627. cc *string
  6628. phone *string
  6629. template_name *string
  6630. template_code *string
  6631. lang *string
  6632. clearedFields map[string]struct{}
  6633. done bool
  6634. oldValue func(context.Context) (*BatchMsg, error)
  6635. predicates []predicate.BatchMsg
  6636. }
  6637. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  6638. // batchmsgOption allows management of the mutation configuration using functional options.
  6639. type batchmsgOption func(*BatchMsgMutation)
  6640. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  6641. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  6642. m := &BatchMsgMutation{
  6643. config: c,
  6644. op: op,
  6645. typ: TypeBatchMsg,
  6646. clearedFields: make(map[string]struct{}),
  6647. }
  6648. for _, opt := range opts {
  6649. opt(m)
  6650. }
  6651. return m
  6652. }
  6653. // withBatchMsgID sets the ID field of the mutation.
  6654. func withBatchMsgID(id uint64) batchmsgOption {
  6655. return func(m *BatchMsgMutation) {
  6656. var (
  6657. err error
  6658. once sync.Once
  6659. value *BatchMsg
  6660. )
  6661. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  6662. once.Do(func() {
  6663. if m.done {
  6664. err = errors.New("querying old values post mutation is not allowed")
  6665. } else {
  6666. value, err = m.Client().BatchMsg.Get(ctx, id)
  6667. }
  6668. })
  6669. return value, err
  6670. }
  6671. m.id = &id
  6672. }
  6673. }
  6674. // withBatchMsg sets the old BatchMsg of the mutation.
  6675. func withBatchMsg(node *BatchMsg) batchmsgOption {
  6676. return func(m *BatchMsgMutation) {
  6677. m.oldValue = func(context.Context) (*BatchMsg, error) {
  6678. return node, nil
  6679. }
  6680. m.id = &node.ID
  6681. }
  6682. }
  6683. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6684. // executed in a transaction (ent.Tx), a transactional client is returned.
  6685. func (m BatchMsgMutation) Client() *Client {
  6686. client := &Client{config: m.config}
  6687. client.init()
  6688. return client
  6689. }
  6690. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6691. // it returns an error otherwise.
  6692. func (m BatchMsgMutation) Tx() (*Tx, error) {
  6693. if _, ok := m.driver.(*txDriver); !ok {
  6694. return nil, errors.New("ent: mutation is not running in a transaction")
  6695. }
  6696. tx := &Tx{config: m.config}
  6697. tx.init()
  6698. return tx, nil
  6699. }
  6700. // SetID sets the value of the id field. Note that this
  6701. // operation is only accepted on creation of BatchMsg entities.
  6702. func (m *BatchMsgMutation) SetID(id uint64) {
  6703. m.id = &id
  6704. }
  6705. // ID returns the ID value in the mutation. Note that the ID is only available
  6706. // if it was provided to the builder or after it was returned from the database.
  6707. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  6708. if m.id == nil {
  6709. return
  6710. }
  6711. return *m.id, true
  6712. }
  6713. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6714. // That means, if the mutation is applied within a transaction with an isolation level such
  6715. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6716. // or updated by the mutation.
  6717. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  6718. switch {
  6719. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6720. id, exists := m.ID()
  6721. if exists {
  6722. return []uint64{id}, nil
  6723. }
  6724. fallthrough
  6725. case m.op.Is(OpUpdate | OpDelete):
  6726. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  6727. default:
  6728. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6729. }
  6730. }
  6731. // SetCreatedAt sets the "created_at" field.
  6732. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  6733. m.created_at = &t
  6734. }
  6735. // CreatedAt returns the value of the "created_at" field in the mutation.
  6736. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  6737. v := m.created_at
  6738. if v == nil {
  6739. return
  6740. }
  6741. return *v, true
  6742. }
  6743. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  6744. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6746. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6747. if !m.op.Is(OpUpdateOne) {
  6748. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6749. }
  6750. if m.id == nil || m.oldValue == nil {
  6751. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6752. }
  6753. oldValue, err := m.oldValue(ctx)
  6754. if err != nil {
  6755. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6756. }
  6757. return oldValue.CreatedAt, nil
  6758. }
  6759. // ResetCreatedAt resets all changes to the "created_at" field.
  6760. func (m *BatchMsgMutation) ResetCreatedAt() {
  6761. m.created_at = nil
  6762. }
  6763. // SetUpdatedAt sets the "updated_at" field.
  6764. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  6765. m.updated_at = &t
  6766. }
  6767. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6768. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  6769. v := m.updated_at
  6770. if v == nil {
  6771. return
  6772. }
  6773. return *v, true
  6774. }
  6775. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  6776. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6778. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6779. if !m.op.Is(OpUpdateOne) {
  6780. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6781. }
  6782. if m.id == nil || m.oldValue == nil {
  6783. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6784. }
  6785. oldValue, err := m.oldValue(ctx)
  6786. if err != nil {
  6787. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6788. }
  6789. return oldValue.UpdatedAt, nil
  6790. }
  6791. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6792. func (m *BatchMsgMutation) ResetUpdatedAt() {
  6793. m.updated_at = nil
  6794. }
  6795. // SetDeletedAt sets the "deleted_at" field.
  6796. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  6797. m.deleted_at = &t
  6798. }
  6799. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6800. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  6801. v := m.deleted_at
  6802. if v == nil {
  6803. return
  6804. }
  6805. return *v, true
  6806. }
  6807. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  6808. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6810. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6811. if !m.op.Is(OpUpdateOne) {
  6812. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6813. }
  6814. if m.id == nil || m.oldValue == nil {
  6815. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6816. }
  6817. oldValue, err := m.oldValue(ctx)
  6818. if err != nil {
  6819. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6820. }
  6821. return oldValue.DeletedAt, nil
  6822. }
  6823. // ClearDeletedAt clears the value of the "deleted_at" field.
  6824. func (m *BatchMsgMutation) ClearDeletedAt() {
  6825. m.deleted_at = nil
  6826. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  6827. }
  6828. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6829. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  6830. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  6831. return ok
  6832. }
  6833. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6834. func (m *BatchMsgMutation) ResetDeletedAt() {
  6835. m.deleted_at = nil
  6836. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  6837. }
  6838. // SetStatus sets the "status" field.
  6839. func (m *BatchMsgMutation) SetStatus(u uint8) {
  6840. m.status = &u
  6841. m.addstatus = nil
  6842. }
  6843. // Status returns the value of the "status" field in the mutation.
  6844. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  6845. v := m.status
  6846. if v == nil {
  6847. return
  6848. }
  6849. return *v, true
  6850. }
  6851. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  6852. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6854. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  6855. if !m.op.Is(OpUpdateOne) {
  6856. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  6857. }
  6858. if m.id == nil || m.oldValue == nil {
  6859. return v, errors.New("OldStatus requires an ID field in the mutation")
  6860. }
  6861. oldValue, err := m.oldValue(ctx)
  6862. if err != nil {
  6863. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  6864. }
  6865. return oldValue.Status, nil
  6866. }
  6867. // AddStatus adds u to the "status" field.
  6868. func (m *BatchMsgMutation) AddStatus(u int8) {
  6869. if m.addstatus != nil {
  6870. *m.addstatus += u
  6871. } else {
  6872. m.addstatus = &u
  6873. }
  6874. }
  6875. // AddedStatus returns the value that was added to the "status" field in this mutation.
  6876. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  6877. v := m.addstatus
  6878. if v == nil {
  6879. return
  6880. }
  6881. return *v, true
  6882. }
  6883. // ClearStatus clears the value of the "status" field.
  6884. func (m *BatchMsgMutation) ClearStatus() {
  6885. m.status = nil
  6886. m.addstatus = nil
  6887. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  6888. }
  6889. // StatusCleared returns if the "status" field was cleared in this mutation.
  6890. func (m *BatchMsgMutation) StatusCleared() bool {
  6891. _, ok := m.clearedFields[batchmsg.FieldStatus]
  6892. return ok
  6893. }
  6894. // ResetStatus resets all changes to the "status" field.
  6895. func (m *BatchMsgMutation) ResetStatus() {
  6896. m.status = nil
  6897. m.addstatus = nil
  6898. delete(m.clearedFields, batchmsg.FieldStatus)
  6899. }
  6900. // SetBatchNo sets the "batch_no" field.
  6901. func (m *BatchMsgMutation) SetBatchNo(s string) {
  6902. m.batch_no = &s
  6903. }
  6904. // BatchNo returns the value of the "batch_no" field in the mutation.
  6905. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  6906. v := m.batch_no
  6907. if v == nil {
  6908. return
  6909. }
  6910. return *v, true
  6911. }
  6912. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  6913. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6915. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  6916. if !m.op.Is(OpUpdateOne) {
  6917. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  6918. }
  6919. if m.id == nil || m.oldValue == nil {
  6920. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  6921. }
  6922. oldValue, err := m.oldValue(ctx)
  6923. if err != nil {
  6924. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  6925. }
  6926. return oldValue.BatchNo, nil
  6927. }
  6928. // ClearBatchNo clears the value of the "batch_no" field.
  6929. func (m *BatchMsgMutation) ClearBatchNo() {
  6930. m.batch_no = nil
  6931. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  6932. }
  6933. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  6934. func (m *BatchMsgMutation) BatchNoCleared() bool {
  6935. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  6936. return ok
  6937. }
  6938. // ResetBatchNo resets all changes to the "batch_no" field.
  6939. func (m *BatchMsgMutation) ResetBatchNo() {
  6940. m.batch_no = nil
  6941. delete(m.clearedFields, batchmsg.FieldBatchNo)
  6942. }
  6943. // SetTaskName sets the "task_name" field.
  6944. func (m *BatchMsgMutation) SetTaskName(s string) {
  6945. m.task_name = &s
  6946. }
  6947. // TaskName returns the value of the "task_name" field in the mutation.
  6948. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  6949. v := m.task_name
  6950. if v == nil {
  6951. return
  6952. }
  6953. return *v, true
  6954. }
  6955. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  6956. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  6957. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6958. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  6959. if !m.op.Is(OpUpdateOne) {
  6960. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  6961. }
  6962. if m.id == nil || m.oldValue == nil {
  6963. return v, errors.New("OldTaskName requires an ID field in the mutation")
  6964. }
  6965. oldValue, err := m.oldValue(ctx)
  6966. if err != nil {
  6967. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  6968. }
  6969. return oldValue.TaskName, nil
  6970. }
  6971. // ClearTaskName clears the value of the "task_name" field.
  6972. func (m *BatchMsgMutation) ClearTaskName() {
  6973. m.task_name = nil
  6974. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  6975. }
  6976. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  6977. func (m *BatchMsgMutation) TaskNameCleared() bool {
  6978. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  6979. return ok
  6980. }
  6981. // ResetTaskName resets all changes to the "task_name" field.
  6982. func (m *BatchMsgMutation) ResetTaskName() {
  6983. m.task_name = nil
  6984. delete(m.clearedFields, batchmsg.FieldTaskName)
  6985. }
  6986. // SetFromwxid sets the "fromwxid" field.
  6987. func (m *BatchMsgMutation) SetFromwxid(s string) {
  6988. m.fromwxid = &s
  6989. }
  6990. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  6991. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  6992. v := m.fromwxid
  6993. if v == nil {
  6994. return
  6995. }
  6996. return *v, true
  6997. }
  6998. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  6999. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7001. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  7002. if !m.op.Is(OpUpdateOne) {
  7003. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  7004. }
  7005. if m.id == nil || m.oldValue == nil {
  7006. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  7007. }
  7008. oldValue, err := m.oldValue(ctx)
  7009. if err != nil {
  7010. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  7011. }
  7012. return oldValue.Fromwxid, nil
  7013. }
  7014. // ClearFromwxid clears the value of the "fromwxid" field.
  7015. func (m *BatchMsgMutation) ClearFromwxid() {
  7016. m.fromwxid = nil
  7017. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  7018. }
  7019. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  7020. func (m *BatchMsgMutation) FromwxidCleared() bool {
  7021. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  7022. return ok
  7023. }
  7024. // ResetFromwxid resets all changes to the "fromwxid" field.
  7025. func (m *BatchMsgMutation) ResetFromwxid() {
  7026. m.fromwxid = nil
  7027. delete(m.clearedFields, batchmsg.FieldFromwxid)
  7028. }
  7029. // SetMsg sets the "msg" field.
  7030. func (m *BatchMsgMutation) SetMsg(s string) {
  7031. m.msg = &s
  7032. }
  7033. // Msg returns the value of the "msg" field in the mutation.
  7034. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  7035. v := m.msg
  7036. if v == nil {
  7037. return
  7038. }
  7039. return *v, true
  7040. }
  7041. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  7042. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7044. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  7045. if !m.op.Is(OpUpdateOne) {
  7046. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  7047. }
  7048. if m.id == nil || m.oldValue == nil {
  7049. return v, errors.New("OldMsg requires an ID field in the mutation")
  7050. }
  7051. oldValue, err := m.oldValue(ctx)
  7052. if err != nil {
  7053. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  7054. }
  7055. return oldValue.Msg, nil
  7056. }
  7057. // ClearMsg clears the value of the "msg" field.
  7058. func (m *BatchMsgMutation) ClearMsg() {
  7059. m.msg = nil
  7060. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  7061. }
  7062. // MsgCleared returns if the "msg" field was cleared in this mutation.
  7063. func (m *BatchMsgMutation) MsgCleared() bool {
  7064. _, ok := m.clearedFields[batchmsg.FieldMsg]
  7065. return ok
  7066. }
  7067. // ResetMsg resets all changes to the "msg" field.
  7068. func (m *BatchMsgMutation) ResetMsg() {
  7069. m.msg = nil
  7070. delete(m.clearedFields, batchmsg.FieldMsg)
  7071. }
  7072. // SetTag sets the "tag" field.
  7073. func (m *BatchMsgMutation) SetTag(s string) {
  7074. m.tag = &s
  7075. }
  7076. // Tag returns the value of the "tag" field in the mutation.
  7077. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  7078. v := m.tag
  7079. if v == nil {
  7080. return
  7081. }
  7082. return *v, true
  7083. }
  7084. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  7085. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7087. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  7088. if !m.op.Is(OpUpdateOne) {
  7089. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  7090. }
  7091. if m.id == nil || m.oldValue == nil {
  7092. return v, errors.New("OldTag requires an ID field in the mutation")
  7093. }
  7094. oldValue, err := m.oldValue(ctx)
  7095. if err != nil {
  7096. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  7097. }
  7098. return oldValue.Tag, nil
  7099. }
  7100. // ClearTag clears the value of the "tag" field.
  7101. func (m *BatchMsgMutation) ClearTag() {
  7102. m.tag = nil
  7103. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  7104. }
  7105. // TagCleared returns if the "tag" field was cleared in this mutation.
  7106. func (m *BatchMsgMutation) TagCleared() bool {
  7107. _, ok := m.clearedFields[batchmsg.FieldTag]
  7108. return ok
  7109. }
  7110. // ResetTag resets all changes to the "tag" field.
  7111. func (m *BatchMsgMutation) ResetTag() {
  7112. m.tag = nil
  7113. delete(m.clearedFields, batchmsg.FieldTag)
  7114. }
  7115. // SetTagids sets the "tagids" field.
  7116. func (m *BatchMsgMutation) SetTagids(s string) {
  7117. m.tagids = &s
  7118. }
  7119. // Tagids returns the value of the "tagids" field in the mutation.
  7120. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  7121. v := m.tagids
  7122. if v == nil {
  7123. return
  7124. }
  7125. return *v, true
  7126. }
  7127. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  7128. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7130. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  7131. if !m.op.Is(OpUpdateOne) {
  7132. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  7133. }
  7134. if m.id == nil || m.oldValue == nil {
  7135. return v, errors.New("OldTagids requires an ID field in the mutation")
  7136. }
  7137. oldValue, err := m.oldValue(ctx)
  7138. if err != nil {
  7139. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  7140. }
  7141. return oldValue.Tagids, nil
  7142. }
  7143. // ClearTagids clears the value of the "tagids" field.
  7144. func (m *BatchMsgMutation) ClearTagids() {
  7145. m.tagids = nil
  7146. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  7147. }
  7148. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  7149. func (m *BatchMsgMutation) TagidsCleared() bool {
  7150. _, ok := m.clearedFields[batchmsg.FieldTagids]
  7151. return ok
  7152. }
  7153. // ResetTagids resets all changes to the "tagids" field.
  7154. func (m *BatchMsgMutation) ResetTagids() {
  7155. m.tagids = nil
  7156. delete(m.clearedFields, batchmsg.FieldTagids)
  7157. }
  7158. // SetTotal sets the "total" field.
  7159. func (m *BatchMsgMutation) SetTotal(i int32) {
  7160. m.total = &i
  7161. m.addtotal = nil
  7162. }
  7163. // Total returns the value of the "total" field in the mutation.
  7164. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  7165. v := m.total
  7166. if v == nil {
  7167. return
  7168. }
  7169. return *v, true
  7170. }
  7171. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  7172. // If the BatchMsg 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 *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  7175. if !m.op.Is(OpUpdateOne) {
  7176. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  7177. }
  7178. if m.id == nil || m.oldValue == nil {
  7179. return v, errors.New("OldTotal 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 OldTotal: %w", err)
  7184. }
  7185. return oldValue.Total, nil
  7186. }
  7187. // AddTotal adds i to the "total" field.
  7188. func (m *BatchMsgMutation) AddTotal(i int32) {
  7189. if m.addtotal != nil {
  7190. *m.addtotal += i
  7191. } else {
  7192. m.addtotal = &i
  7193. }
  7194. }
  7195. // AddedTotal returns the value that was added to the "total" field in this mutation.
  7196. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  7197. v := m.addtotal
  7198. if v == nil {
  7199. return
  7200. }
  7201. return *v, true
  7202. }
  7203. // ClearTotal clears the value of the "total" field.
  7204. func (m *BatchMsgMutation) ClearTotal() {
  7205. m.total = nil
  7206. m.addtotal = nil
  7207. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  7208. }
  7209. // TotalCleared returns if the "total" field was cleared in this mutation.
  7210. func (m *BatchMsgMutation) TotalCleared() bool {
  7211. _, ok := m.clearedFields[batchmsg.FieldTotal]
  7212. return ok
  7213. }
  7214. // ResetTotal resets all changes to the "total" field.
  7215. func (m *BatchMsgMutation) ResetTotal() {
  7216. m.total = nil
  7217. m.addtotal = nil
  7218. delete(m.clearedFields, batchmsg.FieldTotal)
  7219. }
  7220. // SetSuccess sets the "success" field.
  7221. func (m *BatchMsgMutation) SetSuccess(i int32) {
  7222. m.success = &i
  7223. m.addsuccess = nil
  7224. }
  7225. // Success returns the value of the "success" field in the mutation.
  7226. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  7227. v := m.success
  7228. if v == nil {
  7229. return
  7230. }
  7231. return *v, true
  7232. }
  7233. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  7234. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7236. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  7237. if !m.op.Is(OpUpdateOne) {
  7238. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  7239. }
  7240. if m.id == nil || m.oldValue == nil {
  7241. return v, errors.New("OldSuccess requires an ID field in the mutation")
  7242. }
  7243. oldValue, err := m.oldValue(ctx)
  7244. if err != nil {
  7245. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  7246. }
  7247. return oldValue.Success, nil
  7248. }
  7249. // AddSuccess adds i to the "success" field.
  7250. func (m *BatchMsgMutation) AddSuccess(i int32) {
  7251. if m.addsuccess != nil {
  7252. *m.addsuccess += i
  7253. } else {
  7254. m.addsuccess = &i
  7255. }
  7256. }
  7257. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  7258. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  7259. v := m.addsuccess
  7260. if v == nil {
  7261. return
  7262. }
  7263. return *v, true
  7264. }
  7265. // ClearSuccess clears the value of the "success" field.
  7266. func (m *BatchMsgMutation) ClearSuccess() {
  7267. m.success = nil
  7268. m.addsuccess = nil
  7269. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  7270. }
  7271. // SuccessCleared returns if the "success" field was cleared in this mutation.
  7272. func (m *BatchMsgMutation) SuccessCleared() bool {
  7273. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  7274. return ok
  7275. }
  7276. // ResetSuccess resets all changes to the "success" field.
  7277. func (m *BatchMsgMutation) ResetSuccess() {
  7278. m.success = nil
  7279. m.addsuccess = nil
  7280. delete(m.clearedFields, batchmsg.FieldSuccess)
  7281. }
  7282. // SetFail sets the "fail" field.
  7283. func (m *BatchMsgMutation) SetFail(i int32) {
  7284. m.fail = &i
  7285. m.addfail = nil
  7286. }
  7287. // Fail returns the value of the "fail" field in the mutation.
  7288. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  7289. v := m.fail
  7290. if v == nil {
  7291. return
  7292. }
  7293. return *v, true
  7294. }
  7295. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  7296. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7298. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  7299. if !m.op.Is(OpUpdateOne) {
  7300. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  7301. }
  7302. if m.id == nil || m.oldValue == nil {
  7303. return v, errors.New("OldFail requires an ID field in the mutation")
  7304. }
  7305. oldValue, err := m.oldValue(ctx)
  7306. if err != nil {
  7307. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  7308. }
  7309. return oldValue.Fail, nil
  7310. }
  7311. // AddFail adds i to the "fail" field.
  7312. func (m *BatchMsgMutation) AddFail(i int32) {
  7313. if m.addfail != nil {
  7314. *m.addfail += i
  7315. } else {
  7316. m.addfail = &i
  7317. }
  7318. }
  7319. // AddedFail returns the value that was added to the "fail" field in this mutation.
  7320. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  7321. v := m.addfail
  7322. if v == nil {
  7323. return
  7324. }
  7325. return *v, true
  7326. }
  7327. // ClearFail clears the value of the "fail" field.
  7328. func (m *BatchMsgMutation) ClearFail() {
  7329. m.fail = nil
  7330. m.addfail = nil
  7331. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  7332. }
  7333. // FailCleared returns if the "fail" field was cleared in this mutation.
  7334. func (m *BatchMsgMutation) FailCleared() bool {
  7335. _, ok := m.clearedFields[batchmsg.FieldFail]
  7336. return ok
  7337. }
  7338. // ResetFail resets all changes to the "fail" field.
  7339. func (m *BatchMsgMutation) ResetFail() {
  7340. m.fail = nil
  7341. m.addfail = nil
  7342. delete(m.clearedFields, batchmsg.FieldFail)
  7343. }
  7344. // SetStartTime sets the "start_time" field.
  7345. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  7346. m.start_time = &t
  7347. }
  7348. // StartTime returns the value of the "start_time" field in the mutation.
  7349. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  7350. v := m.start_time
  7351. if v == nil {
  7352. return
  7353. }
  7354. return *v, true
  7355. }
  7356. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  7357. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7359. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  7360. if !m.op.Is(OpUpdateOne) {
  7361. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  7362. }
  7363. if m.id == nil || m.oldValue == nil {
  7364. return v, errors.New("OldStartTime requires an ID field in the mutation")
  7365. }
  7366. oldValue, err := m.oldValue(ctx)
  7367. if err != nil {
  7368. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  7369. }
  7370. return oldValue.StartTime, nil
  7371. }
  7372. // ClearStartTime clears the value of the "start_time" field.
  7373. func (m *BatchMsgMutation) ClearStartTime() {
  7374. m.start_time = nil
  7375. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  7376. }
  7377. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  7378. func (m *BatchMsgMutation) StartTimeCleared() bool {
  7379. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  7380. return ok
  7381. }
  7382. // ResetStartTime resets all changes to the "start_time" field.
  7383. func (m *BatchMsgMutation) ResetStartTime() {
  7384. m.start_time = nil
  7385. delete(m.clearedFields, batchmsg.FieldStartTime)
  7386. }
  7387. // SetStopTime sets the "stop_time" field.
  7388. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  7389. m.stop_time = &t
  7390. }
  7391. // StopTime returns the value of the "stop_time" field in the mutation.
  7392. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  7393. v := m.stop_time
  7394. if v == nil {
  7395. return
  7396. }
  7397. return *v, true
  7398. }
  7399. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  7400. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7402. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  7403. if !m.op.Is(OpUpdateOne) {
  7404. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  7405. }
  7406. if m.id == nil || m.oldValue == nil {
  7407. return v, errors.New("OldStopTime requires an ID field in the mutation")
  7408. }
  7409. oldValue, err := m.oldValue(ctx)
  7410. if err != nil {
  7411. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  7412. }
  7413. return oldValue.StopTime, nil
  7414. }
  7415. // ClearStopTime clears the value of the "stop_time" field.
  7416. func (m *BatchMsgMutation) ClearStopTime() {
  7417. m.stop_time = nil
  7418. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  7419. }
  7420. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  7421. func (m *BatchMsgMutation) StopTimeCleared() bool {
  7422. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  7423. return ok
  7424. }
  7425. // ResetStopTime resets all changes to the "stop_time" field.
  7426. func (m *BatchMsgMutation) ResetStopTime() {
  7427. m.stop_time = nil
  7428. delete(m.clearedFields, batchmsg.FieldStopTime)
  7429. }
  7430. // SetSendTime sets the "send_time" field.
  7431. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  7432. m.send_time = &t
  7433. }
  7434. // SendTime returns the value of the "send_time" field in the mutation.
  7435. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  7436. v := m.send_time
  7437. if v == nil {
  7438. return
  7439. }
  7440. return *v, true
  7441. }
  7442. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  7443. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7445. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  7446. if !m.op.Is(OpUpdateOne) {
  7447. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  7448. }
  7449. if m.id == nil || m.oldValue == nil {
  7450. return v, errors.New("OldSendTime requires an ID field in the mutation")
  7451. }
  7452. oldValue, err := m.oldValue(ctx)
  7453. if err != nil {
  7454. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  7455. }
  7456. return oldValue.SendTime, nil
  7457. }
  7458. // ClearSendTime clears the value of the "send_time" field.
  7459. func (m *BatchMsgMutation) ClearSendTime() {
  7460. m.send_time = nil
  7461. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  7462. }
  7463. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  7464. func (m *BatchMsgMutation) SendTimeCleared() bool {
  7465. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  7466. return ok
  7467. }
  7468. // ResetSendTime resets all changes to the "send_time" field.
  7469. func (m *BatchMsgMutation) ResetSendTime() {
  7470. m.send_time = nil
  7471. delete(m.clearedFields, batchmsg.FieldSendTime)
  7472. }
  7473. // SetType sets the "type" field.
  7474. func (m *BatchMsgMutation) SetType(i int32) {
  7475. m._type = &i
  7476. m.add_type = nil
  7477. }
  7478. // GetType returns the value of the "type" field in the mutation.
  7479. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  7480. v := m._type
  7481. if v == nil {
  7482. return
  7483. }
  7484. return *v, true
  7485. }
  7486. // OldType returns the old "type" field's value of the BatchMsg entity.
  7487. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7489. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  7490. if !m.op.Is(OpUpdateOne) {
  7491. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7492. }
  7493. if m.id == nil || m.oldValue == nil {
  7494. return v, errors.New("OldType requires an ID field in the mutation")
  7495. }
  7496. oldValue, err := m.oldValue(ctx)
  7497. if err != nil {
  7498. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7499. }
  7500. return oldValue.Type, nil
  7501. }
  7502. // AddType adds i to the "type" field.
  7503. func (m *BatchMsgMutation) AddType(i int32) {
  7504. if m.add_type != nil {
  7505. *m.add_type += i
  7506. } else {
  7507. m.add_type = &i
  7508. }
  7509. }
  7510. // AddedType returns the value that was added to the "type" field in this mutation.
  7511. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  7512. v := m.add_type
  7513. if v == nil {
  7514. return
  7515. }
  7516. return *v, true
  7517. }
  7518. // ClearType clears the value of the "type" field.
  7519. func (m *BatchMsgMutation) ClearType() {
  7520. m._type = nil
  7521. m.add_type = nil
  7522. m.clearedFields[batchmsg.FieldType] = struct{}{}
  7523. }
  7524. // TypeCleared returns if the "type" field was cleared in this mutation.
  7525. func (m *BatchMsgMutation) TypeCleared() bool {
  7526. _, ok := m.clearedFields[batchmsg.FieldType]
  7527. return ok
  7528. }
  7529. // ResetType resets all changes to the "type" field.
  7530. func (m *BatchMsgMutation) ResetType() {
  7531. m._type = nil
  7532. m.add_type = nil
  7533. delete(m.clearedFields, batchmsg.FieldType)
  7534. }
  7535. // SetOrganizationID sets the "organization_id" field.
  7536. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  7537. m.organization_id = &u
  7538. m.addorganization_id = nil
  7539. }
  7540. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7541. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  7542. v := m.organization_id
  7543. if v == nil {
  7544. return
  7545. }
  7546. return *v, true
  7547. }
  7548. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  7549. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7550. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7551. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7552. if !m.op.Is(OpUpdateOne) {
  7553. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7554. }
  7555. if m.id == nil || m.oldValue == nil {
  7556. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7557. }
  7558. oldValue, err := m.oldValue(ctx)
  7559. if err != nil {
  7560. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7561. }
  7562. return oldValue.OrganizationID, nil
  7563. }
  7564. // AddOrganizationID adds u to the "organization_id" field.
  7565. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  7566. if m.addorganization_id != nil {
  7567. *m.addorganization_id += u
  7568. } else {
  7569. m.addorganization_id = &u
  7570. }
  7571. }
  7572. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7573. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  7574. v := m.addorganization_id
  7575. if v == nil {
  7576. return
  7577. }
  7578. return *v, true
  7579. }
  7580. // ResetOrganizationID resets all changes to the "organization_id" field.
  7581. func (m *BatchMsgMutation) ResetOrganizationID() {
  7582. m.organization_id = nil
  7583. m.addorganization_id = nil
  7584. }
  7585. // SetCtype sets the "ctype" field.
  7586. func (m *BatchMsgMutation) SetCtype(u uint64) {
  7587. m.ctype = &u
  7588. m.addctype = nil
  7589. }
  7590. // Ctype returns the value of the "ctype" field in the mutation.
  7591. func (m *BatchMsgMutation) Ctype() (r uint64, exists bool) {
  7592. v := m.ctype
  7593. if v == nil {
  7594. return
  7595. }
  7596. return *v, true
  7597. }
  7598. // OldCtype returns the old "ctype" field's value of the BatchMsg entity.
  7599. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7601. func (m *BatchMsgMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  7602. if !m.op.Is(OpUpdateOne) {
  7603. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  7604. }
  7605. if m.id == nil || m.oldValue == nil {
  7606. return v, errors.New("OldCtype requires an ID field in the mutation")
  7607. }
  7608. oldValue, err := m.oldValue(ctx)
  7609. if err != nil {
  7610. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  7611. }
  7612. return oldValue.Ctype, nil
  7613. }
  7614. // AddCtype adds u to the "ctype" field.
  7615. func (m *BatchMsgMutation) AddCtype(u int64) {
  7616. if m.addctype != nil {
  7617. *m.addctype += u
  7618. } else {
  7619. m.addctype = &u
  7620. }
  7621. }
  7622. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  7623. func (m *BatchMsgMutation) AddedCtype() (r int64, exists bool) {
  7624. v := m.addctype
  7625. if v == nil {
  7626. return
  7627. }
  7628. return *v, true
  7629. }
  7630. // ResetCtype resets all changes to the "ctype" field.
  7631. func (m *BatchMsgMutation) ResetCtype() {
  7632. m.ctype = nil
  7633. m.addctype = nil
  7634. }
  7635. // SetCc sets the "cc" field.
  7636. func (m *BatchMsgMutation) SetCc(s string) {
  7637. m.cc = &s
  7638. }
  7639. // Cc returns the value of the "cc" field in the mutation.
  7640. func (m *BatchMsgMutation) Cc() (r string, exists bool) {
  7641. v := m.cc
  7642. if v == nil {
  7643. return
  7644. }
  7645. return *v, true
  7646. }
  7647. // OldCc returns the old "cc" field's value of the BatchMsg entity.
  7648. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7650. func (m *BatchMsgMutation) OldCc(ctx context.Context) (v string, err error) {
  7651. if !m.op.Is(OpUpdateOne) {
  7652. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  7653. }
  7654. if m.id == nil || m.oldValue == nil {
  7655. return v, errors.New("OldCc requires an ID field in the mutation")
  7656. }
  7657. oldValue, err := m.oldValue(ctx)
  7658. if err != nil {
  7659. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  7660. }
  7661. return oldValue.Cc, nil
  7662. }
  7663. // ClearCc clears the value of the "cc" field.
  7664. func (m *BatchMsgMutation) ClearCc() {
  7665. m.cc = nil
  7666. m.clearedFields[batchmsg.FieldCc] = struct{}{}
  7667. }
  7668. // CcCleared returns if the "cc" field was cleared in this mutation.
  7669. func (m *BatchMsgMutation) CcCleared() bool {
  7670. _, ok := m.clearedFields[batchmsg.FieldCc]
  7671. return ok
  7672. }
  7673. // ResetCc resets all changes to the "cc" field.
  7674. func (m *BatchMsgMutation) ResetCc() {
  7675. m.cc = nil
  7676. delete(m.clearedFields, batchmsg.FieldCc)
  7677. }
  7678. // SetPhone sets the "phone" field.
  7679. func (m *BatchMsgMutation) SetPhone(s string) {
  7680. m.phone = &s
  7681. }
  7682. // Phone returns the value of the "phone" field in the mutation.
  7683. func (m *BatchMsgMutation) Phone() (r string, exists bool) {
  7684. v := m.phone
  7685. if v == nil {
  7686. return
  7687. }
  7688. return *v, true
  7689. }
  7690. // OldPhone returns the old "phone" field's value of the BatchMsg entity.
  7691. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7693. func (m *BatchMsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  7694. if !m.op.Is(OpUpdateOne) {
  7695. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  7696. }
  7697. if m.id == nil || m.oldValue == nil {
  7698. return v, errors.New("OldPhone requires an ID field in the mutation")
  7699. }
  7700. oldValue, err := m.oldValue(ctx)
  7701. if err != nil {
  7702. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  7703. }
  7704. return oldValue.Phone, nil
  7705. }
  7706. // ClearPhone clears the value of the "phone" field.
  7707. func (m *BatchMsgMutation) ClearPhone() {
  7708. m.phone = nil
  7709. m.clearedFields[batchmsg.FieldPhone] = struct{}{}
  7710. }
  7711. // PhoneCleared returns if the "phone" field was cleared in this mutation.
  7712. func (m *BatchMsgMutation) PhoneCleared() bool {
  7713. _, ok := m.clearedFields[batchmsg.FieldPhone]
  7714. return ok
  7715. }
  7716. // ResetPhone resets all changes to the "phone" field.
  7717. func (m *BatchMsgMutation) ResetPhone() {
  7718. m.phone = nil
  7719. delete(m.clearedFields, batchmsg.FieldPhone)
  7720. }
  7721. // SetTemplateName sets the "template_name" field.
  7722. func (m *BatchMsgMutation) SetTemplateName(s string) {
  7723. m.template_name = &s
  7724. }
  7725. // TemplateName returns the value of the "template_name" field in the mutation.
  7726. func (m *BatchMsgMutation) TemplateName() (r string, exists bool) {
  7727. v := m.template_name
  7728. if v == nil {
  7729. return
  7730. }
  7731. return *v, true
  7732. }
  7733. // OldTemplateName returns the old "template_name" field's value of the BatchMsg entity.
  7734. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7736. func (m *BatchMsgMutation) OldTemplateName(ctx context.Context) (v string, err error) {
  7737. if !m.op.Is(OpUpdateOne) {
  7738. return v, errors.New("OldTemplateName is only allowed on UpdateOne operations")
  7739. }
  7740. if m.id == nil || m.oldValue == nil {
  7741. return v, errors.New("OldTemplateName requires an ID field in the mutation")
  7742. }
  7743. oldValue, err := m.oldValue(ctx)
  7744. if err != nil {
  7745. return v, fmt.Errorf("querying old value for OldTemplateName: %w", err)
  7746. }
  7747. return oldValue.TemplateName, nil
  7748. }
  7749. // ClearTemplateName clears the value of the "template_name" field.
  7750. func (m *BatchMsgMutation) ClearTemplateName() {
  7751. m.template_name = nil
  7752. m.clearedFields[batchmsg.FieldTemplateName] = struct{}{}
  7753. }
  7754. // TemplateNameCleared returns if the "template_name" field was cleared in this mutation.
  7755. func (m *BatchMsgMutation) TemplateNameCleared() bool {
  7756. _, ok := m.clearedFields[batchmsg.FieldTemplateName]
  7757. return ok
  7758. }
  7759. // ResetTemplateName resets all changes to the "template_name" field.
  7760. func (m *BatchMsgMutation) ResetTemplateName() {
  7761. m.template_name = nil
  7762. delete(m.clearedFields, batchmsg.FieldTemplateName)
  7763. }
  7764. // SetTemplateCode sets the "template_code" field.
  7765. func (m *BatchMsgMutation) SetTemplateCode(s string) {
  7766. m.template_code = &s
  7767. }
  7768. // TemplateCode returns the value of the "template_code" field in the mutation.
  7769. func (m *BatchMsgMutation) TemplateCode() (r string, exists bool) {
  7770. v := m.template_code
  7771. if v == nil {
  7772. return
  7773. }
  7774. return *v, true
  7775. }
  7776. // OldTemplateCode returns the old "template_code" field's value of the BatchMsg entity.
  7777. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7779. func (m *BatchMsgMutation) OldTemplateCode(ctx context.Context) (v string, err error) {
  7780. if !m.op.Is(OpUpdateOne) {
  7781. return v, errors.New("OldTemplateCode is only allowed on UpdateOne operations")
  7782. }
  7783. if m.id == nil || m.oldValue == nil {
  7784. return v, errors.New("OldTemplateCode requires an ID field in the mutation")
  7785. }
  7786. oldValue, err := m.oldValue(ctx)
  7787. if err != nil {
  7788. return v, fmt.Errorf("querying old value for OldTemplateCode: %w", err)
  7789. }
  7790. return oldValue.TemplateCode, nil
  7791. }
  7792. // ClearTemplateCode clears the value of the "template_code" field.
  7793. func (m *BatchMsgMutation) ClearTemplateCode() {
  7794. m.template_code = nil
  7795. m.clearedFields[batchmsg.FieldTemplateCode] = struct{}{}
  7796. }
  7797. // TemplateCodeCleared returns if the "template_code" field was cleared in this mutation.
  7798. func (m *BatchMsgMutation) TemplateCodeCleared() bool {
  7799. _, ok := m.clearedFields[batchmsg.FieldTemplateCode]
  7800. return ok
  7801. }
  7802. // ResetTemplateCode resets all changes to the "template_code" field.
  7803. func (m *BatchMsgMutation) ResetTemplateCode() {
  7804. m.template_code = nil
  7805. delete(m.clearedFields, batchmsg.FieldTemplateCode)
  7806. }
  7807. // SetLang sets the "lang" field.
  7808. func (m *BatchMsgMutation) SetLang(s string) {
  7809. m.lang = &s
  7810. }
  7811. // Lang returns the value of the "lang" field in the mutation.
  7812. func (m *BatchMsgMutation) Lang() (r string, exists bool) {
  7813. v := m.lang
  7814. if v == nil {
  7815. return
  7816. }
  7817. return *v, true
  7818. }
  7819. // OldLang returns the old "lang" field's value of the BatchMsg entity.
  7820. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  7821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7822. func (m *BatchMsgMutation) OldLang(ctx context.Context) (v string, err error) {
  7823. if !m.op.Is(OpUpdateOne) {
  7824. return v, errors.New("OldLang is only allowed on UpdateOne operations")
  7825. }
  7826. if m.id == nil || m.oldValue == nil {
  7827. return v, errors.New("OldLang requires an ID field in the mutation")
  7828. }
  7829. oldValue, err := m.oldValue(ctx)
  7830. if err != nil {
  7831. return v, fmt.Errorf("querying old value for OldLang: %w", err)
  7832. }
  7833. return oldValue.Lang, nil
  7834. }
  7835. // ClearLang clears the value of the "lang" field.
  7836. func (m *BatchMsgMutation) ClearLang() {
  7837. m.lang = nil
  7838. m.clearedFields[batchmsg.FieldLang] = struct{}{}
  7839. }
  7840. // LangCleared returns if the "lang" field was cleared in this mutation.
  7841. func (m *BatchMsgMutation) LangCleared() bool {
  7842. _, ok := m.clearedFields[batchmsg.FieldLang]
  7843. return ok
  7844. }
  7845. // ResetLang resets all changes to the "lang" field.
  7846. func (m *BatchMsgMutation) ResetLang() {
  7847. m.lang = nil
  7848. delete(m.clearedFields, batchmsg.FieldLang)
  7849. }
  7850. // Where appends a list predicates to the BatchMsgMutation builder.
  7851. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  7852. m.predicates = append(m.predicates, ps...)
  7853. }
  7854. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  7855. // users can use type-assertion to append predicates that do not depend on any generated package.
  7856. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  7857. p := make([]predicate.BatchMsg, len(ps))
  7858. for i := range ps {
  7859. p[i] = ps[i]
  7860. }
  7861. m.Where(p...)
  7862. }
  7863. // Op returns the operation name.
  7864. func (m *BatchMsgMutation) Op() Op {
  7865. return m.op
  7866. }
  7867. // SetOp allows setting the mutation operation.
  7868. func (m *BatchMsgMutation) SetOp(op Op) {
  7869. m.op = op
  7870. }
  7871. // Type returns the node type of this mutation (BatchMsg).
  7872. func (m *BatchMsgMutation) Type() string {
  7873. return m.typ
  7874. }
  7875. // Fields returns all fields that were changed during this mutation. Note that in
  7876. // order to get all numeric fields that were incremented/decremented, call
  7877. // AddedFields().
  7878. func (m *BatchMsgMutation) Fields() []string {
  7879. fields := make([]string, 0, 24)
  7880. if m.created_at != nil {
  7881. fields = append(fields, batchmsg.FieldCreatedAt)
  7882. }
  7883. if m.updated_at != nil {
  7884. fields = append(fields, batchmsg.FieldUpdatedAt)
  7885. }
  7886. if m.deleted_at != nil {
  7887. fields = append(fields, batchmsg.FieldDeletedAt)
  7888. }
  7889. if m.status != nil {
  7890. fields = append(fields, batchmsg.FieldStatus)
  7891. }
  7892. if m.batch_no != nil {
  7893. fields = append(fields, batchmsg.FieldBatchNo)
  7894. }
  7895. if m.task_name != nil {
  7896. fields = append(fields, batchmsg.FieldTaskName)
  7897. }
  7898. if m.fromwxid != nil {
  7899. fields = append(fields, batchmsg.FieldFromwxid)
  7900. }
  7901. if m.msg != nil {
  7902. fields = append(fields, batchmsg.FieldMsg)
  7903. }
  7904. if m.tag != nil {
  7905. fields = append(fields, batchmsg.FieldTag)
  7906. }
  7907. if m.tagids != nil {
  7908. fields = append(fields, batchmsg.FieldTagids)
  7909. }
  7910. if m.total != nil {
  7911. fields = append(fields, batchmsg.FieldTotal)
  7912. }
  7913. if m.success != nil {
  7914. fields = append(fields, batchmsg.FieldSuccess)
  7915. }
  7916. if m.fail != nil {
  7917. fields = append(fields, batchmsg.FieldFail)
  7918. }
  7919. if m.start_time != nil {
  7920. fields = append(fields, batchmsg.FieldStartTime)
  7921. }
  7922. if m.stop_time != nil {
  7923. fields = append(fields, batchmsg.FieldStopTime)
  7924. }
  7925. if m.send_time != nil {
  7926. fields = append(fields, batchmsg.FieldSendTime)
  7927. }
  7928. if m._type != nil {
  7929. fields = append(fields, batchmsg.FieldType)
  7930. }
  7931. if m.organization_id != nil {
  7932. fields = append(fields, batchmsg.FieldOrganizationID)
  7933. }
  7934. if m.ctype != nil {
  7935. fields = append(fields, batchmsg.FieldCtype)
  7936. }
  7937. if m.cc != nil {
  7938. fields = append(fields, batchmsg.FieldCc)
  7939. }
  7940. if m.phone != nil {
  7941. fields = append(fields, batchmsg.FieldPhone)
  7942. }
  7943. if m.template_name != nil {
  7944. fields = append(fields, batchmsg.FieldTemplateName)
  7945. }
  7946. if m.template_code != nil {
  7947. fields = append(fields, batchmsg.FieldTemplateCode)
  7948. }
  7949. if m.lang != nil {
  7950. fields = append(fields, batchmsg.FieldLang)
  7951. }
  7952. return fields
  7953. }
  7954. // Field returns the value of a field with the given name. The second boolean
  7955. // return value indicates that this field was not set, or was not defined in the
  7956. // schema.
  7957. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  7958. switch name {
  7959. case batchmsg.FieldCreatedAt:
  7960. return m.CreatedAt()
  7961. case batchmsg.FieldUpdatedAt:
  7962. return m.UpdatedAt()
  7963. case batchmsg.FieldDeletedAt:
  7964. return m.DeletedAt()
  7965. case batchmsg.FieldStatus:
  7966. return m.Status()
  7967. case batchmsg.FieldBatchNo:
  7968. return m.BatchNo()
  7969. case batchmsg.FieldTaskName:
  7970. return m.TaskName()
  7971. case batchmsg.FieldFromwxid:
  7972. return m.Fromwxid()
  7973. case batchmsg.FieldMsg:
  7974. return m.Msg()
  7975. case batchmsg.FieldTag:
  7976. return m.Tag()
  7977. case batchmsg.FieldTagids:
  7978. return m.Tagids()
  7979. case batchmsg.FieldTotal:
  7980. return m.Total()
  7981. case batchmsg.FieldSuccess:
  7982. return m.Success()
  7983. case batchmsg.FieldFail:
  7984. return m.Fail()
  7985. case batchmsg.FieldStartTime:
  7986. return m.StartTime()
  7987. case batchmsg.FieldStopTime:
  7988. return m.StopTime()
  7989. case batchmsg.FieldSendTime:
  7990. return m.SendTime()
  7991. case batchmsg.FieldType:
  7992. return m.GetType()
  7993. case batchmsg.FieldOrganizationID:
  7994. return m.OrganizationID()
  7995. case batchmsg.FieldCtype:
  7996. return m.Ctype()
  7997. case batchmsg.FieldCc:
  7998. return m.Cc()
  7999. case batchmsg.FieldPhone:
  8000. return m.Phone()
  8001. case batchmsg.FieldTemplateName:
  8002. return m.TemplateName()
  8003. case batchmsg.FieldTemplateCode:
  8004. return m.TemplateCode()
  8005. case batchmsg.FieldLang:
  8006. return m.Lang()
  8007. }
  8008. return nil, false
  8009. }
  8010. // OldField returns the old value of the field from the database. An error is
  8011. // returned if the mutation operation is not UpdateOne, or the query to the
  8012. // database failed.
  8013. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8014. switch name {
  8015. case batchmsg.FieldCreatedAt:
  8016. return m.OldCreatedAt(ctx)
  8017. case batchmsg.FieldUpdatedAt:
  8018. return m.OldUpdatedAt(ctx)
  8019. case batchmsg.FieldDeletedAt:
  8020. return m.OldDeletedAt(ctx)
  8021. case batchmsg.FieldStatus:
  8022. return m.OldStatus(ctx)
  8023. case batchmsg.FieldBatchNo:
  8024. return m.OldBatchNo(ctx)
  8025. case batchmsg.FieldTaskName:
  8026. return m.OldTaskName(ctx)
  8027. case batchmsg.FieldFromwxid:
  8028. return m.OldFromwxid(ctx)
  8029. case batchmsg.FieldMsg:
  8030. return m.OldMsg(ctx)
  8031. case batchmsg.FieldTag:
  8032. return m.OldTag(ctx)
  8033. case batchmsg.FieldTagids:
  8034. return m.OldTagids(ctx)
  8035. case batchmsg.FieldTotal:
  8036. return m.OldTotal(ctx)
  8037. case batchmsg.FieldSuccess:
  8038. return m.OldSuccess(ctx)
  8039. case batchmsg.FieldFail:
  8040. return m.OldFail(ctx)
  8041. case batchmsg.FieldStartTime:
  8042. return m.OldStartTime(ctx)
  8043. case batchmsg.FieldStopTime:
  8044. return m.OldStopTime(ctx)
  8045. case batchmsg.FieldSendTime:
  8046. return m.OldSendTime(ctx)
  8047. case batchmsg.FieldType:
  8048. return m.OldType(ctx)
  8049. case batchmsg.FieldOrganizationID:
  8050. return m.OldOrganizationID(ctx)
  8051. case batchmsg.FieldCtype:
  8052. return m.OldCtype(ctx)
  8053. case batchmsg.FieldCc:
  8054. return m.OldCc(ctx)
  8055. case batchmsg.FieldPhone:
  8056. return m.OldPhone(ctx)
  8057. case batchmsg.FieldTemplateName:
  8058. return m.OldTemplateName(ctx)
  8059. case batchmsg.FieldTemplateCode:
  8060. return m.OldTemplateCode(ctx)
  8061. case batchmsg.FieldLang:
  8062. return m.OldLang(ctx)
  8063. }
  8064. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  8065. }
  8066. // SetField sets the value of a field with the given name. It returns an error if
  8067. // the field is not defined in the schema, or if the type mismatched the field
  8068. // type.
  8069. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  8070. switch name {
  8071. case batchmsg.FieldCreatedAt:
  8072. v, ok := value.(time.Time)
  8073. if !ok {
  8074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8075. }
  8076. m.SetCreatedAt(v)
  8077. return nil
  8078. case batchmsg.FieldUpdatedAt:
  8079. v, ok := value.(time.Time)
  8080. if !ok {
  8081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8082. }
  8083. m.SetUpdatedAt(v)
  8084. return nil
  8085. case batchmsg.FieldDeletedAt:
  8086. v, ok := value.(time.Time)
  8087. if !ok {
  8088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8089. }
  8090. m.SetDeletedAt(v)
  8091. return nil
  8092. case batchmsg.FieldStatus:
  8093. v, ok := value.(uint8)
  8094. if !ok {
  8095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8096. }
  8097. m.SetStatus(v)
  8098. return nil
  8099. case batchmsg.FieldBatchNo:
  8100. v, ok := value.(string)
  8101. if !ok {
  8102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8103. }
  8104. m.SetBatchNo(v)
  8105. return nil
  8106. case batchmsg.FieldTaskName:
  8107. v, ok := value.(string)
  8108. if !ok {
  8109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8110. }
  8111. m.SetTaskName(v)
  8112. return nil
  8113. case batchmsg.FieldFromwxid:
  8114. v, ok := value.(string)
  8115. if !ok {
  8116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8117. }
  8118. m.SetFromwxid(v)
  8119. return nil
  8120. case batchmsg.FieldMsg:
  8121. v, ok := value.(string)
  8122. if !ok {
  8123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8124. }
  8125. m.SetMsg(v)
  8126. return nil
  8127. case batchmsg.FieldTag:
  8128. v, ok := value.(string)
  8129. if !ok {
  8130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8131. }
  8132. m.SetTag(v)
  8133. return nil
  8134. case batchmsg.FieldTagids:
  8135. v, ok := value.(string)
  8136. if !ok {
  8137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8138. }
  8139. m.SetTagids(v)
  8140. return nil
  8141. case batchmsg.FieldTotal:
  8142. v, ok := value.(int32)
  8143. if !ok {
  8144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8145. }
  8146. m.SetTotal(v)
  8147. return nil
  8148. case batchmsg.FieldSuccess:
  8149. v, ok := value.(int32)
  8150. if !ok {
  8151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8152. }
  8153. m.SetSuccess(v)
  8154. return nil
  8155. case batchmsg.FieldFail:
  8156. v, ok := value.(int32)
  8157. if !ok {
  8158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8159. }
  8160. m.SetFail(v)
  8161. return nil
  8162. case batchmsg.FieldStartTime:
  8163. v, ok := value.(time.Time)
  8164. if !ok {
  8165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8166. }
  8167. m.SetStartTime(v)
  8168. return nil
  8169. case batchmsg.FieldStopTime:
  8170. v, ok := value.(time.Time)
  8171. if !ok {
  8172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8173. }
  8174. m.SetStopTime(v)
  8175. return nil
  8176. case batchmsg.FieldSendTime:
  8177. v, ok := value.(time.Time)
  8178. if !ok {
  8179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8180. }
  8181. m.SetSendTime(v)
  8182. return nil
  8183. case batchmsg.FieldType:
  8184. v, ok := value.(int32)
  8185. if !ok {
  8186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8187. }
  8188. m.SetType(v)
  8189. return nil
  8190. case batchmsg.FieldOrganizationID:
  8191. v, ok := value.(uint64)
  8192. if !ok {
  8193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8194. }
  8195. m.SetOrganizationID(v)
  8196. return nil
  8197. case batchmsg.FieldCtype:
  8198. v, ok := value.(uint64)
  8199. if !ok {
  8200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8201. }
  8202. m.SetCtype(v)
  8203. return nil
  8204. case batchmsg.FieldCc:
  8205. v, ok := value.(string)
  8206. if !ok {
  8207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8208. }
  8209. m.SetCc(v)
  8210. return nil
  8211. case batchmsg.FieldPhone:
  8212. v, ok := value.(string)
  8213. if !ok {
  8214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8215. }
  8216. m.SetPhone(v)
  8217. return nil
  8218. case batchmsg.FieldTemplateName:
  8219. v, ok := value.(string)
  8220. if !ok {
  8221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8222. }
  8223. m.SetTemplateName(v)
  8224. return nil
  8225. case batchmsg.FieldTemplateCode:
  8226. v, ok := value.(string)
  8227. if !ok {
  8228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8229. }
  8230. m.SetTemplateCode(v)
  8231. return nil
  8232. case batchmsg.FieldLang:
  8233. v, ok := value.(string)
  8234. if !ok {
  8235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8236. }
  8237. m.SetLang(v)
  8238. return nil
  8239. }
  8240. return fmt.Errorf("unknown BatchMsg field %s", name)
  8241. }
  8242. // AddedFields returns all numeric fields that were incremented/decremented during
  8243. // this mutation.
  8244. func (m *BatchMsgMutation) AddedFields() []string {
  8245. var fields []string
  8246. if m.addstatus != nil {
  8247. fields = append(fields, batchmsg.FieldStatus)
  8248. }
  8249. if m.addtotal != nil {
  8250. fields = append(fields, batchmsg.FieldTotal)
  8251. }
  8252. if m.addsuccess != nil {
  8253. fields = append(fields, batchmsg.FieldSuccess)
  8254. }
  8255. if m.addfail != nil {
  8256. fields = append(fields, batchmsg.FieldFail)
  8257. }
  8258. if m.add_type != nil {
  8259. fields = append(fields, batchmsg.FieldType)
  8260. }
  8261. if m.addorganization_id != nil {
  8262. fields = append(fields, batchmsg.FieldOrganizationID)
  8263. }
  8264. if m.addctype != nil {
  8265. fields = append(fields, batchmsg.FieldCtype)
  8266. }
  8267. return fields
  8268. }
  8269. // AddedField returns the numeric value that was incremented/decremented on a field
  8270. // with the given name. The second boolean return value indicates that this field
  8271. // was not set, or was not defined in the schema.
  8272. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  8273. switch name {
  8274. case batchmsg.FieldStatus:
  8275. return m.AddedStatus()
  8276. case batchmsg.FieldTotal:
  8277. return m.AddedTotal()
  8278. case batchmsg.FieldSuccess:
  8279. return m.AddedSuccess()
  8280. case batchmsg.FieldFail:
  8281. return m.AddedFail()
  8282. case batchmsg.FieldType:
  8283. return m.AddedType()
  8284. case batchmsg.FieldOrganizationID:
  8285. return m.AddedOrganizationID()
  8286. case batchmsg.FieldCtype:
  8287. return m.AddedCtype()
  8288. }
  8289. return nil, false
  8290. }
  8291. // AddField adds the value to the field with the given name. It returns an error if
  8292. // the field is not defined in the schema, or if the type mismatched the field
  8293. // type.
  8294. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  8295. switch name {
  8296. case batchmsg.FieldStatus:
  8297. v, ok := value.(int8)
  8298. if !ok {
  8299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8300. }
  8301. m.AddStatus(v)
  8302. return nil
  8303. case batchmsg.FieldTotal:
  8304. v, ok := value.(int32)
  8305. if !ok {
  8306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8307. }
  8308. m.AddTotal(v)
  8309. return nil
  8310. case batchmsg.FieldSuccess:
  8311. v, ok := value.(int32)
  8312. if !ok {
  8313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8314. }
  8315. m.AddSuccess(v)
  8316. return nil
  8317. case batchmsg.FieldFail:
  8318. v, ok := value.(int32)
  8319. if !ok {
  8320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8321. }
  8322. m.AddFail(v)
  8323. return nil
  8324. case batchmsg.FieldType:
  8325. v, ok := value.(int32)
  8326. if !ok {
  8327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8328. }
  8329. m.AddType(v)
  8330. return nil
  8331. case batchmsg.FieldOrganizationID:
  8332. v, ok := value.(int64)
  8333. if !ok {
  8334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8335. }
  8336. m.AddOrganizationID(v)
  8337. return nil
  8338. case batchmsg.FieldCtype:
  8339. v, ok := value.(int64)
  8340. if !ok {
  8341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8342. }
  8343. m.AddCtype(v)
  8344. return nil
  8345. }
  8346. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  8347. }
  8348. // ClearedFields returns all nullable fields that were cleared during this
  8349. // mutation.
  8350. func (m *BatchMsgMutation) ClearedFields() []string {
  8351. var fields []string
  8352. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  8353. fields = append(fields, batchmsg.FieldDeletedAt)
  8354. }
  8355. if m.FieldCleared(batchmsg.FieldStatus) {
  8356. fields = append(fields, batchmsg.FieldStatus)
  8357. }
  8358. if m.FieldCleared(batchmsg.FieldBatchNo) {
  8359. fields = append(fields, batchmsg.FieldBatchNo)
  8360. }
  8361. if m.FieldCleared(batchmsg.FieldTaskName) {
  8362. fields = append(fields, batchmsg.FieldTaskName)
  8363. }
  8364. if m.FieldCleared(batchmsg.FieldFromwxid) {
  8365. fields = append(fields, batchmsg.FieldFromwxid)
  8366. }
  8367. if m.FieldCleared(batchmsg.FieldMsg) {
  8368. fields = append(fields, batchmsg.FieldMsg)
  8369. }
  8370. if m.FieldCleared(batchmsg.FieldTag) {
  8371. fields = append(fields, batchmsg.FieldTag)
  8372. }
  8373. if m.FieldCleared(batchmsg.FieldTagids) {
  8374. fields = append(fields, batchmsg.FieldTagids)
  8375. }
  8376. if m.FieldCleared(batchmsg.FieldTotal) {
  8377. fields = append(fields, batchmsg.FieldTotal)
  8378. }
  8379. if m.FieldCleared(batchmsg.FieldSuccess) {
  8380. fields = append(fields, batchmsg.FieldSuccess)
  8381. }
  8382. if m.FieldCleared(batchmsg.FieldFail) {
  8383. fields = append(fields, batchmsg.FieldFail)
  8384. }
  8385. if m.FieldCleared(batchmsg.FieldStartTime) {
  8386. fields = append(fields, batchmsg.FieldStartTime)
  8387. }
  8388. if m.FieldCleared(batchmsg.FieldStopTime) {
  8389. fields = append(fields, batchmsg.FieldStopTime)
  8390. }
  8391. if m.FieldCleared(batchmsg.FieldSendTime) {
  8392. fields = append(fields, batchmsg.FieldSendTime)
  8393. }
  8394. if m.FieldCleared(batchmsg.FieldType) {
  8395. fields = append(fields, batchmsg.FieldType)
  8396. }
  8397. if m.FieldCleared(batchmsg.FieldCc) {
  8398. fields = append(fields, batchmsg.FieldCc)
  8399. }
  8400. if m.FieldCleared(batchmsg.FieldPhone) {
  8401. fields = append(fields, batchmsg.FieldPhone)
  8402. }
  8403. if m.FieldCleared(batchmsg.FieldTemplateName) {
  8404. fields = append(fields, batchmsg.FieldTemplateName)
  8405. }
  8406. if m.FieldCleared(batchmsg.FieldTemplateCode) {
  8407. fields = append(fields, batchmsg.FieldTemplateCode)
  8408. }
  8409. if m.FieldCleared(batchmsg.FieldLang) {
  8410. fields = append(fields, batchmsg.FieldLang)
  8411. }
  8412. return fields
  8413. }
  8414. // FieldCleared returns a boolean indicating if a field with the given name was
  8415. // cleared in this mutation.
  8416. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  8417. _, ok := m.clearedFields[name]
  8418. return ok
  8419. }
  8420. // ClearField clears the value of the field with the given name. It returns an
  8421. // error if the field is not defined in the schema.
  8422. func (m *BatchMsgMutation) ClearField(name string) error {
  8423. switch name {
  8424. case batchmsg.FieldDeletedAt:
  8425. m.ClearDeletedAt()
  8426. return nil
  8427. case batchmsg.FieldStatus:
  8428. m.ClearStatus()
  8429. return nil
  8430. case batchmsg.FieldBatchNo:
  8431. m.ClearBatchNo()
  8432. return nil
  8433. case batchmsg.FieldTaskName:
  8434. m.ClearTaskName()
  8435. return nil
  8436. case batchmsg.FieldFromwxid:
  8437. m.ClearFromwxid()
  8438. return nil
  8439. case batchmsg.FieldMsg:
  8440. m.ClearMsg()
  8441. return nil
  8442. case batchmsg.FieldTag:
  8443. m.ClearTag()
  8444. return nil
  8445. case batchmsg.FieldTagids:
  8446. m.ClearTagids()
  8447. return nil
  8448. case batchmsg.FieldTotal:
  8449. m.ClearTotal()
  8450. return nil
  8451. case batchmsg.FieldSuccess:
  8452. m.ClearSuccess()
  8453. return nil
  8454. case batchmsg.FieldFail:
  8455. m.ClearFail()
  8456. return nil
  8457. case batchmsg.FieldStartTime:
  8458. m.ClearStartTime()
  8459. return nil
  8460. case batchmsg.FieldStopTime:
  8461. m.ClearStopTime()
  8462. return nil
  8463. case batchmsg.FieldSendTime:
  8464. m.ClearSendTime()
  8465. return nil
  8466. case batchmsg.FieldType:
  8467. m.ClearType()
  8468. return nil
  8469. case batchmsg.FieldCc:
  8470. m.ClearCc()
  8471. return nil
  8472. case batchmsg.FieldPhone:
  8473. m.ClearPhone()
  8474. return nil
  8475. case batchmsg.FieldTemplateName:
  8476. m.ClearTemplateName()
  8477. return nil
  8478. case batchmsg.FieldTemplateCode:
  8479. m.ClearTemplateCode()
  8480. return nil
  8481. case batchmsg.FieldLang:
  8482. m.ClearLang()
  8483. return nil
  8484. }
  8485. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  8486. }
  8487. // ResetField resets all changes in the mutation for the field with the given name.
  8488. // It returns an error if the field is not defined in the schema.
  8489. func (m *BatchMsgMutation) ResetField(name string) error {
  8490. switch name {
  8491. case batchmsg.FieldCreatedAt:
  8492. m.ResetCreatedAt()
  8493. return nil
  8494. case batchmsg.FieldUpdatedAt:
  8495. m.ResetUpdatedAt()
  8496. return nil
  8497. case batchmsg.FieldDeletedAt:
  8498. m.ResetDeletedAt()
  8499. return nil
  8500. case batchmsg.FieldStatus:
  8501. m.ResetStatus()
  8502. return nil
  8503. case batchmsg.FieldBatchNo:
  8504. m.ResetBatchNo()
  8505. return nil
  8506. case batchmsg.FieldTaskName:
  8507. m.ResetTaskName()
  8508. return nil
  8509. case batchmsg.FieldFromwxid:
  8510. m.ResetFromwxid()
  8511. return nil
  8512. case batchmsg.FieldMsg:
  8513. m.ResetMsg()
  8514. return nil
  8515. case batchmsg.FieldTag:
  8516. m.ResetTag()
  8517. return nil
  8518. case batchmsg.FieldTagids:
  8519. m.ResetTagids()
  8520. return nil
  8521. case batchmsg.FieldTotal:
  8522. m.ResetTotal()
  8523. return nil
  8524. case batchmsg.FieldSuccess:
  8525. m.ResetSuccess()
  8526. return nil
  8527. case batchmsg.FieldFail:
  8528. m.ResetFail()
  8529. return nil
  8530. case batchmsg.FieldStartTime:
  8531. m.ResetStartTime()
  8532. return nil
  8533. case batchmsg.FieldStopTime:
  8534. m.ResetStopTime()
  8535. return nil
  8536. case batchmsg.FieldSendTime:
  8537. m.ResetSendTime()
  8538. return nil
  8539. case batchmsg.FieldType:
  8540. m.ResetType()
  8541. return nil
  8542. case batchmsg.FieldOrganizationID:
  8543. m.ResetOrganizationID()
  8544. return nil
  8545. case batchmsg.FieldCtype:
  8546. m.ResetCtype()
  8547. return nil
  8548. case batchmsg.FieldCc:
  8549. m.ResetCc()
  8550. return nil
  8551. case batchmsg.FieldPhone:
  8552. m.ResetPhone()
  8553. return nil
  8554. case batchmsg.FieldTemplateName:
  8555. m.ResetTemplateName()
  8556. return nil
  8557. case batchmsg.FieldTemplateCode:
  8558. m.ResetTemplateCode()
  8559. return nil
  8560. case batchmsg.FieldLang:
  8561. m.ResetLang()
  8562. return nil
  8563. }
  8564. return fmt.Errorf("unknown BatchMsg field %s", name)
  8565. }
  8566. // AddedEdges returns all edge names that were set/added in this mutation.
  8567. func (m *BatchMsgMutation) AddedEdges() []string {
  8568. edges := make([]string, 0, 0)
  8569. return edges
  8570. }
  8571. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8572. // name in this mutation.
  8573. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  8574. return nil
  8575. }
  8576. // RemovedEdges returns all edge names that were removed in this mutation.
  8577. func (m *BatchMsgMutation) RemovedEdges() []string {
  8578. edges := make([]string, 0, 0)
  8579. return edges
  8580. }
  8581. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8582. // the given name in this mutation.
  8583. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  8584. return nil
  8585. }
  8586. // ClearedEdges returns all edge names that were cleared in this mutation.
  8587. func (m *BatchMsgMutation) ClearedEdges() []string {
  8588. edges := make([]string, 0, 0)
  8589. return edges
  8590. }
  8591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8592. // was cleared in this mutation.
  8593. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  8594. return false
  8595. }
  8596. // ClearEdge clears the value of the edge with the given name. It returns an error
  8597. // if that edge is not defined in the schema.
  8598. func (m *BatchMsgMutation) ClearEdge(name string) error {
  8599. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  8600. }
  8601. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8602. // It returns an error if the edge is not defined in the schema.
  8603. func (m *BatchMsgMutation) ResetEdge(name string) error {
  8604. return fmt.Errorf("unknown BatchMsg edge %s", name)
  8605. }
  8606. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  8607. type CategoryMutation struct {
  8608. config
  8609. op Op
  8610. typ string
  8611. id *uint64
  8612. created_at *time.Time
  8613. updated_at *time.Time
  8614. deleted_at *time.Time
  8615. name *string
  8616. organization_id *uint64
  8617. addorganization_id *int64
  8618. clearedFields map[string]struct{}
  8619. done bool
  8620. oldValue func(context.Context) (*Category, error)
  8621. predicates []predicate.Category
  8622. }
  8623. var _ ent.Mutation = (*CategoryMutation)(nil)
  8624. // categoryOption allows management of the mutation configuration using functional options.
  8625. type categoryOption func(*CategoryMutation)
  8626. // newCategoryMutation creates new mutation for the Category entity.
  8627. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  8628. m := &CategoryMutation{
  8629. config: c,
  8630. op: op,
  8631. typ: TypeCategory,
  8632. clearedFields: make(map[string]struct{}),
  8633. }
  8634. for _, opt := range opts {
  8635. opt(m)
  8636. }
  8637. return m
  8638. }
  8639. // withCategoryID sets the ID field of the mutation.
  8640. func withCategoryID(id uint64) categoryOption {
  8641. return func(m *CategoryMutation) {
  8642. var (
  8643. err error
  8644. once sync.Once
  8645. value *Category
  8646. )
  8647. m.oldValue = func(ctx context.Context) (*Category, error) {
  8648. once.Do(func() {
  8649. if m.done {
  8650. err = errors.New("querying old values post mutation is not allowed")
  8651. } else {
  8652. value, err = m.Client().Category.Get(ctx, id)
  8653. }
  8654. })
  8655. return value, err
  8656. }
  8657. m.id = &id
  8658. }
  8659. }
  8660. // withCategory sets the old Category of the mutation.
  8661. func withCategory(node *Category) categoryOption {
  8662. return func(m *CategoryMutation) {
  8663. m.oldValue = func(context.Context) (*Category, error) {
  8664. return node, nil
  8665. }
  8666. m.id = &node.ID
  8667. }
  8668. }
  8669. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8670. // executed in a transaction (ent.Tx), a transactional client is returned.
  8671. func (m CategoryMutation) Client() *Client {
  8672. client := &Client{config: m.config}
  8673. client.init()
  8674. return client
  8675. }
  8676. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8677. // it returns an error otherwise.
  8678. func (m CategoryMutation) Tx() (*Tx, error) {
  8679. if _, ok := m.driver.(*txDriver); !ok {
  8680. return nil, errors.New("ent: mutation is not running in a transaction")
  8681. }
  8682. tx := &Tx{config: m.config}
  8683. tx.init()
  8684. return tx, nil
  8685. }
  8686. // SetID sets the value of the id field. Note that this
  8687. // operation is only accepted on creation of Category entities.
  8688. func (m *CategoryMutation) SetID(id uint64) {
  8689. m.id = &id
  8690. }
  8691. // ID returns the ID value in the mutation. Note that the ID is only available
  8692. // if it was provided to the builder or after it was returned from the database.
  8693. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  8694. if m.id == nil {
  8695. return
  8696. }
  8697. return *m.id, true
  8698. }
  8699. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8700. // That means, if the mutation is applied within a transaction with an isolation level such
  8701. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8702. // or updated by the mutation.
  8703. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  8704. switch {
  8705. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8706. id, exists := m.ID()
  8707. if exists {
  8708. return []uint64{id}, nil
  8709. }
  8710. fallthrough
  8711. case m.op.Is(OpUpdate | OpDelete):
  8712. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  8713. default:
  8714. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8715. }
  8716. }
  8717. // SetCreatedAt sets the "created_at" field.
  8718. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  8719. m.created_at = &t
  8720. }
  8721. // CreatedAt returns the value of the "created_at" field in the mutation.
  8722. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  8723. v := m.created_at
  8724. if v == nil {
  8725. return
  8726. }
  8727. return *v, true
  8728. }
  8729. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  8730. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8732. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8733. if !m.op.Is(OpUpdateOne) {
  8734. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8735. }
  8736. if m.id == nil || m.oldValue == nil {
  8737. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8738. }
  8739. oldValue, err := m.oldValue(ctx)
  8740. if err != nil {
  8741. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8742. }
  8743. return oldValue.CreatedAt, nil
  8744. }
  8745. // ResetCreatedAt resets all changes to the "created_at" field.
  8746. func (m *CategoryMutation) ResetCreatedAt() {
  8747. m.created_at = nil
  8748. }
  8749. // SetUpdatedAt sets the "updated_at" field.
  8750. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  8751. m.updated_at = &t
  8752. }
  8753. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8754. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  8755. v := m.updated_at
  8756. if v == nil {
  8757. return
  8758. }
  8759. return *v, true
  8760. }
  8761. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  8762. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8764. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8765. if !m.op.Is(OpUpdateOne) {
  8766. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8767. }
  8768. if m.id == nil || m.oldValue == nil {
  8769. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8770. }
  8771. oldValue, err := m.oldValue(ctx)
  8772. if err != nil {
  8773. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8774. }
  8775. return oldValue.UpdatedAt, nil
  8776. }
  8777. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8778. func (m *CategoryMutation) ResetUpdatedAt() {
  8779. m.updated_at = nil
  8780. }
  8781. // SetDeletedAt sets the "deleted_at" field.
  8782. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  8783. m.deleted_at = &t
  8784. }
  8785. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8786. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  8787. v := m.deleted_at
  8788. if v == nil {
  8789. return
  8790. }
  8791. return *v, true
  8792. }
  8793. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  8794. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8796. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8797. if !m.op.Is(OpUpdateOne) {
  8798. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8799. }
  8800. if m.id == nil || m.oldValue == nil {
  8801. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8802. }
  8803. oldValue, err := m.oldValue(ctx)
  8804. if err != nil {
  8805. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8806. }
  8807. return oldValue.DeletedAt, nil
  8808. }
  8809. // ClearDeletedAt clears the value of the "deleted_at" field.
  8810. func (m *CategoryMutation) ClearDeletedAt() {
  8811. m.deleted_at = nil
  8812. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  8813. }
  8814. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8815. func (m *CategoryMutation) DeletedAtCleared() bool {
  8816. _, ok := m.clearedFields[category.FieldDeletedAt]
  8817. return ok
  8818. }
  8819. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8820. func (m *CategoryMutation) ResetDeletedAt() {
  8821. m.deleted_at = nil
  8822. delete(m.clearedFields, category.FieldDeletedAt)
  8823. }
  8824. // SetName sets the "name" field.
  8825. func (m *CategoryMutation) SetName(s string) {
  8826. m.name = &s
  8827. }
  8828. // Name returns the value of the "name" field in the mutation.
  8829. func (m *CategoryMutation) Name() (r string, exists bool) {
  8830. v := m.name
  8831. if v == nil {
  8832. return
  8833. }
  8834. return *v, true
  8835. }
  8836. // OldName returns the old "name" field's value of the Category entity.
  8837. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8839. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  8840. if !m.op.Is(OpUpdateOne) {
  8841. return v, errors.New("OldName is only allowed on UpdateOne operations")
  8842. }
  8843. if m.id == nil || m.oldValue == nil {
  8844. return v, errors.New("OldName requires an ID field in the mutation")
  8845. }
  8846. oldValue, err := m.oldValue(ctx)
  8847. if err != nil {
  8848. return v, fmt.Errorf("querying old value for OldName: %w", err)
  8849. }
  8850. return oldValue.Name, nil
  8851. }
  8852. // ResetName resets all changes to the "name" field.
  8853. func (m *CategoryMutation) ResetName() {
  8854. m.name = nil
  8855. }
  8856. // SetOrganizationID sets the "organization_id" field.
  8857. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  8858. m.organization_id = &u
  8859. m.addorganization_id = nil
  8860. }
  8861. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8862. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  8863. v := m.organization_id
  8864. if v == nil {
  8865. return
  8866. }
  8867. return *v, true
  8868. }
  8869. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  8870. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  8871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8872. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8873. if !m.op.Is(OpUpdateOne) {
  8874. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8875. }
  8876. if m.id == nil || m.oldValue == nil {
  8877. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8878. }
  8879. oldValue, err := m.oldValue(ctx)
  8880. if err != nil {
  8881. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8882. }
  8883. return oldValue.OrganizationID, nil
  8884. }
  8885. // AddOrganizationID adds u to the "organization_id" field.
  8886. func (m *CategoryMutation) AddOrganizationID(u int64) {
  8887. if m.addorganization_id != nil {
  8888. *m.addorganization_id += u
  8889. } else {
  8890. m.addorganization_id = &u
  8891. }
  8892. }
  8893. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8894. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  8895. v := m.addorganization_id
  8896. if v == nil {
  8897. return
  8898. }
  8899. return *v, true
  8900. }
  8901. // ResetOrganizationID resets all changes to the "organization_id" field.
  8902. func (m *CategoryMutation) ResetOrganizationID() {
  8903. m.organization_id = nil
  8904. m.addorganization_id = nil
  8905. }
  8906. // Where appends a list predicates to the CategoryMutation builder.
  8907. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  8908. m.predicates = append(m.predicates, ps...)
  8909. }
  8910. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  8911. // users can use type-assertion to append predicates that do not depend on any generated package.
  8912. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  8913. p := make([]predicate.Category, len(ps))
  8914. for i := range ps {
  8915. p[i] = ps[i]
  8916. }
  8917. m.Where(p...)
  8918. }
  8919. // Op returns the operation name.
  8920. func (m *CategoryMutation) Op() Op {
  8921. return m.op
  8922. }
  8923. // SetOp allows setting the mutation operation.
  8924. func (m *CategoryMutation) SetOp(op Op) {
  8925. m.op = op
  8926. }
  8927. // Type returns the node type of this mutation (Category).
  8928. func (m *CategoryMutation) Type() string {
  8929. return m.typ
  8930. }
  8931. // Fields returns all fields that were changed during this mutation. Note that in
  8932. // order to get all numeric fields that were incremented/decremented, call
  8933. // AddedFields().
  8934. func (m *CategoryMutation) Fields() []string {
  8935. fields := make([]string, 0, 5)
  8936. if m.created_at != nil {
  8937. fields = append(fields, category.FieldCreatedAt)
  8938. }
  8939. if m.updated_at != nil {
  8940. fields = append(fields, category.FieldUpdatedAt)
  8941. }
  8942. if m.deleted_at != nil {
  8943. fields = append(fields, category.FieldDeletedAt)
  8944. }
  8945. if m.name != nil {
  8946. fields = append(fields, category.FieldName)
  8947. }
  8948. if m.organization_id != nil {
  8949. fields = append(fields, category.FieldOrganizationID)
  8950. }
  8951. return fields
  8952. }
  8953. // Field returns the value of a field with the given name. The second boolean
  8954. // return value indicates that this field was not set, or was not defined in the
  8955. // schema.
  8956. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  8957. switch name {
  8958. case category.FieldCreatedAt:
  8959. return m.CreatedAt()
  8960. case category.FieldUpdatedAt:
  8961. return m.UpdatedAt()
  8962. case category.FieldDeletedAt:
  8963. return m.DeletedAt()
  8964. case category.FieldName:
  8965. return m.Name()
  8966. case category.FieldOrganizationID:
  8967. return m.OrganizationID()
  8968. }
  8969. return nil, false
  8970. }
  8971. // OldField returns the old value of the field from the database. An error is
  8972. // returned if the mutation operation is not UpdateOne, or the query to the
  8973. // database failed.
  8974. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8975. switch name {
  8976. case category.FieldCreatedAt:
  8977. return m.OldCreatedAt(ctx)
  8978. case category.FieldUpdatedAt:
  8979. return m.OldUpdatedAt(ctx)
  8980. case category.FieldDeletedAt:
  8981. return m.OldDeletedAt(ctx)
  8982. case category.FieldName:
  8983. return m.OldName(ctx)
  8984. case category.FieldOrganizationID:
  8985. return m.OldOrganizationID(ctx)
  8986. }
  8987. return nil, fmt.Errorf("unknown Category field %s", name)
  8988. }
  8989. // SetField sets the value of a field with the given name. It returns an error if
  8990. // the field is not defined in the schema, or if the type mismatched the field
  8991. // type.
  8992. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  8993. switch name {
  8994. case category.FieldCreatedAt:
  8995. v, ok := value.(time.Time)
  8996. if !ok {
  8997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8998. }
  8999. m.SetCreatedAt(v)
  9000. return nil
  9001. case category.FieldUpdatedAt:
  9002. v, ok := value.(time.Time)
  9003. if !ok {
  9004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9005. }
  9006. m.SetUpdatedAt(v)
  9007. return nil
  9008. case category.FieldDeletedAt:
  9009. v, ok := value.(time.Time)
  9010. if !ok {
  9011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9012. }
  9013. m.SetDeletedAt(v)
  9014. return nil
  9015. case category.FieldName:
  9016. v, ok := value.(string)
  9017. if !ok {
  9018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9019. }
  9020. m.SetName(v)
  9021. return nil
  9022. case category.FieldOrganizationID:
  9023. v, ok := value.(uint64)
  9024. if !ok {
  9025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9026. }
  9027. m.SetOrganizationID(v)
  9028. return nil
  9029. }
  9030. return fmt.Errorf("unknown Category field %s", name)
  9031. }
  9032. // AddedFields returns all numeric fields that were incremented/decremented during
  9033. // this mutation.
  9034. func (m *CategoryMutation) AddedFields() []string {
  9035. var fields []string
  9036. if m.addorganization_id != nil {
  9037. fields = append(fields, category.FieldOrganizationID)
  9038. }
  9039. return fields
  9040. }
  9041. // AddedField returns the numeric value that was incremented/decremented on a field
  9042. // with the given name. The second boolean return value indicates that this field
  9043. // was not set, or was not defined in the schema.
  9044. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  9045. switch name {
  9046. case category.FieldOrganizationID:
  9047. return m.AddedOrganizationID()
  9048. }
  9049. return nil, false
  9050. }
  9051. // AddField adds the value to the field with the given name. It returns an error if
  9052. // the field is not defined in the schema, or if the type mismatched the field
  9053. // type.
  9054. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  9055. switch name {
  9056. case category.FieldOrganizationID:
  9057. v, ok := value.(int64)
  9058. if !ok {
  9059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9060. }
  9061. m.AddOrganizationID(v)
  9062. return nil
  9063. }
  9064. return fmt.Errorf("unknown Category numeric field %s", name)
  9065. }
  9066. // ClearedFields returns all nullable fields that were cleared during this
  9067. // mutation.
  9068. func (m *CategoryMutation) ClearedFields() []string {
  9069. var fields []string
  9070. if m.FieldCleared(category.FieldDeletedAt) {
  9071. fields = append(fields, category.FieldDeletedAt)
  9072. }
  9073. return fields
  9074. }
  9075. // FieldCleared returns a boolean indicating if a field with the given name was
  9076. // cleared in this mutation.
  9077. func (m *CategoryMutation) FieldCleared(name string) bool {
  9078. _, ok := m.clearedFields[name]
  9079. return ok
  9080. }
  9081. // ClearField clears the value of the field with the given name. It returns an
  9082. // error if the field is not defined in the schema.
  9083. func (m *CategoryMutation) ClearField(name string) error {
  9084. switch name {
  9085. case category.FieldDeletedAt:
  9086. m.ClearDeletedAt()
  9087. return nil
  9088. }
  9089. return fmt.Errorf("unknown Category nullable field %s", name)
  9090. }
  9091. // ResetField resets all changes in the mutation for the field with the given name.
  9092. // It returns an error if the field is not defined in the schema.
  9093. func (m *CategoryMutation) ResetField(name string) error {
  9094. switch name {
  9095. case category.FieldCreatedAt:
  9096. m.ResetCreatedAt()
  9097. return nil
  9098. case category.FieldUpdatedAt:
  9099. m.ResetUpdatedAt()
  9100. return nil
  9101. case category.FieldDeletedAt:
  9102. m.ResetDeletedAt()
  9103. return nil
  9104. case category.FieldName:
  9105. m.ResetName()
  9106. return nil
  9107. case category.FieldOrganizationID:
  9108. m.ResetOrganizationID()
  9109. return nil
  9110. }
  9111. return fmt.Errorf("unknown Category field %s", name)
  9112. }
  9113. // AddedEdges returns all edge names that were set/added in this mutation.
  9114. func (m *CategoryMutation) AddedEdges() []string {
  9115. edges := make([]string, 0, 0)
  9116. return edges
  9117. }
  9118. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9119. // name in this mutation.
  9120. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  9121. return nil
  9122. }
  9123. // RemovedEdges returns all edge names that were removed in this mutation.
  9124. func (m *CategoryMutation) RemovedEdges() []string {
  9125. edges := make([]string, 0, 0)
  9126. return edges
  9127. }
  9128. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9129. // the given name in this mutation.
  9130. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  9131. return nil
  9132. }
  9133. // ClearedEdges returns all edge names that were cleared in this mutation.
  9134. func (m *CategoryMutation) ClearedEdges() []string {
  9135. edges := make([]string, 0, 0)
  9136. return edges
  9137. }
  9138. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9139. // was cleared in this mutation.
  9140. func (m *CategoryMutation) EdgeCleared(name string) bool {
  9141. return false
  9142. }
  9143. // ClearEdge clears the value of the edge with the given name. It returns an error
  9144. // if that edge is not defined in the schema.
  9145. func (m *CategoryMutation) ClearEdge(name string) error {
  9146. return fmt.Errorf("unknown Category unique edge %s", name)
  9147. }
  9148. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9149. // It returns an error if the edge is not defined in the schema.
  9150. func (m *CategoryMutation) ResetEdge(name string) error {
  9151. return fmt.Errorf("unknown Category edge %s", name)
  9152. }
  9153. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  9154. type ChatRecordsMutation struct {
  9155. config
  9156. op Op
  9157. typ string
  9158. id *uint64
  9159. created_at *time.Time
  9160. updated_at *time.Time
  9161. deleted_at *time.Time
  9162. content *string
  9163. content_type *uint8
  9164. addcontent_type *int8
  9165. session_id *uint64
  9166. addsession_id *int64
  9167. user_id *uint64
  9168. adduser_id *int64
  9169. bot_id *uint64
  9170. addbot_id *int64
  9171. bot_type *uint8
  9172. addbot_type *int8
  9173. clearedFields map[string]struct{}
  9174. done bool
  9175. oldValue func(context.Context) (*ChatRecords, error)
  9176. predicates []predicate.ChatRecords
  9177. }
  9178. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  9179. // chatrecordsOption allows management of the mutation configuration using functional options.
  9180. type chatrecordsOption func(*ChatRecordsMutation)
  9181. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  9182. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  9183. m := &ChatRecordsMutation{
  9184. config: c,
  9185. op: op,
  9186. typ: TypeChatRecords,
  9187. clearedFields: make(map[string]struct{}),
  9188. }
  9189. for _, opt := range opts {
  9190. opt(m)
  9191. }
  9192. return m
  9193. }
  9194. // withChatRecordsID sets the ID field of the mutation.
  9195. func withChatRecordsID(id uint64) chatrecordsOption {
  9196. return func(m *ChatRecordsMutation) {
  9197. var (
  9198. err error
  9199. once sync.Once
  9200. value *ChatRecords
  9201. )
  9202. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  9203. once.Do(func() {
  9204. if m.done {
  9205. err = errors.New("querying old values post mutation is not allowed")
  9206. } else {
  9207. value, err = m.Client().ChatRecords.Get(ctx, id)
  9208. }
  9209. })
  9210. return value, err
  9211. }
  9212. m.id = &id
  9213. }
  9214. }
  9215. // withChatRecords sets the old ChatRecords of the mutation.
  9216. func withChatRecords(node *ChatRecords) chatrecordsOption {
  9217. return func(m *ChatRecordsMutation) {
  9218. m.oldValue = func(context.Context) (*ChatRecords, error) {
  9219. return node, nil
  9220. }
  9221. m.id = &node.ID
  9222. }
  9223. }
  9224. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9225. // executed in a transaction (ent.Tx), a transactional client is returned.
  9226. func (m ChatRecordsMutation) Client() *Client {
  9227. client := &Client{config: m.config}
  9228. client.init()
  9229. return client
  9230. }
  9231. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9232. // it returns an error otherwise.
  9233. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  9234. if _, ok := m.driver.(*txDriver); !ok {
  9235. return nil, errors.New("ent: mutation is not running in a transaction")
  9236. }
  9237. tx := &Tx{config: m.config}
  9238. tx.init()
  9239. return tx, nil
  9240. }
  9241. // SetID sets the value of the id field. Note that this
  9242. // operation is only accepted on creation of ChatRecords entities.
  9243. func (m *ChatRecordsMutation) SetID(id uint64) {
  9244. m.id = &id
  9245. }
  9246. // ID returns the ID value in the mutation. Note that the ID is only available
  9247. // if it was provided to the builder or after it was returned from the database.
  9248. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  9249. if m.id == nil {
  9250. return
  9251. }
  9252. return *m.id, true
  9253. }
  9254. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9255. // That means, if the mutation is applied within a transaction with an isolation level such
  9256. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9257. // or updated by the mutation.
  9258. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  9259. switch {
  9260. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9261. id, exists := m.ID()
  9262. if exists {
  9263. return []uint64{id}, nil
  9264. }
  9265. fallthrough
  9266. case m.op.Is(OpUpdate | OpDelete):
  9267. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  9268. default:
  9269. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9270. }
  9271. }
  9272. // SetCreatedAt sets the "created_at" field.
  9273. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  9274. m.created_at = &t
  9275. }
  9276. // CreatedAt returns the value of the "created_at" field in the mutation.
  9277. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  9278. v := m.created_at
  9279. if v == nil {
  9280. return
  9281. }
  9282. return *v, true
  9283. }
  9284. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  9285. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9287. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9288. if !m.op.Is(OpUpdateOne) {
  9289. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9290. }
  9291. if m.id == nil || m.oldValue == nil {
  9292. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9293. }
  9294. oldValue, err := m.oldValue(ctx)
  9295. if err != nil {
  9296. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9297. }
  9298. return oldValue.CreatedAt, nil
  9299. }
  9300. // ResetCreatedAt resets all changes to the "created_at" field.
  9301. func (m *ChatRecordsMutation) ResetCreatedAt() {
  9302. m.created_at = nil
  9303. }
  9304. // SetUpdatedAt sets the "updated_at" field.
  9305. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  9306. m.updated_at = &t
  9307. }
  9308. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9309. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  9310. v := m.updated_at
  9311. if v == nil {
  9312. return
  9313. }
  9314. return *v, true
  9315. }
  9316. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  9317. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9319. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9320. if !m.op.Is(OpUpdateOne) {
  9321. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9322. }
  9323. if m.id == nil || m.oldValue == nil {
  9324. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9325. }
  9326. oldValue, err := m.oldValue(ctx)
  9327. if err != nil {
  9328. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9329. }
  9330. return oldValue.UpdatedAt, nil
  9331. }
  9332. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9333. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  9334. m.updated_at = nil
  9335. }
  9336. // SetDeletedAt sets the "deleted_at" field.
  9337. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  9338. m.deleted_at = &t
  9339. }
  9340. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9341. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  9342. v := m.deleted_at
  9343. if v == nil {
  9344. return
  9345. }
  9346. return *v, true
  9347. }
  9348. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  9349. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9351. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9352. if !m.op.Is(OpUpdateOne) {
  9353. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9354. }
  9355. if m.id == nil || m.oldValue == nil {
  9356. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9357. }
  9358. oldValue, err := m.oldValue(ctx)
  9359. if err != nil {
  9360. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9361. }
  9362. return oldValue.DeletedAt, nil
  9363. }
  9364. // ClearDeletedAt clears the value of the "deleted_at" field.
  9365. func (m *ChatRecordsMutation) ClearDeletedAt() {
  9366. m.deleted_at = nil
  9367. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  9368. }
  9369. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9370. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  9371. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  9372. return ok
  9373. }
  9374. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9375. func (m *ChatRecordsMutation) ResetDeletedAt() {
  9376. m.deleted_at = nil
  9377. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  9378. }
  9379. // SetContent sets the "content" field.
  9380. func (m *ChatRecordsMutation) SetContent(s string) {
  9381. m.content = &s
  9382. }
  9383. // Content returns the value of the "content" field in the mutation.
  9384. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  9385. v := m.content
  9386. if v == nil {
  9387. return
  9388. }
  9389. return *v, true
  9390. }
  9391. // OldContent returns the old "content" field's value of the ChatRecords entity.
  9392. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9394. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  9395. if !m.op.Is(OpUpdateOne) {
  9396. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  9397. }
  9398. if m.id == nil || m.oldValue == nil {
  9399. return v, errors.New("OldContent requires an ID field in the mutation")
  9400. }
  9401. oldValue, err := m.oldValue(ctx)
  9402. if err != nil {
  9403. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  9404. }
  9405. return oldValue.Content, nil
  9406. }
  9407. // ResetContent resets all changes to the "content" field.
  9408. func (m *ChatRecordsMutation) ResetContent() {
  9409. m.content = nil
  9410. }
  9411. // SetContentType sets the "content_type" field.
  9412. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  9413. m.content_type = &u
  9414. m.addcontent_type = nil
  9415. }
  9416. // ContentType returns the value of the "content_type" field in the mutation.
  9417. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  9418. v := m.content_type
  9419. if v == nil {
  9420. return
  9421. }
  9422. return *v, true
  9423. }
  9424. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  9425. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9427. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  9428. if !m.op.Is(OpUpdateOne) {
  9429. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  9430. }
  9431. if m.id == nil || m.oldValue == nil {
  9432. return v, errors.New("OldContentType requires an ID field in the mutation")
  9433. }
  9434. oldValue, err := m.oldValue(ctx)
  9435. if err != nil {
  9436. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  9437. }
  9438. return oldValue.ContentType, nil
  9439. }
  9440. // AddContentType adds u to the "content_type" field.
  9441. func (m *ChatRecordsMutation) AddContentType(u int8) {
  9442. if m.addcontent_type != nil {
  9443. *m.addcontent_type += u
  9444. } else {
  9445. m.addcontent_type = &u
  9446. }
  9447. }
  9448. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  9449. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  9450. v := m.addcontent_type
  9451. if v == nil {
  9452. return
  9453. }
  9454. return *v, true
  9455. }
  9456. // ResetContentType resets all changes to the "content_type" field.
  9457. func (m *ChatRecordsMutation) ResetContentType() {
  9458. m.content_type = nil
  9459. m.addcontent_type = nil
  9460. }
  9461. // SetSessionID sets the "session_id" field.
  9462. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  9463. m.session_id = &u
  9464. m.addsession_id = nil
  9465. }
  9466. // SessionID returns the value of the "session_id" field in the mutation.
  9467. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  9468. v := m.session_id
  9469. if v == nil {
  9470. return
  9471. }
  9472. return *v, true
  9473. }
  9474. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  9475. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9477. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  9478. if !m.op.Is(OpUpdateOne) {
  9479. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  9480. }
  9481. if m.id == nil || m.oldValue == nil {
  9482. return v, errors.New("OldSessionID requires an ID field in the mutation")
  9483. }
  9484. oldValue, err := m.oldValue(ctx)
  9485. if err != nil {
  9486. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  9487. }
  9488. return oldValue.SessionID, nil
  9489. }
  9490. // AddSessionID adds u to the "session_id" field.
  9491. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  9492. if m.addsession_id != nil {
  9493. *m.addsession_id += u
  9494. } else {
  9495. m.addsession_id = &u
  9496. }
  9497. }
  9498. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  9499. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  9500. v := m.addsession_id
  9501. if v == nil {
  9502. return
  9503. }
  9504. return *v, true
  9505. }
  9506. // ResetSessionID resets all changes to the "session_id" field.
  9507. func (m *ChatRecordsMutation) ResetSessionID() {
  9508. m.session_id = nil
  9509. m.addsession_id = nil
  9510. }
  9511. // SetUserID sets the "user_id" field.
  9512. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  9513. m.user_id = &u
  9514. m.adduser_id = nil
  9515. }
  9516. // UserID returns the value of the "user_id" field in the mutation.
  9517. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  9518. v := m.user_id
  9519. if v == nil {
  9520. return
  9521. }
  9522. return *v, true
  9523. }
  9524. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  9525. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9527. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  9528. if !m.op.Is(OpUpdateOne) {
  9529. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9530. }
  9531. if m.id == nil || m.oldValue == nil {
  9532. return v, errors.New("OldUserID requires an ID field in the mutation")
  9533. }
  9534. oldValue, err := m.oldValue(ctx)
  9535. if err != nil {
  9536. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9537. }
  9538. return oldValue.UserID, nil
  9539. }
  9540. // AddUserID adds u to the "user_id" field.
  9541. func (m *ChatRecordsMutation) AddUserID(u int64) {
  9542. if m.adduser_id != nil {
  9543. *m.adduser_id += u
  9544. } else {
  9545. m.adduser_id = &u
  9546. }
  9547. }
  9548. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  9549. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  9550. v := m.adduser_id
  9551. if v == nil {
  9552. return
  9553. }
  9554. return *v, true
  9555. }
  9556. // ResetUserID resets all changes to the "user_id" field.
  9557. func (m *ChatRecordsMutation) ResetUserID() {
  9558. m.user_id = nil
  9559. m.adduser_id = nil
  9560. }
  9561. // SetBotID sets the "bot_id" field.
  9562. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  9563. m.bot_id = &u
  9564. m.addbot_id = nil
  9565. }
  9566. // BotID returns the value of the "bot_id" field in the mutation.
  9567. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  9568. v := m.bot_id
  9569. if v == nil {
  9570. return
  9571. }
  9572. return *v, true
  9573. }
  9574. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  9575. // If the ChatRecords 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 *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  9578. if !m.op.Is(OpUpdateOne) {
  9579. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  9580. }
  9581. if m.id == nil || m.oldValue == nil {
  9582. return v, errors.New("OldBotID 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 OldBotID: %w", err)
  9587. }
  9588. return oldValue.BotID, nil
  9589. }
  9590. // AddBotID adds u to the "bot_id" field.
  9591. func (m *ChatRecordsMutation) AddBotID(u int64) {
  9592. if m.addbot_id != nil {
  9593. *m.addbot_id += u
  9594. } else {
  9595. m.addbot_id = &u
  9596. }
  9597. }
  9598. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  9599. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  9600. v := m.addbot_id
  9601. if v == nil {
  9602. return
  9603. }
  9604. return *v, true
  9605. }
  9606. // ResetBotID resets all changes to the "bot_id" field.
  9607. func (m *ChatRecordsMutation) ResetBotID() {
  9608. m.bot_id = nil
  9609. m.addbot_id = nil
  9610. }
  9611. // SetBotType sets the "bot_type" field.
  9612. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  9613. m.bot_type = &u
  9614. m.addbot_type = nil
  9615. }
  9616. // BotType returns the value of the "bot_type" field in the mutation.
  9617. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  9618. v := m.bot_type
  9619. if v == nil {
  9620. return
  9621. }
  9622. return *v, true
  9623. }
  9624. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  9625. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  9626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9627. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  9628. if !m.op.Is(OpUpdateOne) {
  9629. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  9630. }
  9631. if m.id == nil || m.oldValue == nil {
  9632. return v, errors.New("OldBotType requires an ID field in the mutation")
  9633. }
  9634. oldValue, err := m.oldValue(ctx)
  9635. if err != nil {
  9636. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  9637. }
  9638. return oldValue.BotType, nil
  9639. }
  9640. // AddBotType adds u to the "bot_type" field.
  9641. func (m *ChatRecordsMutation) AddBotType(u int8) {
  9642. if m.addbot_type != nil {
  9643. *m.addbot_type += u
  9644. } else {
  9645. m.addbot_type = &u
  9646. }
  9647. }
  9648. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  9649. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  9650. v := m.addbot_type
  9651. if v == nil {
  9652. return
  9653. }
  9654. return *v, true
  9655. }
  9656. // ResetBotType resets all changes to the "bot_type" field.
  9657. func (m *ChatRecordsMutation) ResetBotType() {
  9658. m.bot_type = nil
  9659. m.addbot_type = nil
  9660. }
  9661. // Where appends a list predicates to the ChatRecordsMutation builder.
  9662. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  9663. m.predicates = append(m.predicates, ps...)
  9664. }
  9665. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  9666. // users can use type-assertion to append predicates that do not depend on any generated package.
  9667. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  9668. p := make([]predicate.ChatRecords, len(ps))
  9669. for i := range ps {
  9670. p[i] = ps[i]
  9671. }
  9672. m.Where(p...)
  9673. }
  9674. // Op returns the operation name.
  9675. func (m *ChatRecordsMutation) Op() Op {
  9676. return m.op
  9677. }
  9678. // SetOp allows setting the mutation operation.
  9679. func (m *ChatRecordsMutation) SetOp(op Op) {
  9680. m.op = op
  9681. }
  9682. // Type returns the node type of this mutation (ChatRecords).
  9683. func (m *ChatRecordsMutation) Type() string {
  9684. return m.typ
  9685. }
  9686. // Fields returns all fields that were changed during this mutation. Note that in
  9687. // order to get all numeric fields that were incremented/decremented, call
  9688. // AddedFields().
  9689. func (m *ChatRecordsMutation) Fields() []string {
  9690. fields := make([]string, 0, 9)
  9691. if m.created_at != nil {
  9692. fields = append(fields, chatrecords.FieldCreatedAt)
  9693. }
  9694. if m.updated_at != nil {
  9695. fields = append(fields, chatrecords.FieldUpdatedAt)
  9696. }
  9697. if m.deleted_at != nil {
  9698. fields = append(fields, chatrecords.FieldDeletedAt)
  9699. }
  9700. if m.content != nil {
  9701. fields = append(fields, chatrecords.FieldContent)
  9702. }
  9703. if m.content_type != nil {
  9704. fields = append(fields, chatrecords.FieldContentType)
  9705. }
  9706. if m.session_id != nil {
  9707. fields = append(fields, chatrecords.FieldSessionID)
  9708. }
  9709. if m.user_id != nil {
  9710. fields = append(fields, chatrecords.FieldUserID)
  9711. }
  9712. if m.bot_id != nil {
  9713. fields = append(fields, chatrecords.FieldBotID)
  9714. }
  9715. if m.bot_type != nil {
  9716. fields = append(fields, chatrecords.FieldBotType)
  9717. }
  9718. return fields
  9719. }
  9720. // Field returns the value of a field with the given name. The second boolean
  9721. // return value indicates that this field was not set, or was not defined in the
  9722. // schema.
  9723. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  9724. switch name {
  9725. case chatrecords.FieldCreatedAt:
  9726. return m.CreatedAt()
  9727. case chatrecords.FieldUpdatedAt:
  9728. return m.UpdatedAt()
  9729. case chatrecords.FieldDeletedAt:
  9730. return m.DeletedAt()
  9731. case chatrecords.FieldContent:
  9732. return m.Content()
  9733. case chatrecords.FieldContentType:
  9734. return m.ContentType()
  9735. case chatrecords.FieldSessionID:
  9736. return m.SessionID()
  9737. case chatrecords.FieldUserID:
  9738. return m.UserID()
  9739. case chatrecords.FieldBotID:
  9740. return m.BotID()
  9741. case chatrecords.FieldBotType:
  9742. return m.BotType()
  9743. }
  9744. return nil, false
  9745. }
  9746. // OldField returns the old value of the field from the database. An error is
  9747. // returned if the mutation operation is not UpdateOne, or the query to the
  9748. // database failed.
  9749. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9750. switch name {
  9751. case chatrecords.FieldCreatedAt:
  9752. return m.OldCreatedAt(ctx)
  9753. case chatrecords.FieldUpdatedAt:
  9754. return m.OldUpdatedAt(ctx)
  9755. case chatrecords.FieldDeletedAt:
  9756. return m.OldDeletedAt(ctx)
  9757. case chatrecords.FieldContent:
  9758. return m.OldContent(ctx)
  9759. case chatrecords.FieldContentType:
  9760. return m.OldContentType(ctx)
  9761. case chatrecords.FieldSessionID:
  9762. return m.OldSessionID(ctx)
  9763. case chatrecords.FieldUserID:
  9764. return m.OldUserID(ctx)
  9765. case chatrecords.FieldBotID:
  9766. return m.OldBotID(ctx)
  9767. case chatrecords.FieldBotType:
  9768. return m.OldBotType(ctx)
  9769. }
  9770. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  9771. }
  9772. // SetField sets the value of a field with the given name. It returns an error if
  9773. // the field is not defined in the schema, or if the type mismatched the field
  9774. // type.
  9775. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  9776. switch name {
  9777. case chatrecords.FieldCreatedAt:
  9778. v, ok := value.(time.Time)
  9779. if !ok {
  9780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9781. }
  9782. m.SetCreatedAt(v)
  9783. return nil
  9784. case chatrecords.FieldUpdatedAt:
  9785. v, ok := value.(time.Time)
  9786. if !ok {
  9787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9788. }
  9789. m.SetUpdatedAt(v)
  9790. return nil
  9791. case chatrecords.FieldDeletedAt:
  9792. v, ok := value.(time.Time)
  9793. if !ok {
  9794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9795. }
  9796. m.SetDeletedAt(v)
  9797. return nil
  9798. case chatrecords.FieldContent:
  9799. v, ok := value.(string)
  9800. if !ok {
  9801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9802. }
  9803. m.SetContent(v)
  9804. return nil
  9805. case chatrecords.FieldContentType:
  9806. v, ok := value.(uint8)
  9807. if !ok {
  9808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9809. }
  9810. m.SetContentType(v)
  9811. return nil
  9812. case chatrecords.FieldSessionID:
  9813. v, ok := value.(uint64)
  9814. if !ok {
  9815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9816. }
  9817. m.SetSessionID(v)
  9818. return nil
  9819. case chatrecords.FieldUserID:
  9820. v, ok := value.(uint64)
  9821. if !ok {
  9822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9823. }
  9824. m.SetUserID(v)
  9825. return nil
  9826. case chatrecords.FieldBotID:
  9827. v, ok := value.(uint64)
  9828. if !ok {
  9829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9830. }
  9831. m.SetBotID(v)
  9832. return nil
  9833. case chatrecords.FieldBotType:
  9834. v, ok := value.(uint8)
  9835. if !ok {
  9836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9837. }
  9838. m.SetBotType(v)
  9839. return nil
  9840. }
  9841. return fmt.Errorf("unknown ChatRecords field %s", name)
  9842. }
  9843. // AddedFields returns all numeric fields that were incremented/decremented during
  9844. // this mutation.
  9845. func (m *ChatRecordsMutation) AddedFields() []string {
  9846. var fields []string
  9847. if m.addcontent_type != nil {
  9848. fields = append(fields, chatrecords.FieldContentType)
  9849. }
  9850. if m.addsession_id != nil {
  9851. fields = append(fields, chatrecords.FieldSessionID)
  9852. }
  9853. if m.adduser_id != nil {
  9854. fields = append(fields, chatrecords.FieldUserID)
  9855. }
  9856. if m.addbot_id != nil {
  9857. fields = append(fields, chatrecords.FieldBotID)
  9858. }
  9859. if m.addbot_type != nil {
  9860. fields = append(fields, chatrecords.FieldBotType)
  9861. }
  9862. return fields
  9863. }
  9864. // AddedField returns the numeric value that was incremented/decremented on a field
  9865. // with the given name. The second boolean return value indicates that this field
  9866. // was not set, or was not defined in the schema.
  9867. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  9868. switch name {
  9869. case chatrecords.FieldContentType:
  9870. return m.AddedContentType()
  9871. case chatrecords.FieldSessionID:
  9872. return m.AddedSessionID()
  9873. case chatrecords.FieldUserID:
  9874. return m.AddedUserID()
  9875. case chatrecords.FieldBotID:
  9876. return m.AddedBotID()
  9877. case chatrecords.FieldBotType:
  9878. return m.AddedBotType()
  9879. }
  9880. return nil, false
  9881. }
  9882. // AddField adds the value to the field with the given name. It returns an error if
  9883. // the field is not defined in the schema, or if the type mismatched the field
  9884. // type.
  9885. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  9886. switch name {
  9887. case chatrecords.FieldContentType:
  9888. v, ok := value.(int8)
  9889. if !ok {
  9890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9891. }
  9892. m.AddContentType(v)
  9893. return nil
  9894. case chatrecords.FieldSessionID:
  9895. v, ok := value.(int64)
  9896. if !ok {
  9897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9898. }
  9899. m.AddSessionID(v)
  9900. return nil
  9901. case chatrecords.FieldUserID:
  9902. v, ok := value.(int64)
  9903. if !ok {
  9904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9905. }
  9906. m.AddUserID(v)
  9907. return nil
  9908. case chatrecords.FieldBotID:
  9909. v, ok := value.(int64)
  9910. if !ok {
  9911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9912. }
  9913. m.AddBotID(v)
  9914. return nil
  9915. case chatrecords.FieldBotType:
  9916. v, ok := value.(int8)
  9917. if !ok {
  9918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9919. }
  9920. m.AddBotType(v)
  9921. return nil
  9922. }
  9923. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  9924. }
  9925. // ClearedFields returns all nullable fields that were cleared during this
  9926. // mutation.
  9927. func (m *ChatRecordsMutation) ClearedFields() []string {
  9928. var fields []string
  9929. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  9930. fields = append(fields, chatrecords.FieldDeletedAt)
  9931. }
  9932. return fields
  9933. }
  9934. // FieldCleared returns a boolean indicating if a field with the given name was
  9935. // cleared in this mutation.
  9936. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  9937. _, ok := m.clearedFields[name]
  9938. return ok
  9939. }
  9940. // ClearField clears the value of the field with the given name. It returns an
  9941. // error if the field is not defined in the schema.
  9942. func (m *ChatRecordsMutation) ClearField(name string) error {
  9943. switch name {
  9944. case chatrecords.FieldDeletedAt:
  9945. m.ClearDeletedAt()
  9946. return nil
  9947. }
  9948. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  9949. }
  9950. // ResetField resets all changes in the mutation for the field with the given name.
  9951. // It returns an error if the field is not defined in the schema.
  9952. func (m *ChatRecordsMutation) ResetField(name string) error {
  9953. switch name {
  9954. case chatrecords.FieldCreatedAt:
  9955. m.ResetCreatedAt()
  9956. return nil
  9957. case chatrecords.FieldUpdatedAt:
  9958. m.ResetUpdatedAt()
  9959. return nil
  9960. case chatrecords.FieldDeletedAt:
  9961. m.ResetDeletedAt()
  9962. return nil
  9963. case chatrecords.FieldContent:
  9964. m.ResetContent()
  9965. return nil
  9966. case chatrecords.FieldContentType:
  9967. m.ResetContentType()
  9968. return nil
  9969. case chatrecords.FieldSessionID:
  9970. m.ResetSessionID()
  9971. return nil
  9972. case chatrecords.FieldUserID:
  9973. m.ResetUserID()
  9974. return nil
  9975. case chatrecords.FieldBotID:
  9976. m.ResetBotID()
  9977. return nil
  9978. case chatrecords.FieldBotType:
  9979. m.ResetBotType()
  9980. return nil
  9981. }
  9982. return fmt.Errorf("unknown ChatRecords field %s", name)
  9983. }
  9984. // AddedEdges returns all edge names that were set/added in this mutation.
  9985. func (m *ChatRecordsMutation) AddedEdges() []string {
  9986. edges := make([]string, 0, 0)
  9987. return edges
  9988. }
  9989. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9990. // name in this mutation.
  9991. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  9992. return nil
  9993. }
  9994. // RemovedEdges returns all edge names that were removed in this mutation.
  9995. func (m *ChatRecordsMutation) RemovedEdges() []string {
  9996. edges := make([]string, 0, 0)
  9997. return edges
  9998. }
  9999. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10000. // the given name in this mutation.
  10001. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  10002. return nil
  10003. }
  10004. // ClearedEdges returns all edge names that were cleared in this mutation.
  10005. func (m *ChatRecordsMutation) ClearedEdges() []string {
  10006. edges := make([]string, 0, 0)
  10007. return edges
  10008. }
  10009. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10010. // was cleared in this mutation.
  10011. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  10012. return false
  10013. }
  10014. // ClearEdge clears the value of the edge with the given name. It returns an error
  10015. // if that edge is not defined in the schema.
  10016. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  10017. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  10018. }
  10019. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10020. // It returns an error if the edge is not defined in the schema.
  10021. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  10022. return fmt.Errorf("unknown ChatRecords edge %s", name)
  10023. }
  10024. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  10025. type ChatSessionMutation struct {
  10026. config
  10027. op Op
  10028. typ string
  10029. id *uint64
  10030. created_at *time.Time
  10031. updated_at *time.Time
  10032. deleted_at *time.Time
  10033. name *string
  10034. user_id *uint64
  10035. adduser_id *int64
  10036. bot_id *uint64
  10037. addbot_id *int64
  10038. bot_type *uint8
  10039. addbot_type *int8
  10040. clearedFields map[string]struct{}
  10041. done bool
  10042. oldValue func(context.Context) (*ChatSession, error)
  10043. predicates []predicate.ChatSession
  10044. }
  10045. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  10046. // chatsessionOption allows management of the mutation configuration using functional options.
  10047. type chatsessionOption func(*ChatSessionMutation)
  10048. // newChatSessionMutation creates new mutation for the ChatSession entity.
  10049. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  10050. m := &ChatSessionMutation{
  10051. config: c,
  10052. op: op,
  10053. typ: TypeChatSession,
  10054. clearedFields: make(map[string]struct{}),
  10055. }
  10056. for _, opt := range opts {
  10057. opt(m)
  10058. }
  10059. return m
  10060. }
  10061. // withChatSessionID sets the ID field of the mutation.
  10062. func withChatSessionID(id uint64) chatsessionOption {
  10063. return func(m *ChatSessionMutation) {
  10064. var (
  10065. err error
  10066. once sync.Once
  10067. value *ChatSession
  10068. )
  10069. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  10070. once.Do(func() {
  10071. if m.done {
  10072. err = errors.New("querying old values post mutation is not allowed")
  10073. } else {
  10074. value, err = m.Client().ChatSession.Get(ctx, id)
  10075. }
  10076. })
  10077. return value, err
  10078. }
  10079. m.id = &id
  10080. }
  10081. }
  10082. // withChatSession sets the old ChatSession of the mutation.
  10083. func withChatSession(node *ChatSession) chatsessionOption {
  10084. return func(m *ChatSessionMutation) {
  10085. m.oldValue = func(context.Context) (*ChatSession, error) {
  10086. return node, nil
  10087. }
  10088. m.id = &node.ID
  10089. }
  10090. }
  10091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10092. // executed in a transaction (ent.Tx), a transactional client is returned.
  10093. func (m ChatSessionMutation) Client() *Client {
  10094. client := &Client{config: m.config}
  10095. client.init()
  10096. return client
  10097. }
  10098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10099. // it returns an error otherwise.
  10100. func (m ChatSessionMutation) Tx() (*Tx, error) {
  10101. if _, ok := m.driver.(*txDriver); !ok {
  10102. return nil, errors.New("ent: mutation is not running in a transaction")
  10103. }
  10104. tx := &Tx{config: m.config}
  10105. tx.init()
  10106. return tx, nil
  10107. }
  10108. // SetID sets the value of the id field. Note that this
  10109. // operation is only accepted on creation of ChatSession entities.
  10110. func (m *ChatSessionMutation) SetID(id uint64) {
  10111. m.id = &id
  10112. }
  10113. // ID returns the ID value in the mutation. Note that the ID is only available
  10114. // if it was provided to the builder or after it was returned from the database.
  10115. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  10116. if m.id == nil {
  10117. return
  10118. }
  10119. return *m.id, true
  10120. }
  10121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10122. // That means, if the mutation is applied within a transaction with an isolation level such
  10123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10124. // or updated by the mutation.
  10125. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  10126. switch {
  10127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10128. id, exists := m.ID()
  10129. if exists {
  10130. return []uint64{id}, nil
  10131. }
  10132. fallthrough
  10133. case m.op.Is(OpUpdate | OpDelete):
  10134. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  10135. default:
  10136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10137. }
  10138. }
  10139. // SetCreatedAt sets the "created_at" field.
  10140. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  10141. m.created_at = &t
  10142. }
  10143. // CreatedAt returns the value of the "created_at" field in the mutation.
  10144. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  10145. v := m.created_at
  10146. if v == nil {
  10147. return
  10148. }
  10149. return *v, true
  10150. }
  10151. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  10152. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10154. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10155. if !m.op.Is(OpUpdateOne) {
  10156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10157. }
  10158. if m.id == nil || m.oldValue == nil {
  10159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10160. }
  10161. oldValue, err := m.oldValue(ctx)
  10162. if err != nil {
  10163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10164. }
  10165. return oldValue.CreatedAt, nil
  10166. }
  10167. // ResetCreatedAt resets all changes to the "created_at" field.
  10168. func (m *ChatSessionMutation) ResetCreatedAt() {
  10169. m.created_at = nil
  10170. }
  10171. // SetUpdatedAt sets the "updated_at" field.
  10172. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  10173. m.updated_at = &t
  10174. }
  10175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10176. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  10177. v := m.updated_at
  10178. if v == nil {
  10179. return
  10180. }
  10181. return *v, true
  10182. }
  10183. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  10184. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10186. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10187. if !m.op.Is(OpUpdateOne) {
  10188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10189. }
  10190. if m.id == nil || m.oldValue == nil {
  10191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10192. }
  10193. oldValue, err := m.oldValue(ctx)
  10194. if err != nil {
  10195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10196. }
  10197. return oldValue.UpdatedAt, nil
  10198. }
  10199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10200. func (m *ChatSessionMutation) ResetUpdatedAt() {
  10201. m.updated_at = nil
  10202. }
  10203. // SetDeletedAt sets the "deleted_at" field.
  10204. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  10205. m.deleted_at = &t
  10206. }
  10207. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10208. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  10209. v := m.deleted_at
  10210. if v == nil {
  10211. return
  10212. }
  10213. return *v, true
  10214. }
  10215. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  10216. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10218. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10219. if !m.op.Is(OpUpdateOne) {
  10220. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10221. }
  10222. if m.id == nil || m.oldValue == nil {
  10223. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10224. }
  10225. oldValue, err := m.oldValue(ctx)
  10226. if err != nil {
  10227. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10228. }
  10229. return oldValue.DeletedAt, nil
  10230. }
  10231. // ClearDeletedAt clears the value of the "deleted_at" field.
  10232. func (m *ChatSessionMutation) ClearDeletedAt() {
  10233. m.deleted_at = nil
  10234. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  10235. }
  10236. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10237. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  10238. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  10239. return ok
  10240. }
  10241. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10242. func (m *ChatSessionMutation) ResetDeletedAt() {
  10243. m.deleted_at = nil
  10244. delete(m.clearedFields, chatsession.FieldDeletedAt)
  10245. }
  10246. // SetName sets the "name" field.
  10247. func (m *ChatSessionMutation) SetName(s string) {
  10248. m.name = &s
  10249. }
  10250. // Name returns the value of the "name" field in the mutation.
  10251. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  10252. v := m.name
  10253. if v == nil {
  10254. return
  10255. }
  10256. return *v, true
  10257. }
  10258. // OldName returns the old "name" field's value of the ChatSession entity.
  10259. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10261. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  10262. if !m.op.Is(OpUpdateOne) {
  10263. return v, errors.New("OldName is only allowed on UpdateOne operations")
  10264. }
  10265. if m.id == nil || m.oldValue == nil {
  10266. return v, errors.New("OldName requires an ID field in the mutation")
  10267. }
  10268. oldValue, err := m.oldValue(ctx)
  10269. if err != nil {
  10270. return v, fmt.Errorf("querying old value for OldName: %w", err)
  10271. }
  10272. return oldValue.Name, nil
  10273. }
  10274. // ResetName resets all changes to the "name" field.
  10275. func (m *ChatSessionMutation) ResetName() {
  10276. m.name = nil
  10277. }
  10278. // SetUserID sets the "user_id" field.
  10279. func (m *ChatSessionMutation) SetUserID(u uint64) {
  10280. m.user_id = &u
  10281. m.adduser_id = nil
  10282. }
  10283. // UserID returns the value of the "user_id" field in the mutation.
  10284. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  10285. v := m.user_id
  10286. if v == nil {
  10287. return
  10288. }
  10289. return *v, true
  10290. }
  10291. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  10292. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10294. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  10295. if !m.op.Is(OpUpdateOne) {
  10296. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10297. }
  10298. if m.id == nil || m.oldValue == nil {
  10299. return v, errors.New("OldUserID requires an ID field in the mutation")
  10300. }
  10301. oldValue, err := m.oldValue(ctx)
  10302. if err != nil {
  10303. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10304. }
  10305. return oldValue.UserID, nil
  10306. }
  10307. // AddUserID adds u to the "user_id" field.
  10308. func (m *ChatSessionMutation) AddUserID(u int64) {
  10309. if m.adduser_id != nil {
  10310. *m.adduser_id += u
  10311. } else {
  10312. m.adduser_id = &u
  10313. }
  10314. }
  10315. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  10316. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  10317. v := m.adduser_id
  10318. if v == nil {
  10319. return
  10320. }
  10321. return *v, true
  10322. }
  10323. // ResetUserID resets all changes to the "user_id" field.
  10324. func (m *ChatSessionMutation) ResetUserID() {
  10325. m.user_id = nil
  10326. m.adduser_id = nil
  10327. }
  10328. // SetBotID sets the "bot_id" field.
  10329. func (m *ChatSessionMutation) SetBotID(u uint64) {
  10330. m.bot_id = &u
  10331. m.addbot_id = nil
  10332. }
  10333. // BotID returns the value of the "bot_id" field in the mutation.
  10334. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  10335. v := m.bot_id
  10336. if v == nil {
  10337. return
  10338. }
  10339. return *v, true
  10340. }
  10341. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  10342. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10344. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  10345. if !m.op.Is(OpUpdateOne) {
  10346. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  10347. }
  10348. if m.id == nil || m.oldValue == nil {
  10349. return v, errors.New("OldBotID requires an ID field in the mutation")
  10350. }
  10351. oldValue, err := m.oldValue(ctx)
  10352. if err != nil {
  10353. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  10354. }
  10355. return oldValue.BotID, nil
  10356. }
  10357. // AddBotID adds u to the "bot_id" field.
  10358. func (m *ChatSessionMutation) AddBotID(u int64) {
  10359. if m.addbot_id != nil {
  10360. *m.addbot_id += u
  10361. } else {
  10362. m.addbot_id = &u
  10363. }
  10364. }
  10365. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  10366. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  10367. v := m.addbot_id
  10368. if v == nil {
  10369. return
  10370. }
  10371. return *v, true
  10372. }
  10373. // ResetBotID resets all changes to the "bot_id" field.
  10374. func (m *ChatSessionMutation) ResetBotID() {
  10375. m.bot_id = nil
  10376. m.addbot_id = nil
  10377. }
  10378. // SetBotType sets the "bot_type" field.
  10379. func (m *ChatSessionMutation) SetBotType(u uint8) {
  10380. m.bot_type = &u
  10381. m.addbot_type = nil
  10382. }
  10383. // BotType returns the value of the "bot_type" field in the mutation.
  10384. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  10385. v := m.bot_type
  10386. if v == nil {
  10387. return
  10388. }
  10389. return *v, true
  10390. }
  10391. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  10392. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  10393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10394. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  10395. if !m.op.Is(OpUpdateOne) {
  10396. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  10397. }
  10398. if m.id == nil || m.oldValue == nil {
  10399. return v, errors.New("OldBotType requires an ID field in the mutation")
  10400. }
  10401. oldValue, err := m.oldValue(ctx)
  10402. if err != nil {
  10403. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  10404. }
  10405. return oldValue.BotType, nil
  10406. }
  10407. // AddBotType adds u to the "bot_type" field.
  10408. func (m *ChatSessionMutation) AddBotType(u int8) {
  10409. if m.addbot_type != nil {
  10410. *m.addbot_type += u
  10411. } else {
  10412. m.addbot_type = &u
  10413. }
  10414. }
  10415. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  10416. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  10417. v := m.addbot_type
  10418. if v == nil {
  10419. return
  10420. }
  10421. return *v, true
  10422. }
  10423. // ResetBotType resets all changes to the "bot_type" field.
  10424. func (m *ChatSessionMutation) ResetBotType() {
  10425. m.bot_type = nil
  10426. m.addbot_type = nil
  10427. }
  10428. // Where appends a list predicates to the ChatSessionMutation builder.
  10429. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  10430. m.predicates = append(m.predicates, ps...)
  10431. }
  10432. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  10433. // users can use type-assertion to append predicates that do not depend on any generated package.
  10434. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  10435. p := make([]predicate.ChatSession, len(ps))
  10436. for i := range ps {
  10437. p[i] = ps[i]
  10438. }
  10439. m.Where(p...)
  10440. }
  10441. // Op returns the operation name.
  10442. func (m *ChatSessionMutation) Op() Op {
  10443. return m.op
  10444. }
  10445. // SetOp allows setting the mutation operation.
  10446. func (m *ChatSessionMutation) SetOp(op Op) {
  10447. m.op = op
  10448. }
  10449. // Type returns the node type of this mutation (ChatSession).
  10450. func (m *ChatSessionMutation) Type() string {
  10451. return m.typ
  10452. }
  10453. // Fields returns all fields that were changed during this mutation. Note that in
  10454. // order to get all numeric fields that were incremented/decremented, call
  10455. // AddedFields().
  10456. func (m *ChatSessionMutation) Fields() []string {
  10457. fields := make([]string, 0, 7)
  10458. if m.created_at != nil {
  10459. fields = append(fields, chatsession.FieldCreatedAt)
  10460. }
  10461. if m.updated_at != nil {
  10462. fields = append(fields, chatsession.FieldUpdatedAt)
  10463. }
  10464. if m.deleted_at != nil {
  10465. fields = append(fields, chatsession.FieldDeletedAt)
  10466. }
  10467. if m.name != nil {
  10468. fields = append(fields, chatsession.FieldName)
  10469. }
  10470. if m.user_id != nil {
  10471. fields = append(fields, chatsession.FieldUserID)
  10472. }
  10473. if m.bot_id != nil {
  10474. fields = append(fields, chatsession.FieldBotID)
  10475. }
  10476. if m.bot_type != nil {
  10477. fields = append(fields, chatsession.FieldBotType)
  10478. }
  10479. return fields
  10480. }
  10481. // Field returns the value of a field with the given name. The second boolean
  10482. // return value indicates that this field was not set, or was not defined in the
  10483. // schema.
  10484. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  10485. switch name {
  10486. case chatsession.FieldCreatedAt:
  10487. return m.CreatedAt()
  10488. case chatsession.FieldUpdatedAt:
  10489. return m.UpdatedAt()
  10490. case chatsession.FieldDeletedAt:
  10491. return m.DeletedAt()
  10492. case chatsession.FieldName:
  10493. return m.Name()
  10494. case chatsession.FieldUserID:
  10495. return m.UserID()
  10496. case chatsession.FieldBotID:
  10497. return m.BotID()
  10498. case chatsession.FieldBotType:
  10499. return m.BotType()
  10500. }
  10501. return nil, false
  10502. }
  10503. // OldField returns the old value of the field from the database. An error is
  10504. // returned if the mutation operation is not UpdateOne, or the query to the
  10505. // database failed.
  10506. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10507. switch name {
  10508. case chatsession.FieldCreatedAt:
  10509. return m.OldCreatedAt(ctx)
  10510. case chatsession.FieldUpdatedAt:
  10511. return m.OldUpdatedAt(ctx)
  10512. case chatsession.FieldDeletedAt:
  10513. return m.OldDeletedAt(ctx)
  10514. case chatsession.FieldName:
  10515. return m.OldName(ctx)
  10516. case chatsession.FieldUserID:
  10517. return m.OldUserID(ctx)
  10518. case chatsession.FieldBotID:
  10519. return m.OldBotID(ctx)
  10520. case chatsession.FieldBotType:
  10521. return m.OldBotType(ctx)
  10522. }
  10523. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  10524. }
  10525. // SetField sets the value of a field with the given name. It returns an error if
  10526. // the field is not defined in the schema, or if the type mismatched the field
  10527. // type.
  10528. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  10529. switch name {
  10530. case chatsession.FieldCreatedAt:
  10531. v, ok := value.(time.Time)
  10532. if !ok {
  10533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10534. }
  10535. m.SetCreatedAt(v)
  10536. return nil
  10537. case chatsession.FieldUpdatedAt:
  10538. v, ok := value.(time.Time)
  10539. if !ok {
  10540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10541. }
  10542. m.SetUpdatedAt(v)
  10543. return nil
  10544. case chatsession.FieldDeletedAt:
  10545. v, ok := value.(time.Time)
  10546. if !ok {
  10547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10548. }
  10549. m.SetDeletedAt(v)
  10550. return nil
  10551. case chatsession.FieldName:
  10552. v, ok := value.(string)
  10553. if !ok {
  10554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10555. }
  10556. m.SetName(v)
  10557. return nil
  10558. case chatsession.FieldUserID:
  10559. v, ok := value.(uint64)
  10560. if !ok {
  10561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10562. }
  10563. m.SetUserID(v)
  10564. return nil
  10565. case chatsession.FieldBotID:
  10566. v, ok := value.(uint64)
  10567. if !ok {
  10568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10569. }
  10570. m.SetBotID(v)
  10571. return nil
  10572. case chatsession.FieldBotType:
  10573. v, ok := value.(uint8)
  10574. if !ok {
  10575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10576. }
  10577. m.SetBotType(v)
  10578. return nil
  10579. }
  10580. return fmt.Errorf("unknown ChatSession field %s", name)
  10581. }
  10582. // AddedFields returns all numeric fields that were incremented/decremented during
  10583. // this mutation.
  10584. func (m *ChatSessionMutation) AddedFields() []string {
  10585. var fields []string
  10586. if m.adduser_id != nil {
  10587. fields = append(fields, chatsession.FieldUserID)
  10588. }
  10589. if m.addbot_id != nil {
  10590. fields = append(fields, chatsession.FieldBotID)
  10591. }
  10592. if m.addbot_type != nil {
  10593. fields = append(fields, chatsession.FieldBotType)
  10594. }
  10595. return fields
  10596. }
  10597. // AddedField returns the numeric value that was incremented/decremented on a field
  10598. // with the given name. The second boolean return value indicates that this field
  10599. // was not set, or was not defined in the schema.
  10600. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  10601. switch name {
  10602. case chatsession.FieldUserID:
  10603. return m.AddedUserID()
  10604. case chatsession.FieldBotID:
  10605. return m.AddedBotID()
  10606. case chatsession.FieldBotType:
  10607. return m.AddedBotType()
  10608. }
  10609. return nil, false
  10610. }
  10611. // AddField adds the value to the field with the given name. It returns an error if
  10612. // the field is not defined in the schema, or if the type mismatched the field
  10613. // type.
  10614. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  10615. switch name {
  10616. case chatsession.FieldUserID:
  10617. v, ok := value.(int64)
  10618. if !ok {
  10619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10620. }
  10621. m.AddUserID(v)
  10622. return nil
  10623. case chatsession.FieldBotID:
  10624. v, ok := value.(int64)
  10625. if !ok {
  10626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10627. }
  10628. m.AddBotID(v)
  10629. return nil
  10630. case chatsession.FieldBotType:
  10631. v, ok := value.(int8)
  10632. if !ok {
  10633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10634. }
  10635. m.AddBotType(v)
  10636. return nil
  10637. }
  10638. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  10639. }
  10640. // ClearedFields returns all nullable fields that were cleared during this
  10641. // mutation.
  10642. func (m *ChatSessionMutation) ClearedFields() []string {
  10643. var fields []string
  10644. if m.FieldCleared(chatsession.FieldDeletedAt) {
  10645. fields = append(fields, chatsession.FieldDeletedAt)
  10646. }
  10647. return fields
  10648. }
  10649. // FieldCleared returns a boolean indicating if a field with the given name was
  10650. // cleared in this mutation.
  10651. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  10652. _, ok := m.clearedFields[name]
  10653. return ok
  10654. }
  10655. // ClearField clears the value of the field with the given name. It returns an
  10656. // error if the field is not defined in the schema.
  10657. func (m *ChatSessionMutation) ClearField(name string) error {
  10658. switch name {
  10659. case chatsession.FieldDeletedAt:
  10660. m.ClearDeletedAt()
  10661. return nil
  10662. }
  10663. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  10664. }
  10665. // ResetField resets all changes in the mutation for the field with the given name.
  10666. // It returns an error if the field is not defined in the schema.
  10667. func (m *ChatSessionMutation) ResetField(name string) error {
  10668. switch name {
  10669. case chatsession.FieldCreatedAt:
  10670. m.ResetCreatedAt()
  10671. return nil
  10672. case chatsession.FieldUpdatedAt:
  10673. m.ResetUpdatedAt()
  10674. return nil
  10675. case chatsession.FieldDeletedAt:
  10676. m.ResetDeletedAt()
  10677. return nil
  10678. case chatsession.FieldName:
  10679. m.ResetName()
  10680. return nil
  10681. case chatsession.FieldUserID:
  10682. m.ResetUserID()
  10683. return nil
  10684. case chatsession.FieldBotID:
  10685. m.ResetBotID()
  10686. return nil
  10687. case chatsession.FieldBotType:
  10688. m.ResetBotType()
  10689. return nil
  10690. }
  10691. return fmt.Errorf("unknown ChatSession field %s", name)
  10692. }
  10693. // AddedEdges returns all edge names that were set/added in this mutation.
  10694. func (m *ChatSessionMutation) AddedEdges() []string {
  10695. edges := make([]string, 0, 0)
  10696. return edges
  10697. }
  10698. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10699. // name in this mutation.
  10700. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  10701. return nil
  10702. }
  10703. // RemovedEdges returns all edge names that were removed in this mutation.
  10704. func (m *ChatSessionMutation) RemovedEdges() []string {
  10705. edges := make([]string, 0, 0)
  10706. return edges
  10707. }
  10708. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10709. // the given name in this mutation.
  10710. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  10711. return nil
  10712. }
  10713. // ClearedEdges returns all edge names that were cleared in this mutation.
  10714. func (m *ChatSessionMutation) ClearedEdges() []string {
  10715. edges := make([]string, 0, 0)
  10716. return edges
  10717. }
  10718. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10719. // was cleared in this mutation.
  10720. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  10721. return false
  10722. }
  10723. // ClearEdge clears the value of the edge with the given name. It returns an error
  10724. // if that edge is not defined in the schema.
  10725. func (m *ChatSessionMutation) ClearEdge(name string) error {
  10726. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  10727. }
  10728. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10729. // It returns an error if the edge is not defined in the schema.
  10730. func (m *ChatSessionMutation) ResetEdge(name string) error {
  10731. return fmt.Errorf("unknown ChatSession edge %s", name)
  10732. }
  10733. // CompapiAsynctaskMutation represents an operation that mutates the CompapiAsynctask nodes in the graph.
  10734. type CompapiAsynctaskMutation struct {
  10735. config
  10736. op Op
  10737. typ string
  10738. id *uint64
  10739. created_at *time.Time
  10740. updated_at *time.Time
  10741. auth_token *string
  10742. event_type *string
  10743. chat_id *string
  10744. response_chat_item_id *string
  10745. organization_id *uint64
  10746. addorganization_id *int64
  10747. openai_base *string
  10748. openai_key *string
  10749. request_raw *string
  10750. response_raw *string
  10751. callback_url *string
  10752. callback_response_raw *string
  10753. model *string
  10754. task_status *int8
  10755. addtask_status *int8
  10756. retry_count *int8
  10757. addretry_count *int8
  10758. last_error *string
  10759. clearedFields map[string]struct{}
  10760. done bool
  10761. oldValue func(context.Context) (*CompapiAsynctask, error)
  10762. predicates []predicate.CompapiAsynctask
  10763. }
  10764. var _ ent.Mutation = (*CompapiAsynctaskMutation)(nil)
  10765. // compapiasynctaskOption allows management of the mutation configuration using functional options.
  10766. type compapiasynctaskOption func(*CompapiAsynctaskMutation)
  10767. // newCompapiAsynctaskMutation creates new mutation for the CompapiAsynctask entity.
  10768. func newCompapiAsynctaskMutation(c config, op Op, opts ...compapiasynctaskOption) *CompapiAsynctaskMutation {
  10769. m := &CompapiAsynctaskMutation{
  10770. config: c,
  10771. op: op,
  10772. typ: TypeCompapiAsynctask,
  10773. clearedFields: make(map[string]struct{}),
  10774. }
  10775. for _, opt := range opts {
  10776. opt(m)
  10777. }
  10778. return m
  10779. }
  10780. // withCompapiAsynctaskID sets the ID field of the mutation.
  10781. func withCompapiAsynctaskID(id uint64) compapiasynctaskOption {
  10782. return func(m *CompapiAsynctaskMutation) {
  10783. var (
  10784. err error
  10785. once sync.Once
  10786. value *CompapiAsynctask
  10787. )
  10788. m.oldValue = func(ctx context.Context) (*CompapiAsynctask, error) {
  10789. once.Do(func() {
  10790. if m.done {
  10791. err = errors.New("querying old values post mutation is not allowed")
  10792. } else {
  10793. value, err = m.Client().CompapiAsynctask.Get(ctx, id)
  10794. }
  10795. })
  10796. return value, err
  10797. }
  10798. m.id = &id
  10799. }
  10800. }
  10801. // withCompapiAsynctask sets the old CompapiAsynctask of the mutation.
  10802. func withCompapiAsynctask(node *CompapiAsynctask) compapiasynctaskOption {
  10803. return func(m *CompapiAsynctaskMutation) {
  10804. m.oldValue = func(context.Context) (*CompapiAsynctask, error) {
  10805. return node, nil
  10806. }
  10807. m.id = &node.ID
  10808. }
  10809. }
  10810. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10811. // executed in a transaction (ent.Tx), a transactional client is returned.
  10812. func (m CompapiAsynctaskMutation) Client() *Client {
  10813. client := &Client{config: m.config}
  10814. client.init()
  10815. return client
  10816. }
  10817. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10818. // it returns an error otherwise.
  10819. func (m CompapiAsynctaskMutation) Tx() (*Tx, error) {
  10820. if _, ok := m.driver.(*txDriver); !ok {
  10821. return nil, errors.New("ent: mutation is not running in a transaction")
  10822. }
  10823. tx := &Tx{config: m.config}
  10824. tx.init()
  10825. return tx, nil
  10826. }
  10827. // SetID sets the value of the id field. Note that this
  10828. // operation is only accepted on creation of CompapiAsynctask entities.
  10829. func (m *CompapiAsynctaskMutation) SetID(id uint64) {
  10830. m.id = &id
  10831. }
  10832. // ID returns the ID value in the mutation. Note that the ID is only available
  10833. // if it was provided to the builder or after it was returned from the database.
  10834. func (m *CompapiAsynctaskMutation) ID() (id uint64, exists bool) {
  10835. if m.id == nil {
  10836. return
  10837. }
  10838. return *m.id, true
  10839. }
  10840. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10841. // That means, if the mutation is applied within a transaction with an isolation level such
  10842. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10843. // or updated by the mutation.
  10844. func (m *CompapiAsynctaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  10845. switch {
  10846. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10847. id, exists := m.ID()
  10848. if exists {
  10849. return []uint64{id}, nil
  10850. }
  10851. fallthrough
  10852. case m.op.Is(OpUpdate | OpDelete):
  10853. return m.Client().CompapiAsynctask.Query().Where(m.predicates...).IDs(ctx)
  10854. default:
  10855. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10856. }
  10857. }
  10858. // SetCreatedAt sets the "created_at" field.
  10859. func (m *CompapiAsynctaskMutation) SetCreatedAt(t time.Time) {
  10860. m.created_at = &t
  10861. }
  10862. // CreatedAt returns the value of the "created_at" field in the mutation.
  10863. func (m *CompapiAsynctaskMutation) CreatedAt() (r time.Time, exists bool) {
  10864. v := m.created_at
  10865. if v == nil {
  10866. return
  10867. }
  10868. return *v, true
  10869. }
  10870. // OldCreatedAt returns the old "created_at" field's value of the CompapiAsynctask entity.
  10871. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10873. func (m *CompapiAsynctaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10874. if !m.op.Is(OpUpdateOne) {
  10875. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10876. }
  10877. if m.id == nil || m.oldValue == nil {
  10878. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10879. }
  10880. oldValue, err := m.oldValue(ctx)
  10881. if err != nil {
  10882. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10883. }
  10884. return oldValue.CreatedAt, nil
  10885. }
  10886. // ResetCreatedAt resets all changes to the "created_at" field.
  10887. func (m *CompapiAsynctaskMutation) ResetCreatedAt() {
  10888. m.created_at = nil
  10889. }
  10890. // SetUpdatedAt sets the "updated_at" field.
  10891. func (m *CompapiAsynctaskMutation) SetUpdatedAt(t time.Time) {
  10892. m.updated_at = &t
  10893. }
  10894. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10895. func (m *CompapiAsynctaskMutation) UpdatedAt() (r time.Time, exists bool) {
  10896. v := m.updated_at
  10897. if v == nil {
  10898. return
  10899. }
  10900. return *v, true
  10901. }
  10902. // OldUpdatedAt returns the old "updated_at" field's value of the CompapiAsynctask entity.
  10903. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10905. func (m *CompapiAsynctaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10906. if !m.op.Is(OpUpdateOne) {
  10907. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10908. }
  10909. if m.id == nil || m.oldValue == nil {
  10910. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10911. }
  10912. oldValue, err := m.oldValue(ctx)
  10913. if err != nil {
  10914. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10915. }
  10916. return oldValue.UpdatedAt, nil
  10917. }
  10918. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10919. func (m *CompapiAsynctaskMutation) ResetUpdatedAt() {
  10920. m.updated_at = nil
  10921. }
  10922. // SetAuthToken sets the "auth_token" field.
  10923. func (m *CompapiAsynctaskMutation) SetAuthToken(s string) {
  10924. m.auth_token = &s
  10925. }
  10926. // AuthToken returns the value of the "auth_token" field in the mutation.
  10927. func (m *CompapiAsynctaskMutation) AuthToken() (r string, exists bool) {
  10928. v := m.auth_token
  10929. if v == nil {
  10930. return
  10931. }
  10932. return *v, true
  10933. }
  10934. // OldAuthToken returns the old "auth_token" field's value of the CompapiAsynctask entity.
  10935. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10937. func (m *CompapiAsynctaskMutation) OldAuthToken(ctx context.Context) (v string, err error) {
  10938. if !m.op.Is(OpUpdateOne) {
  10939. return v, errors.New("OldAuthToken is only allowed on UpdateOne operations")
  10940. }
  10941. if m.id == nil || m.oldValue == nil {
  10942. return v, errors.New("OldAuthToken requires an ID field in the mutation")
  10943. }
  10944. oldValue, err := m.oldValue(ctx)
  10945. if err != nil {
  10946. return v, fmt.Errorf("querying old value for OldAuthToken: %w", err)
  10947. }
  10948. return oldValue.AuthToken, nil
  10949. }
  10950. // ResetAuthToken resets all changes to the "auth_token" field.
  10951. func (m *CompapiAsynctaskMutation) ResetAuthToken() {
  10952. m.auth_token = nil
  10953. }
  10954. // SetEventType sets the "event_type" field.
  10955. func (m *CompapiAsynctaskMutation) SetEventType(s string) {
  10956. m.event_type = &s
  10957. }
  10958. // EventType returns the value of the "event_type" field in the mutation.
  10959. func (m *CompapiAsynctaskMutation) EventType() (r string, exists bool) {
  10960. v := m.event_type
  10961. if v == nil {
  10962. return
  10963. }
  10964. return *v, true
  10965. }
  10966. // OldEventType returns the old "event_type" field's value of the CompapiAsynctask entity.
  10967. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  10968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10969. func (m *CompapiAsynctaskMutation) OldEventType(ctx context.Context) (v string, err error) {
  10970. if !m.op.Is(OpUpdateOne) {
  10971. return v, errors.New("OldEventType is only allowed on UpdateOne operations")
  10972. }
  10973. if m.id == nil || m.oldValue == nil {
  10974. return v, errors.New("OldEventType requires an ID field in the mutation")
  10975. }
  10976. oldValue, err := m.oldValue(ctx)
  10977. if err != nil {
  10978. return v, fmt.Errorf("querying old value for OldEventType: %w", err)
  10979. }
  10980. return oldValue.EventType, nil
  10981. }
  10982. // ResetEventType resets all changes to the "event_type" field.
  10983. func (m *CompapiAsynctaskMutation) ResetEventType() {
  10984. m.event_type = nil
  10985. }
  10986. // SetChatID sets the "chat_id" field.
  10987. func (m *CompapiAsynctaskMutation) SetChatID(s string) {
  10988. m.chat_id = &s
  10989. }
  10990. // ChatID returns the value of the "chat_id" field in the mutation.
  10991. func (m *CompapiAsynctaskMutation) ChatID() (r string, exists bool) {
  10992. v := m.chat_id
  10993. if v == nil {
  10994. return
  10995. }
  10996. return *v, true
  10997. }
  10998. // OldChatID returns the old "chat_id" field's value of the CompapiAsynctask entity.
  10999. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11001. func (m *CompapiAsynctaskMutation) OldChatID(ctx context.Context) (v string, err error) {
  11002. if !m.op.Is(OpUpdateOne) {
  11003. return v, errors.New("OldChatID is only allowed on UpdateOne operations")
  11004. }
  11005. if m.id == nil || m.oldValue == nil {
  11006. return v, errors.New("OldChatID requires an ID field in the mutation")
  11007. }
  11008. oldValue, err := m.oldValue(ctx)
  11009. if err != nil {
  11010. return v, fmt.Errorf("querying old value for OldChatID: %w", err)
  11011. }
  11012. return oldValue.ChatID, nil
  11013. }
  11014. // ClearChatID clears the value of the "chat_id" field.
  11015. func (m *CompapiAsynctaskMutation) ClearChatID() {
  11016. m.chat_id = nil
  11017. m.clearedFields[compapiasynctask.FieldChatID] = struct{}{}
  11018. }
  11019. // ChatIDCleared returns if the "chat_id" field was cleared in this mutation.
  11020. func (m *CompapiAsynctaskMutation) ChatIDCleared() bool {
  11021. _, ok := m.clearedFields[compapiasynctask.FieldChatID]
  11022. return ok
  11023. }
  11024. // ResetChatID resets all changes to the "chat_id" field.
  11025. func (m *CompapiAsynctaskMutation) ResetChatID() {
  11026. m.chat_id = nil
  11027. delete(m.clearedFields, compapiasynctask.FieldChatID)
  11028. }
  11029. // SetResponseChatItemID sets the "response_chat_item_id" field.
  11030. func (m *CompapiAsynctaskMutation) SetResponseChatItemID(s string) {
  11031. m.response_chat_item_id = &s
  11032. }
  11033. // ResponseChatItemID returns the value of the "response_chat_item_id" field in the mutation.
  11034. func (m *CompapiAsynctaskMutation) ResponseChatItemID() (r string, exists bool) {
  11035. v := m.response_chat_item_id
  11036. if v == nil {
  11037. return
  11038. }
  11039. return *v, true
  11040. }
  11041. // OldResponseChatItemID returns the old "response_chat_item_id" field's value of the CompapiAsynctask entity.
  11042. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11044. func (m *CompapiAsynctaskMutation) OldResponseChatItemID(ctx context.Context) (v string, err error) {
  11045. if !m.op.Is(OpUpdateOne) {
  11046. return v, errors.New("OldResponseChatItemID is only allowed on UpdateOne operations")
  11047. }
  11048. if m.id == nil || m.oldValue == nil {
  11049. return v, errors.New("OldResponseChatItemID requires an ID field in the mutation")
  11050. }
  11051. oldValue, err := m.oldValue(ctx)
  11052. if err != nil {
  11053. return v, fmt.Errorf("querying old value for OldResponseChatItemID: %w", err)
  11054. }
  11055. return oldValue.ResponseChatItemID, nil
  11056. }
  11057. // ClearResponseChatItemID clears the value of the "response_chat_item_id" field.
  11058. func (m *CompapiAsynctaskMutation) ClearResponseChatItemID() {
  11059. m.response_chat_item_id = nil
  11060. m.clearedFields[compapiasynctask.FieldResponseChatItemID] = struct{}{}
  11061. }
  11062. // ResponseChatItemIDCleared returns if the "response_chat_item_id" field was cleared in this mutation.
  11063. func (m *CompapiAsynctaskMutation) ResponseChatItemIDCleared() bool {
  11064. _, ok := m.clearedFields[compapiasynctask.FieldResponseChatItemID]
  11065. return ok
  11066. }
  11067. // ResetResponseChatItemID resets all changes to the "response_chat_item_id" field.
  11068. func (m *CompapiAsynctaskMutation) ResetResponseChatItemID() {
  11069. m.response_chat_item_id = nil
  11070. delete(m.clearedFields, compapiasynctask.FieldResponseChatItemID)
  11071. }
  11072. // SetOrganizationID sets the "organization_id" field.
  11073. func (m *CompapiAsynctaskMutation) SetOrganizationID(u uint64) {
  11074. m.organization_id = &u
  11075. m.addorganization_id = nil
  11076. }
  11077. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11078. func (m *CompapiAsynctaskMutation) OrganizationID() (r uint64, exists bool) {
  11079. v := m.organization_id
  11080. if v == nil {
  11081. return
  11082. }
  11083. return *v, true
  11084. }
  11085. // OldOrganizationID returns the old "organization_id" field's value of the CompapiAsynctask entity.
  11086. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11088. func (m *CompapiAsynctaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11089. if !m.op.Is(OpUpdateOne) {
  11090. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11091. }
  11092. if m.id == nil || m.oldValue == nil {
  11093. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11094. }
  11095. oldValue, err := m.oldValue(ctx)
  11096. if err != nil {
  11097. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11098. }
  11099. return oldValue.OrganizationID, nil
  11100. }
  11101. // AddOrganizationID adds u to the "organization_id" field.
  11102. func (m *CompapiAsynctaskMutation) AddOrganizationID(u int64) {
  11103. if m.addorganization_id != nil {
  11104. *m.addorganization_id += u
  11105. } else {
  11106. m.addorganization_id = &u
  11107. }
  11108. }
  11109. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11110. func (m *CompapiAsynctaskMutation) AddedOrganizationID() (r int64, exists bool) {
  11111. v := m.addorganization_id
  11112. if v == nil {
  11113. return
  11114. }
  11115. return *v, true
  11116. }
  11117. // ResetOrganizationID resets all changes to the "organization_id" field.
  11118. func (m *CompapiAsynctaskMutation) ResetOrganizationID() {
  11119. m.organization_id = nil
  11120. m.addorganization_id = nil
  11121. }
  11122. // SetOpenaiBase sets the "openai_base" field.
  11123. func (m *CompapiAsynctaskMutation) SetOpenaiBase(s string) {
  11124. m.openai_base = &s
  11125. }
  11126. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  11127. func (m *CompapiAsynctaskMutation) OpenaiBase() (r string, exists bool) {
  11128. v := m.openai_base
  11129. if v == nil {
  11130. return
  11131. }
  11132. return *v, true
  11133. }
  11134. // OldOpenaiBase returns the old "openai_base" field's value of the CompapiAsynctask entity.
  11135. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11137. func (m *CompapiAsynctaskMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  11138. if !m.op.Is(OpUpdateOne) {
  11139. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  11140. }
  11141. if m.id == nil || m.oldValue == nil {
  11142. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  11143. }
  11144. oldValue, err := m.oldValue(ctx)
  11145. if err != nil {
  11146. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  11147. }
  11148. return oldValue.OpenaiBase, nil
  11149. }
  11150. // ResetOpenaiBase resets all changes to the "openai_base" field.
  11151. func (m *CompapiAsynctaskMutation) ResetOpenaiBase() {
  11152. m.openai_base = nil
  11153. }
  11154. // SetOpenaiKey sets the "openai_key" field.
  11155. func (m *CompapiAsynctaskMutation) SetOpenaiKey(s string) {
  11156. m.openai_key = &s
  11157. }
  11158. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  11159. func (m *CompapiAsynctaskMutation) OpenaiKey() (r string, exists bool) {
  11160. v := m.openai_key
  11161. if v == nil {
  11162. return
  11163. }
  11164. return *v, true
  11165. }
  11166. // OldOpenaiKey returns the old "openai_key" field's value of the CompapiAsynctask entity.
  11167. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11169. func (m *CompapiAsynctaskMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  11170. if !m.op.Is(OpUpdateOne) {
  11171. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  11172. }
  11173. if m.id == nil || m.oldValue == nil {
  11174. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  11175. }
  11176. oldValue, err := m.oldValue(ctx)
  11177. if err != nil {
  11178. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  11179. }
  11180. return oldValue.OpenaiKey, nil
  11181. }
  11182. // ResetOpenaiKey resets all changes to the "openai_key" field.
  11183. func (m *CompapiAsynctaskMutation) ResetOpenaiKey() {
  11184. m.openai_key = nil
  11185. }
  11186. // SetRequestRaw sets the "request_raw" field.
  11187. func (m *CompapiAsynctaskMutation) SetRequestRaw(s string) {
  11188. m.request_raw = &s
  11189. }
  11190. // RequestRaw returns the value of the "request_raw" field in the mutation.
  11191. func (m *CompapiAsynctaskMutation) RequestRaw() (r string, exists bool) {
  11192. v := m.request_raw
  11193. if v == nil {
  11194. return
  11195. }
  11196. return *v, true
  11197. }
  11198. // OldRequestRaw returns the old "request_raw" field's value of the CompapiAsynctask entity.
  11199. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11201. func (m *CompapiAsynctaskMutation) OldRequestRaw(ctx context.Context) (v string, err error) {
  11202. if !m.op.Is(OpUpdateOne) {
  11203. return v, errors.New("OldRequestRaw is only allowed on UpdateOne operations")
  11204. }
  11205. if m.id == nil || m.oldValue == nil {
  11206. return v, errors.New("OldRequestRaw requires an ID field in the mutation")
  11207. }
  11208. oldValue, err := m.oldValue(ctx)
  11209. if err != nil {
  11210. return v, fmt.Errorf("querying old value for OldRequestRaw: %w", err)
  11211. }
  11212. return oldValue.RequestRaw, nil
  11213. }
  11214. // ResetRequestRaw resets all changes to the "request_raw" field.
  11215. func (m *CompapiAsynctaskMutation) ResetRequestRaw() {
  11216. m.request_raw = nil
  11217. }
  11218. // SetResponseRaw sets the "response_raw" field.
  11219. func (m *CompapiAsynctaskMutation) SetResponseRaw(s string) {
  11220. m.response_raw = &s
  11221. }
  11222. // ResponseRaw returns the value of the "response_raw" field in the mutation.
  11223. func (m *CompapiAsynctaskMutation) ResponseRaw() (r string, exists bool) {
  11224. v := m.response_raw
  11225. if v == nil {
  11226. return
  11227. }
  11228. return *v, true
  11229. }
  11230. // OldResponseRaw returns the old "response_raw" field's value of the CompapiAsynctask entity.
  11231. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11233. func (m *CompapiAsynctaskMutation) OldResponseRaw(ctx context.Context) (v string, err error) {
  11234. if !m.op.Is(OpUpdateOne) {
  11235. return v, errors.New("OldResponseRaw is only allowed on UpdateOne operations")
  11236. }
  11237. if m.id == nil || m.oldValue == nil {
  11238. return v, errors.New("OldResponseRaw requires an ID field in the mutation")
  11239. }
  11240. oldValue, err := m.oldValue(ctx)
  11241. if err != nil {
  11242. return v, fmt.Errorf("querying old value for OldResponseRaw: %w", err)
  11243. }
  11244. return oldValue.ResponseRaw, nil
  11245. }
  11246. // ClearResponseRaw clears the value of the "response_raw" field.
  11247. func (m *CompapiAsynctaskMutation) ClearResponseRaw() {
  11248. m.response_raw = nil
  11249. m.clearedFields[compapiasynctask.FieldResponseRaw] = struct{}{}
  11250. }
  11251. // ResponseRawCleared returns if the "response_raw" field was cleared in this mutation.
  11252. func (m *CompapiAsynctaskMutation) ResponseRawCleared() bool {
  11253. _, ok := m.clearedFields[compapiasynctask.FieldResponseRaw]
  11254. return ok
  11255. }
  11256. // ResetResponseRaw resets all changes to the "response_raw" field.
  11257. func (m *CompapiAsynctaskMutation) ResetResponseRaw() {
  11258. m.response_raw = nil
  11259. delete(m.clearedFields, compapiasynctask.FieldResponseRaw)
  11260. }
  11261. // SetCallbackURL sets the "callback_url" field.
  11262. func (m *CompapiAsynctaskMutation) SetCallbackURL(s string) {
  11263. m.callback_url = &s
  11264. }
  11265. // CallbackURL returns the value of the "callback_url" field in the mutation.
  11266. func (m *CompapiAsynctaskMutation) CallbackURL() (r string, exists bool) {
  11267. v := m.callback_url
  11268. if v == nil {
  11269. return
  11270. }
  11271. return *v, true
  11272. }
  11273. // OldCallbackURL returns the old "callback_url" field's value of the CompapiAsynctask entity.
  11274. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11276. func (m *CompapiAsynctaskMutation) OldCallbackURL(ctx context.Context) (v string, err error) {
  11277. if !m.op.Is(OpUpdateOne) {
  11278. return v, errors.New("OldCallbackURL is only allowed on UpdateOne operations")
  11279. }
  11280. if m.id == nil || m.oldValue == nil {
  11281. return v, errors.New("OldCallbackURL requires an ID field in the mutation")
  11282. }
  11283. oldValue, err := m.oldValue(ctx)
  11284. if err != nil {
  11285. return v, fmt.Errorf("querying old value for OldCallbackURL: %w", err)
  11286. }
  11287. return oldValue.CallbackURL, nil
  11288. }
  11289. // ResetCallbackURL resets all changes to the "callback_url" field.
  11290. func (m *CompapiAsynctaskMutation) ResetCallbackURL() {
  11291. m.callback_url = nil
  11292. }
  11293. // SetCallbackResponseRaw sets the "callback_response_raw" field.
  11294. func (m *CompapiAsynctaskMutation) SetCallbackResponseRaw(s string) {
  11295. m.callback_response_raw = &s
  11296. }
  11297. // CallbackResponseRaw returns the value of the "callback_response_raw" field in the mutation.
  11298. func (m *CompapiAsynctaskMutation) CallbackResponseRaw() (r string, exists bool) {
  11299. v := m.callback_response_raw
  11300. if v == nil {
  11301. return
  11302. }
  11303. return *v, true
  11304. }
  11305. // OldCallbackResponseRaw returns the old "callback_response_raw" field's value of the CompapiAsynctask entity.
  11306. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11308. func (m *CompapiAsynctaskMutation) OldCallbackResponseRaw(ctx context.Context) (v string, err error) {
  11309. if !m.op.Is(OpUpdateOne) {
  11310. return v, errors.New("OldCallbackResponseRaw is only allowed on UpdateOne operations")
  11311. }
  11312. if m.id == nil || m.oldValue == nil {
  11313. return v, errors.New("OldCallbackResponseRaw requires an ID field in the mutation")
  11314. }
  11315. oldValue, err := m.oldValue(ctx)
  11316. if err != nil {
  11317. return v, fmt.Errorf("querying old value for OldCallbackResponseRaw: %w", err)
  11318. }
  11319. return oldValue.CallbackResponseRaw, nil
  11320. }
  11321. // ClearCallbackResponseRaw clears the value of the "callback_response_raw" field.
  11322. func (m *CompapiAsynctaskMutation) ClearCallbackResponseRaw() {
  11323. m.callback_response_raw = nil
  11324. m.clearedFields[compapiasynctask.FieldCallbackResponseRaw] = struct{}{}
  11325. }
  11326. // CallbackResponseRawCleared returns if the "callback_response_raw" field was cleared in this mutation.
  11327. func (m *CompapiAsynctaskMutation) CallbackResponseRawCleared() bool {
  11328. _, ok := m.clearedFields[compapiasynctask.FieldCallbackResponseRaw]
  11329. return ok
  11330. }
  11331. // ResetCallbackResponseRaw resets all changes to the "callback_response_raw" field.
  11332. func (m *CompapiAsynctaskMutation) ResetCallbackResponseRaw() {
  11333. m.callback_response_raw = nil
  11334. delete(m.clearedFields, compapiasynctask.FieldCallbackResponseRaw)
  11335. }
  11336. // SetModel sets the "model" field.
  11337. func (m *CompapiAsynctaskMutation) SetModel(s string) {
  11338. m.model = &s
  11339. }
  11340. // Model returns the value of the "model" field in the mutation.
  11341. func (m *CompapiAsynctaskMutation) Model() (r string, exists bool) {
  11342. v := m.model
  11343. if v == nil {
  11344. return
  11345. }
  11346. return *v, true
  11347. }
  11348. // OldModel returns the old "model" field's value of the CompapiAsynctask entity.
  11349. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11350. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11351. func (m *CompapiAsynctaskMutation) OldModel(ctx context.Context) (v string, err error) {
  11352. if !m.op.Is(OpUpdateOne) {
  11353. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  11354. }
  11355. if m.id == nil || m.oldValue == nil {
  11356. return v, errors.New("OldModel requires an ID field in the mutation")
  11357. }
  11358. oldValue, err := m.oldValue(ctx)
  11359. if err != nil {
  11360. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  11361. }
  11362. return oldValue.Model, nil
  11363. }
  11364. // ClearModel clears the value of the "model" field.
  11365. func (m *CompapiAsynctaskMutation) ClearModel() {
  11366. m.model = nil
  11367. m.clearedFields[compapiasynctask.FieldModel] = struct{}{}
  11368. }
  11369. // ModelCleared returns if the "model" field was cleared in this mutation.
  11370. func (m *CompapiAsynctaskMutation) ModelCleared() bool {
  11371. _, ok := m.clearedFields[compapiasynctask.FieldModel]
  11372. return ok
  11373. }
  11374. // ResetModel resets all changes to the "model" field.
  11375. func (m *CompapiAsynctaskMutation) ResetModel() {
  11376. m.model = nil
  11377. delete(m.clearedFields, compapiasynctask.FieldModel)
  11378. }
  11379. // SetTaskStatus sets the "task_status" field.
  11380. func (m *CompapiAsynctaskMutation) SetTaskStatus(i int8) {
  11381. m.task_status = &i
  11382. m.addtask_status = nil
  11383. }
  11384. // TaskStatus returns the value of the "task_status" field in the mutation.
  11385. func (m *CompapiAsynctaskMutation) TaskStatus() (r int8, exists bool) {
  11386. v := m.task_status
  11387. if v == nil {
  11388. return
  11389. }
  11390. return *v, true
  11391. }
  11392. // OldTaskStatus returns the old "task_status" field's value of the CompapiAsynctask entity.
  11393. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11395. func (m *CompapiAsynctaskMutation) OldTaskStatus(ctx context.Context) (v int8, err error) {
  11396. if !m.op.Is(OpUpdateOne) {
  11397. return v, errors.New("OldTaskStatus is only allowed on UpdateOne operations")
  11398. }
  11399. if m.id == nil || m.oldValue == nil {
  11400. return v, errors.New("OldTaskStatus requires an ID field in the mutation")
  11401. }
  11402. oldValue, err := m.oldValue(ctx)
  11403. if err != nil {
  11404. return v, fmt.Errorf("querying old value for OldTaskStatus: %w", err)
  11405. }
  11406. return oldValue.TaskStatus, nil
  11407. }
  11408. // AddTaskStatus adds i to the "task_status" field.
  11409. func (m *CompapiAsynctaskMutation) AddTaskStatus(i int8) {
  11410. if m.addtask_status != nil {
  11411. *m.addtask_status += i
  11412. } else {
  11413. m.addtask_status = &i
  11414. }
  11415. }
  11416. // AddedTaskStatus returns the value that was added to the "task_status" field in this mutation.
  11417. func (m *CompapiAsynctaskMutation) AddedTaskStatus() (r int8, exists bool) {
  11418. v := m.addtask_status
  11419. if v == nil {
  11420. return
  11421. }
  11422. return *v, true
  11423. }
  11424. // ClearTaskStatus clears the value of the "task_status" field.
  11425. func (m *CompapiAsynctaskMutation) ClearTaskStatus() {
  11426. m.task_status = nil
  11427. m.addtask_status = nil
  11428. m.clearedFields[compapiasynctask.FieldTaskStatus] = struct{}{}
  11429. }
  11430. // TaskStatusCleared returns if the "task_status" field was cleared in this mutation.
  11431. func (m *CompapiAsynctaskMutation) TaskStatusCleared() bool {
  11432. _, ok := m.clearedFields[compapiasynctask.FieldTaskStatus]
  11433. return ok
  11434. }
  11435. // ResetTaskStatus resets all changes to the "task_status" field.
  11436. func (m *CompapiAsynctaskMutation) ResetTaskStatus() {
  11437. m.task_status = nil
  11438. m.addtask_status = nil
  11439. delete(m.clearedFields, compapiasynctask.FieldTaskStatus)
  11440. }
  11441. // SetRetryCount sets the "retry_count" field.
  11442. func (m *CompapiAsynctaskMutation) SetRetryCount(i int8) {
  11443. m.retry_count = &i
  11444. m.addretry_count = nil
  11445. }
  11446. // RetryCount returns the value of the "retry_count" field in the mutation.
  11447. func (m *CompapiAsynctaskMutation) RetryCount() (r int8, exists bool) {
  11448. v := m.retry_count
  11449. if v == nil {
  11450. return
  11451. }
  11452. return *v, true
  11453. }
  11454. // OldRetryCount returns the old "retry_count" field's value of the CompapiAsynctask entity.
  11455. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11457. func (m *CompapiAsynctaskMutation) OldRetryCount(ctx context.Context) (v int8, err error) {
  11458. if !m.op.Is(OpUpdateOne) {
  11459. return v, errors.New("OldRetryCount is only allowed on UpdateOne operations")
  11460. }
  11461. if m.id == nil || m.oldValue == nil {
  11462. return v, errors.New("OldRetryCount requires an ID field in the mutation")
  11463. }
  11464. oldValue, err := m.oldValue(ctx)
  11465. if err != nil {
  11466. return v, fmt.Errorf("querying old value for OldRetryCount: %w", err)
  11467. }
  11468. return oldValue.RetryCount, nil
  11469. }
  11470. // AddRetryCount adds i to the "retry_count" field.
  11471. func (m *CompapiAsynctaskMutation) AddRetryCount(i int8) {
  11472. if m.addretry_count != nil {
  11473. *m.addretry_count += i
  11474. } else {
  11475. m.addretry_count = &i
  11476. }
  11477. }
  11478. // AddedRetryCount returns the value that was added to the "retry_count" field in this mutation.
  11479. func (m *CompapiAsynctaskMutation) AddedRetryCount() (r int8, exists bool) {
  11480. v := m.addretry_count
  11481. if v == nil {
  11482. return
  11483. }
  11484. return *v, true
  11485. }
  11486. // ClearRetryCount clears the value of the "retry_count" field.
  11487. func (m *CompapiAsynctaskMutation) ClearRetryCount() {
  11488. m.retry_count = nil
  11489. m.addretry_count = nil
  11490. m.clearedFields[compapiasynctask.FieldRetryCount] = struct{}{}
  11491. }
  11492. // RetryCountCleared returns if the "retry_count" field was cleared in this mutation.
  11493. func (m *CompapiAsynctaskMutation) RetryCountCleared() bool {
  11494. _, ok := m.clearedFields[compapiasynctask.FieldRetryCount]
  11495. return ok
  11496. }
  11497. // ResetRetryCount resets all changes to the "retry_count" field.
  11498. func (m *CompapiAsynctaskMutation) ResetRetryCount() {
  11499. m.retry_count = nil
  11500. m.addretry_count = nil
  11501. delete(m.clearedFields, compapiasynctask.FieldRetryCount)
  11502. }
  11503. // SetLastError sets the "last_error" field.
  11504. func (m *CompapiAsynctaskMutation) SetLastError(s string) {
  11505. m.last_error = &s
  11506. }
  11507. // LastError returns the value of the "last_error" field in the mutation.
  11508. func (m *CompapiAsynctaskMutation) LastError() (r string, exists bool) {
  11509. v := m.last_error
  11510. if v == nil {
  11511. return
  11512. }
  11513. return *v, true
  11514. }
  11515. // OldLastError returns the old "last_error" field's value of the CompapiAsynctask entity.
  11516. // If the CompapiAsynctask object wasn't provided to the builder, the object is fetched from the database.
  11517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11518. func (m *CompapiAsynctaskMutation) OldLastError(ctx context.Context) (v string, err error) {
  11519. if !m.op.Is(OpUpdateOne) {
  11520. return v, errors.New("OldLastError is only allowed on UpdateOne operations")
  11521. }
  11522. if m.id == nil || m.oldValue == nil {
  11523. return v, errors.New("OldLastError requires an ID field in the mutation")
  11524. }
  11525. oldValue, err := m.oldValue(ctx)
  11526. if err != nil {
  11527. return v, fmt.Errorf("querying old value for OldLastError: %w", err)
  11528. }
  11529. return oldValue.LastError, nil
  11530. }
  11531. // ClearLastError clears the value of the "last_error" field.
  11532. func (m *CompapiAsynctaskMutation) ClearLastError() {
  11533. m.last_error = nil
  11534. m.clearedFields[compapiasynctask.FieldLastError] = struct{}{}
  11535. }
  11536. // LastErrorCleared returns if the "last_error" field was cleared in this mutation.
  11537. func (m *CompapiAsynctaskMutation) LastErrorCleared() bool {
  11538. _, ok := m.clearedFields[compapiasynctask.FieldLastError]
  11539. return ok
  11540. }
  11541. // ResetLastError resets all changes to the "last_error" field.
  11542. func (m *CompapiAsynctaskMutation) ResetLastError() {
  11543. m.last_error = nil
  11544. delete(m.clearedFields, compapiasynctask.FieldLastError)
  11545. }
  11546. // Where appends a list predicates to the CompapiAsynctaskMutation builder.
  11547. func (m *CompapiAsynctaskMutation) Where(ps ...predicate.CompapiAsynctask) {
  11548. m.predicates = append(m.predicates, ps...)
  11549. }
  11550. // WhereP appends storage-level predicates to the CompapiAsynctaskMutation builder. Using this method,
  11551. // users can use type-assertion to append predicates that do not depend on any generated package.
  11552. func (m *CompapiAsynctaskMutation) WhereP(ps ...func(*sql.Selector)) {
  11553. p := make([]predicate.CompapiAsynctask, len(ps))
  11554. for i := range ps {
  11555. p[i] = ps[i]
  11556. }
  11557. m.Where(p...)
  11558. }
  11559. // Op returns the operation name.
  11560. func (m *CompapiAsynctaskMutation) Op() Op {
  11561. return m.op
  11562. }
  11563. // SetOp allows setting the mutation operation.
  11564. func (m *CompapiAsynctaskMutation) SetOp(op Op) {
  11565. m.op = op
  11566. }
  11567. // Type returns the node type of this mutation (CompapiAsynctask).
  11568. func (m *CompapiAsynctaskMutation) Type() string {
  11569. return m.typ
  11570. }
  11571. // Fields returns all fields that were changed during this mutation. Note that in
  11572. // order to get all numeric fields that were incremented/decremented, call
  11573. // AddedFields().
  11574. func (m *CompapiAsynctaskMutation) Fields() []string {
  11575. fields := make([]string, 0, 17)
  11576. if m.created_at != nil {
  11577. fields = append(fields, compapiasynctask.FieldCreatedAt)
  11578. }
  11579. if m.updated_at != nil {
  11580. fields = append(fields, compapiasynctask.FieldUpdatedAt)
  11581. }
  11582. if m.auth_token != nil {
  11583. fields = append(fields, compapiasynctask.FieldAuthToken)
  11584. }
  11585. if m.event_type != nil {
  11586. fields = append(fields, compapiasynctask.FieldEventType)
  11587. }
  11588. if m.chat_id != nil {
  11589. fields = append(fields, compapiasynctask.FieldChatID)
  11590. }
  11591. if m.response_chat_item_id != nil {
  11592. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11593. }
  11594. if m.organization_id != nil {
  11595. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11596. }
  11597. if m.openai_base != nil {
  11598. fields = append(fields, compapiasynctask.FieldOpenaiBase)
  11599. }
  11600. if m.openai_key != nil {
  11601. fields = append(fields, compapiasynctask.FieldOpenaiKey)
  11602. }
  11603. if m.request_raw != nil {
  11604. fields = append(fields, compapiasynctask.FieldRequestRaw)
  11605. }
  11606. if m.response_raw != nil {
  11607. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11608. }
  11609. if m.callback_url != nil {
  11610. fields = append(fields, compapiasynctask.FieldCallbackURL)
  11611. }
  11612. if m.callback_response_raw != nil {
  11613. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11614. }
  11615. if m.model != nil {
  11616. fields = append(fields, compapiasynctask.FieldModel)
  11617. }
  11618. if m.task_status != nil {
  11619. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11620. }
  11621. if m.retry_count != nil {
  11622. fields = append(fields, compapiasynctask.FieldRetryCount)
  11623. }
  11624. if m.last_error != nil {
  11625. fields = append(fields, compapiasynctask.FieldLastError)
  11626. }
  11627. return fields
  11628. }
  11629. // Field returns the value of a field with the given name. The second boolean
  11630. // return value indicates that this field was not set, or was not defined in the
  11631. // schema.
  11632. func (m *CompapiAsynctaskMutation) Field(name string) (ent.Value, bool) {
  11633. switch name {
  11634. case compapiasynctask.FieldCreatedAt:
  11635. return m.CreatedAt()
  11636. case compapiasynctask.FieldUpdatedAt:
  11637. return m.UpdatedAt()
  11638. case compapiasynctask.FieldAuthToken:
  11639. return m.AuthToken()
  11640. case compapiasynctask.FieldEventType:
  11641. return m.EventType()
  11642. case compapiasynctask.FieldChatID:
  11643. return m.ChatID()
  11644. case compapiasynctask.FieldResponseChatItemID:
  11645. return m.ResponseChatItemID()
  11646. case compapiasynctask.FieldOrganizationID:
  11647. return m.OrganizationID()
  11648. case compapiasynctask.FieldOpenaiBase:
  11649. return m.OpenaiBase()
  11650. case compapiasynctask.FieldOpenaiKey:
  11651. return m.OpenaiKey()
  11652. case compapiasynctask.FieldRequestRaw:
  11653. return m.RequestRaw()
  11654. case compapiasynctask.FieldResponseRaw:
  11655. return m.ResponseRaw()
  11656. case compapiasynctask.FieldCallbackURL:
  11657. return m.CallbackURL()
  11658. case compapiasynctask.FieldCallbackResponseRaw:
  11659. return m.CallbackResponseRaw()
  11660. case compapiasynctask.FieldModel:
  11661. return m.Model()
  11662. case compapiasynctask.FieldTaskStatus:
  11663. return m.TaskStatus()
  11664. case compapiasynctask.FieldRetryCount:
  11665. return m.RetryCount()
  11666. case compapiasynctask.FieldLastError:
  11667. return m.LastError()
  11668. }
  11669. return nil, false
  11670. }
  11671. // OldField returns the old value of the field from the database. An error is
  11672. // returned if the mutation operation is not UpdateOne, or the query to the
  11673. // database failed.
  11674. func (m *CompapiAsynctaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11675. switch name {
  11676. case compapiasynctask.FieldCreatedAt:
  11677. return m.OldCreatedAt(ctx)
  11678. case compapiasynctask.FieldUpdatedAt:
  11679. return m.OldUpdatedAt(ctx)
  11680. case compapiasynctask.FieldAuthToken:
  11681. return m.OldAuthToken(ctx)
  11682. case compapiasynctask.FieldEventType:
  11683. return m.OldEventType(ctx)
  11684. case compapiasynctask.FieldChatID:
  11685. return m.OldChatID(ctx)
  11686. case compapiasynctask.FieldResponseChatItemID:
  11687. return m.OldResponseChatItemID(ctx)
  11688. case compapiasynctask.FieldOrganizationID:
  11689. return m.OldOrganizationID(ctx)
  11690. case compapiasynctask.FieldOpenaiBase:
  11691. return m.OldOpenaiBase(ctx)
  11692. case compapiasynctask.FieldOpenaiKey:
  11693. return m.OldOpenaiKey(ctx)
  11694. case compapiasynctask.FieldRequestRaw:
  11695. return m.OldRequestRaw(ctx)
  11696. case compapiasynctask.FieldResponseRaw:
  11697. return m.OldResponseRaw(ctx)
  11698. case compapiasynctask.FieldCallbackURL:
  11699. return m.OldCallbackURL(ctx)
  11700. case compapiasynctask.FieldCallbackResponseRaw:
  11701. return m.OldCallbackResponseRaw(ctx)
  11702. case compapiasynctask.FieldModel:
  11703. return m.OldModel(ctx)
  11704. case compapiasynctask.FieldTaskStatus:
  11705. return m.OldTaskStatus(ctx)
  11706. case compapiasynctask.FieldRetryCount:
  11707. return m.OldRetryCount(ctx)
  11708. case compapiasynctask.FieldLastError:
  11709. return m.OldLastError(ctx)
  11710. }
  11711. return nil, fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11712. }
  11713. // SetField sets the value of a field with the given name. It returns an error if
  11714. // the field is not defined in the schema, or if the type mismatched the field
  11715. // type.
  11716. func (m *CompapiAsynctaskMutation) SetField(name string, value ent.Value) error {
  11717. switch name {
  11718. case compapiasynctask.FieldCreatedAt:
  11719. v, ok := value.(time.Time)
  11720. if !ok {
  11721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11722. }
  11723. m.SetCreatedAt(v)
  11724. return nil
  11725. case compapiasynctask.FieldUpdatedAt:
  11726. v, ok := value.(time.Time)
  11727. if !ok {
  11728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11729. }
  11730. m.SetUpdatedAt(v)
  11731. return nil
  11732. case compapiasynctask.FieldAuthToken:
  11733. v, ok := value.(string)
  11734. if !ok {
  11735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11736. }
  11737. m.SetAuthToken(v)
  11738. return nil
  11739. case compapiasynctask.FieldEventType:
  11740. v, ok := value.(string)
  11741. if !ok {
  11742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11743. }
  11744. m.SetEventType(v)
  11745. return nil
  11746. case compapiasynctask.FieldChatID:
  11747. v, ok := value.(string)
  11748. if !ok {
  11749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11750. }
  11751. m.SetChatID(v)
  11752. return nil
  11753. case compapiasynctask.FieldResponseChatItemID:
  11754. v, ok := value.(string)
  11755. if !ok {
  11756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11757. }
  11758. m.SetResponseChatItemID(v)
  11759. return nil
  11760. case compapiasynctask.FieldOrganizationID:
  11761. v, ok := value.(uint64)
  11762. if !ok {
  11763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11764. }
  11765. m.SetOrganizationID(v)
  11766. return nil
  11767. case compapiasynctask.FieldOpenaiBase:
  11768. v, ok := value.(string)
  11769. if !ok {
  11770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11771. }
  11772. m.SetOpenaiBase(v)
  11773. return nil
  11774. case compapiasynctask.FieldOpenaiKey:
  11775. v, ok := value.(string)
  11776. if !ok {
  11777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11778. }
  11779. m.SetOpenaiKey(v)
  11780. return nil
  11781. case compapiasynctask.FieldRequestRaw:
  11782. v, ok := value.(string)
  11783. if !ok {
  11784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11785. }
  11786. m.SetRequestRaw(v)
  11787. return nil
  11788. case compapiasynctask.FieldResponseRaw:
  11789. v, ok := value.(string)
  11790. if !ok {
  11791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11792. }
  11793. m.SetResponseRaw(v)
  11794. return nil
  11795. case compapiasynctask.FieldCallbackURL:
  11796. v, ok := value.(string)
  11797. if !ok {
  11798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11799. }
  11800. m.SetCallbackURL(v)
  11801. return nil
  11802. case compapiasynctask.FieldCallbackResponseRaw:
  11803. v, ok := value.(string)
  11804. if !ok {
  11805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11806. }
  11807. m.SetCallbackResponseRaw(v)
  11808. return nil
  11809. case compapiasynctask.FieldModel:
  11810. v, ok := value.(string)
  11811. if !ok {
  11812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11813. }
  11814. m.SetModel(v)
  11815. return nil
  11816. case compapiasynctask.FieldTaskStatus:
  11817. v, ok := value.(int8)
  11818. if !ok {
  11819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11820. }
  11821. m.SetTaskStatus(v)
  11822. return nil
  11823. case compapiasynctask.FieldRetryCount:
  11824. v, ok := value.(int8)
  11825. if !ok {
  11826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11827. }
  11828. m.SetRetryCount(v)
  11829. return nil
  11830. case compapiasynctask.FieldLastError:
  11831. v, ok := value.(string)
  11832. if !ok {
  11833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11834. }
  11835. m.SetLastError(v)
  11836. return nil
  11837. }
  11838. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  11839. }
  11840. // AddedFields returns all numeric fields that were incremented/decremented during
  11841. // this mutation.
  11842. func (m *CompapiAsynctaskMutation) AddedFields() []string {
  11843. var fields []string
  11844. if m.addorganization_id != nil {
  11845. fields = append(fields, compapiasynctask.FieldOrganizationID)
  11846. }
  11847. if m.addtask_status != nil {
  11848. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11849. }
  11850. if m.addretry_count != nil {
  11851. fields = append(fields, compapiasynctask.FieldRetryCount)
  11852. }
  11853. return fields
  11854. }
  11855. // AddedField returns the numeric value that was incremented/decremented on a field
  11856. // with the given name. The second boolean return value indicates that this field
  11857. // was not set, or was not defined in the schema.
  11858. func (m *CompapiAsynctaskMutation) AddedField(name string) (ent.Value, bool) {
  11859. switch name {
  11860. case compapiasynctask.FieldOrganizationID:
  11861. return m.AddedOrganizationID()
  11862. case compapiasynctask.FieldTaskStatus:
  11863. return m.AddedTaskStatus()
  11864. case compapiasynctask.FieldRetryCount:
  11865. return m.AddedRetryCount()
  11866. }
  11867. return nil, false
  11868. }
  11869. // AddField adds the value to the field with the given name. It returns an error if
  11870. // the field is not defined in the schema, or if the type mismatched the field
  11871. // type.
  11872. func (m *CompapiAsynctaskMutation) AddField(name string, value ent.Value) error {
  11873. switch name {
  11874. case compapiasynctask.FieldOrganizationID:
  11875. v, ok := value.(int64)
  11876. if !ok {
  11877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11878. }
  11879. m.AddOrganizationID(v)
  11880. return nil
  11881. case compapiasynctask.FieldTaskStatus:
  11882. v, ok := value.(int8)
  11883. if !ok {
  11884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11885. }
  11886. m.AddTaskStatus(v)
  11887. return nil
  11888. case compapiasynctask.FieldRetryCount:
  11889. v, ok := value.(int8)
  11890. if !ok {
  11891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11892. }
  11893. m.AddRetryCount(v)
  11894. return nil
  11895. }
  11896. return fmt.Errorf("unknown CompapiAsynctask numeric field %s", name)
  11897. }
  11898. // ClearedFields returns all nullable fields that were cleared during this
  11899. // mutation.
  11900. func (m *CompapiAsynctaskMutation) ClearedFields() []string {
  11901. var fields []string
  11902. if m.FieldCleared(compapiasynctask.FieldChatID) {
  11903. fields = append(fields, compapiasynctask.FieldChatID)
  11904. }
  11905. if m.FieldCleared(compapiasynctask.FieldResponseChatItemID) {
  11906. fields = append(fields, compapiasynctask.FieldResponseChatItemID)
  11907. }
  11908. if m.FieldCleared(compapiasynctask.FieldResponseRaw) {
  11909. fields = append(fields, compapiasynctask.FieldResponseRaw)
  11910. }
  11911. if m.FieldCleared(compapiasynctask.FieldCallbackResponseRaw) {
  11912. fields = append(fields, compapiasynctask.FieldCallbackResponseRaw)
  11913. }
  11914. if m.FieldCleared(compapiasynctask.FieldModel) {
  11915. fields = append(fields, compapiasynctask.FieldModel)
  11916. }
  11917. if m.FieldCleared(compapiasynctask.FieldTaskStatus) {
  11918. fields = append(fields, compapiasynctask.FieldTaskStatus)
  11919. }
  11920. if m.FieldCleared(compapiasynctask.FieldRetryCount) {
  11921. fields = append(fields, compapiasynctask.FieldRetryCount)
  11922. }
  11923. if m.FieldCleared(compapiasynctask.FieldLastError) {
  11924. fields = append(fields, compapiasynctask.FieldLastError)
  11925. }
  11926. return fields
  11927. }
  11928. // FieldCleared returns a boolean indicating if a field with the given name was
  11929. // cleared in this mutation.
  11930. func (m *CompapiAsynctaskMutation) FieldCleared(name string) bool {
  11931. _, ok := m.clearedFields[name]
  11932. return ok
  11933. }
  11934. // ClearField clears the value of the field with the given name. It returns an
  11935. // error if the field is not defined in the schema.
  11936. func (m *CompapiAsynctaskMutation) ClearField(name string) error {
  11937. switch name {
  11938. case compapiasynctask.FieldChatID:
  11939. m.ClearChatID()
  11940. return nil
  11941. case compapiasynctask.FieldResponseChatItemID:
  11942. m.ClearResponseChatItemID()
  11943. return nil
  11944. case compapiasynctask.FieldResponseRaw:
  11945. m.ClearResponseRaw()
  11946. return nil
  11947. case compapiasynctask.FieldCallbackResponseRaw:
  11948. m.ClearCallbackResponseRaw()
  11949. return nil
  11950. case compapiasynctask.FieldModel:
  11951. m.ClearModel()
  11952. return nil
  11953. case compapiasynctask.FieldTaskStatus:
  11954. m.ClearTaskStatus()
  11955. return nil
  11956. case compapiasynctask.FieldRetryCount:
  11957. m.ClearRetryCount()
  11958. return nil
  11959. case compapiasynctask.FieldLastError:
  11960. m.ClearLastError()
  11961. return nil
  11962. }
  11963. return fmt.Errorf("unknown CompapiAsynctask nullable field %s", name)
  11964. }
  11965. // ResetField resets all changes in the mutation for the field with the given name.
  11966. // It returns an error if the field is not defined in the schema.
  11967. func (m *CompapiAsynctaskMutation) ResetField(name string) error {
  11968. switch name {
  11969. case compapiasynctask.FieldCreatedAt:
  11970. m.ResetCreatedAt()
  11971. return nil
  11972. case compapiasynctask.FieldUpdatedAt:
  11973. m.ResetUpdatedAt()
  11974. return nil
  11975. case compapiasynctask.FieldAuthToken:
  11976. m.ResetAuthToken()
  11977. return nil
  11978. case compapiasynctask.FieldEventType:
  11979. m.ResetEventType()
  11980. return nil
  11981. case compapiasynctask.FieldChatID:
  11982. m.ResetChatID()
  11983. return nil
  11984. case compapiasynctask.FieldResponseChatItemID:
  11985. m.ResetResponseChatItemID()
  11986. return nil
  11987. case compapiasynctask.FieldOrganizationID:
  11988. m.ResetOrganizationID()
  11989. return nil
  11990. case compapiasynctask.FieldOpenaiBase:
  11991. m.ResetOpenaiBase()
  11992. return nil
  11993. case compapiasynctask.FieldOpenaiKey:
  11994. m.ResetOpenaiKey()
  11995. return nil
  11996. case compapiasynctask.FieldRequestRaw:
  11997. m.ResetRequestRaw()
  11998. return nil
  11999. case compapiasynctask.FieldResponseRaw:
  12000. m.ResetResponseRaw()
  12001. return nil
  12002. case compapiasynctask.FieldCallbackURL:
  12003. m.ResetCallbackURL()
  12004. return nil
  12005. case compapiasynctask.FieldCallbackResponseRaw:
  12006. m.ResetCallbackResponseRaw()
  12007. return nil
  12008. case compapiasynctask.FieldModel:
  12009. m.ResetModel()
  12010. return nil
  12011. case compapiasynctask.FieldTaskStatus:
  12012. m.ResetTaskStatus()
  12013. return nil
  12014. case compapiasynctask.FieldRetryCount:
  12015. m.ResetRetryCount()
  12016. return nil
  12017. case compapiasynctask.FieldLastError:
  12018. m.ResetLastError()
  12019. return nil
  12020. }
  12021. return fmt.Errorf("unknown CompapiAsynctask field %s", name)
  12022. }
  12023. // AddedEdges returns all edge names that were set/added in this mutation.
  12024. func (m *CompapiAsynctaskMutation) AddedEdges() []string {
  12025. edges := make([]string, 0, 0)
  12026. return edges
  12027. }
  12028. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12029. // name in this mutation.
  12030. func (m *CompapiAsynctaskMutation) AddedIDs(name string) []ent.Value {
  12031. return nil
  12032. }
  12033. // RemovedEdges returns all edge names that were removed in this mutation.
  12034. func (m *CompapiAsynctaskMutation) RemovedEdges() []string {
  12035. edges := make([]string, 0, 0)
  12036. return edges
  12037. }
  12038. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12039. // the given name in this mutation.
  12040. func (m *CompapiAsynctaskMutation) RemovedIDs(name string) []ent.Value {
  12041. return nil
  12042. }
  12043. // ClearedEdges returns all edge names that were cleared in this mutation.
  12044. func (m *CompapiAsynctaskMutation) ClearedEdges() []string {
  12045. edges := make([]string, 0, 0)
  12046. return edges
  12047. }
  12048. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12049. // was cleared in this mutation.
  12050. func (m *CompapiAsynctaskMutation) EdgeCleared(name string) bool {
  12051. return false
  12052. }
  12053. // ClearEdge clears the value of the edge with the given name. It returns an error
  12054. // if that edge is not defined in the schema.
  12055. func (m *CompapiAsynctaskMutation) ClearEdge(name string) error {
  12056. return fmt.Errorf("unknown CompapiAsynctask unique edge %s", name)
  12057. }
  12058. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12059. // It returns an error if the edge is not defined in the schema.
  12060. func (m *CompapiAsynctaskMutation) ResetEdge(name string) error {
  12061. return fmt.Errorf("unknown CompapiAsynctask edge %s", name)
  12062. }
  12063. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  12064. type ContactMutation struct {
  12065. config
  12066. op Op
  12067. typ string
  12068. id *uint64
  12069. created_at *time.Time
  12070. updated_at *time.Time
  12071. status *uint8
  12072. addstatus *int8
  12073. deleted_at *time.Time
  12074. wx_wxid *string
  12075. _type *int
  12076. add_type *int
  12077. wxid *string
  12078. account *string
  12079. nickname *string
  12080. markname *string
  12081. headimg *string
  12082. sex *int
  12083. addsex *int
  12084. starrole *string
  12085. dontseeit *int
  12086. adddontseeit *int
  12087. dontseeme *int
  12088. adddontseeme *int
  12089. lag *string
  12090. gid *string
  12091. gname *string
  12092. v3 *string
  12093. organization_id *uint64
  12094. addorganization_id *int64
  12095. ctype *uint64
  12096. addctype *int64
  12097. cage *int
  12098. addcage *int
  12099. cname *string
  12100. carea *string
  12101. cbirthday *string
  12102. cbirtharea *string
  12103. cidcard_no *string
  12104. ctitle *string
  12105. cc *string
  12106. phone *string
  12107. clearedFields map[string]struct{}
  12108. contact_relationships map[uint64]struct{}
  12109. removedcontact_relationships map[uint64]struct{}
  12110. clearedcontact_relationships bool
  12111. contact_fields map[uint64]struct{}
  12112. removedcontact_fields map[uint64]struct{}
  12113. clearedcontact_fields bool
  12114. contact_messages map[uint64]struct{}
  12115. removedcontact_messages map[uint64]struct{}
  12116. clearedcontact_messages bool
  12117. done bool
  12118. oldValue func(context.Context) (*Contact, error)
  12119. predicates []predicate.Contact
  12120. }
  12121. var _ ent.Mutation = (*ContactMutation)(nil)
  12122. // contactOption allows management of the mutation configuration using functional options.
  12123. type contactOption func(*ContactMutation)
  12124. // newContactMutation creates new mutation for the Contact entity.
  12125. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  12126. m := &ContactMutation{
  12127. config: c,
  12128. op: op,
  12129. typ: TypeContact,
  12130. clearedFields: make(map[string]struct{}),
  12131. }
  12132. for _, opt := range opts {
  12133. opt(m)
  12134. }
  12135. return m
  12136. }
  12137. // withContactID sets the ID field of the mutation.
  12138. func withContactID(id uint64) contactOption {
  12139. return func(m *ContactMutation) {
  12140. var (
  12141. err error
  12142. once sync.Once
  12143. value *Contact
  12144. )
  12145. m.oldValue = func(ctx context.Context) (*Contact, error) {
  12146. once.Do(func() {
  12147. if m.done {
  12148. err = errors.New("querying old values post mutation is not allowed")
  12149. } else {
  12150. value, err = m.Client().Contact.Get(ctx, id)
  12151. }
  12152. })
  12153. return value, err
  12154. }
  12155. m.id = &id
  12156. }
  12157. }
  12158. // withContact sets the old Contact of the mutation.
  12159. func withContact(node *Contact) contactOption {
  12160. return func(m *ContactMutation) {
  12161. m.oldValue = func(context.Context) (*Contact, error) {
  12162. return node, nil
  12163. }
  12164. m.id = &node.ID
  12165. }
  12166. }
  12167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12168. // executed in a transaction (ent.Tx), a transactional client is returned.
  12169. func (m ContactMutation) Client() *Client {
  12170. client := &Client{config: m.config}
  12171. client.init()
  12172. return client
  12173. }
  12174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12175. // it returns an error otherwise.
  12176. func (m ContactMutation) Tx() (*Tx, error) {
  12177. if _, ok := m.driver.(*txDriver); !ok {
  12178. return nil, errors.New("ent: mutation is not running in a transaction")
  12179. }
  12180. tx := &Tx{config: m.config}
  12181. tx.init()
  12182. return tx, nil
  12183. }
  12184. // SetID sets the value of the id field. Note that this
  12185. // operation is only accepted on creation of Contact entities.
  12186. func (m *ContactMutation) SetID(id uint64) {
  12187. m.id = &id
  12188. }
  12189. // ID returns the ID value in the mutation. Note that the ID is only available
  12190. // if it was provided to the builder or after it was returned from the database.
  12191. func (m *ContactMutation) ID() (id uint64, exists bool) {
  12192. if m.id == nil {
  12193. return
  12194. }
  12195. return *m.id, true
  12196. }
  12197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12198. // That means, if the mutation is applied within a transaction with an isolation level such
  12199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12200. // or updated by the mutation.
  12201. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  12202. switch {
  12203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12204. id, exists := m.ID()
  12205. if exists {
  12206. return []uint64{id}, nil
  12207. }
  12208. fallthrough
  12209. case m.op.Is(OpUpdate | OpDelete):
  12210. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  12211. default:
  12212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12213. }
  12214. }
  12215. // SetCreatedAt sets the "created_at" field.
  12216. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  12217. m.created_at = &t
  12218. }
  12219. // CreatedAt returns the value of the "created_at" field in the mutation.
  12220. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  12221. v := m.created_at
  12222. if v == nil {
  12223. return
  12224. }
  12225. return *v, true
  12226. }
  12227. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  12228. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12230. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12231. if !m.op.Is(OpUpdateOne) {
  12232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12233. }
  12234. if m.id == nil || m.oldValue == nil {
  12235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12236. }
  12237. oldValue, err := m.oldValue(ctx)
  12238. if err != nil {
  12239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12240. }
  12241. return oldValue.CreatedAt, nil
  12242. }
  12243. // ResetCreatedAt resets all changes to the "created_at" field.
  12244. func (m *ContactMutation) ResetCreatedAt() {
  12245. m.created_at = nil
  12246. }
  12247. // SetUpdatedAt sets the "updated_at" field.
  12248. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  12249. m.updated_at = &t
  12250. }
  12251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12252. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  12253. v := m.updated_at
  12254. if v == nil {
  12255. return
  12256. }
  12257. return *v, true
  12258. }
  12259. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  12260. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12262. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12263. if !m.op.Is(OpUpdateOne) {
  12264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12265. }
  12266. if m.id == nil || m.oldValue == nil {
  12267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12268. }
  12269. oldValue, err := m.oldValue(ctx)
  12270. if err != nil {
  12271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12272. }
  12273. return oldValue.UpdatedAt, nil
  12274. }
  12275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12276. func (m *ContactMutation) ResetUpdatedAt() {
  12277. m.updated_at = nil
  12278. }
  12279. // SetStatus sets the "status" field.
  12280. func (m *ContactMutation) SetStatus(u uint8) {
  12281. m.status = &u
  12282. m.addstatus = nil
  12283. }
  12284. // Status returns the value of the "status" field in the mutation.
  12285. func (m *ContactMutation) Status() (r uint8, exists bool) {
  12286. v := m.status
  12287. if v == nil {
  12288. return
  12289. }
  12290. return *v, true
  12291. }
  12292. // OldStatus returns the old "status" field's value of the Contact entity.
  12293. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12295. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12296. if !m.op.Is(OpUpdateOne) {
  12297. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12298. }
  12299. if m.id == nil || m.oldValue == nil {
  12300. return v, errors.New("OldStatus requires an ID field in the mutation")
  12301. }
  12302. oldValue, err := m.oldValue(ctx)
  12303. if err != nil {
  12304. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12305. }
  12306. return oldValue.Status, nil
  12307. }
  12308. // AddStatus adds u to the "status" field.
  12309. func (m *ContactMutation) AddStatus(u int8) {
  12310. if m.addstatus != nil {
  12311. *m.addstatus += u
  12312. } else {
  12313. m.addstatus = &u
  12314. }
  12315. }
  12316. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12317. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  12318. v := m.addstatus
  12319. if v == nil {
  12320. return
  12321. }
  12322. return *v, true
  12323. }
  12324. // ClearStatus clears the value of the "status" field.
  12325. func (m *ContactMutation) ClearStatus() {
  12326. m.status = nil
  12327. m.addstatus = nil
  12328. m.clearedFields[contact.FieldStatus] = struct{}{}
  12329. }
  12330. // StatusCleared returns if the "status" field was cleared in this mutation.
  12331. func (m *ContactMutation) StatusCleared() bool {
  12332. _, ok := m.clearedFields[contact.FieldStatus]
  12333. return ok
  12334. }
  12335. // ResetStatus resets all changes to the "status" field.
  12336. func (m *ContactMutation) ResetStatus() {
  12337. m.status = nil
  12338. m.addstatus = nil
  12339. delete(m.clearedFields, contact.FieldStatus)
  12340. }
  12341. // SetDeletedAt sets the "deleted_at" field.
  12342. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  12343. m.deleted_at = &t
  12344. }
  12345. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12346. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  12347. v := m.deleted_at
  12348. if v == nil {
  12349. return
  12350. }
  12351. return *v, true
  12352. }
  12353. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  12354. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12356. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12357. if !m.op.Is(OpUpdateOne) {
  12358. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12359. }
  12360. if m.id == nil || m.oldValue == nil {
  12361. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12362. }
  12363. oldValue, err := m.oldValue(ctx)
  12364. if err != nil {
  12365. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12366. }
  12367. return oldValue.DeletedAt, nil
  12368. }
  12369. // ClearDeletedAt clears the value of the "deleted_at" field.
  12370. func (m *ContactMutation) ClearDeletedAt() {
  12371. m.deleted_at = nil
  12372. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  12373. }
  12374. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12375. func (m *ContactMutation) DeletedAtCleared() bool {
  12376. _, ok := m.clearedFields[contact.FieldDeletedAt]
  12377. return ok
  12378. }
  12379. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12380. func (m *ContactMutation) ResetDeletedAt() {
  12381. m.deleted_at = nil
  12382. delete(m.clearedFields, contact.FieldDeletedAt)
  12383. }
  12384. // SetWxWxid sets the "wx_wxid" field.
  12385. func (m *ContactMutation) SetWxWxid(s string) {
  12386. m.wx_wxid = &s
  12387. }
  12388. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  12389. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  12390. v := m.wx_wxid
  12391. if v == nil {
  12392. return
  12393. }
  12394. return *v, true
  12395. }
  12396. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  12397. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12399. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  12400. if !m.op.Is(OpUpdateOne) {
  12401. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  12402. }
  12403. if m.id == nil || m.oldValue == nil {
  12404. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  12405. }
  12406. oldValue, err := m.oldValue(ctx)
  12407. if err != nil {
  12408. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  12409. }
  12410. return oldValue.WxWxid, nil
  12411. }
  12412. // ResetWxWxid resets all changes to the "wx_wxid" field.
  12413. func (m *ContactMutation) ResetWxWxid() {
  12414. m.wx_wxid = nil
  12415. }
  12416. // SetType sets the "type" field.
  12417. func (m *ContactMutation) SetType(i int) {
  12418. m._type = &i
  12419. m.add_type = nil
  12420. }
  12421. // GetType returns the value of the "type" field in the mutation.
  12422. func (m *ContactMutation) GetType() (r int, exists bool) {
  12423. v := m._type
  12424. if v == nil {
  12425. return
  12426. }
  12427. return *v, true
  12428. }
  12429. // OldType returns the old "type" field's value of the Contact entity.
  12430. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12432. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  12433. if !m.op.Is(OpUpdateOne) {
  12434. return v, errors.New("OldType is only allowed on UpdateOne operations")
  12435. }
  12436. if m.id == nil || m.oldValue == nil {
  12437. return v, errors.New("OldType requires an ID field in the mutation")
  12438. }
  12439. oldValue, err := m.oldValue(ctx)
  12440. if err != nil {
  12441. return v, fmt.Errorf("querying old value for OldType: %w", err)
  12442. }
  12443. return oldValue.Type, nil
  12444. }
  12445. // AddType adds i to the "type" field.
  12446. func (m *ContactMutation) AddType(i int) {
  12447. if m.add_type != nil {
  12448. *m.add_type += i
  12449. } else {
  12450. m.add_type = &i
  12451. }
  12452. }
  12453. // AddedType returns the value that was added to the "type" field in this mutation.
  12454. func (m *ContactMutation) AddedType() (r int, exists bool) {
  12455. v := m.add_type
  12456. if v == nil {
  12457. return
  12458. }
  12459. return *v, true
  12460. }
  12461. // ClearType clears the value of the "type" field.
  12462. func (m *ContactMutation) ClearType() {
  12463. m._type = nil
  12464. m.add_type = nil
  12465. m.clearedFields[contact.FieldType] = struct{}{}
  12466. }
  12467. // TypeCleared returns if the "type" field was cleared in this mutation.
  12468. func (m *ContactMutation) TypeCleared() bool {
  12469. _, ok := m.clearedFields[contact.FieldType]
  12470. return ok
  12471. }
  12472. // ResetType resets all changes to the "type" field.
  12473. func (m *ContactMutation) ResetType() {
  12474. m._type = nil
  12475. m.add_type = nil
  12476. delete(m.clearedFields, contact.FieldType)
  12477. }
  12478. // SetWxid sets the "wxid" field.
  12479. func (m *ContactMutation) SetWxid(s string) {
  12480. m.wxid = &s
  12481. }
  12482. // Wxid returns the value of the "wxid" field in the mutation.
  12483. func (m *ContactMutation) Wxid() (r string, exists bool) {
  12484. v := m.wxid
  12485. if v == nil {
  12486. return
  12487. }
  12488. return *v, true
  12489. }
  12490. // OldWxid returns the old "wxid" field's value of the Contact entity.
  12491. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12493. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  12494. if !m.op.Is(OpUpdateOne) {
  12495. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  12496. }
  12497. if m.id == nil || m.oldValue == nil {
  12498. return v, errors.New("OldWxid requires an ID field in the mutation")
  12499. }
  12500. oldValue, err := m.oldValue(ctx)
  12501. if err != nil {
  12502. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  12503. }
  12504. return oldValue.Wxid, nil
  12505. }
  12506. // ResetWxid resets all changes to the "wxid" field.
  12507. func (m *ContactMutation) ResetWxid() {
  12508. m.wxid = nil
  12509. }
  12510. // SetAccount sets the "account" field.
  12511. func (m *ContactMutation) SetAccount(s string) {
  12512. m.account = &s
  12513. }
  12514. // Account returns the value of the "account" field in the mutation.
  12515. func (m *ContactMutation) Account() (r string, exists bool) {
  12516. v := m.account
  12517. if v == nil {
  12518. return
  12519. }
  12520. return *v, true
  12521. }
  12522. // OldAccount returns the old "account" field's value of the Contact entity.
  12523. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12525. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  12526. if !m.op.Is(OpUpdateOne) {
  12527. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  12528. }
  12529. if m.id == nil || m.oldValue == nil {
  12530. return v, errors.New("OldAccount requires an ID field in the mutation")
  12531. }
  12532. oldValue, err := m.oldValue(ctx)
  12533. if err != nil {
  12534. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  12535. }
  12536. return oldValue.Account, nil
  12537. }
  12538. // ResetAccount resets all changes to the "account" field.
  12539. func (m *ContactMutation) ResetAccount() {
  12540. m.account = nil
  12541. }
  12542. // SetNickname sets the "nickname" field.
  12543. func (m *ContactMutation) SetNickname(s string) {
  12544. m.nickname = &s
  12545. }
  12546. // Nickname returns the value of the "nickname" field in the mutation.
  12547. func (m *ContactMutation) Nickname() (r string, exists bool) {
  12548. v := m.nickname
  12549. if v == nil {
  12550. return
  12551. }
  12552. return *v, true
  12553. }
  12554. // OldNickname returns the old "nickname" field's value of the Contact entity.
  12555. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12557. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  12558. if !m.op.Is(OpUpdateOne) {
  12559. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  12560. }
  12561. if m.id == nil || m.oldValue == nil {
  12562. return v, errors.New("OldNickname requires an ID field in the mutation")
  12563. }
  12564. oldValue, err := m.oldValue(ctx)
  12565. if err != nil {
  12566. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  12567. }
  12568. return oldValue.Nickname, nil
  12569. }
  12570. // ResetNickname resets all changes to the "nickname" field.
  12571. func (m *ContactMutation) ResetNickname() {
  12572. m.nickname = nil
  12573. }
  12574. // SetMarkname sets the "markname" field.
  12575. func (m *ContactMutation) SetMarkname(s string) {
  12576. m.markname = &s
  12577. }
  12578. // Markname returns the value of the "markname" field in the mutation.
  12579. func (m *ContactMutation) Markname() (r string, exists bool) {
  12580. v := m.markname
  12581. if v == nil {
  12582. return
  12583. }
  12584. return *v, true
  12585. }
  12586. // OldMarkname returns the old "markname" field's value of the Contact entity.
  12587. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12589. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  12590. if !m.op.Is(OpUpdateOne) {
  12591. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  12592. }
  12593. if m.id == nil || m.oldValue == nil {
  12594. return v, errors.New("OldMarkname requires an ID field in the mutation")
  12595. }
  12596. oldValue, err := m.oldValue(ctx)
  12597. if err != nil {
  12598. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  12599. }
  12600. return oldValue.Markname, nil
  12601. }
  12602. // ResetMarkname resets all changes to the "markname" field.
  12603. func (m *ContactMutation) ResetMarkname() {
  12604. m.markname = nil
  12605. }
  12606. // SetHeadimg sets the "headimg" field.
  12607. func (m *ContactMutation) SetHeadimg(s string) {
  12608. m.headimg = &s
  12609. }
  12610. // Headimg returns the value of the "headimg" field in the mutation.
  12611. func (m *ContactMutation) Headimg() (r string, exists bool) {
  12612. v := m.headimg
  12613. if v == nil {
  12614. return
  12615. }
  12616. return *v, true
  12617. }
  12618. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  12619. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12621. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  12622. if !m.op.Is(OpUpdateOne) {
  12623. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  12624. }
  12625. if m.id == nil || m.oldValue == nil {
  12626. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  12627. }
  12628. oldValue, err := m.oldValue(ctx)
  12629. if err != nil {
  12630. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  12631. }
  12632. return oldValue.Headimg, nil
  12633. }
  12634. // ResetHeadimg resets all changes to the "headimg" field.
  12635. func (m *ContactMutation) ResetHeadimg() {
  12636. m.headimg = nil
  12637. }
  12638. // SetSex sets the "sex" field.
  12639. func (m *ContactMutation) SetSex(i int) {
  12640. m.sex = &i
  12641. m.addsex = nil
  12642. }
  12643. // Sex returns the value of the "sex" field in the mutation.
  12644. func (m *ContactMutation) Sex() (r int, exists bool) {
  12645. v := m.sex
  12646. if v == nil {
  12647. return
  12648. }
  12649. return *v, true
  12650. }
  12651. // OldSex returns the old "sex" field's value of the Contact entity.
  12652. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12654. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  12655. if !m.op.Is(OpUpdateOne) {
  12656. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  12657. }
  12658. if m.id == nil || m.oldValue == nil {
  12659. return v, errors.New("OldSex requires an ID field in the mutation")
  12660. }
  12661. oldValue, err := m.oldValue(ctx)
  12662. if err != nil {
  12663. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  12664. }
  12665. return oldValue.Sex, nil
  12666. }
  12667. // AddSex adds i to the "sex" field.
  12668. func (m *ContactMutation) AddSex(i int) {
  12669. if m.addsex != nil {
  12670. *m.addsex += i
  12671. } else {
  12672. m.addsex = &i
  12673. }
  12674. }
  12675. // AddedSex returns the value that was added to the "sex" field in this mutation.
  12676. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  12677. v := m.addsex
  12678. if v == nil {
  12679. return
  12680. }
  12681. return *v, true
  12682. }
  12683. // ResetSex resets all changes to the "sex" field.
  12684. func (m *ContactMutation) ResetSex() {
  12685. m.sex = nil
  12686. m.addsex = nil
  12687. }
  12688. // SetStarrole sets the "starrole" field.
  12689. func (m *ContactMutation) SetStarrole(s string) {
  12690. m.starrole = &s
  12691. }
  12692. // Starrole returns the value of the "starrole" field in the mutation.
  12693. func (m *ContactMutation) Starrole() (r string, exists bool) {
  12694. v := m.starrole
  12695. if v == nil {
  12696. return
  12697. }
  12698. return *v, true
  12699. }
  12700. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  12701. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12703. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  12704. if !m.op.Is(OpUpdateOne) {
  12705. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  12706. }
  12707. if m.id == nil || m.oldValue == nil {
  12708. return v, errors.New("OldStarrole requires an ID field in the mutation")
  12709. }
  12710. oldValue, err := m.oldValue(ctx)
  12711. if err != nil {
  12712. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  12713. }
  12714. return oldValue.Starrole, nil
  12715. }
  12716. // ResetStarrole resets all changes to the "starrole" field.
  12717. func (m *ContactMutation) ResetStarrole() {
  12718. m.starrole = nil
  12719. }
  12720. // SetDontseeit sets the "dontseeit" field.
  12721. func (m *ContactMutation) SetDontseeit(i int) {
  12722. m.dontseeit = &i
  12723. m.adddontseeit = nil
  12724. }
  12725. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  12726. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  12727. v := m.dontseeit
  12728. if v == nil {
  12729. return
  12730. }
  12731. return *v, true
  12732. }
  12733. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  12734. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12736. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  12737. if !m.op.Is(OpUpdateOne) {
  12738. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  12739. }
  12740. if m.id == nil || m.oldValue == nil {
  12741. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  12742. }
  12743. oldValue, err := m.oldValue(ctx)
  12744. if err != nil {
  12745. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  12746. }
  12747. return oldValue.Dontseeit, nil
  12748. }
  12749. // AddDontseeit adds i to the "dontseeit" field.
  12750. func (m *ContactMutation) AddDontseeit(i int) {
  12751. if m.adddontseeit != nil {
  12752. *m.adddontseeit += i
  12753. } else {
  12754. m.adddontseeit = &i
  12755. }
  12756. }
  12757. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  12758. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  12759. v := m.adddontseeit
  12760. if v == nil {
  12761. return
  12762. }
  12763. return *v, true
  12764. }
  12765. // ResetDontseeit resets all changes to the "dontseeit" field.
  12766. func (m *ContactMutation) ResetDontseeit() {
  12767. m.dontseeit = nil
  12768. m.adddontseeit = nil
  12769. }
  12770. // SetDontseeme sets the "dontseeme" field.
  12771. func (m *ContactMutation) SetDontseeme(i int) {
  12772. m.dontseeme = &i
  12773. m.adddontseeme = nil
  12774. }
  12775. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  12776. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  12777. v := m.dontseeme
  12778. if v == nil {
  12779. return
  12780. }
  12781. return *v, true
  12782. }
  12783. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  12784. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12786. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  12787. if !m.op.Is(OpUpdateOne) {
  12788. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  12789. }
  12790. if m.id == nil || m.oldValue == nil {
  12791. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  12792. }
  12793. oldValue, err := m.oldValue(ctx)
  12794. if err != nil {
  12795. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  12796. }
  12797. return oldValue.Dontseeme, nil
  12798. }
  12799. // AddDontseeme adds i to the "dontseeme" field.
  12800. func (m *ContactMutation) AddDontseeme(i int) {
  12801. if m.adddontseeme != nil {
  12802. *m.adddontseeme += i
  12803. } else {
  12804. m.adddontseeme = &i
  12805. }
  12806. }
  12807. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  12808. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  12809. v := m.adddontseeme
  12810. if v == nil {
  12811. return
  12812. }
  12813. return *v, true
  12814. }
  12815. // ResetDontseeme resets all changes to the "dontseeme" field.
  12816. func (m *ContactMutation) ResetDontseeme() {
  12817. m.dontseeme = nil
  12818. m.adddontseeme = nil
  12819. }
  12820. // SetLag sets the "lag" field.
  12821. func (m *ContactMutation) SetLag(s string) {
  12822. m.lag = &s
  12823. }
  12824. // Lag returns the value of the "lag" field in the mutation.
  12825. func (m *ContactMutation) Lag() (r string, exists bool) {
  12826. v := m.lag
  12827. if v == nil {
  12828. return
  12829. }
  12830. return *v, true
  12831. }
  12832. // OldLag returns the old "lag" field's value of the Contact entity.
  12833. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12835. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  12836. if !m.op.Is(OpUpdateOne) {
  12837. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  12838. }
  12839. if m.id == nil || m.oldValue == nil {
  12840. return v, errors.New("OldLag requires an ID field in the mutation")
  12841. }
  12842. oldValue, err := m.oldValue(ctx)
  12843. if err != nil {
  12844. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  12845. }
  12846. return oldValue.Lag, nil
  12847. }
  12848. // ResetLag resets all changes to the "lag" field.
  12849. func (m *ContactMutation) ResetLag() {
  12850. m.lag = nil
  12851. }
  12852. // SetGid sets the "gid" field.
  12853. func (m *ContactMutation) SetGid(s string) {
  12854. m.gid = &s
  12855. }
  12856. // Gid returns the value of the "gid" field in the mutation.
  12857. func (m *ContactMutation) Gid() (r string, exists bool) {
  12858. v := m.gid
  12859. if v == nil {
  12860. return
  12861. }
  12862. return *v, true
  12863. }
  12864. // OldGid returns the old "gid" field's value of the Contact entity.
  12865. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12867. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  12868. if !m.op.Is(OpUpdateOne) {
  12869. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  12870. }
  12871. if m.id == nil || m.oldValue == nil {
  12872. return v, errors.New("OldGid requires an ID field in the mutation")
  12873. }
  12874. oldValue, err := m.oldValue(ctx)
  12875. if err != nil {
  12876. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  12877. }
  12878. return oldValue.Gid, nil
  12879. }
  12880. // ResetGid resets all changes to the "gid" field.
  12881. func (m *ContactMutation) ResetGid() {
  12882. m.gid = nil
  12883. }
  12884. // SetGname sets the "gname" field.
  12885. func (m *ContactMutation) SetGname(s string) {
  12886. m.gname = &s
  12887. }
  12888. // Gname returns the value of the "gname" field in the mutation.
  12889. func (m *ContactMutation) Gname() (r string, exists bool) {
  12890. v := m.gname
  12891. if v == nil {
  12892. return
  12893. }
  12894. return *v, true
  12895. }
  12896. // OldGname returns the old "gname" field's value of the Contact entity.
  12897. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12899. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  12900. if !m.op.Is(OpUpdateOne) {
  12901. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  12902. }
  12903. if m.id == nil || m.oldValue == nil {
  12904. return v, errors.New("OldGname requires an ID field in the mutation")
  12905. }
  12906. oldValue, err := m.oldValue(ctx)
  12907. if err != nil {
  12908. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  12909. }
  12910. return oldValue.Gname, nil
  12911. }
  12912. // ResetGname resets all changes to the "gname" field.
  12913. func (m *ContactMutation) ResetGname() {
  12914. m.gname = nil
  12915. }
  12916. // SetV3 sets the "v3" field.
  12917. func (m *ContactMutation) SetV3(s string) {
  12918. m.v3 = &s
  12919. }
  12920. // V3 returns the value of the "v3" field in the mutation.
  12921. func (m *ContactMutation) V3() (r string, exists bool) {
  12922. v := m.v3
  12923. if v == nil {
  12924. return
  12925. }
  12926. return *v, true
  12927. }
  12928. // OldV3 returns the old "v3" field's value of the Contact entity.
  12929. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12931. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  12932. if !m.op.Is(OpUpdateOne) {
  12933. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  12934. }
  12935. if m.id == nil || m.oldValue == nil {
  12936. return v, errors.New("OldV3 requires an ID field in the mutation")
  12937. }
  12938. oldValue, err := m.oldValue(ctx)
  12939. if err != nil {
  12940. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  12941. }
  12942. return oldValue.V3, nil
  12943. }
  12944. // ResetV3 resets all changes to the "v3" field.
  12945. func (m *ContactMutation) ResetV3() {
  12946. m.v3 = nil
  12947. }
  12948. // SetOrganizationID sets the "organization_id" field.
  12949. func (m *ContactMutation) SetOrganizationID(u uint64) {
  12950. m.organization_id = &u
  12951. m.addorganization_id = nil
  12952. }
  12953. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12954. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  12955. v := m.organization_id
  12956. if v == nil {
  12957. return
  12958. }
  12959. return *v, true
  12960. }
  12961. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  12962. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  12963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12964. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12965. if !m.op.Is(OpUpdateOne) {
  12966. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12967. }
  12968. if m.id == nil || m.oldValue == nil {
  12969. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12970. }
  12971. oldValue, err := m.oldValue(ctx)
  12972. if err != nil {
  12973. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12974. }
  12975. return oldValue.OrganizationID, nil
  12976. }
  12977. // AddOrganizationID adds u to the "organization_id" field.
  12978. func (m *ContactMutation) AddOrganizationID(u int64) {
  12979. if m.addorganization_id != nil {
  12980. *m.addorganization_id += u
  12981. } else {
  12982. m.addorganization_id = &u
  12983. }
  12984. }
  12985. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12986. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  12987. v := m.addorganization_id
  12988. if v == nil {
  12989. return
  12990. }
  12991. return *v, true
  12992. }
  12993. // ClearOrganizationID clears the value of the "organization_id" field.
  12994. func (m *ContactMutation) ClearOrganizationID() {
  12995. m.organization_id = nil
  12996. m.addorganization_id = nil
  12997. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  12998. }
  12999. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13000. func (m *ContactMutation) OrganizationIDCleared() bool {
  13001. _, ok := m.clearedFields[contact.FieldOrganizationID]
  13002. return ok
  13003. }
  13004. // ResetOrganizationID resets all changes to the "organization_id" field.
  13005. func (m *ContactMutation) ResetOrganizationID() {
  13006. m.organization_id = nil
  13007. m.addorganization_id = nil
  13008. delete(m.clearedFields, contact.FieldOrganizationID)
  13009. }
  13010. // SetCtype sets the "ctype" field.
  13011. func (m *ContactMutation) SetCtype(u uint64) {
  13012. m.ctype = &u
  13013. m.addctype = nil
  13014. }
  13015. // Ctype returns the value of the "ctype" field in the mutation.
  13016. func (m *ContactMutation) Ctype() (r uint64, exists bool) {
  13017. v := m.ctype
  13018. if v == nil {
  13019. return
  13020. }
  13021. return *v, true
  13022. }
  13023. // OldCtype returns the old "ctype" field's value of the Contact entity.
  13024. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13026. func (m *ContactMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  13027. if !m.op.Is(OpUpdateOne) {
  13028. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  13029. }
  13030. if m.id == nil || m.oldValue == nil {
  13031. return v, errors.New("OldCtype requires an ID field in the mutation")
  13032. }
  13033. oldValue, err := m.oldValue(ctx)
  13034. if err != nil {
  13035. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  13036. }
  13037. return oldValue.Ctype, nil
  13038. }
  13039. // AddCtype adds u to the "ctype" field.
  13040. func (m *ContactMutation) AddCtype(u int64) {
  13041. if m.addctype != nil {
  13042. *m.addctype += u
  13043. } else {
  13044. m.addctype = &u
  13045. }
  13046. }
  13047. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  13048. func (m *ContactMutation) AddedCtype() (r int64, exists bool) {
  13049. v := m.addctype
  13050. if v == nil {
  13051. return
  13052. }
  13053. return *v, true
  13054. }
  13055. // ResetCtype resets all changes to the "ctype" field.
  13056. func (m *ContactMutation) ResetCtype() {
  13057. m.ctype = nil
  13058. m.addctype = nil
  13059. }
  13060. // SetCage sets the "cage" field.
  13061. func (m *ContactMutation) SetCage(i int) {
  13062. m.cage = &i
  13063. m.addcage = nil
  13064. }
  13065. // Cage returns the value of the "cage" field in the mutation.
  13066. func (m *ContactMutation) Cage() (r int, exists bool) {
  13067. v := m.cage
  13068. if v == nil {
  13069. return
  13070. }
  13071. return *v, true
  13072. }
  13073. // OldCage returns the old "cage" field's value of the Contact entity.
  13074. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13076. func (m *ContactMutation) OldCage(ctx context.Context) (v int, err error) {
  13077. if !m.op.Is(OpUpdateOne) {
  13078. return v, errors.New("OldCage is only allowed on UpdateOne operations")
  13079. }
  13080. if m.id == nil || m.oldValue == nil {
  13081. return v, errors.New("OldCage requires an ID field in the mutation")
  13082. }
  13083. oldValue, err := m.oldValue(ctx)
  13084. if err != nil {
  13085. return v, fmt.Errorf("querying old value for OldCage: %w", err)
  13086. }
  13087. return oldValue.Cage, nil
  13088. }
  13089. // AddCage adds i to the "cage" field.
  13090. func (m *ContactMutation) AddCage(i int) {
  13091. if m.addcage != nil {
  13092. *m.addcage += i
  13093. } else {
  13094. m.addcage = &i
  13095. }
  13096. }
  13097. // AddedCage returns the value that was added to the "cage" field in this mutation.
  13098. func (m *ContactMutation) AddedCage() (r int, exists bool) {
  13099. v := m.addcage
  13100. if v == nil {
  13101. return
  13102. }
  13103. return *v, true
  13104. }
  13105. // ResetCage resets all changes to the "cage" field.
  13106. func (m *ContactMutation) ResetCage() {
  13107. m.cage = nil
  13108. m.addcage = nil
  13109. }
  13110. // SetCname sets the "cname" field.
  13111. func (m *ContactMutation) SetCname(s string) {
  13112. m.cname = &s
  13113. }
  13114. // Cname returns the value of the "cname" field in the mutation.
  13115. func (m *ContactMutation) Cname() (r string, exists bool) {
  13116. v := m.cname
  13117. if v == nil {
  13118. return
  13119. }
  13120. return *v, true
  13121. }
  13122. // OldCname returns the old "cname" field's value of the Contact entity.
  13123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13125. func (m *ContactMutation) OldCname(ctx context.Context) (v string, err error) {
  13126. if !m.op.Is(OpUpdateOne) {
  13127. return v, errors.New("OldCname is only allowed on UpdateOne operations")
  13128. }
  13129. if m.id == nil || m.oldValue == nil {
  13130. return v, errors.New("OldCname requires an ID field in the mutation")
  13131. }
  13132. oldValue, err := m.oldValue(ctx)
  13133. if err != nil {
  13134. return v, fmt.Errorf("querying old value for OldCname: %w", err)
  13135. }
  13136. return oldValue.Cname, nil
  13137. }
  13138. // ResetCname resets all changes to the "cname" field.
  13139. func (m *ContactMutation) ResetCname() {
  13140. m.cname = nil
  13141. }
  13142. // SetCarea sets the "carea" field.
  13143. func (m *ContactMutation) SetCarea(s string) {
  13144. m.carea = &s
  13145. }
  13146. // Carea returns the value of the "carea" field in the mutation.
  13147. func (m *ContactMutation) Carea() (r string, exists bool) {
  13148. v := m.carea
  13149. if v == nil {
  13150. return
  13151. }
  13152. return *v, true
  13153. }
  13154. // OldCarea returns the old "carea" field's value of the Contact entity.
  13155. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13157. func (m *ContactMutation) OldCarea(ctx context.Context) (v string, err error) {
  13158. if !m.op.Is(OpUpdateOne) {
  13159. return v, errors.New("OldCarea is only allowed on UpdateOne operations")
  13160. }
  13161. if m.id == nil || m.oldValue == nil {
  13162. return v, errors.New("OldCarea requires an ID field in the mutation")
  13163. }
  13164. oldValue, err := m.oldValue(ctx)
  13165. if err != nil {
  13166. return v, fmt.Errorf("querying old value for OldCarea: %w", err)
  13167. }
  13168. return oldValue.Carea, nil
  13169. }
  13170. // ResetCarea resets all changes to the "carea" field.
  13171. func (m *ContactMutation) ResetCarea() {
  13172. m.carea = nil
  13173. }
  13174. // SetCbirthday sets the "cbirthday" field.
  13175. func (m *ContactMutation) SetCbirthday(s string) {
  13176. m.cbirthday = &s
  13177. }
  13178. // Cbirthday returns the value of the "cbirthday" field in the mutation.
  13179. func (m *ContactMutation) Cbirthday() (r string, exists bool) {
  13180. v := m.cbirthday
  13181. if v == nil {
  13182. return
  13183. }
  13184. return *v, true
  13185. }
  13186. // OldCbirthday returns the old "cbirthday" field's value of the Contact entity.
  13187. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13189. func (m *ContactMutation) OldCbirthday(ctx context.Context) (v string, err error) {
  13190. if !m.op.Is(OpUpdateOne) {
  13191. return v, errors.New("OldCbirthday is only allowed on UpdateOne operations")
  13192. }
  13193. if m.id == nil || m.oldValue == nil {
  13194. return v, errors.New("OldCbirthday requires an ID field in the mutation")
  13195. }
  13196. oldValue, err := m.oldValue(ctx)
  13197. if err != nil {
  13198. return v, fmt.Errorf("querying old value for OldCbirthday: %w", err)
  13199. }
  13200. return oldValue.Cbirthday, nil
  13201. }
  13202. // ResetCbirthday resets all changes to the "cbirthday" field.
  13203. func (m *ContactMutation) ResetCbirthday() {
  13204. m.cbirthday = nil
  13205. }
  13206. // SetCbirtharea sets the "cbirtharea" field.
  13207. func (m *ContactMutation) SetCbirtharea(s string) {
  13208. m.cbirtharea = &s
  13209. }
  13210. // Cbirtharea returns the value of the "cbirtharea" field in the mutation.
  13211. func (m *ContactMutation) Cbirtharea() (r string, exists bool) {
  13212. v := m.cbirtharea
  13213. if v == nil {
  13214. return
  13215. }
  13216. return *v, true
  13217. }
  13218. // OldCbirtharea returns the old "cbirtharea" field's value of the Contact entity.
  13219. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13221. func (m *ContactMutation) OldCbirtharea(ctx context.Context) (v string, err error) {
  13222. if !m.op.Is(OpUpdateOne) {
  13223. return v, errors.New("OldCbirtharea is only allowed on UpdateOne operations")
  13224. }
  13225. if m.id == nil || m.oldValue == nil {
  13226. return v, errors.New("OldCbirtharea requires an ID field in the mutation")
  13227. }
  13228. oldValue, err := m.oldValue(ctx)
  13229. if err != nil {
  13230. return v, fmt.Errorf("querying old value for OldCbirtharea: %w", err)
  13231. }
  13232. return oldValue.Cbirtharea, nil
  13233. }
  13234. // ResetCbirtharea resets all changes to the "cbirtharea" field.
  13235. func (m *ContactMutation) ResetCbirtharea() {
  13236. m.cbirtharea = nil
  13237. }
  13238. // SetCidcardNo sets the "cidcard_no" field.
  13239. func (m *ContactMutation) SetCidcardNo(s string) {
  13240. m.cidcard_no = &s
  13241. }
  13242. // CidcardNo returns the value of the "cidcard_no" field in the mutation.
  13243. func (m *ContactMutation) CidcardNo() (r string, exists bool) {
  13244. v := m.cidcard_no
  13245. if v == nil {
  13246. return
  13247. }
  13248. return *v, true
  13249. }
  13250. // OldCidcardNo returns the old "cidcard_no" field's value of the Contact entity.
  13251. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13253. func (m *ContactMutation) OldCidcardNo(ctx context.Context) (v string, err error) {
  13254. if !m.op.Is(OpUpdateOne) {
  13255. return v, errors.New("OldCidcardNo is only allowed on UpdateOne operations")
  13256. }
  13257. if m.id == nil || m.oldValue == nil {
  13258. return v, errors.New("OldCidcardNo requires an ID field in the mutation")
  13259. }
  13260. oldValue, err := m.oldValue(ctx)
  13261. if err != nil {
  13262. return v, fmt.Errorf("querying old value for OldCidcardNo: %w", err)
  13263. }
  13264. return oldValue.CidcardNo, nil
  13265. }
  13266. // ResetCidcardNo resets all changes to the "cidcard_no" field.
  13267. func (m *ContactMutation) ResetCidcardNo() {
  13268. m.cidcard_no = nil
  13269. }
  13270. // SetCtitle sets the "ctitle" field.
  13271. func (m *ContactMutation) SetCtitle(s string) {
  13272. m.ctitle = &s
  13273. }
  13274. // Ctitle returns the value of the "ctitle" field in the mutation.
  13275. func (m *ContactMutation) Ctitle() (r string, exists bool) {
  13276. v := m.ctitle
  13277. if v == nil {
  13278. return
  13279. }
  13280. return *v, true
  13281. }
  13282. // OldCtitle returns the old "ctitle" field's value of the Contact entity.
  13283. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13285. func (m *ContactMutation) OldCtitle(ctx context.Context) (v string, err error) {
  13286. if !m.op.Is(OpUpdateOne) {
  13287. return v, errors.New("OldCtitle is only allowed on UpdateOne operations")
  13288. }
  13289. if m.id == nil || m.oldValue == nil {
  13290. return v, errors.New("OldCtitle requires an ID field in the mutation")
  13291. }
  13292. oldValue, err := m.oldValue(ctx)
  13293. if err != nil {
  13294. return v, fmt.Errorf("querying old value for OldCtitle: %w", err)
  13295. }
  13296. return oldValue.Ctitle, nil
  13297. }
  13298. // ResetCtitle resets all changes to the "ctitle" field.
  13299. func (m *ContactMutation) ResetCtitle() {
  13300. m.ctitle = nil
  13301. }
  13302. // SetCc sets the "cc" field.
  13303. func (m *ContactMutation) SetCc(s string) {
  13304. m.cc = &s
  13305. }
  13306. // Cc returns the value of the "cc" field in the mutation.
  13307. func (m *ContactMutation) Cc() (r string, exists bool) {
  13308. v := m.cc
  13309. if v == nil {
  13310. return
  13311. }
  13312. return *v, true
  13313. }
  13314. // OldCc returns the old "cc" field's value of the Contact entity.
  13315. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13316. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13317. func (m *ContactMutation) OldCc(ctx context.Context) (v string, err error) {
  13318. if !m.op.Is(OpUpdateOne) {
  13319. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  13320. }
  13321. if m.id == nil || m.oldValue == nil {
  13322. return v, errors.New("OldCc requires an ID field in the mutation")
  13323. }
  13324. oldValue, err := m.oldValue(ctx)
  13325. if err != nil {
  13326. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  13327. }
  13328. return oldValue.Cc, nil
  13329. }
  13330. // ResetCc resets all changes to the "cc" field.
  13331. func (m *ContactMutation) ResetCc() {
  13332. m.cc = nil
  13333. }
  13334. // SetPhone sets the "phone" field.
  13335. func (m *ContactMutation) SetPhone(s string) {
  13336. m.phone = &s
  13337. }
  13338. // Phone returns the value of the "phone" field in the mutation.
  13339. func (m *ContactMutation) Phone() (r string, exists bool) {
  13340. v := m.phone
  13341. if v == nil {
  13342. return
  13343. }
  13344. return *v, true
  13345. }
  13346. // OldPhone returns the old "phone" field's value of the Contact entity.
  13347. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  13348. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13349. func (m *ContactMutation) OldPhone(ctx context.Context) (v string, err error) {
  13350. if !m.op.Is(OpUpdateOne) {
  13351. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  13352. }
  13353. if m.id == nil || m.oldValue == nil {
  13354. return v, errors.New("OldPhone requires an ID field in the mutation")
  13355. }
  13356. oldValue, err := m.oldValue(ctx)
  13357. if err != nil {
  13358. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  13359. }
  13360. return oldValue.Phone, nil
  13361. }
  13362. // ResetPhone resets all changes to the "phone" field.
  13363. func (m *ContactMutation) ResetPhone() {
  13364. m.phone = nil
  13365. }
  13366. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  13367. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  13368. if m.contact_relationships == nil {
  13369. m.contact_relationships = make(map[uint64]struct{})
  13370. }
  13371. for i := range ids {
  13372. m.contact_relationships[ids[i]] = struct{}{}
  13373. }
  13374. }
  13375. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  13376. func (m *ContactMutation) ClearContactRelationships() {
  13377. m.clearedcontact_relationships = true
  13378. }
  13379. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  13380. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  13381. return m.clearedcontact_relationships
  13382. }
  13383. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  13384. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  13385. if m.removedcontact_relationships == nil {
  13386. m.removedcontact_relationships = make(map[uint64]struct{})
  13387. }
  13388. for i := range ids {
  13389. delete(m.contact_relationships, ids[i])
  13390. m.removedcontact_relationships[ids[i]] = struct{}{}
  13391. }
  13392. }
  13393. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  13394. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  13395. for id := range m.removedcontact_relationships {
  13396. ids = append(ids, id)
  13397. }
  13398. return
  13399. }
  13400. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  13401. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  13402. for id := range m.contact_relationships {
  13403. ids = append(ids, id)
  13404. }
  13405. return
  13406. }
  13407. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  13408. func (m *ContactMutation) ResetContactRelationships() {
  13409. m.contact_relationships = nil
  13410. m.clearedcontact_relationships = false
  13411. m.removedcontact_relationships = nil
  13412. }
  13413. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
  13414. func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
  13415. if m.contact_fields == nil {
  13416. m.contact_fields = make(map[uint64]struct{})
  13417. }
  13418. for i := range ids {
  13419. m.contact_fields[ids[i]] = struct{}{}
  13420. }
  13421. }
  13422. // ClearContactFields clears the "contact_fields" edge to the ContactField entity.
  13423. func (m *ContactMutation) ClearContactFields() {
  13424. m.clearedcontact_fields = true
  13425. }
  13426. // ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
  13427. func (m *ContactMutation) ContactFieldsCleared() bool {
  13428. return m.clearedcontact_fields
  13429. }
  13430. // RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
  13431. func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
  13432. if m.removedcontact_fields == nil {
  13433. m.removedcontact_fields = make(map[uint64]struct{})
  13434. }
  13435. for i := range ids {
  13436. delete(m.contact_fields, ids[i])
  13437. m.removedcontact_fields[ids[i]] = struct{}{}
  13438. }
  13439. }
  13440. // RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
  13441. func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
  13442. for id := range m.removedcontact_fields {
  13443. ids = append(ids, id)
  13444. }
  13445. return
  13446. }
  13447. // ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
  13448. func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
  13449. for id := range m.contact_fields {
  13450. ids = append(ids, id)
  13451. }
  13452. return
  13453. }
  13454. // ResetContactFields resets all changes to the "contact_fields" edge.
  13455. func (m *ContactMutation) ResetContactFields() {
  13456. m.contact_fields = nil
  13457. m.clearedcontact_fields = false
  13458. m.removedcontact_fields = nil
  13459. }
  13460. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  13461. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  13462. if m.contact_messages == nil {
  13463. m.contact_messages = make(map[uint64]struct{})
  13464. }
  13465. for i := range ids {
  13466. m.contact_messages[ids[i]] = struct{}{}
  13467. }
  13468. }
  13469. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  13470. func (m *ContactMutation) ClearContactMessages() {
  13471. m.clearedcontact_messages = true
  13472. }
  13473. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  13474. func (m *ContactMutation) ContactMessagesCleared() bool {
  13475. return m.clearedcontact_messages
  13476. }
  13477. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  13478. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  13479. if m.removedcontact_messages == nil {
  13480. m.removedcontact_messages = make(map[uint64]struct{})
  13481. }
  13482. for i := range ids {
  13483. delete(m.contact_messages, ids[i])
  13484. m.removedcontact_messages[ids[i]] = struct{}{}
  13485. }
  13486. }
  13487. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  13488. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  13489. for id := range m.removedcontact_messages {
  13490. ids = append(ids, id)
  13491. }
  13492. return
  13493. }
  13494. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  13495. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  13496. for id := range m.contact_messages {
  13497. ids = append(ids, id)
  13498. }
  13499. return
  13500. }
  13501. // ResetContactMessages resets all changes to the "contact_messages" edge.
  13502. func (m *ContactMutation) ResetContactMessages() {
  13503. m.contact_messages = nil
  13504. m.clearedcontact_messages = false
  13505. m.removedcontact_messages = nil
  13506. }
  13507. // Where appends a list predicates to the ContactMutation builder.
  13508. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  13509. m.predicates = append(m.predicates, ps...)
  13510. }
  13511. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  13512. // users can use type-assertion to append predicates that do not depend on any generated package.
  13513. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  13514. p := make([]predicate.Contact, len(ps))
  13515. for i := range ps {
  13516. p[i] = ps[i]
  13517. }
  13518. m.Where(p...)
  13519. }
  13520. // Op returns the operation name.
  13521. func (m *ContactMutation) Op() Op {
  13522. return m.op
  13523. }
  13524. // SetOp allows setting the mutation operation.
  13525. func (m *ContactMutation) SetOp(op Op) {
  13526. m.op = op
  13527. }
  13528. // Type returns the node type of this mutation (Contact).
  13529. func (m *ContactMutation) Type() string {
  13530. return m.typ
  13531. }
  13532. // Fields returns all fields that were changed during this mutation. Note that in
  13533. // order to get all numeric fields that were incremented/decremented, call
  13534. // AddedFields().
  13535. func (m *ContactMutation) Fields() []string {
  13536. fields := make([]string, 0, 30)
  13537. if m.created_at != nil {
  13538. fields = append(fields, contact.FieldCreatedAt)
  13539. }
  13540. if m.updated_at != nil {
  13541. fields = append(fields, contact.FieldUpdatedAt)
  13542. }
  13543. if m.status != nil {
  13544. fields = append(fields, contact.FieldStatus)
  13545. }
  13546. if m.deleted_at != nil {
  13547. fields = append(fields, contact.FieldDeletedAt)
  13548. }
  13549. if m.wx_wxid != nil {
  13550. fields = append(fields, contact.FieldWxWxid)
  13551. }
  13552. if m._type != nil {
  13553. fields = append(fields, contact.FieldType)
  13554. }
  13555. if m.wxid != nil {
  13556. fields = append(fields, contact.FieldWxid)
  13557. }
  13558. if m.account != nil {
  13559. fields = append(fields, contact.FieldAccount)
  13560. }
  13561. if m.nickname != nil {
  13562. fields = append(fields, contact.FieldNickname)
  13563. }
  13564. if m.markname != nil {
  13565. fields = append(fields, contact.FieldMarkname)
  13566. }
  13567. if m.headimg != nil {
  13568. fields = append(fields, contact.FieldHeadimg)
  13569. }
  13570. if m.sex != nil {
  13571. fields = append(fields, contact.FieldSex)
  13572. }
  13573. if m.starrole != nil {
  13574. fields = append(fields, contact.FieldStarrole)
  13575. }
  13576. if m.dontseeit != nil {
  13577. fields = append(fields, contact.FieldDontseeit)
  13578. }
  13579. if m.dontseeme != nil {
  13580. fields = append(fields, contact.FieldDontseeme)
  13581. }
  13582. if m.lag != nil {
  13583. fields = append(fields, contact.FieldLag)
  13584. }
  13585. if m.gid != nil {
  13586. fields = append(fields, contact.FieldGid)
  13587. }
  13588. if m.gname != nil {
  13589. fields = append(fields, contact.FieldGname)
  13590. }
  13591. if m.v3 != nil {
  13592. fields = append(fields, contact.FieldV3)
  13593. }
  13594. if m.organization_id != nil {
  13595. fields = append(fields, contact.FieldOrganizationID)
  13596. }
  13597. if m.ctype != nil {
  13598. fields = append(fields, contact.FieldCtype)
  13599. }
  13600. if m.cage != nil {
  13601. fields = append(fields, contact.FieldCage)
  13602. }
  13603. if m.cname != nil {
  13604. fields = append(fields, contact.FieldCname)
  13605. }
  13606. if m.carea != nil {
  13607. fields = append(fields, contact.FieldCarea)
  13608. }
  13609. if m.cbirthday != nil {
  13610. fields = append(fields, contact.FieldCbirthday)
  13611. }
  13612. if m.cbirtharea != nil {
  13613. fields = append(fields, contact.FieldCbirtharea)
  13614. }
  13615. if m.cidcard_no != nil {
  13616. fields = append(fields, contact.FieldCidcardNo)
  13617. }
  13618. if m.ctitle != nil {
  13619. fields = append(fields, contact.FieldCtitle)
  13620. }
  13621. if m.cc != nil {
  13622. fields = append(fields, contact.FieldCc)
  13623. }
  13624. if m.phone != nil {
  13625. fields = append(fields, contact.FieldPhone)
  13626. }
  13627. return fields
  13628. }
  13629. // Field returns the value of a field with the given name. The second boolean
  13630. // return value indicates that this field was not set, or was not defined in the
  13631. // schema.
  13632. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  13633. switch name {
  13634. case contact.FieldCreatedAt:
  13635. return m.CreatedAt()
  13636. case contact.FieldUpdatedAt:
  13637. return m.UpdatedAt()
  13638. case contact.FieldStatus:
  13639. return m.Status()
  13640. case contact.FieldDeletedAt:
  13641. return m.DeletedAt()
  13642. case contact.FieldWxWxid:
  13643. return m.WxWxid()
  13644. case contact.FieldType:
  13645. return m.GetType()
  13646. case contact.FieldWxid:
  13647. return m.Wxid()
  13648. case contact.FieldAccount:
  13649. return m.Account()
  13650. case contact.FieldNickname:
  13651. return m.Nickname()
  13652. case contact.FieldMarkname:
  13653. return m.Markname()
  13654. case contact.FieldHeadimg:
  13655. return m.Headimg()
  13656. case contact.FieldSex:
  13657. return m.Sex()
  13658. case contact.FieldStarrole:
  13659. return m.Starrole()
  13660. case contact.FieldDontseeit:
  13661. return m.Dontseeit()
  13662. case contact.FieldDontseeme:
  13663. return m.Dontseeme()
  13664. case contact.FieldLag:
  13665. return m.Lag()
  13666. case contact.FieldGid:
  13667. return m.Gid()
  13668. case contact.FieldGname:
  13669. return m.Gname()
  13670. case contact.FieldV3:
  13671. return m.V3()
  13672. case contact.FieldOrganizationID:
  13673. return m.OrganizationID()
  13674. case contact.FieldCtype:
  13675. return m.Ctype()
  13676. case contact.FieldCage:
  13677. return m.Cage()
  13678. case contact.FieldCname:
  13679. return m.Cname()
  13680. case contact.FieldCarea:
  13681. return m.Carea()
  13682. case contact.FieldCbirthday:
  13683. return m.Cbirthday()
  13684. case contact.FieldCbirtharea:
  13685. return m.Cbirtharea()
  13686. case contact.FieldCidcardNo:
  13687. return m.CidcardNo()
  13688. case contact.FieldCtitle:
  13689. return m.Ctitle()
  13690. case contact.FieldCc:
  13691. return m.Cc()
  13692. case contact.FieldPhone:
  13693. return m.Phone()
  13694. }
  13695. return nil, false
  13696. }
  13697. // OldField returns the old value of the field from the database. An error is
  13698. // returned if the mutation operation is not UpdateOne, or the query to the
  13699. // database failed.
  13700. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13701. switch name {
  13702. case contact.FieldCreatedAt:
  13703. return m.OldCreatedAt(ctx)
  13704. case contact.FieldUpdatedAt:
  13705. return m.OldUpdatedAt(ctx)
  13706. case contact.FieldStatus:
  13707. return m.OldStatus(ctx)
  13708. case contact.FieldDeletedAt:
  13709. return m.OldDeletedAt(ctx)
  13710. case contact.FieldWxWxid:
  13711. return m.OldWxWxid(ctx)
  13712. case contact.FieldType:
  13713. return m.OldType(ctx)
  13714. case contact.FieldWxid:
  13715. return m.OldWxid(ctx)
  13716. case contact.FieldAccount:
  13717. return m.OldAccount(ctx)
  13718. case contact.FieldNickname:
  13719. return m.OldNickname(ctx)
  13720. case contact.FieldMarkname:
  13721. return m.OldMarkname(ctx)
  13722. case contact.FieldHeadimg:
  13723. return m.OldHeadimg(ctx)
  13724. case contact.FieldSex:
  13725. return m.OldSex(ctx)
  13726. case contact.FieldStarrole:
  13727. return m.OldStarrole(ctx)
  13728. case contact.FieldDontseeit:
  13729. return m.OldDontseeit(ctx)
  13730. case contact.FieldDontseeme:
  13731. return m.OldDontseeme(ctx)
  13732. case contact.FieldLag:
  13733. return m.OldLag(ctx)
  13734. case contact.FieldGid:
  13735. return m.OldGid(ctx)
  13736. case contact.FieldGname:
  13737. return m.OldGname(ctx)
  13738. case contact.FieldV3:
  13739. return m.OldV3(ctx)
  13740. case contact.FieldOrganizationID:
  13741. return m.OldOrganizationID(ctx)
  13742. case contact.FieldCtype:
  13743. return m.OldCtype(ctx)
  13744. case contact.FieldCage:
  13745. return m.OldCage(ctx)
  13746. case contact.FieldCname:
  13747. return m.OldCname(ctx)
  13748. case contact.FieldCarea:
  13749. return m.OldCarea(ctx)
  13750. case contact.FieldCbirthday:
  13751. return m.OldCbirthday(ctx)
  13752. case contact.FieldCbirtharea:
  13753. return m.OldCbirtharea(ctx)
  13754. case contact.FieldCidcardNo:
  13755. return m.OldCidcardNo(ctx)
  13756. case contact.FieldCtitle:
  13757. return m.OldCtitle(ctx)
  13758. case contact.FieldCc:
  13759. return m.OldCc(ctx)
  13760. case contact.FieldPhone:
  13761. return m.OldPhone(ctx)
  13762. }
  13763. return nil, fmt.Errorf("unknown Contact field %s", name)
  13764. }
  13765. // SetField sets the value of a field with the given name. It returns an error if
  13766. // the field is not defined in the schema, or if the type mismatched the field
  13767. // type.
  13768. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  13769. switch name {
  13770. case contact.FieldCreatedAt:
  13771. v, ok := value.(time.Time)
  13772. if !ok {
  13773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13774. }
  13775. m.SetCreatedAt(v)
  13776. return nil
  13777. case contact.FieldUpdatedAt:
  13778. v, ok := value.(time.Time)
  13779. if !ok {
  13780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13781. }
  13782. m.SetUpdatedAt(v)
  13783. return nil
  13784. case contact.FieldStatus:
  13785. v, ok := value.(uint8)
  13786. if !ok {
  13787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13788. }
  13789. m.SetStatus(v)
  13790. return nil
  13791. case contact.FieldDeletedAt:
  13792. v, ok := value.(time.Time)
  13793. if !ok {
  13794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13795. }
  13796. m.SetDeletedAt(v)
  13797. return nil
  13798. case contact.FieldWxWxid:
  13799. v, ok := value.(string)
  13800. if !ok {
  13801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13802. }
  13803. m.SetWxWxid(v)
  13804. return nil
  13805. case contact.FieldType:
  13806. v, ok := value.(int)
  13807. if !ok {
  13808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13809. }
  13810. m.SetType(v)
  13811. return nil
  13812. case contact.FieldWxid:
  13813. v, ok := value.(string)
  13814. if !ok {
  13815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13816. }
  13817. m.SetWxid(v)
  13818. return nil
  13819. case contact.FieldAccount:
  13820. v, ok := value.(string)
  13821. if !ok {
  13822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13823. }
  13824. m.SetAccount(v)
  13825. return nil
  13826. case contact.FieldNickname:
  13827. v, ok := value.(string)
  13828. if !ok {
  13829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13830. }
  13831. m.SetNickname(v)
  13832. return nil
  13833. case contact.FieldMarkname:
  13834. v, ok := value.(string)
  13835. if !ok {
  13836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13837. }
  13838. m.SetMarkname(v)
  13839. return nil
  13840. case contact.FieldHeadimg:
  13841. v, ok := value.(string)
  13842. if !ok {
  13843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13844. }
  13845. m.SetHeadimg(v)
  13846. return nil
  13847. case contact.FieldSex:
  13848. v, ok := value.(int)
  13849. if !ok {
  13850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13851. }
  13852. m.SetSex(v)
  13853. return nil
  13854. case contact.FieldStarrole:
  13855. v, ok := value.(string)
  13856. if !ok {
  13857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13858. }
  13859. m.SetStarrole(v)
  13860. return nil
  13861. case contact.FieldDontseeit:
  13862. v, ok := value.(int)
  13863. if !ok {
  13864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13865. }
  13866. m.SetDontseeit(v)
  13867. return nil
  13868. case contact.FieldDontseeme:
  13869. v, ok := value.(int)
  13870. if !ok {
  13871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13872. }
  13873. m.SetDontseeme(v)
  13874. return nil
  13875. case contact.FieldLag:
  13876. v, ok := value.(string)
  13877. if !ok {
  13878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13879. }
  13880. m.SetLag(v)
  13881. return nil
  13882. case contact.FieldGid:
  13883. v, ok := value.(string)
  13884. if !ok {
  13885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13886. }
  13887. m.SetGid(v)
  13888. return nil
  13889. case contact.FieldGname:
  13890. v, ok := value.(string)
  13891. if !ok {
  13892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13893. }
  13894. m.SetGname(v)
  13895. return nil
  13896. case contact.FieldV3:
  13897. v, ok := value.(string)
  13898. if !ok {
  13899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13900. }
  13901. m.SetV3(v)
  13902. return nil
  13903. case contact.FieldOrganizationID:
  13904. v, ok := value.(uint64)
  13905. if !ok {
  13906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13907. }
  13908. m.SetOrganizationID(v)
  13909. return nil
  13910. case contact.FieldCtype:
  13911. v, ok := value.(uint64)
  13912. if !ok {
  13913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13914. }
  13915. m.SetCtype(v)
  13916. return nil
  13917. case contact.FieldCage:
  13918. v, ok := value.(int)
  13919. if !ok {
  13920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13921. }
  13922. m.SetCage(v)
  13923. return nil
  13924. case contact.FieldCname:
  13925. v, ok := value.(string)
  13926. if !ok {
  13927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13928. }
  13929. m.SetCname(v)
  13930. return nil
  13931. case contact.FieldCarea:
  13932. v, ok := value.(string)
  13933. if !ok {
  13934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13935. }
  13936. m.SetCarea(v)
  13937. return nil
  13938. case contact.FieldCbirthday:
  13939. v, ok := value.(string)
  13940. if !ok {
  13941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13942. }
  13943. m.SetCbirthday(v)
  13944. return nil
  13945. case contact.FieldCbirtharea:
  13946. v, ok := value.(string)
  13947. if !ok {
  13948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13949. }
  13950. m.SetCbirtharea(v)
  13951. return nil
  13952. case contact.FieldCidcardNo:
  13953. v, ok := value.(string)
  13954. if !ok {
  13955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13956. }
  13957. m.SetCidcardNo(v)
  13958. return nil
  13959. case contact.FieldCtitle:
  13960. v, ok := value.(string)
  13961. if !ok {
  13962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13963. }
  13964. m.SetCtitle(v)
  13965. return nil
  13966. case contact.FieldCc:
  13967. v, ok := value.(string)
  13968. if !ok {
  13969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13970. }
  13971. m.SetCc(v)
  13972. return nil
  13973. case contact.FieldPhone:
  13974. v, ok := value.(string)
  13975. if !ok {
  13976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13977. }
  13978. m.SetPhone(v)
  13979. return nil
  13980. }
  13981. return fmt.Errorf("unknown Contact field %s", name)
  13982. }
  13983. // AddedFields returns all numeric fields that were incremented/decremented during
  13984. // this mutation.
  13985. func (m *ContactMutation) AddedFields() []string {
  13986. var fields []string
  13987. if m.addstatus != nil {
  13988. fields = append(fields, contact.FieldStatus)
  13989. }
  13990. if m.add_type != nil {
  13991. fields = append(fields, contact.FieldType)
  13992. }
  13993. if m.addsex != nil {
  13994. fields = append(fields, contact.FieldSex)
  13995. }
  13996. if m.adddontseeit != nil {
  13997. fields = append(fields, contact.FieldDontseeit)
  13998. }
  13999. if m.adddontseeme != nil {
  14000. fields = append(fields, contact.FieldDontseeme)
  14001. }
  14002. if m.addorganization_id != nil {
  14003. fields = append(fields, contact.FieldOrganizationID)
  14004. }
  14005. if m.addctype != nil {
  14006. fields = append(fields, contact.FieldCtype)
  14007. }
  14008. if m.addcage != nil {
  14009. fields = append(fields, contact.FieldCage)
  14010. }
  14011. return fields
  14012. }
  14013. // AddedField returns the numeric value that was incremented/decremented on a field
  14014. // with the given name. The second boolean return value indicates that this field
  14015. // was not set, or was not defined in the schema.
  14016. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  14017. switch name {
  14018. case contact.FieldStatus:
  14019. return m.AddedStatus()
  14020. case contact.FieldType:
  14021. return m.AddedType()
  14022. case contact.FieldSex:
  14023. return m.AddedSex()
  14024. case contact.FieldDontseeit:
  14025. return m.AddedDontseeit()
  14026. case contact.FieldDontseeme:
  14027. return m.AddedDontseeme()
  14028. case contact.FieldOrganizationID:
  14029. return m.AddedOrganizationID()
  14030. case contact.FieldCtype:
  14031. return m.AddedCtype()
  14032. case contact.FieldCage:
  14033. return m.AddedCage()
  14034. }
  14035. return nil, false
  14036. }
  14037. // AddField adds the value to the field with the given name. It returns an error if
  14038. // the field is not defined in the schema, or if the type mismatched the field
  14039. // type.
  14040. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  14041. switch name {
  14042. case contact.FieldStatus:
  14043. v, ok := value.(int8)
  14044. if !ok {
  14045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14046. }
  14047. m.AddStatus(v)
  14048. return nil
  14049. case contact.FieldType:
  14050. v, ok := value.(int)
  14051. if !ok {
  14052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14053. }
  14054. m.AddType(v)
  14055. return nil
  14056. case contact.FieldSex:
  14057. v, ok := value.(int)
  14058. if !ok {
  14059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14060. }
  14061. m.AddSex(v)
  14062. return nil
  14063. case contact.FieldDontseeit:
  14064. v, ok := value.(int)
  14065. if !ok {
  14066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14067. }
  14068. m.AddDontseeit(v)
  14069. return nil
  14070. case contact.FieldDontseeme:
  14071. v, ok := value.(int)
  14072. if !ok {
  14073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14074. }
  14075. m.AddDontseeme(v)
  14076. return nil
  14077. case contact.FieldOrganizationID:
  14078. v, ok := value.(int64)
  14079. if !ok {
  14080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14081. }
  14082. m.AddOrganizationID(v)
  14083. return nil
  14084. case contact.FieldCtype:
  14085. v, ok := value.(int64)
  14086. if !ok {
  14087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14088. }
  14089. m.AddCtype(v)
  14090. return nil
  14091. case contact.FieldCage:
  14092. v, ok := value.(int)
  14093. if !ok {
  14094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14095. }
  14096. m.AddCage(v)
  14097. return nil
  14098. }
  14099. return fmt.Errorf("unknown Contact numeric field %s", name)
  14100. }
  14101. // ClearedFields returns all nullable fields that were cleared during this
  14102. // mutation.
  14103. func (m *ContactMutation) ClearedFields() []string {
  14104. var fields []string
  14105. if m.FieldCleared(contact.FieldStatus) {
  14106. fields = append(fields, contact.FieldStatus)
  14107. }
  14108. if m.FieldCleared(contact.FieldDeletedAt) {
  14109. fields = append(fields, contact.FieldDeletedAt)
  14110. }
  14111. if m.FieldCleared(contact.FieldType) {
  14112. fields = append(fields, contact.FieldType)
  14113. }
  14114. if m.FieldCleared(contact.FieldOrganizationID) {
  14115. fields = append(fields, contact.FieldOrganizationID)
  14116. }
  14117. return fields
  14118. }
  14119. // FieldCleared returns a boolean indicating if a field with the given name was
  14120. // cleared in this mutation.
  14121. func (m *ContactMutation) FieldCleared(name string) bool {
  14122. _, ok := m.clearedFields[name]
  14123. return ok
  14124. }
  14125. // ClearField clears the value of the field with the given name. It returns an
  14126. // error if the field is not defined in the schema.
  14127. func (m *ContactMutation) ClearField(name string) error {
  14128. switch name {
  14129. case contact.FieldStatus:
  14130. m.ClearStatus()
  14131. return nil
  14132. case contact.FieldDeletedAt:
  14133. m.ClearDeletedAt()
  14134. return nil
  14135. case contact.FieldType:
  14136. m.ClearType()
  14137. return nil
  14138. case contact.FieldOrganizationID:
  14139. m.ClearOrganizationID()
  14140. return nil
  14141. }
  14142. return fmt.Errorf("unknown Contact nullable field %s", name)
  14143. }
  14144. // ResetField resets all changes in the mutation for the field with the given name.
  14145. // It returns an error if the field is not defined in the schema.
  14146. func (m *ContactMutation) ResetField(name string) error {
  14147. switch name {
  14148. case contact.FieldCreatedAt:
  14149. m.ResetCreatedAt()
  14150. return nil
  14151. case contact.FieldUpdatedAt:
  14152. m.ResetUpdatedAt()
  14153. return nil
  14154. case contact.FieldStatus:
  14155. m.ResetStatus()
  14156. return nil
  14157. case contact.FieldDeletedAt:
  14158. m.ResetDeletedAt()
  14159. return nil
  14160. case contact.FieldWxWxid:
  14161. m.ResetWxWxid()
  14162. return nil
  14163. case contact.FieldType:
  14164. m.ResetType()
  14165. return nil
  14166. case contact.FieldWxid:
  14167. m.ResetWxid()
  14168. return nil
  14169. case contact.FieldAccount:
  14170. m.ResetAccount()
  14171. return nil
  14172. case contact.FieldNickname:
  14173. m.ResetNickname()
  14174. return nil
  14175. case contact.FieldMarkname:
  14176. m.ResetMarkname()
  14177. return nil
  14178. case contact.FieldHeadimg:
  14179. m.ResetHeadimg()
  14180. return nil
  14181. case contact.FieldSex:
  14182. m.ResetSex()
  14183. return nil
  14184. case contact.FieldStarrole:
  14185. m.ResetStarrole()
  14186. return nil
  14187. case contact.FieldDontseeit:
  14188. m.ResetDontseeit()
  14189. return nil
  14190. case contact.FieldDontseeme:
  14191. m.ResetDontseeme()
  14192. return nil
  14193. case contact.FieldLag:
  14194. m.ResetLag()
  14195. return nil
  14196. case contact.FieldGid:
  14197. m.ResetGid()
  14198. return nil
  14199. case contact.FieldGname:
  14200. m.ResetGname()
  14201. return nil
  14202. case contact.FieldV3:
  14203. m.ResetV3()
  14204. return nil
  14205. case contact.FieldOrganizationID:
  14206. m.ResetOrganizationID()
  14207. return nil
  14208. case contact.FieldCtype:
  14209. m.ResetCtype()
  14210. return nil
  14211. case contact.FieldCage:
  14212. m.ResetCage()
  14213. return nil
  14214. case contact.FieldCname:
  14215. m.ResetCname()
  14216. return nil
  14217. case contact.FieldCarea:
  14218. m.ResetCarea()
  14219. return nil
  14220. case contact.FieldCbirthday:
  14221. m.ResetCbirthday()
  14222. return nil
  14223. case contact.FieldCbirtharea:
  14224. m.ResetCbirtharea()
  14225. return nil
  14226. case contact.FieldCidcardNo:
  14227. m.ResetCidcardNo()
  14228. return nil
  14229. case contact.FieldCtitle:
  14230. m.ResetCtitle()
  14231. return nil
  14232. case contact.FieldCc:
  14233. m.ResetCc()
  14234. return nil
  14235. case contact.FieldPhone:
  14236. m.ResetPhone()
  14237. return nil
  14238. }
  14239. return fmt.Errorf("unknown Contact field %s", name)
  14240. }
  14241. // AddedEdges returns all edge names that were set/added in this mutation.
  14242. func (m *ContactMutation) AddedEdges() []string {
  14243. edges := make([]string, 0, 3)
  14244. if m.contact_relationships != nil {
  14245. edges = append(edges, contact.EdgeContactRelationships)
  14246. }
  14247. if m.contact_fields != nil {
  14248. edges = append(edges, contact.EdgeContactFields)
  14249. }
  14250. if m.contact_messages != nil {
  14251. edges = append(edges, contact.EdgeContactMessages)
  14252. }
  14253. return edges
  14254. }
  14255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14256. // name in this mutation.
  14257. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  14258. switch name {
  14259. case contact.EdgeContactRelationships:
  14260. ids := make([]ent.Value, 0, len(m.contact_relationships))
  14261. for id := range m.contact_relationships {
  14262. ids = append(ids, id)
  14263. }
  14264. return ids
  14265. case contact.EdgeContactFields:
  14266. ids := make([]ent.Value, 0, len(m.contact_fields))
  14267. for id := range m.contact_fields {
  14268. ids = append(ids, id)
  14269. }
  14270. return ids
  14271. case contact.EdgeContactMessages:
  14272. ids := make([]ent.Value, 0, len(m.contact_messages))
  14273. for id := range m.contact_messages {
  14274. ids = append(ids, id)
  14275. }
  14276. return ids
  14277. }
  14278. return nil
  14279. }
  14280. // RemovedEdges returns all edge names that were removed in this mutation.
  14281. func (m *ContactMutation) RemovedEdges() []string {
  14282. edges := make([]string, 0, 3)
  14283. if m.removedcontact_relationships != nil {
  14284. edges = append(edges, contact.EdgeContactRelationships)
  14285. }
  14286. if m.removedcontact_fields != nil {
  14287. edges = append(edges, contact.EdgeContactFields)
  14288. }
  14289. if m.removedcontact_messages != nil {
  14290. edges = append(edges, contact.EdgeContactMessages)
  14291. }
  14292. return edges
  14293. }
  14294. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14295. // the given name in this mutation.
  14296. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  14297. switch name {
  14298. case contact.EdgeContactRelationships:
  14299. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  14300. for id := range m.removedcontact_relationships {
  14301. ids = append(ids, id)
  14302. }
  14303. return ids
  14304. case contact.EdgeContactFields:
  14305. ids := make([]ent.Value, 0, len(m.removedcontact_fields))
  14306. for id := range m.removedcontact_fields {
  14307. ids = append(ids, id)
  14308. }
  14309. return ids
  14310. case contact.EdgeContactMessages:
  14311. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  14312. for id := range m.removedcontact_messages {
  14313. ids = append(ids, id)
  14314. }
  14315. return ids
  14316. }
  14317. return nil
  14318. }
  14319. // ClearedEdges returns all edge names that were cleared in this mutation.
  14320. func (m *ContactMutation) ClearedEdges() []string {
  14321. edges := make([]string, 0, 3)
  14322. if m.clearedcontact_relationships {
  14323. edges = append(edges, contact.EdgeContactRelationships)
  14324. }
  14325. if m.clearedcontact_fields {
  14326. edges = append(edges, contact.EdgeContactFields)
  14327. }
  14328. if m.clearedcontact_messages {
  14329. edges = append(edges, contact.EdgeContactMessages)
  14330. }
  14331. return edges
  14332. }
  14333. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14334. // was cleared in this mutation.
  14335. func (m *ContactMutation) EdgeCleared(name string) bool {
  14336. switch name {
  14337. case contact.EdgeContactRelationships:
  14338. return m.clearedcontact_relationships
  14339. case contact.EdgeContactFields:
  14340. return m.clearedcontact_fields
  14341. case contact.EdgeContactMessages:
  14342. return m.clearedcontact_messages
  14343. }
  14344. return false
  14345. }
  14346. // ClearEdge clears the value of the edge with the given name. It returns an error
  14347. // if that edge is not defined in the schema.
  14348. func (m *ContactMutation) ClearEdge(name string) error {
  14349. switch name {
  14350. }
  14351. return fmt.Errorf("unknown Contact unique edge %s", name)
  14352. }
  14353. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14354. // It returns an error if the edge is not defined in the schema.
  14355. func (m *ContactMutation) ResetEdge(name string) error {
  14356. switch name {
  14357. case contact.EdgeContactRelationships:
  14358. m.ResetContactRelationships()
  14359. return nil
  14360. case contact.EdgeContactFields:
  14361. m.ResetContactFields()
  14362. return nil
  14363. case contact.EdgeContactMessages:
  14364. m.ResetContactMessages()
  14365. return nil
  14366. }
  14367. return fmt.Errorf("unknown Contact edge %s", name)
  14368. }
  14369. // ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
  14370. type ContactFieldMutation struct {
  14371. config
  14372. op Op
  14373. typ string
  14374. id *uint64
  14375. created_at *time.Time
  14376. updated_at *time.Time
  14377. status *uint8
  14378. addstatus *int8
  14379. deleted_at *time.Time
  14380. form_id *string
  14381. value *[]string
  14382. appendvalue []string
  14383. clearedFields map[string]struct{}
  14384. field_contact *uint64
  14385. clearedfield_contact bool
  14386. done bool
  14387. oldValue func(context.Context) (*ContactField, error)
  14388. predicates []predicate.ContactField
  14389. }
  14390. var _ ent.Mutation = (*ContactFieldMutation)(nil)
  14391. // contactfieldOption allows management of the mutation configuration using functional options.
  14392. type contactfieldOption func(*ContactFieldMutation)
  14393. // newContactFieldMutation creates new mutation for the ContactField entity.
  14394. func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
  14395. m := &ContactFieldMutation{
  14396. config: c,
  14397. op: op,
  14398. typ: TypeContactField,
  14399. clearedFields: make(map[string]struct{}),
  14400. }
  14401. for _, opt := range opts {
  14402. opt(m)
  14403. }
  14404. return m
  14405. }
  14406. // withContactFieldID sets the ID field of the mutation.
  14407. func withContactFieldID(id uint64) contactfieldOption {
  14408. return func(m *ContactFieldMutation) {
  14409. var (
  14410. err error
  14411. once sync.Once
  14412. value *ContactField
  14413. )
  14414. m.oldValue = func(ctx context.Context) (*ContactField, error) {
  14415. once.Do(func() {
  14416. if m.done {
  14417. err = errors.New("querying old values post mutation is not allowed")
  14418. } else {
  14419. value, err = m.Client().ContactField.Get(ctx, id)
  14420. }
  14421. })
  14422. return value, err
  14423. }
  14424. m.id = &id
  14425. }
  14426. }
  14427. // withContactField sets the old ContactField of the mutation.
  14428. func withContactField(node *ContactField) contactfieldOption {
  14429. return func(m *ContactFieldMutation) {
  14430. m.oldValue = func(context.Context) (*ContactField, error) {
  14431. return node, nil
  14432. }
  14433. m.id = &node.ID
  14434. }
  14435. }
  14436. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14437. // executed in a transaction (ent.Tx), a transactional client is returned.
  14438. func (m ContactFieldMutation) Client() *Client {
  14439. client := &Client{config: m.config}
  14440. client.init()
  14441. return client
  14442. }
  14443. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14444. // it returns an error otherwise.
  14445. func (m ContactFieldMutation) Tx() (*Tx, error) {
  14446. if _, ok := m.driver.(*txDriver); !ok {
  14447. return nil, errors.New("ent: mutation is not running in a transaction")
  14448. }
  14449. tx := &Tx{config: m.config}
  14450. tx.init()
  14451. return tx, nil
  14452. }
  14453. // SetID sets the value of the id field. Note that this
  14454. // operation is only accepted on creation of ContactField entities.
  14455. func (m *ContactFieldMutation) SetID(id uint64) {
  14456. m.id = &id
  14457. }
  14458. // ID returns the ID value in the mutation. Note that the ID is only available
  14459. // if it was provided to the builder or after it was returned from the database.
  14460. func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
  14461. if m.id == nil {
  14462. return
  14463. }
  14464. return *m.id, true
  14465. }
  14466. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14467. // That means, if the mutation is applied within a transaction with an isolation level such
  14468. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14469. // or updated by the mutation.
  14470. func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
  14471. switch {
  14472. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14473. id, exists := m.ID()
  14474. if exists {
  14475. return []uint64{id}, nil
  14476. }
  14477. fallthrough
  14478. case m.op.Is(OpUpdate | OpDelete):
  14479. return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
  14480. default:
  14481. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14482. }
  14483. }
  14484. // SetCreatedAt sets the "created_at" field.
  14485. func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
  14486. m.created_at = &t
  14487. }
  14488. // CreatedAt returns the value of the "created_at" field in the mutation.
  14489. func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
  14490. v := m.created_at
  14491. if v == nil {
  14492. return
  14493. }
  14494. return *v, true
  14495. }
  14496. // OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
  14497. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14499. func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14500. if !m.op.Is(OpUpdateOne) {
  14501. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14502. }
  14503. if m.id == nil || m.oldValue == nil {
  14504. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14505. }
  14506. oldValue, err := m.oldValue(ctx)
  14507. if err != nil {
  14508. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14509. }
  14510. return oldValue.CreatedAt, nil
  14511. }
  14512. // ResetCreatedAt resets all changes to the "created_at" field.
  14513. func (m *ContactFieldMutation) ResetCreatedAt() {
  14514. m.created_at = nil
  14515. }
  14516. // SetUpdatedAt sets the "updated_at" field.
  14517. func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
  14518. m.updated_at = &t
  14519. }
  14520. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14521. func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
  14522. v := m.updated_at
  14523. if v == nil {
  14524. return
  14525. }
  14526. return *v, true
  14527. }
  14528. // OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
  14529. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14531. func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14532. if !m.op.Is(OpUpdateOne) {
  14533. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14534. }
  14535. if m.id == nil || m.oldValue == nil {
  14536. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14537. }
  14538. oldValue, err := m.oldValue(ctx)
  14539. if err != nil {
  14540. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14541. }
  14542. return oldValue.UpdatedAt, nil
  14543. }
  14544. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14545. func (m *ContactFieldMutation) ResetUpdatedAt() {
  14546. m.updated_at = nil
  14547. }
  14548. // SetStatus sets the "status" field.
  14549. func (m *ContactFieldMutation) SetStatus(u uint8) {
  14550. m.status = &u
  14551. m.addstatus = nil
  14552. }
  14553. // Status returns the value of the "status" field in the mutation.
  14554. func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
  14555. v := m.status
  14556. if v == nil {
  14557. return
  14558. }
  14559. return *v, true
  14560. }
  14561. // OldStatus returns the old "status" field's value of the ContactField entity.
  14562. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14564. func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14565. if !m.op.Is(OpUpdateOne) {
  14566. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14567. }
  14568. if m.id == nil || m.oldValue == nil {
  14569. return v, errors.New("OldStatus requires an ID field in the mutation")
  14570. }
  14571. oldValue, err := m.oldValue(ctx)
  14572. if err != nil {
  14573. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14574. }
  14575. return oldValue.Status, nil
  14576. }
  14577. // AddStatus adds u to the "status" field.
  14578. func (m *ContactFieldMutation) AddStatus(u int8) {
  14579. if m.addstatus != nil {
  14580. *m.addstatus += u
  14581. } else {
  14582. m.addstatus = &u
  14583. }
  14584. }
  14585. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14586. func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
  14587. v := m.addstatus
  14588. if v == nil {
  14589. return
  14590. }
  14591. return *v, true
  14592. }
  14593. // ClearStatus clears the value of the "status" field.
  14594. func (m *ContactFieldMutation) ClearStatus() {
  14595. m.status = nil
  14596. m.addstatus = nil
  14597. m.clearedFields[contactfield.FieldStatus] = struct{}{}
  14598. }
  14599. // StatusCleared returns if the "status" field was cleared in this mutation.
  14600. func (m *ContactFieldMutation) StatusCleared() bool {
  14601. _, ok := m.clearedFields[contactfield.FieldStatus]
  14602. return ok
  14603. }
  14604. // ResetStatus resets all changes to the "status" field.
  14605. func (m *ContactFieldMutation) ResetStatus() {
  14606. m.status = nil
  14607. m.addstatus = nil
  14608. delete(m.clearedFields, contactfield.FieldStatus)
  14609. }
  14610. // SetDeletedAt sets the "deleted_at" field.
  14611. func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
  14612. m.deleted_at = &t
  14613. }
  14614. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14615. func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
  14616. v := m.deleted_at
  14617. if v == nil {
  14618. return
  14619. }
  14620. return *v, true
  14621. }
  14622. // OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
  14623. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14625. func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14626. if !m.op.Is(OpUpdateOne) {
  14627. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14628. }
  14629. if m.id == nil || m.oldValue == nil {
  14630. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14631. }
  14632. oldValue, err := m.oldValue(ctx)
  14633. if err != nil {
  14634. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14635. }
  14636. return oldValue.DeletedAt, nil
  14637. }
  14638. // ClearDeletedAt clears the value of the "deleted_at" field.
  14639. func (m *ContactFieldMutation) ClearDeletedAt() {
  14640. m.deleted_at = nil
  14641. m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
  14642. }
  14643. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14644. func (m *ContactFieldMutation) DeletedAtCleared() bool {
  14645. _, ok := m.clearedFields[contactfield.FieldDeletedAt]
  14646. return ok
  14647. }
  14648. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14649. func (m *ContactFieldMutation) ResetDeletedAt() {
  14650. m.deleted_at = nil
  14651. delete(m.clearedFields, contactfield.FieldDeletedAt)
  14652. }
  14653. // SetContactID sets the "contact_id" field.
  14654. func (m *ContactFieldMutation) SetContactID(u uint64) {
  14655. m.field_contact = &u
  14656. }
  14657. // ContactID returns the value of the "contact_id" field in the mutation.
  14658. func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
  14659. v := m.field_contact
  14660. if v == nil {
  14661. return
  14662. }
  14663. return *v, true
  14664. }
  14665. // OldContactID returns the old "contact_id" field's value of the ContactField entity.
  14666. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14668. func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14669. if !m.op.Is(OpUpdateOne) {
  14670. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14671. }
  14672. if m.id == nil || m.oldValue == nil {
  14673. return v, errors.New("OldContactID requires an ID field in the mutation")
  14674. }
  14675. oldValue, err := m.oldValue(ctx)
  14676. if err != nil {
  14677. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14678. }
  14679. return oldValue.ContactID, nil
  14680. }
  14681. // ResetContactID resets all changes to the "contact_id" field.
  14682. func (m *ContactFieldMutation) ResetContactID() {
  14683. m.field_contact = nil
  14684. }
  14685. // SetFormID sets the "form_id" field.
  14686. func (m *ContactFieldMutation) SetFormID(s string) {
  14687. m.form_id = &s
  14688. }
  14689. // FormID returns the value of the "form_id" field in the mutation.
  14690. func (m *ContactFieldMutation) FormID() (r string, exists bool) {
  14691. v := m.form_id
  14692. if v == nil {
  14693. return
  14694. }
  14695. return *v, true
  14696. }
  14697. // OldFormID returns the old "form_id" field's value of the ContactField entity.
  14698. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14700. func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
  14701. if !m.op.Is(OpUpdateOne) {
  14702. return v, errors.New("OldFormID is only allowed on UpdateOne operations")
  14703. }
  14704. if m.id == nil || m.oldValue == nil {
  14705. return v, errors.New("OldFormID requires an ID field in the mutation")
  14706. }
  14707. oldValue, err := m.oldValue(ctx)
  14708. if err != nil {
  14709. return v, fmt.Errorf("querying old value for OldFormID: %w", err)
  14710. }
  14711. return oldValue.FormID, nil
  14712. }
  14713. // ResetFormID resets all changes to the "form_id" field.
  14714. func (m *ContactFieldMutation) ResetFormID() {
  14715. m.form_id = nil
  14716. }
  14717. // SetValue sets the "value" field.
  14718. func (m *ContactFieldMutation) SetValue(s []string) {
  14719. m.value = &s
  14720. m.appendvalue = nil
  14721. }
  14722. // Value returns the value of the "value" field in the mutation.
  14723. func (m *ContactFieldMutation) Value() (r []string, exists bool) {
  14724. v := m.value
  14725. if v == nil {
  14726. return
  14727. }
  14728. return *v, true
  14729. }
  14730. // OldValue returns the old "value" field's value of the ContactField entity.
  14731. // If the ContactField object wasn't provided to the builder, the object is fetched from the database.
  14732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14733. func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
  14734. if !m.op.Is(OpUpdateOne) {
  14735. return v, errors.New("OldValue is only allowed on UpdateOne operations")
  14736. }
  14737. if m.id == nil || m.oldValue == nil {
  14738. return v, errors.New("OldValue requires an ID field in the mutation")
  14739. }
  14740. oldValue, err := m.oldValue(ctx)
  14741. if err != nil {
  14742. return v, fmt.Errorf("querying old value for OldValue: %w", err)
  14743. }
  14744. return oldValue.Value, nil
  14745. }
  14746. // AppendValue adds s to the "value" field.
  14747. func (m *ContactFieldMutation) AppendValue(s []string) {
  14748. m.appendvalue = append(m.appendvalue, s...)
  14749. }
  14750. // AppendedValue returns the list of values that were appended to the "value" field in this mutation.
  14751. func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
  14752. if len(m.appendvalue) == 0 {
  14753. return nil, false
  14754. }
  14755. return m.appendvalue, true
  14756. }
  14757. // ResetValue resets all changes to the "value" field.
  14758. func (m *ContactFieldMutation) ResetValue() {
  14759. m.value = nil
  14760. m.appendvalue = nil
  14761. }
  14762. // SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
  14763. func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
  14764. m.field_contact = &id
  14765. }
  14766. // ClearFieldContact clears the "field_contact" edge to the Contact entity.
  14767. func (m *ContactFieldMutation) ClearFieldContact() {
  14768. m.clearedfield_contact = true
  14769. m.clearedFields[contactfield.FieldContactID] = struct{}{}
  14770. }
  14771. // FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
  14772. func (m *ContactFieldMutation) FieldContactCleared() bool {
  14773. return m.clearedfield_contact
  14774. }
  14775. // FieldContactID returns the "field_contact" edge ID in the mutation.
  14776. func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
  14777. if m.field_contact != nil {
  14778. return *m.field_contact, true
  14779. }
  14780. return
  14781. }
  14782. // FieldContactIDs returns the "field_contact" edge IDs in the mutation.
  14783. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14784. // FieldContactID instead. It exists only for internal usage by the builders.
  14785. func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
  14786. if id := m.field_contact; id != nil {
  14787. ids = append(ids, *id)
  14788. }
  14789. return
  14790. }
  14791. // ResetFieldContact resets all changes to the "field_contact" edge.
  14792. func (m *ContactFieldMutation) ResetFieldContact() {
  14793. m.field_contact = nil
  14794. m.clearedfield_contact = false
  14795. }
  14796. // Where appends a list predicates to the ContactFieldMutation builder.
  14797. func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
  14798. m.predicates = append(m.predicates, ps...)
  14799. }
  14800. // WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
  14801. // users can use type-assertion to append predicates that do not depend on any generated package.
  14802. func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
  14803. p := make([]predicate.ContactField, len(ps))
  14804. for i := range ps {
  14805. p[i] = ps[i]
  14806. }
  14807. m.Where(p...)
  14808. }
  14809. // Op returns the operation name.
  14810. func (m *ContactFieldMutation) Op() Op {
  14811. return m.op
  14812. }
  14813. // SetOp allows setting the mutation operation.
  14814. func (m *ContactFieldMutation) SetOp(op Op) {
  14815. m.op = op
  14816. }
  14817. // Type returns the node type of this mutation (ContactField).
  14818. func (m *ContactFieldMutation) Type() string {
  14819. return m.typ
  14820. }
  14821. // Fields returns all fields that were changed during this mutation. Note that in
  14822. // order to get all numeric fields that were incremented/decremented, call
  14823. // AddedFields().
  14824. func (m *ContactFieldMutation) Fields() []string {
  14825. fields := make([]string, 0, 7)
  14826. if m.created_at != nil {
  14827. fields = append(fields, contactfield.FieldCreatedAt)
  14828. }
  14829. if m.updated_at != nil {
  14830. fields = append(fields, contactfield.FieldUpdatedAt)
  14831. }
  14832. if m.status != nil {
  14833. fields = append(fields, contactfield.FieldStatus)
  14834. }
  14835. if m.deleted_at != nil {
  14836. fields = append(fields, contactfield.FieldDeletedAt)
  14837. }
  14838. if m.field_contact != nil {
  14839. fields = append(fields, contactfield.FieldContactID)
  14840. }
  14841. if m.form_id != nil {
  14842. fields = append(fields, contactfield.FieldFormID)
  14843. }
  14844. if m.value != nil {
  14845. fields = append(fields, contactfield.FieldValue)
  14846. }
  14847. return fields
  14848. }
  14849. // Field returns the value of a field with the given name. The second boolean
  14850. // return value indicates that this field was not set, or was not defined in the
  14851. // schema.
  14852. func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
  14853. switch name {
  14854. case contactfield.FieldCreatedAt:
  14855. return m.CreatedAt()
  14856. case contactfield.FieldUpdatedAt:
  14857. return m.UpdatedAt()
  14858. case contactfield.FieldStatus:
  14859. return m.Status()
  14860. case contactfield.FieldDeletedAt:
  14861. return m.DeletedAt()
  14862. case contactfield.FieldContactID:
  14863. return m.ContactID()
  14864. case contactfield.FieldFormID:
  14865. return m.FormID()
  14866. case contactfield.FieldValue:
  14867. return m.Value()
  14868. }
  14869. return nil, false
  14870. }
  14871. // OldField returns the old value of the field from the database. An error is
  14872. // returned if the mutation operation is not UpdateOne, or the query to the
  14873. // database failed.
  14874. func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14875. switch name {
  14876. case contactfield.FieldCreatedAt:
  14877. return m.OldCreatedAt(ctx)
  14878. case contactfield.FieldUpdatedAt:
  14879. return m.OldUpdatedAt(ctx)
  14880. case contactfield.FieldStatus:
  14881. return m.OldStatus(ctx)
  14882. case contactfield.FieldDeletedAt:
  14883. return m.OldDeletedAt(ctx)
  14884. case contactfield.FieldContactID:
  14885. return m.OldContactID(ctx)
  14886. case contactfield.FieldFormID:
  14887. return m.OldFormID(ctx)
  14888. case contactfield.FieldValue:
  14889. return m.OldValue(ctx)
  14890. }
  14891. return nil, fmt.Errorf("unknown ContactField field %s", name)
  14892. }
  14893. // SetField sets the value of a field with the given name. It returns an error if
  14894. // the field is not defined in the schema, or if the type mismatched the field
  14895. // type.
  14896. func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
  14897. switch name {
  14898. case contactfield.FieldCreatedAt:
  14899. v, ok := value.(time.Time)
  14900. if !ok {
  14901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14902. }
  14903. m.SetCreatedAt(v)
  14904. return nil
  14905. case contactfield.FieldUpdatedAt:
  14906. v, ok := value.(time.Time)
  14907. if !ok {
  14908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14909. }
  14910. m.SetUpdatedAt(v)
  14911. return nil
  14912. case contactfield.FieldStatus:
  14913. v, ok := value.(uint8)
  14914. if !ok {
  14915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14916. }
  14917. m.SetStatus(v)
  14918. return nil
  14919. case contactfield.FieldDeletedAt:
  14920. v, ok := value.(time.Time)
  14921. if !ok {
  14922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14923. }
  14924. m.SetDeletedAt(v)
  14925. return nil
  14926. case contactfield.FieldContactID:
  14927. v, ok := value.(uint64)
  14928. if !ok {
  14929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14930. }
  14931. m.SetContactID(v)
  14932. return nil
  14933. case contactfield.FieldFormID:
  14934. v, ok := value.(string)
  14935. if !ok {
  14936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14937. }
  14938. m.SetFormID(v)
  14939. return nil
  14940. case contactfield.FieldValue:
  14941. v, ok := value.([]string)
  14942. if !ok {
  14943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14944. }
  14945. m.SetValue(v)
  14946. return nil
  14947. }
  14948. return fmt.Errorf("unknown ContactField field %s", name)
  14949. }
  14950. // AddedFields returns all numeric fields that were incremented/decremented during
  14951. // this mutation.
  14952. func (m *ContactFieldMutation) AddedFields() []string {
  14953. var fields []string
  14954. if m.addstatus != nil {
  14955. fields = append(fields, contactfield.FieldStatus)
  14956. }
  14957. return fields
  14958. }
  14959. // AddedField returns the numeric value that was incremented/decremented on a field
  14960. // with the given name. The second boolean return value indicates that this field
  14961. // was not set, or was not defined in the schema.
  14962. func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
  14963. switch name {
  14964. case contactfield.FieldStatus:
  14965. return m.AddedStatus()
  14966. }
  14967. return nil, false
  14968. }
  14969. // AddField adds the value to the field with the given name. It returns an error if
  14970. // the field is not defined in the schema, or if the type mismatched the field
  14971. // type.
  14972. func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
  14973. switch name {
  14974. case contactfield.FieldStatus:
  14975. v, ok := value.(int8)
  14976. if !ok {
  14977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14978. }
  14979. m.AddStatus(v)
  14980. return nil
  14981. }
  14982. return fmt.Errorf("unknown ContactField numeric field %s", name)
  14983. }
  14984. // ClearedFields returns all nullable fields that were cleared during this
  14985. // mutation.
  14986. func (m *ContactFieldMutation) ClearedFields() []string {
  14987. var fields []string
  14988. if m.FieldCleared(contactfield.FieldStatus) {
  14989. fields = append(fields, contactfield.FieldStatus)
  14990. }
  14991. if m.FieldCleared(contactfield.FieldDeletedAt) {
  14992. fields = append(fields, contactfield.FieldDeletedAt)
  14993. }
  14994. return fields
  14995. }
  14996. // FieldCleared returns a boolean indicating if a field with the given name was
  14997. // cleared in this mutation.
  14998. func (m *ContactFieldMutation) FieldCleared(name string) bool {
  14999. _, ok := m.clearedFields[name]
  15000. return ok
  15001. }
  15002. // ClearField clears the value of the field with the given name. It returns an
  15003. // error if the field is not defined in the schema.
  15004. func (m *ContactFieldMutation) ClearField(name string) error {
  15005. switch name {
  15006. case contactfield.FieldStatus:
  15007. m.ClearStatus()
  15008. return nil
  15009. case contactfield.FieldDeletedAt:
  15010. m.ClearDeletedAt()
  15011. return nil
  15012. }
  15013. return fmt.Errorf("unknown ContactField nullable field %s", name)
  15014. }
  15015. // ResetField resets all changes in the mutation for the field with the given name.
  15016. // It returns an error if the field is not defined in the schema.
  15017. func (m *ContactFieldMutation) ResetField(name string) error {
  15018. switch name {
  15019. case contactfield.FieldCreatedAt:
  15020. m.ResetCreatedAt()
  15021. return nil
  15022. case contactfield.FieldUpdatedAt:
  15023. m.ResetUpdatedAt()
  15024. return nil
  15025. case contactfield.FieldStatus:
  15026. m.ResetStatus()
  15027. return nil
  15028. case contactfield.FieldDeletedAt:
  15029. m.ResetDeletedAt()
  15030. return nil
  15031. case contactfield.FieldContactID:
  15032. m.ResetContactID()
  15033. return nil
  15034. case contactfield.FieldFormID:
  15035. m.ResetFormID()
  15036. return nil
  15037. case contactfield.FieldValue:
  15038. m.ResetValue()
  15039. return nil
  15040. }
  15041. return fmt.Errorf("unknown ContactField field %s", name)
  15042. }
  15043. // AddedEdges returns all edge names that were set/added in this mutation.
  15044. func (m *ContactFieldMutation) AddedEdges() []string {
  15045. edges := make([]string, 0, 1)
  15046. if m.field_contact != nil {
  15047. edges = append(edges, contactfield.EdgeFieldContact)
  15048. }
  15049. return edges
  15050. }
  15051. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15052. // name in this mutation.
  15053. func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
  15054. switch name {
  15055. case contactfield.EdgeFieldContact:
  15056. if id := m.field_contact; id != nil {
  15057. return []ent.Value{*id}
  15058. }
  15059. }
  15060. return nil
  15061. }
  15062. // RemovedEdges returns all edge names that were removed in this mutation.
  15063. func (m *ContactFieldMutation) RemovedEdges() []string {
  15064. edges := make([]string, 0, 1)
  15065. return edges
  15066. }
  15067. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15068. // the given name in this mutation.
  15069. func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
  15070. return nil
  15071. }
  15072. // ClearedEdges returns all edge names that were cleared in this mutation.
  15073. func (m *ContactFieldMutation) ClearedEdges() []string {
  15074. edges := make([]string, 0, 1)
  15075. if m.clearedfield_contact {
  15076. edges = append(edges, contactfield.EdgeFieldContact)
  15077. }
  15078. return edges
  15079. }
  15080. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15081. // was cleared in this mutation.
  15082. func (m *ContactFieldMutation) EdgeCleared(name string) bool {
  15083. switch name {
  15084. case contactfield.EdgeFieldContact:
  15085. return m.clearedfield_contact
  15086. }
  15087. return false
  15088. }
  15089. // ClearEdge clears the value of the edge with the given name. It returns an error
  15090. // if that edge is not defined in the schema.
  15091. func (m *ContactFieldMutation) ClearEdge(name string) error {
  15092. switch name {
  15093. case contactfield.EdgeFieldContact:
  15094. m.ClearFieldContact()
  15095. return nil
  15096. }
  15097. return fmt.Errorf("unknown ContactField unique edge %s", name)
  15098. }
  15099. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15100. // It returns an error if the edge is not defined in the schema.
  15101. func (m *ContactFieldMutation) ResetEdge(name string) error {
  15102. switch name {
  15103. case contactfield.EdgeFieldContact:
  15104. m.ResetFieldContact()
  15105. return nil
  15106. }
  15107. return fmt.Errorf("unknown ContactField edge %s", name)
  15108. }
  15109. // ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
  15110. type ContactFieldTemplateMutation struct {
  15111. config
  15112. op Op
  15113. typ string
  15114. id *uint64
  15115. created_at *time.Time
  15116. updated_at *time.Time
  15117. status *uint8
  15118. addstatus *int8
  15119. deleted_at *time.Time
  15120. organization_id *uint64
  15121. addorganization_id *int64
  15122. template *[]custom_types.ContactFieldTemplate
  15123. appendtemplate []custom_types.ContactFieldTemplate
  15124. clearedFields map[string]struct{}
  15125. done bool
  15126. oldValue func(context.Context) (*ContactFieldTemplate, error)
  15127. predicates []predicate.ContactFieldTemplate
  15128. }
  15129. var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
  15130. // contactfieldtemplateOption allows management of the mutation configuration using functional options.
  15131. type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
  15132. // newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
  15133. func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
  15134. m := &ContactFieldTemplateMutation{
  15135. config: c,
  15136. op: op,
  15137. typ: TypeContactFieldTemplate,
  15138. clearedFields: make(map[string]struct{}),
  15139. }
  15140. for _, opt := range opts {
  15141. opt(m)
  15142. }
  15143. return m
  15144. }
  15145. // withContactFieldTemplateID sets the ID field of the mutation.
  15146. func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
  15147. return func(m *ContactFieldTemplateMutation) {
  15148. var (
  15149. err error
  15150. once sync.Once
  15151. value *ContactFieldTemplate
  15152. )
  15153. m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
  15154. once.Do(func() {
  15155. if m.done {
  15156. err = errors.New("querying old values post mutation is not allowed")
  15157. } else {
  15158. value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
  15159. }
  15160. })
  15161. return value, err
  15162. }
  15163. m.id = &id
  15164. }
  15165. }
  15166. // withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
  15167. func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
  15168. return func(m *ContactFieldTemplateMutation) {
  15169. m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
  15170. return node, nil
  15171. }
  15172. m.id = &node.ID
  15173. }
  15174. }
  15175. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15176. // executed in a transaction (ent.Tx), a transactional client is returned.
  15177. func (m ContactFieldTemplateMutation) Client() *Client {
  15178. client := &Client{config: m.config}
  15179. client.init()
  15180. return client
  15181. }
  15182. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15183. // it returns an error otherwise.
  15184. func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
  15185. if _, ok := m.driver.(*txDriver); !ok {
  15186. return nil, errors.New("ent: mutation is not running in a transaction")
  15187. }
  15188. tx := &Tx{config: m.config}
  15189. tx.init()
  15190. return tx, nil
  15191. }
  15192. // SetID sets the value of the id field. Note that this
  15193. // operation is only accepted on creation of ContactFieldTemplate entities.
  15194. func (m *ContactFieldTemplateMutation) SetID(id uint64) {
  15195. m.id = &id
  15196. }
  15197. // ID returns the ID value in the mutation. Note that the ID is only available
  15198. // if it was provided to the builder or after it was returned from the database.
  15199. func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
  15200. if m.id == nil {
  15201. return
  15202. }
  15203. return *m.id, true
  15204. }
  15205. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15206. // That means, if the mutation is applied within a transaction with an isolation level such
  15207. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15208. // or updated by the mutation.
  15209. func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
  15210. switch {
  15211. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15212. id, exists := m.ID()
  15213. if exists {
  15214. return []uint64{id}, nil
  15215. }
  15216. fallthrough
  15217. case m.op.Is(OpUpdate | OpDelete):
  15218. return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
  15219. default:
  15220. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15221. }
  15222. }
  15223. // SetCreatedAt sets the "created_at" field.
  15224. func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
  15225. m.created_at = &t
  15226. }
  15227. // CreatedAt returns the value of the "created_at" field in the mutation.
  15228. func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
  15229. v := m.created_at
  15230. if v == nil {
  15231. return
  15232. }
  15233. return *v, true
  15234. }
  15235. // OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
  15236. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15238. func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15239. if !m.op.Is(OpUpdateOne) {
  15240. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15241. }
  15242. if m.id == nil || m.oldValue == nil {
  15243. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15244. }
  15245. oldValue, err := m.oldValue(ctx)
  15246. if err != nil {
  15247. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15248. }
  15249. return oldValue.CreatedAt, nil
  15250. }
  15251. // ResetCreatedAt resets all changes to the "created_at" field.
  15252. func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
  15253. m.created_at = nil
  15254. }
  15255. // SetUpdatedAt sets the "updated_at" field.
  15256. func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
  15257. m.updated_at = &t
  15258. }
  15259. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15260. func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
  15261. v := m.updated_at
  15262. if v == nil {
  15263. return
  15264. }
  15265. return *v, true
  15266. }
  15267. // OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
  15268. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15270. func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15271. if !m.op.Is(OpUpdateOne) {
  15272. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15273. }
  15274. if m.id == nil || m.oldValue == nil {
  15275. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15276. }
  15277. oldValue, err := m.oldValue(ctx)
  15278. if err != nil {
  15279. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15280. }
  15281. return oldValue.UpdatedAt, nil
  15282. }
  15283. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15284. func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
  15285. m.updated_at = nil
  15286. }
  15287. // SetStatus sets the "status" field.
  15288. func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
  15289. m.status = &u
  15290. m.addstatus = nil
  15291. }
  15292. // Status returns the value of the "status" field in the mutation.
  15293. func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
  15294. v := m.status
  15295. if v == nil {
  15296. return
  15297. }
  15298. return *v, true
  15299. }
  15300. // OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
  15301. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15303. func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15304. if !m.op.Is(OpUpdateOne) {
  15305. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15306. }
  15307. if m.id == nil || m.oldValue == nil {
  15308. return v, errors.New("OldStatus requires an ID field in the mutation")
  15309. }
  15310. oldValue, err := m.oldValue(ctx)
  15311. if err != nil {
  15312. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15313. }
  15314. return oldValue.Status, nil
  15315. }
  15316. // AddStatus adds u to the "status" field.
  15317. func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
  15318. if m.addstatus != nil {
  15319. *m.addstatus += u
  15320. } else {
  15321. m.addstatus = &u
  15322. }
  15323. }
  15324. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15325. func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
  15326. v := m.addstatus
  15327. if v == nil {
  15328. return
  15329. }
  15330. return *v, true
  15331. }
  15332. // ClearStatus clears the value of the "status" field.
  15333. func (m *ContactFieldTemplateMutation) ClearStatus() {
  15334. m.status = nil
  15335. m.addstatus = nil
  15336. m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
  15337. }
  15338. // StatusCleared returns if the "status" field was cleared in this mutation.
  15339. func (m *ContactFieldTemplateMutation) StatusCleared() bool {
  15340. _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
  15341. return ok
  15342. }
  15343. // ResetStatus resets all changes to the "status" field.
  15344. func (m *ContactFieldTemplateMutation) ResetStatus() {
  15345. m.status = nil
  15346. m.addstatus = nil
  15347. delete(m.clearedFields, contactfieldtemplate.FieldStatus)
  15348. }
  15349. // SetDeletedAt sets the "deleted_at" field.
  15350. func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
  15351. m.deleted_at = &t
  15352. }
  15353. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15354. func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
  15355. v := m.deleted_at
  15356. if v == nil {
  15357. return
  15358. }
  15359. return *v, true
  15360. }
  15361. // OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
  15362. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15363. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15364. func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15365. if !m.op.Is(OpUpdateOne) {
  15366. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15367. }
  15368. if m.id == nil || m.oldValue == nil {
  15369. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15370. }
  15371. oldValue, err := m.oldValue(ctx)
  15372. if err != nil {
  15373. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15374. }
  15375. return oldValue.DeletedAt, nil
  15376. }
  15377. // ClearDeletedAt clears the value of the "deleted_at" field.
  15378. func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
  15379. m.deleted_at = nil
  15380. m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
  15381. }
  15382. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15383. func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
  15384. _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
  15385. return ok
  15386. }
  15387. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15388. func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
  15389. m.deleted_at = nil
  15390. delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
  15391. }
  15392. // SetOrganizationID sets the "organization_id" field.
  15393. func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
  15394. m.organization_id = &u
  15395. m.addorganization_id = nil
  15396. }
  15397. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15398. func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
  15399. v := m.organization_id
  15400. if v == nil {
  15401. return
  15402. }
  15403. return *v, true
  15404. }
  15405. // OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
  15406. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15408. func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15409. if !m.op.Is(OpUpdateOne) {
  15410. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15411. }
  15412. if m.id == nil || m.oldValue == nil {
  15413. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15414. }
  15415. oldValue, err := m.oldValue(ctx)
  15416. if err != nil {
  15417. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15418. }
  15419. return oldValue.OrganizationID, nil
  15420. }
  15421. // AddOrganizationID adds u to the "organization_id" field.
  15422. func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
  15423. if m.addorganization_id != nil {
  15424. *m.addorganization_id += u
  15425. } else {
  15426. m.addorganization_id = &u
  15427. }
  15428. }
  15429. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15430. func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
  15431. v := m.addorganization_id
  15432. if v == nil {
  15433. return
  15434. }
  15435. return *v, true
  15436. }
  15437. // ResetOrganizationID resets all changes to the "organization_id" field.
  15438. func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
  15439. m.organization_id = nil
  15440. m.addorganization_id = nil
  15441. }
  15442. // SetTemplate sets the "template" field.
  15443. func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
  15444. m.template = &ctft
  15445. m.appendtemplate = nil
  15446. }
  15447. // Template returns the value of the "template" field in the mutation.
  15448. func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
  15449. v := m.template
  15450. if v == nil {
  15451. return
  15452. }
  15453. return *v, true
  15454. }
  15455. // OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
  15456. // If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
  15457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15458. func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
  15459. if !m.op.Is(OpUpdateOne) {
  15460. return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
  15461. }
  15462. if m.id == nil || m.oldValue == nil {
  15463. return v, errors.New("OldTemplate requires an ID field in the mutation")
  15464. }
  15465. oldValue, err := m.oldValue(ctx)
  15466. if err != nil {
  15467. return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
  15468. }
  15469. return oldValue.Template, nil
  15470. }
  15471. // AppendTemplate adds ctft to the "template" field.
  15472. func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
  15473. m.appendtemplate = append(m.appendtemplate, ctft...)
  15474. }
  15475. // AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
  15476. func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
  15477. if len(m.appendtemplate) == 0 {
  15478. return nil, false
  15479. }
  15480. return m.appendtemplate, true
  15481. }
  15482. // ResetTemplate resets all changes to the "template" field.
  15483. func (m *ContactFieldTemplateMutation) ResetTemplate() {
  15484. m.template = nil
  15485. m.appendtemplate = nil
  15486. }
  15487. // Where appends a list predicates to the ContactFieldTemplateMutation builder.
  15488. func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
  15489. m.predicates = append(m.predicates, ps...)
  15490. }
  15491. // WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
  15492. // users can use type-assertion to append predicates that do not depend on any generated package.
  15493. func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
  15494. p := make([]predicate.ContactFieldTemplate, len(ps))
  15495. for i := range ps {
  15496. p[i] = ps[i]
  15497. }
  15498. m.Where(p...)
  15499. }
  15500. // Op returns the operation name.
  15501. func (m *ContactFieldTemplateMutation) Op() Op {
  15502. return m.op
  15503. }
  15504. // SetOp allows setting the mutation operation.
  15505. func (m *ContactFieldTemplateMutation) SetOp(op Op) {
  15506. m.op = op
  15507. }
  15508. // Type returns the node type of this mutation (ContactFieldTemplate).
  15509. func (m *ContactFieldTemplateMutation) Type() string {
  15510. return m.typ
  15511. }
  15512. // Fields returns all fields that were changed during this mutation. Note that in
  15513. // order to get all numeric fields that were incremented/decremented, call
  15514. // AddedFields().
  15515. func (m *ContactFieldTemplateMutation) Fields() []string {
  15516. fields := make([]string, 0, 6)
  15517. if m.created_at != nil {
  15518. fields = append(fields, contactfieldtemplate.FieldCreatedAt)
  15519. }
  15520. if m.updated_at != nil {
  15521. fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
  15522. }
  15523. if m.status != nil {
  15524. fields = append(fields, contactfieldtemplate.FieldStatus)
  15525. }
  15526. if m.deleted_at != nil {
  15527. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15528. }
  15529. if m.organization_id != nil {
  15530. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15531. }
  15532. if m.template != nil {
  15533. fields = append(fields, contactfieldtemplate.FieldTemplate)
  15534. }
  15535. return fields
  15536. }
  15537. // Field returns the value of a field with the given name. The second boolean
  15538. // return value indicates that this field was not set, or was not defined in the
  15539. // schema.
  15540. func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
  15541. switch name {
  15542. case contactfieldtemplate.FieldCreatedAt:
  15543. return m.CreatedAt()
  15544. case contactfieldtemplate.FieldUpdatedAt:
  15545. return m.UpdatedAt()
  15546. case contactfieldtemplate.FieldStatus:
  15547. return m.Status()
  15548. case contactfieldtemplate.FieldDeletedAt:
  15549. return m.DeletedAt()
  15550. case contactfieldtemplate.FieldOrganizationID:
  15551. return m.OrganizationID()
  15552. case contactfieldtemplate.FieldTemplate:
  15553. return m.Template()
  15554. }
  15555. return nil, false
  15556. }
  15557. // OldField returns the old value of the field from the database. An error is
  15558. // returned if the mutation operation is not UpdateOne, or the query to the
  15559. // database failed.
  15560. func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15561. switch name {
  15562. case contactfieldtemplate.FieldCreatedAt:
  15563. return m.OldCreatedAt(ctx)
  15564. case contactfieldtemplate.FieldUpdatedAt:
  15565. return m.OldUpdatedAt(ctx)
  15566. case contactfieldtemplate.FieldStatus:
  15567. return m.OldStatus(ctx)
  15568. case contactfieldtemplate.FieldDeletedAt:
  15569. return m.OldDeletedAt(ctx)
  15570. case contactfieldtemplate.FieldOrganizationID:
  15571. return m.OldOrganizationID(ctx)
  15572. case contactfieldtemplate.FieldTemplate:
  15573. return m.OldTemplate(ctx)
  15574. }
  15575. return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15576. }
  15577. // SetField sets the value of a field with the given name. It returns an error if
  15578. // the field is not defined in the schema, or if the type mismatched the field
  15579. // type.
  15580. func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
  15581. switch name {
  15582. case contactfieldtemplate.FieldCreatedAt:
  15583. v, ok := value.(time.Time)
  15584. if !ok {
  15585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15586. }
  15587. m.SetCreatedAt(v)
  15588. return nil
  15589. case contactfieldtemplate.FieldUpdatedAt:
  15590. v, ok := value.(time.Time)
  15591. if !ok {
  15592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15593. }
  15594. m.SetUpdatedAt(v)
  15595. return nil
  15596. case contactfieldtemplate.FieldStatus:
  15597. v, ok := value.(uint8)
  15598. if !ok {
  15599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15600. }
  15601. m.SetStatus(v)
  15602. return nil
  15603. case contactfieldtemplate.FieldDeletedAt:
  15604. v, ok := value.(time.Time)
  15605. if !ok {
  15606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15607. }
  15608. m.SetDeletedAt(v)
  15609. return nil
  15610. case contactfieldtemplate.FieldOrganizationID:
  15611. v, ok := value.(uint64)
  15612. if !ok {
  15613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15614. }
  15615. m.SetOrganizationID(v)
  15616. return nil
  15617. case contactfieldtemplate.FieldTemplate:
  15618. v, ok := value.([]custom_types.ContactFieldTemplate)
  15619. if !ok {
  15620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15621. }
  15622. m.SetTemplate(v)
  15623. return nil
  15624. }
  15625. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15626. }
  15627. // AddedFields returns all numeric fields that were incremented/decremented during
  15628. // this mutation.
  15629. func (m *ContactFieldTemplateMutation) AddedFields() []string {
  15630. var fields []string
  15631. if m.addstatus != nil {
  15632. fields = append(fields, contactfieldtemplate.FieldStatus)
  15633. }
  15634. if m.addorganization_id != nil {
  15635. fields = append(fields, contactfieldtemplate.FieldOrganizationID)
  15636. }
  15637. return fields
  15638. }
  15639. // AddedField returns the numeric value that was incremented/decremented on a field
  15640. // with the given name. The second boolean return value indicates that this field
  15641. // was not set, or was not defined in the schema.
  15642. func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
  15643. switch name {
  15644. case contactfieldtemplate.FieldStatus:
  15645. return m.AddedStatus()
  15646. case contactfieldtemplate.FieldOrganizationID:
  15647. return m.AddedOrganizationID()
  15648. }
  15649. return nil, false
  15650. }
  15651. // AddField adds the value to the field with the given name. It returns an error if
  15652. // the field is not defined in the schema, or if the type mismatched the field
  15653. // type.
  15654. func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
  15655. switch name {
  15656. case contactfieldtemplate.FieldStatus:
  15657. v, ok := value.(int8)
  15658. if !ok {
  15659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15660. }
  15661. m.AddStatus(v)
  15662. return nil
  15663. case contactfieldtemplate.FieldOrganizationID:
  15664. v, ok := value.(int64)
  15665. if !ok {
  15666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15667. }
  15668. m.AddOrganizationID(v)
  15669. return nil
  15670. }
  15671. return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
  15672. }
  15673. // ClearedFields returns all nullable fields that were cleared during this
  15674. // mutation.
  15675. func (m *ContactFieldTemplateMutation) ClearedFields() []string {
  15676. var fields []string
  15677. if m.FieldCleared(contactfieldtemplate.FieldStatus) {
  15678. fields = append(fields, contactfieldtemplate.FieldStatus)
  15679. }
  15680. if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
  15681. fields = append(fields, contactfieldtemplate.FieldDeletedAt)
  15682. }
  15683. return fields
  15684. }
  15685. // FieldCleared returns a boolean indicating if a field with the given name was
  15686. // cleared in this mutation.
  15687. func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
  15688. _, ok := m.clearedFields[name]
  15689. return ok
  15690. }
  15691. // ClearField clears the value of the field with the given name. It returns an
  15692. // error if the field is not defined in the schema.
  15693. func (m *ContactFieldTemplateMutation) ClearField(name string) error {
  15694. switch name {
  15695. case contactfieldtemplate.FieldStatus:
  15696. m.ClearStatus()
  15697. return nil
  15698. case contactfieldtemplate.FieldDeletedAt:
  15699. m.ClearDeletedAt()
  15700. return nil
  15701. }
  15702. return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
  15703. }
  15704. // ResetField resets all changes in the mutation for the field with the given name.
  15705. // It returns an error if the field is not defined in the schema.
  15706. func (m *ContactFieldTemplateMutation) ResetField(name string) error {
  15707. switch name {
  15708. case contactfieldtemplate.FieldCreatedAt:
  15709. m.ResetCreatedAt()
  15710. return nil
  15711. case contactfieldtemplate.FieldUpdatedAt:
  15712. m.ResetUpdatedAt()
  15713. return nil
  15714. case contactfieldtemplate.FieldStatus:
  15715. m.ResetStatus()
  15716. return nil
  15717. case contactfieldtemplate.FieldDeletedAt:
  15718. m.ResetDeletedAt()
  15719. return nil
  15720. case contactfieldtemplate.FieldOrganizationID:
  15721. m.ResetOrganizationID()
  15722. return nil
  15723. case contactfieldtemplate.FieldTemplate:
  15724. m.ResetTemplate()
  15725. return nil
  15726. }
  15727. return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
  15728. }
  15729. // AddedEdges returns all edge names that were set/added in this mutation.
  15730. func (m *ContactFieldTemplateMutation) AddedEdges() []string {
  15731. edges := make([]string, 0, 0)
  15732. return edges
  15733. }
  15734. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15735. // name in this mutation.
  15736. func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
  15737. return nil
  15738. }
  15739. // RemovedEdges returns all edge names that were removed in this mutation.
  15740. func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
  15741. edges := make([]string, 0, 0)
  15742. return edges
  15743. }
  15744. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15745. // the given name in this mutation.
  15746. func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
  15747. return nil
  15748. }
  15749. // ClearedEdges returns all edge names that were cleared in this mutation.
  15750. func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
  15751. edges := make([]string, 0, 0)
  15752. return edges
  15753. }
  15754. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15755. // was cleared in this mutation.
  15756. func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
  15757. return false
  15758. }
  15759. // ClearEdge clears the value of the edge with the given name. It returns an error
  15760. // if that edge is not defined in the schema.
  15761. func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
  15762. return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
  15763. }
  15764. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15765. // It returns an error if the edge is not defined in the schema.
  15766. func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
  15767. return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
  15768. }
  15769. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  15770. type CreditBalanceMutation struct {
  15771. config
  15772. op Op
  15773. typ string
  15774. id *uint64
  15775. created_at *time.Time
  15776. updated_at *time.Time
  15777. deleted_at *time.Time
  15778. user_id *string
  15779. balance *float64
  15780. addbalance *float64
  15781. status *int
  15782. addstatus *int
  15783. organization_id *uint64
  15784. addorganization_id *int64
  15785. clearedFields map[string]struct{}
  15786. done bool
  15787. oldValue func(context.Context) (*CreditBalance, error)
  15788. predicates []predicate.CreditBalance
  15789. }
  15790. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  15791. // creditbalanceOption allows management of the mutation configuration using functional options.
  15792. type creditbalanceOption func(*CreditBalanceMutation)
  15793. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  15794. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  15795. m := &CreditBalanceMutation{
  15796. config: c,
  15797. op: op,
  15798. typ: TypeCreditBalance,
  15799. clearedFields: make(map[string]struct{}),
  15800. }
  15801. for _, opt := range opts {
  15802. opt(m)
  15803. }
  15804. return m
  15805. }
  15806. // withCreditBalanceID sets the ID field of the mutation.
  15807. func withCreditBalanceID(id uint64) creditbalanceOption {
  15808. return func(m *CreditBalanceMutation) {
  15809. var (
  15810. err error
  15811. once sync.Once
  15812. value *CreditBalance
  15813. )
  15814. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  15815. once.Do(func() {
  15816. if m.done {
  15817. err = errors.New("querying old values post mutation is not allowed")
  15818. } else {
  15819. value, err = m.Client().CreditBalance.Get(ctx, id)
  15820. }
  15821. })
  15822. return value, err
  15823. }
  15824. m.id = &id
  15825. }
  15826. }
  15827. // withCreditBalance sets the old CreditBalance of the mutation.
  15828. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  15829. return func(m *CreditBalanceMutation) {
  15830. m.oldValue = func(context.Context) (*CreditBalance, error) {
  15831. return node, nil
  15832. }
  15833. m.id = &node.ID
  15834. }
  15835. }
  15836. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15837. // executed in a transaction (ent.Tx), a transactional client is returned.
  15838. func (m CreditBalanceMutation) Client() *Client {
  15839. client := &Client{config: m.config}
  15840. client.init()
  15841. return client
  15842. }
  15843. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15844. // it returns an error otherwise.
  15845. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  15846. if _, ok := m.driver.(*txDriver); !ok {
  15847. return nil, errors.New("ent: mutation is not running in a transaction")
  15848. }
  15849. tx := &Tx{config: m.config}
  15850. tx.init()
  15851. return tx, nil
  15852. }
  15853. // SetID sets the value of the id field. Note that this
  15854. // operation is only accepted on creation of CreditBalance entities.
  15855. func (m *CreditBalanceMutation) SetID(id uint64) {
  15856. m.id = &id
  15857. }
  15858. // ID returns the ID value in the mutation. Note that the ID is only available
  15859. // if it was provided to the builder or after it was returned from the database.
  15860. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  15861. if m.id == nil {
  15862. return
  15863. }
  15864. return *m.id, true
  15865. }
  15866. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15867. // That means, if the mutation is applied within a transaction with an isolation level such
  15868. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15869. // or updated by the mutation.
  15870. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  15871. switch {
  15872. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15873. id, exists := m.ID()
  15874. if exists {
  15875. return []uint64{id}, nil
  15876. }
  15877. fallthrough
  15878. case m.op.Is(OpUpdate | OpDelete):
  15879. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  15880. default:
  15881. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15882. }
  15883. }
  15884. // SetCreatedAt sets the "created_at" field.
  15885. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  15886. m.created_at = &t
  15887. }
  15888. // CreatedAt returns the value of the "created_at" field in the mutation.
  15889. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  15890. v := m.created_at
  15891. if v == nil {
  15892. return
  15893. }
  15894. return *v, true
  15895. }
  15896. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  15897. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15899. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15900. if !m.op.Is(OpUpdateOne) {
  15901. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15902. }
  15903. if m.id == nil || m.oldValue == nil {
  15904. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15905. }
  15906. oldValue, err := m.oldValue(ctx)
  15907. if err != nil {
  15908. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15909. }
  15910. return oldValue.CreatedAt, nil
  15911. }
  15912. // ResetCreatedAt resets all changes to the "created_at" field.
  15913. func (m *CreditBalanceMutation) ResetCreatedAt() {
  15914. m.created_at = nil
  15915. }
  15916. // SetUpdatedAt sets the "updated_at" field.
  15917. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  15918. m.updated_at = &t
  15919. }
  15920. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15921. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  15922. v := m.updated_at
  15923. if v == nil {
  15924. return
  15925. }
  15926. return *v, true
  15927. }
  15928. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  15929. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15931. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15932. if !m.op.Is(OpUpdateOne) {
  15933. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15934. }
  15935. if m.id == nil || m.oldValue == nil {
  15936. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15937. }
  15938. oldValue, err := m.oldValue(ctx)
  15939. if err != nil {
  15940. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15941. }
  15942. return oldValue.UpdatedAt, nil
  15943. }
  15944. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15945. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  15946. m.updated_at = nil
  15947. }
  15948. // SetDeletedAt sets the "deleted_at" field.
  15949. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  15950. m.deleted_at = &t
  15951. }
  15952. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15953. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  15954. v := m.deleted_at
  15955. if v == nil {
  15956. return
  15957. }
  15958. return *v, true
  15959. }
  15960. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  15961. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  15962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15963. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15964. if !m.op.Is(OpUpdateOne) {
  15965. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15966. }
  15967. if m.id == nil || m.oldValue == nil {
  15968. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15969. }
  15970. oldValue, err := m.oldValue(ctx)
  15971. if err != nil {
  15972. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15973. }
  15974. return oldValue.DeletedAt, nil
  15975. }
  15976. // ClearDeletedAt clears the value of the "deleted_at" field.
  15977. func (m *CreditBalanceMutation) ClearDeletedAt() {
  15978. m.deleted_at = nil
  15979. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  15980. }
  15981. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15982. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  15983. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  15984. return ok
  15985. }
  15986. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15987. func (m *CreditBalanceMutation) ResetDeletedAt() {
  15988. m.deleted_at = nil
  15989. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  15990. }
  15991. // SetUserID sets the "user_id" field.
  15992. func (m *CreditBalanceMutation) SetUserID(s string) {
  15993. m.user_id = &s
  15994. }
  15995. // UserID returns the value of the "user_id" field in the mutation.
  15996. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  15997. v := m.user_id
  15998. if v == nil {
  15999. return
  16000. }
  16001. return *v, true
  16002. }
  16003. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  16004. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16006. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  16007. if !m.op.Is(OpUpdateOne) {
  16008. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  16009. }
  16010. if m.id == nil || m.oldValue == nil {
  16011. return v, errors.New("OldUserID requires an ID field in the mutation")
  16012. }
  16013. oldValue, err := m.oldValue(ctx)
  16014. if err != nil {
  16015. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  16016. }
  16017. return oldValue.UserID, nil
  16018. }
  16019. // ClearUserID clears the value of the "user_id" field.
  16020. func (m *CreditBalanceMutation) ClearUserID() {
  16021. m.user_id = nil
  16022. m.clearedFields[creditbalance.FieldUserID] = struct{}{}
  16023. }
  16024. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  16025. func (m *CreditBalanceMutation) UserIDCleared() bool {
  16026. _, ok := m.clearedFields[creditbalance.FieldUserID]
  16027. return ok
  16028. }
  16029. // ResetUserID resets all changes to the "user_id" field.
  16030. func (m *CreditBalanceMutation) ResetUserID() {
  16031. m.user_id = nil
  16032. delete(m.clearedFields, creditbalance.FieldUserID)
  16033. }
  16034. // SetBalance sets the "balance" field.
  16035. func (m *CreditBalanceMutation) SetBalance(f float64) {
  16036. m.balance = &f
  16037. m.addbalance = nil
  16038. }
  16039. // Balance returns the value of the "balance" field in the mutation.
  16040. func (m *CreditBalanceMutation) Balance() (r float64, exists bool) {
  16041. v := m.balance
  16042. if v == nil {
  16043. return
  16044. }
  16045. return *v, true
  16046. }
  16047. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  16048. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16050. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float64, err error) {
  16051. if !m.op.Is(OpUpdateOne) {
  16052. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  16053. }
  16054. if m.id == nil || m.oldValue == nil {
  16055. return v, errors.New("OldBalance requires an ID field in the mutation")
  16056. }
  16057. oldValue, err := m.oldValue(ctx)
  16058. if err != nil {
  16059. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  16060. }
  16061. return oldValue.Balance, nil
  16062. }
  16063. // AddBalance adds f to the "balance" field.
  16064. func (m *CreditBalanceMutation) AddBalance(f float64) {
  16065. if m.addbalance != nil {
  16066. *m.addbalance += f
  16067. } else {
  16068. m.addbalance = &f
  16069. }
  16070. }
  16071. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  16072. func (m *CreditBalanceMutation) AddedBalance() (r float64, exists bool) {
  16073. v := m.addbalance
  16074. if v == nil {
  16075. return
  16076. }
  16077. return *v, true
  16078. }
  16079. // ResetBalance resets all changes to the "balance" field.
  16080. func (m *CreditBalanceMutation) ResetBalance() {
  16081. m.balance = nil
  16082. m.addbalance = nil
  16083. }
  16084. // SetStatus sets the "status" field.
  16085. func (m *CreditBalanceMutation) SetStatus(i int) {
  16086. m.status = &i
  16087. m.addstatus = nil
  16088. }
  16089. // Status returns the value of the "status" field in the mutation.
  16090. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  16091. v := m.status
  16092. if v == nil {
  16093. return
  16094. }
  16095. return *v, true
  16096. }
  16097. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  16098. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16100. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  16101. if !m.op.Is(OpUpdateOne) {
  16102. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16103. }
  16104. if m.id == nil || m.oldValue == nil {
  16105. return v, errors.New("OldStatus requires an ID field in the mutation")
  16106. }
  16107. oldValue, err := m.oldValue(ctx)
  16108. if err != nil {
  16109. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16110. }
  16111. return oldValue.Status, nil
  16112. }
  16113. // AddStatus adds i to the "status" field.
  16114. func (m *CreditBalanceMutation) AddStatus(i int) {
  16115. if m.addstatus != nil {
  16116. *m.addstatus += i
  16117. } else {
  16118. m.addstatus = &i
  16119. }
  16120. }
  16121. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16122. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  16123. v := m.addstatus
  16124. if v == nil {
  16125. return
  16126. }
  16127. return *v, true
  16128. }
  16129. // ClearStatus clears the value of the "status" field.
  16130. func (m *CreditBalanceMutation) ClearStatus() {
  16131. m.status = nil
  16132. m.addstatus = nil
  16133. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  16134. }
  16135. // StatusCleared returns if the "status" field was cleared in this mutation.
  16136. func (m *CreditBalanceMutation) StatusCleared() bool {
  16137. _, ok := m.clearedFields[creditbalance.FieldStatus]
  16138. return ok
  16139. }
  16140. // ResetStatus resets all changes to the "status" field.
  16141. func (m *CreditBalanceMutation) ResetStatus() {
  16142. m.status = nil
  16143. m.addstatus = nil
  16144. delete(m.clearedFields, creditbalance.FieldStatus)
  16145. }
  16146. // SetOrganizationID sets the "organization_id" field.
  16147. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  16148. m.organization_id = &u
  16149. m.addorganization_id = nil
  16150. }
  16151. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16152. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  16153. v := m.organization_id
  16154. if v == nil {
  16155. return
  16156. }
  16157. return *v, true
  16158. }
  16159. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  16160. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  16161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16162. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16163. if !m.op.Is(OpUpdateOne) {
  16164. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16165. }
  16166. if m.id == nil || m.oldValue == nil {
  16167. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16168. }
  16169. oldValue, err := m.oldValue(ctx)
  16170. if err != nil {
  16171. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16172. }
  16173. return oldValue.OrganizationID, nil
  16174. }
  16175. // AddOrganizationID adds u to the "organization_id" field.
  16176. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  16177. if m.addorganization_id != nil {
  16178. *m.addorganization_id += u
  16179. } else {
  16180. m.addorganization_id = &u
  16181. }
  16182. }
  16183. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16184. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  16185. v := m.addorganization_id
  16186. if v == nil {
  16187. return
  16188. }
  16189. return *v, true
  16190. }
  16191. // ClearOrganizationID clears the value of the "organization_id" field.
  16192. func (m *CreditBalanceMutation) ClearOrganizationID() {
  16193. m.organization_id = nil
  16194. m.addorganization_id = nil
  16195. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  16196. }
  16197. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16198. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  16199. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  16200. return ok
  16201. }
  16202. // ResetOrganizationID resets all changes to the "organization_id" field.
  16203. func (m *CreditBalanceMutation) ResetOrganizationID() {
  16204. m.organization_id = nil
  16205. m.addorganization_id = nil
  16206. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  16207. }
  16208. // Where appends a list predicates to the CreditBalanceMutation builder.
  16209. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  16210. m.predicates = append(m.predicates, ps...)
  16211. }
  16212. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  16213. // users can use type-assertion to append predicates that do not depend on any generated package.
  16214. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  16215. p := make([]predicate.CreditBalance, len(ps))
  16216. for i := range ps {
  16217. p[i] = ps[i]
  16218. }
  16219. m.Where(p...)
  16220. }
  16221. // Op returns the operation name.
  16222. func (m *CreditBalanceMutation) Op() Op {
  16223. return m.op
  16224. }
  16225. // SetOp allows setting the mutation operation.
  16226. func (m *CreditBalanceMutation) SetOp(op Op) {
  16227. m.op = op
  16228. }
  16229. // Type returns the node type of this mutation (CreditBalance).
  16230. func (m *CreditBalanceMutation) Type() string {
  16231. return m.typ
  16232. }
  16233. // Fields returns all fields that were changed during this mutation. Note that in
  16234. // order to get all numeric fields that were incremented/decremented, call
  16235. // AddedFields().
  16236. func (m *CreditBalanceMutation) Fields() []string {
  16237. fields := make([]string, 0, 7)
  16238. if m.created_at != nil {
  16239. fields = append(fields, creditbalance.FieldCreatedAt)
  16240. }
  16241. if m.updated_at != nil {
  16242. fields = append(fields, creditbalance.FieldUpdatedAt)
  16243. }
  16244. if m.deleted_at != nil {
  16245. fields = append(fields, creditbalance.FieldDeletedAt)
  16246. }
  16247. if m.user_id != nil {
  16248. fields = append(fields, creditbalance.FieldUserID)
  16249. }
  16250. if m.balance != nil {
  16251. fields = append(fields, creditbalance.FieldBalance)
  16252. }
  16253. if m.status != nil {
  16254. fields = append(fields, creditbalance.FieldStatus)
  16255. }
  16256. if m.organization_id != nil {
  16257. fields = append(fields, creditbalance.FieldOrganizationID)
  16258. }
  16259. return fields
  16260. }
  16261. // Field returns the value of a field with the given name. The second boolean
  16262. // return value indicates that this field was not set, or was not defined in the
  16263. // schema.
  16264. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  16265. switch name {
  16266. case creditbalance.FieldCreatedAt:
  16267. return m.CreatedAt()
  16268. case creditbalance.FieldUpdatedAt:
  16269. return m.UpdatedAt()
  16270. case creditbalance.FieldDeletedAt:
  16271. return m.DeletedAt()
  16272. case creditbalance.FieldUserID:
  16273. return m.UserID()
  16274. case creditbalance.FieldBalance:
  16275. return m.Balance()
  16276. case creditbalance.FieldStatus:
  16277. return m.Status()
  16278. case creditbalance.FieldOrganizationID:
  16279. return m.OrganizationID()
  16280. }
  16281. return nil, false
  16282. }
  16283. // OldField returns the old value of the field from the database. An error is
  16284. // returned if the mutation operation is not UpdateOne, or the query to the
  16285. // database failed.
  16286. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16287. switch name {
  16288. case creditbalance.FieldCreatedAt:
  16289. return m.OldCreatedAt(ctx)
  16290. case creditbalance.FieldUpdatedAt:
  16291. return m.OldUpdatedAt(ctx)
  16292. case creditbalance.FieldDeletedAt:
  16293. return m.OldDeletedAt(ctx)
  16294. case creditbalance.FieldUserID:
  16295. return m.OldUserID(ctx)
  16296. case creditbalance.FieldBalance:
  16297. return m.OldBalance(ctx)
  16298. case creditbalance.FieldStatus:
  16299. return m.OldStatus(ctx)
  16300. case creditbalance.FieldOrganizationID:
  16301. return m.OldOrganizationID(ctx)
  16302. }
  16303. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  16304. }
  16305. // SetField sets the value of a field with the given name. It returns an error if
  16306. // the field is not defined in the schema, or if the type mismatched the field
  16307. // type.
  16308. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  16309. switch name {
  16310. case creditbalance.FieldCreatedAt:
  16311. v, ok := value.(time.Time)
  16312. if !ok {
  16313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16314. }
  16315. m.SetCreatedAt(v)
  16316. return nil
  16317. case creditbalance.FieldUpdatedAt:
  16318. v, ok := value.(time.Time)
  16319. if !ok {
  16320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16321. }
  16322. m.SetUpdatedAt(v)
  16323. return nil
  16324. case creditbalance.FieldDeletedAt:
  16325. v, ok := value.(time.Time)
  16326. if !ok {
  16327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16328. }
  16329. m.SetDeletedAt(v)
  16330. return nil
  16331. case creditbalance.FieldUserID:
  16332. v, ok := value.(string)
  16333. if !ok {
  16334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16335. }
  16336. m.SetUserID(v)
  16337. return nil
  16338. case creditbalance.FieldBalance:
  16339. v, ok := value.(float64)
  16340. if !ok {
  16341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16342. }
  16343. m.SetBalance(v)
  16344. return nil
  16345. case creditbalance.FieldStatus:
  16346. v, ok := value.(int)
  16347. if !ok {
  16348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16349. }
  16350. m.SetStatus(v)
  16351. return nil
  16352. case creditbalance.FieldOrganizationID:
  16353. v, ok := value.(uint64)
  16354. if !ok {
  16355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16356. }
  16357. m.SetOrganizationID(v)
  16358. return nil
  16359. }
  16360. return fmt.Errorf("unknown CreditBalance field %s", name)
  16361. }
  16362. // AddedFields returns all numeric fields that were incremented/decremented during
  16363. // this mutation.
  16364. func (m *CreditBalanceMutation) AddedFields() []string {
  16365. var fields []string
  16366. if m.addbalance != nil {
  16367. fields = append(fields, creditbalance.FieldBalance)
  16368. }
  16369. if m.addstatus != nil {
  16370. fields = append(fields, creditbalance.FieldStatus)
  16371. }
  16372. if m.addorganization_id != nil {
  16373. fields = append(fields, creditbalance.FieldOrganizationID)
  16374. }
  16375. return fields
  16376. }
  16377. // AddedField returns the numeric value that was incremented/decremented on a field
  16378. // with the given name. The second boolean return value indicates that this field
  16379. // was not set, or was not defined in the schema.
  16380. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  16381. switch name {
  16382. case creditbalance.FieldBalance:
  16383. return m.AddedBalance()
  16384. case creditbalance.FieldStatus:
  16385. return m.AddedStatus()
  16386. case creditbalance.FieldOrganizationID:
  16387. return m.AddedOrganizationID()
  16388. }
  16389. return nil, false
  16390. }
  16391. // AddField adds the value to the field with the given name. It returns an error if
  16392. // the field is not defined in the schema, or if the type mismatched the field
  16393. // type.
  16394. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  16395. switch name {
  16396. case creditbalance.FieldBalance:
  16397. v, ok := value.(float64)
  16398. if !ok {
  16399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16400. }
  16401. m.AddBalance(v)
  16402. return nil
  16403. case creditbalance.FieldStatus:
  16404. v, ok := value.(int)
  16405. if !ok {
  16406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16407. }
  16408. m.AddStatus(v)
  16409. return nil
  16410. case creditbalance.FieldOrganizationID:
  16411. v, ok := value.(int64)
  16412. if !ok {
  16413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16414. }
  16415. m.AddOrganizationID(v)
  16416. return nil
  16417. }
  16418. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  16419. }
  16420. // ClearedFields returns all nullable fields that were cleared during this
  16421. // mutation.
  16422. func (m *CreditBalanceMutation) ClearedFields() []string {
  16423. var fields []string
  16424. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  16425. fields = append(fields, creditbalance.FieldDeletedAt)
  16426. }
  16427. if m.FieldCleared(creditbalance.FieldUserID) {
  16428. fields = append(fields, creditbalance.FieldUserID)
  16429. }
  16430. if m.FieldCleared(creditbalance.FieldStatus) {
  16431. fields = append(fields, creditbalance.FieldStatus)
  16432. }
  16433. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  16434. fields = append(fields, creditbalance.FieldOrganizationID)
  16435. }
  16436. return fields
  16437. }
  16438. // FieldCleared returns a boolean indicating if a field with the given name was
  16439. // cleared in this mutation.
  16440. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  16441. _, ok := m.clearedFields[name]
  16442. return ok
  16443. }
  16444. // ClearField clears the value of the field with the given name. It returns an
  16445. // error if the field is not defined in the schema.
  16446. func (m *CreditBalanceMutation) ClearField(name string) error {
  16447. switch name {
  16448. case creditbalance.FieldDeletedAt:
  16449. m.ClearDeletedAt()
  16450. return nil
  16451. case creditbalance.FieldUserID:
  16452. m.ClearUserID()
  16453. return nil
  16454. case creditbalance.FieldStatus:
  16455. m.ClearStatus()
  16456. return nil
  16457. case creditbalance.FieldOrganizationID:
  16458. m.ClearOrganizationID()
  16459. return nil
  16460. }
  16461. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  16462. }
  16463. // ResetField resets all changes in the mutation for the field with the given name.
  16464. // It returns an error if the field is not defined in the schema.
  16465. func (m *CreditBalanceMutation) ResetField(name string) error {
  16466. switch name {
  16467. case creditbalance.FieldCreatedAt:
  16468. m.ResetCreatedAt()
  16469. return nil
  16470. case creditbalance.FieldUpdatedAt:
  16471. m.ResetUpdatedAt()
  16472. return nil
  16473. case creditbalance.FieldDeletedAt:
  16474. m.ResetDeletedAt()
  16475. return nil
  16476. case creditbalance.FieldUserID:
  16477. m.ResetUserID()
  16478. return nil
  16479. case creditbalance.FieldBalance:
  16480. m.ResetBalance()
  16481. return nil
  16482. case creditbalance.FieldStatus:
  16483. m.ResetStatus()
  16484. return nil
  16485. case creditbalance.FieldOrganizationID:
  16486. m.ResetOrganizationID()
  16487. return nil
  16488. }
  16489. return fmt.Errorf("unknown CreditBalance field %s", name)
  16490. }
  16491. // AddedEdges returns all edge names that were set/added in this mutation.
  16492. func (m *CreditBalanceMutation) AddedEdges() []string {
  16493. edges := make([]string, 0, 0)
  16494. return edges
  16495. }
  16496. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16497. // name in this mutation.
  16498. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  16499. return nil
  16500. }
  16501. // RemovedEdges returns all edge names that were removed in this mutation.
  16502. func (m *CreditBalanceMutation) RemovedEdges() []string {
  16503. edges := make([]string, 0, 0)
  16504. return edges
  16505. }
  16506. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16507. // the given name in this mutation.
  16508. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  16509. return nil
  16510. }
  16511. // ClearedEdges returns all edge names that were cleared in this mutation.
  16512. func (m *CreditBalanceMutation) ClearedEdges() []string {
  16513. edges := make([]string, 0, 0)
  16514. return edges
  16515. }
  16516. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16517. // was cleared in this mutation.
  16518. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  16519. return false
  16520. }
  16521. // ClearEdge clears the value of the edge with the given name. It returns an error
  16522. // if that edge is not defined in the schema.
  16523. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  16524. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  16525. }
  16526. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16527. // It returns an error if the edge is not defined in the schema.
  16528. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  16529. return fmt.Errorf("unknown CreditBalance edge %s", name)
  16530. }
  16531. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  16532. type CreditUsageMutation struct {
  16533. config
  16534. op Op
  16535. typ string
  16536. id *uint64
  16537. created_at *time.Time
  16538. updated_at *time.Time
  16539. deleted_at *time.Time
  16540. user_id *string
  16541. number *float64
  16542. addnumber *float64
  16543. pay_number *float64
  16544. addpay_number *float64
  16545. before_number *float64
  16546. addbefore_number *float64
  16547. after_number *float64
  16548. addafter_number *float64
  16549. pay_method *int
  16550. addpay_method *int
  16551. status *int
  16552. addstatus *int
  16553. ntype *int
  16554. addntype *int
  16555. table *string
  16556. organization_id *uint64
  16557. addorganization_id *int64
  16558. nid *uint64
  16559. addnid *int64
  16560. reason *string
  16561. operator *string
  16562. clearedFields map[string]struct{}
  16563. done bool
  16564. oldValue func(context.Context) (*CreditUsage, error)
  16565. predicates []predicate.CreditUsage
  16566. }
  16567. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  16568. // creditusageOption allows management of the mutation configuration using functional options.
  16569. type creditusageOption func(*CreditUsageMutation)
  16570. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  16571. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  16572. m := &CreditUsageMutation{
  16573. config: c,
  16574. op: op,
  16575. typ: TypeCreditUsage,
  16576. clearedFields: make(map[string]struct{}),
  16577. }
  16578. for _, opt := range opts {
  16579. opt(m)
  16580. }
  16581. return m
  16582. }
  16583. // withCreditUsageID sets the ID field of the mutation.
  16584. func withCreditUsageID(id uint64) creditusageOption {
  16585. return func(m *CreditUsageMutation) {
  16586. var (
  16587. err error
  16588. once sync.Once
  16589. value *CreditUsage
  16590. )
  16591. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  16592. once.Do(func() {
  16593. if m.done {
  16594. err = errors.New("querying old values post mutation is not allowed")
  16595. } else {
  16596. value, err = m.Client().CreditUsage.Get(ctx, id)
  16597. }
  16598. })
  16599. return value, err
  16600. }
  16601. m.id = &id
  16602. }
  16603. }
  16604. // withCreditUsage sets the old CreditUsage of the mutation.
  16605. func withCreditUsage(node *CreditUsage) creditusageOption {
  16606. return func(m *CreditUsageMutation) {
  16607. m.oldValue = func(context.Context) (*CreditUsage, error) {
  16608. return node, nil
  16609. }
  16610. m.id = &node.ID
  16611. }
  16612. }
  16613. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16614. // executed in a transaction (ent.Tx), a transactional client is returned.
  16615. func (m CreditUsageMutation) Client() *Client {
  16616. client := &Client{config: m.config}
  16617. client.init()
  16618. return client
  16619. }
  16620. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16621. // it returns an error otherwise.
  16622. func (m CreditUsageMutation) Tx() (*Tx, error) {
  16623. if _, ok := m.driver.(*txDriver); !ok {
  16624. return nil, errors.New("ent: mutation is not running in a transaction")
  16625. }
  16626. tx := &Tx{config: m.config}
  16627. tx.init()
  16628. return tx, nil
  16629. }
  16630. // SetID sets the value of the id field. Note that this
  16631. // operation is only accepted on creation of CreditUsage entities.
  16632. func (m *CreditUsageMutation) SetID(id uint64) {
  16633. m.id = &id
  16634. }
  16635. // ID returns the ID value in the mutation. Note that the ID is only available
  16636. // if it was provided to the builder or after it was returned from the database.
  16637. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  16638. if m.id == nil {
  16639. return
  16640. }
  16641. return *m.id, true
  16642. }
  16643. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16644. // That means, if the mutation is applied within a transaction with an isolation level such
  16645. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16646. // or updated by the mutation.
  16647. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  16648. switch {
  16649. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16650. id, exists := m.ID()
  16651. if exists {
  16652. return []uint64{id}, nil
  16653. }
  16654. fallthrough
  16655. case m.op.Is(OpUpdate | OpDelete):
  16656. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  16657. default:
  16658. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16659. }
  16660. }
  16661. // SetCreatedAt sets the "created_at" field.
  16662. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  16663. m.created_at = &t
  16664. }
  16665. // CreatedAt returns the value of the "created_at" field in the mutation.
  16666. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  16667. v := m.created_at
  16668. if v == nil {
  16669. return
  16670. }
  16671. return *v, true
  16672. }
  16673. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  16674. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16676. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16677. if !m.op.Is(OpUpdateOne) {
  16678. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16679. }
  16680. if m.id == nil || m.oldValue == nil {
  16681. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16682. }
  16683. oldValue, err := m.oldValue(ctx)
  16684. if err != nil {
  16685. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16686. }
  16687. return oldValue.CreatedAt, nil
  16688. }
  16689. // ResetCreatedAt resets all changes to the "created_at" field.
  16690. func (m *CreditUsageMutation) ResetCreatedAt() {
  16691. m.created_at = nil
  16692. }
  16693. // SetUpdatedAt sets the "updated_at" field.
  16694. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  16695. m.updated_at = &t
  16696. }
  16697. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16698. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  16699. v := m.updated_at
  16700. if v == nil {
  16701. return
  16702. }
  16703. return *v, true
  16704. }
  16705. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  16706. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16708. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16709. if !m.op.Is(OpUpdateOne) {
  16710. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16711. }
  16712. if m.id == nil || m.oldValue == nil {
  16713. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16714. }
  16715. oldValue, err := m.oldValue(ctx)
  16716. if err != nil {
  16717. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16718. }
  16719. return oldValue.UpdatedAt, nil
  16720. }
  16721. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16722. func (m *CreditUsageMutation) ResetUpdatedAt() {
  16723. m.updated_at = nil
  16724. }
  16725. // SetDeletedAt sets the "deleted_at" field.
  16726. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  16727. m.deleted_at = &t
  16728. }
  16729. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16730. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  16731. v := m.deleted_at
  16732. if v == nil {
  16733. return
  16734. }
  16735. return *v, true
  16736. }
  16737. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  16738. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16740. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16741. if !m.op.Is(OpUpdateOne) {
  16742. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16743. }
  16744. if m.id == nil || m.oldValue == nil {
  16745. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16746. }
  16747. oldValue, err := m.oldValue(ctx)
  16748. if err != nil {
  16749. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16750. }
  16751. return oldValue.DeletedAt, nil
  16752. }
  16753. // ClearDeletedAt clears the value of the "deleted_at" field.
  16754. func (m *CreditUsageMutation) ClearDeletedAt() {
  16755. m.deleted_at = nil
  16756. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  16757. }
  16758. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16759. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  16760. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  16761. return ok
  16762. }
  16763. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16764. func (m *CreditUsageMutation) ResetDeletedAt() {
  16765. m.deleted_at = nil
  16766. delete(m.clearedFields, creditusage.FieldDeletedAt)
  16767. }
  16768. // SetUserID sets the "user_id" field.
  16769. func (m *CreditUsageMutation) SetUserID(s string) {
  16770. m.user_id = &s
  16771. }
  16772. // UserID returns the value of the "user_id" field in the mutation.
  16773. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  16774. v := m.user_id
  16775. if v == nil {
  16776. return
  16777. }
  16778. return *v, true
  16779. }
  16780. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  16781. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16783. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  16784. if !m.op.Is(OpUpdateOne) {
  16785. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  16786. }
  16787. if m.id == nil || m.oldValue == nil {
  16788. return v, errors.New("OldUserID requires an ID field in the mutation")
  16789. }
  16790. oldValue, err := m.oldValue(ctx)
  16791. if err != nil {
  16792. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  16793. }
  16794. return oldValue.UserID, nil
  16795. }
  16796. // ClearUserID clears the value of the "user_id" field.
  16797. func (m *CreditUsageMutation) ClearUserID() {
  16798. m.user_id = nil
  16799. m.clearedFields[creditusage.FieldUserID] = struct{}{}
  16800. }
  16801. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  16802. func (m *CreditUsageMutation) UserIDCleared() bool {
  16803. _, ok := m.clearedFields[creditusage.FieldUserID]
  16804. return ok
  16805. }
  16806. // ResetUserID resets all changes to the "user_id" field.
  16807. func (m *CreditUsageMutation) ResetUserID() {
  16808. m.user_id = nil
  16809. delete(m.clearedFields, creditusage.FieldUserID)
  16810. }
  16811. // SetNumber sets the "number" field.
  16812. func (m *CreditUsageMutation) SetNumber(f float64) {
  16813. m.number = &f
  16814. m.addnumber = nil
  16815. }
  16816. // Number returns the value of the "number" field in the mutation.
  16817. func (m *CreditUsageMutation) Number() (r float64, exists bool) {
  16818. v := m.number
  16819. if v == nil {
  16820. return
  16821. }
  16822. return *v, true
  16823. }
  16824. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  16825. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16827. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float64, err error) {
  16828. if !m.op.Is(OpUpdateOne) {
  16829. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  16830. }
  16831. if m.id == nil || m.oldValue == nil {
  16832. return v, errors.New("OldNumber requires an ID field in the mutation")
  16833. }
  16834. oldValue, err := m.oldValue(ctx)
  16835. if err != nil {
  16836. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  16837. }
  16838. return oldValue.Number, nil
  16839. }
  16840. // AddNumber adds f to the "number" field.
  16841. func (m *CreditUsageMutation) AddNumber(f float64) {
  16842. if m.addnumber != nil {
  16843. *m.addnumber += f
  16844. } else {
  16845. m.addnumber = &f
  16846. }
  16847. }
  16848. // AddedNumber returns the value that was added to the "number" field in this mutation.
  16849. func (m *CreditUsageMutation) AddedNumber() (r float64, exists bool) {
  16850. v := m.addnumber
  16851. if v == nil {
  16852. return
  16853. }
  16854. return *v, true
  16855. }
  16856. // ResetNumber resets all changes to the "number" field.
  16857. func (m *CreditUsageMutation) ResetNumber() {
  16858. m.number = nil
  16859. m.addnumber = nil
  16860. }
  16861. // SetPayNumber sets the "pay_number" field.
  16862. func (m *CreditUsageMutation) SetPayNumber(f float64) {
  16863. m.pay_number = &f
  16864. m.addpay_number = nil
  16865. }
  16866. // PayNumber returns the value of the "pay_number" field in the mutation.
  16867. func (m *CreditUsageMutation) PayNumber() (r float64, exists bool) {
  16868. v := m.pay_number
  16869. if v == nil {
  16870. return
  16871. }
  16872. return *v, true
  16873. }
  16874. // OldPayNumber returns the old "pay_number" field's value of the CreditUsage entity.
  16875. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16877. func (m *CreditUsageMutation) OldPayNumber(ctx context.Context) (v float64, err error) {
  16878. if !m.op.Is(OpUpdateOne) {
  16879. return v, errors.New("OldPayNumber is only allowed on UpdateOne operations")
  16880. }
  16881. if m.id == nil || m.oldValue == nil {
  16882. return v, errors.New("OldPayNumber requires an ID field in the mutation")
  16883. }
  16884. oldValue, err := m.oldValue(ctx)
  16885. if err != nil {
  16886. return v, fmt.Errorf("querying old value for OldPayNumber: %w", err)
  16887. }
  16888. return oldValue.PayNumber, nil
  16889. }
  16890. // AddPayNumber adds f to the "pay_number" field.
  16891. func (m *CreditUsageMutation) AddPayNumber(f float64) {
  16892. if m.addpay_number != nil {
  16893. *m.addpay_number += f
  16894. } else {
  16895. m.addpay_number = &f
  16896. }
  16897. }
  16898. // AddedPayNumber returns the value that was added to the "pay_number" field in this mutation.
  16899. func (m *CreditUsageMutation) AddedPayNumber() (r float64, exists bool) {
  16900. v := m.addpay_number
  16901. if v == nil {
  16902. return
  16903. }
  16904. return *v, true
  16905. }
  16906. // ClearPayNumber clears the value of the "pay_number" field.
  16907. func (m *CreditUsageMutation) ClearPayNumber() {
  16908. m.pay_number = nil
  16909. m.addpay_number = nil
  16910. m.clearedFields[creditusage.FieldPayNumber] = struct{}{}
  16911. }
  16912. // PayNumberCleared returns if the "pay_number" field was cleared in this mutation.
  16913. func (m *CreditUsageMutation) PayNumberCleared() bool {
  16914. _, ok := m.clearedFields[creditusage.FieldPayNumber]
  16915. return ok
  16916. }
  16917. // ResetPayNumber resets all changes to the "pay_number" field.
  16918. func (m *CreditUsageMutation) ResetPayNumber() {
  16919. m.pay_number = nil
  16920. m.addpay_number = nil
  16921. delete(m.clearedFields, creditusage.FieldPayNumber)
  16922. }
  16923. // SetBeforeNumber sets the "before_number" field.
  16924. func (m *CreditUsageMutation) SetBeforeNumber(f float64) {
  16925. m.before_number = &f
  16926. m.addbefore_number = nil
  16927. }
  16928. // BeforeNumber returns the value of the "before_number" field in the mutation.
  16929. func (m *CreditUsageMutation) BeforeNumber() (r float64, exists bool) {
  16930. v := m.before_number
  16931. if v == nil {
  16932. return
  16933. }
  16934. return *v, true
  16935. }
  16936. // OldBeforeNumber returns the old "before_number" field's value of the CreditUsage entity.
  16937. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  16938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16939. func (m *CreditUsageMutation) OldBeforeNumber(ctx context.Context) (v float64, err error) {
  16940. if !m.op.Is(OpUpdateOne) {
  16941. return v, errors.New("OldBeforeNumber is only allowed on UpdateOne operations")
  16942. }
  16943. if m.id == nil || m.oldValue == nil {
  16944. return v, errors.New("OldBeforeNumber requires an ID field in the mutation")
  16945. }
  16946. oldValue, err := m.oldValue(ctx)
  16947. if err != nil {
  16948. return v, fmt.Errorf("querying old value for OldBeforeNumber: %w", err)
  16949. }
  16950. return oldValue.BeforeNumber, nil
  16951. }
  16952. // AddBeforeNumber adds f to the "before_number" field.
  16953. func (m *CreditUsageMutation) AddBeforeNumber(f float64) {
  16954. if m.addbefore_number != nil {
  16955. *m.addbefore_number += f
  16956. } else {
  16957. m.addbefore_number = &f
  16958. }
  16959. }
  16960. // AddedBeforeNumber returns the value that was added to the "before_number" field in this mutation.
  16961. func (m *CreditUsageMutation) AddedBeforeNumber() (r float64, exists bool) {
  16962. v := m.addbefore_number
  16963. if v == nil {
  16964. return
  16965. }
  16966. return *v, true
  16967. }
  16968. // ClearBeforeNumber clears the value of the "before_number" field.
  16969. func (m *CreditUsageMutation) ClearBeforeNumber() {
  16970. m.before_number = nil
  16971. m.addbefore_number = nil
  16972. m.clearedFields[creditusage.FieldBeforeNumber] = struct{}{}
  16973. }
  16974. // BeforeNumberCleared returns if the "before_number" field was cleared in this mutation.
  16975. func (m *CreditUsageMutation) BeforeNumberCleared() bool {
  16976. _, ok := m.clearedFields[creditusage.FieldBeforeNumber]
  16977. return ok
  16978. }
  16979. // ResetBeforeNumber resets all changes to the "before_number" field.
  16980. func (m *CreditUsageMutation) ResetBeforeNumber() {
  16981. m.before_number = nil
  16982. m.addbefore_number = nil
  16983. delete(m.clearedFields, creditusage.FieldBeforeNumber)
  16984. }
  16985. // SetAfterNumber sets the "after_number" field.
  16986. func (m *CreditUsageMutation) SetAfterNumber(f float64) {
  16987. m.after_number = &f
  16988. m.addafter_number = nil
  16989. }
  16990. // AfterNumber returns the value of the "after_number" field in the mutation.
  16991. func (m *CreditUsageMutation) AfterNumber() (r float64, exists bool) {
  16992. v := m.after_number
  16993. if v == nil {
  16994. return
  16995. }
  16996. return *v, true
  16997. }
  16998. // OldAfterNumber returns the old "after_number" field's value of the CreditUsage entity.
  16999. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17001. func (m *CreditUsageMutation) OldAfterNumber(ctx context.Context) (v float64, err error) {
  17002. if !m.op.Is(OpUpdateOne) {
  17003. return v, errors.New("OldAfterNumber is only allowed on UpdateOne operations")
  17004. }
  17005. if m.id == nil || m.oldValue == nil {
  17006. return v, errors.New("OldAfterNumber requires an ID field in the mutation")
  17007. }
  17008. oldValue, err := m.oldValue(ctx)
  17009. if err != nil {
  17010. return v, fmt.Errorf("querying old value for OldAfterNumber: %w", err)
  17011. }
  17012. return oldValue.AfterNumber, nil
  17013. }
  17014. // AddAfterNumber adds f to the "after_number" field.
  17015. func (m *CreditUsageMutation) AddAfterNumber(f float64) {
  17016. if m.addafter_number != nil {
  17017. *m.addafter_number += f
  17018. } else {
  17019. m.addafter_number = &f
  17020. }
  17021. }
  17022. // AddedAfterNumber returns the value that was added to the "after_number" field in this mutation.
  17023. func (m *CreditUsageMutation) AddedAfterNumber() (r float64, exists bool) {
  17024. v := m.addafter_number
  17025. if v == nil {
  17026. return
  17027. }
  17028. return *v, true
  17029. }
  17030. // ClearAfterNumber clears the value of the "after_number" field.
  17031. func (m *CreditUsageMutation) ClearAfterNumber() {
  17032. m.after_number = nil
  17033. m.addafter_number = nil
  17034. m.clearedFields[creditusage.FieldAfterNumber] = struct{}{}
  17035. }
  17036. // AfterNumberCleared returns if the "after_number" field was cleared in this mutation.
  17037. func (m *CreditUsageMutation) AfterNumberCleared() bool {
  17038. _, ok := m.clearedFields[creditusage.FieldAfterNumber]
  17039. return ok
  17040. }
  17041. // ResetAfterNumber resets all changes to the "after_number" field.
  17042. func (m *CreditUsageMutation) ResetAfterNumber() {
  17043. m.after_number = nil
  17044. m.addafter_number = nil
  17045. delete(m.clearedFields, creditusage.FieldAfterNumber)
  17046. }
  17047. // SetPayMethod sets the "pay_method" field.
  17048. func (m *CreditUsageMutation) SetPayMethod(i int) {
  17049. m.pay_method = &i
  17050. m.addpay_method = nil
  17051. }
  17052. // PayMethod returns the value of the "pay_method" field in the mutation.
  17053. func (m *CreditUsageMutation) PayMethod() (r int, exists bool) {
  17054. v := m.pay_method
  17055. if v == nil {
  17056. return
  17057. }
  17058. return *v, true
  17059. }
  17060. // OldPayMethod returns the old "pay_method" field's value of the CreditUsage entity.
  17061. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17063. func (m *CreditUsageMutation) OldPayMethod(ctx context.Context) (v int, err error) {
  17064. if !m.op.Is(OpUpdateOne) {
  17065. return v, errors.New("OldPayMethod is only allowed on UpdateOne operations")
  17066. }
  17067. if m.id == nil || m.oldValue == nil {
  17068. return v, errors.New("OldPayMethod requires an ID field in the mutation")
  17069. }
  17070. oldValue, err := m.oldValue(ctx)
  17071. if err != nil {
  17072. return v, fmt.Errorf("querying old value for OldPayMethod: %w", err)
  17073. }
  17074. return oldValue.PayMethod, nil
  17075. }
  17076. // AddPayMethod adds i to the "pay_method" field.
  17077. func (m *CreditUsageMutation) AddPayMethod(i int) {
  17078. if m.addpay_method != nil {
  17079. *m.addpay_method += i
  17080. } else {
  17081. m.addpay_method = &i
  17082. }
  17083. }
  17084. // AddedPayMethod returns the value that was added to the "pay_method" field in this mutation.
  17085. func (m *CreditUsageMutation) AddedPayMethod() (r int, exists bool) {
  17086. v := m.addpay_method
  17087. if v == nil {
  17088. return
  17089. }
  17090. return *v, true
  17091. }
  17092. // ClearPayMethod clears the value of the "pay_method" field.
  17093. func (m *CreditUsageMutation) ClearPayMethod() {
  17094. m.pay_method = nil
  17095. m.addpay_method = nil
  17096. m.clearedFields[creditusage.FieldPayMethod] = struct{}{}
  17097. }
  17098. // PayMethodCleared returns if the "pay_method" field was cleared in this mutation.
  17099. func (m *CreditUsageMutation) PayMethodCleared() bool {
  17100. _, ok := m.clearedFields[creditusage.FieldPayMethod]
  17101. return ok
  17102. }
  17103. // ResetPayMethod resets all changes to the "pay_method" field.
  17104. func (m *CreditUsageMutation) ResetPayMethod() {
  17105. m.pay_method = nil
  17106. m.addpay_method = nil
  17107. delete(m.clearedFields, creditusage.FieldPayMethod)
  17108. }
  17109. // SetStatus sets the "status" field.
  17110. func (m *CreditUsageMutation) SetStatus(i int) {
  17111. m.status = &i
  17112. m.addstatus = nil
  17113. }
  17114. // Status returns the value of the "status" field in the mutation.
  17115. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  17116. v := m.status
  17117. if v == nil {
  17118. return
  17119. }
  17120. return *v, true
  17121. }
  17122. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  17123. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17125. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  17126. if !m.op.Is(OpUpdateOne) {
  17127. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17128. }
  17129. if m.id == nil || m.oldValue == nil {
  17130. return v, errors.New("OldStatus requires an ID field in the mutation")
  17131. }
  17132. oldValue, err := m.oldValue(ctx)
  17133. if err != nil {
  17134. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17135. }
  17136. return oldValue.Status, nil
  17137. }
  17138. // AddStatus adds i to the "status" field.
  17139. func (m *CreditUsageMutation) AddStatus(i int) {
  17140. if m.addstatus != nil {
  17141. *m.addstatus += i
  17142. } else {
  17143. m.addstatus = &i
  17144. }
  17145. }
  17146. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17147. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  17148. v := m.addstatus
  17149. if v == nil {
  17150. return
  17151. }
  17152. return *v, true
  17153. }
  17154. // ClearStatus clears the value of the "status" field.
  17155. func (m *CreditUsageMutation) ClearStatus() {
  17156. m.status = nil
  17157. m.addstatus = nil
  17158. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  17159. }
  17160. // StatusCleared returns if the "status" field was cleared in this mutation.
  17161. func (m *CreditUsageMutation) StatusCleared() bool {
  17162. _, ok := m.clearedFields[creditusage.FieldStatus]
  17163. return ok
  17164. }
  17165. // ResetStatus resets all changes to the "status" field.
  17166. func (m *CreditUsageMutation) ResetStatus() {
  17167. m.status = nil
  17168. m.addstatus = nil
  17169. delete(m.clearedFields, creditusage.FieldStatus)
  17170. }
  17171. // SetNtype sets the "ntype" field.
  17172. func (m *CreditUsageMutation) SetNtype(i int) {
  17173. m.ntype = &i
  17174. m.addntype = nil
  17175. }
  17176. // Ntype returns the value of the "ntype" field in the mutation.
  17177. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  17178. v := m.ntype
  17179. if v == nil {
  17180. return
  17181. }
  17182. return *v, true
  17183. }
  17184. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  17185. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17187. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  17188. if !m.op.Is(OpUpdateOne) {
  17189. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  17190. }
  17191. if m.id == nil || m.oldValue == nil {
  17192. return v, errors.New("OldNtype requires an ID field in the mutation")
  17193. }
  17194. oldValue, err := m.oldValue(ctx)
  17195. if err != nil {
  17196. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  17197. }
  17198. return oldValue.Ntype, nil
  17199. }
  17200. // AddNtype adds i to the "ntype" field.
  17201. func (m *CreditUsageMutation) AddNtype(i int) {
  17202. if m.addntype != nil {
  17203. *m.addntype += i
  17204. } else {
  17205. m.addntype = &i
  17206. }
  17207. }
  17208. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  17209. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  17210. v := m.addntype
  17211. if v == nil {
  17212. return
  17213. }
  17214. return *v, true
  17215. }
  17216. // ResetNtype resets all changes to the "ntype" field.
  17217. func (m *CreditUsageMutation) ResetNtype() {
  17218. m.ntype = nil
  17219. m.addntype = nil
  17220. }
  17221. // SetTable sets the "table" field.
  17222. func (m *CreditUsageMutation) SetTable(s string) {
  17223. m.table = &s
  17224. }
  17225. // Table returns the value of the "table" field in the mutation.
  17226. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  17227. v := m.table
  17228. if v == nil {
  17229. return
  17230. }
  17231. return *v, true
  17232. }
  17233. // OldTable returns the old "table" field's value of the CreditUsage entity.
  17234. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17236. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  17237. if !m.op.Is(OpUpdateOne) {
  17238. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  17239. }
  17240. if m.id == nil || m.oldValue == nil {
  17241. return v, errors.New("OldTable requires an ID field in the mutation")
  17242. }
  17243. oldValue, err := m.oldValue(ctx)
  17244. if err != nil {
  17245. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  17246. }
  17247. return oldValue.Table, nil
  17248. }
  17249. // ResetTable resets all changes to the "table" field.
  17250. func (m *CreditUsageMutation) ResetTable() {
  17251. m.table = nil
  17252. }
  17253. // SetOrganizationID sets the "organization_id" field.
  17254. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  17255. m.organization_id = &u
  17256. m.addorganization_id = nil
  17257. }
  17258. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17259. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  17260. v := m.organization_id
  17261. if v == nil {
  17262. return
  17263. }
  17264. return *v, true
  17265. }
  17266. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  17267. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17269. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17270. if !m.op.Is(OpUpdateOne) {
  17271. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17272. }
  17273. if m.id == nil || m.oldValue == nil {
  17274. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17275. }
  17276. oldValue, err := m.oldValue(ctx)
  17277. if err != nil {
  17278. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17279. }
  17280. return oldValue.OrganizationID, nil
  17281. }
  17282. // AddOrganizationID adds u to the "organization_id" field.
  17283. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  17284. if m.addorganization_id != nil {
  17285. *m.addorganization_id += u
  17286. } else {
  17287. m.addorganization_id = &u
  17288. }
  17289. }
  17290. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17291. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  17292. v := m.addorganization_id
  17293. if v == nil {
  17294. return
  17295. }
  17296. return *v, true
  17297. }
  17298. // ClearOrganizationID clears the value of the "organization_id" field.
  17299. func (m *CreditUsageMutation) ClearOrganizationID() {
  17300. m.organization_id = nil
  17301. m.addorganization_id = nil
  17302. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  17303. }
  17304. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17305. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  17306. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  17307. return ok
  17308. }
  17309. // ResetOrganizationID resets all changes to the "organization_id" field.
  17310. func (m *CreditUsageMutation) ResetOrganizationID() {
  17311. m.organization_id = nil
  17312. m.addorganization_id = nil
  17313. delete(m.clearedFields, creditusage.FieldOrganizationID)
  17314. }
  17315. // SetNid sets the "nid" field.
  17316. func (m *CreditUsageMutation) SetNid(u uint64) {
  17317. m.nid = &u
  17318. m.addnid = nil
  17319. }
  17320. // Nid returns the value of the "nid" field in the mutation.
  17321. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  17322. v := m.nid
  17323. if v == nil {
  17324. return
  17325. }
  17326. return *v, true
  17327. }
  17328. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  17329. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17331. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  17332. if !m.op.Is(OpUpdateOne) {
  17333. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  17334. }
  17335. if m.id == nil || m.oldValue == nil {
  17336. return v, errors.New("OldNid requires an ID field in the mutation")
  17337. }
  17338. oldValue, err := m.oldValue(ctx)
  17339. if err != nil {
  17340. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  17341. }
  17342. return oldValue.Nid, nil
  17343. }
  17344. // AddNid adds u to the "nid" field.
  17345. func (m *CreditUsageMutation) AddNid(u int64) {
  17346. if m.addnid != nil {
  17347. *m.addnid += u
  17348. } else {
  17349. m.addnid = &u
  17350. }
  17351. }
  17352. // AddedNid returns the value that was added to the "nid" field in this mutation.
  17353. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  17354. v := m.addnid
  17355. if v == nil {
  17356. return
  17357. }
  17358. return *v, true
  17359. }
  17360. // ResetNid resets all changes to the "nid" field.
  17361. func (m *CreditUsageMutation) ResetNid() {
  17362. m.nid = nil
  17363. m.addnid = nil
  17364. }
  17365. // SetReason sets the "reason" field.
  17366. func (m *CreditUsageMutation) SetReason(s string) {
  17367. m.reason = &s
  17368. }
  17369. // Reason returns the value of the "reason" field in the mutation.
  17370. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  17371. v := m.reason
  17372. if v == nil {
  17373. return
  17374. }
  17375. return *v, true
  17376. }
  17377. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  17378. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17380. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  17381. if !m.op.Is(OpUpdateOne) {
  17382. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  17383. }
  17384. if m.id == nil || m.oldValue == nil {
  17385. return v, errors.New("OldReason requires an ID field in the mutation")
  17386. }
  17387. oldValue, err := m.oldValue(ctx)
  17388. if err != nil {
  17389. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  17390. }
  17391. return oldValue.Reason, nil
  17392. }
  17393. // ResetReason resets all changes to the "reason" field.
  17394. func (m *CreditUsageMutation) ResetReason() {
  17395. m.reason = nil
  17396. }
  17397. // SetOperator sets the "operator" field.
  17398. func (m *CreditUsageMutation) SetOperator(s string) {
  17399. m.operator = &s
  17400. }
  17401. // Operator returns the value of the "operator" field in the mutation.
  17402. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  17403. v := m.operator
  17404. if v == nil {
  17405. return
  17406. }
  17407. return *v, true
  17408. }
  17409. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  17410. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  17411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17412. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  17413. if !m.op.Is(OpUpdateOne) {
  17414. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  17415. }
  17416. if m.id == nil || m.oldValue == nil {
  17417. return v, errors.New("OldOperator requires an ID field in the mutation")
  17418. }
  17419. oldValue, err := m.oldValue(ctx)
  17420. if err != nil {
  17421. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  17422. }
  17423. return oldValue.Operator, nil
  17424. }
  17425. // ResetOperator resets all changes to the "operator" field.
  17426. func (m *CreditUsageMutation) ResetOperator() {
  17427. m.operator = nil
  17428. }
  17429. // Where appends a list predicates to the CreditUsageMutation builder.
  17430. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  17431. m.predicates = append(m.predicates, ps...)
  17432. }
  17433. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  17434. // users can use type-assertion to append predicates that do not depend on any generated package.
  17435. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  17436. p := make([]predicate.CreditUsage, len(ps))
  17437. for i := range ps {
  17438. p[i] = ps[i]
  17439. }
  17440. m.Where(p...)
  17441. }
  17442. // Op returns the operation name.
  17443. func (m *CreditUsageMutation) Op() Op {
  17444. return m.op
  17445. }
  17446. // SetOp allows setting the mutation operation.
  17447. func (m *CreditUsageMutation) SetOp(op Op) {
  17448. m.op = op
  17449. }
  17450. // Type returns the node type of this mutation (CreditUsage).
  17451. func (m *CreditUsageMutation) Type() string {
  17452. return m.typ
  17453. }
  17454. // Fields returns all fields that were changed during this mutation. Note that in
  17455. // order to get all numeric fields that were incremented/decremented, call
  17456. // AddedFields().
  17457. func (m *CreditUsageMutation) Fields() []string {
  17458. fields := make([]string, 0, 16)
  17459. if m.created_at != nil {
  17460. fields = append(fields, creditusage.FieldCreatedAt)
  17461. }
  17462. if m.updated_at != nil {
  17463. fields = append(fields, creditusage.FieldUpdatedAt)
  17464. }
  17465. if m.deleted_at != nil {
  17466. fields = append(fields, creditusage.FieldDeletedAt)
  17467. }
  17468. if m.user_id != nil {
  17469. fields = append(fields, creditusage.FieldUserID)
  17470. }
  17471. if m.number != nil {
  17472. fields = append(fields, creditusage.FieldNumber)
  17473. }
  17474. if m.pay_number != nil {
  17475. fields = append(fields, creditusage.FieldPayNumber)
  17476. }
  17477. if m.before_number != nil {
  17478. fields = append(fields, creditusage.FieldBeforeNumber)
  17479. }
  17480. if m.after_number != nil {
  17481. fields = append(fields, creditusage.FieldAfterNumber)
  17482. }
  17483. if m.pay_method != nil {
  17484. fields = append(fields, creditusage.FieldPayMethod)
  17485. }
  17486. if m.status != nil {
  17487. fields = append(fields, creditusage.FieldStatus)
  17488. }
  17489. if m.ntype != nil {
  17490. fields = append(fields, creditusage.FieldNtype)
  17491. }
  17492. if m.table != nil {
  17493. fields = append(fields, creditusage.FieldTable)
  17494. }
  17495. if m.organization_id != nil {
  17496. fields = append(fields, creditusage.FieldOrganizationID)
  17497. }
  17498. if m.nid != nil {
  17499. fields = append(fields, creditusage.FieldNid)
  17500. }
  17501. if m.reason != nil {
  17502. fields = append(fields, creditusage.FieldReason)
  17503. }
  17504. if m.operator != nil {
  17505. fields = append(fields, creditusage.FieldOperator)
  17506. }
  17507. return fields
  17508. }
  17509. // Field returns the value of a field with the given name. The second boolean
  17510. // return value indicates that this field was not set, or was not defined in the
  17511. // schema.
  17512. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  17513. switch name {
  17514. case creditusage.FieldCreatedAt:
  17515. return m.CreatedAt()
  17516. case creditusage.FieldUpdatedAt:
  17517. return m.UpdatedAt()
  17518. case creditusage.FieldDeletedAt:
  17519. return m.DeletedAt()
  17520. case creditusage.FieldUserID:
  17521. return m.UserID()
  17522. case creditusage.FieldNumber:
  17523. return m.Number()
  17524. case creditusage.FieldPayNumber:
  17525. return m.PayNumber()
  17526. case creditusage.FieldBeforeNumber:
  17527. return m.BeforeNumber()
  17528. case creditusage.FieldAfterNumber:
  17529. return m.AfterNumber()
  17530. case creditusage.FieldPayMethod:
  17531. return m.PayMethod()
  17532. case creditusage.FieldStatus:
  17533. return m.Status()
  17534. case creditusage.FieldNtype:
  17535. return m.Ntype()
  17536. case creditusage.FieldTable:
  17537. return m.Table()
  17538. case creditusage.FieldOrganizationID:
  17539. return m.OrganizationID()
  17540. case creditusage.FieldNid:
  17541. return m.Nid()
  17542. case creditusage.FieldReason:
  17543. return m.Reason()
  17544. case creditusage.FieldOperator:
  17545. return m.Operator()
  17546. }
  17547. return nil, false
  17548. }
  17549. // OldField returns the old value of the field from the database. An error is
  17550. // returned if the mutation operation is not UpdateOne, or the query to the
  17551. // database failed.
  17552. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17553. switch name {
  17554. case creditusage.FieldCreatedAt:
  17555. return m.OldCreatedAt(ctx)
  17556. case creditusage.FieldUpdatedAt:
  17557. return m.OldUpdatedAt(ctx)
  17558. case creditusage.FieldDeletedAt:
  17559. return m.OldDeletedAt(ctx)
  17560. case creditusage.FieldUserID:
  17561. return m.OldUserID(ctx)
  17562. case creditusage.FieldNumber:
  17563. return m.OldNumber(ctx)
  17564. case creditusage.FieldPayNumber:
  17565. return m.OldPayNumber(ctx)
  17566. case creditusage.FieldBeforeNumber:
  17567. return m.OldBeforeNumber(ctx)
  17568. case creditusage.FieldAfterNumber:
  17569. return m.OldAfterNumber(ctx)
  17570. case creditusage.FieldPayMethod:
  17571. return m.OldPayMethod(ctx)
  17572. case creditusage.FieldStatus:
  17573. return m.OldStatus(ctx)
  17574. case creditusage.FieldNtype:
  17575. return m.OldNtype(ctx)
  17576. case creditusage.FieldTable:
  17577. return m.OldTable(ctx)
  17578. case creditusage.FieldOrganizationID:
  17579. return m.OldOrganizationID(ctx)
  17580. case creditusage.FieldNid:
  17581. return m.OldNid(ctx)
  17582. case creditusage.FieldReason:
  17583. return m.OldReason(ctx)
  17584. case creditusage.FieldOperator:
  17585. return m.OldOperator(ctx)
  17586. }
  17587. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  17588. }
  17589. // SetField sets the value of a field with the given name. It returns an error if
  17590. // the field is not defined in the schema, or if the type mismatched the field
  17591. // type.
  17592. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  17593. switch name {
  17594. case creditusage.FieldCreatedAt:
  17595. v, ok := value.(time.Time)
  17596. if !ok {
  17597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17598. }
  17599. m.SetCreatedAt(v)
  17600. return nil
  17601. case creditusage.FieldUpdatedAt:
  17602. v, ok := value.(time.Time)
  17603. if !ok {
  17604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17605. }
  17606. m.SetUpdatedAt(v)
  17607. return nil
  17608. case creditusage.FieldDeletedAt:
  17609. v, ok := value.(time.Time)
  17610. if !ok {
  17611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17612. }
  17613. m.SetDeletedAt(v)
  17614. return nil
  17615. case creditusage.FieldUserID:
  17616. v, ok := value.(string)
  17617. if !ok {
  17618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17619. }
  17620. m.SetUserID(v)
  17621. return nil
  17622. case creditusage.FieldNumber:
  17623. v, ok := value.(float64)
  17624. if !ok {
  17625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17626. }
  17627. m.SetNumber(v)
  17628. return nil
  17629. case creditusage.FieldPayNumber:
  17630. v, ok := value.(float64)
  17631. if !ok {
  17632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17633. }
  17634. m.SetPayNumber(v)
  17635. return nil
  17636. case creditusage.FieldBeforeNumber:
  17637. v, ok := value.(float64)
  17638. if !ok {
  17639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17640. }
  17641. m.SetBeforeNumber(v)
  17642. return nil
  17643. case creditusage.FieldAfterNumber:
  17644. v, ok := value.(float64)
  17645. if !ok {
  17646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17647. }
  17648. m.SetAfterNumber(v)
  17649. return nil
  17650. case creditusage.FieldPayMethod:
  17651. v, ok := value.(int)
  17652. if !ok {
  17653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17654. }
  17655. m.SetPayMethod(v)
  17656. return nil
  17657. case creditusage.FieldStatus:
  17658. v, ok := value.(int)
  17659. if !ok {
  17660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17661. }
  17662. m.SetStatus(v)
  17663. return nil
  17664. case creditusage.FieldNtype:
  17665. v, ok := value.(int)
  17666. if !ok {
  17667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17668. }
  17669. m.SetNtype(v)
  17670. return nil
  17671. case creditusage.FieldTable:
  17672. v, ok := value.(string)
  17673. if !ok {
  17674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17675. }
  17676. m.SetTable(v)
  17677. return nil
  17678. case creditusage.FieldOrganizationID:
  17679. v, ok := value.(uint64)
  17680. if !ok {
  17681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17682. }
  17683. m.SetOrganizationID(v)
  17684. return nil
  17685. case creditusage.FieldNid:
  17686. v, ok := value.(uint64)
  17687. if !ok {
  17688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17689. }
  17690. m.SetNid(v)
  17691. return nil
  17692. case creditusage.FieldReason:
  17693. v, ok := value.(string)
  17694. if !ok {
  17695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17696. }
  17697. m.SetReason(v)
  17698. return nil
  17699. case creditusage.FieldOperator:
  17700. v, ok := value.(string)
  17701. if !ok {
  17702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17703. }
  17704. m.SetOperator(v)
  17705. return nil
  17706. }
  17707. return fmt.Errorf("unknown CreditUsage field %s", name)
  17708. }
  17709. // AddedFields returns all numeric fields that were incremented/decremented during
  17710. // this mutation.
  17711. func (m *CreditUsageMutation) AddedFields() []string {
  17712. var fields []string
  17713. if m.addnumber != nil {
  17714. fields = append(fields, creditusage.FieldNumber)
  17715. }
  17716. if m.addpay_number != nil {
  17717. fields = append(fields, creditusage.FieldPayNumber)
  17718. }
  17719. if m.addbefore_number != nil {
  17720. fields = append(fields, creditusage.FieldBeforeNumber)
  17721. }
  17722. if m.addafter_number != nil {
  17723. fields = append(fields, creditusage.FieldAfterNumber)
  17724. }
  17725. if m.addpay_method != nil {
  17726. fields = append(fields, creditusage.FieldPayMethod)
  17727. }
  17728. if m.addstatus != nil {
  17729. fields = append(fields, creditusage.FieldStatus)
  17730. }
  17731. if m.addntype != nil {
  17732. fields = append(fields, creditusage.FieldNtype)
  17733. }
  17734. if m.addorganization_id != nil {
  17735. fields = append(fields, creditusage.FieldOrganizationID)
  17736. }
  17737. if m.addnid != nil {
  17738. fields = append(fields, creditusage.FieldNid)
  17739. }
  17740. return fields
  17741. }
  17742. // AddedField returns the numeric value that was incremented/decremented on a field
  17743. // with the given name. The second boolean return value indicates that this field
  17744. // was not set, or was not defined in the schema.
  17745. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  17746. switch name {
  17747. case creditusage.FieldNumber:
  17748. return m.AddedNumber()
  17749. case creditusage.FieldPayNumber:
  17750. return m.AddedPayNumber()
  17751. case creditusage.FieldBeforeNumber:
  17752. return m.AddedBeforeNumber()
  17753. case creditusage.FieldAfterNumber:
  17754. return m.AddedAfterNumber()
  17755. case creditusage.FieldPayMethod:
  17756. return m.AddedPayMethod()
  17757. case creditusage.FieldStatus:
  17758. return m.AddedStatus()
  17759. case creditusage.FieldNtype:
  17760. return m.AddedNtype()
  17761. case creditusage.FieldOrganizationID:
  17762. return m.AddedOrganizationID()
  17763. case creditusage.FieldNid:
  17764. return m.AddedNid()
  17765. }
  17766. return nil, false
  17767. }
  17768. // AddField adds the value to the field with the given name. It returns an error if
  17769. // the field is not defined in the schema, or if the type mismatched the field
  17770. // type.
  17771. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  17772. switch name {
  17773. case creditusage.FieldNumber:
  17774. v, ok := value.(float64)
  17775. if !ok {
  17776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17777. }
  17778. m.AddNumber(v)
  17779. return nil
  17780. case creditusage.FieldPayNumber:
  17781. v, ok := value.(float64)
  17782. if !ok {
  17783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17784. }
  17785. m.AddPayNumber(v)
  17786. return nil
  17787. case creditusage.FieldBeforeNumber:
  17788. v, ok := value.(float64)
  17789. if !ok {
  17790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17791. }
  17792. m.AddBeforeNumber(v)
  17793. return nil
  17794. case creditusage.FieldAfterNumber:
  17795. v, ok := value.(float64)
  17796. if !ok {
  17797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17798. }
  17799. m.AddAfterNumber(v)
  17800. return nil
  17801. case creditusage.FieldPayMethod:
  17802. v, ok := value.(int)
  17803. if !ok {
  17804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17805. }
  17806. m.AddPayMethod(v)
  17807. return nil
  17808. case creditusage.FieldStatus:
  17809. v, ok := value.(int)
  17810. if !ok {
  17811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17812. }
  17813. m.AddStatus(v)
  17814. return nil
  17815. case creditusage.FieldNtype:
  17816. v, ok := value.(int)
  17817. if !ok {
  17818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17819. }
  17820. m.AddNtype(v)
  17821. return nil
  17822. case creditusage.FieldOrganizationID:
  17823. v, ok := value.(int64)
  17824. if !ok {
  17825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17826. }
  17827. m.AddOrganizationID(v)
  17828. return nil
  17829. case creditusage.FieldNid:
  17830. v, ok := value.(int64)
  17831. if !ok {
  17832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17833. }
  17834. m.AddNid(v)
  17835. return nil
  17836. }
  17837. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  17838. }
  17839. // ClearedFields returns all nullable fields that were cleared during this
  17840. // mutation.
  17841. func (m *CreditUsageMutation) ClearedFields() []string {
  17842. var fields []string
  17843. if m.FieldCleared(creditusage.FieldDeletedAt) {
  17844. fields = append(fields, creditusage.FieldDeletedAt)
  17845. }
  17846. if m.FieldCleared(creditusage.FieldUserID) {
  17847. fields = append(fields, creditusage.FieldUserID)
  17848. }
  17849. if m.FieldCleared(creditusage.FieldPayNumber) {
  17850. fields = append(fields, creditusage.FieldPayNumber)
  17851. }
  17852. if m.FieldCleared(creditusage.FieldBeforeNumber) {
  17853. fields = append(fields, creditusage.FieldBeforeNumber)
  17854. }
  17855. if m.FieldCleared(creditusage.FieldAfterNumber) {
  17856. fields = append(fields, creditusage.FieldAfterNumber)
  17857. }
  17858. if m.FieldCleared(creditusage.FieldPayMethod) {
  17859. fields = append(fields, creditusage.FieldPayMethod)
  17860. }
  17861. if m.FieldCleared(creditusage.FieldStatus) {
  17862. fields = append(fields, creditusage.FieldStatus)
  17863. }
  17864. if m.FieldCleared(creditusage.FieldOrganizationID) {
  17865. fields = append(fields, creditusage.FieldOrganizationID)
  17866. }
  17867. return fields
  17868. }
  17869. // FieldCleared returns a boolean indicating if a field with the given name was
  17870. // cleared in this mutation.
  17871. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  17872. _, ok := m.clearedFields[name]
  17873. return ok
  17874. }
  17875. // ClearField clears the value of the field with the given name. It returns an
  17876. // error if the field is not defined in the schema.
  17877. func (m *CreditUsageMutation) ClearField(name string) error {
  17878. switch name {
  17879. case creditusage.FieldDeletedAt:
  17880. m.ClearDeletedAt()
  17881. return nil
  17882. case creditusage.FieldUserID:
  17883. m.ClearUserID()
  17884. return nil
  17885. case creditusage.FieldPayNumber:
  17886. m.ClearPayNumber()
  17887. return nil
  17888. case creditusage.FieldBeforeNumber:
  17889. m.ClearBeforeNumber()
  17890. return nil
  17891. case creditusage.FieldAfterNumber:
  17892. m.ClearAfterNumber()
  17893. return nil
  17894. case creditusage.FieldPayMethod:
  17895. m.ClearPayMethod()
  17896. return nil
  17897. case creditusage.FieldStatus:
  17898. m.ClearStatus()
  17899. return nil
  17900. case creditusage.FieldOrganizationID:
  17901. m.ClearOrganizationID()
  17902. return nil
  17903. }
  17904. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  17905. }
  17906. // ResetField resets all changes in the mutation for the field with the given name.
  17907. // It returns an error if the field is not defined in the schema.
  17908. func (m *CreditUsageMutation) ResetField(name string) error {
  17909. switch name {
  17910. case creditusage.FieldCreatedAt:
  17911. m.ResetCreatedAt()
  17912. return nil
  17913. case creditusage.FieldUpdatedAt:
  17914. m.ResetUpdatedAt()
  17915. return nil
  17916. case creditusage.FieldDeletedAt:
  17917. m.ResetDeletedAt()
  17918. return nil
  17919. case creditusage.FieldUserID:
  17920. m.ResetUserID()
  17921. return nil
  17922. case creditusage.FieldNumber:
  17923. m.ResetNumber()
  17924. return nil
  17925. case creditusage.FieldPayNumber:
  17926. m.ResetPayNumber()
  17927. return nil
  17928. case creditusage.FieldBeforeNumber:
  17929. m.ResetBeforeNumber()
  17930. return nil
  17931. case creditusage.FieldAfterNumber:
  17932. m.ResetAfterNumber()
  17933. return nil
  17934. case creditusage.FieldPayMethod:
  17935. m.ResetPayMethod()
  17936. return nil
  17937. case creditusage.FieldStatus:
  17938. m.ResetStatus()
  17939. return nil
  17940. case creditusage.FieldNtype:
  17941. m.ResetNtype()
  17942. return nil
  17943. case creditusage.FieldTable:
  17944. m.ResetTable()
  17945. return nil
  17946. case creditusage.FieldOrganizationID:
  17947. m.ResetOrganizationID()
  17948. return nil
  17949. case creditusage.FieldNid:
  17950. m.ResetNid()
  17951. return nil
  17952. case creditusage.FieldReason:
  17953. m.ResetReason()
  17954. return nil
  17955. case creditusage.FieldOperator:
  17956. m.ResetOperator()
  17957. return nil
  17958. }
  17959. return fmt.Errorf("unknown CreditUsage field %s", name)
  17960. }
  17961. // AddedEdges returns all edge names that were set/added in this mutation.
  17962. func (m *CreditUsageMutation) AddedEdges() []string {
  17963. edges := make([]string, 0, 0)
  17964. return edges
  17965. }
  17966. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17967. // name in this mutation.
  17968. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  17969. return nil
  17970. }
  17971. // RemovedEdges returns all edge names that were removed in this mutation.
  17972. func (m *CreditUsageMutation) RemovedEdges() []string {
  17973. edges := make([]string, 0, 0)
  17974. return edges
  17975. }
  17976. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17977. // the given name in this mutation.
  17978. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  17979. return nil
  17980. }
  17981. // ClearedEdges returns all edge names that were cleared in this mutation.
  17982. func (m *CreditUsageMutation) ClearedEdges() []string {
  17983. edges := make([]string, 0, 0)
  17984. return edges
  17985. }
  17986. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17987. // was cleared in this mutation.
  17988. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  17989. return false
  17990. }
  17991. // ClearEdge clears the value of the edge with the given name. It returns an error
  17992. // if that edge is not defined in the schema.
  17993. func (m *CreditUsageMutation) ClearEdge(name string) error {
  17994. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  17995. }
  17996. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17997. // It returns an error if the edge is not defined in the schema.
  17998. func (m *CreditUsageMutation) ResetEdge(name string) error {
  17999. return fmt.Errorf("unknown CreditUsage edge %s", name)
  18000. }
  18001. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  18002. type EmployeeMutation struct {
  18003. config
  18004. op Op
  18005. typ string
  18006. id *uint64
  18007. created_at *time.Time
  18008. updated_at *time.Time
  18009. deleted_at *time.Time
  18010. title *string
  18011. avatar *string
  18012. tags *string
  18013. hire_count *int
  18014. addhire_count *int
  18015. service_count *int
  18016. addservice_count *int
  18017. achievement_count *int
  18018. addachievement_count *int
  18019. intro *string
  18020. estimate *string
  18021. skill *string
  18022. ability_type *string
  18023. scene *string
  18024. switch_in *string
  18025. video_url *string
  18026. organization_id *uint64
  18027. addorganization_id *int64
  18028. category_id *uint64
  18029. addcategory_id *int64
  18030. api_base *string
  18031. api_key *string
  18032. ai_info *string
  18033. is_vip *int
  18034. addis_vip *int
  18035. chat_url *string
  18036. clearedFields map[string]struct{}
  18037. em_work_experiences map[uint64]struct{}
  18038. removedem_work_experiences map[uint64]struct{}
  18039. clearedem_work_experiences bool
  18040. em_tutorial map[uint64]struct{}
  18041. removedem_tutorial map[uint64]struct{}
  18042. clearedem_tutorial bool
  18043. done bool
  18044. oldValue func(context.Context) (*Employee, error)
  18045. predicates []predicate.Employee
  18046. }
  18047. var _ ent.Mutation = (*EmployeeMutation)(nil)
  18048. // employeeOption allows management of the mutation configuration using functional options.
  18049. type employeeOption func(*EmployeeMutation)
  18050. // newEmployeeMutation creates new mutation for the Employee entity.
  18051. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  18052. m := &EmployeeMutation{
  18053. config: c,
  18054. op: op,
  18055. typ: TypeEmployee,
  18056. clearedFields: make(map[string]struct{}),
  18057. }
  18058. for _, opt := range opts {
  18059. opt(m)
  18060. }
  18061. return m
  18062. }
  18063. // withEmployeeID sets the ID field of the mutation.
  18064. func withEmployeeID(id uint64) employeeOption {
  18065. return func(m *EmployeeMutation) {
  18066. var (
  18067. err error
  18068. once sync.Once
  18069. value *Employee
  18070. )
  18071. m.oldValue = func(ctx context.Context) (*Employee, error) {
  18072. once.Do(func() {
  18073. if m.done {
  18074. err = errors.New("querying old values post mutation is not allowed")
  18075. } else {
  18076. value, err = m.Client().Employee.Get(ctx, id)
  18077. }
  18078. })
  18079. return value, err
  18080. }
  18081. m.id = &id
  18082. }
  18083. }
  18084. // withEmployee sets the old Employee of the mutation.
  18085. func withEmployee(node *Employee) employeeOption {
  18086. return func(m *EmployeeMutation) {
  18087. m.oldValue = func(context.Context) (*Employee, error) {
  18088. return node, nil
  18089. }
  18090. m.id = &node.ID
  18091. }
  18092. }
  18093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18094. // executed in a transaction (ent.Tx), a transactional client is returned.
  18095. func (m EmployeeMutation) Client() *Client {
  18096. client := &Client{config: m.config}
  18097. client.init()
  18098. return client
  18099. }
  18100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18101. // it returns an error otherwise.
  18102. func (m EmployeeMutation) Tx() (*Tx, error) {
  18103. if _, ok := m.driver.(*txDriver); !ok {
  18104. return nil, errors.New("ent: mutation is not running in a transaction")
  18105. }
  18106. tx := &Tx{config: m.config}
  18107. tx.init()
  18108. return tx, nil
  18109. }
  18110. // SetID sets the value of the id field. Note that this
  18111. // operation is only accepted on creation of Employee entities.
  18112. func (m *EmployeeMutation) SetID(id uint64) {
  18113. m.id = &id
  18114. }
  18115. // ID returns the ID value in the mutation. Note that the ID is only available
  18116. // if it was provided to the builder or after it was returned from the database.
  18117. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  18118. if m.id == nil {
  18119. return
  18120. }
  18121. return *m.id, true
  18122. }
  18123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18124. // That means, if the mutation is applied within a transaction with an isolation level such
  18125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18126. // or updated by the mutation.
  18127. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  18128. switch {
  18129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18130. id, exists := m.ID()
  18131. if exists {
  18132. return []uint64{id}, nil
  18133. }
  18134. fallthrough
  18135. case m.op.Is(OpUpdate | OpDelete):
  18136. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  18137. default:
  18138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18139. }
  18140. }
  18141. // SetCreatedAt sets the "created_at" field.
  18142. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  18143. m.created_at = &t
  18144. }
  18145. // CreatedAt returns the value of the "created_at" field in the mutation.
  18146. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  18147. v := m.created_at
  18148. if v == nil {
  18149. return
  18150. }
  18151. return *v, true
  18152. }
  18153. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  18154. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18156. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18157. if !m.op.Is(OpUpdateOne) {
  18158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18159. }
  18160. if m.id == nil || m.oldValue == nil {
  18161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18162. }
  18163. oldValue, err := m.oldValue(ctx)
  18164. if err != nil {
  18165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18166. }
  18167. return oldValue.CreatedAt, nil
  18168. }
  18169. // ResetCreatedAt resets all changes to the "created_at" field.
  18170. func (m *EmployeeMutation) ResetCreatedAt() {
  18171. m.created_at = nil
  18172. }
  18173. // SetUpdatedAt sets the "updated_at" field.
  18174. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  18175. m.updated_at = &t
  18176. }
  18177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18178. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  18179. v := m.updated_at
  18180. if v == nil {
  18181. return
  18182. }
  18183. return *v, true
  18184. }
  18185. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  18186. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18188. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18189. if !m.op.Is(OpUpdateOne) {
  18190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18191. }
  18192. if m.id == nil || m.oldValue == nil {
  18193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18194. }
  18195. oldValue, err := m.oldValue(ctx)
  18196. if err != nil {
  18197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18198. }
  18199. return oldValue.UpdatedAt, nil
  18200. }
  18201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18202. func (m *EmployeeMutation) ResetUpdatedAt() {
  18203. m.updated_at = nil
  18204. }
  18205. // SetDeletedAt sets the "deleted_at" field.
  18206. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  18207. m.deleted_at = &t
  18208. }
  18209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18210. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  18211. v := m.deleted_at
  18212. if v == nil {
  18213. return
  18214. }
  18215. return *v, true
  18216. }
  18217. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  18218. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18220. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18221. if !m.op.Is(OpUpdateOne) {
  18222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18223. }
  18224. if m.id == nil || m.oldValue == nil {
  18225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18226. }
  18227. oldValue, err := m.oldValue(ctx)
  18228. if err != nil {
  18229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18230. }
  18231. return oldValue.DeletedAt, nil
  18232. }
  18233. // ClearDeletedAt clears the value of the "deleted_at" field.
  18234. func (m *EmployeeMutation) ClearDeletedAt() {
  18235. m.deleted_at = nil
  18236. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  18237. }
  18238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18239. func (m *EmployeeMutation) DeletedAtCleared() bool {
  18240. _, ok := m.clearedFields[employee.FieldDeletedAt]
  18241. return ok
  18242. }
  18243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18244. func (m *EmployeeMutation) ResetDeletedAt() {
  18245. m.deleted_at = nil
  18246. delete(m.clearedFields, employee.FieldDeletedAt)
  18247. }
  18248. // SetTitle sets the "title" field.
  18249. func (m *EmployeeMutation) SetTitle(s string) {
  18250. m.title = &s
  18251. }
  18252. // Title returns the value of the "title" field in the mutation.
  18253. func (m *EmployeeMutation) Title() (r string, exists bool) {
  18254. v := m.title
  18255. if v == nil {
  18256. return
  18257. }
  18258. return *v, true
  18259. }
  18260. // OldTitle returns the old "title" field's value of the Employee entity.
  18261. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18263. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  18264. if !m.op.Is(OpUpdateOne) {
  18265. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  18266. }
  18267. if m.id == nil || m.oldValue == nil {
  18268. return v, errors.New("OldTitle requires an ID field in the mutation")
  18269. }
  18270. oldValue, err := m.oldValue(ctx)
  18271. if err != nil {
  18272. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  18273. }
  18274. return oldValue.Title, nil
  18275. }
  18276. // ResetTitle resets all changes to the "title" field.
  18277. func (m *EmployeeMutation) ResetTitle() {
  18278. m.title = nil
  18279. }
  18280. // SetAvatar sets the "avatar" field.
  18281. func (m *EmployeeMutation) SetAvatar(s string) {
  18282. m.avatar = &s
  18283. }
  18284. // Avatar returns the value of the "avatar" field in the mutation.
  18285. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  18286. v := m.avatar
  18287. if v == nil {
  18288. return
  18289. }
  18290. return *v, true
  18291. }
  18292. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  18293. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18295. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  18296. if !m.op.Is(OpUpdateOne) {
  18297. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  18298. }
  18299. if m.id == nil || m.oldValue == nil {
  18300. return v, errors.New("OldAvatar requires an ID field in the mutation")
  18301. }
  18302. oldValue, err := m.oldValue(ctx)
  18303. if err != nil {
  18304. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  18305. }
  18306. return oldValue.Avatar, nil
  18307. }
  18308. // ResetAvatar resets all changes to the "avatar" field.
  18309. func (m *EmployeeMutation) ResetAvatar() {
  18310. m.avatar = nil
  18311. }
  18312. // SetTags sets the "tags" field.
  18313. func (m *EmployeeMutation) SetTags(s string) {
  18314. m.tags = &s
  18315. }
  18316. // Tags returns the value of the "tags" field in the mutation.
  18317. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  18318. v := m.tags
  18319. if v == nil {
  18320. return
  18321. }
  18322. return *v, true
  18323. }
  18324. // OldTags returns the old "tags" field's value of the Employee entity.
  18325. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18327. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  18328. if !m.op.Is(OpUpdateOne) {
  18329. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  18330. }
  18331. if m.id == nil || m.oldValue == nil {
  18332. return v, errors.New("OldTags requires an ID field in the mutation")
  18333. }
  18334. oldValue, err := m.oldValue(ctx)
  18335. if err != nil {
  18336. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  18337. }
  18338. return oldValue.Tags, nil
  18339. }
  18340. // ResetTags resets all changes to the "tags" field.
  18341. func (m *EmployeeMutation) ResetTags() {
  18342. m.tags = nil
  18343. }
  18344. // SetHireCount sets the "hire_count" field.
  18345. func (m *EmployeeMutation) SetHireCount(i int) {
  18346. m.hire_count = &i
  18347. m.addhire_count = nil
  18348. }
  18349. // HireCount returns the value of the "hire_count" field in the mutation.
  18350. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  18351. v := m.hire_count
  18352. if v == nil {
  18353. return
  18354. }
  18355. return *v, true
  18356. }
  18357. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  18358. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18360. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  18361. if !m.op.Is(OpUpdateOne) {
  18362. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  18363. }
  18364. if m.id == nil || m.oldValue == nil {
  18365. return v, errors.New("OldHireCount requires an ID field in the mutation")
  18366. }
  18367. oldValue, err := m.oldValue(ctx)
  18368. if err != nil {
  18369. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  18370. }
  18371. return oldValue.HireCount, nil
  18372. }
  18373. // AddHireCount adds i to the "hire_count" field.
  18374. func (m *EmployeeMutation) AddHireCount(i int) {
  18375. if m.addhire_count != nil {
  18376. *m.addhire_count += i
  18377. } else {
  18378. m.addhire_count = &i
  18379. }
  18380. }
  18381. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  18382. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  18383. v := m.addhire_count
  18384. if v == nil {
  18385. return
  18386. }
  18387. return *v, true
  18388. }
  18389. // ResetHireCount resets all changes to the "hire_count" field.
  18390. func (m *EmployeeMutation) ResetHireCount() {
  18391. m.hire_count = nil
  18392. m.addhire_count = nil
  18393. }
  18394. // SetServiceCount sets the "service_count" field.
  18395. func (m *EmployeeMutation) SetServiceCount(i int) {
  18396. m.service_count = &i
  18397. m.addservice_count = nil
  18398. }
  18399. // ServiceCount returns the value of the "service_count" field in the mutation.
  18400. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  18401. v := m.service_count
  18402. if v == nil {
  18403. return
  18404. }
  18405. return *v, true
  18406. }
  18407. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  18408. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18410. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  18411. if !m.op.Is(OpUpdateOne) {
  18412. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  18413. }
  18414. if m.id == nil || m.oldValue == nil {
  18415. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  18416. }
  18417. oldValue, err := m.oldValue(ctx)
  18418. if err != nil {
  18419. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  18420. }
  18421. return oldValue.ServiceCount, nil
  18422. }
  18423. // AddServiceCount adds i to the "service_count" field.
  18424. func (m *EmployeeMutation) AddServiceCount(i int) {
  18425. if m.addservice_count != nil {
  18426. *m.addservice_count += i
  18427. } else {
  18428. m.addservice_count = &i
  18429. }
  18430. }
  18431. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  18432. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  18433. v := m.addservice_count
  18434. if v == nil {
  18435. return
  18436. }
  18437. return *v, true
  18438. }
  18439. // ResetServiceCount resets all changes to the "service_count" field.
  18440. func (m *EmployeeMutation) ResetServiceCount() {
  18441. m.service_count = nil
  18442. m.addservice_count = nil
  18443. }
  18444. // SetAchievementCount sets the "achievement_count" field.
  18445. func (m *EmployeeMutation) SetAchievementCount(i int) {
  18446. m.achievement_count = &i
  18447. m.addachievement_count = nil
  18448. }
  18449. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  18450. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  18451. v := m.achievement_count
  18452. if v == nil {
  18453. return
  18454. }
  18455. return *v, true
  18456. }
  18457. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  18458. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18460. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  18461. if !m.op.Is(OpUpdateOne) {
  18462. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  18463. }
  18464. if m.id == nil || m.oldValue == nil {
  18465. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  18466. }
  18467. oldValue, err := m.oldValue(ctx)
  18468. if err != nil {
  18469. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  18470. }
  18471. return oldValue.AchievementCount, nil
  18472. }
  18473. // AddAchievementCount adds i to the "achievement_count" field.
  18474. func (m *EmployeeMutation) AddAchievementCount(i int) {
  18475. if m.addachievement_count != nil {
  18476. *m.addachievement_count += i
  18477. } else {
  18478. m.addachievement_count = &i
  18479. }
  18480. }
  18481. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  18482. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  18483. v := m.addachievement_count
  18484. if v == nil {
  18485. return
  18486. }
  18487. return *v, true
  18488. }
  18489. // ResetAchievementCount resets all changes to the "achievement_count" field.
  18490. func (m *EmployeeMutation) ResetAchievementCount() {
  18491. m.achievement_count = nil
  18492. m.addachievement_count = nil
  18493. }
  18494. // SetIntro sets the "intro" field.
  18495. func (m *EmployeeMutation) SetIntro(s string) {
  18496. m.intro = &s
  18497. }
  18498. // Intro returns the value of the "intro" field in the mutation.
  18499. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  18500. v := m.intro
  18501. if v == nil {
  18502. return
  18503. }
  18504. return *v, true
  18505. }
  18506. // OldIntro returns the old "intro" field's value of the Employee entity.
  18507. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18509. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  18510. if !m.op.Is(OpUpdateOne) {
  18511. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  18512. }
  18513. if m.id == nil || m.oldValue == nil {
  18514. return v, errors.New("OldIntro requires an ID field in the mutation")
  18515. }
  18516. oldValue, err := m.oldValue(ctx)
  18517. if err != nil {
  18518. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  18519. }
  18520. return oldValue.Intro, nil
  18521. }
  18522. // ResetIntro resets all changes to the "intro" field.
  18523. func (m *EmployeeMutation) ResetIntro() {
  18524. m.intro = nil
  18525. }
  18526. // SetEstimate sets the "estimate" field.
  18527. func (m *EmployeeMutation) SetEstimate(s string) {
  18528. m.estimate = &s
  18529. }
  18530. // Estimate returns the value of the "estimate" field in the mutation.
  18531. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  18532. v := m.estimate
  18533. if v == nil {
  18534. return
  18535. }
  18536. return *v, true
  18537. }
  18538. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  18539. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18541. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  18542. if !m.op.Is(OpUpdateOne) {
  18543. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  18544. }
  18545. if m.id == nil || m.oldValue == nil {
  18546. return v, errors.New("OldEstimate requires an ID field in the mutation")
  18547. }
  18548. oldValue, err := m.oldValue(ctx)
  18549. if err != nil {
  18550. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  18551. }
  18552. return oldValue.Estimate, nil
  18553. }
  18554. // ResetEstimate resets all changes to the "estimate" field.
  18555. func (m *EmployeeMutation) ResetEstimate() {
  18556. m.estimate = nil
  18557. }
  18558. // SetSkill sets the "skill" field.
  18559. func (m *EmployeeMutation) SetSkill(s string) {
  18560. m.skill = &s
  18561. }
  18562. // Skill returns the value of the "skill" field in the mutation.
  18563. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  18564. v := m.skill
  18565. if v == nil {
  18566. return
  18567. }
  18568. return *v, true
  18569. }
  18570. // OldSkill returns the old "skill" field's value of the Employee entity.
  18571. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18573. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  18574. if !m.op.Is(OpUpdateOne) {
  18575. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  18576. }
  18577. if m.id == nil || m.oldValue == nil {
  18578. return v, errors.New("OldSkill requires an ID field in the mutation")
  18579. }
  18580. oldValue, err := m.oldValue(ctx)
  18581. if err != nil {
  18582. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  18583. }
  18584. return oldValue.Skill, nil
  18585. }
  18586. // ResetSkill resets all changes to the "skill" field.
  18587. func (m *EmployeeMutation) ResetSkill() {
  18588. m.skill = nil
  18589. }
  18590. // SetAbilityType sets the "ability_type" field.
  18591. func (m *EmployeeMutation) SetAbilityType(s string) {
  18592. m.ability_type = &s
  18593. }
  18594. // AbilityType returns the value of the "ability_type" field in the mutation.
  18595. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  18596. v := m.ability_type
  18597. if v == nil {
  18598. return
  18599. }
  18600. return *v, true
  18601. }
  18602. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  18603. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18605. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  18606. if !m.op.Is(OpUpdateOne) {
  18607. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  18608. }
  18609. if m.id == nil || m.oldValue == nil {
  18610. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  18611. }
  18612. oldValue, err := m.oldValue(ctx)
  18613. if err != nil {
  18614. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  18615. }
  18616. return oldValue.AbilityType, nil
  18617. }
  18618. // ResetAbilityType resets all changes to the "ability_type" field.
  18619. func (m *EmployeeMutation) ResetAbilityType() {
  18620. m.ability_type = nil
  18621. }
  18622. // SetScene sets the "scene" field.
  18623. func (m *EmployeeMutation) SetScene(s string) {
  18624. m.scene = &s
  18625. }
  18626. // Scene returns the value of the "scene" field in the mutation.
  18627. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  18628. v := m.scene
  18629. if v == nil {
  18630. return
  18631. }
  18632. return *v, true
  18633. }
  18634. // OldScene returns the old "scene" field's value of the Employee entity.
  18635. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18637. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  18638. if !m.op.Is(OpUpdateOne) {
  18639. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  18640. }
  18641. if m.id == nil || m.oldValue == nil {
  18642. return v, errors.New("OldScene requires an ID field in the mutation")
  18643. }
  18644. oldValue, err := m.oldValue(ctx)
  18645. if err != nil {
  18646. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  18647. }
  18648. return oldValue.Scene, nil
  18649. }
  18650. // ResetScene resets all changes to the "scene" field.
  18651. func (m *EmployeeMutation) ResetScene() {
  18652. m.scene = nil
  18653. }
  18654. // SetSwitchIn sets the "switch_in" field.
  18655. func (m *EmployeeMutation) SetSwitchIn(s string) {
  18656. m.switch_in = &s
  18657. }
  18658. // SwitchIn returns the value of the "switch_in" field in the mutation.
  18659. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  18660. v := m.switch_in
  18661. if v == nil {
  18662. return
  18663. }
  18664. return *v, true
  18665. }
  18666. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  18667. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18669. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  18670. if !m.op.Is(OpUpdateOne) {
  18671. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  18672. }
  18673. if m.id == nil || m.oldValue == nil {
  18674. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  18675. }
  18676. oldValue, err := m.oldValue(ctx)
  18677. if err != nil {
  18678. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  18679. }
  18680. return oldValue.SwitchIn, nil
  18681. }
  18682. // ResetSwitchIn resets all changes to the "switch_in" field.
  18683. func (m *EmployeeMutation) ResetSwitchIn() {
  18684. m.switch_in = nil
  18685. }
  18686. // SetVideoURL sets the "video_url" field.
  18687. func (m *EmployeeMutation) SetVideoURL(s string) {
  18688. m.video_url = &s
  18689. }
  18690. // VideoURL returns the value of the "video_url" field in the mutation.
  18691. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  18692. v := m.video_url
  18693. if v == nil {
  18694. return
  18695. }
  18696. return *v, true
  18697. }
  18698. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  18699. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18701. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  18702. if !m.op.Is(OpUpdateOne) {
  18703. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  18704. }
  18705. if m.id == nil || m.oldValue == nil {
  18706. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  18707. }
  18708. oldValue, err := m.oldValue(ctx)
  18709. if err != nil {
  18710. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  18711. }
  18712. return oldValue.VideoURL, nil
  18713. }
  18714. // ResetVideoURL resets all changes to the "video_url" field.
  18715. func (m *EmployeeMutation) ResetVideoURL() {
  18716. m.video_url = nil
  18717. }
  18718. // SetOrganizationID sets the "organization_id" field.
  18719. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  18720. m.organization_id = &u
  18721. m.addorganization_id = nil
  18722. }
  18723. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18724. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  18725. v := m.organization_id
  18726. if v == nil {
  18727. return
  18728. }
  18729. return *v, true
  18730. }
  18731. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  18732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18734. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18735. if !m.op.Is(OpUpdateOne) {
  18736. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18737. }
  18738. if m.id == nil || m.oldValue == nil {
  18739. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18740. }
  18741. oldValue, err := m.oldValue(ctx)
  18742. if err != nil {
  18743. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18744. }
  18745. return oldValue.OrganizationID, nil
  18746. }
  18747. // AddOrganizationID adds u to the "organization_id" field.
  18748. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  18749. if m.addorganization_id != nil {
  18750. *m.addorganization_id += u
  18751. } else {
  18752. m.addorganization_id = &u
  18753. }
  18754. }
  18755. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18756. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  18757. v := m.addorganization_id
  18758. if v == nil {
  18759. return
  18760. }
  18761. return *v, true
  18762. }
  18763. // ResetOrganizationID resets all changes to the "organization_id" field.
  18764. func (m *EmployeeMutation) ResetOrganizationID() {
  18765. m.organization_id = nil
  18766. m.addorganization_id = nil
  18767. }
  18768. // SetCategoryID sets the "category_id" field.
  18769. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  18770. m.category_id = &u
  18771. m.addcategory_id = nil
  18772. }
  18773. // CategoryID returns the value of the "category_id" field in the mutation.
  18774. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  18775. v := m.category_id
  18776. if v == nil {
  18777. return
  18778. }
  18779. return *v, true
  18780. }
  18781. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  18782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18784. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  18785. if !m.op.Is(OpUpdateOne) {
  18786. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  18787. }
  18788. if m.id == nil || m.oldValue == nil {
  18789. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  18790. }
  18791. oldValue, err := m.oldValue(ctx)
  18792. if err != nil {
  18793. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  18794. }
  18795. return oldValue.CategoryID, nil
  18796. }
  18797. // AddCategoryID adds u to the "category_id" field.
  18798. func (m *EmployeeMutation) AddCategoryID(u int64) {
  18799. if m.addcategory_id != nil {
  18800. *m.addcategory_id += u
  18801. } else {
  18802. m.addcategory_id = &u
  18803. }
  18804. }
  18805. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  18806. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  18807. v := m.addcategory_id
  18808. if v == nil {
  18809. return
  18810. }
  18811. return *v, true
  18812. }
  18813. // ResetCategoryID resets all changes to the "category_id" field.
  18814. func (m *EmployeeMutation) ResetCategoryID() {
  18815. m.category_id = nil
  18816. m.addcategory_id = nil
  18817. }
  18818. // SetAPIBase sets the "api_base" field.
  18819. func (m *EmployeeMutation) SetAPIBase(s string) {
  18820. m.api_base = &s
  18821. }
  18822. // APIBase returns the value of the "api_base" field in the mutation.
  18823. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  18824. v := m.api_base
  18825. if v == nil {
  18826. return
  18827. }
  18828. return *v, true
  18829. }
  18830. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  18831. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18833. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  18834. if !m.op.Is(OpUpdateOne) {
  18835. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  18836. }
  18837. if m.id == nil || m.oldValue == nil {
  18838. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  18839. }
  18840. oldValue, err := m.oldValue(ctx)
  18841. if err != nil {
  18842. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  18843. }
  18844. return oldValue.APIBase, nil
  18845. }
  18846. // ResetAPIBase resets all changes to the "api_base" field.
  18847. func (m *EmployeeMutation) ResetAPIBase() {
  18848. m.api_base = nil
  18849. }
  18850. // SetAPIKey sets the "api_key" field.
  18851. func (m *EmployeeMutation) SetAPIKey(s string) {
  18852. m.api_key = &s
  18853. }
  18854. // APIKey returns the value of the "api_key" field in the mutation.
  18855. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  18856. v := m.api_key
  18857. if v == nil {
  18858. return
  18859. }
  18860. return *v, true
  18861. }
  18862. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  18863. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18865. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  18866. if !m.op.Is(OpUpdateOne) {
  18867. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  18868. }
  18869. if m.id == nil || m.oldValue == nil {
  18870. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  18871. }
  18872. oldValue, err := m.oldValue(ctx)
  18873. if err != nil {
  18874. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  18875. }
  18876. return oldValue.APIKey, nil
  18877. }
  18878. // ResetAPIKey resets all changes to the "api_key" field.
  18879. func (m *EmployeeMutation) ResetAPIKey() {
  18880. m.api_key = nil
  18881. }
  18882. // SetAiInfo sets the "ai_info" field.
  18883. func (m *EmployeeMutation) SetAiInfo(s string) {
  18884. m.ai_info = &s
  18885. }
  18886. // AiInfo returns the value of the "ai_info" field in the mutation.
  18887. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  18888. v := m.ai_info
  18889. if v == nil {
  18890. return
  18891. }
  18892. return *v, true
  18893. }
  18894. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  18895. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18896. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18897. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  18898. if !m.op.Is(OpUpdateOne) {
  18899. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  18900. }
  18901. if m.id == nil || m.oldValue == nil {
  18902. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  18903. }
  18904. oldValue, err := m.oldValue(ctx)
  18905. if err != nil {
  18906. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  18907. }
  18908. return oldValue.AiInfo, nil
  18909. }
  18910. // ClearAiInfo clears the value of the "ai_info" field.
  18911. func (m *EmployeeMutation) ClearAiInfo() {
  18912. m.ai_info = nil
  18913. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  18914. }
  18915. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  18916. func (m *EmployeeMutation) AiInfoCleared() bool {
  18917. _, ok := m.clearedFields[employee.FieldAiInfo]
  18918. return ok
  18919. }
  18920. // ResetAiInfo resets all changes to the "ai_info" field.
  18921. func (m *EmployeeMutation) ResetAiInfo() {
  18922. m.ai_info = nil
  18923. delete(m.clearedFields, employee.FieldAiInfo)
  18924. }
  18925. // SetIsVip sets the "is_vip" field.
  18926. func (m *EmployeeMutation) SetIsVip(i int) {
  18927. m.is_vip = &i
  18928. m.addis_vip = nil
  18929. }
  18930. // IsVip returns the value of the "is_vip" field in the mutation.
  18931. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  18932. v := m.is_vip
  18933. if v == nil {
  18934. return
  18935. }
  18936. return *v, true
  18937. }
  18938. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  18939. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18941. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  18942. if !m.op.Is(OpUpdateOne) {
  18943. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  18944. }
  18945. if m.id == nil || m.oldValue == nil {
  18946. return v, errors.New("OldIsVip requires an ID field in the mutation")
  18947. }
  18948. oldValue, err := m.oldValue(ctx)
  18949. if err != nil {
  18950. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  18951. }
  18952. return oldValue.IsVip, nil
  18953. }
  18954. // AddIsVip adds i to the "is_vip" field.
  18955. func (m *EmployeeMutation) AddIsVip(i int) {
  18956. if m.addis_vip != nil {
  18957. *m.addis_vip += i
  18958. } else {
  18959. m.addis_vip = &i
  18960. }
  18961. }
  18962. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  18963. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  18964. v := m.addis_vip
  18965. if v == nil {
  18966. return
  18967. }
  18968. return *v, true
  18969. }
  18970. // ResetIsVip resets all changes to the "is_vip" field.
  18971. func (m *EmployeeMutation) ResetIsVip() {
  18972. m.is_vip = nil
  18973. m.addis_vip = nil
  18974. }
  18975. // SetChatURL sets the "chat_url" field.
  18976. func (m *EmployeeMutation) SetChatURL(s string) {
  18977. m.chat_url = &s
  18978. }
  18979. // ChatURL returns the value of the "chat_url" field in the mutation.
  18980. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  18981. v := m.chat_url
  18982. if v == nil {
  18983. return
  18984. }
  18985. return *v, true
  18986. }
  18987. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  18988. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  18989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18990. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  18991. if !m.op.Is(OpUpdateOne) {
  18992. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  18993. }
  18994. if m.id == nil || m.oldValue == nil {
  18995. return v, errors.New("OldChatURL requires an ID field in the mutation")
  18996. }
  18997. oldValue, err := m.oldValue(ctx)
  18998. if err != nil {
  18999. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  19000. }
  19001. return oldValue.ChatURL, nil
  19002. }
  19003. // ResetChatURL resets all changes to the "chat_url" field.
  19004. func (m *EmployeeMutation) ResetChatURL() {
  19005. m.chat_url = nil
  19006. }
  19007. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  19008. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  19009. if m.em_work_experiences == nil {
  19010. m.em_work_experiences = make(map[uint64]struct{})
  19011. }
  19012. for i := range ids {
  19013. m.em_work_experiences[ids[i]] = struct{}{}
  19014. }
  19015. }
  19016. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  19017. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  19018. m.clearedem_work_experiences = true
  19019. }
  19020. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  19021. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  19022. return m.clearedem_work_experiences
  19023. }
  19024. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  19025. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  19026. if m.removedem_work_experiences == nil {
  19027. m.removedem_work_experiences = make(map[uint64]struct{})
  19028. }
  19029. for i := range ids {
  19030. delete(m.em_work_experiences, ids[i])
  19031. m.removedem_work_experiences[ids[i]] = struct{}{}
  19032. }
  19033. }
  19034. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  19035. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  19036. for id := range m.removedem_work_experiences {
  19037. ids = append(ids, id)
  19038. }
  19039. return
  19040. }
  19041. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  19042. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  19043. for id := range m.em_work_experiences {
  19044. ids = append(ids, id)
  19045. }
  19046. return
  19047. }
  19048. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  19049. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  19050. m.em_work_experiences = nil
  19051. m.clearedem_work_experiences = false
  19052. m.removedem_work_experiences = nil
  19053. }
  19054. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  19055. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  19056. if m.em_tutorial == nil {
  19057. m.em_tutorial = make(map[uint64]struct{})
  19058. }
  19059. for i := range ids {
  19060. m.em_tutorial[ids[i]] = struct{}{}
  19061. }
  19062. }
  19063. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  19064. func (m *EmployeeMutation) ClearEmTutorial() {
  19065. m.clearedem_tutorial = true
  19066. }
  19067. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  19068. func (m *EmployeeMutation) EmTutorialCleared() bool {
  19069. return m.clearedem_tutorial
  19070. }
  19071. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  19072. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  19073. if m.removedem_tutorial == nil {
  19074. m.removedem_tutorial = make(map[uint64]struct{})
  19075. }
  19076. for i := range ids {
  19077. delete(m.em_tutorial, ids[i])
  19078. m.removedem_tutorial[ids[i]] = struct{}{}
  19079. }
  19080. }
  19081. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  19082. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  19083. for id := range m.removedem_tutorial {
  19084. ids = append(ids, id)
  19085. }
  19086. return
  19087. }
  19088. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  19089. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  19090. for id := range m.em_tutorial {
  19091. ids = append(ids, id)
  19092. }
  19093. return
  19094. }
  19095. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  19096. func (m *EmployeeMutation) ResetEmTutorial() {
  19097. m.em_tutorial = nil
  19098. m.clearedem_tutorial = false
  19099. m.removedem_tutorial = nil
  19100. }
  19101. // Where appends a list predicates to the EmployeeMutation builder.
  19102. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  19103. m.predicates = append(m.predicates, ps...)
  19104. }
  19105. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  19106. // users can use type-assertion to append predicates that do not depend on any generated package.
  19107. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  19108. p := make([]predicate.Employee, len(ps))
  19109. for i := range ps {
  19110. p[i] = ps[i]
  19111. }
  19112. m.Where(p...)
  19113. }
  19114. // Op returns the operation name.
  19115. func (m *EmployeeMutation) Op() Op {
  19116. return m.op
  19117. }
  19118. // SetOp allows setting the mutation operation.
  19119. func (m *EmployeeMutation) SetOp(op Op) {
  19120. m.op = op
  19121. }
  19122. // Type returns the node type of this mutation (Employee).
  19123. func (m *EmployeeMutation) Type() string {
  19124. return m.typ
  19125. }
  19126. // Fields returns all fields that were changed during this mutation. Note that in
  19127. // order to get all numeric fields that were incremented/decremented, call
  19128. // AddedFields().
  19129. func (m *EmployeeMutation) Fields() []string {
  19130. fields := make([]string, 0, 23)
  19131. if m.created_at != nil {
  19132. fields = append(fields, employee.FieldCreatedAt)
  19133. }
  19134. if m.updated_at != nil {
  19135. fields = append(fields, employee.FieldUpdatedAt)
  19136. }
  19137. if m.deleted_at != nil {
  19138. fields = append(fields, employee.FieldDeletedAt)
  19139. }
  19140. if m.title != nil {
  19141. fields = append(fields, employee.FieldTitle)
  19142. }
  19143. if m.avatar != nil {
  19144. fields = append(fields, employee.FieldAvatar)
  19145. }
  19146. if m.tags != nil {
  19147. fields = append(fields, employee.FieldTags)
  19148. }
  19149. if m.hire_count != nil {
  19150. fields = append(fields, employee.FieldHireCount)
  19151. }
  19152. if m.service_count != nil {
  19153. fields = append(fields, employee.FieldServiceCount)
  19154. }
  19155. if m.achievement_count != nil {
  19156. fields = append(fields, employee.FieldAchievementCount)
  19157. }
  19158. if m.intro != nil {
  19159. fields = append(fields, employee.FieldIntro)
  19160. }
  19161. if m.estimate != nil {
  19162. fields = append(fields, employee.FieldEstimate)
  19163. }
  19164. if m.skill != nil {
  19165. fields = append(fields, employee.FieldSkill)
  19166. }
  19167. if m.ability_type != nil {
  19168. fields = append(fields, employee.FieldAbilityType)
  19169. }
  19170. if m.scene != nil {
  19171. fields = append(fields, employee.FieldScene)
  19172. }
  19173. if m.switch_in != nil {
  19174. fields = append(fields, employee.FieldSwitchIn)
  19175. }
  19176. if m.video_url != nil {
  19177. fields = append(fields, employee.FieldVideoURL)
  19178. }
  19179. if m.organization_id != nil {
  19180. fields = append(fields, employee.FieldOrganizationID)
  19181. }
  19182. if m.category_id != nil {
  19183. fields = append(fields, employee.FieldCategoryID)
  19184. }
  19185. if m.api_base != nil {
  19186. fields = append(fields, employee.FieldAPIBase)
  19187. }
  19188. if m.api_key != nil {
  19189. fields = append(fields, employee.FieldAPIKey)
  19190. }
  19191. if m.ai_info != nil {
  19192. fields = append(fields, employee.FieldAiInfo)
  19193. }
  19194. if m.is_vip != nil {
  19195. fields = append(fields, employee.FieldIsVip)
  19196. }
  19197. if m.chat_url != nil {
  19198. fields = append(fields, employee.FieldChatURL)
  19199. }
  19200. return fields
  19201. }
  19202. // Field returns the value of a field with the given name. The second boolean
  19203. // return value indicates that this field was not set, or was not defined in the
  19204. // schema.
  19205. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  19206. switch name {
  19207. case employee.FieldCreatedAt:
  19208. return m.CreatedAt()
  19209. case employee.FieldUpdatedAt:
  19210. return m.UpdatedAt()
  19211. case employee.FieldDeletedAt:
  19212. return m.DeletedAt()
  19213. case employee.FieldTitle:
  19214. return m.Title()
  19215. case employee.FieldAvatar:
  19216. return m.Avatar()
  19217. case employee.FieldTags:
  19218. return m.Tags()
  19219. case employee.FieldHireCount:
  19220. return m.HireCount()
  19221. case employee.FieldServiceCount:
  19222. return m.ServiceCount()
  19223. case employee.FieldAchievementCount:
  19224. return m.AchievementCount()
  19225. case employee.FieldIntro:
  19226. return m.Intro()
  19227. case employee.FieldEstimate:
  19228. return m.Estimate()
  19229. case employee.FieldSkill:
  19230. return m.Skill()
  19231. case employee.FieldAbilityType:
  19232. return m.AbilityType()
  19233. case employee.FieldScene:
  19234. return m.Scene()
  19235. case employee.FieldSwitchIn:
  19236. return m.SwitchIn()
  19237. case employee.FieldVideoURL:
  19238. return m.VideoURL()
  19239. case employee.FieldOrganizationID:
  19240. return m.OrganizationID()
  19241. case employee.FieldCategoryID:
  19242. return m.CategoryID()
  19243. case employee.FieldAPIBase:
  19244. return m.APIBase()
  19245. case employee.FieldAPIKey:
  19246. return m.APIKey()
  19247. case employee.FieldAiInfo:
  19248. return m.AiInfo()
  19249. case employee.FieldIsVip:
  19250. return m.IsVip()
  19251. case employee.FieldChatURL:
  19252. return m.ChatURL()
  19253. }
  19254. return nil, false
  19255. }
  19256. // OldField returns the old value of the field from the database. An error is
  19257. // returned if the mutation operation is not UpdateOne, or the query to the
  19258. // database failed.
  19259. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19260. switch name {
  19261. case employee.FieldCreatedAt:
  19262. return m.OldCreatedAt(ctx)
  19263. case employee.FieldUpdatedAt:
  19264. return m.OldUpdatedAt(ctx)
  19265. case employee.FieldDeletedAt:
  19266. return m.OldDeletedAt(ctx)
  19267. case employee.FieldTitle:
  19268. return m.OldTitle(ctx)
  19269. case employee.FieldAvatar:
  19270. return m.OldAvatar(ctx)
  19271. case employee.FieldTags:
  19272. return m.OldTags(ctx)
  19273. case employee.FieldHireCount:
  19274. return m.OldHireCount(ctx)
  19275. case employee.FieldServiceCount:
  19276. return m.OldServiceCount(ctx)
  19277. case employee.FieldAchievementCount:
  19278. return m.OldAchievementCount(ctx)
  19279. case employee.FieldIntro:
  19280. return m.OldIntro(ctx)
  19281. case employee.FieldEstimate:
  19282. return m.OldEstimate(ctx)
  19283. case employee.FieldSkill:
  19284. return m.OldSkill(ctx)
  19285. case employee.FieldAbilityType:
  19286. return m.OldAbilityType(ctx)
  19287. case employee.FieldScene:
  19288. return m.OldScene(ctx)
  19289. case employee.FieldSwitchIn:
  19290. return m.OldSwitchIn(ctx)
  19291. case employee.FieldVideoURL:
  19292. return m.OldVideoURL(ctx)
  19293. case employee.FieldOrganizationID:
  19294. return m.OldOrganizationID(ctx)
  19295. case employee.FieldCategoryID:
  19296. return m.OldCategoryID(ctx)
  19297. case employee.FieldAPIBase:
  19298. return m.OldAPIBase(ctx)
  19299. case employee.FieldAPIKey:
  19300. return m.OldAPIKey(ctx)
  19301. case employee.FieldAiInfo:
  19302. return m.OldAiInfo(ctx)
  19303. case employee.FieldIsVip:
  19304. return m.OldIsVip(ctx)
  19305. case employee.FieldChatURL:
  19306. return m.OldChatURL(ctx)
  19307. }
  19308. return nil, fmt.Errorf("unknown Employee field %s", name)
  19309. }
  19310. // SetField sets the value of a field with the given name. It returns an error if
  19311. // the field is not defined in the schema, or if the type mismatched the field
  19312. // type.
  19313. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  19314. switch name {
  19315. case employee.FieldCreatedAt:
  19316. v, ok := value.(time.Time)
  19317. if !ok {
  19318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19319. }
  19320. m.SetCreatedAt(v)
  19321. return nil
  19322. case employee.FieldUpdatedAt:
  19323. v, ok := value.(time.Time)
  19324. if !ok {
  19325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19326. }
  19327. m.SetUpdatedAt(v)
  19328. return nil
  19329. case employee.FieldDeletedAt:
  19330. v, ok := value.(time.Time)
  19331. if !ok {
  19332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19333. }
  19334. m.SetDeletedAt(v)
  19335. return nil
  19336. case employee.FieldTitle:
  19337. v, ok := value.(string)
  19338. if !ok {
  19339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19340. }
  19341. m.SetTitle(v)
  19342. return nil
  19343. case employee.FieldAvatar:
  19344. v, ok := value.(string)
  19345. if !ok {
  19346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19347. }
  19348. m.SetAvatar(v)
  19349. return nil
  19350. case employee.FieldTags:
  19351. v, ok := value.(string)
  19352. if !ok {
  19353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19354. }
  19355. m.SetTags(v)
  19356. return nil
  19357. case employee.FieldHireCount:
  19358. v, ok := value.(int)
  19359. if !ok {
  19360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19361. }
  19362. m.SetHireCount(v)
  19363. return nil
  19364. case employee.FieldServiceCount:
  19365. v, ok := value.(int)
  19366. if !ok {
  19367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19368. }
  19369. m.SetServiceCount(v)
  19370. return nil
  19371. case employee.FieldAchievementCount:
  19372. v, ok := value.(int)
  19373. if !ok {
  19374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19375. }
  19376. m.SetAchievementCount(v)
  19377. return nil
  19378. case employee.FieldIntro:
  19379. v, ok := value.(string)
  19380. if !ok {
  19381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19382. }
  19383. m.SetIntro(v)
  19384. return nil
  19385. case employee.FieldEstimate:
  19386. v, ok := value.(string)
  19387. if !ok {
  19388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19389. }
  19390. m.SetEstimate(v)
  19391. return nil
  19392. case employee.FieldSkill:
  19393. v, ok := value.(string)
  19394. if !ok {
  19395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19396. }
  19397. m.SetSkill(v)
  19398. return nil
  19399. case employee.FieldAbilityType:
  19400. v, ok := value.(string)
  19401. if !ok {
  19402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19403. }
  19404. m.SetAbilityType(v)
  19405. return nil
  19406. case employee.FieldScene:
  19407. v, ok := value.(string)
  19408. if !ok {
  19409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19410. }
  19411. m.SetScene(v)
  19412. return nil
  19413. case employee.FieldSwitchIn:
  19414. v, ok := value.(string)
  19415. if !ok {
  19416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19417. }
  19418. m.SetSwitchIn(v)
  19419. return nil
  19420. case employee.FieldVideoURL:
  19421. v, ok := value.(string)
  19422. if !ok {
  19423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19424. }
  19425. m.SetVideoURL(v)
  19426. return nil
  19427. case employee.FieldOrganizationID:
  19428. v, ok := value.(uint64)
  19429. if !ok {
  19430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19431. }
  19432. m.SetOrganizationID(v)
  19433. return nil
  19434. case employee.FieldCategoryID:
  19435. v, ok := value.(uint64)
  19436. if !ok {
  19437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19438. }
  19439. m.SetCategoryID(v)
  19440. return nil
  19441. case employee.FieldAPIBase:
  19442. v, ok := value.(string)
  19443. if !ok {
  19444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19445. }
  19446. m.SetAPIBase(v)
  19447. return nil
  19448. case employee.FieldAPIKey:
  19449. v, ok := value.(string)
  19450. if !ok {
  19451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19452. }
  19453. m.SetAPIKey(v)
  19454. return nil
  19455. case employee.FieldAiInfo:
  19456. v, ok := value.(string)
  19457. if !ok {
  19458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19459. }
  19460. m.SetAiInfo(v)
  19461. return nil
  19462. case employee.FieldIsVip:
  19463. v, ok := value.(int)
  19464. if !ok {
  19465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19466. }
  19467. m.SetIsVip(v)
  19468. return nil
  19469. case employee.FieldChatURL:
  19470. v, ok := value.(string)
  19471. if !ok {
  19472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19473. }
  19474. m.SetChatURL(v)
  19475. return nil
  19476. }
  19477. return fmt.Errorf("unknown Employee field %s", name)
  19478. }
  19479. // AddedFields returns all numeric fields that were incremented/decremented during
  19480. // this mutation.
  19481. func (m *EmployeeMutation) AddedFields() []string {
  19482. var fields []string
  19483. if m.addhire_count != nil {
  19484. fields = append(fields, employee.FieldHireCount)
  19485. }
  19486. if m.addservice_count != nil {
  19487. fields = append(fields, employee.FieldServiceCount)
  19488. }
  19489. if m.addachievement_count != nil {
  19490. fields = append(fields, employee.FieldAchievementCount)
  19491. }
  19492. if m.addorganization_id != nil {
  19493. fields = append(fields, employee.FieldOrganizationID)
  19494. }
  19495. if m.addcategory_id != nil {
  19496. fields = append(fields, employee.FieldCategoryID)
  19497. }
  19498. if m.addis_vip != nil {
  19499. fields = append(fields, employee.FieldIsVip)
  19500. }
  19501. return fields
  19502. }
  19503. // AddedField returns the numeric value that was incremented/decremented on a field
  19504. // with the given name. The second boolean return value indicates that this field
  19505. // was not set, or was not defined in the schema.
  19506. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  19507. switch name {
  19508. case employee.FieldHireCount:
  19509. return m.AddedHireCount()
  19510. case employee.FieldServiceCount:
  19511. return m.AddedServiceCount()
  19512. case employee.FieldAchievementCount:
  19513. return m.AddedAchievementCount()
  19514. case employee.FieldOrganizationID:
  19515. return m.AddedOrganizationID()
  19516. case employee.FieldCategoryID:
  19517. return m.AddedCategoryID()
  19518. case employee.FieldIsVip:
  19519. return m.AddedIsVip()
  19520. }
  19521. return nil, false
  19522. }
  19523. // AddField adds the value to the field with the given name. It returns an error if
  19524. // the field is not defined in the schema, or if the type mismatched the field
  19525. // type.
  19526. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  19527. switch name {
  19528. case employee.FieldHireCount:
  19529. v, ok := value.(int)
  19530. if !ok {
  19531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19532. }
  19533. m.AddHireCount(v)
  19534. return nil
  19535. case employee.FieldServiceCount:
  19536. v, ok := value.(int)
  19537. if !ok {
  19538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19539. }
  19540. m.AddServiceCount(v)
  19541. return nil
  19542. case employee.FieldAchievementCount:
  19543. v, ok := value.(int)
  19544. if !ok {
  19545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19546. }
  19547. m.AddAchievementCount(v)
  19548. return nil
  19549. case employee.FieldOrganizationID:
  19550. v, ok := value.(int64)
  19551. if !ok {
  19552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19553. }
  19554. m.AddOrganizationID(v)
  19555. return nil
  19556. case employee.FieldCategoryID:
  19557. v, ok := value.(int64)
  19558. if !ok {
  19559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19560. }
  19561. m.AddCategoryID(v)
  19562. return nil
  19563. case employee.FieldIsVip:
  19564. v, ok := value.(int)
  19565. if !ok {
  19566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19567. }
  19568. m.AddIsVip(v)
  19569. return nil
  19570. }
  19571. return fmt.Errorf("unknown Employee numeric field %s", name)
  19572. }
  19573. // ClearedFields returns all nullable fields that were cleared during this
  19574. // mutation.
  19575. func (m *EmployeeMutation) ClearedFields() []string {
  19576. var fields []string
  19577. if m.FieldCleared(employee.FieldDeletedAt) {
  19578. fields = append(fields, employee.FieldDeletedAt)
  19579. }
  19580. if m.FieldCleared(employee.FieldAiInfo) {
  19581. fields = append(fields, employee.FieldAiInfo)
  19582. }
  19583. return fields
  19584. }
  19585. // FieldCleared returns a boolean indicating if a field with the given name was
  19586. // cleared in this mutation.
  19587. func (m *EmployeeMutation) FieldCleared(name string) bool {
  19588. _, ok := m.clearedFields[name]
  19589. return ok
  19590. }
  19591. // ClearField clears the value of the field with the given name. It returns an
  19592. // error if the field is not defined in the schema.
  19593. func (m *EmployeeMutation) ClearField(name string) error {
  19594. switch name {
  19595. case employee.FieldDeletedAt:
  19596. m.ClearDeletedAt()
  19597. return nil
  19598. case employee.FieldAiInfo:
  19599. m.ClearAiInfo()
  19600. return nil
  19601. }
  19602. return fmt.Errorf("unknown Employee nullable field %s", name)
  19603. }
  19604. // ResetField resets all changes in the mutation for the field with the given name.
  19605. // It returns an error if the field is not defined in the schema.
  19606. func (m *EmployeeMutation) ResetField(name string) error {
  19607. switch name {
  19608. case employee.FieldCreatedAt:
  19609. m.ResetCreatedAt()
  19610. return nil
  19611. case employee.FieldUpdatedAt:
  19612. m.ResetUpdatedAt()
  19613. return nil
  19614. case employee.FieldDeletedAt:
  19615. m.ResetDeletedAt()
  19616. return nil
  19617. case employee.FieldTitle:
  19618. m.ResetTitle()
  19619. return nil
  19620. case employee.FieldAvatar:
  19621. m.ResetAvatar()
  19622. return nil
  19623. case employee.FieldTags:
  19624. m.ResetTags()
  19625. return nil
  19626. case employee.FieldHireCount:
  19627. m.ResetHireCount()
  19628. return nil
  19629. case employee.FieldServiceCount:
  19630. m.ResetServiceCount()
  19631. return nil
  19632. case employee.FieldAchievementCount:
  19633. m.ResetAchievementCount()
  19634. return nil
  19635. case employee.FieldIntro:
  19636. m.ResetIntro()
  19637. return nil
  19638. case employee.FieldEstimate:
  19639. m.ResetEstimate()
  19640. return nil
  19641. case employee.FieldSkill:
  19642. m.ResetSkill()
  19643. return nil
  19644. case employee.FieldAbilityType:
  19645. m.ResetAbilityType()
  19646. return nil
  19647. case employee.FieldScene:
  19648. m.ResetScene()
  19649. return nil
  19650. case employee.FieldSwitchIn:
  19651. m.ResetSwitchIn()
  19652. return nil
  19653. case employee.FieldVideoURL:
  19654. m.ResetVideoURL()
  19655. return nil
  19656. case employee.FieldOrganizationID:
  19657. m.ResetOrganizationID()
  19658. return nil
  19659. case employee.FieldCategoryID:
  19660. m.ResetCategoryID()
  19661. return nil
  19662. case employee.FieldAPIBase:
  19663. m.ResetAPIBase()
  19664. return nil
  19665. case employee.FieldAPIKey:
  19666. m.ResetAPIKey()
  19667. return nil
  19668. case employee.FieldAiInfo:
  19669. m.ResetAiInfo()
  19670. return nil
  19671. case employee.FieldIsVip:
  19672. m.ResetIsVip()
  19673. return nil
  19674. case employee.FieldChatURL:
  19675. m.ResetChatURL()
  19676. return nil
  19677. }
  19678. return fmt.Errorf("unknown Employee field %s", name)
  19679. }
  19680. // AddedEdges returns all edge names that were set/added in this mutation.
  19681. func (m *EmployeeMutation) AddedEdges() []string {
  19682. edges := make([]string, 0, 2)
  19683. if m.em_work_experiences != nil {
  19684. edges = append(edges, employee.EdgeEmWorkExperiences)
  19685. }
  19686. if m.em_tutorial != nil {
  19687. edges = append(edges, employee.EdgeEmTutorial)
  19688. }
  19689. return edges
  19690. }
  19691. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19692. // name in this mutation.
  19693. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  19694. switch name {
  19695. case employee.EdgeEmWorkExperiences:
  19696. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  19697. for id := range m.em_work_experiences {
  19698. ids = append(ids, id)
  19699. }
  19700. return ids
  19701. case employee.EdgeEmTutorial:
  19702. ids := make([]ent.Value, 0, len(m.em_tutorial))
  19703. for id := range m.em_tutorial {
  19704. ids = append(ids, id)
  19705. }
  19706. return ids
  19707. }
  19708. return nil
  19709. }
  19710. // RemovedEdges returns all edge names that were removed in this mutation.
  19711. func (m *EmployeeMutation) RemovedEdges() []string {
  19712. edges := make([]string, 0, 2)
  19713. if m.removedem_work_experiences != nil {
  19714. edges = append(edges, employee.EdgeEmWorkExperiences)
  19715. }
  19716. if m.removedem_tutorial != nil {
  19717. edges = append(edges, employee.EdgeEmTutorial)
  19718. }
  19719. return edges
  19720. }
  19721. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19722. // the given name in this mutation.
  19723. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  19724. switch name {
  19725. case employee.EdgeEmWorkExperiences:
  19726. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  19727. for id := range m.removedem_work_experiences {
  19728. ids = append(ids, id)
  19729. }
  19730. return ids
  19731. case employee.EdgeEmTutorial:
  19732. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  19733. for id := range m.removedem_tutorial {
  19734. ids = append(ids, id)
  19735. }
  19736. return ids
  19737. }
  19738. return nil
  19739. }
  19740. // ClearedEdges returns all edge names that were cleared in this mutation.
  19741. func (m *EmployeeMutation) ClearedEdges() []string {
  19742. edges := make([]string, 0, 2)
  19743. if m.clearedem_work_experiences {
  19744. edges = append(edges, employee.EdgeEmWorkExperiences)
  19745. }
  19746. if m.clearedem_tutorial {
  19747. edges = append(edges, employee.EdgeEmTutorial)
  19748. }
  19749. return edges
  19750. }
  19751. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19752. // was cleared in this mutation.
  19753. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  19754. switch name {
  19755. case employee.EdgeEmWorkExperiences:
  19756. return m.clearedem_work_experiences
  19757. case employee.EdgeEmTutorial:
  19758. return m.clearedem_tutorial
  19759. }
  19760. return false
  19761. }
  19762. // ClearEdge clears the value of the edge with the given name. It returns an error
  19763. // if that edge is not defined in the schema.
  19764. func (m *EmployeeMutation) ClearEdge(name string) error {
  19765. switch name {
  19766. }
  19767. return fmt.Errorf("unknown Employee unique edge %s", name)
  19768. }
  19769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19770. // It returns an error if the edge is not defined in the schema.
  19771. func (m *EmployeeMutation) ResetEdge(name string) error {
  19772. switch name {
  19773. case employee.EdgeEmWorkExperiences:
  19774. m.ResetEmWorkExperiences()
  19775. return nil
  19776. case employee.EdgeEmTutorial:
  19777. m.ResetEmTutorial()
  19778. return nil
  19779. }
  19780. return fmt.Errorf("unknown Employee edge %s", name)
  19781. }
  19782. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  19783. type EmployeeConfigMutation struct {
  19784. config
  19785. op Op
  19786. typ string
  19787. id *uint64
  19788. created_at *time.Time
  19789. updated_at *time.Time
  19790. deleted_at *time.Time
  19791. stype *string
  19792. title *string
  19793. photo *string
  19794. organization_id *uint64
  19795. addorganization_id *int64
  19796. clearedFields map[string]struct{}
  19797. done bool
  19798. oldValue func(context.Context) (*EmployeeConfig, error)
  19799. predicates []predicate.EmployeeConfig
  19800. }
  19801. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  19802. // employeeconfigOption allows management of the mutation configuration using functional options.
  19803. type employeeconfigOption func(*EmployeeConfigMutation)
  19804. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  19805. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  19806. m := &EmployeeConfigMutation{
  19807. config: c,
  19808. op: op,
  19809. typ: TypeEmployeeConfig,
  19810. clearedFields: make(map[string]struct{}),
  19811. }
  19812. for _, opt := range opts {
  19813. opt(m)
  19814. }
  19815. return m
  19816. }
  19817. // withEmployeeConfigID sets the ID field of the mutation.
  19818. func withEmployeeConfigID(id uint64) employeeconfigOption {
  19819. return func(m *EmployeeConfigMutation) {
  19820. var (
  19821. err error
  19822. once sync.Once
  19823. value *EmployeeConfig
  19824. )
  19825. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  19826. once.Do(func() {
  19827. if m.done {
  19828. err = errors.New("querying old values post mutation is not allowed")
  19829. } else {
  19830. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  19831. }
  19832. })
  19833. return value, err
  19834. }
  19835. m.id = &id
  19836. }
  19837. }
  19838. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  19839. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  19840. return func(m *EmployeeConfigMutation) {
  19841. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  19842. return node, nil
  19843. }
  19844. m.id = &node.ID
  19845. }
  19846. }
  19847. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19848. // executed in a transaction (ent.Tx), a transactional client is returned.
  19849. func (m EmployeeConfigMutation) Client() *Client {
  19850. client := &Client{config: m.config}
  19851. client.init()
  19852. return client
  19853. }
  19854. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19855. // it returns an error otherwise.
  19856. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  19857. if _, ok := m.driver.(*txDriver); !ok {
  19858. return nil, errors.New("ent: mutation is not running in a transaction")
  19859. }
  19860. tx := &Tx{config: m.config}
  19861. tx.init()
  19862. return tx, nil
  19863. }
  19864. // SetID sets the value of the id field. Note that this
  19865. // operation is only accepted on creation of EmployeeConfig entities.
  19866. func (m *EmployeeConfigMutation) SetID(id uint64) {
  19867. m.id = &id
  19868. }
  19869. // ID returns the ID value in the mutation. Note that the ID is only available
  19870. // if it was provided to the builder or after it was returned from the database.
  19871. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  19872. if m.id == nil {
  19873. return
  19874. }
  19875. return *m.id, true
  19876. }
  19877. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19878. // That means, if the mutation is applied within a transaction with an isolation level such
  19879. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19880. // or updated by the mutation.
  19881. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  19882. switch {
  19883. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19884. id, exists := m.ID()
  19885. if exists {
  19886. return []uint64{id}, nil
  19887. }
  19888. fallthrough
  19889. case m.op.Is(OpUpdate | OpDelete):
  19890. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  19891. default:
  19892. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19893. }
  19894. }
  19895. // SetCreatedAt sets the "created_at" field.
  19896. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  19897. m.created_at = &t
  19898. }
  19899. // CreatedAt returns the value of the "created_at" field in the mutation.
  19900. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  19901. v := m.created_at
  19902. if v == nil {
  19903. return
  19904. }
  19905. return *v, true
  19906. }
  19907. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  19908. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19910. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19911. if !m.op.Is(OpUpdateOne) {
  19912. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19913. }
  19914. if m.id == nil || m.oldValue == nil {
  19915. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19916. }
  19917. oldValue, err := m.oldValue(ctx)
  19918. if err != nil {
  19919. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19920. }
  19921. return oldValue.CreatedAt, nil
  19922. }
  19923. // ResetCreatedAt resets all changes to the "created_at" field.
  19924. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  19925. m.created_at = nil
  19926. }
  19927. // SetUpdatedAt sets the "updated_at" field.
  19928. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  19929. m.updated_at = &t
  19930. }
  19931. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19932. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  19933. v := m.updated_at
  19934. if v == nil {
  19935. return
  19936. }
  19937. return *v, true
  19938. }
  19939. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  19940. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19942. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19943. if !m.op.Is(OpUpdateOne) {
  19944. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19945. }
  19946. if m.id == nil || m.oldValue == nil {
  19947. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19948. }
  19949. oldValue, err := m.oldValue(ctx)
  19950. if err != nil {
  19951. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19952. }
  19953. return oldValue.UpdatedAt, nil
  19954. }
  19955. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19956. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  19957. m.updated_at = nil
  19958. }
  19959. // SetDeletedAt sets the "deleted_at" field.
  19960. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  19961. m.deleted_at = &t
  19962. }
  19963. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19964. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  19965. v := m.deleted_at
  19966. if v == nil {
  19967. return
  19968. }
  19969. return *v, true
  19970. }
  19971. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  19972. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  19973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19974. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19975. if !m.op.Is(OpUpdateOne) {
  19976. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19977. }
  19978. if m.id == nil || m.oldValue == nil {
  19979. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19980. }
  19981. oldValue, err := m.oldValue(ctx)
  19982. if err != nil {
  19983. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19984. }
  19985. return oldValue.DeletedAt, nil
  19986. }
  19987. // ClearDeletedAt clears the value of the "deleted_at" field.
  19988. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  19989. m.deleted_at = nil
  19990. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  19991. }
  19992. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19993. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  19994. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  19995. return ok
  19996. }
  19997. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19998. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  19999. m.deleted_at = nil
  20000. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  20001. }
  20002. // SetStype sets the "stype" field.
  20003. func (m *EmployeeConfigMutation) SetStype(s string) {
  20004. m.stype = &s
  20005. }
  20006. // Stype returns the value of the "stype" field in the mutation.
  20007. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  20008. v := m.stype
  20009. if v == nil {
  20010. return
  20011. }
  20012. return *v, true
  20013. }
  20014. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  20015. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20017. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  20018. if !m.op.Is(OpUpdateOne) {
  20019. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  20020. }
  20021. if m.id == nil || m.oldValue == nil {
  20022. return v, errors.New("OldStype requires an ID field in the mutation")
  20023. }
  20024. oldValue, err := m.oldValue(ctx)
  20025. if err != nil {
  20026. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  20027. }
  20028. return oldValue.Stype, nil
  20029. }
  20030. // ResetStype resets all changes to the "stype" field.
  20031. func (m *EmployeeConfigMutation) ResetStype() {
  20032. m.stype = nil
  20033. }
  20034. // SetTitle sets the "title" field.
  20035. func (m *EmployeeConfigMutation) SetTitle(s string) {
  20036. m.title = &s
  20037. }
  20038. // Title returns the value of the "title" field in the mutation.
  20039. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  20040. v := m.title
  20041. if v == nil {
  20042. return
  20043. }
  20044. return *v, true
  20045. }
  20046. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  20047. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20049. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  20050. if !m.op.Is(OpUpdateOne) {
  20051. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  20052. }
  20053. if m.id == nil || m.oldValue == nil {
  20054. return v, errors.New("OldTitle requires an ID field in the mutation")
  20055. }
  20056. oldValue, err := m.oldValue(ctx)
  20057. if err != nil {
  20058. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  20059. }
  20060. return oldValue.Title, nil
  20061. }
  20062. // ResetTitle resets all changes to the "title" field.
  20063. func (m *EmployeeConfigMutation) ResetTitle() {
  20064. m.title = nil
  20065. }
  20066. // SetPhoto sets the "photo" field.
  20067. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  20068. m.photo = &s
  20069. }
  20070. // Photo returns the value of the "photo" field in the mutation.
  20071. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  20072. v := m.photo
  20073. if v == nil {
  20074. return
  20075. }
  20076. return *v, true
  20077. }
  20078. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  20079. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20081. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  20082. if !m.op.Is(OpUpdateOne) {
  20083. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  20084. }
  20085. if m.id == nil || m.oldValue == nil {
  20086. return v, errors.New("OldPhoto requires an ID field in the mutation")
  20087. }
  20088. oldValue, err := m.oldValue(ctx)
  20089. if err != nil {
  20090. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  20091. }
  20092. return oldValue.Photo, nil
  20093. }
  20094. // ResetPhoto resets all changes to the "photo" field.
  20095. func (m *EmployeeConfigMutation) ResetPhoto() {
  20096. m.photo = nil
  20097. }
  20098. // SetOrganizationID sets the "organization_id" field.
  20099. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  20100. m.organization_id = &u
  20101. m.addorganization_id = nil
  20102. }
  20103. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20104. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  20105. v := m.organization_id
  20106. if v == nil {
  20107. return
  20108. }
  20109. return *v, true
  20110. }
  20111. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  20112. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  20113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20114. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20115. if !m.op.Is(OpUpdateOne) {
  20116. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20117. }
  20118. if m.id == nil || m.oldValue == nil {
  20119. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20120. }
  20121. oldValue, err := m.oldValue(ctx)
  20122. if err != nil {
  20123. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20124. }
  20125. return oldValue.OrganizationID, nil
  20126. }
  20127. // AddOrganizationID adds u to the "organization_id" field.
  20128. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  20129. if m.addorganization_id != nil {
  20130. *m.addorganization_id += u
  20131. } else {
  20132. m.addorganization_id = &u
  20133. }
  20134. }
  20135. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20136. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  20137. v := m.addorganization_id
  20138. if v == nil {
  20139. return
  20140. }
  20141. return *v, true
  20142. }
  20143. // ClearOrganizationID clears the value of the "organization_id" field.
  20144. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  20145. m.organization_id = nil
  20146. m.addorganization_id = nil
  20147. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  20148. }
  20149. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20150. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  20151. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  20152. return ok
  20153. }
  20154. // ResetOrganizationID resets all changes to the "organization_id" field.
  20155. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  20156. m.organization_id = nil
  20157. m.addorganization_id = nil
  20158. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  20159. }
  20160. // Where appends a list predicates to the EmployeeConfigMutation builder.
  20161. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  20162. m.predicates = append(m.predicates, ps...)
  20163. }
  20164. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  20165. // users can use type-assertion to append predicates that do not depend on any generated package.
  20166. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  20167. p := make([]predicate.EmployeeConfig, len(ps))
  20168. for i := range ps {
  20169. p[i] = ps[i]
  20170. }
  20171. m.Where(p...)
  20172. }
  20173. // Op returns the operation name.
  20174. func (m *EmployeeConfigMutation) Op() Op {
  20175. return m.op
  20176. }
  20177. // SetOp allows setting the mutation operation.
  20178. func (m *EmployeeConfigMutation) SetOp(op Op) {
  20179. m.op = op
  20180. }
  20181. // Type returns the node type of this mutation (EmployeeConfig).
  20182. func (m *EmployeeConfigMutation) Type() string {
  20183. return m.typ
  20184. }
  20185. // Fields returns all fields that were changed during this mutation. Note that in
  20186. // order to get all numeric fields that were incremented/decremented, call
  20187. // AddedFields().
  20188. func (m *EmployeeConfigMutation) Fields() []string {
  20189. fields := make([]string, 0, 7)
  20190. if m.created_at != nil {
  20191. fields = append(fields, employeeconfig.FieldCreatedAt)
  20192. }
  20193. if m.updated_at != nil {
  20194. fields = append(fields, employeeconfig.FieldUpdatedAt)
  20195. }
  20196. if m.deleted_at != nil {
  20197. fields = append(fields, employeeconfig.FieldDeletedAt)
  20198. }
  20199. if m.stype != nil {
  20200. fields = append(fields, employeeconfig.FieldStype)
  20201. }
  20202. if m.title != nil {
  20203. fields = append(fields, employeeconfig.FieldTitle)
  20204. }
  20205. if m.photo != nil {
  20206. fields = append(fields, employeeconfig.FieldPhoto)
  20207. }
  20208. if m.organization_id != nil {
  20209. fields = append(fields, employeeconfig.FieldOrganizationID)
  20210. }
  20211. return fields
  20212. }
  20213. // Field returns the value of a field with the given name. The second boolean
  20214. // return value indicates that this field was not set, or was not defined in the
  20215. // schema.
  20216. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  20217. switch name {
  20218. case employeeconfig.FieldCreatedAt:
  20219. return m.CreatedAt()
  20220. case employeeconfig.FieldUpdatedAt:
  20221. return m.UpdatedAt()
  20222. case employeeconfig.FieldDeletedAt:
  20223. return m.DeletedAt()
  20224. case employeeconfig.FieldStype:
  20225. return m.Stype()
  20226. case employeeconfig.FieldTitle:
  20227. return m.Title()
  20228. case employeeconfig.FieldPhoto:
  20229. return m.Photo()
  20230. case employeeconfig.FieldOrganizationID:
  20231. return m.OrganizationID()
  20232. }
  20233. return nil, false
  20234. }
  20235. // OldField returns the old value of the field from the database. An error is
  20236. // returned if the mutation operation is not UpdateOne, or the query to the
  20237. // database failed.
  20238. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20239. switch name {
  20240. case employeeconfig.FieldCreatedAt:
  20241. return m.OldCreatedAt(ctx)
  20242. case employeeconfig.FieldUpdatedAt:
  20243. return m.OldUpdatedAt(ctx)
  20244. case employeeconfig.FieldDeletedAt:
  20245. return m.OldDeletedAt(ctx)
  20246. case employeeconfig.FieldStype:
  20247. return m.OldStype(ctx)
  20248. case employeeconfig.FieldTitle:
  20249. return m.OldTitle(ctx)
  20250. case employeeconfig.FieldPhoto:
  20251. return m.OldPhoto(ctx)
  20252. case employeeconfig.FieldOrganizationID:
  20253. return m.OldOrganizationID(ctx)
  20254. }
  20255. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  20256. }
  20257. // SetField sets the value of a field with the given name. It returns an error if
  20258. // the field is not defined in the schema, or if the type mismatched the field
  20259. // type.
  20260. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  20261. switch name {
  20262. case employeeconfig.FieldCreatedAt:
  20263. v, ok := value.(time.Time)
  20264. if !ok {
  20265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20266. }
  20267. m.SetCreatedAt(v)
  20268. return nil
  20269. case employeeconfig.FieldUpdatedAt:
  20270. v, ok := value.(time.Time)
  20271. if !ok {
  20272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20273. }
  20274. m.SetUpdatedAt(v)
  20275. return nil
  20276. case employeeconfig.FieldDeletedAt:
  20277. v, ok := value.(time.Time)
  20278. if !ok {
  20279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20280. }
  20281. m.SetDeletedAt(v)
  20282. return nil
  20283. case employeeconfig.FieldStype:
  20284. v, ok := value.(string)
  20285. if !ok {
  20286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20287. }
  20288. m.SetStype(v)
  20289. return nil
  20290. case employeeconfig.FieldTitle:
  20291. v, ok := value.(string)
  20292. if !ok {
  20293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20294. }
  20295. m.SetTitle(v)
  20296. return nil
  20297. case employeeconfig.FieldPhoto:
  20298. v, ok := value.(string)
  20299. if !ok {
  20300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20301. }
  20302. m.SetPhoto(v)
  20303. return nil
  20304. case employeeconfig.FieldOrganizationID:
  20305. v, ok := value.(uint64)
  20306. if !ok {
  20307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20308. }
  20309. m.SetOrganizationID(v)
  20310. return nil
  20311. }
  20312. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20313. }
  20314. // AddedFields returns all numeric fields that were incremented/decremented during
  20315. // this mutation.
  20316. func (m *EmployeeConfigMutation) AddedFields() []string {
  20317. var fields []string
  20318. if m.addorganization_id != nil {
  20319. fields = append(fields, employeeconfig.FieldOrganizationID)
  20320. }
  20321. return fields
  20322. }
  20323. // AddedField returns the numeric value that was incremented/decremented on a field
  20324. // with the given name. The second boolean return value indicates that this field
  20325. // was not set, or was not defined in the schema.
  20326. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  20327. switch name {
  20328. case employeeconfig.FieldOrganizationID:
  20329. return m.AddedOrganizationID()
  20330. }
  20331. return nil, false
  20332. }
  20333. // AddField adds the value to the field with the given name. It returns an error if
  20334. // the field is not defined in the schema, or if the type mismatched the field
  20335. // type.
  20336. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  20337. switch name {
  20338. case employeeconfig.FieldOrganizationID:
  20339. v, ok := value.(int64)
  20340. if !ok {
  20341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20342. }
  20343. m.AddOrganizationID(v)
  20344. return nil
  20345. }
  20346. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  20347. }
  20348. // ClearedFields returns all nullable fields that were cleared during this
  20349. // mutation.
  20350. func (m *EmployeeConfigMutation) ClearedFields() []string {
  20351. var fields []string
  20352. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  20353. fields = append(fields, employeeconfig.FieldDeletedAt)
  20354. }
  20355. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  20356. fields = append(fields, employeeconfig.FieldOrganizationID)
  20357. }
  20358. return fields
  20359. }
  20360. // FieldCleared returns a boolean indicating if a field with the given name was
  20361. // cleared in this mutation.
  20362. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  20363. _, ok := m.clearedFields[name]
  20364. return ok
  20365. }
  20366. // ClearField clears the value of the field with the given name. It returns an
  20367. // error if the field is not defined in the schema.
  20368. func (m *EmployeeConfigMutation) ClearField(name string) error {
  20369. switch name {
  20370. case employeeconfig.FieldDeletedAt:
  20371. m.ClearDeletedAt()
  20372. return nil
  20373. case employeeconfig.FieldOrganizationID:
  20374. m.ClearOrganizationID()
  20375. return nil
  20376. }
  20377. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  20378. }
  20379. // ResetField resets all changes in the mutation for the field with the given name.
  20380. // It returns an error if the field is not defined in the schema.
  20381. func (m *EmployeeConfigMutation) ResetField(name string) error {
  20382. switch name {
  20383. case employeeconfig.FieldCreatedAt:
  20384. m.ResetCreatedAt()
  20385. return nil
  20386. case employeeconfig.FieldUpdatedAt:
  20387. m.ResetUpdatedAt()
  20388. return nil
  20389. case employeeconfig.FieldDeletedAt:
  20390. m.ResetDeletedAt()
  20391. return nil
  20392. case employeeconfig.FieldStype:
  20393. m.ResetStype()
  20394. return nil
  20395. case employeeconfig.FieldTitle:
  20396. m.ResetTitle()
  20397. return nil
  20398. case employeeconfig.FieldPhoto:
  20399. m.ResetPhoto()
  20400. return nil
  20401. case employeeconfig.FieldOrganizationID:
  20402. m.ResetOrganizationID()
  20403. return nil
  20404. }
  20405. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  20406. }
  20407. // AddedEdges returns all edge names that were set/added in this mutation.
  20408. func (m *EmployeeConfigMutation) AddedEdges() []string {
  20409. edges := make([]string, 0, 0)
  20410. return edges
  20411. }
  20412. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20413. // name in this mutation.
  20414. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  20415. return nil
  20416. }
  20417. // RemovedEdges returns all edge names that were removed in this mutation.
  20418. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  20419. edges := make([]string, 0, 0)
  20420. return edges
  20421. }
  20422. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20423. // the given name in this mutation.
  20424. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  20425. return nil
  20426. }
  20427. // ClearedEdges returns all edge names that were cleared in this mutation.
  20428. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  20429. edges := make([]string, 0, 0)
  20430. return edges
  20431. }
  20432. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20433. // was cleared in this mutation.
  20434. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  20435. return false
  20436. }
  20437. // ClearEdge clears the value of the edge with the given name. It returns an error
  20438. // if that edge is not defined in the schema.
  20439. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  20440. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  20441. }
  20442. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20443. // It returns an error if the edge is not defined in the schema.
  20444. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  20445. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  20446. }
  20447. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  20448. type LabelMutation struct {
  20449. config
  20450. op Op
  20451. typ string
  20452. id *uint64
  20453. created_at *time.Time
  20454. updated_at *time.Time
  20455. status *uint8
  20456. addstatus *int8
  20457. _type *int
  20458. add_type *int
  20459. name *string
  20460. from *int
  20461. addfrom *int
  20462. mode *int
  20463. addmode *int
  20464. conditions *string
  20465. organization_id *uint64
  20466. addorganization_id *int64
  20467. clearedFields map[string]struct{}
  20468. label_relationships map[uint64]struct{}
  20469. removedlabel_relationships map[uint64]struct{}
  20470. clearedlabel_relationships bool
  20471. done bool
  20472. oldValue func(context.Context) (*Label, error)
  20473. predicates []predicate.Label
  20474. }
  20475. var _ ent.Mutation = (*LabelMutation)(nil)
  20476. // labelOption allows management of the mutation configuration using functional options.
  20477. type labelOption func(*LabelMutation)
  20478. // newLabelMutation creates new mutation for the Label entity.
  20479. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  20480. m := &LabelMutation{
  20481. config: c,
  20482. op: op,
  20483. typ: TypeLabel,
  20484. clearedFields: make(map[string]struct{}),
  20485. }
  20486. for _, opt := range opts {
  20487. opt(m)
  20488. }
  20489. return m
  20490. }
  20491. // withLabelID sets the ID field of the mutation.
  20492. func withLabelID(id uint64) labelOption {
  20493. return func(m *LabelMutation) {
  20494. var (
  20495. err error
  20496. once sync.Once
  20497. value *Label
  20498. )
  20499. m.oldValue = func(ctx context.Context) (*Label, error) {
  20500. once.Do(func() {
  20501. if m.done {
  20502. err = errors.New("querying old values post mutation is not allowed")
  20503. } else {
  20504. value, err = m.Client().Label.Get(ctx, id)
  20505. }
  20506. })
  20507. return value, err
  20508. }
  20509. m.id = &id
  20510. }
  20511. }
  20512. // withLabel sets the old Label of the mutation.
  20513. func withLabel(node *Label) labelOption {
  20514. return func(m *LabelMutation) {
  20515. m.oldValue = func(context.Context) (*Label, error) {
  20516. return node, nil
  20517. }
  20518. m.id = &node.ID
  20519. }
  20520. }
  20521. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20522. // executed in a transaction (ent.Tx), a transactional client is returned.
  20523. func (m LabelMutation) Client() *Client {
  20524. client := &Client{config: m.config}
  20525. client.init()
  20526. return client
  20527. }
  20528. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20529. // it returns an error otherwise.
  20530. func (m LabelMutation) Tx() (*Tx, error) {
  20531. if _, ok := m.driver.(*txDriver); !ok {
  20532. return nil, errors.New("ent: mutation is not running in a transaction")
  20533. }
  20534. tx := &Tx{config: m.config}
  20535. tx.init()
  20536. return tx, nil
  20537. }
  20538. // SetID sets the value of the id field. Note that this
  20539. // operation is only accepted on creation of Label entities.
  20540. func (m *LabelMutation) SetID(id uint64) {
  20541. m.id = &id
  20542. }
  20543. // ID returns the ID value in the mutation. Note that the ID is only available
  20544. // if it was provided to the builder or after it was returned from the database.
  20545. func (m *LabelMutation) ID() (id uint64, exists bool) {
  20546. if m.id == nil {
  20547. return
  20548. }
  20549. return *m.id, true
  20550. }
  20551. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20552. // That means, if the mutation is applied within a transaction with an isolation level such
  20553. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20554. // or updated by the mutation.
  20555. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  20556. switch {
  20557. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20558. id, exists := m.ID()
  20559. if exists {
  20560. return []uint64{id}, nil
  20561. }
  20562. fallthrough
  20563. case m.op.Is(OpUpdate | OpDelete):
  20564. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  20565. default:
  20566. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20567. }
  20568. }
  20569. // SetCreatedAt sets the "created_at" field.
  20570. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  20571. m.created_at = &t
  20572. }
  20573. // CreatedAt returns the value of the "created_at" field in the mutation.
  20574. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  20575. v := m.created_at
  20576. if v == nil {
  20577. return
  20578. }
  20579. return *v, true
  20580. }
  20581. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  20582. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20583. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20584. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20585. if !m.op.Is(OpUpdateOne) {
  20586. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20587. }
  20588. if m.id == nil || m.oldValue == nil {
  20589. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20590. }
  20591. oldValue, err := m.oldValue(ctx)
  20592. if err != nil {
  20593. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20594. }
  20595. return oldValue.CreatedAt, nil
  20596. }
  20597. // ResetCreatedAt resets all changes to the "created_at" field.
  20598. func (m *LabelMutation) ResetCreatedAt() {
  20599. m.created_at = nil
  20600. }
  20601. // SetUpdatedAt sets the "updated_at" field.
  20602. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  20603. m.updated_at = &t
  20604. }
  20605. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20606. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  20607. v := m.updated_at
  20608. if v == nil {
  20609. return
  20610. }
  20611. return *v, true
  20612. }
  20613. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  20614. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20616. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20617. if !m.op.Is(OpUpdateOne) {
  20618. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20619. }
  20620. if m.id == nil || m.oldValue == nil {
  20621. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20622. }
  20623. oldValue, err := m.oldValue(ctx)
  20624. if err != nil {
  20625. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20626. }
  20627. return oldValue.UpdatedAt, nil
  20628. }
  20629. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20630. func (m *LabelMutation) ResetUpdatedAt() {
  20631. m.updated_at = nil
  20632. }
  20633. // SetStatus sets the "status" field.
  20634. func (m *LabelMutation) SetStatus(u uint8) {
  20635. m.status = &u
  20636. m.addstatus = nil
  20637. }
  20638. // Status returns the value of the "status" field in the mutation.
  20639. func (m *LabelMutation) Status() (r uint8, exists bool) {
  20640. v := m.status
  20641. if v == nil {
  20642. return
  20643. }
  20644. return *v, true
  20645. }
  20646. // OldStatus returns the old "status" field's value of the Label entity.
  20647. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20649. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20650. if !m.op.Is(OpUpdateOne) {
  20651. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20652. }
  20653. if m.id == nil || m.oldValue == nil {
  20654. return v, errors.New("OldStatus requires an ID field in the mutation")
  20655. }
  20656. oldValue, err := m.oldValue(ctx)
  20657. if err != nil {
  20658. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20659. }
  20660. return oldValue.Status, nil
  20661. }
  20662. // AddStatus adds u to the "status" field.
  20663. func (m *LabelMutation) AddStatus(u int8) {
  20664. if m.addstatus != nil {
  20665. *m.addstatus += u
  20666. } else {
  20667. m.addstatus = &u
  20668. }
  20669. }
  20670. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20671. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  20672. v := m.addstatus
  20673. if v == nil {
  20674. return
  20675. }
  20676. return *v, true
  20677. }
  20678. // ClearStatus clears the value of the "status" field.
  20679. func (m *LabelMutation) ClearStatus() {
  20680. m.status = nil
  20681. m.addstatus = nil
  20682. m.clearedFields[label.FieldStatus] = struct{}{}
  20683. }
  20684. // StatusCleared returns if the "status" field was cleared in this mutation.
  20685. func (m *LabelMutation) StatusCleared() bool {
  20686. _, ok := m.clearedFields[label.FieldStatus]
  20687. return ok
  20688. }
  20689. // ResetStatus resets all changes to the "status" field.
  20690. func (m *LabelMutation) ResetStatus() {
  20691. m.status = nil
  20692. m.addstatus = nil
  20693. delete(m.clearedFields, label.FieldStatus)
  20694. }
  20695. // SetType sets the "type" field.
  20696. func (m *LabelMutation) SetType(i int) {
  20697. m._type = &i
  20698. m.add_type = nil
  20699. }
  20700. // GetType returns the value of the "type" field in the mutation.
  20701. func (m *LabelMutation) GetType() (r int, exists bool) {
  20702. v := m._type
  20703. if v == nil {
  20704. return
  20705. }
  20706. return *v, true
  20707. }
  20708. // OldType returns the old "type" field's value of the Label entity.
  20709. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20711. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  20712. if !m.op.Is(OpUpdateOne) {
  20713. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20714. }
  20715. if m.id == nil || m.oldValue == nil {
  20716. return v, errors.New("OldType requires an ID field in the mutation")
  20717. }
  20718. oldValue, err := m.oldValue(ctx)
  20719. if err != nil {
  20720. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20721. }
  20722. return oldValue.Type, nil
  20723. }
  20724. // AddType adds i to the "type" field.
  20725. func (m *LabelMutation) AddType(i int) {
  20726. if m.add_type != nil {
  20727. *m.add_type += i
  20728. } else {
  20729. m.add_type = &i
  20730. }
  20731. }
  20732. // AddedType returns the value that was added to the "type" field in this mutation.
  20733. func (m *LabelMutation) AddedType() (r int, exists bool) {
  20734. v := m.add_type
  20735. if v == nil {
  20736. return
  20737. }
  20738. return *v, true
  20739. }
  20740. // ResetType resets all changes to the "type" field.
  20741. func (m *LabelMutation) ResetType() {
  20742. m._type = nil
  20743. m.add_type = nil
  20744. }
  20745. // SetName sets the "name" field.
  20746. func (m *LabelMutation) SetName(s string) {
  20747. m.name = &s
  20748. }
  20749. // Name returns the value of the "name" field in the mutation.
  20750. func (m *LabelMutation) Name() (r string, exists bool) {
  20751. v := m.name
  20752. if v == nil {
  20753. return
  20754. }
  20755. return *v, true
  20756. }
  20757. // OldName returns the old "name" field's value of the Label entity.
  20758. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20760. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  20761. if !m.op.Is(OpUpdateOne) {
  20762. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20763. }
  20764. if m.id == nil || m.oldValue == nil {
  20765. return v, errors.New("OldName requires an ID field in the mutation")
  20766. }
  20767. oldValue, err := m.oldValue(ctx)
  20768. if err != nil {
  20769. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20770. }
  20771. return oldValue.Name, nil
  20772. }
  20773. // ResetName resets all changes to the "name" field.
  20774. func (m *LabelMutation) ResetName() {
  20775. m.name = nil
  20776. }
  20777. // SetFrom sets the "from" field.
  20778. func (m *LabelMutation) SetFrom(i int) {
  20779. m.from = &i
  20780. m.addfrom = nil
  20781. }
  20782. // From returns the value of the "from" field in the mutation.
  20783. func (m *LabelMutation) From() (r int, exists bool) {
  20784. v := m.from
  20785. if v == nil {
  20786. return
  20787. }
  20788. return *v, true
  20789. }
  20790. // OldFrom returns the old "from" field's value of the Label entity.
  20791. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20793. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  20794. if !m.op.Is(OpUpdateOne) {
  20795. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  20796. }
  20797. if m.id == nil || m.oldValue == nil {
  20798. return v, errors.New("OldFrom requires an ID field in the mutation")
  20799. }
  20800. oldValue, err := m.oldValue(ctx)
  20801. if err != nil {
  20802. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  20803. }
  20804. return oldValue.From, nil
  20805. }
  20806. // AddFrom adds i to the "from" field.
  20807. func (m *LabelMutation) AddFrom(i int) {
  20808. if m.addfrom != nil {
  20809. *m.addfrom += i
  20810. } else {
  20811. m.addfrom = &i
  20812. }
  20813. }
  20814. // AddedFrom returns the value that was added to the "from" field in this mutation.
  20815. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  20816. v := m.addfrom
  20817. if v == nil {
  20818. return
  20819. }
  20820. return *v, true
  20821. }
  20822. // ResetFrom resets all changes to the "from" field.
  20823. func (m *LabelMutation) ResetFrom() {
  20824. m.from = nil
  20825. m.addfrom = nil
  20826. }
  20827. // SetMode sets the "mode" field.
  20828. func (m *LabelMutation) SetMode(i int) {
  20829. m.mode = &i
  20830. m.addmode = nil
  20831. }
  20832. // Mode returns the value of the "mode" field in the mutation.
  20833. func (m *LabelMutation) Mode() (r int, exists bool) {
  20834. v := m.mode
  20835. if v == nil {
  20836. return
  20837. }
  20838. return *v, true
  20839. }
  20840. // OldMode returns the old "mode" field's value of the Label entity.
  20841. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20843. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  20844. if !m.op.Is(OpUpdateOne) {
  20845. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  20846. }
  20847. if m.id == nil || m.oldValue == nil {
  20848. return v, errors.New("OldMode requires an ID field in the mutation")
  20849. }
  20850. oldValue, err := m.oldValue(ctx)
  20851. if err != nil {
  20852. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  20853. }
  20854. return oldValue.Mode, nil
  20855. }
  20856. // AddMode adds i to the "mode" field.
  20857. func (m *LabelMutation) AddMode(i int) {
  20858. if m.addmode != nil {
  20859. *m.addmode += i
  20860. } else {
  20861. m.addmode = &i
  20862. }
  20863. }
  20864. // AddedMode returns the value that was added to the "mode" field in this mutation.
  20865. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  20866. v := m.addmode
  20867. if v == nil {
  20868. return
  20869. }
  20870. return *v, true
  20871. }
  20872. // ResetMode resets all changes to the "mode" field.
  20873. func (m *LabelMutation) ResetMode() {
  20874. m.mode = nil
  20875. m.addmode = nil
  20876. }
  20877. // SetConditions sets the "conditions" field.
  20878. func (m *LabelMutation) SetConditions(s string) {
  20879. m.conditions = &s
  20880. }
  20881. // Conditions returns the value of the "conditions" field in the mutation.
  20882. func (m *LabelMutation) Conditions() (r string, exists bool) {
  20883. v := m.conditions
  20884. if v == nil {
  20885. return
  20886. }
  20887. return *v, true
  20888. }
  20889. // OldConditions returns the old "conditions" field's value of the Label entity.
  20890. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20892. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  20893. if !m.op.Is(OpUpdateOne) {
  20894. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  20895. }
  20896. if m.id == nil || m.oldValue == nil {
  20897. return v, errors.New("OldConditions requires an ID field in the mutation")
  20898. }
  20899. oldValue, err := m.oldValue(ctx)
  20900. if err != nil {
  20901. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  20902. }
  20903. return oldValue.Conditions, nil
  20904. }
  20905. // ClearConditions clears the value of the "conditions" field.
  20906. func (m *LabelMutation) ClearConditions() {
  20907. m.conditions = nil
  20908. m.clearedFields[label.FieldConditions] = struct{}{}
  20909. }
  20910. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  20911. func (m *LabelMutation) ConditionsCleared() bool {
  20912. _, ok := m.clearedFields[label.FieldConditions]
  20913. return ok
  20914. }
  20915. // ResetConditions resets all changes to the "conditions" field.
  20916. func (m *LabelMutation) ResetConditions() {
  20917. m.conditions = nil
  20918. delete(m.clearedFields, label.FieldConditions)
  20919. }
  20920. // SetOrganizationID sets the "organization_id" field.
  20921. func (m *LabelMutation) SetOrganizationID(u uint64) {
  20922. m.organization_id = &u
  20923. m.addorganization_id = nil
  20924. }
  20925. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20926. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  20927. v := m.organization_id
  20928. if v == nil {
  20929. return
  20930. }
  20931. return *v, true
  20932. }
  20933. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  20934. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  20935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20936. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20937. if !m.op.Is(OpUpdateOne) {
  20938. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20939. }
  20940. if m.id == nil || m.oldValue == nil {
  20941. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20942. }
  20943. oldValue, err := m.oldValue(ctx)
  20944. if err != nil {
  20945. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20946. }
  20947. return oldValue.OrganizationID, nil
  20948. }
  20949. // AddOrganizationID adds u to the "organization_id" field.
  20950. func (m *LabelMutation) AddOrganizationID(u int64) {
  20951. if m.addorganization_id != nil {
  20952. *m.addorganization_id += u
  20953. } else {
  20954. m.addorganization_id = &u
  20955. }
  20956. }
  20957. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20958. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  20959. v := m.addorganization_id
  20960. if v == nil {
  20961. return
  20962. }
  20963. return *v, true
  20964. }
  20965. // ClearOrganizationID clears the value of the "organization_id" field.
  20966. func (m *LabelMutation) ClearOrganizationID() {
  20967. m.organization_id = nil
  20968. m.addorganization_id = nil
  20969. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  20970. }
  20971. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20972. func (m *LabelMutation) OrganizationIDCleared() bool {
  20973. _, ok := m.clearedFields[label.FieldOrganizationID]
  20974. return ok
  20975. }
  20976. // ResetOrganizationID resets all changes to the "organization_id" field.
  20977. func (m *LabelMutation) ResetOrganizationID() {
  20978. m.organization_id = nil
  20979. m.addorganization_id = nil
  20980. delete(m.clearedFields, label.FieldOrganizationID)
  20981. }
  20982. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  20983. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  20984. if m.label_relationships == nil {
  20985. m.label_relationships = make(map[uint64]struct{})
  20986. }
  20987. for i := range ids {
  20988. m.label_relationships[ids[i]] = struct{}{}
  20989. }
  20990. }
  20991. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  20992. func (m *LabelMutation) ClearLabelRelationships() {
  20993. m.clearedlabel_relationships = true
  20994. }
  20995. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  20996. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  20997. return m.clearedlabel_relationships
  20998. }
  20999. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  21000. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  21001. if m.removedlabel_relationships == nil {
  21002. m.removedlabel_relationships = make(map[uint64]struct{})
  21003. }
  21004. for i := range ids {
  21005. delete(m.label_relationships, ids[i])
  21006. m.removedlabel_relationships[ids[i]] = struct{}{}
  21007. }
  21008. }
  21009. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  21010. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  21011. for id := range m.removedlabel_relationships {
  21012. ids = append(ids, id)
  21013. }
  21014. return
  21015. }
  21016. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  21017. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  21018. for id := range m.label_relationships {
  21019. ids = append(ids, id)
  21020. }
  21021. return
  21022. }
  21023. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  21024. func (m *LabelMutation) ResetLabelRelationships() {
  21025. m.label_relationships = nil
  21026. m.clearedlabel_relationships = false
  21027. m.removedlabel_relationships = nil
  21028. }
  21029. // Where appends a list predicates to the LabelMutation builder.
  21030. func (m *LabelMutation) Where(ps ...predicate.Label) {
  21031. m.predicates = append(m.predicates, ps...)
  21032. }
  21033. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  21034. // users can use type-assertion to append predicates that do not depend on any generated package.
  21035. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  21036. p := make([]predicate.Label, len(ps))
  21037. for i := range ps {
  21038. p[i] = ps[i]
  21039. }
  21040. m.Where(p...)
  21041. }
  21042. // Op returns the operation name.
  21043. func (m *LabelMutation) Op() Op {
  21044. return m.op
  21045. }
  21046. // SetOp allows setting the mutation operation.
  21047. func (m *LabelMutation) SetOp(op Op) {
  21048. m.op = op
  21049. }
  21050. // Type returns the node type of this mutation (Label).
  21051. func (m *LabelMutation) Type() string {
  21052. return m.typ
  21053. }
  21054. // Fields returns all fields that were changed during this mutation. Note that in
  21055. // order to get all numeric fields that were incremented/decremented, call
  21056. // AddedFields().
  21057. func (m *LabelMutation) Fields() []string {
  21058. fields := make([]string, 0, 9)
  21059. if m.created_at != nil {
  21060. fields = append(fields, label.FieldCreatedAt)
  21061. }
  21062. if m.updated_at != nil {
  21063. fields = append(fields, label.FieldUpdatedAt)
  21064. }
  21065. if m.status != nil {
  21066. fields = append(fields, label.FieldStatus)
  21067. }
  21068. if m._type != nil {
  21069. fields = append(fields, label.FieldType)
  21070. }
  21071. if m.name != nil {
  21072. fields = append(fields, label.FieldName)
  21073. }
  21074. if m.from != nil {
  21075. fields = append(fields, label.FieldFrom)
  21076. }
  21077. if m.mode != nil {
  21078. fields = append(fields, label.FieldMode)
  21079. }
  21080. if m.conditions != nil {
  21081. fields = append(fields, label.FieldConditions)
  21082. }
  21083. if m.organization_id != nil {
  21084. fields = append(fields, label.FieldOrganizationID)
  21085. }
  21086. return fields
  21087. }
  21088. // Field returns the value of a field with the given name. The second boolean
  21089. // return value indicates that this field was not set, or was not defined in the
  21090. // schema.
  21091. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  21092. switch name {
  21093. case label.FieldCreatedAt:
  21094. return m.CreatedAt()
  21095. case label.FieldUpdatedAt:
  21096. return m.UpdatedAt()
  21097. case label.FieldStatus:
  21098. return m.Status()
  21099. case label.FieldType:
  21100. return m.GetType()
  21101. case label.FieldName:
  21102. return m.Name()
  21103. case label.FieldFrom:
  21104. return m.From()
  21105. case label.FieldMode:
  21106. return m.Mode()
  21107. case label.FieldConditions:
  21108. return m.Conditions()
  21109. case label.FieldOrganizationID:
  21110. return m.OrganizationID()
  21111. }
  21112. return nil, false
  21113. }
  21114. // OldField returns the old value of the field from the database. An error is
  21115. // returned if the mutation operation is not UpdateOne, or the query to the
  21116. // database failed.
  21117. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21118. switch name {
  21119. case label.FieldCreatedAt:
  21120. return m.OldCreatedAt(ctx)
  21121. case label.FieldUpdatedAt:
  21122. return m.OldUpdatedAt(ctx)
  21123. case label.FieldStatus:
  21124. return m.OldStatus(ctx)
  21125. case label.FieldType:
  21126. return m.OldType(ctx)
  21127. case label.FieldName:
  21128. return m.OldName(ctx)
  21129. case label.FieldFrom:
  21130. return m.OldFrom(ctx)
  21131. case label.FieldMode:
  21132. return m.OldMode(ctx)
  21133. case label.FieldConditions:
  21134. return m.OldConditions(ctx)
  21135. case label.FieldOrganizationID:
  21136. return m.OldOrganizationID(ctx)
  21137. }
  21138. return nil, fmt.Errorf("unknown Label field %s", name)
  21139. }
  21140. // SetField sets the value of a field with the given name. It returns an error if
  21141. // the field is not defined in the schema, or if the type mismatched the field
  21142. // type.
  21143. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  21144. switch name {
  21145. case label.FieldCreatedAt:
  21146. v, ok := value.(time.Time)
  21147. if !ok {
  21148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21149. }
  21150. m.SetCreatedAt(v)
  21151. return nil
  21152. case label.FieldUpdatedAt:
  21153. v, ok := value.(time.Time)
  21154. if !ok {
  21155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21156. }
  21157. m.SetUpdatedAt(v)
  21158. return nil
  21159. case label.FieldStatus:
  21160. v, ok := value.(uint8)
  21161. if !ok {
  21162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21163. }
  21164. m.SetStatus(v)
  21165. return nil
  21166. case label.FieldType:
  21167. v, ok := value.(int)
  21168. if !ok {
  21169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21170. }
  21171. m.SetType(v)
  21172. return nil
  21173. case label.FieldName:
  21174. v, ok := value.(string)
  21175. if !ok {
  21176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21177. }
  21178. m.SetName(v)
  21179. return nil
  21180. case label.FieldFrom:
  21181. v, ok := value.(int)
  21182. if !ok {
  21183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21184. }
  21185. m.SetFrom(v)
  21186. return nil
  21187. case label.FieldMode:
  21188. v, ok := value.(int)
  21189. if !ok {
  21190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21191. }
  21192. m.SetMode(v)
  21193. return nil
  21194. case label.FieldConditions:
  21195. v, ok := value.(string)
  21196. if !ok {
  21197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21198. }
  21199. m.SetConditions(v)
  21200. return nil
  21201. case label.FieldOrganizationID:
  21202. v, ok := value.(uint64)
  21203. if !ok {
  21204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21205. }
  21206. m.SetOrganizationID(v)
  21207. return nil
  21208. }
  21209. return fmt.Errorf("unknown Label field %s", name)
  21210. }
  21211. // AddedFields returns all numeric fields that were incremented/decremented during
  21212. // this mutation.
  21213. func (m *LabelMutation) AddedFields() []string {
  21214. var fields []string
  21215. if m.addstatus != nil {
  21216. fields = append(fields, label.FieldStatus)
  21217. }
  21218. if m.add_type != nil {
  21219. fields = append(fields, label.FieldType)
  21220. }
  21221. if m.addfrom != nil {
  21222. fields = append(fields, label.FieldFrom)
  21223. }
  21224. if m.addmode != nil {
  21225. fields = append(fields, label.FieldMode)
  21226. }
  21227. if m.addorganization_id != nil {
  21228. fields = append(fields, label.FieldOrganizationID)
  21229. }
  21230. return fields
  21231. }
  21232. // AddedField returns the numeric value that was incremented/decremented on a field
  21233. // with the given name. The second boolean return value indicates that this field
  21234. // was not set, or was not defined in the schema.
  21235. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  21236. switch name {
  21237. case label.FieldStatus:
  21238. return m.AddedStatus()
  21239. case label.FieldType:
  21240. return m.AddedType()
  21241. case label.FieldFrom:
  21242. return m.AddedFrom()
  21243. case label.FieldMode:
  21244. return m.AddedMode()
  21245. case label.FieldOrganizationID:
  21246. return m.AddedOrganizationID()
  21247. }
  21248. return nil, false
  21249. }
  21250. // AddField adds the value to the field with the given name. It returns an error if
  21251. // the field is not defined in the schema, or if the type mismatched the field
  21252. // type.
  21253. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  21254. switch name {
  21255. case label.FieldStatus:
  21256. v, ok := value.(int8)
  21257. if !ok {
  21258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21259. }
  21260. m.AddStatus(v)
  21261. return nil
  21262. case label.FieldType:
  21263. v, ok := value.(int)
  21264. if !ok {
  21265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21266. }
  21267. m.AddType(v)
  21268. return nil
  21269. case label.FieldFrom:
  21270. v, ok := value.(int)
  21271. if !ok {
  21272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21273. }
  21274. m.AddFrom(v)
  21275. return nil
  21276. case label.FieldMode:
  21277. v, ok := value.(int)
  21278. if !ok {
  21279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21280. }
  21281. m.AddMode(v)
  21282. return nil
  21283. case label.FieldOrganizationID:
  21284. v, ok := value.(int64)
  21285. if !ok {
  21286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21287. }
  21288. m.AddOrganizationID(v)
  21289. return nil
  21290. }
  21291. return fmt.Errorf("unknown Label numeric field %s", name)
  21292. }
  21293. // ClearedFields returns all nullable fields that were cleared during this
  21294. // mutation.
  21295. func (m *LabelMutation) ClearedFields() []string {
  21296. var fields []string
  21297. if m.FieldCleared(label.FieldStatus) {
  21298. fields = append(fields, label.FieldStatus)
  21299. }
  21300. if m.FieldCleared(label.FieldConditions) {
  21301. fields = append(fields, label.FieldConditions)
  21302. }
  21303. if m.FieldCleared(label.FieldOrganizationID) {
  21304. fields = append(fields, label.FieldOrganizationID)
  21305. }
  21306. return fields
  21307. }
  21308. // FieldCleared returns a boolean indicating if a field with the given name was
  21309. // cleared in this mutation.
  21310. func (m *LabelMutation) FieldCleared(name string) bool {
  21311. _, ok := m.clearedFields[name]
  21312. return ok
  21313. }
  21314. // ClearField clears the value of the field with the given name. It returns an
  21315. // error if the field is not defined in the schema.
  21316. func (m *LabelMutation) ClearField(name string) error {
  21317. switch name {
  21318. case label.FieldStatus:
  21319. m.ClearStatus()
  21320. return nil
  21321. case label.FieldConditions:
  21322. m.ClearConditions()
  21323. return nil
  21324. case label.FieldOrganizationID:
  21325. m.ClearOrganizationID()
  21326. return nil
  21327. }
  21328. return fmt.Errorf("unknown Label nullable field %s", name)
  21329. }
  21330. // ResetField resets all changes in the mutation for the field with the given name.
  21331. // It returns an error if the field is not defined in the schema.
  21332. func (m *LabelMutation) ResetField(name string) error {
  21333. switch name {
  21334. case label.FieldCreatedAt:
  21335. m.ResetCreatedAt()
  21336. return nil
  21337. case label.FieldUpdatedAt:
  21338. m.ResetUpdatedAt()
  21339. return nil
  21340. case label.FieldStatus:
  21341. m.ResetStatus()
  21342. return nil
  21343. case label.FieldType:
  21344. m.ResetType()
  21345. return nil
  21346. case label.FieldName:
  21347. m.ResetName()
  21348. return nil
  21349. case label.FieldFrom:
  21350. m.ResetFrom()
  21351. return nil
  21352. case label.FieldMode:
  21353. m.ResetMode()
  21354. return nil
  21355. case label.FieldConditions:
  21356. m.ResetConditions()
  21357. return nil
  21358. case label.FieldOrganizationID:
  21359. m.ResetOrganizationID()
  21360. return nil
  21361. }
  21362. return fmt.Errorf("unknown Label field %s", name)
  21363. }
  21364. // AddedEdges returns all edge names that were set/added in this mutation.
  21365. func (m *LabelMutation) AddedEdges() []string {
  21366. edges := make([]string, 0, 1)
  21367. if m.label_relationships != nil {
  21368. edges = append(edges, label.EdgeLabelRelationships)
  21369. }
  21370. return edges
  21371. }
  21372. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21373. // name in this mutation.
  21374. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  21375. switch name {
  21376. case label.EdgeLabelRelationships:
  21377. ids := make([]ent.Value, 0, len(m.label_relationships))
  21378. for id := range m.label_relationships {
  21379. ids = append(ids, id)
  21380. }
  21381. return ids
  21382. }
  21383. return nil
  21384. }
  21385. // RemovedEdges returns all edge names that were removed in this mutation.
  21386. func (m *LabelMutation) RemovedEdges() []string {
  21387. edges := make([]string, 0, 1)
  21388. if m.removedlabel_relationships != nil {
  21389. edges = append(edges, label.EdgeLabelRelationships)
  21390. }
  21391. return edges
  21392. }
  21393. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21394. // the given name in this mutation.
  21395. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  21396. switch name {
  21397. case label.EdgeLabelRelationships:
  21398. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  21399. for id := range m.removedlabel_relationships {
  21400. ids = append(ids, id)
  21401. }
  21402. return ids
  21403. }
  21404. return nil
  21405. }
  21406. // ClearedEdges returns all edge names that were cleared in this mutation.
  21407. func (m *LabelMutation) ClearedEdges() []string {
  21408. edges := make([]string, 0, 1)
  21409. if m.clearedlabel_relationships {
  21410. edges = append(edges, label.EdgeLabelRelationships)
  21411. }
  21412. return edges
  21413. }
  21414. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21415. // was cleared in this mutation.
  21416. func (m *LabelMutation) EdgeCleared(name string) bool {
  21417. switch name {
  21418. case label.EdgeLabelRelationships:
  21419. return m.clearedlabel_relationships
  21420. }
  21421. return false
  21422. }
  21423. // ClearEdge clears the value of the edge with the given name. It returns an error
  21424. // if that edge is not defined in the schema.
  21425. func (m *LabelMutation) ClearEdge(name string) error {
  21426. switch name {
  21427. }
  21428. return fmt.Errorf("unknown Label unique edge %s", name)
  21429. }
  21430. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21431. // It returns an error if the edge is not defined in the schema.
  21432. func (m *LabelMutation) ResetEdge(name string) error {
  21433. switch name {
  21434. case label.EdgeLabelRelationships:
  21435. m.ResetLabelRelationships()
  21436. return nil
  21437. }
  21438. return fmt.Errorf("unknown Label edge %s", name)
  21439. }
  21440. // LabelLogMutation represents an operation that mutates the LabelLog nodes in the graph.
  21441. type LabelLogMutation struct {
  21442. config
  21443. op Op
  21444. typ string
  21445. id *uint64
  21446. created_at *time.Time
  21447. updated_at *time.Time
  21448. label_name *string
  21449. label_id *int
  21450. addlabel_id *int
  21451. wx_id *string
  21452. organization_id *uint64
  21453. addorganization_id *int64
  21454. clearedFields map[string]struct{}
  21455. done bool
  21456. oldValue func(context.Context) (*LabelLog, error)
  21457. predicates []predicate.LabelLog
  21458. }
  21459. var _ ent.Mutation = (*LabelLogMutation)(nil)
  21460. // labellogOption allows management of the mutation configuration using functional options.
  21461. type labellogOption func(*LabelLogMutation)
  21462. // newLabelLogMutation creates new mutation for the LabelLog entity.
  21463. func newLabelLogMutation(c config, op Op, opts ...labellogOption) *LabelLogMutation {
  21464. m := &LabelLogMutation{
  21465. config: c,
  21466. op: op,
  21467. typ: TypeLabelLog,
  21468. clearedFields: make(map[string]struct{}),
  21469. }
  21470. for _, opt := range opts {
  21471. opt(m)
  21472. }
  21473. return m
  21474. }
  21475. // withLabelLogID sets the ID field of the mutation.
  21476. func withLabelLogID(id uint64) labellogOption {
  21477. return func(m *LabelLogMutation) {
  21478. var (
  21479. err error
  21480. once sync.Once
  21481. value *LabelLog
  21482. )
  21483. m.oldValue = func(ctx context.Context) (*LabelLog, error) {
  21484. once.Do(func() {
  21485. if m.done {
  21486. err = errors.New("querying old values post mutation is not allowed")
  21487. } else {
  21488. value, err = m.Client().LabelLog.Get(ctx, id)
  21489. }
  21490. })
  21491. return value, err
  21492. }
  21493. m.id = &id
  21494. }
  21495. }
  21496. // withLabelLog sets the old LabelLog of the mutation.
  21497. func withLabelLog(node *LabelLog) labellogOption {
  21498. return func(m *LabelLogMutation) {
  21499. m.oldValue = func(context.Context) (*LabelLog, error) {
  21500. return node, nil
  21501. }
  21502. m.id = &node.ID
  21503. }
  21504. }
  21505. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21506. // executed in a transaction (ent.Tx), a transactional client is returned.
  21507. func (m LabelLogMutation) Client() *Client {
  21508. client := &Client{config: m.config}
  21509. client.init()
  21510. return client
  21511. }
  21512. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21513. // it returns an error otherwise.
  21514. func (m LabelLogMutation) Tx() (*Tx, error) {
  21515. if _, ok := m.driver.(*txDriver); !ok {
  21516. return nil, errors.New("ent: mutation is not running in a transaction")
  21517. }
  21518. tx := &Tx{config: m.config}
  21519. tx.init()
  21520. return tx, nil
  21521. }
  21522. // SetID sets the value of the id field. Note that this
  21523. // operation is only accepted on creation of LabelLog entities.
  21524. func (m *LabelLogMutation) SetID(id uint64) {
  21525. m.id = &id
  21526. }
  21527. // ID returns the ID value in the mutation. Note that the ID is only available
  21528. // if it was provided to the builder or after it was returned from the database.
  21529. func (m *LabelLogMutation) ID() (id uint64, exists bool) {
  21530. if m.id == nil {
  21531. return
  21532. }
  21533. return *m.id, true
  21534. }
  21535. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21536. // That means, if the mutation is applied within a transaction with an isolation level such
  21537. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21538. // or updated by the mutation.
  21539. func (m *LabelLogMutation) IDs(ctx context.Context) ([]uint64, error) {
  21540. switch {
  21541. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21542. id, exists := m.ID()
  21543. if exists {
  21544. return []uint64{id}, nil
  21545. }
  21546. fallthrough
  21547. case m.op.Is(OpUpdate | OpDelete):
  21548. return m.Client().LabelLog.Query().Where(m.predicates...).IDs(ctx)
  21549. default:
  21550. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21551. }
  21552. }
  21553. // SetCreatedAt sets the "created_at" field.
  21554. func (m *LabelLogMutation) SetCreatedAt(t time.Time) {
  21555. m.created_at = &t
  21556. }
  21557. // CreatedAt returns the value of the "created_at" field in the mutation.
  21558. func (m *LabelLogMutation) CreatedAt() (r time.Time, exists bool) {
  21559. v := m.created_at
  21560. if v == nil {
  21561. return
  21562. }
  21563. return *v, true
  21564. }
  21565. // OldCreatedAt returns the old "created_at" field's value of the LabelLog entity.
  21566. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21567. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21568. func (m *LabelLogMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21569. if !m.op.Is(OpUpdateOne) {
  21570. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21571. }
  21572. if m.id == nil || m.oldValue == nil {
  21573. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21574. }
  21575. oldValue, err := m.oldValue(ctx)
  21576. if err != nil {
  21577. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21578. }
  21579. return oldValue.CreatedAt, nil
  21580. }
  21581. // ResetCreatedAt resets all changes to the "created_at" field.
  21582. func (m *LabelLogMutation) ResetCreatedAt() {
  21583. m.created_at = nil
  21584. }
  21585. // SetUpdatedAt sets the "updated_at" field.
  21586. func (m *LabelLogMutation) SetUpdatedAt(t time.Time) {
  21587. m.updated_at = &t
  21588. }
  21589. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21590. func (m *LabelLogMutation) UpdatedAt() (r time.Time, exists bool) {
  21591. v := m.updated_at
  21592. if v == nil {
  21593. return
  21594. }
  21595. return *v, true
  21596. }
  21597. // OldUpdatedAt returns the old "updated_at" field's value of the LabelLog entity.
  21598. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21600. func (m *LabelLogMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21601. if !m.op.Is(OpUpdateOne) {
  21602. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21603. }
  21604. if m.id == nil || m.oldValue == nil {
  21605. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21606. }
  21607. oldValue, err := m.oldValue(ctx)
  21608. if err != nil {
  21609. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21610. }
  21611. return oldValue.UpdatedAt, nil
  21612. }
  21613. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21614. func (m *LabelLogMutation) ResetUpdatedAt() {
  21615. m.updated_at = nil
  21616. }
  21617. // SetLabelName sets the "label_name" field.
  21618. func (m *LabelLogMutation) SetLabelName(s string) {
  21619. m.label_name = &s
  21620. }
  21621. // LabelName returns the value of the "label_name" field in the mutation.
  21622. func (m *LabelLogMutation) LabelName() (r string, exists bool) {
  21623. v := m.label_name
  21624. if v == nil {
  21625. return
  21626. }
  21627. return *v, true
  21628. }
  21629. // OldLabelName returns the old "label_name" field's value of the LabelLog entity.
  21630. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21632. func (m *LabelLogMutation) OldLabelName(ctx context.Context) (v string, err error) {
  21633. if !m.op.Is(OpUpdateOne) {
  21634. return v, errors.New("OldLabelName is only allowed on UpdateOne operations")
  21635. }
  21636. if m.id == nil || m.oldValue == nil {
  21637. return v, errors.New("OldLabelName requires an ID field in the mutation")
  21638. }
  21639. oldValue, err := m.oldValue(ctx)
  21640. if err != nil {
  21641. return v, fmt.Errorf("querying old value for OldLabelName: %w", err)
  21642. }
  21643. return oldValue.LabelName, nil
  21644. }
  21645. // ResetLabelName resets all changes to the "label_name" field.
  21646. func (m *LabelLogMutation) ResetLabelName() {
  21647. m.label_name = nil
  21648. }
  21649. // SetLabelID sets the "label_id" field.
  21650. func (m *LabelLogMutation) SetLabelID(i int) {
  21651. m.label_id = &i
  21652. m.addlabel_id = nil
  21653. }
  21654. // LabelID returns the value of the "label_id" field in the mutation.
  21655. func (m *LabelLogMutation) LabelID() (r int, exists bool) {
  21656. v := m.label_id
  21657. if v == nil {
  21658. return
  21659. }
  21660. return *v, true
  21661. }
  21662. // OldLabelID returns the old "label_id" field's value of the LabelLog entity.
  21663. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21665. func (m *LabelLogMutation) OldLabelID(ctx context.Context) (v int, err error) {
  21666. if !m.op.Is(OpUpdateOne) {
  21667. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  21668. }
  21669. if m.id == nil || m.oldValue == nil {
  21670. return v, errors.New("OldLabelID requires an ID field in the mutation")
  21671. }
  21672. oldValue, err := m.oldValue(ctx)
  21673. if err != nil {
  21674. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  21675. }
  21676. return oldValue.LabelID, nil
  21677. }
  21678. // AddLabelID adds i to the "label_id" field.
  21679. func (m *LabelLogMutation) AddLabelID(i int) {
  21680. if m.addlabel_id != nil {
  21681. *m.addlabel_id += i
  21682. } else {
  21683. m.addlabel_id = &i
  21684. }
  21685. }
  21686. // AddedLabelID returns the value that was added to the "label_id" field in this mutation.
  21687. func (m *LabelLogMutation) AddedLabelID() (r int, exists bool) {
  21688. v := m.addlabel_id
  21689. if v == nil {
  21690. return
  21691. }
  21692. return *v, true
  21693. }
  21694. // ResetLabelID resets all changes to the "label_id" field.
  21695. func (m *LabelLogMutation) ResetLabelID() {
  21696. m.label_id = nil
  21697. m.addlabel_id = nil
  21698. }
  21699. // SetWxID sets the "wx_id" field.
  21700. func (m *LabelLogMutation) SetWxID(s string) {
  21701. m.wx_id = &s
  21702. }
  21703. // WxID returns the value of the "wx_id" field in the mutation.
  21704. func (m *LabelLogMutation) WxID() (r string, exists bool) {
  21705. v := m.wx_id
  21706. if v == nil {
  21707. return
  21708. }
  21709. return *v, true
  21710. }
  21711. // OldWxID returns the old "wx_id" field's value of the LabelLog entity.
  21712. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21714. func (m *LabelLogMutation) OldWxID(ctx context.Context) (v string, err error) {
  21715. if !m.op.Is(OpUpdateOne) {
  21716. return v, errors.New("OldWxID is only allowed on UpdateOne operations")
  21717. }
  21718. if m.id == nil || m.oldValue == nil {
  21719. return v, errors.New("OldWxID requires an ID field in the mutation")
  21720. }
  21721. oldValue, err := m.oldValue(ctx)
  21722. if err != nil {
  21723. return v, fmt.Errorf("querying old value for OldWxID: %w", err)
  21724. }
  21725. return oldValue.WxID, nil
  21726. }
  21727. // ResetWxID resets all changes to the "wx_id" field.
  21728. func (m *LabelLogMutation) ResetWxID() {
  21729. m.wx_id = nil
  21730. }
  21731. // SetOrganizationID sets the "organization_id" field.
  21732. func (m *LabelLogMutation) SetOrganizationID(u uint64) {
  21733. m.organization_id = &u
  21734. m.addorganization_id = nil
  21735. }
  21736. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21737. func (m *LabelLogMutation) OrganizationID() (r uint64, exists bool) {
  21738. v := m.organization_id
  21739. if v == nil {
  21740. return
  21741. }
  21742. return *v, true
  21743. }
  21744. // OldOrganizationID returns the old "organization_id" field's value of the LabelLog entity.
  21745. // If the LabelLog object wasn't provided to the builder, the object is fetched from the database.
  21746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21747. func (m *LabelLogMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21748. if !m.op.Is(OpUpdateOne) {
  21749. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21750. }
  21751. if m.id == nil || m.oldValue == nil {
  21752. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21753. }
  21754. oldValue, err := m.oldValue(ctx)
  21755. if err != nil {
  21756. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21757. }
  21758. return oldValue.OrganizationID, nil
  21759. }
  21760. // AddOrganizationID adds u to the "organization_id" field.
  21761. func (m *LabelLogMutation) AddOrganizationID(u int64) {
  21762. if m.addorganization_id != nil {
  21763. *m.addorganization_id += u
  21764. } else {
  21765. m.addorganization_id = &u
  21766. }
  21767. }
  21768. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21769. func (m *LabelLogMutation) AddedOrganizationID() (r int64, exists bool) {
  21770. v := m.addorganization_id
  21771. if v == nil {
  21772. return
  21773. }
  21774. return *v, true
  21775. }
  21776. // ClearOrganizationID clears the value of the "organization_id" field.
  21777. func (m *LabelLogMutation) ClearOrganizationID() {
  21778. m.organization_id = nil
  21779. m.addorganization_id = nil
  21780. m.clearedFields[labellog.FieldOrganizationID] = struct{}{}
  21781. }
  21782. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  21783. func (m *LabelLogMutation) OrganizationIDCleared() bool {
  21784. _, ok := m.clearedFields[labellog.FieldOrganizationID]
  21785. return ok
  21786. }
  21787. // ResetOrganizationID resets all changes to the "organization_id" field.
  21788. func (m *LabelLogMutation) ResetOrganizationID() {
  21789. m.organization_id = nil
  21790. m.addorganization_id = nil
  21791. delete(m.clearedFields, labellog.FieldOrganizationID)
  21792. }
  21793. // Where appends a list predicates to the LabelLogMutation builder.
  21794. func (m *LabelLogMutation) Where(ps ...predicate.LabelLog) {
  21795. m.predicates = append(m.predicates, ps...)
  21796. }
  21797. // WhereP appends storage-level predicates to the LabelLogMutation builder. Using this method,
  21798. // users can use type-assertion to append predicates that do not depend on any generated package.
  21799. func (m *LabelLogMutation) WhereP(ps ...func(*sql.Selector)) {
  21800. p := make([]predicate.LabelLog, len(ps))
  21801. for i := range ps {
  21802. p[i] = ps[i]
  21803. }
  21804. m.Where(p...)
  21805. }
  21806. // Op returns the operation name.
  21807. func (m *LabelLogMutation) Op() Op {
  21808. return m.op
  21809. }
  21810. // SetOp allows setting the mutation operation.
  21811. func (m *LabelLogMutation) SetOp(op Op) {
  21812. m.op = op
  21813. }
  21814. // Type returns the node type of this mutation (LabelLog).
  21815. func (m *LabelLogMutation) Type() string {
  21816. return m.typ
  21817. }
  21818. // Fields returns all fields that were changed during this mutation. Note that in
  21819. // order to get all numeric fields that were incremented/decremented, call
  21820. // AddedFields().
  21821. func (m *LabelLogMutation) Fields() []string {
  21822. fields := make([]string, 0, 6)
  21823. if m.created_at != nil {
  21824. fields = append(fields, labellog.FieldCreatedAt)
  21825. }
  21826. if m.updated_at != nil {
  21827. fields = append(fields, labellog.FieldUpdatedAt)
  21828. }
  21829. if m.label_name != nil {
  21830. fields = append(fields, labellog.FieldLabelName)
  21831. }
  21832. if m.label_id != nil {
  21833. fields = append(fields, labellog.FieldLabelID)
  21834. }
  21835. if m.wx_id != nil {
  21836. fields = append(fields, labellog.FieldWxID)
  21837. }
  21838. if m.organization_id != nil {
  21839. fields = append(fields, labellog.FieldOrganizationID)
  21840. }
  21841. return fields
  21842. }
  21843. // Field returns the value of a field with the given name. The second boolean
  21844. // return value indicates that this field was not set, or was not defined in the
  21845. // schema.
  21846. func (m *LabelLogMutation) Field(name string) (ent.Value, bool) {
  21847. switch name {
  21848. case labellog.FieldCreatedAt:
  21849. return m.CreatedAt()
  21850. case labellog.FieldUpdatedAt:
  21851. return m.UpdatedAt()
  21852. case labellog.FieldLabelName:
  21853. return m.LabelName()
  21854. case labellog.FieldLabelID:
  21855. return m.LabelID()
  21856. case labellog.FieldWxID:
  21857. return m.WxID()
  21858. case labellog.FieldOrganizationID:
  21859. return m.OrganizationID()
  21860. }
  21861. return nil, false
  21862. }
  21863. // OldField returns the old value of the field from the database. An error is
  21864. // returned if the mutation operation is not UpdateOne, or the query to the
  21865. // database failed.
  21866. func (m *LabelLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21867. switch name {
  21868. case labellog.FieldCreatedAt:
  21869. return m.OldCreatedAt(ctx)
  21870. case labellog.FieldUpdatedAt:
  21871. return m.OldUpdatedAt(ctx)
  21872. case labellog.FieldLabelName:
  21873. return m.OldLabelName(ctx)
  21874. case labellog.FieldLabelID:
  21875. return m.OldLabelID(ctx)
  21876. case labellog.FieldWxID:
  21877. return m.OldWxID(ctx)
  21878. case labellog.FieldOrganizationID:
  21879. return m.OldOrganizationID(ctx)
  21880. }
  21881. return nil, fmt.Errorf("unknown LabelLog field %s", name)
  21882. }
  21883. // SetField sets the value of a field with the given name. It returns an error if
  21884. // the field is not defined in the schema, or if the type mismatched the field
  21885. // type.
  21886. func (m *LabelLogMutation) SetField(name string, value ent.Value) error {
  21887. switch name {
  21888. case labellog.FieldCreatedAt:
  21889. v, ok := value.(time.Time)
  21890. if !ok {
  21891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21892. }
  21893. m.SetCreatedAt(v)
  21894. return nil
  21895. case labellog.FieldUpdatedAt:
  21896. v, ok := value.(time.Time)
  21897. if !ok {
  21898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21899. }
  21900. m.SetUpdatedAt(v)
  21901. return nil
  21902. case labellog.FieldLabelName:
  21903. v, ok := value.(string)
  21904. if !ok {
  21905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21906. }
  21907. m.SetLabelName(v)
  21908. return nil
  21909. case labellog.FieldLabelID:
  21910. v, ok := value.(int)
  21911. if !ok {
  21912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21913. }
  21914. m.SetLabelID(v)
  21915. return nil
  21916. case labellog.FieldWxID:
  21917. v, ok := value.(string)
  21918. if !ok {
  21919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21920. }
  21921. m.SetWxID(v)
  21922. return nil
  21923. case labellog.FieldOrganizationID:
  21924. v, ok := value.(uint64)
  21925. if !ok {
  21926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21927. }
  21928. m.SetOrganizationID(v)
  21929. return nil
  21930. }
  21931. return fmt.Errorf("unknown LabelLog field %s", name)
  21932. }
  21933. // AddedFields returns all numeric fields that were incremented/decremented during
  21934. // this mutation.
  21935. func (m *LabelLogMutation) AddedFields() []string {
  21936. var fields []string
  21937. if m.addlabel_id != nil {
  21938. fields = append(fields, labellog.FieldLabelID)
  21939. }
  21940. if m.addorganization_id != nil {
  21941. fields = append(fields, labellog.FieldOrganizationID)
  21942. }
  21943. return fields
  21944. }
  21945. // AddedField returns the numeric value that was incremented/decremented on a field
  21946. // with the given name. The second boolean return value indicates that this field
  21947. // was not set, or was not defined in the schema.
  21948. func (m *LabelLogMutation) AddedField(name string) (ent.Value, bool) {
  21949. switch name {
  21950. case labellog.FieldLabelID:
  21951. return m.AddedLabelID()
  21952. case labellog.FieldOrganizationID:
  21953. return m.AddedOrganizationID()
  21954. }
  21955. return nil, false
  21956. }
  21957. // AddField adds the value to the field with the given name. It returns an error if
  21958. // the field is not defined in the schema, or if the type mismatched the field
  21959. // type.
  21960. func (m *LabelLogMutation) AddField(name string, value ent.Value) error {
  21961. switch name {
  21962. case labellog.FieldLabelID:
  21963. v, ok := value.(int)
  21964. if !ok {
  21965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21966. }
  21967. m.AddLabelID(v)
  21968. return nil
  21969. case labellog.FieldOrganizationID:
  21970. v, ok := value.(int64)
  21971. if !ok {
  21972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21973. }
  21974. m.AddOrganizationID(v)
  21975. return nil
  21976. }
  21977. return fmt.Errorf("unknown LabelLog numeric field %s", name)
  21978. }
  21979. // ClearedFields returns all nullable fields that were cleared during this
  21980. // mutation.
  21981. func (m *LabelLogMutation) ClearedFields() []string {
  21982. var fields []string
  21983. if m.FieldCleared(labellog.FieldOrganizationID) {
  21984. fields = append(fields, labellog.FieldOrganizationID)
  21985. }
  21986. return fields
  21987. }
  21988. // FieldCleared returns a boolean indicating if a field with the given name was
  21989. // cleared in this mutation.
  21990. func (m *LabelLogMutation) FieldCleared(name string) bool {
  21991. _, ok := m.clearedFields[name]
  21992. return ok
  21993. }
  21994. // ClearField clears the value of the field with the given name. It returns an
  21995. // error if the field is not defined in the schema.
  21996. func (m *LabelLogMutation) ClearField(name string) error {
  21997. switch name {
  21998. case labellog.FieldOrganizationID:
  21999. m.ClearOrganizationID()
  22000. return nil
  22001. }
  22002. return fmt.Errorf("unknown LabelLog nullable field %s", name)
  22003. }
  22004. // ResetField resets all changes in the mutation for the field with the given name.
  22005. // It returns an error if the field is not defined in the schema.
  22006. func (m *LabelLogMutation) ResetField(name string) error {
  22007. switch name {
  22008. case labellog.FieldCreatedAt:
  22009. m.ResetCreatedAt()
  22010. return nil
  22011. case labellog.FieldUpdatedAt:
  22012. m.ResetUpdatedAt()
  22013. return nil
  22014. case labellog.FieldLabelName:
  22015. m.ResetLabelName()
  22016. return nil
  22017. case labellog.FieldLabelID:
  22018. m.ResetLabelID()
  22019. return nil
  22020. case labellog.FieldWxID:
  22021. m.ResetWxID()
  22022. return nil
  22023. case labellog.FieldOrganizationID:
  22024. m.ResetOrganizationID()
  22025. return nil
  22026. }
  22027. return fmt.Errorf("unknown LabelLog field %s", name)
  22028. }
  22029. // AddedEdges returns all edge names that were set/added in this mutation.
  22030. func (m *LabelLogMutation) AddedEdges() []string {
  22031. edges := make([]string, 0, 0)
  22032. return edges
  22033. }
  22034. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22035. // name in this mutation.
  22036. func (m *LabelLogMutation) AddedIDs(name string) []ent.Value {
  22037. return nil
  22038. }
  22039. // RemovedEdges returns all edge names that were removed in this mutation.
  22040. func (m *LabelLogMutation) RemovedEdges() []string {
  22041. edges := make([]string, 0, 0)
  22042. return edges
  22043. }
  22044. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22045. // the given name in this mutation.
  22046. func (m *LabelLogMutation) RemovedIDs(name string) []ent.Value {
  22047. return nil
  22048. }
  22049. // ClearedEdges returns all edge names that were cleared in this mutation.
  22050. func (m *LabelLogMutation) ClearedEdges() []string {
  22051. edges := make([]string, 0, 0)
  22052. return edges
  22053. }
  22054. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22055. // was cleared in this mutation.
  22056. func (m *LabelLogMutation) EdgeCleared(name string) bool {
  22057. return false
  22058. }
  22059. // ClearEdge clears the value of the edge with the given name. It returns an error
  22060. // if that edge is not defined in the schema.
  22061. func (m *LabelLogMutation) ClearEdge(name string) error {
  22062. return fmt.Errorf("unknown LabelLog unique edge %s", name)
  22063. }
  22064. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22065. // It returns an error if the edge is not defined in the schema.
  22066. func (m *LabelLogMutation) ResetEdge(name string) error {
  22067. return fmt.Errorf("unknown LabelLog edge %s", name)
  22068. }
  22069. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  22070. type LabelRelationshipMutation struct {
  22071. config
  22072. op Op
  22073. typ string
  22074. id *uint64
  22075. created_at *time.Time
  22076. updated_at *time.Time
  22077. status *uint8
  22078. addstatus *int8
  22079. organization_id *uint64
  22080. addorganization_id *int64
  22081. clearedFields map[string]struct{}
  22082. contacts *uint64
  22083. clearedcontacts bool
  22084. labels *uint64
  22085. clearedlabels bool
  22086. done bool
  22087. oldValue func(context.Context) (*LabelRelationship, error)
  22088. predicates []predicate.LabelRelationship
  22089. }
  22090. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  22091. // labelrelationshipOption allows management of the mutation configuration using functional options.
  22092. type labelrelationshipOption func(*LabelRelationshipMutation)
  22093. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  22094. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  22095. m := &LabelRelationshipMutation{
  22096. config: c,
  22097. op: op,
  22098. typ: TypeLabelRelationship,
  22099. clearedFields: make(map[string]struct{}),
  22100. }
  22101. for _, opt := range opts {
  22102. opt(m)
  22103. }
  22104. return m
  22105. }
  22106. // withLabelRelationshipID sets the ID field of the mutation.
  22107. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  22108. return func(m *LabelRelationshipMutation) {
  22109. var (
  22110. err error
  22111. once sync.Once
  22112. value *LabelRelationship
  22113. )
  22114. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  22115. once.Do(func() {
  22116. if m.done {
  22117. err = errors.New("querying old values post mutation is not allowed")
  22118. } else {
  22119. value, err = m.Client().LabelRelationship.Get(ctx, id)
  22120. }
  22121. })
  22122. return value, err
  22123. }
  22124. m.id = &id
  22125. }
  22126. }
  22127. // withLabelRelationship sets the old LabelRelationship of the mutation.
  22128. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  22129. return func(m *LabelRelationshipMutation) {
  22130. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  22131. return node, nil
  22132. }
  22133. m.id = &node.ID
  22134. }
  22135. }
  22136. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22137. // executed in a transaction (ent.Tx), a transactional client is returned.
  22138. func (m LabelRelationshipMutation) Client() *Client {
  22139. client := &Client{config: m.config}
  22140. client.init()
  22141. return client
  22142. }
  22143. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22144. // it returns an error otherwise.
  22145. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  22146. if _, ok := m.driver.(*txDriver); !ok {
  22147. return nil, errors.New("ent: mutation is not running in a transaction")
  22148. }
  22149. tx := &Tx{config: m.config}
  22150. tx.init()
  22151. return tx, nil
  22152. }
  22153. // SetID sets the value of the id field. Note that this
  22154. // operation is only accepted on creation of LabelRelationship entities.
  22155. func (m *LabelRelationshipMutation) SetID(id uint64) {
  22156. m.id = &id
  22157. }
  22158. // ID returns the ID value in the mutation. Note that the ID is only available
  22159. // if it was provided to the builder or after it was returned from the database.
  22160. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  22161. if m.id == nil {
  22162. return
  22163. }
  22164. return *m.id, true
  22165. }
  22166. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22167. // That means, if the mutation is applied within a transaction with an isolation level such
  22168. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22169. // or updated by the mutation.
  22170. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  22171. switch {
  22172. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22173. id, exists := m.ID()
  22174. if exists {
  22175. return []uint64{id}, nil
  22176. }
  22177. fallthrough
  22178. case m.op.Is(OpUpdate | OpDelete):
  22179. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  22180. default:
  22181. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22182. }
  22183. }
  22184. // SetCreatedAt sets the "created_at" field.
  22185. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  22186. m.created_at = &t
  22187. }
  22188. // CreatedAt returns the value of the "created_at" field in the mutation.
  22189. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  22190. v := m.created_at
  22191. if v == nil {
  22192. return
  22193. }
  22194. return *v, true
  22195. }
  22196. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  22197. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22199. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22200. if !m.op.Is(OpUpdateOne) {
  22201. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22202. }
  22203. if m.id == nil || m.oldValue == nil {
  22204. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22205. }
  22206. oldValue, err := m.oldValue(ctx)
  22207. if err != nil {
  22208. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22209. }
  22210. return oldValue.CreatedAt, nil
  22211. }
  22212. // ResetCreatedAt resets all changes to the "created_at" field.
  22213. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  22214. m.created_at = nil
  22215. }
  22216. // SetUpdatedAt sets the "updated_at" field.
  22217. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  22218. m.updated_at = &t
  22219. }
  22220. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22221. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  22222. v := m.updated_at
  22223. if v == nil {
  22224. return
  22225. }
  22226. return *v, true
  22227. }
  22228. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  22229. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22231. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22232. if !m.op.Is(OpUpdateOne) {
  22233. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22234. }
  22235. if m.id == nil || m.oldValue == nil {
  22236. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22237. }
  22238. oldValue, err := m.oldValue(ctx)
  22239. if err != nil {
  22240. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22241. }
  22242. return oldValue.UpdatedAt, nil
  22243. }
  22244. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22245. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  22246. m.updated_at = nil
  22247. }
  22248. // SetStatus sets the "status" field.
  22249. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  22250. m.status = &u
  22251. m.addstatus = nil
  22252. }
  22253. // Status returns the value of the "status" field in the mutation.
  22254. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  22255. v := m.status
  22256. if v == nil {
  22257. return
  22258. }
  22259. return *v, true
  22260. }
  22261. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  22262. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22264. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22265. if !m.op.Is(OpUpdateOne) {
  22266. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22267. }
  22268. if m.id == nil || m.oldValue == nil {
  22269. return v, errors.New("OldStatus requires an ID field in the mutation")
  22270. }
  22271. oldValue, err := m.oldValue(ctx)
  22272. if err != nil {
  22273. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22274. }
  22275. return oldValue.Status, nil
  22276. }
  22277. // AddStatus adds u to the "status" field.
  22278. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  22279. if m.addstatus != nil {
  22280. *m.addstatus += u
  22281. } else {
  22282. m.addstatus = &u
  22283. }
  22284. }
  22285. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22286. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  22287. v := m.addstatus
  22288. if v == nil {
  22289. return
  22290. }
  22291. return *v, true
  22292. }
  22293. // ClearStatus clears the value of the "status" field.
  22294. func (m *LabelRelationshipMutation) ClearStatus() {
  22295. m.status = nil
  22296. m.addstatus = nil
  22297. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  22298. }
  22299. // StatusCleared returns if the "status" field was cleared in this mutation.
  22300. func (m *LabelRelationshipMutation) StatusCleared() bool {
  22301. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  22302. return ok
  22303. }
  22304. // ResetStatus resets all changes to the "status" field.
  22305. func (m *LabelRelationshipMutation) ResetStatus() {
  22306. m.status = nil
  22307. m.addstatus = nil
  22308. delete(m.clearedFields, labelrelationship.FieldStatus)
  22309. }
  22310. // SetLabelID sets the "label_id" field.
  22311. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  22312. m.labels = &u
  22313. }
  22314. // LabelID returns the value of the "label_id" field in the mutation.
  22315. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  22316. v := m.labels
  22317. if v == nil {
  22318. return
  22319. }
  22320. return *v, true
  22321. }
  22322. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  22323. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22325. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  22326. if !m.op.Is(OpUpdateOne) {
  22327. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  22328. }
  22329. if m.id == nil || m.oldValue == nil {
  22330. return v, errors.New("OldLabelID requires an ID field in the mutation")
  22331. }
  22332. oldValue, err := m.oldValue(ctx)
  22333. if err != nil {
  22334. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  22335. }
  22336. return oldValue.LabelID, nil
  22337. }
  22338. // ResetLabelID resets all changes to the "label_id" field.
  22339. func (m *LabelRelationshipMutation) ResetLabelID() {
  22340. m.labels = nil
  22341. }
  22342. // SetContactID sets the "contact_id" field.
  22343. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  22344. m.contacts = &u
  22345. }
  22346. // ContactID returns the value of the "contact_id" field in the mutation.
  22347. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  22348. v := m.contacts
  22349. if v == nil {
  22350. return
  22351. }
  22352. return *v, true
  22353. }
  22354. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  22355. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22357. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  22358. if !m.op.Is(OpUpdateOne) {
  22359. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  22360. }
  22361. if m.id == nil || m.oldValue == nil {
  22362. return v, errors.New("OldContactID requires an ID field in the mutation")
  22363. }
  22364. oldValue, err := m.oldValue(ctx)
  22365. if err != nil {
  22366. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  22367. }
  22368. return oldValue.ContactID, nil
  22369. }
  22370. // ResetContactID resets all changes to the "contact_id" field.
  22371. func (m *LabelRelationshipMutation) ResetContactID() {
  22372. m.contacts = nil
  22373. }
  22374. // SetOrganizationID sets the "organization_id" field.
  22375. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  22376. m.organization_id = &u
  22377. m.addorganization_id = nil
  22378. }
  22379. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22380. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  22381. v := m.organization_id
  22382. if v == nil {
  22383. return
  22384. }
  22385. return *v, true
  22386. }
  22387. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  22388. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  22389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22390. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22391. if !m.op.Is(OpUpdateOne) {
  22392. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22393. }
  22394. if m.id == nil || m.oldValue == nil {
  22395. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22396. }
  22397. oldValue, err := m.oldValue(ctx)
  22398. if err != nil {
  22399. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22400. }
  22401. return oldValue.OrganizationID, nil
  22402. }
  22403. // AddOrganizationID adds u to the "organization_id" field.
  22404. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  22405. if m.addorganization_id != nil {
  22406. *m.addorganization_id += u
  22407. } else {
  22408. m.addorganization_id = &u
  22409. }
  22410. }
  22411. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22412. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  22413. v := m.addorganization_id
  22414. if v == nil {
  22415. return
  22416. }
  22417. return *v, true
  22418. }
  22419. // ClearOrganizationID clears the value of the "organization_id" field.
  22420. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  22421. m.organization_id = nil
  22422. m.addorganization_id = nil
  22423. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  22424. }
  22425. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  22426. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  22427. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  22428. return ok
  22429. }
  22430. // ResetOrganizationID resets all changes to the "organization_id" field.
  22431. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  22432. m.organization_id = nil
  22433. m.addorganization_id = nil
  22434. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  22435. }
  22436. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  22437. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  22438. m.contacts = &id
  22439. }
  22440. // ClearContacts clears the "contacts" edge to the Contact entity.
  22441. func (m *LabelRelationshipMutation) ClearContacts() {
  22442. m.clearedcontacts = true
  22443. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  22444. }
  22445. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  22446. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  22447. return m.clearedcontacts
  22448. }
  22449. // ContactsID returns the "contacts" edge ID in the mutation.
  22450. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  22451. if m.contacts != nil {
  22452. return *m.contacts, true
  22453. }
  22454. return
  22455. }
  22456. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  22457. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22458. // ContactsID instead. It exists only for internal usage by the builders.
  22459. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  22460. if id := m.contacts; id != nil {
  22461. ids = append(ids, *id)
  22462. }
  22463. return
  22464. }
  22465. // ResetContacts resets all changes to the "contacts" edge.
  22466. func (m *LabelRelationshipMutation) ResetContacts() {
  22467. m.contacts = nil
  22468. m.clearedcontacts = false
  22469. }
  22470. // SetLabelsID sets the "labels" edge to the Label entity by id.
  22471. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  22472. m.labels = &id
  22473. }
  22474. // ClearLabels clears the "labels" edge to the Label entity.
  22475. func (m *LabelRelationshipMutation) ClearLabels() {
  22476. m.clearedlabels = true
  22477. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  22478. }
  22479. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  22480. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  22481. return m.clearedlabels
  22482. }
  22483. // LabelsID returns the "labels" edge ID in the mutation.
  22484. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  22485. if m.labels != nil {
  22486. return *m.labels, true
  22487. }
  22488. return
  22489. }
  22490. // LabelsIDs returns the "labels" edge IDs in the mutation.
  22491. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22492. // LabelsID instead. It exists only for internal usage by the builders.
  22493. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  22494. if id := m.labels; id != nil {
  22495. ids = append(ids, *id)
  22496. }
  22497. return
  22498. }
  22499. // ResetLabels resets all changes to the "labels" edge.
  22500. func (m *LabelRelationshipMutation) ResetLabels() {
  22501. m.labels = nil
  22502. m.clearedlabels = false
  22503. }
  22504. // Where appends a list predicates to the LabelRelationshipMutation builder.
  22505. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  22506. m.predicates = append(m.predicates, ps...)
  22507. }
  22508. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  22509. // users can use type-assertion to append predicates that do not depend on any generated package.
  22510. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  22511. p := make([]predicate.LabelRelationship, len(ps))
  22512. for i := range ps {
  22513. p[i] = ps[i]
  22514. }
  22515. m.Where(p...)
  22516. }
  22517. // Op returns the operation name.
  22518. func (m *LabelRelationshipMutation) Op() Op {
  22519. return m.op
  22520. }
  22521. // SetOp allows setting the mutation operation.
  22522. func (m *LabelRelationshipMutation) SetOp(op Op) {
  22523. m.op = op
  22524. }
  22525. // Type returns the node type of this mutation (LabelRelationship).
  22526. func (m *LabelRelationshipMutation) Type() string {
  22527. return m.typ
  22528. }
  22529. // Fields returns all fields that were changed during this mutation. Note that in
  22530. // order to get all numeric fields that were incremented/decremented, call
  22531. // AddedFields().
  22532. func (m *LabelRelationshipMutation) Fields() []string {
  22533. fields := make([]string, 0, 6)
  22534. if m.created_at != nil {
  22535. fields = append(fields, labelrelationship.FieldCreatedAt)
  22536. }
  22537. if m.updated_at != nil {
  22538. fields = append(fields, labelrelationship.FieldUpdatedAt)
  22539. }
  22540. if m.status != nil {
  22541. fields = append(fields, labelrelationship.FieldStatus)
  22542. }
  22543. if m.labels != nil {
  22544. fields = append(fields, labelrelationship.FieldLabelID)
  22545. }
  22546. if m.contacts != nil {
  22547. fields = append(fields, labelrelationship.FieldContactID)
  22548. }
  22549. if m.organization_id != nil {
  22550. fields = append(fields, labelrelationship.FieldOrganizationID)
  22551. }
  22552. return fields
  22553. }
  22554. // Field returns the value of a field with the given name. The second boolean
  22555. // return value indicates that this field was not set, or was not defined in the
  22556. // schema.
  22557. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  22558. switch name {
  22559. case labelrelationship.FieldCreatedAt:
  22560. return m.CreatedAt()
  22561. case labelrelationship.FieldUpdatedAt:
  22562. return m.UpdatedAt()
  22563. case labelrelationship.FieldStatus:
  22564. return m.Status()
  22565. case labelrelationship.FieldLabelID:
  22566. return m.LabelID()
  22567. case labelrelationship.FieldContactID:
  22568. return m.ContactID()
  22569. case labelrelationship.FieldOrganizationID:
  22570. return m.OrganizationID()
  22571. }
  22572. return nil, false
  22573. }
  22574. // OldField returns the old value of the field from the database. An error is
  22575. // returned if the mutation operation is not UpdateOne, or the query to the
  22576. // database failed.
  22577. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22578. switch name {
  22579. case labelrelationship.FieldCreatedAt:
  22580. return m.OldCreatedAt(ctx)
  22581. case labelrelationship.FieldUpdatedAt:
  22582. return m.OldUpdatedAt(ctx)
  22583. case labelrelationship.FieldStatus:
  22584. return m.OldStatus(ctx)
  22585. case labelrelationship.FieldLabelID:
  22586. return m.OldLabelID(ctx)
  22587. case labelrelationship.FieldContactID:
  22588. return m.OldContactID(ctx)
  22589. case labelrelationship.FieldOrganizationID:
  22590. return m.OldOrganizationID(ctx)
  22591. }
  22592. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  22593. }
  22594. // SetField sets the value of a field with the given name. It returns an error if
  22595. // the field is not defined in the schema, or if the type mismatched the field
  22596. // type.
  22597. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  22598. switch name {
  22599. case labelrelationship.FieldCreatedAt:
  22600. v, ok := value.(time.Time)
  22601. if !ok {
  22602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22603. }
  22604. m.SetCreatedAt(v)
  22605. return nil
  22606. case labelrelationship.FieldUpdatedAt:
  22607. v, ok := value.(time.Time)
  22608. if !ok {
  22609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22610. }
  22611. m.SetUpdatedAt(v)
  22612. return nil
  22613. case labelrelationship.FieldStatus:
  22614. v, ok := value.(uint8)
  22615. if !ok {
  22616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22617. }
  22618. m.SetStatus(v)
  22619. return nil
  22620. case labelrelationship.FieldLabelID:
  22621. v, ok := value.(uint64)
  22622. if !ok {
  22623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22624. }
  22625. m.SetLabelID(v)
  22626. return nil
  22627. case labelrelationship.FieldContactID:
  22628. v, ok := value.(uint64)
  22629. if !ok {
  22630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22631. }
  22632. m.SetContactID(v)
  22633. return nil
  22634. case labelrelationship.FieldOrganizationID:
  22635. v, ok := value.(uint64)
  22636. if !ok {
  22637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22638. }
  22639. m.SetOrganizationID(v)
  22640. return nil
  22641. }
  22642. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22643. }
  22644. // AddedFields returns all numeric fields that were incremented/decremented during
  22645. // this mutation.
  22646. func (m *LabelRelationshipMutation) AddedFields() []string {
  22647. var fields []string
  22648. if m.addstatus != nil {
  22649. fields = append(fields, labelrelationship.FieldStatus)
  22650. }
  22651. if m.addorganization_id != nil {
  22652. fields = append(fields, labelrelationship.FieldOrganizationID)
  22653. }
  22654. return fields
  22655. }
  22656. // AddedField returns the numeric value that was incremented/decremented on a field
  22657. // with the given name. The second boolean return value indicates that this field
  22658. // was not set, or was not defined in the schema.
  22659. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  22660. switch name {
  22661. case labelrelationship.FieldStatus:
  22662. return m.AddedStatus()
  22663. case labelrelationship.FieldOrganizationID:
  22664. return m.AddedOrganizationID()
  22665. }
  22666. return nil, false
  22667. }
  22668. // AddField adds the value to the field with the given name. It returns an error if
  22669. // the field is not defined in the schema, or if the type mismatched the field
  22670. // type.
  22671. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  22672. switch name {
  22673. case labelrelationship.FieldStatus:
  22674. v, ok := value.(int8)
  22675. if !ok {
  22676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22677. }
  22678. m.AddStatus(v)
  22679. return nil
  22680. case labelrelationship.FieldOrganizationID:
  22681. v, ok := value.(int64)
  22682. if !ok {
  22683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22684. }
  22685. m.AddOrganizationID(v)
  22686. return nil
  22687. }
  22688. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  22689. }
  22690. // ClearedFields returns all nullable fields that were cleared during this
  22691. // mutation.
  22692. func (m *LabelRelationshipMutation) ClearedFields() []string {
  22693. var fields []string
  22694. if m.FieldCleared(labelrelationship.FieldStatus) {
  22695. fields = append(fields, labelrelationship.FieldStatus)
  22696. }
  22697. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  22698. fields = append(fields, labelrelationship.FieldOrganizationID)
  22699. }
  22700. return fields
  22701. }
  22702. // FieldCleared returns a boolean indicating if a field with the given name was
  22703. // cleared in this mutation.
  22704. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  22705. _, ok := m.clearedFields[name]
  22706. return ok
  22707. }
  22708. // ClearField clears the value of the field with the given name. It returns an
  22709. // error if the field is not defined in the schema.
  22710. func (m *LabelRelationshipMutation) ClearField(name string) error {
  22711. switch name {
  22712. case labelrelationship.FieldStatus:
  22713. m.ClearStatus()
  22714. return nil
  22715. case labelrelationship.FieldOrganizationID:
  22716. m.ClearOrganizationID()
  22717. return nil
  22718. }
  22719. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  22720. }
  22721. // ResetField resets all changes in the mutation for the field with the given name.
  22722. // It returns an error if the field is not defined in the schema.
  22723. func (m *LabelRelationshipMutation) ResetField(name string) error {
  22724. switch name {
  22725. case labelrelationship.FieldCreatedAt:
  22726. m.ResetCreatedAt()
  22727. return nil
  22728. case labelrelationship.FieldUpdatedAt:
  22729. m.ResetUpdatedAt()
  22730. return nil
  22731. case labelrelationship.FieldStatus:
  22732. m.ResetStatus()
  22733. return nil
  22734. case labelrelationship.FieldLabelID:
  22735. m.ResetLabelID()
  22736. return nil
  22737. case labelrelationship.FieldContactID:
  22738. m.ResetContactID()
  22739. return nil
  22740. case labelrelationship.FieldOrganizationID:
  22741. m.ResetOrganizationID()
  22742. return nil
  22743. }
  22744. return fmt.Errorf("unknown LabelRelationship field %s", name)
  22745. }
  22746. // AddedEdges returns all edge names that were set/added in this mutation.
  22747. func (m *LabelRelationshipMutation) AddedEdges() []string {
  22748. edges := make([]string, 0, 2)
  22749. if m.contacts != nil {
  22750. edges = append(edges, labelrelationship.EdgeContacts)
  22751. }
  22752. if m.labels != nil {
  22753. edges = append(edges, labelrelationship.EdgeLabels)
  22754. }
  22755. return edges
  22756. }
  22757. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22758. // name in this mutation.
  22759. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  22760. switch name {
  22761. case labelrelationship.EdgeContacts:
  22762. if id := m.contacts; id != nil {
  22763. return []ent.Value{*id}
  22764. }
  22765. case labelrelationship.EdgeLabels:
  22766. if id := m.labels; id != nil {
  22767. return []ent.Value{*id}
  22768. }
  22769. }
  22770. return nil
  22771. }
  22772. // RemovedEdges returns all edge names that were removed in this mutation.
  22773. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  22774. edges := make([]string, 0, 2)
  22775. return edges
  22776. }
  22777. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22778. // the given name in this mutation.
  22779. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  22780. return nil
  22781. }
  22782. // ClearedEdges returns all edge names that were cleared in this mutation.
  22783. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  22784. edges := make([]string, 0, 2)
  22785. if m.clearedcontacts {
  22786. edges = append(edges, labelrelationship.EdgeContacts)
  22787. }
  22788. if m.clearedlabels {
  22789. edges = append(edges, labelrelationship.EdgeLabels)
  22790. }
  22791. return edges
  22792. }
  22793. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22794. // was cleared in this mutation.
  22795. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  22796. switch name {
  22797. case labelrelationship.EdgeContacts:
  22798. return m.clearedcontacts
  22799. case labelrelationship.EdgeLabels:
  22800. return m.clearedlabels
  22801. }
  22802. return false
  22803. }
  22804. // ClearEdge clears the value of the edge with the given name. It returns an error
  22805. // if that edge is not defined in the schema.
  22806. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  22807. switch name {
  22808. case labelrelationship.EdgeContacts:
  22809. m.ClearContacts()
  22810. return nil
  22811. case labelrelationship.EdgeLabels:
  22812. m.ClearLabels()
  22813. return nil
  22814. }
  22815. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  22816. }
  22817. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22818. // It returns an error if the edge is not defined in the schema.
  22819. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  22820. switch name {
  22821. case labelrelationship.EdgeContacts:
  22822. m.ResetContacts()
  22823. return nil
  22824. case labelrelationship.EdgeLabels:
  22825. m.ResetLabels()
  22826. return nil
  22827. }
  22828. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  22829. }
  22830. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  22831. type LabelTaggingMutation struct {
  22832. config
  22833. op Op
  22834. typ string
  22835. id *uint64
  22836. created_at *time.Time
  22837. updated_at *time.Time
  22838. status *uint8
  22839. addstatus *int8
  22840. deleted_at *time.Time
  22841. organization_id *uint64
  22842. addorganization_id *int64
  22843. _type *int
  22844. add_type *int
  22845. conditions *string
  22846. action_label_add *[]uint64
  22847. appendaction_label_add []uint64
  22848. action_label_del *[]uint64
  22849. appendaction_label_del []uint64
  22850. clearedFields map[string]struct{}
  22851. done bool
  22852. oldValue func(context.Context) (*LabelTagging, error)
  22853. predicates []predicate.LabelTagging
  22854. }
  22855. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  22856. // labeltaggingOption allows management of the mutation configuration using functional options.
  22857. type labeltaggingOption func(*LabelTaggingMutation)
  22858. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  22859. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  22860. m := &LabelTaggingMutation{
  22861. config: c,
  22862. op: op,
  22863. typ: TypeLabelTagging,
  22864. clearedFields: make(map[string]struct{}),
  22865. }
  22866. for _, opt := range opts {
  22867. opt(m)
  22868. }
  22869. return m
  22870. }
  22871. // withLabelTaggingID sets the ID field of the mutation.
  22872. func withLabelTaggingID(id uint64) labeltaggingOption {
  22873. return func(m *LabelTaggingMutation) {
  22874. var (
  22875. err error
  22876. once sync.Once
  22877. value *LabelTagging
  22878. )
  22879. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  22880. once.Do(func() {
  22881. if m.done {
  22882. err = errors.New("querying old values post mutation is not allowed")
  22883. } else {
  22884. value, err = m.Client().LabelTagging.Get(ctx, id)
  22885. }
  22886. })
  22887. return value, err
  22888. }
  22889. m.id = &id
  22890. }
  22891. }
  22892. // withLabelTagging sets the old LabelTagging of the mutation.
  22893. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  22894. return func(m *LabelTaggingMutation) {
  22895. m.oldValue = func(context.Context) (*LabelTagging, error) {
  22896. return node, nil
  22897. }
  22898. m.id = &node.ID
  22899. }
  22900. }
  22901. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22902. // executed in a transaction (ent.Tx), a transactional client is returned.
  22903. func (m LabelTaggingMutation) Client() *Client {
  22904. client := &Client{config: m.config}
  22905. client.init()
  22906. return client
  22907. }
  22908. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22909. // it returns an error otherwise.
  22910. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  22911. if _, ok := m.driver.(*txDriver); !ok {
  22912. return nil, errors.New("ent: mutation is not running in a transaction")
  22913. }
  22914. tx := &Tx{config: m.config}
  22915. tx.init()
  22916. return tx, nil
  22917. }
  22918. // SetID sets the value of the id field. Note that this
  22919. // operation is only accepted on creation of LabelTagging entities.
  22920. func (m *LabelTaggingMutation) SetID(id uint64) {
  22921. m.id = &id
  22922. }
  22923. // ID returns the ID value in the mutation. Note that the ID is only available
  22924. // if it was provided to the builder or after it was returned from the database.
  22925. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  22926. if m.id == nil {
  22927. return
  22928. }
  22929. return *m.id, true
  22930. }
  22931. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22932. // That means, if the mutation is applied within a transaction with an isolation level such
  22933. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22934. // or updated by the mutation.
  22935. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  22936. switch {
  22937. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22938. id, exists := m.ID()
  22939. if exists {
  22940. return []uint64{id}, nil
  22941. }
  22942. fallthrough
  22943. case m.op.Is(OpUpdate | OpDelete):
  22944. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  22945. default:
  22946. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22947. }
  22948. }
  22949. // SetCreatedAt sets the "created_at" field.
  22950. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  22951. m.created_at = &t
  22952. }
  22953. // CreatedAt returns the value of the "created_at" field in the mutation.
  22954. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  22955. v := m.created_at
  22956. if v == nil {
  22957. return
  22958. }
  22959. return *v, true
  22960. }
  22961. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  22962. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22964. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22965. if !m.op.Is(OpUpdateOne) {
  22966. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22967. }
  22968. if m.id == nil || m.oldValue == nil {
  22969. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22970. }
  22971. oldValue, err := m.oldValue(ctx)
  22972. if err != nil {
  22973. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22974. }
  22975. return oldValue.CreatedAt, nil
  22976. }
  22977. // ResetCreatedAt resets all changes to the "created_at" field.
  22978. func (m *LabelTaggingMutation) ResetCreatedAt() {
  22979. m.created_at = nil
  22980. }
  22981. // SetUpdatedAt sets the "updated_at" field.
  22982. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  22983. m.updated_at = &t
  22984. }
  22985. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22986. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  22987. v := m.updated_at
  22988. if v == nil {
  22989. return
  22990. }
  22991. return *v, true
  22992. }
  22993. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  22994. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  22995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22996. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22997. if !m.op.Is(OpUpdateOne) {
  22998. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22999. }
  23000. if m.id == nil || m.oldValue == nil {
  23001. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23002. }
  23003. oldValue, err := m.oldValue(ctx)
  23004. if err != nil {
  23005. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23006. }
  23007. return oldValue.UpdatedAt, nil
  23008. }
  23009. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23010. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  23011. m.updated_at = nil
  23012. }
  23013. // SetStatus sets the "status" field.
  23014. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  23015. m.status = &u
  23016. m.addstatus = nil
  23017. }
  23018. // Status returns the value of the "status" field in the mutation.
  23019. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  23020. v := m.status
  23021. if v == nil {
  23022. return
  23023. }
  23024. return *v, true
  23025. }
  23026. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  23027. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23029. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23030. if !m.op.Is(OpUpdateOne) {
  23031. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23032. }
  23033. if m.id == nil || m.oldValue == nil {
  23034. return v, errors.New("OldStatus requires an ID field in the mutation")
  23035. }
  23036. oldValue, err := m.oldValue(ctx)
  23037. if err != nil {
  23038. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23039. }
  23040. return oldValue.Status, nil
  23041. }
  23042. // AddStatus adds u to the "status" field.
  23043. func (m *LabelTaggingMutation) AddStatus(u int8) {
  23044. if m.addstatus != nil {
  23045. *m.addstatus += u
  23046. } else {
  23047. m.addstatus = &u
  23048. }
  23049. }
  23050. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23051. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  23052. v := m.addstatus
  23053. if v == nil {
  23054. return
  23055. }
  23056. return *v, true
  23057. }
  23058. // ClearStatus clears the value of the "status" field.
  23059. func (m *LabelTaggingMutation) ClearStatus() {
  23060. m.status = nil
  23061. m.addstatus = nil
  23062. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  23063. }
  23064. // StatusCleared returns if the "status" field was cleared in this mutation.
  23065. func (m *LabelTaggingMutation) StatusCleared() bool {
  23066. _, ok := m.clearedFields[labeltagging.FieldStatus]
  23067. return ok
  23068. }
  23069. // ResetStatus resets all changes to the "status" field.
  23070. func (m *LabelTaggingMutation) ResetStatus() {
  23071. m.status = nil
  23072. m.addstatus = nil
  23073. delete(m.clearedFields, labeltagging.FieldStatus)
  23074. }
  23075. // SetDeletedAt sets the "deleted_at" field.
  23076. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  23077. m.deleted_at = &t
  23078. }
  23079. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23080. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  23081. v := m.deleted_at
  23082. if v == nil {
  23083. return
  23084. }
  23085. return *v, true
  23086. }
  23087. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  23088. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23090. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23091. if !m.op.Is(OpUpdateOne) {
  23092. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23093. }
  23094. if m.id == nil || m.oldValue == nil {
  23095. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23096. }
  23097. oldValue, err := m.oldValue(ctx)
  23098. if err != nil {
  23099. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23100. }
  23101. return oldValue.DeletedAt, nil
  23102. }
  23103. // ClearDeletedAt clears the value of the "deleted_at" field.
  23104. func (m *LabelTaggingMutation) ClearDeletedAt() {
  23105. m.deleted_at = nil
  23106. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  23107. }
  23108. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23109. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  23110. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  23111. return ok
  23112. }
  23113. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23114. func (m *LabelTaggingMutation) ResetDeletedAt() {
  23115. m.deleted_at = nil
  23116. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  23117. }
  23118. // SetOrganizationID sets the "organization_id" field.
  23119. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  23120. m.organization_id = &u
  23121. m.addorganization_id = nil
  23122. }
  23123. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23124. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  23125. v := m.organization_id
  23126. if v == nil {
  23127. return
  23128. }
  23129. return *v, true
  23130. }
  23131. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  23132. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23134. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23135. if !m.op.Is(OpUpdateOne) {
  23136. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23137. }
  23138. if m.id == nil || m.oldValue == nil {
  23139. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23140. }
  23141. oldValue, err := m.oldValue(ctx)
  23142. if err != nil {
  23143. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23144. }
  23145. return oldValue.OrganizationID, nil
  23146. }
  23147. // AddOrganizationID adds u to the "organization_id" field.
  23148. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  23149. if m.addorganization_id != nil {
  23150. *m.addorganization_id += u
  23151. } else {
  23152. m.addorganization_id = &u
  23153. }
  23154. }
  23155. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23156. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  23157. v := m.addorganization_id
  23158. if v == nil {
  23159. return
  23160. }
  23161. return *v, true
  23162. }
  23163. // ResetOrganizationID resets all changes to the "organization_id" field.
  23164. func (m *LabelTaggingMutation) ResetOrganizationID() {
  23165. m.organization_id = nil
  23166. m.addorganization_id = nil
  23167. }
  23168. // SetType sets the "type" field.
  23169. func (m *LabelTaggingMutation) SetType(i int) {
  23170. m._type = &i
  23171. m.add_type = nil
  23172. }
  23173. // GetType returns the value of the "type" field in the mutation.
  23174. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  23175. v := m._type
  23176. if v == nil {
  23177. return
  23178. }
  23179. return *v, true
  23180. }
  23181. // OldType returns the old "type" field's value of the LabelTagging entity.
  23182. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23184. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  23185. if !m.op.Is(OpUpdateOne) {
  23186. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23187. }
  23188. if m.id == nil || m.oldValue == nil {
  23189. return v, errors.New("OldType requires an ID field in the mutation")
  23190. }
  23191. oldValue, err := m.oldValue(ctx)
  23192. if err != nil {
  23193. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23194. }
  23195. return oldValue.Type, nil
  23196. }
  23197. // AddType adds i to the "type" field.
  23198. func (m *LabelTaggingMutation) AddType(i int) {
  23199. if m.add_type != nil {
  23200. *m.add_type += i
  23201. } else {
  23202. m.add_type = &i
  23203. }
  23204. }
  23205. // AddedType returns the value that was added to the "type" field in this mutation.
  23206. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  23207. v := m.add_type
  23208. if v == nil {
  23209. return
  23210. }
  23211. return *v, true
  23212. }
  23213. // ResetType resets all changes to the "type" field.
  23214. func (m *LabelTaggingMutation) ResetType() {
  23215. m._type = nil
  23216. m.add_type = nil
  23217. }
  23218. // SetConditions sets the "conditions" field.
  23219. func (m *LabelTaggingMutation) SetConditions(s string) {
  23220. m.conditions = &s
  23221. }
  23222. // Conditions returns the value of the "conditions" field in the mutation.
  23223. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  23224. v := m.conditions
  23225. if v == nil {
  23226. return
  23227. }
  23228. return *v, true
  23229. }
  23230. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  23231. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23233. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  23234. if !m.op.Is(OpUpdateOne) {
  23235. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  23236. }
  23237. if m.id == nil || m.oldValue == nil {
  23238. return v, errors.New("OldConditions requires an ID field in the mutation")
  23239. }
  23240. oldValue, err := m.oldValue(ctx)
  23241. if err != nil {
  23242. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  23243. }
  23244. return oldValue.Conditions, nil
  23245. }
  23246. // ResetConditions resets all changes to the "conditions" field.
  23247. func (m *LabelTaggingMutation) ResetConditions() {
  23248. m.conditions = nil
  23249. }
  23250. // SetActionLabelAdd sets the "action_label_add" field.
  23251. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  23252. m.action_label_add = &u
  23253. m.appendaction_label_add = nil
  23254. }
  23255. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  23256. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  23257. v := m.action_label_add
  23258. if v == nil {
  23259. return
  23260. }
  23261. return *v, true
  23262. }
  23263. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  23264. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23266. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  23267. if !m.op.Is(OpUpdateOne) {
  23268. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  23269. }
  23270. if m.id == nil || m.oldValue == nil {
  23271. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  23272. }
  23273. oldValue, err := m.oldValue(ctx)
  23274. if err != nil {
  23275. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  23276. }
  23277. return oldValue.ActionLabelAdd, nil
  23278. }
  23279. // AppendActionLabelAdd adds u to the "action_label_add" field.
  23280. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  23281. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  23282. }
  23283. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  23284. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  23285. if len(m.appendaction_label_add) == 0 {
  23286. return nil, false
  23287. }
  23288. return m.appendaction_label_add, true
  23289. }
  23290. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  23291. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  23292. m.action_label_add = nil
  23293. m.appendaction_label_add = nil
  23294. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  23295. }
  23296. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  23297. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  23298. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  23299. return ok
  23300. }
  23301. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  23302. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  23303. m.action_label_add = nil
  23304. m.appendaction_label_add = nil
  23305. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  23306. }
  23307. // SetActionLabelDel sets the "action_label_del" field.
  23308. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  23309. m.action_label_del = &u
  23310. m.appendaction_label_del = nil
  23311. }
  23312. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  23313. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  23314. v := m.action_label_del
  23315. if v == nil {
  23316. return
  23317. }
  23318. return *v, true
  23319. }
  23320. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  23321. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  23322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23323. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  23324. if !m.op.Is(OpUpdateOne) {
  23325. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  23326. }
  23327. if m.id == nil || m.oldValue == nil {
  23328. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  23329. }
  23330. oldValue, err := m.oldValue(ctx)
  23331. if err != nil {
  23332. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  23333. }
  23334. return oldValue.ActionLabelDel, nil
  23335. }
  23336. // AppendActionLabelDel adds u to the "action_label_del" field.
  23337. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  23338. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  23339. }
  23340. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  23341. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  23342. if len(m.appendaction_label_del) == 0 {
  23343. return nil, false
  23344. }
  23345. return m.appendaction_label_del, true
  23346. }
  23347. // ClearActionLabelDel clears the value of the "action_label_del" field.
  23348. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  23349. m.action_label_del = nil
  23350. m.appendaction_label_del = nil
  23351. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  23352. }
  23353. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  23354. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  23355. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  23356. return ok
  23357. }
  23358. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  23359. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  23360. m.action_label_del = nil
  23361. m.appendaction_label_del = nil
  23362. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  23363. }
  23364. // Where appends a list predicates to the LabelTaggingMutation builder.
  23365. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  23366. m.predicates = append(m.predicates, ps...)
  23367. }
  23368. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  23369. // users can use type-assertion to append predicates that do not depend on any generated package.
  23370. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  23371. p := make([]predicate.LabelTagging, len(ps))
  23372. for i := range ps {
  23373. p[i] = ps[i]
  23374. }
  23375. m.Where(p...)
  23376. }
  23377. // Op returns the operation name.
  23378. func (m *LabelTaggingMutation) Op() Op {
  23379. return m.op
  23380. }
  23381. // SetOp allows setting the mutation operation.
  23382. func (m *LabelTaggingMutation) SetOp(op Op) {
  23383. m.op = op
  23384. }
  23385. // Type returns the node type of this mutation (LabelTagging).
  23386. func (m *LabelTaggingMutation) Type() string {
  23387. return m.typ
  23388. }
  23389. // Fields returns all fields that were changed during this mutation. Note that in
  23390. // order to get all numeric fields that were incremented/decremented, call
  23391. // AddedFields().
  23392. func (m *LabelTaggingMutation) Fields() []string {
  23393. fields := make([]string, 0, 9)
  23394. if m.created_at != nil {
  23395. fields = append(fields, labeltagging.FieldCreatedAt)
  23396. }
  23397. if m.updated_at != nil {
  23398. fields = append(fields, labeltagging.FieldUpdatedAt)
  23399. }
  23400. if m.status != nil {
  23401. fields = append(fields, labeltagging.FieldStatus)
  23402. }
  23403. if m.deleted_at != nil {
  23404. fields = append(fields, labeltagging.FieldDeletedAt)
  23405. }
  23406. if m.organization_id != nil {
  23407. fields = append(fields, labeltagging.FieldOrganizationID)
  23408. }
  23409. if m._type != nil {
  23410. fields = append(fields, labeltagging.FieldType)
  23411. }
  23412. if m.conditions != nil {
  23413. fields = append(fields, labeltagging.FieldConditions)
  23414. }
  23415. if m.action_label_add != nil {
  23416. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23417. }
  23418. if m.action_label_del != nil {
  23419. fields = append(fields, labeltagging.FieldActionLabelDel)
  23420. }
  23421. return fields
  23422. }
  23423. // Field returns the value of a field with the given name. The second boolean
  23424. // return value indicates that this field was not set, or was not defined in the
  23425. // schema.
  23426. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  23427. switch name {
  23428. case labeltagging.FieldCreatedAt:
  23429. return m.CreatedAt()
  23430. case labeltagging.FieldUpdatedAt:
  23431. return m.UpdatedAt()
  23432. case labeltagging.FieldStatus:
  23433. return m.Status()
  23434. case labeltagging.FieldDeletedAt:
  23435. return m.DeletedAt()
  23436. case labeltagging.FieldOrganizationID:
  23437. return m.OrganizationID()
  23438. case labeltagging.FieldType:
  23439. return m.GetType()
  23440. case labeltagging.FieldConditions:
  23441. return m.Conditions()
  23442. case labeltagging.FieldActionLabelAdd:
  23443. return m.ActionLabelAdd()
  23444. case labeltagging.FieldActionLabelDel:
  23445. return m.ActionLabelDel()
  23446. }
  23447. return nil, false
  23448. }
  23449. // OldField returns the old value of the field from the database. An error is
  23450. // returned if the mutation operation is not UpdateOne, or the query to the
  23451. // database failed.
  23452. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23453. switch name {
  23454. case labeltagging.FieldCreatedAt:
  23455. return m.OldCreatedAt(ctx)
  23456. case labeltagging.FieldUpdatedAt:
  23457. return m.OldUpdatedAt(ctx)
  23458. case labeltagging.FieldStatus:
  23459. return m.OldStatus(ctx)
  23460. case labeltagging.FieldDeletedAt:
  23461. return m.OldDeletedAt(ctx)
  23462. case labeltagging.FieldOrganizationID:
  23463. return m.OldOrganizationID(ctx)
  23464. case labeltagging.FieldType:
  23465. return m.OldType(ctx)
  23466. case labeltagging.FieldConditions:
  23467. return m.OldConditions(ctx)
  23468. case labeltagging.FieldActionLabelAdd:
  23469. return m.OldActionLabelAdd(ctx)
  23470. case labeltagging.FieldActionLabelDel:
  23471. return m.OldActionLabelDel(ctx)
  23472. }
  23473. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  23474. }
  23475. // SetField sets the value of a field with the given name. It returns an error if
  23476. // the field is not defined in the schema, or if the type mismatched the field
  23477. // type.
  23478. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  23479. switch name {
  23480. case labeltagging.FieldCreatedAt:
  23481. v, ok := value.(time.Time)
  23482. if !ok {
  23483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23484. }
  23485. m.SetCreatedAt(v)
  23486. return nil
  23487. case labeltagging.FieldUpdatedAt:
  23488. v, ok := value.(time.Time)
  23489. if !ok {
  23490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23491. }
  23492. m.SetUpdatedAt(v)
  23493. return nil
  23494. case labeltagging.FieldStatus:
  23495. v, ok := value.(uint8)
  23496. if !ok {
  23497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23498. }
  23499. m.SetStatus(v)
  23500. return nil
  23501. case labeltagging.FieldDeletedAt:
  23502. v, ok := value.(time.Time)
  23503. if !ok {
  23504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23505. }
  23506. m.SetDeletedAt(v)
  23507. return nil
  23508. case labeltagging.FieldOrganizationID:
  23509. v, ok := value.(uint64)
  23510. if !ok {
  23511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23512. }
  23513. m.SetOrganizationID(v)
  23514. return nil
  23515. case labeltagging.FieldType:
  23516. v, ok := value.(int)
  23517. if !ok {
  23518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23519. }
  23520. m.SetType(v)
  23521. return nil
  23522. case labeltagging.FieldConditions:
  23523. v, ok := value.(string)
  23524. if !ok {
  23525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23526. }
  23527. m.SetConditions(v)
  23528. return nil
  23529. case labeltagging.FieldActionLabelAdd:
  23530. v, ok := value.([]uint64)
  23531. if !ok {
  23532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23533. }
  23534. m.SetActionLabelAdd(v)
  23535. return nil
  23536. case labeltagging.FieldActionLabelDel:
  23537. v, ok := value.([]uint64)
  23538. if !ok {
  23539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23540. }
  23541. m.SetActionLabelDel(v)
  23542. return nil
  23543. }
  23544. return fmt.Errorf("unknown LabelTagging field %s", name)
  23545. }
  23546. // AddedFields returns all numeric fields that were incremented/decremented during
  23547. // this mutation.
  23548. func (m *LabelTaggingMutation) AddedFields() []string {
  23549. var fields []string
  23550. if m.addstatus != nil {
  23551. fields = append(fields, labeltagging.FieldStatus)
  23552. }
  23553. if m.addorganization_id != nil {
  23554. fields = append(fields, labeltagging.FieldOrganizationID)
  23555. }
  23556. if m.add_type != nil {
  23557. fields = append(fields, labeltagging.FieldType)
  23558. }
  23559. return fields
  23560. }
  23561. // AddedField returns the numeric value that was incremented/decremented on a field
  23562. // with the given name. The second boolean return value indicates that this field
  23563. // was not set, or was not defined in the schema.
  23564. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  23565. switch name {
  23566. case labeltagging.FieldStatus:
  23567. return m.AddedStatus()
  23568. case labeltagging.FieldOrganizationID:
  23569. return m.AddedOrganizationID()
  23570. case labeltagging.FieldType:
  23571. return m.AddedType()
  23572. }
  23573. return nil, false
  23574. }
  23575. // AddField adds the value to the field with the given name. It returns an error if
  23576. // the field is not defined in the schema, or if the type mismatched the field
  23577. // type.
  23578. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  23579. switch name {
  23580. case labeltagging.FieldStatus:
  23581. v, ok := value.(int8)
  23582. if !ok {
  23583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23584. }
  23585. m.AddStatus(v)
  23586. return nil
  23587. case labeltagging.FieldOrganizationID:
  23588. v, ok := value.(int64)
  23589. if !ok {
  23590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23591. }
  23592. m.AddOrganizationID(v)
  23593. return nil
  23594. case labeltagging.FieldType:
  23595. v, ok := value.(int)
  23596. if !ok {
  23597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23598. }
  23599. m.AddType(v)
  23600. return nil
  23601. }
  23602. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  23603. }
  23604. // ClearedFields returns all nullable fields that were cleared during this
  23605. // mutation.
  23606. func (m *LabelTaggingMutation) ClearedFields() []string {
  23607. var fields []string
  23608. if m.FieldCleared(labeltagging.FieldStatus) {
  23609. fields = append(fields, labeltagging.FieldStatus)
  23610. }
  23611. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  23612. fields = append(fields, labeltagging.FieldDeletedAt)
  23613. }
  23614. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  23615. fields = append(fields, labeltagging.FieldActionLabelAdd)
  23616. }
  23617. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  23618. fields = append(fields, labeltagging.FieldActionLabelDel)
  23619. }
  23620. return fields
  23621. }
  23622. // FieldCleared returns a boolean indicating if a field with the given name was
  23623. // cleared in this mutation.
  23624. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  23625. _, ok := m.clearedFields[name]
  23626. return ok
  23627. }
  23628. // ClearField clears the value of the field with the given name. It returns an
  23629. // error if the field is not defined in the schema.
  23630. func (m *LabelTaggingMutation) ClearField(name string) error {
  23631. switch name {
  23632. case labeltagging.FieldStatus:
  23633. m.ClearStatus()
  23634. return nil
  23635. case labeltagging.FieldDeletedAt:
  23636. m.ClearDeletedAt()
  23637. return nil
  23638. case labeltagging.FieldActionLabelAdd:
  23639. m.ClearActionLabelAdd()
  23640. return nil
  23641. case labeltagging.FieldActionLabelDel:
  23642. m.ClearActionLabelDel()
  23643. return nil
  23644. }
  23645. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  23646. }
  23647. // ResetField resets all changes in the mutation for the field with the given name.
  23648. // It returns an error if the field is not defined in the schema.
  23649. func (m *LabelTaggingMutation) ResetField(name string) error {
  23650. switch name {
  23651. case labeltagging.FieldCreatedAt:
  23652. m.ResetCreatedAt()
  23653. return nil
  23654. case labeltagging.FieldUpdatedAt:
  23655. m.ResetUpdatedAt()
  23656. return nil
  23657. case labeltagging.FieldStatus:
  23658. m.ResetStatus()
  23659. return nil
  23660. case labeltagging.FieldDeletedAt:
  23661. m.ResetDeletedAt()
  23662. return nil
  23663. case labeltagging.FieldOrganizationID:
  23664. m.ResetOrganizationID()
  23665. return nil
  23666. case labeltagging.FieldType:
  23667. m.ResetType()
  23668. return nil
  23669. case labeltagging.FieldConditions:
  23670. m.ResetConditions()
  23671. return nil
  23672. case labeltagging.FieldActionLabelAdd:
  23673. m.ResetActionLabelAdd()
  23674. return nil
  23675. case labeltagging.FieldActionLabelDel:
  23676. m.ResetActionLabelDel()
  23677. return nil
  23678. }
  23679. return fmt.Errorf("unknown LabelTagging field %s", name)
  23680. }
  23681. // AddedEdges returns all edge names that were set/added in this mutation.
  23682. func (m *LabelTaggingMutation) AddedEdges() []string {
  23683. edges := make([]string, 0, 0)
  23684. return edges
  23685. }
  23686. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23687. // name in this mutation.
  23688. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  23689. return nil
  23690. }
  23691. // RemovedEdges returns all edge names that were removed in this mutation.
  23692. func (m *LabelTaggingMutation) RemovedEdges() []string {
  23693. edges := make([]string, 0, 0)
  23694. return edges
  23695. }
  23696. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23697. // the given name in this mutation.
  23698. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  23699. return nil
  23700. }
  23701. // ClearedEdges returns all edge names that were cleared in this mutation.
  23702. func (m *LabelTaggingMutation) ClearedEdges() []string {
  23703. edges := make([]string, 0, 0)
  23704. return edges
  23705. }
  23706. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23707. // was cleared in this mutation.
  23708. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  23709. return false
  23710. }
  23711. // ClearEdge clears the value of the edge with the given name. It returns an error
  23712. // if that edge is not defined in the schema.
  23713. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  23714. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  23715. }
  23716. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23717. // It returns an error if the edge is not defined in the schema.
  23718. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  23719. return fmt.Errorf("unknown LabelTagging edge %s", name)
  23720. }
  23721. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  23722. type MessageMutation struct {
  23723. config
  23724. op Op
  23725. typ string
  23726. id *int
  23727. wx_wxid *string
  23728. wxid *string
  23729. content *string
  23730. clearedFields map[string]struct{}
  23731. done bool
  23732. oldValue func(context.Context) (*Message, error)
  23733. predicates []predicate.Message
  23734. }
  23735. var _ ent.Mutation = (*MessageMutation)(nil)
  23736. // messageOption allows management of the mutation configuration using functional options.
  23737. type messageOption func(*MessageMutation)
  23738. // newMessageMutation creates new mutation for the Message entity.
  23739. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  23740. m := &MessageMutation{
  23741. config: c,
  23742. op: op,
  23743. typ: TypeMessage,
  23744. clearedFields: make(map[string]struct{}),
  23745. }
  23746. for _, opt := range opts {
  23747. opt(m)
  23748. }
  23749. return m
  23750. }
  23751. // withMessageID sets the ID field of the mutation.
  23752. func withMessageID(id int) messageOption {
  23753. return func(m *MessageMutation) {
  23754. var (
  23755. err error
  23756. once sync.Once
  23757. value *Message
  23758. )
  23759. m.oldValue = func(ctx context.Context) (*Message, error) {
  23760. once.Do(func() {
  23761. if m.done {
  23762. err = errors.New("querying old values post mutation is not allowed")
  23763. } else {
  23764. value, err = m.Client().Message.Get(ctx, id)
  23765. }
  23766. })
  23767. return value, err
  23768. }
  23769. m.id = &id
  23770. }
  23771. }
  23772. // withMessage sets the old Message of the mutation.
  23773. func withMessage(node *Message) messageOption {
  23774. return func(m *MessageMutation) {
  23775. m.oldValue = func(context.Context) (*Message, error) {
  23776. return node, nil
  23777. }
  23778. m.id = &node.ID
  23779. }
  23780. }
  23781. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23782. // executed in a transaction (ent.Tx), a transactional client is returned.
  23783. func (m MessageMutation) Client() *Client {
  23784. client := &Client{config: m.config}
  23785. client.init()
  23786. return client
  23787. }
  23788. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23789. // it returns an error otherwise.
  23790. func (m MessageMutation) Tx() (*Tx, error) {
  23791. if _, ok := m.driver.(*txDriver); !ok {
  23792. return nil, errors.New("ent: mutation is not running in a transaction")
  23793. }
  23794. tx := &Tx{config: m.config}
  23795. tx.init()
  23796. return tx, nil
  23797. }
  23798. // ID returns the ID value in the mutation. Note that the ID is only available
  23799. // if it was provided to the builder or after it was returned from the database.
  23800. func (m *MessageMutation) ID() (id int, exists bool) {
  23801. if m.id == nil {
  23802. return
  23803. }
  23804. return *m.id, true
  23805. }
  23806. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23807. // That means, if the mutation is applied within a transaction with an isolation level such
  23808. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23809. // or updated by the mutation.
  23810. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  23811. switch {
  23812. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23813. id, exists := m.ID()
  23814. if exists {
  23815. return []int{id}, nil
  23816. }
  23817. fallthrough
  23818. case m.op.Is(OpUpdate | OpDelete):
  23819. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  23820. default:
  23821. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23822. }
  23823. }
  23824. // SetWxWxid sets the "wx_wxid" field.
  23825. func (m *MessageMutation) SetWxWxid(s string) {
  23826. m.wx_wxid = &s
  23827. }
  23828. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  23829. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  23830. v := m.wx_wxid
  23831. if v == nil {
  23832. return
  23833. }
  23834. return *v, true
  23835. }
  23836. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  23837. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23839. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  23840. if !m.op.Is(OpUpdateOne) {
  23841. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  23842. }
  23843. if m.id == nil || m.oldValue == nil {
  23844. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  23845. }
  23846. oldValue, err := m.oldValue(ctx)
  23847. if err != nil {
  23848. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  23849. }
  23850. return oldValue.WxWxid, nil
  23851. }
  23852. // ClearWxWxid clears the value of the "wx_wxid" field.
  23853. func (m *MessageMutation) ClearWxWxid() {
  23854. m.wx_wxid = nil
  23855. m.clearedFields[message.FieldWxWxid] = struct{}{}
  23856. }
  23857. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  23858. func (m *MessageMutation) WxWxidCleared() bool {
  23859. _, ok := m.clearedFields[message.FieldWxWxid]
  23860. return ok
  23861. }
  23862. // ResetWxWxid resets all changes to the "wx_wxid" field.
  23863. func (m *MessageMutation) ResetWxWxid() {
  23864. m.wx_wxid = nil
  23865. delete(m.clearedFields, message.FieldWxWxid)
  23866. }
  23867. // SetWxid sets the "wxid" field.
  23868. func (m *MessageMutation) SetWxid(s string) {
  23869. m.wxid = &s
  23870. }
  23871. // Wxid returns the value of the "wxid" field in the mutation.
  23872. func (m *MessageMutation) Wxid() (r string, exists bool) {
  23873. v := m.wxid
  23874. if v == nil {
  23875. return
  23876. }
  23877. return *v, true
  23878. }
  23879. // OldWxid returns the old "wxid" field's value of the Message entity.
  23880. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23882. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  23883. if !m.op.Is(OpUpdateOne) {
  23884. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  23885. }
  23886. if m.id == nil || m.oldValue == nil {
  23887. return v, errors.New("OldWxid requires an ID field in the mutation")
  23888. }
  23889. oldValue, err := m.oldValue(ctx)
  23890. if err != nil {
  23891. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  23892. }
  23893. return oldValue.Wxid, nil
  23894. }
  23895. // ResetWxid resets all changes to the "wxid" field.
  23896. func (m *MessageMutation) ResetWxid() {
  23897. m.wxid = nil
  23898. }
  23899. // SetContent sets the "content" field.
  23900. func (m *MessageMutation) SetContent(s string) {
  23901. m.content = &s
  23902. }
  23903. // Content returns the value of the "content" field in the mutation.
  23904. func (m *MessageMutation) Content() (r string, exists bool) {
  23905. v := m.content
  23906. if v == nil {
  23907. return
  23908. }
  23909. return *v, true
  23910. }
  23911. // OldContent returns the old "content" field's value of the Message entity.
  23912. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  23913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23914. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  23915. if !m.op.Is(OpUpdateOne) {
  23916. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  23917. }
  23918. if m.id == nil || m.oldValue == nil {
  23919. return v, errors.New("OldContent requires an ID field in the mutation")
  23920. }
  23921. oldValue, err := m.oldValue(ctx)
  23922. if err != nil {
  23923. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  23924. }
  23925. return oldValue.Content, nil
  23926. }
  23927. // ResetContent resets all changes to the "content" field.
  23928. func (m *MessageMutation) ResetContent() {
  23929. m.content = nil
  23930. }
  23931. // Where appends a list predicates to the MessageMutation builder.
  23932. func (m *MessageMutation) Where(ps ...predicate.Message) {
  23933. m.predicates = append(m.predicates, ps...)
  23934. }
  23935. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  23936. // users can use type-assertion to append predicates that do not depend on any generated package.
  23937. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  23938. p := make([]predicate.Message, len(ps))
  23939. for i := range ps {
  23940. p[i] = ps[i]
  23941. }
  23942. m.Where(p...)
  23943. }
  23944. // Op returns the operation name.
  23945. func (m *MessageMutation) Op() Op {
  23946. return m.op
  23947. }
  23948. // SetOp allows setting the mutation operation.
  23949. func (m *MessageMutation) SetOp(op Op) {
  23950. m.op = op
  23951. }
  23952. // Type returns the node type of this mutation (Message).
  23953. func (m *MessageMutation) Type() string {
  23954. return m.typ
  23955. }
  23956. // Fields returns all fields that were changed during this mutation. Note that in
  23957. // order to get all numeric fields that were incremented/decremented, call
  23958. // AddedFields().
  23959. func (m *MessageMutation) Fields() []string {
  23960. fields := make([]string, 0, 3)
  23961. if m.wx_wxid != nil {
  23962. fields = append(fields, message.FieldWxWxid)
  23963. }
  23964. if m.wxid != nil {
  23965. fields = append(fields, message.FieldWxid)
  23966. }
  23967. if m.content != nil {
  23968. fields = append(fields, message.FieldContent)
  23969. }
  23970. return fields
  23971. }
  23972. // Field returns the value of a field with the given name. The second boolean
  23973. // return value indicates that this field was not set, or was not defined in the
  23974. // schema.
  23975. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  23976. switch name {
  23977. case message.FieldWxWxid:
  23978. return m.WxWxid()
  23979. case message.FieldWxid:
  23980. return m.Wxid()
  23981. case message.FieldContent:
  23982. return m.Content()
  23983. }
  23984. return nil, false
  23985. }
  23986. // OldField returns the old value of the field from the database. An error is
  23987. // returned if the mutation operation is not UpdateOne, or the query to the
  23988. // database failed.
  23989. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23990. switch name {
  23991. case message.FieldWxWxid:
  23992. return m.OldWxWxid(ctx)
  23993. case message.FieldWxid:
  23994. return m.OldWxid(ctx)
  23995. case message.FieldContent:
  23996. return m.OldContent(ctx)
  23997. }
  23998. return nil, fmt.Errorf("unknown Message field %s", name)
  23999. }
  24000. // SetField sets the value of a field with the given name. It returns an error if
  24001. // the field is not defined in the schema, or if the type mismatched the field
  24002. // type.
  24003. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  24004. switch name {
  24005. case message.FieldWxWxid:
  24006. v, ok := value.(string)
  24007. if !ok {
  24008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24009. }
  24010. m.SetWxWxid(v)
  24011. return nil
  24012. case message.FieldWxid:
  24013. v, ok := value.(string)
  24014. if !ok {
  24015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24016. }
  24017. m.SetWxid(v)
  24018. return nil
  24019. case message.FieldContent:
  24020. v, ok := value.(string)
  24021. if !ok {
  24022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24023. }
  24024. m.SetContent(v)
  24025. return nil
  24026. }
  24027. return fmt.Errorf("unknown Message field %s", name)
  24028. }
  24029. // AddedFields returns all numeric fields that were incremented/decremented during
  24030. // this mutation.
  24031. func (m *MessageMutation) AddedFields() []string {
  24032. return nil
  24033. }
  24034. // AddedField returns the numeric value that was incremented/decremented on a field
  24035. // with the given name. The second boolean return value indicates that this field
  24036. // was not set, or was not defined in the schema.
  24037. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  24038. return nil, false
  24039. }
  24040. // AddField adds the value to the field with the given name. It returns an error if
  24041. // the field is not defined in the schema, or if the type mismatched the field
  24042. // type.
  24043. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  24044. switch name {
  24045. }
  24046. return fmt.Errorf("unknown Message numeric field %s", name)
  24047. }
  24048. // ClearedFields returns all nullable fields that were cleared during this
  24049. // mutation.
  24050. func (m *MessageMutation) ClearedFields() []string {
  24051. var fields []string
  24052. if m.FieldCleared(message.FieldWxWxid) {
  24053. fields = append(fields, message.FieldWxWxid)
  24054. }
  24055. return fields
  24056. }
  24057. // FieldCleared returns a boolean indicating if a field with the given name was
  24058. // cleared in this mutation.
  24059. func (m *MessageMutation) FieldCleared(name string) bool {
  24060. _, ok := m.clearedFields[name]
  24061. return ok
  24062. }
  24063. // ClearField clears the value of the field with the given name. It returns an
  24064. // error if the field is not defined in the schema.
  24065. func (m *MessageMutation) ClearField(name string) error {
  24066. switch name {
  24067. case message.FieldWxWxid:
  24068. m.ClearWxWxid()
  24069. return nil
  24070. }
  24071. return fmt.Errorf("unknown Message nullable field %s", name)
  24072. }
  24073. // ResetField resets all changes in the mutation for the field with the given name.
  24074. // It returns an error if the field is not defined in the schema.
  24075. func (m *MessageMutation) ResetField(name string) error {
  24076. switch name {
  24077. case message.FieldWxWxid:
  24078. m.ResetWxWxid()
  24079. return nil
  24080. case message.FieldWxid:
  24081. m.ResetWxid()
  24082. return nil
  24083. case message.FieldContent:
  24084. m.ResetContent()
  24085. return nil
  24086. }
  24087. return fmt.Errorf("unknown Message field %s", name)
  24088. }
  24089. // AddedEdges returns all edge names that were set/added in this mutation.
  24090. func (m *MessageMutation) AddedEdges() []string {
  24091. edges := make([]string, 0, 0)
  24092. return edges
  24093. }
  24094. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24095. // name in this mutation.
  24096. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  24097. return nil
  24098. }
  24099. // RemovedEdges returns all edge names that were removed in this mutation.
  24100. func (m *MessageMutation) RemovedEdges() []string {
  24101. edges := make([]string, 0, 0)
  24102. return edges
  24103. }
  24104. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24105. // the given name in this mutation.
  24106. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  24107. return nil
  24108. }
  24109. // ClearedEdges returns all edge names that were cleared in this mutation.
  24110. func (m *MessageMutation) ClearedEdges() []string {
  24111. edges := make([]string, 0, 0)
  24112. return edges
  24113. }
  24114. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24115. // was cleared in this mutation.
  24116. func (m *MessageMutation) EdgeCleared(name string) bool {
  24117. return false
  24118. }
  24119. // ClearEdge clears the value of the edge with the given name. It returns an error
  24120. // if that edge is not defined in the schema.
  24121. func (m *MessageMutation) ClearEdge(name string) error {
  24122. return fmt.Errorf("unknown Message unique edge %s", name)
  24123. }
  24124. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24125. // It returns an error if the edge is not defined in the schema.
  24126. func (m *MessageMutation) ResetEdge(name string) error {
  24127. return fmt.Errorf("unknown Message edge %s", name)
  24128. }
  24129. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  24130. type MessageRecordsMutation struct {
  24131. config
  24132. op Op
  24133. typ string
  24134. id *uint64
  24135. created_at *time.Time
  24136. updated_at *time.Time
  24137. status *uint8
  24138. addstatus *int8
  24139. bot_wxid *string
  24140. contact_type *int
  24141. addcontact_type *int
  24142. contact_wxid *string
  24143. content_type *int
  24144. addcontent_type *int
  24145. content *string
  24146. meta *custom_types.Meta
  24147. error_detail *string
  24148. send_time *time.Time
  24149. source_type *int
  24150. addsource_type *int
  24151. organization_id *uint64
  24152. addorganization_id *int64
  24153. clearedFields map[string]struct{}
  24154. sop_stage *uint64
  24155. clearedsop_stage bool
  24156. sop_node *uint64
  24157. clearedsop_node bool
  24158. message_contact *uint64
  24159. clearedmessage_contact bool
  24160. done bool
  24161. oldValue func(context.Context) (*MessageRecords, error)
  24162. predicates []predicate.MessageRecords
  24163. }
  24164. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  24165. // messagerecordsOption allows management of the mutation configuration using functional options.
  24166. type messagerecordsOption func(*MessageRecordsMutation)
  24167. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  24168. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  24169. m := &MessageRecordsMutation{
  24170. config: c,
  24171. op: op,
  24172. typ: TypeMessageRecords,
  24173. clearedFields: make(map[string]struct{}),
  24174. }
  24175. for _, opt := range opts {
  24176. opt(m)
  24177. }
  24178. return m
  24179. }
  24180. // withMessageRecordsID sets the ID field of the mutation.
  24181. func withMessageRecordsID(id uint64) messagerecordsOption {
  24182. return func(m *MessageRecordsMutation) {
  24183. var (
  24184. err error
  24185. once sync.Once
  24186. value *MessageRecords
  24187. )
  24188. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  24189. once.Do(func() {
  24190. if m.done {
  24191. err = errors.New("querying old values post mutation is not allowed")
  24192. } else {
  24193. value, err = m.Client().MessageRecords.Get(ctx, id)
  24194. }
  24195. })
  24196. return value, err
  24197. }
  24198. m.id = &id
  24199. }
  24200. }
  24201. // withMessageRecords sets the old MessageRecords of the mutation.
  24202. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  24203. return func(m *MessageRecordsMutation) {
  24204. m.oldValue = func(context.Context) (*MessageRecords, error) {
  24205. return node, nil
  24206. }
  24207. m.id = &node.ID
  24208. }
  24209. }
  24210. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24211. // executed in a transaction (ent.Tx), a transactional client is returned.
  24212. func (m MessageRecordsMutation) Client() *Client {
  24213. client := &Client{config: m.config}
  24214. client.init()
  24215. return client
  24216. }
  24217. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24218. // it returns an error otherwise.
  24219. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  24220. if _, ok := m.driver.(*txDriver); !ok {
  24221. return nil, errors.New("ent: mutation is not running in a transaction")
  24222. }
  24223. tx := &Tx{config: m.config}
  24224. tx.init()
  24225. return tx, nil
  24226. }
  24227. // SetID sets the value of the id field. Note that this
  24228. // operation is only accepted on creation of MessageRecords entities.
  24229. func (m *MessageRecordsMutation) SetID(id uint64) {
  24230. m.id = &id
  24231. }
  24232. // ID returns the ID value in the mutation. Note that the ID is only available
  24233. // if it was provided to the builder or after it was returned from the database.
  24234. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  24235. if m.id == nil {
  24236. return
  24237. }
  24238. return *m.id, true
  24239. }
  24240. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24241. // That means, if the mutation is applied within a transaction with an isolation level such
  24242. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24243. // or updated by the mutation.
  24244. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  24245. switch {
  24246. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24247. id, exists := m.ID()
  24248. if exists {
  24249. return []uint64{id}, nil
  24250. }
  24251. fallthrough
  24252. case m.op.Is(OpUpdate | OpDelete):
  24253. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  24254. default:
  24255. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24256. }
  24257. }
  24258. // SetCreatedAt sets the "created_at" field.
  24259. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  24260. m.created_at = &t
  24261. }
  24262. // CreatedAt returns the value of the "created_at" field in the mutation.
  24263. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  24264. v := m.created_at
  24265. if v == nil {
  24266. return
  24267. }
  24268. return *v, true
  24269. }
  24270. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  24271. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24273. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24274. if !m.op.Is(OpUpdateOne) {
  24275. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24276. }
  24277. if m.id == nil || m.oldValue == nil {
  24278. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24279. }
  24280. oldValue, err := m.oldValue(ctx)
  24281. if err != nil {
  24282. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24283. }
  24284. return oldValue.CreatedAt, nil
  24285. }
  24286. // ResetCreatedAt resets all changes to the "created_at" field.
  24287. func (m *MessageRecordsMutation) ResetCreatedAt() {
  24288. m.created_at = nil
  24289. }
  24290. // SetUpdatedAt sets the "updated_at" field.
  24291. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  24292. m.updated_at = &t
  24293. }
  24294. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24295. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  24296. v := m.updated_at
  24297. if v == nil {
  24298. return
  24299. }
  24300. return *v, true
  24301. }
  24302. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  24303. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24305. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24306. if !m.op.Is(OpUpdateOne) {
  24307. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24308. }
  24309. if m.id == nil || m.oldValue == nil {
  24310. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24311. }
  24312. oldValue, err := m.oldValue(ctx)
  24313. if err != nil {
  24314. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24315. }
  24316. return oldValue.UpdatedAt, nil
  24317. }
  24318. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24319. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  24320. m.updated_at = nil
  24321. }
  24322. // SetStatus sets the "status" field.
  24323. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  24324. m.status = &u
  24325. m.addstatus = nil
  24326. }
  24327. // Status returns the value of the "status" field in the mutation.
  24328. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  24329. v := m.status
  24330. if v == nil {
  24331. return
  24332. }
  24333. return *v, true
  24334. }
  24335. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  24336. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24338. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24339. if !m.op.Is(OpUpdateOne) {
  24340. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24341. }
  24342. if m.id == nil || m.oldValue == nil {
  24343. return v, errors.New("OldStatus requires an ID field in the mutation")
  24344. }
  24345. oldValue, err := m.oldValue(ctx)
  24346. if err != nil {
  24347. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24348. }
  24349. return oldValue.Status, nil
  24350. }
  24351. // AddStatus adds u to the "status" field.
  24352. func (m *MessageRecordsMutation) AddStatus(u int8) {
  24353. if m.addstatus != nil {
  24354. *m.addstatus += u
  24355. } else {
  24356. m.addstatus = &u
  24357. }
  24358. }
  24359. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24360. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  24361. v := m.addstatus
  24362. if v == nil {
  24363. return
  24364. }
  24365. return *v, true
  24366. }
  24367. // ClearStatus clears the value of the "status" field.
  24368. func (m *MessageRecordsMutation) ClearStatus() {
  24369. m.status = nil
  24370. m.addstatus = nil
  24371. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  24372. }
  24373. // StatusCleared returns if the "status" field was cleared in this mutation.
  24374. func (m *MessageRecordsMutation) StatusCleared() bool {
  24375. _, ok := m.clearedFields[messagerecords.FieldStatus]
  24376. return ok
  24377. }
  24378. // ResetStatus resets all changes to the "status" field.
  24379. func (m *MessageRecordsMutation) ResetStatus() {
  24380. m.status = nil
  24381. m.addstatus = nil
  24382. delete(m.clearedFields, messagerecords.FieldStatus)
  24383. }
  24384. // SetBotWxid sets the "bot_wxid" field.
  24385. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  24386. m.bot_wxid = &s
  24387. }
  24388. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  24389. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  24390. v := m.bot_wxid
  24391. if v == nil {
  24392. return
  24393. }
  24394. return *v, true
  24395. }
  24396. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  24397. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24399. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  24400. if !m.op.Is(OpUpdateOne) {
  24401. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  24402. }
  24403. if m.id == nil || m.oldValue == nil {
  24404. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  24405. }
  24406. oldValue, err := m.oldValue(ctx)
  24407. if err != nil {
  24408. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  24409. }
  24410. return oldValue.BotWxid, nil
  24411. }
  24412. // ResetBotWxid resets all changes to the "bot_wxid" field.
  24413. func (m *MessageRecordsMutation) ResetBotWxid() {
  24414. m.bot_wxid = nil
  24415. }
  24416. // SetContactID sets the "contact_id" field.
  24417. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  24418. m.message_contact = &u
  24419. }
  24420. // ContactID returns the value of the "contact_id" field in the mutation.
  24421. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  24422. v := m.message_contact
  24423. if v == nil {
  24424. return
  24425. }
  24426. return *v, true
  24427. }
  24428. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  24429. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24431. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  24432. if !m.op.Is(OpUpdateOne) {
  24433. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  24434. }
  24435. if m.id == nil || m.oldValue == nil {
  24436. return v, errors.New("OldContactID requires an ID field in the mutation")
  24437. }
  24438. oldValue, err := m.oldValue(ctx)
  24439. if err != nil {
  24440. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  24441. }
  24442. return oldValue.ContactID, nil
  24443. }
  24444. // ClearContactID clears the value of the "contact_id" field.
  24445. func (m *MessageRecordsMutation) ClearContactID() {
  24446. m.message_contact = nil
  24447. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  24448. }
  24449. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  24450. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  24451. _, ok := m.clearedFields[messagerecords.FieldContactID]
  24452. return ok
  24453. }
  24454. // ResetContactID resets all changes to the "contact_id" field.
  24455. func (m *MessageRecordsMutation) ResetContactID() {
  24456. m.message_contact = nil
  24457. delete(m.clearedFields, messagerecords.FieldContactID)
  24458. }
  24459. // SetContactType sets the "contact_type" field.
  24460. func (m *MessageRecordsMutation) SetContactType(i int) {
  24461. m.contact_type = &i
  24462. m.addcontact_type = nil
  24463. }
  24464. // ContactType returns the value of the "contact_type" field in the mutation.
  24465. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  24466. v := m.contact_type
  24467. if v == nil {
  24468. return
  24469. }
  24470. return *v, true
  24471. }
  24472. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  24473. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24475. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  24476. if !m.op.Is(OpUpdateOne) {
  24477. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  24478. }
  24479. if m.id == nil || m.oldValue == nil {
  24480. return v, errors.New("OldContactType requires an ID field in the mutation")
  24481. }
  24482. oldValue, err := m.oldValue(ctx)
  24483. if err != nil {
  24484. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  24485. }
  24486. return oldValue.ContactType, nil
  24487. }
  24488. // AddContactType adds i to the "contact_type" field.
  24489. func (m *MessageRecordsMutation) AddContactType(i int) {
  24490. if m.addcontact_type != nil {
  24491. *m.addcontact_type += i
  24492. } else {
  24493. m.addcontact_type = &i
  24494. }
  24495. }
  24496. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  24497. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  24498. v := m.addcontact_type
  24499. if v == nil {
  24500. return
  24501. }
  24502. return *v, true
  24503. }
  24504. // ResetContactType resets all changes to the "contact_type" field.
  24505. func (m *MessageRecordsMutation) ResetContactType() {
  24506. m.contact_type = nil
  24507. m.addcontact_type = nil
  24508. }
  24509. // SetContactWxid sets the "contact_wxid" field.
  24510. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  24511. m.contact_wxid = &s
  24512. }
  24513. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  24514. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  24515. v := m.contact_wxid
  24516. if v == nil {
  24517. return
  24518. }
  24519. return *v, true
  24520. }
  24521. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  24522. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24524. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  24525. if !m.op.Is(OpUpdateOne) {
  24526. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  24527. }
  24528. if m.id == nil || m.oldValue == nil {
  24529. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  24530. }
  24531. oldValue, err := m.oldValue(ctx)
  24532. if err != nil {
  24533. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  24534. }
  24535. return oldValue.ContactWxid, nil
  24536. }
  24537. // ResetContactWxid resets all changes to the "contact_wxid" field.
  24538. func (m *MessageRecordsMutation) ResetContactWxid() {
  24539. m.contact_wxid = nil
  24540. }
  24541. // SetContentType sets the "content_type" field.
  24542. func (m *MessageRecordsMutation) SetContentType(i int) {
  24543. m.content_type = &i
  24544. m.addcontent_type = nil
  24545. }
  24546. // ContentType returns the value of the "content_type" field in the mutation.
  24547. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  24548. v := m.content_type
  24549. if v == nil {
  24550. return
  24551. }
  24552. return *v, true
  24553. }
  24554. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  24555. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24557. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  24558. if !m.op.Is(OpUpdateOne) {
  24559. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  24560. }
  24561. if m.id == nil || m.oldValue == nil {
  24562. return v, errors.New("OldContentType requires an ID field in the mutation")
  24563. }
  24564. oldValue, err := m.oldValue(ctx)
  24565. if err != nil {
  24566. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  24567. }
  24568. return oldValue.ContentType, nil
  24569. }
  24570. // AddContentType adds i to the "content_type" field.
  24571. func (m *MessageRecordsMutation) AddContentType(i int) {
  24572. if m.addcontent_type != nil {
  24573. *m.addcontent_type += i
  24574. } else {
  24575. m.addcontent_type = &i
  24576. }
  24577. }
  24578. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  24579. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  24580. v := m.addcontent_type
  24581. if v == nil {
  24582. return
  24583. }
  24584. return *v, true
  24585. }
  24586. // ResetContentType resets all changes to the "content_type" field.
  24587. func (m *MessageRecordsMutation) ResetContentType() {
  24588. m.content_type = nil
  24589. m.addcontent_type = nil
  24590. }
  24591. // SetContent sets the "content" field.
  24592. func (m *MessageRecordsMutation) SetContent(s string) {
  24593. m.content = &s
  24594. }
  24595. // Content returns the value of the "content" field in the mutation.
  24596. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  24597. v := m.content
  24598. if v == nil {
  24599. return
  24600. }
  24601. return *v, true
  24602. }
  24603. // OldContent returns the old "content" field's value of the MessageRecords entity.
  24604. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24606. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  24607. if !m.op.Is(OpUpdateOne) {
  24608. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  24609. }
  24610. if m.id == nil || m.oldValue == nil {
  24611. return v, errors.New("OldContent requires an ID field in the mutation")
  24612. }
  24613. oldValue, err := m.oldValue(ctx)
  24614. if err != nil {
  24615. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  24616. }
  24617. return oldValue.Content, nil
  24618. }
  24619. // ResetContent resets all changes to the "content" field.
  24620. func (m *MessageRecordsMutation) ResetContent() {
  24621. m.content = nil
  24622. }
  24623. // SetMeta sets the "meta" field.
  24624. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  24625. m.meta = &ct
  24626. }
  24627. // Meta returns the value of the "meta" field in the mutation.
  24628. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  24629. v := m.meta
  24630. if v == nil {
  24631. return
  24632. }
  24633. return *v, true
  24634. }
  24635. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  24636. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24638. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  24639. if !m.op.Is(OpUpdateOne) {
  24640. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  24641. }
  24642. if m.id == nil || m.oldValue == nil {
  24643. return v, errors.New("OldMeta requires an ID field in the mutation")
  24644. }
  24645. oldValue, err := m.oldValue(ctx)
  24646. if err != nil {
  24647. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  24648. }
  24649. return oldValue.Meta, nil
  24650. }
  24651. // ClearMeta clears the value of the "meta" field.
  24652. func (m *MessageRecordsMutation) ClearMeta() {
  24653. m.meta = nil
  24654. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  24655. }
  24656. // MetaCleared returns if the "meta" field was cleared in this mutation.
  24657. func (m *MessageRecordsMutation) MetaCleared() bool {
  24658. _, ok := m.clearedFields[messagerecords.FieldMeta]
  24659. return ok
  24660. }
  24661. // ResetMeta resets all changes to the "meta" field.
  24662. func (m *MessageRecordsMutation) ResetMeta() {
  24663. m.meta = nil
  24664. delete(m.clearedFields, messagerecords.FieldMeta)
  24665. }
  24666. // SetErrorDetail sets the "error_detail" field.
  24667. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  24668. m.error_detail = &s
  24669. }
  24670. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  24671. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  24672. v := m.error_detail
  24673. if v == nil {
  24674. return
  24675. }
  24676. return *v, true
  24677. }
  24678. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  24679. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24681. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  24682. if !m.op.Is(OpUpdateOne) {
  24683. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  24684. }
  24685. if m.id == nil || m.oldValue == nil {
  24686. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  24687. }
  24688. oldValue, err := m.oldValue(ctx)
  24689. if err != nil {
  24690. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  24691. }
  24692. return oldValue.ErrorDetail, nil
  24693. }
  24694. // ResetErrorDetail resets all changes to the "error_detail" field.
  24695. func (m *MessageRecordsMutation) ResetErrorDetail() {
  24696. m.error_detail = nil
  24697. }
  24698. // SetSendTime sets the "send_time" field.
  24699. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  24700. m.send_time = &t
  24701. }
  24702. // SendTime returns the value of the "send_time" field in the mutation.
  24703. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  24704. v := m.send_time
  24705. if v == nil {
  24706. return
  24707. }
  24708. return *v, true
  24709. }
  24710. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  24711. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24713. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  24714. if !m.op.Is(OpUpdateOne) {
  24715. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  24716. }
  24717. if m.id == nil || m.oldValue == nil {
  24718. return v, errors.New("OldSendTime requires an ID field in the mutation")
  24719. }
  24720. oldValue, err := m.oldValue(ctx)
  24721. if err != nil {
  24722. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  24723. }
  24724. return oldValue.SendTime, nil
  24725. }
  24726. // ClearSendTime clears the value of the "send_time" field.
  24727. func (m *MessageRecordsMutation) ClearSendTime() {
  24728. m.send_time = nil
  24729. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  24730. }
  24731. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  24732. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  24733. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  24734. return ok
  24735. }
  24736. // ResetSendTime resets all changes to the "send_time" field.
  24737. func (m *MessageRecordsMutation) ResetSendTime() {
  24738. m.send_time = nil
  24739. delete(m.clearedFields, messagerecords.FieldSendTime)
  24740. }
  24741. // SetSourceType sets the "source_type" field.
  24742. func (m *MessageRecordsMutation) SetSourceType(i int) {
  24743. m.source_type = &i
  24744. m.addsource_type = nil
  24745. }
  24746. // SourceType returns the value of the "source_type" field in the mutation.
  24747. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  24748. v := m.source_type
  24749. if v == nil {
  24750. return
  24751. }
  24752. return *v, true
  24753. }
  24754. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  24755. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24757. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  24758. if !m.op.Is(OpUpdateOne) {
  24759. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  24760. }
  24761. if m.id == nil || m.oldValue == nil {
  24762. return v, errors.New("OldSourceType requires an ID field in the mutation")
  24763. }
  24764. oldValue, err := m.oldValue(ctx)
  24765. if err != nil {
  24766. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  24767. }
  24768. return oldValue.SourceType, nil
  24769. }
  24770. // AddSourceType adds i to the "source_type" field.
  24771. func (m *MessageRecordsMutation) AddSourceType(i int) {
  24772. if m.addsource_type != nil {
  24773. *m.addsource_type += i
  24774. } else {
  24775. m.addsource_type = &i
  24776. }
  24777. }
  24778. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  24779. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  24780. v := m.addsource_type
  24781. if v == nil {
  24782. return
  24783. }
  24784. return *v, true
  24785. }
  24786. // ResetSourceType resets all changes to the "source_type" field.
  24787. func (m *MessageRecordsMutation) ResetSourceType() {
  24788. m.source_type = nil
  24789. m.addsource_type = nil
  24790. }
  24791. // SetSourceID sets the "source_id" field.
  24792. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  24793. m.sop_stage = &u
  24794. }
  24795. // SourceID returns the value of the "source_id" field in the mutation.
  24796. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  24797. v := m.sop_stage
  24798. if v == nil {
  24799. return
  24800. }
  24801. return *v, true
  24802. }
  24803. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  24804. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24806. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  24807. if !m.op.Is(OpUpdateOne) {
  24808. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  24809. }
  24810. if m.id == nil || m.oldValue == nil {
  24811. return v, errors.New("OldSourceID requires an ID field in the mutation")
  24812. }
  24813. oldValue, err := m.oldValue(ctx)
  24814. if err != nil {
  24815. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  24816. }
  24817. return oldValue.SourceID, nil
  24818. }
  24819. // ClearSourceID clears the value of the "source_id" field.
  24820. func (m *MessageRecordsMutation) ClearSourceID() {
  24821. m.sop_stage = nil
  24822. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  24823. }
  24824. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  24825. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  24826. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  24827. return ok
  24828. }
  24829. // ResetSourceID resets all changes to the "source_id" field.
  24830. func (m *MessageRecordsMutation) ResetSourceID() {
  24831. m.sop_stage = nil
  24832. delete(m.clearedFields, messagerecords.FieldSourceID)
  24833. }
  24834. // SetSubSourceID sets the "sub_source_id" field.
  24835. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  24836. m.sop_node = &u
  24837. }
  24838. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  24839. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  24840. v := m.sop_node
  24841. if v == nil {
  24842. return
  24843. }
  24844. return *v, true
  24845. }
  24846. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  24847. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24849. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  24850. if !m.op.Is(OpUpdateOne) {
  24851. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  24852. }
  24853. if m.id == nil || m.oldValue == nil {
  24854. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  24855. }
  24856. oldValue, err := m.oldValue(ctx)
  24857. if err != nil {
  24858. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  24859. }
  24860. return oldValue.SubSourceID, nil
  24861. }
  24862. // ClearSubSourceID clears the value of the "sub_source_id" field.
  24863. func (m *MessageRecordsMutation) ClearSubSourceID() {
  24864. m.sop_node = nil
  24865. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  24866. }
  24867. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  24868. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  24869. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  24870. return ok
  24871. }
  24872. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  24873. func (m *MessageRecordsMutation) ResetSubSourceID() {
  24874. m.sop_node = nil
  24875. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  24876. }
  24877. // SetOrganizationID sets the "organization_id" field.
  24878. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  24879. m.organization_id = &u
  24880. m.addorganization_id = nil
  24881. }
  24882. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24883. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  24884. v := m.organization_id
  24885. if v == nil {
  24886. return
  24887. }
  24888. return *v, true
  24889. }
  24890. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  24891. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  24892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24893. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24894. if !m.op.Is(OpUpdateOne) {
  24895. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24896. }
  24897. if m.id == nil || m.oldValue == nil {
  24898. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24899. }
  24900. oldValue, err := m.oldValue(ctx)
  24901. if err != nil {
  24902. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24903. }
  24904. return oldValue.OrganizationID, nil
  24905. }
  24906. // AddOrganizationID adds u to the "organization_id" field.
  24907. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  24908. if m.addorganization_id != nil {
  24909. *m.addorganization_id += u
  24910. } else {
  24911. m.addorganization_id = &u
  24912. }
  24913. }
  24914. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24915. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  24916. v := m.addorganization_id
  24917. if v == nil {
  24918. return
  24919. }
  24920. return *v, true
  24921. }
  24922. // ClearOrganizationID clears the value of the "organization_id" field.
  24923. func (m *MessageRecordsMutation) ClearOrganizationID() {
  24924. m.organization_id = nil
  24925. m.addorganization_id = nil
  24926. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  24927. }
  24928. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24929. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  24930. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  24931. return ok
  24932. }
  24933. // ResetOrganizationID resets all changes to the "organization_id" field.
  24934. func (m *MessageRecordsMutation) ResetOrganizationID() {
  24935. m.organization_id = nil
  24936. m.addorganization_id = nil
  24937. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  24938. }
  24939. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  24940. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  24941. m.sop_stage = &id
  24942. }
  24943. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  24944. func (m *MessageRecordsMutation) ClearSopStage() {
  24945. m.clearedsop_stage = true
  24946. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  24947. }
  24948. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  24949. func (m *MessageRecordsMutation) SopStageCleared() bool {
  24950. return m.SourceIDCleared() || m.clearedsop_stage
  24951. }
  24952. // SopStageID returns the "sop_stage" edge ID in the mutation.
  24953. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  24954. if m.sop_stage != nil {
  24955. return *m.sop_stage, true
  24956. }
  24957. return
  24958. }
  24959. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  24960. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24961. // SopStageID instead. It exists only for internal usage by the builders.
  24962. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  24963. if id := m.sop_stage; id != nil {
  24964. ids = append(ids, *id)
  24965. }
  24966. return
  24967. }
  24968. // ResetSopStage resets all changes to the "sop_stage" edge.
  24969. func (m *MessageRecordsMutation) ResetSopStage() {
  24970. m.sop_stage = nil
  24971. m.clearedsop_stage = false
  24972. }
  24973. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  24974. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  24975. m.sop_node = &id
  24976. }
  24977. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  24978. func (m *MessageRecordsMutation) ClearSopNode() {
  24979. m.clearedsop_node = true
  24980. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  24981. }
  24982. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  24983. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  24984. return m.SubSourceIDCleared() || m.clearedsop_node
  24985. }
  24986. // SopNodeID returns the "sop_node" edge ID in the mutation.
  24987. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  24988. if m.sop_node != nil {
  24989. return *m.sop_node, true
  24990. }
  24991. return
  24992. }
  24993. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  24994. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24995. // SopNodeID instead. It exists only for internal usage by the builders.
  24996. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  24997. if id := m.sop_node; id != nil {
  24998. ids = append(ids, *id)
  24999. }
  25000. return
  25001. }
  25002. // ResetSopNode resets all changes to the "sop_node" edge.
  25003. func (m *MessageRecordsMutation) ResetSopNode() {
  25004. m.sop_node = nil
  25005. m.clearedsop_node = false
  25006. }
  25007. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  25008. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  25009. m.message_contact = &id
  25010. }
  25011. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  25012. func (m *MessageRecordsMutation) ClearMessageContact() {
  25013. m.clearedmessage_contact = true
  25014. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  25015. }
  25016. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  25017. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  25018. return m.ContactIDCleared() || m.clearedmessage_contact
  25019. }
  25020. // MessageContactID returns the "message_contact" edge ID in the mutation.
  25021. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  25022. if m.message_contact != nil {
  25023. return *m.message_contact, true
  25024. }
  25025. return
  25026. }
  25027. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  25028. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25029. // MessageContactID instead. It exists only for internal usage by the builders.
  25030. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  25031. if id := m.message_contact; id != nil {
  25032. ids = append(ids, *id)
  25033. }
  25034. return
  25035. }
  25036. // ResetMessageContact resets all changes to the "message_contact" edge.
  25037. func (m *MessageRecordsMutation) ResetMessageContact() {
  25038. m.message_contact = nil
  25039. m.clearedmessage_contact = false
  25040. }
  25041. // Where appends a list predicates to the MessageRecordsMutation builder.
  25042. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  25043. m.predicates = append(m.predicates, ps...)
  25044. }
  25045. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  25046. // users can use type-assertion to append predicates that do not depend on any generated package.
  25047. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  25048. p := make([]predicate.MessageRecords, len(ps))
  25049. for i := range ps {
  25050. p[i] = ps[i]
  25051. }
  25052. m.Where(p...)
  25053. }
  25054. // Op returns the operation name.
  25055. func (m *MessageRecordsMutation) Op() Op {
  25056. return m.op
  25057. }
  25058. // SetOp allows setting the mutation operation.
  25059. func (m *MessageRecordsMutation) SetOp(op Op) {
  25060. m.op = op
  25061. }
  25062. // Type returns the node type of this mutation (MessageRecords).
  25063. func (m *MessageRecordsMutation) Type() string {
  25064. return m.typ
  25065. }
  25066. // Fields returns all fields that were changed during this mutation. Note that in
  25067. // order to get all numeric fields that were incremented/decremented, call
  25068. // AddedFields().
  25069. func (m *MessageRecordsMutation) Fields() []string {
  25070. fields := make([]string, 0, 16)
  25071. if m.created_at != nil {
  25072. fields = append(fields, messagerecords.FieldCreatedAt)
  25073. }
  25074. if m.updated_at != nil {
  25075. fields = append(fields, messagerecords.FieldUpdatedAt)
  25076. }
  25077. if m.status != nil {
  25078. fields = append(fields, messagerecords.FieldStatus)
  25079. }
  25080. if m.bot_wxid != nil {
  25081. fields = append(fields, messagerecords.FieldBotWxid)
  25082. }
  25083. if m.message_contact != nil {
  25084. fields = append(fields, messagerecords.FieldContactID)
  25085. }
  25086. if m.contact_type != nil {
  25087. fields = append(fields, messagerecords.FieldContactType)
  25088. }
  25089. if m.contact_wxid != nil {
  25090. fields = append(fields, messagerecords.FieldContactWxid)
  25091. }
  25092. if m.content_type != nil {
  25093. fields = append(fields, messagerecords.FieldContentType)
  25094. }
  25095. if m.content != nil {
  25096. fields = append(fields, messagerecords.FieldContent)
  25097. }
  25098. if m.meta != nil {
  25099. fields = append(fields, messagerecords.FieldMeta)
  25100. }
  25101. if m.error_detail != nil {
  25102. fields = append(fields, messagerecords.FieldErrorDetail)
  25103. }
  25104. if m.send_time != nil {
  25105. fields = append(fields, messagerecords.FieldSendTime)
  25106. }
  25107. if m.source_type != nil {
  25108. fields = append(fields, messagerecords.FieldSourceType)
  25109. }
  25110. if m.sop_stage != nil {
  25111. fields = append(fields, messagerecords.FieldSourceID)
  25112. }
  25113. if m.sop_node != nil {
  25114. fields = append(fields, messagerecords.FieldSubSourceID)
  25115. }
  25116. if m.organization_id != nil {
  25117. fields = append(fields, messagerecords.FieldOrganizationID)
  25118. }
  25119. return fields
  25120. }
  25121. // Field returns the value of a field with the given name. The second boolean
  25122. // return value indicates that this field was not set, or was not defined in the
  25123. // schema.
  25124. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  25125. switch name {
  25126. case messagerecords.FieldCreatedAt:
  25127. return m.CreatedAt()
  25128. case messagerecords.FieldUpdatedAt:
  25129. return m.UpdatedAt()
  25130. case messagerecords.FieldStatus:
  25131. return m.Status()
  25132. case messagerecords.FieldBotWxid:
  25133. return m.BotWxid()
  25134. case messagerecords.FieldContactID:
  25135. return m.ContactID()
  25136. case messagerecords.FieldContactType:
  25137. return m.ContactType()
  25138. case messagerecords.FieldContactWxid:
  25139. return m.ContactWxid()
  25140. case messagerecords.FieldContentType:
  25141. return m.ContentType()
  25142. case messagerecords.FieldContent:
  25143. return m.Content()
  25144. case messagerecords.FieldMeta:
  25145. return m.Meta()
  25146. case messagerecords.FieldErrorDetail:
  25147. return m.ErrorDetail()
  25148. case messagerecords.FieldSendTime:
  25149. return m.SendTime()
  25150. case messagerecords.FieldSourceType:
  25151. return m.SourceType()
  25152. case messagerecords.FieldSourceID:
  25153. return m.SourceID()
  25154. case messagerecords.FieldSubSourceID:
  25155. return m.SubSourceID()
  25156. case messagerecords.FieldOrganizationID:
  25157. return m.OrganizationID()
  25158. }
  25159. return nil, false
  25160. }
  25161. // OldField returns the old value of the field from the database. An error is
  25162. // returned if the mutation operation is not UpdateOne, or the query to the
  25163. // database failed.
  25164. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25165. switch name {
  25166. case messagerecords.FieldCreatedAt:
  25167. return m.OldCreatedAt(ctx)
  25168. case messagerecords.FieldUpdatedAt:
  25169. return m.OldUpdatedAt(ctx)
  25170. case messagerecords.FieldStatus:
  25171. return m.OldStatus(ctx)
  25172. case messagerecords.FieldBotWxid:
  25173. return m.OldBotWxid(ctx)
  25174. case messagerecords.FieldContactID:
  25175. return m.OldContactID(ctx)
  25176. case messagerecords.FieldContactType:
  25177. return m.OldContactType(ctx)
  25178. case messagerecords.FieldContactWxid:
  25179. return m.OldContactWxid(ctx)
  25180. case messagerecords.FieldContentType:
  25181. return m.OldContentType(ctx)
  25182. case messagerecords.FieldContent:
  25183. return m.OldContent(ctx)
  25184. case messagerecords.FieldMeta:
  25185. return m.OldMeta(ctx)
  25186. case messagerecords.FieldErrorDetail:
  25187. return m.OldErrorDetail(ctx)
  25188. case messagerecords.FieldSendTime:
  25189. return m.OldSendTime(ctx)
  25190. case messagerecords.FieldSourceType:
  25191. return m.OldSourceType(ctx)
  25192. case messagerecords.FieldSourceID:
  25193. return m.OldSourceID(ctx)
  25194. case messagerecords.FieldSubSourceID:
  25195. return m.OldSubSourceID(ctx)
  25196. case messagerecords.FieldOrganizationID:
  25197. return m.OldOrganizationID(ctx)
  25198. }
  25199. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  25200. }
  25201. // SetField sets the value of a field with the given name. It returns an error if
  25202. // the field is not defined in the schema, or if the type mismatched the field
  25203. // type.
  25204. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  25205. switch name {
  25206. case messagerecords.FieldCreatedAt:
  25207. v, ok := value.(time.Time)
  25208. if !ok {
  25209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25210. }
  25211. m.SetCreatedAt(v)
  25212. return nil
  25213. case messagerecords.FieldUpdatedAt:
  25214. v, ok := value.(time.Time)
  25215. if !ok {
  25216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25217. }
  25218. m.SetUpdatedAt(v)
  25219. return nil
  25220. case messagerecords.FieldStatus:
  25221. v, ok := value.(uint8)
  25222. if !ok {
  25223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25224. }
  25225. m.SetStatus(v)
  25226. return nil
  25227. case messagerecords.FieldBotWxid:
  25228. v, ok := value.(string)
  25229. if !ok {
  25230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25231. }
  25232. m.SetBotWxid(v)
  25233. return nil
  25234. case messagerecords.FieldContactID:
  25235. v, ok := value.(uint64)
  25236. if !ok {
  25237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25238. }
  25239. m.SetContactID(v)
  25240. return nil
  25241. case messagerecords.FieldContactType:
  25242. v, ok := value.(int)
  25243. if !ok {
  25244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25245. }
  25246. m.SetContactType(v)
  25247. return nil
  25248. case messagerecords.FieldContactWxid:
  25249. v, ok := value.(string)
  25250. if !ok {
  25251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25252. }
  25253. m.SetContactWxid(v)
  25254. return nil
  25255. case messagerecords.FieldContentType:
  25256. v, ok := value.(int)
  25257. if !ok {
  25258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25259. }
  25260. m.SetContentType(v)
  25261. return nil
  25262. case messagerecords.FieldContent:
  25263. v, ok := value.(string)
  25264. if !ok {
  25265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25266. }
  25267. m.SetContent(v)
  25268. return nil
  25269. case messagerecords.FieldMeta:
  25270. v, ok := value.(custom_types.Meta)
  25271. if !ok {
  25272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25273. }
  25274. m.SetMeta(v)
  25275. return nil
  25276. case messagerecords.FieldErrorDetail:
  25277. v, ok := value.(string)
  25278. if !ok {
  25279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25280. }
  25281. m.SetErrorDetail(v)
  25282. return nil
  25283. case messagerecords.FieldSendTime:
  25284. v, ok := value.(time.Time)
  25285. if !ok {
  25286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25287. }
  25288. m.SetSendTime(v)
  25289. return nil
  25290. case messagerecords.FieldSourceType:
  25291. v, ok := value.(int)
  25292. if !ok {
  25293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25294. }
  25295. m.SetSourceType(v)
  25296. return nil
  25297. case messagerecords.FieldSourceID:
  25298. v, ok := value.(uint64)
  25299. if !ok {
  25300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25301. }
  25302. m.SetSourceID(v)
  25303. return nil
  25304. case messagerecords.FieldSubSourceID:
  25305. v, ok := value.(uint64)
  25306. if !ok {
  25307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25308. }
  25309. m.SetSubSourceID(v)
  25310. return nil
  25311. case messagerecords.FieldOrganizationID:
  25312. v, ok := value.(uint64)
  25313. if !ok {
  25314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25315. }
  25316. m.SetOrganizationID(v)
  25317. return nil
  25318. }
  25319. return fmt.Errorf("unknown MessageRecords field %s", name)
  25320. }
  25321. // AddedFields returns all numeric fields that were incremented/decremented during
  25322. // this mutation.
  25323. func (m *MessageRecordsMutation) AddedFields() []string {
  25324. var fields []string
  25325. if m.addstatus != nil {
  25326. fields = append(fields, messagerecords.FieldStatus)
  25327. }
  25328. if m.addcontact_type != nil {
  25329. fields = append(fields, messagerecords.FieldContactType)
  25330. }
  25331. if m.addcontent_type != nil {
  25332. fields = append(fields, messagerecords.FieldContentType)
  25333. }
  25334. if m.addsource_type != nil {
  25335. fields = append(fields, messagerecords.FieldSourceType)
  25336. }
  25337. if m.addorganization_id != nil {
  25338. fields = append(fields, messagerecords.FieldOrganizationID)
  25339. }
  25340. return fields
  25341. }
  25342. // AddedField returns the numeric value that was incremented/decremented on a field
  25343. // with the given name. The second boolean return value indicates that this field
  25344. // was not set, or was not defined in the schema.
  25345. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  25346. switch name {
  25347. case messagerecords.FieldStatus:
  25348. return m.AddedStatus()
  25349. case messagerecords.FieldContactType:
  25350. return m.AddedContactType()
  25351. case messagerecords.FieldContentType:
  25352. return m.AddedContentType()
  25353. case messagerecords.FieldSourceType:
  25354. return m.AddedSourceType()
  25355. case messagerecords.FieldOrganizationID:
  25356. return m.AddedOrganizationID()
  25357. }
  25358. return nil, false
  25359. }
  25360. // AddField adds the value to the field with the given name. It returns an error if
  25361. // the field is not defined in the schema, or if the type mismatched the field
  25362. // type.
  25363. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  25364. switch name {
  25365. case messagerecords.FieldStatus:
  25366. v, ok := value.(int8)
  25367. if !ok {
  25368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25369. }
  25370. m.AddStatus(v)
  25371. return nil
  25372. case messagerecords.FieldContactType:
  25373. v, ok := value.(int)
  25374. if !ok {
  25375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25376. }
  25377. m.AddContactType(v)
  25378. return nil
  25379. case messagerecords.FieldContentType:
  25380. v, ok := value.(int)
  25381. if !ok {
  25382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25383. }
  25384. m.AddContentType(v)
  25385. return nil
  25386. case messagerecords.FieldSourceType:
  25387. v, ok := value.(int)
  25388. if !ok {
  25389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25390. }
  25391. m.AddSourceType(v)
  25392. return nil
  25393. case messagerecords.FieldOrganizationID:
  25394. v, ok := value.(int64)
  25395. if !ok {
  25396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25397. }
  25398. m.AddOrganizationID(v)
  25399. return nil
  25400. }
  25401. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  25402. }
  25403. // ClearedFields returns all nullable fields that were cleared during this
  25404. // mutation.
  25405. func (m *MessageRecordsMutation) ClearedFields() []string {
  25406. var fields []string
  25407. if m.FieldCleared(messagerecords.FieldStatus) {
  25408. fields = append(fields, messagerecords.FieldStatus)
  25409. }
  25410. if m.FieldCleared(messagerecords.FieldContactID) {
  25411. fields = append(fields, messagerecords.FieldContactID)
  25412. }
  25413. if m.FieldCleared(messagerecords.FieldMeta) {
  25414. fields = append(fields, messagerecords.FieldMeta)
  25415. }
  25416. if m.FieldCleared(messagerecords.FieldSendTime) {
  25417. fields = append(fields, messagerecords.FieldSendTime)
  25418. }
  25419. if m.FieldCleared(messagerecords.FieldSourceID) {
  25420. fields = append(fields, messagerecords.FieldSourceID)
  25421. }
  25422. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  25423. fields = append(fields, messagerecords.FieldSubSourceID)
  25424. }
  25425. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  25426. fields = append(fields, messagerecords.FieldOrganizationID)
  25427. }
  25428. return fields
  25429. }
  25430. // FieldCleared returns a boolean indicating if a field with the given name was
  25431. // cleared in this mutation.
  25432. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  25433. _, ok := m.clearedFields[name]
  25434. return ok
  25435. }
  25436. // ClearField clears the value of the field with the given name. It returns an
  25437. // error if the field is not defined in the schema.
  25438. func (m *MessageRecordsMutation) ClearField(name string) error {
  25439. switch name {
  25440. case messagerecords.FieldStatus:
  25441. m.ClearStatus()
  25442. return nil
  25443. case messagerecords.FieldContactID:
  25444. m.ClearContactID()
  25445. return nil
  25446. case messagerecords.FieldMeta:
  25447. m.ClearMeta()
  25448. return nil
  25449. case messagerecords.FieldSendTime:
  25450. m.ClearSendTime()
  25451. return nil
  25452. case messagerecords.FieldSourceID:
  25453. m.ClearSourceID()
  25454. return nil
  25455. case messagerecords.FieldSubSourceID:
  25456. m.ClearSubSourceID()
  25457. return nil
  25458. case messagerecords.FieldOrganizationID:
  25459. m.ClearOrganizationID()
  25460. return nil
  25461. }
  25462. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  25463. }
  25464. // ResetField resets all changes in the mutation for the field with the given name.
  25465. // It returns an error if the field is not defined in the schema.
  25466. func (m *MessageRecordsMutation) ResetField(name string) error {
  25467. switch name {
  25468. case messagerecords.FieldCreatedAt:
  25469. m.ResetCreatedAt()
  25470. return nil
  25471. case messagerecords.FieldUpdatedAt:
  25472. m.ResetUpdatedAt()
  25473. return nil
  25474. case messagerecords.FieldStatus:
  25475. m.ResetStatus()
  25476. return nil
  25477. case messagerecords.FieldBotWxid:
  25478. m.ResetBotWxid()
  25479. return nil
  25480. case messagerecords.FieldContactID:
  25481. m.ResetContactID()
  25482. return nil
  25483. case messagerecords.FieldContactType:
  25484. m.ResetContactType()
  25485. return nil
  25486. case messagerecords.FieldContactWxid:
  25487. m.ResetContactWxid()
  25488. return nil
  25489. case messagerecords.FieldContentType:
  25490. m.ResetContentType()
  25491. return nil
  25492. case messagerecords.FieldContent:
  25493. m.ResetContent()
  25494. return nil
  25495. case messagerecords.FieldMeta:
  25496. m.ResetMeta()
  25497. return nil
  25498. case messagerecords.FieldErrorDetail:
  25499. m.ResetErrorDetail()
  25500. return nil
  25501. case messagerecords.FieldSendTime:
  25502. m.ResetSendTime()
  25503. return nil
  25504. case messagerecords.FieldSourceType:
  25505. m.ResetSourceType()
  25506. return nil
  25507. case messagerecords.FieldSourceID:
  25508. m.ResetSourceID()
  25509. return nil
  25510. case messagerecords.FieldSubSourceID:
  25511. m.ResetSubSourceID()
  25512. return nil
  25513. case messagerecords.FieldOrganizationID:
  25514. m.ResetOrganizationID()
  25515. return nil
  25516. }
  25517. return fmt.Errorf("unknown MessageRecords field %s", name)
  25518. }
  25519. // AddedEdges returns all edge names that were set/added in this mutation.
  25520. func (m *MessageRecordsMutation) AddedEdges() []string {
  25521. edges := make([]string, 0, 3)
  25522. if m.sop_stage != nil {
  25523. edges = append(edges, messagerecords.EdgeSopStage)
  25524. }
  25525. if m.sop_node != nil {
  25526. edges = append(edges, messagerecords.EdgeSopNode)
  25527. }
  25528. if m.message_contact != nil {
  25529. edges = append(edges, messagerecords.EdgeMessageContact)
  25530. }
  25531. return edges
  25532. }
  25533. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25534. // name in this mutation.
  25535. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  25536. switch name {
  25537. case messagerecords.EdgeSopStage:
  25538. if id := m.sop_stage; id != nil {
  25539. return []ent.Value{*id}
  25540. }
  25541. case messagerecords.EdgeSopNode:
  25542. if id := m.sop_node; id != nil {
  25543. return []ent.Value{*id}
  25544. }
  25545. case messagerecords.EdgeMessageContact:
  25546. if id := m.message_contact; id != nil {
  25547. return []ent.Value{*id}
  25548. }
  25549. }
  25550. return nil
  25551. }
  25552. // RemovedEdges returns all edge names that were removed in this mutation.
  25553. func (m *MessageRecordsMutation) RemovedEdges() []string {
  25554. edges := make([]string, 0, 3)
  25555. return edges
  25556. }
  25557. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25558. // the given name in this mutation.
  25559. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  25560. return nil
  25561. }
  25562. // ClearedEdges returns all edge names that were cleared in this mutation.
  25563. func (m *MessageRecordsMutation) ClearedEdges() []string {
  25564. edges := make([]string, 0, 3)
  25565. if m.clearedsop_stage {
  25566. edges = append(edges, messagerecords.EdgeSopStage)
  25567. }
  25568. if m.clearedsop_node {
  25569. edges = append(edges, messagerecords.EdgeSopNode)
  25570. }
  25571. if m.clearedmessage_contact {
  25572. edges = append(edges, messagerecords.EdgeMessageContact)
  25573. }
  25574. return edges
  25575. }
  25576. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25577. // was cleared in this mutation.
  25578. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  25579. switch name {
  25580. case messagerecords.EdgeSopStage:
  25581. return m.clearedsop_stage
  25582. case messagerecords.EdgeSopNode:
  25583. return m.clearedsop_node
  25584. case messagerecords.EdgeMessageContact:
  25585. return m.clearedmessage_contact
  25586. }
  25587. return false
  25588. }
  25589. // ClearEdge clears the value of the edge with the given name. It returns an error
  25590. // if that edge is not defined in the schema.
  25591. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  25592. switch name {
  25593. case messagerecords.EdgeSopStage:
  25594. m.ClearSopStage()
  25595. return nil
  25596. case messagerecords.EdgeSopNode:
  25597. m.ClearSopNode()
  25598. return nil
  25599. case messagerecords.EdgeMessageContact:
  25600. m.ClearMessageContact()
  25601. return nil
  25602. }
  25603. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  25604. }
  25605. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25606. // It returns an error if the edge is not defined in the schema.
  25607. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  25608. switch name {
  25609. case messagerecords.EdgeSopStage:
  25610. m.ResetSopStage()
  25611. return nil
  25612. case messagerecords.EdgeSopNode:
  25613. m.ResetSopNode()
  25614. return nil
  25615. case messagerecords.EdgeMessageContact:
  25616. m.ResetMessageContact()
  25617. return nil
  25618. }
  25619. return fmt.Errorf("unknown MessageRecords edge %s", name)
  25620. }
  25621. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  25622. type MsgMutation struct {
  25623. config
  25624. op Op
  25625. typ string
  25626. id *uint64
  25627. created_at *time.Time
  25628. updated_at *time.Time
  25629. deleted_at *time.Time
  25630. status *uint8
  25631. addstatus *int8
  25632. fromwxid *string
  25633. toid *string
  25634. msgtype *int32
  25635. addmsgtype *int32
  25636. msg *string
  25637. batch_no *string
  25638. cc *string
  25639. phone *string
  25640. clearedFields map[string]struct{}
  25641. done bool
  25642. oldValue func(context.Context) (*Msg, error)
  25643. predicates []predicate.Msg
  25644. }
  25645. var _ ent.Mutation = (*MsgMutation)(nil)
  25646. // msgOption allows management of the mutation configuration using functional options.
  25647. type msgOption func(*MsgMutation)
  25648. // newMsgMutation creates new mutation for the Msg entity.
  25649. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  25650. m := &MsgMutation{
  25651. config: c,
  25652. op: op,
  25653. typ: TypeMsg,
  25654. clearedFields: make(map[string]struct{}),
  25655. }
  25656. for _, opt := range opts {
  25657. opt(m)
  25658. }
  25659. return m
  25660. }
  25661. // withMsgID sets the ID field of the mutation.
  25662. func withMsgID(id uint64) msgOption {
  25663. return func(m *MsgMutation) {
  25664. var (
  25665. err error
  25666. once sync.Once
  25667. value *Msg
  25668. )
  25669. m.oldValue = func(ctx context.Context) (*Msg, error) {
  25670. once.Do(func() {
  25671. if m.done {
  25672. err = errors.New("querying old values post mutation is not allowed")
  25673. } else {
  25674. value, err = m.Client().Msg.Get(ctx, id)
  25675. }
  25676. })
  25677. return value, err
  25678. }
  25679. m.id = &id
  25680. }
  25681. }
  25682. // withMsg sets the old Msg of the mutation.
  25683. func withMsg(node *Msg) msgOption {
  25684. return func(m *MsgMutation) {
  25685. m.oldValue = func(context.Context) (*Msg, error) {
  25686. return node, nil
  25687. }
  25688. m.id = &node.ID
  25689. }
  25690. }
  25691. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25692. // executed in a transaction (ent.Tx), a transactional client is returned.
  25693. func (m MsgMutation) Client() *Client {
  25694. client := &Client{config: m.config}
  25695. client.init()
  25696. return client
  25697. }
  25698. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25699. // it returns an error otherwise.
  25700. func (m MsgMutation) Tx() (*Tx, error) {
  25701. if _, ok := m.driver.(*txDriver); !ok {
  25702. return nil, errors.New("ent: mutation is not running in a transaction")
  25703. }
  25704. tx := &Tx{config: m.config}
  25705. tx.init()
  25706. return tx, nil
  25707. }
  25708. // SetID sets the value of the id field. Note that this
  25709. // operation is only accepted on creation of Msg entities.
  25710. func (m *MsgMutation) SetID(id uint64) {
  25711. m.id = &id
  25712. }
  25713. // ID returns the ID value in the mutation. Note that the ID is only available
  25714. // if it was provided to the builder or after it was returned from the database.
  25715. func (m *MsgMutation) ID() (id uint64, exists bool) {
  25716. if m.id == nil {
  25717. return
  25718. }
  25719. return *m.id, true
  25720. }
  25721. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25722. // That means, if the mutation is applied within a transaction with an isolation level such
  25723. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25724. // or updated by the mutation.
  25725. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  25726. switch {
  25727. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25728. id, exists := m.ID()
  25729. if exists {
  25730. return []uint64{id}, nil
  25731. }
  25732. fallthrough
  25733. case m.op.Is(OpUpdate | OpDelete):
  25734. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  25735. default:
  25736. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25737. }
  25738. }
  25739. // SetCreatedAt sets the "created_at" field.
  25740. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  25741. m.created_at = &t
  25742. }
  25743. // CreatedAt returns the value of the "created_at" field in the mutation.
  25744. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  25745. v := m.created_at
  25746. if v == nil {
  25747. return
  25748. }
  25749. return *v, true
  25750. }
  25751. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  25752. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25754. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25755. if !m.op.Is(OpUpdateOne) {
  25756. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25757. }
  25758. if m.id == nil || m.oldValue == nil {
  25759. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25760. }
  25761. oldValue, err := m.oldValue(ctx)
  25762. if err != nil {
  25763. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25764. }
  25765. return oldValue.CreatedAt, nil
  25766. }
  25767. // ResetCreatedAt resets all changes to the "created_at" field.
  25768. func (m *MsgMutation) ResetCreatedAt() {
  25769. m.created_at = nil
  25770. }
  25771. // SetUpdatedAt sets the "updated_at" field.
  25772. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  25773. m.updated_at = &t
  25774. }
  25775. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25776. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  25777. v := m.updated_at
  25778. if v == nil {
  25779. return
  25780. }
  25781. return *v, true
  25782. }
  25783. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  25784. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25786. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25787. if !m.op.Is(OpUpdateOne) {
  25788. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25789. }
  25790. if m.id == nil || m.oldValue == nil {
  25791. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25792. }
  25793. oldValue, err := m.oldValue(ctx)
  25794. if err != nil {
  25795. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25796. }
  25797. return oldValue.UpdatedAt, nil
  25798. }
  25799. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25800. func (m *MsgMutation) ResetUpdatedAt() {
  25801. m.updated_at = nil
  25802. }
  25803. // SetDeletedAt sets the "deleted_at" field.
  25804. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  25805. m.deleted_at = &t
  25806. }
  25807. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25808. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  25809. v := m.deleted_at
  25810. if v == nil {
  25811. return
  25812. }
  25813. return *v, true
  25814. }
  25815. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  25816. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25818. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25819. if !m.op.Is(OpUpdateOne) {
  25820. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25821. }
  25822. if m.id == nil || m.oldValue == nil {
  25823. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25824. }
  25825. oldValue, err := m.oldValue(ctx)
  25826. if err != nil {
  25827. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25828. }
  25829. return oldValue.DeletedAt, nil
  25830. }
  25831. // ClearDeletedAt clears the value of the "deleted_at" field.
  25832. func (m *MsgMutation) ClearDeletedAt() {
  25833. m.deleted_at = nil
  25834. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  25835. }
  25836. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25837. func (m *MsgMutation) DeletedAtCleared() bool {
  25838. _, ok := m.clearedFields[msg.FieldDeletedAt]
  25839. return ok
  25840. }
  25841. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25842. func (m *MsgMutation) ResetDeletedAt() {
  25843. m.deleted_at = nil
  25844. delete(m.clearedFields, msg.FieldDeletedAt)
  25845. }
  25846. // SetStatus sets the "status" field.
  25847. func (m *MsgMutation) SetStatus(u uint8) {
  25848. m.status = &u
  25849. m.addstatus = nil
  25850. }
  25851. // Status returns the value of the "status" field in the mutation.
  25852. func (m *MsgMutation) Status() (r uint8, exists bool) {
  25853. v := m.status
  25854. if v == nil {
  25855. return
  25856. }
  25857. return *v, true
  25858. }
  25859. // OldStatus returns the old "status" field's value of the Msg entity.
  25860. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25862. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25863. if !m.op.Is(OpUpdateOne) {
  25864. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25865. }
  25866. if m.id == nil || m.oldValue == nil {
  25867. return v, errors.New("OldStatus requires an ID field in the mutation")
  25868. }
  25869. oldValue, err := m.oldValue(ctx)
  25870. if err != nil {
  25871. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25872. }
  25873. return oldValue.Status, nil
  25874. }
  25875. // AddStatus adds u to the "status" field.
  25876. func (m *MsgMutation) AddStatus(u int8) {
  25877. if m.addstatus != nil {
  25878. *m.addstatus += u
  25879. } else {
  25880. m.addstatus = &u
  25881. }
  25882. }
  25883. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25884. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  25885. v := m.addstatus
  25886. if v == nil {
  25887. return
  25888. }
  25889. return *v, true
  25890. }
  25891. // ClearStatus clears the value of the "status" field.
  25892. func (m *MsgMutation) ClearStatus() {
  25893. m.status = nil
  25894. m.addstatus = nil
  25895. m.clearedFields[msg.FieldStatus] = struct{}{}
  25896. }
  25897. // StatusCleared returns if the "status" field was cleared in this mutation.
  25898. func (m *MsgMutation) StatusCleared() bool {
  25899. _, ok := m.clearedFields[msg.FieldStatus]
  25900. return ok
  25901. }
  25902. // ResetStatus resets all changes to the "status" field.
  25903. func (m *MsgMutation) ResetStatus() {
  25904. m.status = nil
  25905. m.addstatus = nil
  25906. delete(m.clearedFields, msg.FieldStatus)
  25907. }
  25908. // SetFromwxid sets the "fromwxid" field.
  25909. func (m *MsgMutation) SetFromwxid(s string) {
  25910. m.fromwxid = &s
  25911. }
  25912. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  25913. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  25914. v := m.fromwxid
  25915. if v == nil {
  25916. return
  25917. }
  25918. return *v, true
  25919. }
  25920. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  25921. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25923. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  25924. if !m.op.Is(OpUpdateOne) {
  25925. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  25926. }
  25927. if m.id == nil || m.oldValue == nil {
  25928. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  25929. }
  25930. oldValue, err := m.oldValue(ctx)
  25931. if err != nil {
  25932. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  25933. }
  25934. return oldValue.Fromwxid, nil
  25935. }
  25936. // ClearFromwxid clears the value of the "fromwxid" field.
  25937. func (m *MsgMutation) ClearFromwxid() {
  25938. m.fromwxid = nil
  25939. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  25940. }
  25941. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  25942. func (m *MsgMutation) FromwxidCleared() bool {
  25943. _, ok := m.clearedFields[msg.FieldFromwxid]
  25944. return ok
  25945. }
  25946. // ResetFromwxid resets all changes to the "fromwxid" field.
  25947. func (m *MsgMutation) ResetFromwxid() {
  25948. m.fromwxid = nil
  25949. delete(m.clearedFields, msg.FieldFromwxid)
  25950. }
  25951. // SetToid sets the "toid" field.
  25952. func (m *MsgMutation) SetToid(s string) {
  25953. m.toid = &s
  25954. }
  25955. // Toid returns the value of the "toid" field in the mutation.
  25956. func (m *MsgMutation) Toid() (r string, exists bool) {
  25957. v := m.toid
  25958. if v == nil {
  25959. return
  25960. }
  25961. return *v, true
  25962. }
  25963. // OldToid returns the old "toid" field's value of the Msg entity.
  25964. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  25965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25966. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  25967. if !m.op.Is(OpUpdateOne) {
  25968. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  25969. }
  25970. if m.id == nil || m.oldValue == nil {
  25971. return v, errors.New("OldToid requires an ID field in the mutation")
  25972. }
  25973. oldValue, err := m.oldValue(ctx)
  25974. if err != nil {
  25975. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  25976. }
  25977. return oldValue.Toid, nil
  25978. }
  25979. // ClearToid clears the value of the "toid" field.
  25980. func (m *MsgMutation) ClearToid() {
  25981. m.toid = nil
  25982. m.clearedFields[msg.FieldToid] = struct{}{}
  25983. }
  25984. // ToidCleared returns if the "toid" field was cleared in this mutation.
  25985. func (m *MsgMutation) ToidCleared() bool {
  25986. _, ok := m.clearedFields[msg.FieldToid]
  25987. return ok
  25988. }
  25989. // ResetToid resets all changes to the "toid" field.
  25990. func (m *MsgMutation) ResetToid() {
  25991. m.toid = nil
  25992. delete(m.clearedFields, msg.FieldToid)
  25993. }
  25994. // SetMsgtype sets the "msgtype" field.
  25995. func (m *MsgMutation) SetMsgtype(i int32) {
  25996. m.msgtype = &i
  25997. m.addmsgtype = nil
  25998. }
  25999. // Msgtype returns the value of the "msgtype" field in the mutation.
  26000. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  26001. v := m.msgtype
  26002. if v == nil {
  26003. return
  26004. }
  26005. return *v, true
  26006. }
  26007. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  26008. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26010. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  26011. if !m.op.Is(OpUpdateOne) {
  26012. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  26013. }
  26014. if m.id == nil || m.oldValue == nil {
  26015. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  26016. }
  26017. oldValue, err := m.oldValue(ctx)
  26018. if err != nil {
  26019. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  26020. }
  26021. return oldValue.Msgtype, nil
  26022. }
  26023. // AddMsgtype adds i to the "msgtype" field.
  26024. func (m *MsgMutation) AddMsgtype(i int32) {
  26025. if m.addmsgtype != nil {
  26026. *m.addmsgtype += i
  26027. } else {
  26028. m.addmsgtype = &i
  26029. }
  26030. }
  26031. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  26032. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  26033. v := m.addmsgtype
  26034. if v == nil {
  26035. return
  26036. }
  26037. return *v, true
  26038. }
  26039. // ClearMsgtype clears the value of the "msgtype" field.
  26040. func (m *MsgMutation) ClearMsgtype() {
  26041. m.msgtype = nil
  26042. m.addmsgtype = nil
  26043. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  26044. }
  26045. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  26046. func (m *MsgMutation) MsgtypeCleared() bool {
  26047. _, ok := m.clearedFields[msg.FieldMsgtype]
  26048. return ok
  26049. }
  26050. // ResetMsgtype resets all changes to the "msgtype" field.
  26051. func (m *MsgMutation) ResetMsgtype() {
  26052. m.msgtype = nil
  26053. m.addmsgtype = nil
  26054. delete(m.clearedFields, msg.FieldMsgtype)
  26055. }
  26056. // SetMsg sets the "msg" field.
  26057. func (m *MsgMutation) SetMsg(s string) {
  26058. m.msg = &s
  26059. }
  26060. // Msg returns the value of the "msg" field in the mutation.
  26061. func (m *MsgMutation) Msg() (r string, exists bool) {
  26062. v := m.msg
  26063. if v == nil {
  26064. return
  26065. }
  26066. return *v, true
  26067. }
  26068. // OldMsg returns the old "msg" field's value of the Msg entity.
  26069. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26071. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  26072. if !m.op.Is(OpUpdateOne) {
  26073. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  26074. }
  26075. if m.id == nil || m.oldValue == nil {
  26076. return v, errors.New("OldMsg requires an ID field in the mutation")
  26077. }
  26078. oldValue, err := m.oldValue(ctx)
  26079. if err != nil {
  26080. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  26081. }
  26082. return oldValue.Msg, nil
  26083. }
  26084. // ClearMsg clears the value of the "msg" field.
  26085. func (m *MsgMutation) ClearMsg() {
  26086. m.msg = nil
  26087. m.clearedFields[msg.FieldMsg] = struct{}{}
  26088. }
  26089. // MsgCleared returns if the "msg" field was cleared in this mutation.
  26090. func (m *MsgMutation) MsgCleared() bool {
  26091. _, ok := m.clearedFields[msg.FieldMsg]
  26092. return ok
  26093. }
  26094. // ResetMsg resets all changes to the "msg" field.
  26095. func (m *MsgMutation) ResetMsg() {
  26096. m.msg = nil
  26097. delete(m.clearedFields, msg.FieldMsg)
  26098. }
  26099. // SetBatchNo sets the "batch_no" field.
  26100. func (m *MsgMutation) SetBatchNo(s string) {
  26101. m.batch_no = &s
  26102. }
  26103. // BatchNo returns the value of the "batch_no" field in the mutation.
  26104. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  26105. v := m.batch_no
  26106. if v == nil {
  26107. return
  26108. }
  26109. return *v, true
  26110. }
  26111. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  26112. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26114. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  26115. if !m.op.Is(OpUpdateOne) {
  26116. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  26117. }
  26118. if m.id == nil || m.oldValue == nil {
  26119. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  26120. }
  26121. oldValue, err := m.oldValue(ctx)
  26122. if err != nil {
  26123. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  26124. }
  26125. return oldValue.BatchNo, nil
  26126. }
  26127. // ClearBatchNo clears the value of the "batch_no" field.
  26128. func (m *MsgMutation) ClearBatchNo() {
  26129. m.batch_no = nil
  26130. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  26131. }
  26132. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  26133. func (m *MsgMutation) BatchNoCleared() bool {
  26134. _, ok := m.clearedFields[msg.FieldBatchNo]
  26135. return ok
  26136. }
  26137. // ResetBatchNo resets all changes to the "batch_no" field.
  26138. func (m *MsgMutation) ResetBatchNo() {
  26139. m.batch_no = nil
  26140. delete(m.clearedFields, msg.FieldBatchNo)
  26141. }
  26142. // SetCc sets the "cc" field.
  26143. func (m *MsgMutation) SetCc(s string) {
  26144. m.cc = &s
  26145. }
  26146. // Cc returns the value of the "cc" field in the mutation.
  26147. func (m *MsgMutation) Cc() (r string, exists bool) {
  26148. v := m.cc
  26149. if v == nil {
  26150. return
  26151. }
  26152. return *v, true
  26153. }
  26154. // OldCc returns the old "cc" field's value of the Msg entity.
  26155. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26157. func (m *MsgMutation) OldCc(ctx context.Context) (v string, err error) {
  26158. if !m.op.Is(OpUpdateOne) {
  26159. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  26160. }
  26161. if m.id == nil || m.oldValue == nil {
  26162. return v, errors.New("OldCc requires an ID field in the mutation")
  26163. }
  26164. oldValue, err := m.oldValue(ctx)
  26165. if err != nil {
  26166. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  26167. }
  26168. return oldValue.Cc, nil
  26169. }
  26170. // ResetCc resets all changes to the "cc" field.
  26171. func (m *MsgMutation) ResetCc() {
  26172. m.cc = nil
  26173. }
  26174. // SetPhone sets the "phone" field.
  26175. func (m *MsgMutation) SetPhone(s string) {
  26176. m.phone = &s
  26177. }
  26178. // Phone returns the value of the "phone" field in the mutation.
  26179. func (m *MsgMutation) Phone() (r string, exists bool) {
  26180. v := m.phone
  26181. if v == nil {
  26182. return
  26183. }
  26184. return *v, true
  26185. }
  26186. // OldPhone returns the old "phone" field's value of the Msg entity.
  26187. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  26188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26189. func (m *MsgMutation) OldPhone(ctx context.Context) (v string, err error) {
  26190. if !m.op.Is(OpUpdateOne) {
  26191. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  26192. }
  26193. if m.id == nil || m.oldValue == nil {
  26194. return v, errors.New("OldPhone requires an ID field in the mutation")
  26195. }
  26196. oldValue, err := m.oldValue(ctx)
  26197. if err != nil {
  26198. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  26199. }
  26200. return oldValue.Phone, nil
  26201. }
  26202. // ResetPhone resets all changes to the "phone" field.
  26203. func (m *MsgMutation) ResetPhone() {
  26204. m.phone = nil
  26205. }
  26206. // Where appends a list predicates to the MsgMutation builder.
  26207. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  26208. m.predicates = append(m.predicates, ps...)
  26209. }
  26210. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  26211. // users can use type-assertion to append predicates that do not depend on any generated package.
  26212. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  26213. p := make([]predicate.Msg, len(ps))
  26214. for i := range ps {
  26215. p[i] = ps[i]
  26216. }
  26217. m.Where(p...)
  26218. }
  26219. // Op returns the operation name.
  26220. func (m *MsgMutation) Op() Op {
  26221. return m.op
  26222. }
  26223. // SetOp allows setting the mutation operation.
  26224. func (m *MsgMutation) SetOp(op Op) {
  26225. m.op = op
  26226. }
  26227. // Type returns the node type of this mutation (Msg).
  26228. func (m *MsgMutation) Type() string {
  26229. return m.typ
  26230. }
  26231. // Fields returns all fields that were changed during this mutation. Note that in
  26232. // order to get all numeric fields that were incremented/decremented, call
  26233. // AddedFields().
  26234. func (m *MsgMutation) Fields() []string {
  26235. fields := make([]string, 0, 11)
  26236. if m.created_at != nil {
  26237. fields = append(fields, msg.FieldCreatedAt)
  26238. }
  26239. if m.updated_at != nil {
  26240. fields = append(fields, msg.FieldUpdatedAt)
  26241. }
  26242. if m.deleted_at != nil {
  26243. fields = append(fields, msg.FieldDeletedAt)
  26244. }
  26245. if m.status != nil {
  26246. fields = append(fields, msg.FieldStatus)
  26247. }
  26248. if m.fromwxid != nil {
  26249. fields = append(fields, msg.FieldFromwxid)
  26250. }
  26251. if m.toid != nil {
  26252. fields = append(fields, msg.FieldToid)
  26253. }
  26254. if m.msgtype != nil {
  26255. fields = append(fields, msg.FieldMsgtype)
  26256. }
  26257. if m.msg != nil {
  26258. fields = append(fields, msg.FieldMsg)
  26259. }
  26260. if m.batch_no != nil {
  26261. fields = append(fields, msg.FieldBatchNo)
  26262. }
  26263. if m.cc != nil {
  26264. fields = append(fields, msg.FieldCc)
  26265. }
  26266. if m.phone != nil {
  26267. fields = append(fields, msg.FieldPhone)
  26268. }
  26269. return fields
  26270. }
  26271. // Field returns the value of a field with the given name. The second boolean
  26272. // return value indicates that this field was not set, or was not defined in the
  26273. // schema.
  26274. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  26275. switch name {
  26276. case msg.FieldCreatedAt:
  26277. return m.CreatedAt()
  26278. case msg.FieldUpdatedAt:
  26279. return m.UpdatedAt()
  26280. case msg.FieldDeletedAt:
  26281. return m.DeletedAt()
  26282. case msg.FieldStatus:
  26283. return m.Status()
  26284. case msg.FieldFromwxid:
  26285. return m.Fromwxid()
  26286. case msg.FieldToid:
  26287. return m.Toid()
  26288. case msg.FieldMsgtype:
  26289. return m.Msgtype()
  26290. case msg.FieldMsg:
  26291. return m.Msg()
  26292. case msg.FieldBatchNo:
  26293. return m.BatchNo()
  26294. case msg.FieldCc:
  26295. return m.Cc()
  26296. case msg.FieldPhone:
  26297. return m.Phone()
  26298. }
  26299. return nil, false
  26300. }
  26301. // OldField returns the old value of the field from the database. An error is
  26302. // returned if the mutation operation is not UpdateOne, or the query to the
  26303. // database failed.
  26304. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26305. switch name {
  26306. case msg.FieldCreatedAt:
  26307. return m.OldCreatedAt(ctx)
  26308. case msg.FieldUpdatedAt:
  26309. return m.OldUpdatedAt(ctx)
  26310. case msg.FieldDeletedAt:
  26311. return m.OldDeletedAt(ctx)
  26312. case msg.FieldStatus:
  26313. return m.OldStatus(ctx)
  26314. case msg.FieldFromwxid:
  26315. return m.OldFromwxid(ctx)
  26316. case msg.FieldToid:
  26317. return m.OldToid(ctx)
  26318. case msg.FieldMsgtype:
  26319. return m.OldMsgtype(ctx)
  26320. case msg.FieldMsg:
  26321. return m.OldMsg(ctx)
  26322. case msg.FieldBatchNo:
  26323. return m.OldBatchNo(ctx)
  26324. case msg.FieldCc:
  26325. return m.OldCc(ctx)
  26326. case msg.FieldPhone:
  26327. return m.OldPhone(ctx)
  26328. }
  26329. return nil, fmt.Errorf("unknown Msg field %s", name)
  26330. }
  26331. // SetField sets the value of a field with the given name. It returns an error if
  26332. // the field is not defined in the schema, or if the type mismatched the field
  26333. // type.
  26334. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  26335. switch name {
  26336. case msg.FieldCreatedAt:
  26337. v, ok := value.(time.Time)
  26338. if !ok {
  26339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26340. }
  26341. m.SetCreatedAt(v)
  26342. return nil
  26343. case msg.FieldUpdatedAt:
  26344. v, ok := value.(time.Time)
  26345. if !ok {
  26346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26347. }
  26348. m.SetUpdatedAt(v)
  26349. return nil
  26350. case msg.FieldDeletedAt:
  26351. v, ok := value.(time.Time)
  26352. if !ok {
  26353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26354. }
  26355. m.SetDeletedAt(v)
  26356. return nil
  26357. case msg.FieldStatus:
  26358. v, ok := value.(uint8)
  26359. if !ok {
  26360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26361. }
  26362. m.SetStatus(v)
  26363. return nil
  26364. case msg.FieldFromwxid:
  26365. v, ok := value.(string)
  26366. if !ok {
  26367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26368. }
  26369. m.SetFromwxid(v)
  26370. return nil
  26371. case msg.FieldToid:
  26372. v, ok := value.(string)
  26373. if !ok {
  26374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26375. }
  26376. m.SetToid(v)
  26377. return nil
  26378. case msg.FieldMsgtype:
  26379. v, ok := value.(int32)
  26380. if !ok {
  26381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26382. }
  26383. m.SetMsgtype(v)
  26384. return nil
  26385. case msg.FieldMsg:
  26386. v, ok := value.(string)
  26387. if !ok {
  26388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26389. }
  26390. m.SetMsg(v)
  26391. return nil
  26392. case msg.FieldBatchNo:
  26393. v, ok := value.(string)
  26394. if !ok {
  26395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26396. }
  26397. m.SetBatchNo(v)
  26398. return nil
  26399. case msg.FieldCc:
  26400. v, ok := value.(string)
  26401. if !ok {
  26402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26403. }
  26404. m.SetCc(v)
  26405. return nil
  26406. case msg.FieldPhone:
  26407. v, ok := value.(string)
  26408. if !ok {
  26409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26410. }
  26411. m.SetPhone(v)
  26412. return nil
  26413. }
  26414. return fmt.Errorf("unknown Msg field %s", name)
  26415. }
  26416. // AddedFields returns all numeric fields that were incremented/decremented during
  26417. // this mutation.
  26418. func (m *MsgMutation) AddedFields() []string {
  26419. var fields []string
  26420. if m.addstatus != nil {
  26421. fields = append(fields, msg.FieldStatus)
  26422. }
  26423. if m.addmsgtype != nil {
  26424. fields = append(fields, msg.FieldMsgtype)
  26425. }
  26426. return fields
  26427. }
  26428. // AddedField returns the numeric value that was incremented/decremented on a field
  26429. // with the given name. The second boolean return value indicates that this field
  26430. // was not set, or was not defined in the schema.
  26431. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  26432. switch name {
  26433. case msg.FieldStatus:
  26434. return m.AddedStatus()
  26435. case msg.FieldMsgtype:
  26436. return m.AddedMsgtype()
  26437. }
  26438. return nil, false
  26439. }
  26440. // AddField adds the value to the field with the given name. It returns an error if
  26441. // the field is not defined in the schema, or if the type mismatched the field
  26442. // type.
  26443. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  26444. switch name {
  26445. case msg.FieldStatus:
  26446. v, ok := value.(int8)
  26447. if !ok {
  26448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26449. }
  26450. m.AddStatus(v)
  26451. return nil
  26452. case msg.FieldMsgtype:
  26453. v, ok := value.(int32)
  26454. if !ok {
  26455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26456. }
  26457. m.AddMsgtype(v)
  26458. return nil
  26459. }
  26460. return fmt.Errorf("unknown Msg numeric field %s", name)
  26461. }
  26462. // ClearedFields returns all nullable fields that were cleared during this
  26463. // mutation.
  26464. func (m *MsgMutation) ClearedFields() []string {
  26465. var fields []string
  26466. if m.FieldCleared(msg.FieldDeletedAt) {
  26467. fields = append(fields, msg.FieldDeletedAt)
  26468. }
  26469. if m.FieldCleared(msg.FieldStatus) {
  26470. fields = append(fields, msg.FieldStatus)
  26471. }
  26472. if m.FieldCleared(msg.FieldFromwxid) {
  26473. fields = append(fields, msg.FieldFromwxid)
  26474. }
  26475. if m.FieldCleared(msg.FieldToid) {
  26476. fields = append(fields, msg.FieldToid)
  26477. }
  26478. if m.FieldCleared(msg.FieldMsgtype) {
  26479. fields = append(fields, msg.FieldMsgtype)
  26480. }
  26481. if m.FieldCleared(msg.FieldMsg) {
  26482. fields = append(fields, msg.FieldMsg)
  26483. }
  26484. if m.FieldCleared(msg.FieldBatchNo) {
  26485. fields = append(fields, msg.FieldBatchNo)
  26486. }
  26487. return fields
  26488. }
  26489. // FieldCleared returns a boolean indicating if a field with the given name was
  26490. // cleared in this mutation.
  26491. func (m *MsgMutation) FieldCleared(name string) bool {
  26492. _, ok := m.clearedFields[name]
  26493. return ok
  26494. }
  26495. // ClearField clears the value of the field with the given name. It returns an
  26496. // error if the field is not defined in the schema.
  26497. func (m *MsgMutation) ClearField(name string) error {
  26498. switch name {
  26499. case msg.FieldDeletedAt:
  26500. m.ClearDeletedAt()
  26501. return nil
  26502. case msg.FieldStatus:
  26503. m.ClearStatus()
  26504. return nil
  26505. case msg.FieldFromwxid:
  26506. m.ClearFromwxid()
  26507. return nil
  26508. case msg.FieldToid:
  26509. m.ClearToid()
  26510. return nil
  26511. case msg.FieldMsgtype:
  26512. m.ClearMsgtype()
  26513. return nil
  26514. case msg.FieldMsg:
  26515. m.ClearMsg()
  26516. return nil
  26517. case msg.FieldBatchNo:
  26518. m.ClearBatchNo()
  26519. return nil
  26520. }
  26521. return fmt.Errorf("unknown Msg nullable field %s", name)
  26522. }
  26523. // ResetField resets all changes in the mutation for the field with the given name.
  26524. // It returns an error if the field is not defined in the schema.
  26525. func (m *MsgMutation) ResetField(name string) error {
  26526. switch name {
  26527. case msg.FieldCreatedAt:
  26528. m.ResetCreatedAt()
  26529. return nil
  26530. case msg.FieldUpdatedAt:
  26531. m.ResetUpdatedAt()
  26532. return nil
  26533. case msg.FieldDeletedAt:
  26534. m.ResetDeletedAt()
  26535. return nil
  26536. case msg.FieldStatus:
  26537. m.ResetStatus()
  26538. return nil
  26539. case msg.FieldFromwxid:
  26540. m.ResetFromwxid()
  26541. return nil
  26542. case msg.FieldToid:
  26543. m.ResetToid()
  26544. return nil
  26545. case msg.FieldMsgtype:
  26546. m.ResetMsgtype()
  26547. return nil
  26548. case msg.FieldMsg:
  26549. m.ResetMsg()
  26550. return nil
  26551. case msg.FieldBatchNo:
  26552. m.ResetBatchNo()
  26553. return nil
  26554. case msg.FieldCc:
  26555. m.ResetCc()
  26556. return nil
  26557. case msg.FieldPhone:
  26558. m.ResetPhone()
  26559. return nil
  26560. }
  26561. return fmt.Errorf("unknown Msg field %s", name)
  26562. }
  26563. // AddedEdges returns all edge names that were set/added in this mutation.
  26564. func (m *MsgMutation) AddedEdges() []string {
  26565. edges := make([]string, 0, 0)
  26566. return edges
  26567. }
  26568. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26569. // name in this mutation.
  26570. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  26571. return nil
  26572. }
  26573. // RemovedEdges returns all edge names that were removed in this mutation.
  26574. func (m *MsgMutation) RemovedEdges() []string {
  26575. edges := make([]string, 0, 0)
  26576. return edges
  26577. }
  26578. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26579. // the given name in this mutation.
  26580. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  26581. return nil
  26582. }
  26583. // ClearedEdges returns all edge names that were cleared in this mutation.
  26584. func (m *MsgMutation) ClearedEdges() []string {
  26585. edges := make([]string, 0, 0)
  26586. return edges
  26587. }
  26588. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26589. // was cleared in this mutation.
  26590. func (m *MsgMutation) EdgeCleared(name string) bool {
  26591. return false
  26592. }
  26593. // ClearEdge clears the value of the edge with the given name. It returns an error
  26594. // if that edge is not defined in the schema.
  26595. func (m *MsgMutation) ClearEdge(name string) error {
  26596. return fmt.Errorf("unknown Msg unique edge %s", name)
  26597. }
  26598. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26599. // It returns an error if the edge is not defined in the schema.
  26600. func (m *MsgMutation) ResetEdge(name string) error {
  26601. return fmt.Errorf("unknown Msg edge %s", name)
  26602. }
  26603. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  26604. type PayRechargeMutation struct {
  26605. config
  26606. op Op
  26607. typ string
  26608. id *uint64
  26609. created_at *time.Time
  26610. updated_at *time.Time
  26611. deleted_at *time.Time
  26612. user_id *string
  26613. number *float32
  26614. addnumber *float32
  26615. status *int
  26616. addstatus *int
  26617. money *float32
  26618. addmoney *float32
  26619. out_trade_no *string
  26620. organization_id *uint64
  26621. addorganization_id *int64
  26622. clearedFields map[string]struct{}
  26623. done bool
  26624. oldValue func(context.Context) (*PayRecharge, error)
  26625. predicates []predicate.PayRecharge
  26626. }
  26627. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  26628. // payrechargeOption allows management of the mutation configuration using functional options.
  26629. type payrechargeOption func(*PayRechargeMutation)
  26630. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  26631. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  26632. m := &PayRechargeMutation{
  26633. config: c,
  26634. op: op,
  26635. typ: TypePayRecharge,
  26636. clearedFields: make(map[string]struct{}),
  26637. }
  26638. for _, opt := range opts {
  26639. opt(m)
  26640. }
  26641. return m
  26642. }
  26643. // withPayRechargeID sets the ID field of the mutation.
  26644. func withPayRechargeID(id uint64) payrechargeOption {
  26645. return func(m *PayRechargeMutation) {
  26646. var (
  26647. err error
  26648. once sync.Once
  26649. value *PayRecharge
  26650. )
  26651. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  26652. once.Do(func() {
  26653. if m.done {
  26654. err = errors.New("querying old values post mutation is not allowed")
  26655. } else {
  26656. value, err = m.Client().PayRecharge.Get(ctx, id)
  26657. }
  26658. })
  26659. return value, err
  26660. }
  26661. m.id = &id
  26662. }
  26663. }
  26664. // withPayRecharge sets the old PayRecharge of the mutation.
  26665. func withPayRecharge(node *PayRecharge) payrechargeOption {
  26666. return func(m *PayRechargeMutation) {
  26667. m.oldValue = func(context.Context) (*PayRecharge, error) {
  26668. return node, nil
  26669. }
  26670. m.id = &node.ID
  26671. }
  26672. }
  26673. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26674. // executed in a transaction (ent.Tx), a transactional client is returned.
  26675. func (m PayRechargeMutation) Client() *Client {
  26676. client := &Client{config: m.config}
  26677. client.init()
  26678. return client
  26679. }
  26680. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26681. // it returns an error otherwise.
  26682. func (m PayRechargeMutation) Tx() (*Tx, error) {
  26683. if _, ok := m.driver.(*txDriver); !ok {
  26684. return nil, errors.New("ent: mutation is not running in a transaction")
  26685. }
  26686. tx := &Tx{config: m.config}
  26687. tx.init()
  26688. return tx, nil
  26689. }
  26690. // SetID sets the value of the id field. Note that this
  26691. // operation is only accepted on creation of PayRecharge entities.
  26692. func (m *PayRechargeMutation) SetID(id uint64) {
  26693. m.id = &id
  26694. }
  26695. // ID returns the ID value in the mutation. Note that the ID is only available
  26696. // if it was provided to the builder or after it was returned from the database.
  26697. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  26698. if m.id == nil {
  26699. return
  26700. }
  26701. return *m.id, true
  26702. }
  26703. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26704. // That means, if the mutation is applied within a transaction with an isolation level such
  26705. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26706. // or updated by the mutation.
  26707. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  26708. switch {
  26709. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26710. id, exists := m.ID()
  26711. if exists {
  26712. return []uint64{id}, nil
  26713. }
  26714. fallthrough
  26715. case m.op.Is(OpUpdate | OpDelete):
  26716. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  26717. default:
  26718. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26719. }
  26720. }
  26721. // SetCreatedAt sets the "created_at" field.
  26722. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  26723. m.created_at = &t
  26724. }
  26725. // CreatedAt returns the value of the "created_at" field in the mutation.
  26726. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  26727. v := m.created_at
  26728. if v == nil {
  26729. return
  26730. }
  26731. return *v, true
  26732. }
  26733. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  26734. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26736. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26737. if !m.op.Is(OpUpdateOne) {
  26738. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26739. }
  26740. if m.id == nil || m.oldValue == nil {
  26741. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26742. }
  26743. oldValue, err := m.oldValue(ctx)
  26744. if err != nil {
  26745. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26746. }
  26747. return oldValue.CreatedAt, nil
  26748. }
  26749. // ResetCreatedAt resets all changes to the "created_at" field.
  26750. func (m *PayRechargeMutation) ResetCreatedAt() {
  26751. m.created_at = nil
  26752. }
  26753. // SetUpdatedAt sets the "updated_at" field.
  26754. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  26755. m.updated_at = &t
  26756. }
  26757. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26758. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  26759. v := m.updated_at
  26760. if v == nil {
  26761. return
  26762. }
  26763. return *v, true
  26764. }
  26765. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  26766. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26767. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26768. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26769. if !m.op.Is(OpUpdateOne) {
  26770. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26771. }
  26772. if m.id == nil || m.oldValue == nil {
  26773. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26774. }
  26775. oldValue, err := m.oldValue(ctx)
  26776. if err != nil {
  26777. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26778. }
  26779. return oldValue.UpdatedAt, nil
  26780. }
  26781. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26782. func (m *PayRechargeMutation) ResetUpdatedAt() {
  26783. m.updated_at = nil
  26784. }
  26785. // SetDeletedAt sets the "deleted_at" field.
  26786. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  26787. m.deleted_at = &t
  26788. }
  26789. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26790. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  26791. v := m.deleted_at
  26792. if v == nil {
  26793. return
  26794. }
  26795. return *v, true
  26796. }
  26797. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  26798. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26800. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26801. if !m.op.Is(OpUpdateOne) {
  26802. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26803. }
  26804. if m.id == nil || m.oldValue == nil {
  26805. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26806. }
  26807. oldValue, err := m.oldValue(ctx)
  26808. if err != nil {
  26809. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26810. }
  26811. return oldValue.DeletedAt, nil
  26812. }
  26813. // ClearDeletedAt clears the value of the "deleted_at" field.
  26814. func (m *PayRechargeMutation) ClearDeletedAt() {
  26815. m.deleted_at = nil
  26816. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  26817. }
  26818. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26819. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  26820. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  26821. return ok
  26822. }
  26823. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26824. func (m *PayRechargeMutation) ResetDeletedAt() {
  26825. m.deleted_at = nil
  26826. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  26827. }
  26828. // SetUserID sets the "user_id" field.
  26829. func (m *PayRechargeMutation) SetUserID(s string) {
  26830. m.user_id = &s
  26831. }
  26832. // UserID returns the value of the "user_id" field in the mutation.
  26833. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  26834. v := m.user_id
  26835. if v == nil {
  26836. return
  26837. }
  26838. return *v, true
  26839. }
  26840. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  26841. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26843. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  26844. if !m.op.Is(OpUpdateOne) {
  26845. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  26846. }
  26847. if m.id == nil || m.oldValue == nil {
  26848. return v, errors.New("OldUserID requires an ID field in the mutation")
  26849. }
  26850. oldValue, err := m.oldValue(ctx)
  26851. if err != nil {
  26852. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  26853. }
  26854. return oldValue.UserID, nil
  26855. }
  26856. // ResetUserID resets all changes to the "user_id" field.
  26857. func (m *PayRechargeMutation) ResetUserID() {
  26858. m.user_id = nil
  26859. }
  26860. // SetNumber sets the "number" field.
  26861. func (m *PayRechargeMutation) SetNumber(f float32) {
  26862. m.number = &f
  26863. m.addnumber = nil
  26864. }
  26865. // Number returns the value of the "number" field in the mutation.
  26866. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  26867. v := m.number
  26868. if v == nil {
  26869. return
  26870. }
  26871. return *v, true
  26872. }
  26873. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  26874. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26876. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  26877. if !m.op.Is(OpUpdateOne) {
  26878. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  26879. }
  26880. if m.id == nil || m.oldValue == nil {
  26881. return v, errors.New("OldNumber requires an ID field in the mutation")
  26882. }
  26883. oldValue, err := m.oldValue(ctx)
  26884. if err != nil {
  26885. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  26886. }
  26887. return oldValue.Number, nil
  26888. }
  26889. // AddNumber adds f to the "number" field.
  26890. func (m *PayRechargeMutation) AddNumber(f float32) {
  26891. if m.addnumber != nil {
  26892. *m.addnumber += f
  26893. } else {
  26894. m.addnumber = &f
  26895. }
  26896. }
  26897. // AddedNumber returns the value that was added to the "number" field in this mutation.
  26898. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  26899. v := m.addnumber
  26900. if v == nil {
  26901. return
  26902. }
  26903. return *v, true
  26904. }
  26905. // ResetNumber resets all changes to the "number" field.
  26906. func (m *PayRechargeMutation) ResetNumber() {
  26907. m.number = nil
  26908. m.addnumber = nil
  26909. }
  26910. // SetStatus sets the "status" field.
  26911. func (m *PayRechargeMutation) SetStatus(i int) {
  26912. m.status = &i
  26913. m.addstatus = nil
  26914. }
  26915. // Status returns the value of the "status" field in the mutation.
  26916. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  26917. v := m.status
  26918. if v == nil {
  26919. return
  26920. }
  26921. return *v, true
  26922. }
  26923. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  26924. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26926. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  26927. if !m.op.Is(OpUpdateOne) {
  26928. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26929. }
  26930. if m.id == nil || m.oldValue == nil {
  26931. return v, errors.New("OldStatus requires an ID field in the mutation")
  26932. }
  26933. oldValue, err := m.oldValue(ctx)
  26934. if err != nil {
  26935. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26936. }
  26937. return oldValue.Status, nil
  26938. }
  26939. // AddStatus adds i to the "status" field.
  26940. func (m *PayRechargeMutation) AddStatus(i int) {
  26941. if m.addstatus != nil {
  26942. *m.addstatus += i
  26943. } else {
  26944. m.addstatus = &i
  26945. }
  26946. }
  26947. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26948. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  26949. v := m.addstatus
  26950. if v == nil {
  26951. return
  26952. }
  26953. return *v, true
  26954. }
  26955. // ClearStatus clears the value of the "status" field.
  26956. func (m *PayRechargeMutation) ClearStatus() {
  26957. m.status = nil
  26958. m.addstatus = nil
  26959. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  26960. }
  26961. // StatusCleared returns if the "status" field was cleared in this mutation.
  26962. func (m *PayRechargeMutation) StatusCleared() bool {
  26963. _, ok := m.clearedFields[payrecharge.FieldStatus]
  26964. return ok
  26965. }
  26966. // ResetStatus resets all changes to the "status" field.
  26967. func (m *PayRechargeMutation) ResetStatus() {
  26968. m.status = nil
  26969. m.addstatus = nil
  26970. delete(m.clearedFields, payrecharge.FieldStatus)
  26971. }
  26972. // SetMoney sets the "money" field.
  26973. func (m *PayRechargeMutation) SetMoney(f float32) {
  26974. m.money = &f
  26975. m.addmoney = nil
  26976. }
  26977. // Money returns the value of the "money" field in the mutation.
  26978. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  26979. v := m.money
  26980. if v == nil {
  26981. return
  26982. }
  26983. return *v, true
  26984. }
  26985. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  26986. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  26987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26988. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  26989. if !m.op.Is(OpUpdateOne) {
  26990. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  26991. }
  26992. if m.id == nil || m.oldValue == nil {
  26993. return v, errors.New("OldMoney requires an ID field in the mutation")
  26994. }
  26995. oldValue, err := m.oldValue(ctx)
  26996. if err != nil {
  26997. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  26998. }
  26999. return oldValue.Money, nil
  27000. }
  27001. // AddMoney adds f to the "money" field.
  27002. func (m *PayRechargeMutation) AddMoney(f float32) {
  27003. if m.addmoney != nil {
  27004. *m.addmoney += f
  27005. } else {
  27006. m.addmoney = &f
  27007. }
  27008. }
  27009. // AddedMoney returns the value that was added to the "money" field in this mutation.
  27010. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  27011. v := m.addmoney
  27012. if v == nil {
  27013. return
  27014. }
  27015. return *v, true
  27016. }
  27017. // ClearMoney clears the value of the "money" field.
  27018. func (m *PayRechargeMutation) ClearMoney() {
  27019. m.money = nil
  27020. m.addmoney = nil
  27021. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  27022. }
  27023. // MoneyCleared returns if the "money" field was cleared in this mutation.
  27024. func (m *PayRechargeMutation) MoneyCleared() bool {
  27025. _, ok := m.clearedFields[payrecharge.FieldMoney]
  27026. return ok
  27027. }
  27028. // ResetMoney resets all changes to the "money" field.
  27029. func (m *PayRechargeMutation) ResetMoney() {
  27030. m.money = nil
  27031. m.addmoney = nil
  27032. delete(m.clearedFields, payrecharge.FieldMoney)
  27033. }
  27034. // SetOutTradeNo sets the "out_trade_no" field.
  27035. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  27036. m.out_trade_no = &s
  27037. }
  27038. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  27039. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  27040. v := m.out_trade_no
  27041. if v == nil {
  27042. return
  27043. }
  27044. return *v, true
  27045. }
  27046. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  27047. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27049. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  27050. if !m.op.Is(OpUpdateOne) {
  27051. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  27052. }
  27053. if m.id == nil || m.oldValue == nil {
  27054. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  27055. }
  27056. oldValue, err := m.oldValue(ctx)
  27057. if err != nil {
  27058. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  27059. }
  27060. return oldValue.OutTradeNo, nil
  27061. }
  27062. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  27063. func (m *PayRechargeMutation) ClearOutTradeNo() {
  27064. m.out_trade_no = nil
  27065. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  27066. }
  27067. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  27068. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  27069. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  27070. return ok
  27071. }
  27072. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  27073. func (m *PayRechargeMutation) ResetOutTradeNo() {
  27074. m.out_trade_no = nil
  27075. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  27076. }
  27077. // SetOrganizationID sets the "organization_id" field.
  27078. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  27079. m.organization_id = &u
  27080. m.addorganization_id = nil
  27081. }
  27082. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27083. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  27084. v := m.organization_id
  27085. if v == nil {
  27086. return
  27087. }
  27088. return *v, true
  27089. }
  27090. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  27091. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  27092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27093. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27094. if !m.op.Is(OpUpdateOne) {
  27095. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27096. }
  27097. if m.id == nil || m.oldValue == nil {
  27098. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27099. }
  27100. oldValue, err := m.oldValue(ctx)
  27101. if err != nil {
  27102. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27103. }
  27104. return oldValue.OrganizationID, nil
  27105. }
  27106. // AddOrganizationID adds u to the "organization_id" field.
  27107. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  27108. if m.addorganization_id != nil {
  27109. *m.addorganization_id += u
  27110. } else {
  27111. m.addorganization_id = &u
  27112. }
  27113. }
  27114. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27115. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  27116. v := m.addorganization_id
  27117. if v == nil {
  27118. return
  27119. }
  27120. return *v, true
  27121. }
  27122. // ResetOrganizationID resets all changes to the "organization_id" field.
  27123. func (m *PayRechargeMutation) ResetOrganizationID() {
  27124. m.organization_id = nil
  27125. m.addorganization_id = nil
  27126. }
  27127. // Where appends a list predicates to the PayRechargeMutation builder.
  27128. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  27129. m.predicates = append(m.predicates, ps...)
  27130. }
  27131. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  27132. // users can use type-assertion to append predicates that do not depend on any generated package.
  27133. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  27134. p := make([]predicate.PayRecharge, len(ps))
  27135. for i := range ps {
  27136. p[i] = ps[i]
  27137. }
  27138. m.Where(p...)
  27139. }
  27140. // Op returns the operation name.
  27141. func (m *PayRechargeMutation) Op() Op {
  27142. return m.op
  27143. }
  27144. // SetOp allows setting the mutation operation.
  27145. func (m *PayRechargeMutation) SetOp(op Op) {
  27146. m.op = op
  27147. }
  27148. // Type returns the node type of this mutation (PayRecharge).
  27149. func (m *PayRechargeMutation) Type() string {
  27150. return m.typ
  27151. }
  27152. // Fields returns all fields that were changed during this mutation. Note that in
  27153. // order to get all numeric fields that were incremented/decremented, call
  27154. // AddedFields().
  27155. func (m *PayRechargeMutation) Fields() []string {
  27156. fields := make([]string, 0, 9)
  27157. if m.created_at != nil {
  27158. fields = append(fields, payrecharge.FieldCreatedAt)
  27159. }
  27160. if m.updated_at != nil {
  27161. fields = append(fields, payrecharge.FieldUpdatedAt)
  27162. }
  27163. if m.deleted_at != nil {
  27164. fields = append(fields, payrecharge.FieldDeletedAt)
  27165. }
  27166. if m.user_id != nil {
  27167. fields = append(fields, payrecharge.FieldUserID)
  27168. }
  27169. if m.number != nil {
  27170. fields = append(fields, payrecharge.FieldNumber)
  27171. }
  27172. if m.status != nil {
  27173. fields = append(fields, payrecharge.FieldStatus)
  27174. }
  27175. if m.money != nil {
  27176. fields = append(fields, payrecharge.FieldMoney)
  27177. }
  27178. if m.out_trade_no != nil {
  27179. fields = append(fields, payrecharge.FieldOutTradeNo)
  27180. }
  27181. if m.organization_id != nil {
  27182. fields = append(fields, payrecharge.FieldOrganizationID)
  27183. }
  27184. return fields
  27185. }
  27186. // Field returns the value of a field with the given name. The second boolean
  27187. // return value indicates that this field was not set, or was not defined in the
  27188. // schema.
  27189. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  27190. switch name {
  27191. case payrecharge.FieldCreatedAt:
  27192. return m.CreatedAt()
  27193. case payrecharge.FieldUpdatedAt:
  27194. return m.UpdatedAt()
  27195. case payrecharge.FieldDeletedAt:
  27196. return m.DeletedAt()
  27197. case payrecharge.FieldUserID:
  27198. return m.UserID()
  27199. case payrecharge.FieldNumber:
  27200. return m.Number()
  27201. case payrecharge.FieldStatus:
  27202. return m.Status()
  27203. case payrecharge.FieldMoney:
  27204. return m.Money()
  27205. case payrecharge.FieldOutTradeNo:
  27206. return m.OutTradeNo()
  27207. case payrecharge.FieldOrganizationID:
  27208. return m.OrganizationID()
  27209. }
  27210. return nil, false
  27211. }
  27212. // OldField returns the old value of the field from the database. An error is
  27213. // returned if the mutation operation is not UpdateOne, or the query to the
  27214. // database failed.
  27215. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27216. switch name {
  27217. case payrecharge.FieldCreatedAt:
  27218. return m.OldCreatedAt(ctx)
  27219. case payrecharge.FieldUpdatedAt:
  27220. return m.OldUpdatedAt(ctx)
  27221. case payrecharge.FieldDeletedAt:
  27222. return m.OldDeletedAt(ctx)
  27223. case payrecharge.FieldUserID:
  27224. return m.OldUserID(ctx)
  27225. case payrecharge.FieldNumber:
  27226. return m.OldNumber(ctx)
  27227. case payrecharge.FieldStatus:
  27228. return m.OldStatus(ctx)
  27229. case payrecharge.FieldMoney:
  27230. return m.OldMoney(ctx)
  27231. case payrecharge.FieldOutTradeNo:
  27232. return m.OldOutTradeNo(ctx)
  27233. case payrecharge.FieldOrganizationID:
  27234. return m.OldOrganizationID(ctx)
  27235. }
  27236. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  27237. }
  27238. // SetField sets the value of a field with the given name. It returns an error if
  27239. // the field is not defined in the schema, or if the type mismatched the field
  27240. // type.
  27241. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  27242. switch name {
  27243. case payrecharge.FieldCreatedAt:
  27244. v, ok := value.(time.Time)
  27245. if !ok {
  27246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27247. }
  27248. m.SetCreatedAt(v)
  27249. return nil
  27250. case payrecharge.FieldUpdatedAt:
  27251. v, ok := value.(time.Time)
  27252. if !ok {
  27253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27254. }
  27255. m.SetUpdatedAt(v)
  27256. return nil
  27257. case payrecharge.FieldDeletedAt:
  27258. v, ok := value.(time.Time)
  27259. if !ok {
  27260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27261. }
  27262. m.SetDeletedAt(v)
  27263. return nil
  27264. case payrecharge.FieldUserID:
  27265. v, ok := value.(string)
  27266. if !ok {
  27267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27268. }
  27269. m.SetUserID(v)
  27270. return nil
  27271. case payrecharge.FieldNumber:
  27272. v, ok := value.(float32)
  27273. if !ok {
  27274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27275. }
  27276. m.SetNumber(v)
  27277. return nil
  27278. case payrecharge.FieldStatus:
  27279. v, ok := value.(int)
  27280. if !ok {
  27281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27282. }
  27283. m.SetStatus(v)
  27284. return nil
  27285. case payrecharge.FieldMoney:
  27286. v, ok := value.(float32)
  27287. if !ok {
  27288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27289. }
  27290. m.SetMoney(v)
  27291. return nil
  27292. case payrecharge.FieldOutTradeNo:
  27293. v, ok := value.(string)
  27294. if !ok {
  27295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27296. }
  27297. m.SetOutTradeNo(v)
  27298. return nil
  27299. case payrecharge.FieldOrganizationID:
  27300. v, ok := value.(uint64)
  27301. if !ok {
  27302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27303. }
  27304. m.SetOrganizationID(v)
  27305. return nil
  27306. }
  27307. return fmt.Errorf("unknown PayRecharge field %s", name)
  27308. }
  27309. // AddedFields returns all numeric fields that were incremented/decremented during
  27310. // this mutation.
  27311. func (m *PayRechargeMutation) AddedFields() []string {
  27312. var fields []string
  27313. if m.addnumber != nil {
  27314. fields = append(fields, payrecharge.FieldNumber)
  27315. }
  27316. if m.addstatus != nil {
  27317. fields = append(fields, payrecharge.FieldStatus)
  27318. }
  27319. if m.addmoney != nil {
  27320. fields = append(fields, payrecharge.FieldMoney)
  27321. }
  27322. if m.addorganization_id != nil {
  27323. fields = append(fields, payrecharge.FieldOrganizationID)
  27324. }
  27325. return fields
  27326. }
  27327. // AddedField returns the numeric value that was incremented/decremented on a field
  27328. // with the given name. The second boolean return value indicates that this field
  27329. // was not set, or was not defined in the schema.
  27330. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  27331. switch name {
  27332. case payrecharge.FieldNumber:
  27333. return m.AddedNumber()
  27334. case payrecharge.FieldStatus:
  27335. return m.AddedStatus()
  27336. case payrecharge.FieldMoney:
  27337. return m.AddedMoney()
  27338. case payrecharge.FieldOrganizationID:
  27339. return m.AddedOrganizationID()
  27340. }
  27341. return nil, false
  27342. }
  27343. // AddField adds the value to the field with the given name. It returns an error if
  27344. // the field is not defined in the schema, or if the type mismatched the field
  27345. // type.
  27346. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  27347. switch name {
  27348. case payrecharge.FieldNumber:
  27349. v, ok := value.(float32)
  27350. if !ok {
  27351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27352. }
  27353. m.AddNumber(v)
  27354. return nil
  27355. case payrecharge.FieldStatus:
  27356. v, ok := value.(int)
  27357. if !ok {
  27358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27359. }
  27360. m.AddStatus(v)
  27361. return nil
  27362. case payrecharge.FieldMoney:
  27363. v, ok := value.(float32)
  27364. if !ok {
  27365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27366. }
  27367. m.AddMoney(v)
  27368. return nil
  27369. case payrecharge.FieldOrganizationID:
  27370. v, ok := value.(int64)
  27371. if !ok {
  27372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27373. }
  27374. m.AddOrganizationID(v)
  27375. return nil
  27376. }
  27377. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  27378. }
  27379. // ClearedFields returns all nullable fields that were cleared during this
  27380. // mutation.
  27381. func (m *PayRechargeMutation) ClearedFields() []string {
  27382. var fields []string
  27383. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  27384. fields = append(fields, payrecharge.FieldDeletedAt)
  27385. }
  27386. if m.FieldCleared(payrecharge.FieldStatus) {
  27387. fields = append(fields, payrecharge.FieldStatus)
  27388. }
  27389. if m.FieldCleared(payrecharge.FieldMoney) {
  27390. fields = append(fields, payrecharge.FieldMoney)
  27391. }
  27392. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  27393. fields = append(fields, payrecharge.FieldOutTradeNo)
  27394. }
  27395. return fields
  27396. }
  27397. // FieldCleared returns a boolean indicating if a field with the given name was
  27398. // cleared in this mutation.
  27399. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  27400. _, ok := m.clearedFields[name]
  27401. return ok
  27402. }
  27403. // ClearField clears the value of the field with the given name. It returns an
  27404. // error if the field is not defined in the schema.
  27405. func (m *PayRechargeMutation) ClearField(name string) error {
  27406. switch name {
  27407. case payrecharge.FieldDeletedAt:
  27408. m.ClearDeletedAt()
  27409. return nil
  27410. case payrecharge.FieldStatus:
  27411. m.ClearStatus()
  27412. return nil
  27413. case payrecharge.FieldMoney:
  27414. m.ClearMoney()
  27415. return nil
  27416. case payrecharge.FieldOutTradeNo:
  27417. m.ClearOutTradeNo()
  27418. return nil
  27419. }
  27420. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  27421. }
  27422. // ResetField resets all changes in the mutation for the field with the given name.
  27423. // It returns an error if the field is not defined in the schema.
  27424. func (m *PayRechargeMutation) ResetField(name string) error {
  27425. switch name {
  27426. case payrecharge.FieldCreatedAt:
  27427. m.ResetCreatedAt()
  27428. return nil
  27429. case payrecharge.FieldUpdatedAt:
  27430. m.ResetUpdatedAt()
  27431. return nil
  27432. case payrecharge.FieldDeletedAt:
  27433. m.ResetDeletedAt()
  27434. return nil
  27435. case payrecharge.FieldUserID:
  27436. m.ResetUserID()
  27437. return nil
  27438. case payrecharge.FieldNumber:
  27439. m.ResetNumber()
  27440. return nil
  27441. case payrecharge.FieldStatus:
  27442. m.ResetStatus()
  27443. return nil
  27444. case payrecharge.FieldMoney:
  27445. m.ResetMoney()
  27446. return nil
  27447. case payrecharge.FieldOutTradeNo:
  27448. m.ResetOutTradeNo()
  27449. return nil
  27450. case payrecharge.FieldOrganizationID:
  27451. m.ResetOrganizationID()
  27452. return nil
  27453. }
  27454. return fmt.Errorf("unknown PayRecharge field %s", name)
  27455. }
  27456. // AddedEdges returns all edge names that were set/added in this mutation.
  27457. func (m *PayRechargeMutation) AddedEdges() []string {
  27458. edges := make([]string, 0, 0)
  27459. return edges
  27460. }
  27461. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27462. // name in this mutation.
  27463. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  27464. return nil
  27465. }
  27466. // RemovedEdges returns all edge names that were removed in this mutation.
  27467. func (m *PayRechargeMutation) RemovedEdges() []string {
  27468. edges := make([]string, 0, 0)
  27469. return edges
  27470. }
  27471. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27472. // the given name in this mutation.
  27473. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  27474. return nil
  27475. }
  27476. // ClearedEdges returns all edge names that were cleared in this mutation.
  27477. func (m *PayRechargeMutation) ClearedEdges() []string {
  27478. edges := make([]string, 0, 0)
  27479. return edges
  27480. }
  27481. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27482. // was cleared in this mutation.
  27483. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  27484. return false
  27485. }
  27486. // ClearEdge clears the value of the edge with the given name. It returns an error
  27487. // if that edge is not defined in the schema.
  27488. func (m *PayRechargeMutation) ClearEdge(name string) error {
  27489. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  27490. }
  27491. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27492. // It returns an error if the edge is not defined in the schema.
  27493. func (m *PayRechargeMutation) ResetEdge(name string) error {
  27494. return fmt.Errorf("unknown PayRecharge edge %s", name)
  27495. }
  27496. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  27497. type ServerMutation struct {
  27498. config
  27499. op Op
  27500. typ string
  27501. id *uint64
  27502. created_at *time.Time
  27503. updated_at *time.Time
  27504. status *uint8
  27505. addstatus *int8
  27506. deleted_at *time.Time
  27507. name *string
  27508. public_ip *string
  27509. private_ip *string
  27510. admin_port *string
  27511. clearedFields map[string]struct{}
  27512. wxs map[uint64]struct{}
  27513. removedwxs map[uint64]struct{}
  27514. clearedwxs bool
  27515. done bool
  27516. oldValue func(context.Context) (*Server, error)
  27517. predicates []predicate.Server
  27518. }
  27519. var _ ent.Mutation = (*ServerMutation)(nil)
  27520. // serverOption allows management of the mutation configuration using functional options.
  27521. type serverOption func(*ServerMutation)
  27522. // newServerMutation creates new mutation for the Server entity.
  27523. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  27524. m := &ServerMutation{
  27525. config: c,
  27526. op: op,
  27527. typ: TypeServer,
  27528. clearedFields: make(map[string]struct{}),
  27529. }
  27530. for _, opt := range opts {
  27531. opt(m)
  27532. }
  27533. return m
  27534. }
  27535. // withServerID sets the ID field of the mutation.
  27536. func withServerID(id uint64) serverOption {
  27537. return func(m *ServerMutation) {
  27538. var (
  27539. err error
  27540. once sync.Once
  27541. value *Server
  27542. )
  27543. m.oldValue = func(ctx context.Context) (*Server, error) {
  27544. once.Do(func() {
  27545. if m.done {
  27546. err = errors.New("querying old values post mutation is not allowed")
  27547. } else {
  27548. value, err = m.Client().Server.Get(ctx, id)
  27549. }
  27550. })
  27551. return value, err
  27552. }
  27553. m.id = &id
  27554. }
  27555. }
  27556. // withServer sets the old Server of the mutation.
  27557. func withServer(node *Server) serverOption {
  27558. return func(m *ServerMutation) {
  27559. m.oldValue = func(context.Context) (*Server, error) {
  27560. return node, nil
  27561. }
  27562. m.id = &node.ID
  27563. }
  27564. }
  27565. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27566. // executed in a transaction (ent.Tx), a transactional client is returned.
  27567. func (m ServerMutation) Client() *Client {
  27568. client := &Client{config: m.config}
  27569. client.init()
  27570. return client
  27571. }
  27572. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27573. // it returns an error otherwise.
  27574. func (m ServerMutation) Tx() (*Tx, error) {
  27575. if _, ok := m.driver.(*txDriver); !ok {
  27576. return nil, errors.New("ent: mutation is not running in a transaction")
  27577. }
  27578. tx := &Tx{config: m.config}
  27579. tx.init()
  27580. return tx, nil
  27581. }
  27582. // SetID sets the value of the id field. Note that this
  27583. // operation is only accepted on creation of Server entities.
  27584. func (m *ServerMutation) SetID(id uint64) {
  27585. m.id = &id
  27586. }
  27587. // ID returns the ID value in the mutation. Note that the ID is only available
  27588. // if it was provided to the builder or after it was returned from the database.
  27589. func (m *ServerMutation) ID() (id uint64, exists bool) {
  27590. if m.id == nil {
  27591. return
  27592. }
  27593. return *m.id, true
  27594. }
  27595. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27596. // That means, if the mutation is applied within a transaction with an isolation level such
  27597. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27598. // or updated by the mutation.
  27599. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  27600. switch {
  27601. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27602. id, exists := m.ID()
  27603. if exists {
  27604. return []uint64{id}, nil
  27605. }
  27606. fallthrough
  27607. case m.op.Is(OpUpdate | OpDelete):
  27608. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  27609. default:
  27610. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27611. }
  27612. }
  27613. // SetCreatedAt sets the "created_at" field.
  27614. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  27615. m.created_at = &t
  27616. }
  27617. // CreatedAt returns the value of the "created_at" field in the mutation.
  27618. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  27619. v := m.created_at
  27620. if v == nil {
  27621. return
  27622. }
  27623. return *v, true
  27624. }
  27625. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  27626. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27628. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27629. if !m.op.Is(OpUpdateOne) {
  27630. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27631. }
  27632. if m.id == nil || m.oldValue == nil {
  27633. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27634. }
  27635. oldValue, err := m.oldValue(ctx)
  27636. if err != nil {
  27637. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27638. }
  27639. return oldValue.CreatedAt, nil
  27640. }
  27641. // ResetCreatedAt resets all changes to the "created_at" field.
  27642. func (m *ServerMutation) ResetCreatedAt() {
  27643. m.created_at = nil
  27644. }
  27645. // SetUpdatedAt sets the "updated_at" field.
  27646. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  27647. m.updated_at = &t
  27648. }
  27649. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27650. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  27651. v := m.updated_at
  27652. if v == nil {
  27653. return
  27654. }
  27655. return *v, true
  27656. }
  27657. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  27658. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27660. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27661. if !m.op.Is(OpUpdateOne) {
  27662. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27663. }
  27664. if m.id == nil || m.oldValue == nil {
  27665. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27666. }
  27667. oldValue, err := m.oldValue(ctx)
  27668. if err != nil {
  27669. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27670. }
  27671. return oldValue.UpdatedAt, nil
  27672. }
  27673. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27674. func (m *ServerMutation) ResetUpdatedAt() {
  27675. m.updated_at = nil
  27676. }
  27677. // SetStatus sets the "status" field.
  27678. func (m *ServerMutation) SetStatus(u uint8) {
  27679. m.status = &u
  27680. m.addstatus = nil
  27681. }
  27682. // Status returns the value of the "status" field in the mutation.
  27683. func (m *ServerMutation) Status() (r uint8, exists bool) {
  27684. v := m.status
  27685. if v == nil {
  27686. return
  27687. }
  27688. return *v, true
  27689. }
  27690. // OldStatus returns the old "status" field's value of the Server entity.
  27691. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27692. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27693. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27694. if !m.op.Is(OpUpdateOne) {
  27695. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27696. }
  27697. if m.id == nil || m.oldValue == nil {
  27698. return v, errors.New("OldStatus requires an ID field in the mutation")
  27699. }
  27700. oldValue, err := m.oldValue(ctx)
  27701. if err != nil {
  27702. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27703. }
  27704. return oldValue.Status, nil
  27705. }
  27706. // AddStatus adds u to the "status" field.
  27707. func (m *ServerMutation) AddStatus(u int8) {
  27708. if m.addstatus != nil {
  27709. *m.addstatus += u
  27710. } else {
  27711. m.addstatus = &u
  27712. }
  27713. }
  27714. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27715. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  27716. v := m.addstatus
  27717. if v == nil {
  27718. return
  27719. }
  27720. return *v, true
  27721. }
  27722. // ClearStatus clears the value of the "status" field.
  27723. func (m *ServerMutation) ClearStatus() {
  27724. m.status = nil
  27725. m.addstatus = nil
  27726. m.clearedFields[server.FieldStatus] = struct{}{}
  27727. }
  27728. // StatusCleared returns if the "status" field was cleared in this mutation.
  27729. func (m *ServerMutation) StatusCleared() bool {
  27730. _, ok := m.clearedFields[server.FieldStatus]
  27731. return ok
  27732. }
  27733. // ResetStatus resets all changes to the "status" field.
  27734. func (m *ServerMutation) ResetStatus() {
  27735. m.status = nil
  27736. m.addstatus = nil
  27737. delete(m.clearedFields, server.FieldStatus)
  27738. }
  27739. // SetDeletedAt sets the "deleted_at" field.
  27740. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  27741. m.deleted_at = &t
  27742. }
  27743. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27744. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  27745. v := m.deleted_at
  27746. if v == nil {
  27747. return
  27748. }
  27749. return *v, true
  27750. }
  27751. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  27752. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27754. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27755. if !m.op.Is(OpUpdateOne) {
  27756. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27757. }
  27758. if m.id == nil || m.oldValue == nil {
  27759. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27760. }
  27761. oldValue, err := m.oldValue(ctx)
  27762. if err != nil {
  27763. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27764. }
  27765. return oldValue.DeletedAt, nil
  27766. }
  27767. // ClearDeletedAt clears the value of the "deleted_at" field.
  27768. func (m *ServerMutation) ClearDeletedAt() {
  27769. m.deleted_at = nil
  27770. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  27771. }
  27772. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27773. func (m *ServerMutation) DeletedAtCleared() bool {
  27774. _, ok := m.clearedFields[server.FieldDeletedAt]
  27775. return ok
  27776. }
  27777. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27778. func (m *ServerMutation) ResetDeletedAt() {
  27779. m.deleted_at = nil
  27780. delete(m.clearedFields, server.FieldDeletedAt)
  27781. }
  27782. // SetName sets the "name" field.
  27783. func (m *ServerMutation) SetName(s string) {
  27784. m.name = &s
  27785. }
  27786. // Name returns the value of the "name" field in the mutation.
  27787. func (m *ServerMutation) Name() (r string, exists bool) {
  27788. v := m.name
  27789. if v == nil {
  27790. return
  27791. }
  27792. return *v, true
  27793. }
  27794. // OldName returns the old "name" field's value of the Server entity.
  27795. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27797. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  27798. if !m.op.Is(OpUpdateOne) {
  27799. return v, errors.New("OldName is only allowed on UpdateOne operations")
  27800. }
  27801. if m.id == nil || m.oldValue == nil {
  27802. return v, errors.New("OldName requires an ID field in the mutation")
  27803. }
  27804. oldValue, err := m.oldValue(ctx)
  27805. if err != nil {
  27806. return v, fmt.Errorf("querying old value for OldName: %w", err)
  27807. }
  27808. return oldValue.Name, nil
  27809. }
  27810. // ResetName resets all changes to the "name" field.
  27811. func (m *ServerMutation) ResetName() {
  27812. m.name = nil
  27813. }
  27814. // SetPublicIP sets the "public_ip" field.
  27815. func (m *ServerMutation) SetPublicIP(s string) {
  27816. m.public_ip = &s
  27817. }
  27818. // PublicIP returns the value of the "public_ip" field in the mutation.
  27819. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  27820. v := m.public_ip
  27821. if v == nil {
  27822. return
  27823. }
  27824. return *v, true
  27825. }
  27826. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  27827. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27829. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  27830. if !m.op.Is(OpUpdateOne) {
  27831. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  27832. }
  27833. if m.id == nil || m.oldValue == nil {
  27834. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  27835. }
  27836. oldValue, err := m.oldValue(ctx)
  27837. if err != nil {
  27838. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  27839. }
  27840. return oldValue.PublicIP, nil
  27841. }
  27842. // ResetPublicIP resets all changes to the "public_ip" field.
  27843. func (m *ServerMutation) ResetPublicIP() {
  27844. m.public_ip = nil
  27845. }
  27846. // SetPrivateIP sets the "private_ip" field.
  27847. func (m *ServerMutation) SetPrivateIP(s string) {
  27848. m.private_ip = &s
  27849. }
  27850. // PrivateIP returns the value of the "private_ip" field in the mutation.
  27851. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  27852. v := m.private_ip
  27853. if v == nil {
  27854. return
  27855. }
  27856. return *v, true
  27857. }
  27858. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  27859. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27860. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27861. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  27862. if !m.op.Is(OpUpdateOne) {
  27863. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  27864. }
  27865. if m.id == nil || m.oldValue == nil {
  27866. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  27867. }
  27868. oldValue, err := m.oldValue(ctx)
  27869. if err != nil {
  27870. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  27871. }
  27872. return oldValue.PrivateIP, nil
  27873. }
  27874. // ResetPrivateIP resets all changes to the "private_ip" field.
  27875. func (m *ServerMutation) ResetPrivateIP() {
  27876. m.private_ip = nil
  27877. }
  27878. // SetAdminPort sets the "admin_port" field.
  27879. func (m *ServerMutation) SetAdminPort(s string) {
  27880. m.admin_port = &s
  27881. }
  27882. // AdminPort returns the value of the "admin_port" field in the mutation.
  27883. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  27884. v := m.admin_port
  27885. if v == nil {
  27886. return
  27887. }
  27888. return *v, true
  27889. }
  27890. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  27891. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  27892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27893. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  27894. if !m.op.Is(OpUpdateOne) {
  27895. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  27896. }
  27897. if m.id == nil || m.oldValue == nil {
  27898. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  27899. }
  27900. oldValue, err := m.oldValue(ctx)
  27901. if err != nil {
  27902. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  27903. }
  27904. return oldValue.AdminPort, nil
  27905. }
  27906. // ResetAdminPort resets all changes to the "admin_port" field.
  27907. func (m *ServerMutation) ResetAdminPort() {
  27908. m.admin_port = nil
  27909. }
  27910. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  27911. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  27912. if m.wxs == nil {
  27913. m.wxs = make(map[uint64]struct{})
  27914. }
  27915. for i := range ids {
  27916. m.wxs[ids[i]] = struct{}{}
  27917. }
  27918. }
  27919. // ClearWxs clears the "wxs" edge to the Wx entity.
  27920. func (m *ServerMutation) ClearWxs() {
  27921. m.clearedwxs = true
  27922. }
  27923. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  27924. func (m *ServerMutation) WxsCleared() bool {
  27925. return m.clearedwxs
  27926. }
  27927. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  27928. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  27929. if m.removedwxs == nil {
  27930. m.removedwxs = make(map[uint64]struct{})
  27931. }
  27932. for i := range ids {
  27933. delete(m.wxs, ids[i])
  27934. m.removedwxs[ids[i]] = struct{}{}
  27935. }
  27936. }
  27937. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  27938. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  27939. for id := range m.removedwxs {
  27940. ids = append(ids, id)
  27941. }
  27942. return
  27943. }
  27944. // WxsIDs returns the "wxs" edge IDs in the mutation.
  27945. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  27946. for id := range m.wxs {
  27947. ids = append(ids, id)
  27948. }
  27949. return
  27950. }
  27951. // ResetWxs resets all changes to the "wxs" edge.
  27952. func (m *ServerMutation) ResetWxs() {
  27953. m.wxs = nil
  27954. m.clearedwxs = false
  27955. m.removedwxs = nil
  27956. }
  27957. // Where appends a list predicates to the ServerMutation builder.
  27958. func (m *ServerMutation) Where(ps ...predicate.Server) {
  27959. m.predicates = append(m.predicates, ps...)
  27960. }
  27961. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  27962. // users can use type-assertion to append predicates that do not depend on any generated package.
  27963. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  27964. p := make([]predicate.Server, len(ps))
  27965. for i := range ps {
  27966. p[i] = ps[i]
  27967. }
  27968. m.Where(p...)
  27969. }
  27970. // Op returns the operation name.
  27971. func (m *ServerMutation) Op() Op {
  27972. return m.op
  27973. }
  27974. // SetOp allows setting the mutation operation.
  27975. func (m *ServerMutation) SetOp(op Op) {
  27976. m.op = op
  27977. }
  27978. // Type returns the node type of this mutation (Server).
  27979. func (m *ServerMutation) Type() string {
  27980. return m.typ
  27981. }
  27982. // Fields returns all fields that were changed during this mutation. Note that in
  27983. // order to get all numeric fields that were incremented/decremented, call
  27984. // AddedFields().
  27985. func (m *ServerMutation) Fields() []string {
  27986. fields := make([]string, 0, 8)
  27987. if m.created_at != nil {
  27988. fields = append(fields, server.FieldCreatedAt)
  27989. }
  27990. if m.updated_at != nil {
  27991. fields = append(fields, server.FieldUpdatedAt)
  27992. }
  27993. if m.status != nil {
  27994. fields = append(fields, server.FieldStatus)
  27995. }
  27996. if m.deleted_at != nil {
  27997. fields = append(fields, server.FieldDeletedAt)
  27998. }
  27999. if m.name != nil {
  28000. fields = append(fields, server.FieldName)
  28001. }
  28002. if m.public_ip != nil {
  28003. fields = append(fields, server.FieldPublicIP)
  28004. }
  28005. if m.private_ip != nil {
  28006. fields = append(fields, server.FieldPrivateIP)
  28007. }
  28008. if m.admin_port != nil {
  28009. fields = append(fields, server.FieldAdminPort)
  28010. }
  28011. return fields
  28012. }
  28013. // Field returns the value of a field with the given name. The second boolean
  28014. // return value indicates that this field was not set, or was not defined in the
  28015. // schema.
  28016. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  28017. switch name {
  28018. case server.FieldCreatedAt:
  28019. return m.CreatedAt()
  28020. case server.FieldUpdatedAt:
  28021. return m.UpdatedAt()
  28022. case server.FieldStatus:
  28023. return m.Status()
  28024. case server.FieldDeletedAt:
  28025. return m.DeletedAt()
  28026. case server.FieldName:
  28027. return m.Name()
  28028. case server.FieldPublicIP:
  28029. return m.PublicIP()
  28030. case server.FieldPrivateIP:
  28031. return m.PrivateIP()
  28032. case server.FieldAdminPort:
  28033. return m.AdminPort()
  28034. }
  28035. return nil, false
  28036. }
  28037. // OldField returns the old value of the field from the database. An error is
  28038. // returned if the mutation operation is not UpdateOne, or the query to the
  28039. // database failed.
  28040. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28041. switch name {
  28042. case server.FieldCreatedAt:
  28043. return m.OldCreatedAt(ctx)
  28044. case server.FieldUpdatedAt:
  28045. return m.OldUpdatedAt(ctx)
  28046. case server.FieldStatus:
  28047. return m.OldStatus(ctx)
  28048. case server.FieldDeletedAt:
  28049. return m.OldDeletedAt(ctx)
  28050. case server.FieldName:
  28051. return m.OldName(ctx)
  28052. case server.FieldPublicIP:
  28053. return m.OldPublicIP(ctx)
  28054. case server.FieldPrivateIP:
  28055. return m.OldPrivateIP(ctx)
  28056. case server.FieldAdminPort:
  28057. return m.OldAdminPort(ctx)
  28058. }
  28059. return nil, fmt.Errorf("unknown Server field %s", name)
  28060. }
  28061. // SetField sets the value of a field with the given name. It returns an error if
  28062. // the field is not defined in the schema, or if the type mismatched the field
  28063. // type.
  28064. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  28065. switch name {
  28066. case server.FieldCreatedAt:
  28067. v, ok := value.(time.Time)
  28068. if !ok {
  28069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28070. }
  28071. m.SetCreatedAt(v)
  28072. return nil
  28073. case server.FieldUpdatedAt:
  28074. v, ok := value.(time.Time)
  28075. if !ok {
  28076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28077. }
  28078. m.SetUpdatedAt(v)
  28079. return nil
  28080. case server.FieldStatus:
  28081. v, ok := value.(uint8)
  28082. if !ok {
  28083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28084. }
  28085. m.SetStatus(v)
  28086. return nil
  28087. case server.FieldDeletedAt:
  28088. v, ok := value.(time.Time)
  28089. if !ok {
  28090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28091. }
  28092. m.SetDeletedAt(v)
  28093. return nil
  28094. case server.FieldName:
  28095. v, ok := value.(string)
  28096. if !ok {
  28097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28098. }
  28099. m.SetName(v)
  28100. return nil
  28101. case server.FieldPublicIP:
  28102. v, ok := value.(string)
  28103. if !ok {
  28104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28105. }
  28106. m.SetPublicIP(v)
  28107. return nil
  28108. case server.FieldPrivateIP:
  28109. v, ok := value.(string)
  28110. if !ok {
  28111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28112. }
  28113. m.SetPrivateIP(v)
  28114. return nil
  28115. case server.FieldAdminPort:
  28116. v, ok := value.(string)
  28117. if !ok {
  28118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28119. }
  28120. m.SetAdminPort(v)
  28121. return nil
  28122. }
  28123. return fmt.Errorf("unknown Server field %s", name)
  28124. }
  28125. // AddedFields returns all numeric fields that were incremented/decremented during
  28126. // this mutation.
  28127. func (m *ServerMutation) AddedFields() []string {
  28128. var fields []string
  28129. if m.addstatus != nil {
  28130. fields = append(fields, server.FieldStatus)
  28131. }
  28132. return fields
  28133. }
  28134. // AddedField returns the numeric value that was incremented/decremented on a field
  28135. // with the given name. The second boolean return value indicates that this field
  28136. // was not set, or was not defined in the schema.
  28137. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  28138. switch name {
  28139. case server.FieldStatus:
  28140. return m.AddedStatus()
  28141. }
  28142. return nil, false
  28143. }
  28144. // AddField adds the value to the field with the given name. It returns an error if
  28145. // the field is not defined in the schema, or if the type mismatched the field
  28146. // type.
  28147. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  28148. switch name {
  28149. case server.FieldStatus:
  28150. v, ok := value.(int8)
  28151. if !ok {
  28152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28153. }
  28154. m.AddStatus(v)
  28155. return nil
  28156. }
  28157. return fmt.Errorf("unknown Server numeric field %s", name)
  28158. }
  28159. // ClearedFields returns all nullable fields that were cleared during this
  28160. // mutation.
  28161. func (m *ServerMutation) ClearedFields() []string {
  28162. var fields []string
  28163. if m.FieldCleared(server.FieldStatus) {
  28164. fields = append(fields, server.FieldStatus)
  28165. }
  28166. if m.FieldCleared(server.FieldDeletedAt) {
  28167. fields = append(fields, server.FieldDeletedAt)
  28168. }
  28169. return fields
  28170. }
  28171. // FieldCleared returns a boolean indicating if a field with the given name was
  28172. // cleared in this mutation.
  28173. func (m *ServerMutation) FieldCleared(name string) bool {
  28174. _, ok := m.clearedFields[name]
  28175. return ok
  28176. }
  28177. // ClearField clears the value of the field with the given name. It returns an
  28178. // error if the field is not defined in the schema.
  28179. func (m *ServerMutation) ClearField(name string) error {
  28180. switch name {
  28181. case server.FieldStatus:
  28182. m.ClearStatus()
  28183. return nil
  28184. case server.FieldDeletedAt:
  28185. m.ClearDeletedAt()
  28186. return nil
  28187. }
  28188. return fmt.Errorf("unknown Server nullable field %s", name)
  28189. }
  28190. // ResetField resets all changes in the mutation for the field with the given name.
  28191. // It returns an error if the field is not defined in the schema.
  28192. func (m *ServerMutation) ResetField(name string) error {
  28193. switch name {
  28194. case server.FieldCreatedAt:
  28195. m.ResetCreatedAt()
  28196. return nil
  28197. case server.FieldUpdatedAt:
  28198. m.ResetUpdatedAt()
  28199. return nil
  28200. case server.FieldStatus:
  28201. m.ResetStatus()
  28202. return nil
  28203. case server.FieldDeletedAt:
  28204. m.ResetDeletedAt()
  28205. return nil
  28206. case server.FieldName:
  28207. m.ResetName()
  28208. return nil
  28209. case server.FieldPublicIP:
  28210. m.ResetPublicIP()
  28211. return nil
  28212. case server.FieldPrivateIP:
  28213. m.ResetPrivateIP()
  28214. return nil
  28215. case server.FieldAdminPort:
  28216. m.ResetAdminPort()
  28217. return nil
  28218. }
  28219. return fmt.Errorf("unknown Server field %s", name)
  28220. }
  28221. // AddedEdges returns all edge names that were set/added in this mutation.
  28222. func (m *ServerMutation) AddedEdges() []string {
  28223. edges := make([]string, 0, 1)
  28224. if m.wxs != nil {
  28225. edges = append(edges, server.EdgeWxs)
  28226. }
  28227. return edges
  28228. }
  28229. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28230. // name in this mutation.
  28231. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  28232. switch name {
  28233. case server.EdgeWxs:
  28234. ids := make([]ent.Value, 0, len(m.wxs))
  28235. for id := range m.wxs {
  28236. ids = append(ids, id)
  28237. }
  28238. return ids
  28239. }
  28240. return nil
  28241. }
  28242. // RemovedEdges returns all edge names that were removed in this mutation.
  28243. func (m *ServerMutation) RemovedEdges() []string {
  28244. edges := make([]string, 0, 1)
  28245. if m.removedwxs != nil {
  28246. edges = append(edges, server.EdgeWxs)
  28247. }
  28248. return edges
  28249. }
  28250. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28251. // the given name in this mutation.
  28252. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  28253. switch name {
  28254. case server.EdgeWxs:
  28255. ids := make([]ent.Value, 0, len(m.removedwxs))
  28256. for id := range m.removedwxs {
  28257. ids = append(ids, id)
  28258. }
  28259. return ids
  28260. }
  28261. return nil
  28262. }
  28263. // ClearedEdges returns all edge names that were cleared in this mutation.
  28264. func (m *ServerMutation) ClearedEdges() []string {
  28265. edges := make([]string, 0, 1)
  28266. if m.clearedwxs {
  28267. edges = append(edges, server.EdgeWxs)
  28268. }
  28269. return edges
  28270. }
  28271. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28272. // was cleared in this mutation.
  28273. func (m *ServerMutation) EdgeCleared(name string) bool {
  28274. switch name {
  28275. case server.EdgeWxs:
  28276. return m.clearedwxs
  28277. }
  28278. return false
  28279. }
  28280. // ClearEdge clears the value of the edge with the given name. It returns an error
  28281. // if that edge is not defined in the schema.
  28282. func (m *ServerMutation) ClearEdge(name string) error {
  28283. switch name {
  28284. }
  28285. return fmt.Errorf("unknown Server unique edge %s", name)
  28286. }
  28287. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28288. // It returns an error if the edge is not defined in the schema.
  28289. func (m *ServerMutation) ResetEdge(name string) error {
  28290. switch name {
  28291. case server.EdgeWxs:
  28292. m.ResetWxs()
  28293. return nil
  28294. }
  28295. return fmt.Errorf("unknown Server edge %s", name)
  28296. }
  28297. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  28298. type SopNodeMutation struct {
  28299. config
  28300. op Op
  28301. typ string
  28302. id *uint64
  28303. created_at *time.Time
  28304. updated_at *time.Time
  28305. status *uint8
  28306. addstatus *int8
  28307. deleted_at *time.Time
  28308. parent_id *uint64
  28309. addparent_id *int64
  28310. name *string
  28311. condition_type *int
  28312. addcondition_type *int
  28313. condition_list *[]string
  28314. appendcondition_list []string
  28315. no_reply_condition *uint64
  28316. addno_reply_condition *int64
  28317. no_reply_unit *string
  28318. action_message *[]custom_types.Action
  28319. appendaction_message []custom_types.Action
  28320. action_label_add *[]uint64
  28321. appendaction_label_add []uint64
  28322. action_label_del *[]uint64
  28323. appendaction_label_del []uint64
  28324. action_forward **custom_types.ActionForward
  28325. clearedFields map[string]struct{}
  28326. sop_stage *uint64
  28327. clearedsop_stage bool
  28328. node_messages map[uint64]struct{}
  28329. removednode_messages map[uint64]struct{}
  28330. clearednode_messages bool
  28331. done bool
  28332. oldValue func(context.Context) (*SopNode, error)
  28333. predicates []predicate.SopNode
  28334. }
  28335. var _ ent.Mutation = (*SopNodeMutation)(nil)
  28336. // sopnodeOption allows management of the mutation configuration using functional options.
  28337. type sopnodeOption func(*SopNodeMutation)
  28338. // newSopNodeMutation creates new mutation for the SopNode entity.
  28339. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  28340. m := &SopNodeMutation{
  28341. config: c,
  28342. op: op,
  28343. typ: TypeSopNode,
  28344. clearedFields: make(map[string]struct{}),
  28345. }
  28346. for _, opt := range opts {
  28347. opt(m)
  28348. }
  28349. return m
  28350. }
  28351. // withSopNodeID sets the ID field of the mutation.
  28352. func withSopNodeID(id uint64) sopnodeOption {
  28353. return func(m *SopNodeMutation) {
  28354. var (
  28355. err error
  28356. once sync.Once
  28357. value *SopNode
  28358. )
  28359. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  28360. once.Do(func() {
  28361. if m.done {
  28362. err = errors.New("querying old values post mutation is not allowed")
  28363. } else {
  28364. value, err = m.Client().SopNode.Get(ctx, id)
  28365. }
  28366. })
  28367. return value, err
  28368. }
  28369. m.id = &id
  28370. }
  28371. }
  28372. // withSopNode sets the old SopNode of the mutation.
  28373. func withSopNode(node *SopNode) sopnodeOption {
  28374. return func(m *SopNodeMutation) {
  28375. m.oldValue = func(context.Context) (*SopNode, error) {
  28376. return node, nil
  28377. }
  28378. m.id = &node.ID
  28379. }
  28380. }
  28381. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28382. // executed in a transaction (ent.Tx), a transactional client is returned.
  28383. func (m SopNodeMutation) Client() *Client {
  28384. client := &Client{config: m.config}
  28385. client.init()
  28386. return client
  28387. }
  28388. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28389. // it returns an error otherwise.
  28390. func (m SopNodeMutation) Tx() (*Tx, error) {
  28391. if _, ok := m.driver.(*txDriver); !ok {
  28392. return nil, errors.New("ent: mutation is not running in a transaction")
  28393. }
  28394. tx := &Tx{config: m.config}
  28395. tx.init()
  28396. return tx, nil
  28397. }
  28398. // SetID sets the value of the id field. Note that this
  28399. // operation is only accepted on creation of SopNode entities.
  28400. func (m *SopNodeMutation) SetID(id uint64) {
  28401. m.id = &id
  28402. }
  28403. // ID returns the ID value in the mutation. Note that the ID is only available
  28404. // if it was provided to the builder or after it was returned from the database.
  28405. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  28406. if m.id == nil {
  28407. return
  28408. }
  28409. return *m.id, true
  28410. }
  28411. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28412. // That means, if the mutation is applied within a transaction with an isolation level such
  28413. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28414. // or updated by the mutation.
  28415. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  28416. switch {
  28417. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28418. id, exists := m.ID()
  28419. if exists {
  28420. return []uint64{id}, nil
  28421. }
  28422. fallthrough
  28423. case m.op.Is(OpUpdate | OpDelete):
  28424. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  28425. default:
  28426. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28427. }
  28428. }
  28429. // SetCreatedAt sets the "created_at" field.
  28430. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  28431. m.created_at = &t
  28432. }
  28433. // CreatedAt returns the value of the "created_at" field in the mutation.
  28434. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  28435. v := m.created_at
  28436. if v == nil {
  28437. return
  28438. }
  28439. return *v, true
  28440. }
  28441. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  28442. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28444. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28445. if !m.op.Is(OpUpdateOne) {
  28446. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28447. }
  28448. if m.id == nil || m.oldValue == nil {
  28449. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28450. }
  28451. oldValue, err := m.oldValue(ctx)
  28452. if err != nil {
  28453. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28454. }
  28455. return oldValue.CreatedAt, nil
  28456. }
  28457. // ResetCreatedAt resets all changes to the "created_at" field.
  28458. func (m *SopNodeMutation) ResetCreatedAt() {
  28459. m.created_at = nil
  28460. }
  28461. // SetUpdatedAt sets the "updated_at" field.
  28462. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  28463. m.updated_at = &t
  28464. }
  28465. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28466. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  28467. v := m.updated_at
  28468. if v == nil {
  28469. return
  28470. }
  28471. return *v, true
  28472. }
  28473. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  28474. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28476. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28477. if !m.op.Is(OpUpdateOne) {
  28478. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28479. }
  28480. if m.id == nil || m.oldValue == nil {
  28481. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28482. }
  28483. oldValue, err := m.oldValue(ctx)
  28484. if err != nil {
  28485. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28486. }
  28487. return oldValue.UpdatedAt, nil
  28488. }
  28489. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28490. func (m *SopNodeMutation) ResetUpdatedAt() {
  28491. m.updated_at = nil
  28492. }
  28493. // SetStatus sets the "status" field.
  28494. func (m *SopNodeMutation) SetStatus(u uint8) {
  28495. m.status = &u
  28496. m.addstatus = nil
  28497. }
  28498. // Status returns the value of the "status" field in the mutation.
  28499. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  28500. v := m.status
  28501. if v == nil {
  28502. return
  28503. }
  28504. return *v, true
  28505. }
  28506. // OldStatus returns the old "status" field's value of the SopNode entity.
  28507. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28509. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28510. if !m.op.Is(OpUpdateOne) {
  28511. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28512. }
  28513. if m.id == nil || m.oldValue == nil {
  28514. return v, errors.New("OldStatus requires an ID field in the mutation")
  28515. }
  28516. oldValue, err := m.oldValue(ctx)
  28517. if err != nil {
  28518. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28519. }
  28520. return oldValue.Status, nil
  28521. }
  28522. // AddStatus adds u to the "status" field.
  28523. func (m *SopNodeMutation) AddStatus(u int8) {
  28524. if m.addstatus != nil {
  28525. *m.addstatus += u
  28526. } else {
  28527. m.addstatus = &u
  28528. }
  28529. }
  28530. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28531. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  28532. v := m.addstatus
  28533. if v == nil {
  28534. return
  28535. }
  28536. return *v, true
  28537. }
  28538. // ClearStatus clears the value of the "status" field.
  28539. func (m *SopNodeMutation) ClearStatus() {
  28540. m.status = nil
  28541. m.addstatus = nil
  28542. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  28543. }
  28544. // StatusCleared returns if the "status" field was cleared in this mutation.
  28545. func (m *SopNodeMutation) StatusCleared() bool {
  28546. _, ok := m.clearedFields[sopnode.FieldStatus]
  28547. return ok
  28548. }
  28549. // ResetStatus resets all changes to the "status" field.
  28550. func (m *SopNodeMutation) ResetStatus() {
  28551. m.status = nil
  28552. m.addstatus = nil
  28553. delete(m.clearedFields, sopnode.FieldStatus)
  28554. }
  28555. // SetDeletedAt sets the "deleted_at" field.
  28556. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  28557. m.deleted_at = &t
  28558. }
  28559. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28560. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  28561. v := m.deleted_at
  28562. if v == nil {
  28563. return
  28564. }
  28565. return *v, true
  28566. }
  28567. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  28568. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28569. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28570. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28571. if !m.op.Is(OpUpdateOne) {
  28572. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28573. }
  28574. if m.id == nil || m.oldValue == nil {
  28575. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28576. }
  28577. oldValue, err := m.oldValue(ctx)
  28578. if err != nil {
  28579. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28580. }
  28581. return oldValue.DeletedAt, nil
  28582. }
  28583. // ClearDeletedAt clears the value of the "deleted_at" field.
  28584. func (m *SopNodeMutation) ClearDeletedAt() {
  28585. m.deleted_at = nil
  28586. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  28587. }
  28588. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28589. func (m *SopNodeMutation) DeletedAtCleared() bool {
  28590. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  28591. return ok
  28592. }
  28593. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28594. func (m *SopNodeMutation) ResetDeletedAt() {
  28595. m.deleted_at = nil
  28596. delete(m.clearedFields, sopnode.FieldDeletedAt)
  28597. }
  28598. // SetStageID sets the "stage_id" field.
  28599. func (m *SopNodeMutation) SetStageID(u uint64) {
  28600. m.sop_stage = &u
  28601. }
  28602. // StageID returns the value of the "stage_id" field in the mutation.
  28603. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  28604. v := m.sop_stage
  28605. if v == nil {
  28606. return
  28607. }
  28608. return *v, true
  28609. }
  28610. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  28611. // If the SopNode 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 *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  28614. if !m.op.Is(OpUpdateOne) {
  28615. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  28616. }
  28617. if m.id == nil || m.oldValue == nil {
  28618. return v, errors.New("OldStageID 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 OldStageID: %w", err)
  28623. }
  28624. return oldValue.StageID, nil
  28625. }
  28626. // ResetStageID resets all changes to the "stage_id" field.
  28627. func (m *SopNodeMutation) ResetStageID() {
  28628. m.sop_stage = nil
  28629. }
  28630. // SetParentID sets the "parent_id" field.
  28631. func (m *SopNodeMutation) SetParentID(u uint64) {
  28632. m.parent_id = &u
  28633. m.addparent_id = nil
  28634. }
  28635. // ParentID returns the value of the "parent_id" field in the mutation.
  28636. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  28637. v := m.parent_id
  28638. if v == nil {
  28639. return
  28640. }
  28641. return *v, true
  28642. }
  28643. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  28644. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28646. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  28647. if !m.op.Is(OpUpdateOne) {
  28648. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  28649. }
  28650. if m.id == nil || m.oldValue == nil {
  28651. return v, errors.New("OldParentID requires an ID field in the mutation")
  28652. }
  28653. oldValue, err := m.oldValue(ctx)
  28654. if err != nil {
  28655. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  28656. }
  28657. return oldValue.ParentID, nil
  28658. }
  28659. // AddParentID adds u to the "parent_id" field.
  28660. func (m *SopNodeMutation) AddParentID(u int64) {
  28661. if m.addparent_id != nil {
  28662. *m.addparent_id += u
  28663. } else {
  28664. m.addparent_id = &u
  28665. }
  28666. }
  28667. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  28668. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  28669. v := m.addparent_id
  28670. if v == nil {
  28671. return
  28672. }
  28673. return *v, true
  28674. }
  28675. // ResetParentID resets all changes to the "parent_id" field.
  28676. func (m *SopNodeMutation) ResetParentID() {
  28677. m.parent_id = nil
  28678. m.addparent_id = nil
  28679. }
  28680. // SetName sets the "name" field.
  28681. func (m *SopNodeMutation) SetName(s string) {
  28682. m.name = &s
  28683. }
  28684. // Name returns the value of the "name" field in the mutation.
  28685. func (m *SopNodeMutation) Name() (r string, exists bool) {
  28686. v := m.name
  28687. if v == nil {
  28688. return
  28689. }
  28690. return *v, true
  28691. }
  28692. // OldName returns the old "name" field's value of the SopNode entity.
  28693. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28695. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  28696. if !m.op.Is(OpUpdateOne) {
  28697. return v, errors.New("OldName is only allowed on UpdateOne operations")
  28698. }
  28699. if m.id == nil || m.oldValue == nil {
  28700. return v, errors.New("OldName requires an ID field in the mutation")
  28701. }
  28702. oldValue, err := m.oldValue(ctx)
  28703. if err != nil {
  28704. return v, fmt.Errorf("querying old value for OldName: %w", err)
  28705. }
  28706. return oldValue.Name, nil
  28707. }
  28708. // ResetName resets all changes to the "name" field.
  28709. func (m *SopNodeMutation) ResetName() {
  28710. m.name = nil
  28711. }
  28712. // SetConditionType sets the "condition_type" field.
  28713. func (m *SopNodeMutation) SetConditionType(i int) {
  28714. m.condition_type = &i
  28715. m.addcondition_type = nil
  28716. }
  28717. // ConditionType returns the value of the "condition_type" field in the mutation.
  28718. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  28719. v := m.condition_type
  28720. if v == nil {
  28721. return
  28722. }
  28723. return *v, true
  28724. }
  28725. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  28726. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28728. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  28729. if !m.op.Is(OpUpdateOne) {
  28730. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  28731. }
  28732. if m.id == nil || m.oldValue == nil {
  28733. return v, errors.New("OldConditionType requires an ID field in the mutation")
  28734. }
  28735. oldValue, err := m.oldValue(ctx)
  28736. if err != nil {
  28737. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  28738. }
  28739. return oldValue.ConditionType, nil
  28740. }
  28741. // AddConditionType adds i to the "condition_type" field.
  28742. func (m *SopNodeMutation) AddConditionType(i int) {
  28743. if m.addcondition_type != nil {
  28744. *m.addcondition_type += i
  28745. } else {
  28746. m.addcondition_type = &i
  28747. }
  28748. }
  28749. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  28750. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  28751. v := m.addcondition_type
  28752. if v == nil {
  28753. return
  28754. }
  28755. return *v, true
  28756. }
  28757. // ResetConditionType resets all changes to the "condition_type" field.
  28758. func (m *SopNodeMutation) ResetConditionType() {
  28759. m.condition_type = nil
  28760. m.addcondition_type = nil
  28761. }
  28762. // SetConditionList sets the "condition_list" field.
  28763. func (m *SopNodeMutation) SetConditionList(s []string) {
  28764. m.condition_list = &s
  28765. m.appendcondition_list = nil
  28766. }
  28767. // ConditionList returns the value of the "condition_list" field in the mutation.
  28768. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  28769. v := m.condition_list
  28770. if v == nil {
  28771. return
  28772. }
  28773. return *v, true
  28774. }
  28775. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  28776. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28778. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  28779. if !m.op.Is(OpUpdateOne) {
  28780. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  28781. }
  28782. if m.id == nil || m.oldValue == nil {
  28783. return v, errors.New("OldConditionList requires an ID field in the mutation")
  28784. }
  28785. oldValue, err := m.oldValue(ctx)
  28786. if err != nil {
  28787. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  28788. }
  28789. return oldValue.ConditionList, nil
  28790. }
  28791. // AppendConditionList adds s to the "condition_list" field.
  28792. func (m *SopNodeMutation) AppendConditionList(s []string) {
  28793. m.appendcondition_list = append(m.appendcondition_list, s...)
  28794. }
  28795. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  28796. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  28797. if len(m.appendcondition_list) == 0 {
  28798. return nil, false
  28799. }
  28800. return m.appendcondition_list, true
  28801. }
  28802. // ClearConditionList clears the value of the "condition_list" field.
  28803. func (m *SopNodeMutation) ClearConditionList() {
  28804. m.condition_list = nil
  28805. m.appendcondition_list = nil
  28806. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  28807. }
  28808. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  28809. func (m *SopNodeMutation) ConditionListCleared() bool {
  28810. _, ok := m.clearedFields[sopnode.FieldConditionList]
  28811. return ok
  28812. }
  28813. // ResetConditionList resets all changes to the "condition_list" field.
  28814. func (m *SopNodeMutation) ResetConditionList() {
  28815. m.condition_list = nil
  28816. m.appendcondition_list = nil
  28817. delete(m.clearedFields, sopnode.FieldConditionList)
  28818. }
  28819. // SetNoReplyCondition sets the "no_reply_condition" field.
  28820. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  28821. m.no_reply_condition = &u
  28822. m.addno_reply_condition = nil
  28823. }
  28824. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  28825. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  28826. v := m.no_reply_condition
  28827. if v == nil {
  28828. return
  28829. }
  28830. return *v, true
  28831. }
  28832. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  28833. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28835. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  28836. if !m.op.Is(OpUpdateOne) {
  28837. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  28838. }
  28839. if m.id == nil || m.oldValue == nil {
  28840. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  28841. }
  28842. oldValue, err := m.oldValue(ctx)
  28843. if err != nil {
  28844. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  28845. }
  28846. return oldValue.NoReplyCondition, nil
  28847. }
  28848. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  28849. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  28850. if m.addno_reply_condition != nil {
  28851. *m.addno_reply_condition += u
  28852. } else {
  28853. m.addno_reply_condition = &u
  28854. }
  28855. }
  28856. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  28857. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  28858. v := m.addno_reply_condition
  28859. if v == nil {
  28860. return
  28861. }
  28862. return *v, true
  28863. }
  28864. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  28865. func (m *SopNodeMutation) ResetNoReplyCondition() {
  28866. m.no_reply_condition = nil
  28867. m.addno_reply_condition = nil
  28868. }
  28869. // SetNoReplyUnit sets the "no_reply_unit" field.
  28870. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  28871. m.no_reply_unit = &s
  28872. }
  28873. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  28874. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  28875. v := m.no_reply_unit
  28876. if v == nil {
  28877. return
  28878. }
  28879. return *v, true
  28880. }
  28881. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  28882. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28884. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  28885. if !m.op.Is(OpUpdateOne) {
  28886. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  28887. }
  28888. if m.id == nil || m.oldValue == nil {
  28889. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  28890. }
  28891. oldValue, err := m.oldValue(ctx)
  28892. if err != nil {
  28893. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  28894. }
  28895. return oldValue.NoReplyUnit, nil
  28896. }
  28897. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  28898. func (m *SopNodeMutation) ResetNoReplyUnit() {
  28899. m.no_reply_unit = nil
  28900. }
  28901. // SetActionMessage sets the "action_message" field.
  28902. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  28903. m.action_message = &ct
  28904. m.appendaction_message = nil
  28905. }
  28906. // ActionMessage returns the value of the "action_message" field in the mutation.
  28907. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  28908. v := m.action_message
  28909. if v == nil {
  28910. return
  28911. }
  28912. return *v, true
  28913. }
  28914. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  28915. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28917. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  28918. if !m.op.Is(OpUpdateOne) {
  28919. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  28920. }
  28921. if m.id == nil || m.oldValue == nil {
  28922. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  28923. }
  28924. oldValue, err := m.oldValue(ctx)
  28925. if err != nil {
  28926. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  28927. }
  28928. return oldValue.ActionMessage, nil
  28929. }
  28930. // AppendActionMessage adds ct to the "action_message" field.
  28931. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  28932. m.appendaction_message = append(m.appendaction_message, ct...)
  28933. }
  28934. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  28935. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  28936. if len(m.appendaction_message) == 0 {
  28937. return nil, false
  28938. }
  28939. return m.appendaction_message, true
  28940. }
  28941. // ClearActionMessage clears the value of the "action_message" field.
  28942. func (m *SopNodeMutation) ClearActionMessage() {
  28943. m.action_message = nil
  28944. m.appendaction_message = nil
  28945. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  28946. }
  28947. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  28948. func (m *SopNodeMutation) ActionMessageCleared() bool {
  28949. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  28950. return ok
  28951. }
  28952. // ResetActionMessage resets all changes to the "action_message" field.
  28953. func (m *SopNodeMutation) ResetActionMessage() {
  28954. m.action_message = nil
  28955. m.appendaction_message = nil
  28956. delete(m.clearedFields, sopnode.FieldActionMessage)
  28957. }
  28958. // SetActionLabelAdd sets the "action_label_add" field.
  28959. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  28960. m.action_label_add = &u
  28961. m.appendaction_label_add = nil
  28962. }
  28963. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  28964. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  28965. v := m.action_label_add
  28966. if v == nil {
  28967. return
  28968. }
  28969. return *v, true
  28970. }
  28971. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  28972. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  28973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28974. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  28975. if !m.op.Is(OpUpdateOne) {
  28976. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  28977. }
  28978. if m.id == nil || m.oldValue == nil {
  28979. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  28980. }
  28981. oldValue, err := m.oldValue(ctx)
  28982. if err != nil {
  28983. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  28984. }
  28985. return oldValue.ActionLabelAdd, nil
  28986. }
  28987. // AppendActionLabelAdd adds u to the "action_label_add" field.
  28988. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  28989. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  28990. }
  28991. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  28992. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  28993. if len(m.appendaction_label_add) == 0 {
  28994. return nil, false
  28995. }
  28996. return m.appendaction_label_add, true
  28997. }
  28998. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  28999. func (m *SopNodeMutation) ClearActionLabelAdd() {
  29000. m.action_label_add = nil
  29001. m.appendaction_label_add = nil
  29002. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  29003. }
  29004. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  29005. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  29006. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  29007. return ok
  29008. }
  29009. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  29010. func (m *SopNodeMutation) ResetActionLabelAdd() {
  29011. m.action_label_add = nil
  29012. m.appendaction_label_add = nil
  29013. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  29014. }
  29015. // SetActionLabelDel sets the "action_label_del" field.
  29016. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  29017. m.action_label_del = &u
  29018. m.appendaction_label_del = nil
  29019. }
  29020. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  29021. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  29022. v := m.action_label_del
  29023. if v == nil {
  29024. return
  29025. }
  29026. return *v, true
  29027. }
  29028. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  29029. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29031. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  29032. if !m.op.Is(OpUpdateOne) {
  29033. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  29034. }
  29035. if m.id == nil || m.oldValue == nil {
  29036. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  29037. }
  29038. oldValue, err := m.oldValue(ctx)
  29039. if err != nil {
  29040. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  29041. }
  29042. return oldValue.ActionLabelDel, nil
  29043. }
  29044. // AppendActionLabelDel adds u to the "action_label_del" field.
  29045. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  29046. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  29047. }
  29048. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  29049. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  29050. if len(m.appendaction_label_del) == 0 {
  29051. return nil, false
  29052. }
  29053. return m.appendaction_label_del, true
  29054. }
  29055. // ClearActionLabelDel clears the value of the "action_label_del" field.
  29056. func (m *SopNodeMutation) ClearActionLabelDel() {
  29057. m.action_label_del = nil
  29058. m.appendaction_label_del = nil
  29059. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  29060. }
  29061. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  29062. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  29063. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  29064. return ok
  29065. }
  29066. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  29067. func (m *SopNodeMutation) ResetActionLabelDel() {
  29068. m.action_label_del = nil
  29069. m.appendaction_label_del = nil
  29070. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  29071. }
  29072. // SetActionForward sets the "action_forward" field.
  29073. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  29074. m.action_forward = &ctf
  29075. }
  29076. // ActionForward returns the value of the "action_forward" field in the mutation.
  29077. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  29078. v := m.action_forward
  29079. if v == nil {
  29080. return
  29081. }
  29082. return *v, true
  29083. }
  29084. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  29085. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  29086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29087. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  29088. if !m.op.Is(OpUpdateOne) {
  29089. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  29090. }
  29091. if m.id == nil || m.oldValue == nil {
  29092. return v, errors.New("OldActionForward requires an ID field in the mutation")
  29093. }
  29094. oldValue, err := m.oldValue(ctx)
  29095. if err != nil {
  29096. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  29097. }
  29098. return oldValue.ActionForward, nil
  29099. }
  29100. // ClearActionForward clears the value of the "action_forward" field.
  29101. func (m *SopNodeMutation) ClearActionForward() {
  29102. m.action_forward = nil
  29103. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  29104. }
  29105. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  29106. func (m *SopNodeMutation) ActionForwardCleared() bool {
  29107. _, ok := m.clearedFields[sopnode.FieldActionForward]
  29108. return ok
  29109. }
  29110. // ResetActionForward resets all changes to the "action_forward" field.
  29111. func (m *SopNodeMutation) ResetActionForward() {
  29112. m.action_forward = nil
  29113. delete(m.clearedFields, sopnode.FieldActionForward)
  29114. }
  29115. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  29116. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  29117. m.sop_stage = &id
  29118. }
  29119. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  29120. func (m *SopNodeMutation) ClearSopStage() {
  29121. m.clearedsop_stage = true
  29122. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  29123. }
  29124. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  29125. func (m *SopNodeMutation) SopStageCleared() bool {
  29126. return m.clearedsop_stage
  29127. }
  29128. // SopStageID returns the "sop_stage" edge ID in the mutation.
  29129. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  29130. if m.sop_stage != nil {
  29131. return *m.sop_stage, true
  29132. }
  29133. return
  29134. }
  29135. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  29136. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  29137. // SopStageID instead. It exists only for internal usage by the builders.
  29138. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  29139. if id := m.sop_stage; id != nil {
  29140. ids = append(ids, *id)
  29141. }
  29142. return
  29143. }
  29144. // ResetSopStage resets all changes to the "sop_stage" edge.
  29145. func (m *SopNodeMutation) ResetSopStage() {
  29146. m.sop_stage = nil
  29147. m.clearedsop_stage = false
  29148. }
  29149. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  29150. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  29151. if m.node_messages == nil {
  29152. m.node_messages = make(map[uint64]struct{})
  29153. }
  29154. for i := range ids {
  29155. m.node_messages[ids[i]] = struct{}{}
  29156. }
  29157. }
  29158. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  29159. func (m *SopNodeMutation) ClearNodeMessages() {
  29160. m.clearednode_messages = true
  29161. }
  29162. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  29163. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  29164. return m.clearednode_messages
  29165. }
  29166. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  29167. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  29168. if m.removednode_messages == nil {
  29169. m.removednode_messages = make(map[uint64]struct{})
  29170. }
  29171. for i := range ids {
  29172. delete(m.node_messages, ids[i])
  29173. m.removednode_messages[ids[i]] = struct{}{}
  29174. }
  29175. }
  29176. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  29177. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  29178. for id := range m.removednode_messages {
  29179. ids = append(ids, id)
  29180. }
  29181. return
  29182. }
  29183. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  29184. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  29185. for id := range m.node_messages {
  29186. ids = append(ids, id)
  29187. }
  29188. return
  29189. }
  29190. // ResetNodeMessages resets all changes to the "node_messages" edge.
  29191. func (m *SopNodeMutation) ResetNodeMessages() {
  29192. m.node_messages = nil
  29193. m.clearednode_messages = false
  29194. m.removednode_messages = nil
  29195. }
  29196. // Where appends a list predicates to the SopNodeMutation builder.
  29197. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  29198. m.predicates = append(m.predicates, ps...)
  29199. }
  29200. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  29201. // users can use type-assertion to append predicates that do not depend on any generated package.
  29202. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  29203. p := make([]predicate.SopNode, len(ps))
  29204. for i := range ps {
  29205. p[i] = ps[i]
  29206. }
  29207. m.Where(p...)
  29208. }
  29209. // Op returns the operation name.
  29210. func (m *SopNodeMutation) Op() Op {
  29211. return m.op
  29212. }
  29213. // SetOp allows setting the mutation operation.
  29214. func (m *SopNodeMutation) SetOp(op Op) {
  29215. m.op = op
  29216. }
  29217. // Type returns the node type of this mutation (SopNode).
  29218. func (m *SopNodeMutation) Type() string {
  29219. return m.typ
  29220. }
  29221. // Fields returns all fields that were changed during this mutation. Note that in
  29222. // order to get all numeric fields that were incremented/decremented, call
  29223. // AddedFields().
  29224. func (m *SopNodeMutation) Fields() []string {
  29225. fields := make([]string, 0, 15)
  29226. if m.created_at != nil {
  29227. fields = append(fields, sopnode.FieldCreatedAt)
  29228. }
  29229. if m.updated_at != nil {
  29230. fields = append(fields, sopnode.FieldUpdatedAt)
  29231. }
  29232. if m.status != nil {
  29233. fields = append(fields, sopnode.FieldStatus)
  29234. }
  29235. if m.deleted_at != nil {
  29236. fields = append(fields, sopnode.FieldDeletedAt)
  29237. }
  29238. if m.sop_stage != nil {
  29239. fields = append(fields, sopnode.FieldStageID)
  29240. }
  29241. if m.parent_id != nil {
  29242. fields = append(fields, sopnode.FieldParentID)
  29243. }
  29244. if m.name != nil {
  29245. fields = append(fields, sopnode.FieldName)
  29246. }
  29247. if m.condition_type != nil {
  29248. fields = append(fields, sopnode.FieldConditionType)
  29249. }
  29250. if m.condition_list != nil {
  29251. fields = append(fields, sopnode.FieldConditionList)
  29252. }
  29253. if m.no_reply_condition != nil {
  29254. fields = append(fields, sopnode.FieldNoReplyCondition)
  29255. }
  29256. if m.no_reply_unit != nil {
  29257. fields = append(fields, sopnode.FieldNoReplyUnit)
  29258. }
  29259. if m.action_message != nil {
  29260. fields = append(fields, sopnode.FieldActionMessage)
  29261. }
  29262. if m.action_label_add != nil {
  29263. fields = append(fields, sopnode.FieldActionLabelAdd)
  29264. }
  29265. if m.action_label_del != nil {
  29266. fields = append(fields, sopnode.FieldActionLabelDel)
  29267. }
  29268. if m.action_forward != nil {
  29269. fields = append(fields, sopnode.FieldActionForward)
  29270. }
  29271. return fields
  29272. }
  29273. // Field returns the value of a field with the given name. The second boolean
  29274. // return value indicates that this field was not set, or was not defined in the
  29275. // schema.
  29276. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  29277. switch name {
  29278. case sopnode.FieldCreatedAt:
  29279. return m.CreatedAt()
  29280. case sopnode.FieldUpdatedAt:
  29281. return m.UpdatedAt()
  29282. case sopnode.FieldStatus:
  29283. return m.Status()
  29284. case sopnode.FieldDeletedAt:
  29285. return m.DeletedAt()
  29286. case sopnode.FieldStageID:
  29287. return m.StageID()
  29288. case sopnode.FieldParentID:
  29289. return m.ParentID()
  29290. case sopnode.FieldName:
  29291. return m.Name()
  29292. case sopnode.FieldConditionType:
  29293. return m.ConditionType()
  29294. case sopnode.FieldConditionList:
  29295. return m.ConditionList()
  29296. case sopnode.FieldNoReplyCondition:
  29297. return m.NoReplyCondition()
  29298. case sopnode.FieldNoReplyUnit:
  29299. return m.NoReplyUnit()
  29300. case sopnode.FieldActionMessage:
  29301. return m.ActionMessage()
  29302. case sopnode.FieldActionLabelAdd:
  29303. return m.ActionLabelAdd()
  29304. case sopnode.FieldActionLabelDel:
  29305. return m.ActionLabelDel()
  29306. case sopnode.FieldActionForward:
  29307. return m.ActionForward()
  29308. }
  29309. return nil, false
  29310. }
  29311. // OldField returns the old value of the field from the database. An error is
  29312. // returned if the mutation operation is not UpdateOne, or the query to the
  29313. // database failed.
  29314. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29315. switch name {
  29316. case sopnode.FieldCreatedAt:
  29317. return m.OldCreatedAt(ctx)
  29318. case sopnode.FieldUpdatedAt:
  29319. return m.OldUpdatedAt(ctx)
  29320. case sopnode.FieldStatus:
  29321. return m.OldStatus(ctx)
  29322. case sopnode.FieldDeletedAt:
  29323. return m.OldDeletedAt(ctx)
  29324. case sopnode.FieldStageID:
  29325. return m.OldStageID(ctx)
  29326. case sopnode.FieldParentID:
  29327. return m.OldParentID(ctx)
  29328. case sopnode.FieldName:
  29329. return m.OldName(ctx)
  29330. case sopnode.FieldConditionType:
  29331. return m.OldConditionType(ctx)
  29332. case sopnode.FieldConditionList:
  29333. return m.OldConditionList(ctx)
  29334. case sopnode.FieldNoReplyCondition:
  29335. return m.OldNoReplyCondition(ctx)
  29336. case sopnode.FieldNoReplyUnit:
  29337. return m.OldNoReplyUnit(ctx)
  29338. case sopnode.FieldActionMessage:
  29339. return m.OldActionMessage(ctx)
  29340. case sopnode.FieldActionLabelAdd:
  29341. return m.OldActionLabelAdd(ctx)
  29342. case sopnode.FieldActionLabelDel:
  29343. return m.OldActionLabelDel(ctx)
  29344. case sopnode.FieldActionForward:
  29345. return m.OldActionForward(ctx)
  29346. }
  29347. return nil, fmt.Errorf("unknown SopNode field %s", name)
  29348. }
  29349. // SetField sets the value of a field with the given name. It returns an error if
  29350. // the field is not defined in the schema, or if the type mismatched the field
  29351. // type.
  29352. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  29353. switch name {
  29354. case sopnode.FieldCreatedAt:
  29355. v, ok := value.(time.Time)
  29356. if !ok {
  29357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29358. }
  29359. m.SetCreatedAt(v)
  29360. return nil
  29361. case sopnode.FieldUpdatedAt:
  29362. v, ok := value.(time.Time)
  29363. if !ok {
  29364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29365. }
  29366. m.SetUpdatedAt(v)
  29367. return nil
  29368. case sopnode.FieldStatus:
  29369. v, ok := value.(uint8)
  29370. if !ok {
  29371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29372. }
  29373. m.SetStatus(v)
  29374. return nil
  29375. case sopnode.FieldDeletedAt:
  29376. v, ok := value.(time.Time)
  29377. if !ok {
  29378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29379. }
  29380. m.SetDeletedAt(v)
  29381. return nil
  29382. case sopnode.FieldStageID:
  29383. v, ok := value.(uint64)
  29384. if !ok {
  29385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29386. }
  29387. m.SetStageID(v)
  29388. return nil
  29389. case sopnode.FieldParentID:
  29390. v, ok := value.(uint64)
  29391. if !ok {
  29392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29393. }
  29394. m.SetParentID(v)
  29395. return nil
  29396. case sopnode.FieldName:
  29397. v, ok := value.(string)
  29398. if !ok {
  29399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29400. }
  29401. m.SetName(v)
  29402. return nil
  29403. case sopnode.FieldConditionType:
  29404. v, ok := value.(int)
  29405. if !ok {
  29406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29407. }
  29408. m.SetConditionType(v)
  29409. return nil
  29410. case sopnode.FieldConditionList:
  29411. v, ok := value.([]string)
  29412. if !ok {
  29413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29414. }
  29415. m.SetConditionList(v)
  29416. return nil
  29417. case sopnode.FieldNoReplyCondition:
  29418. v, ok := value.(uint64)
  29419. if !ok {
  29420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29421. }
  29422. m.SetNoReplyCondition(v)
  29423. return nil
  29424. case sopnode.FieldNoReplyUnit:
  29425. v, ok := value.(string)
  29426. if !ok {
  29427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29428. }
  29429. m.SetNoReplyUnit(v)
  29430. return nil
  29431. case sopnode.FieldActionMessage:
  29432. v, ok := value.([]custom_types.Action)
  29433. if !ok {
  29434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29435. }
  29436. m.SetActionMessage(v)
  29437. return nil
  29438. case sopnode.FieldActionLabelAdd:
  29439. v, ok := value.([]uint64)
  29440. if !ok {
  29441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29442. }
  29443. m.SetActionLabelAdd(v)
  29444. return nil
  29445. case sopnode.FieldActionLabelDel:
  29446. v, ok := value.([]uint64)
  29447. if !ok {
  29448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29449. }
  29450. m.SetActionLabelDel(v)
  29451. return nil
  29452. case sopnode.FieldActionForward:
  29453. v, ok := value.(*custom_types.ActionForward)
  29454. if !ok {
  29455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29456. }
  29457. m.SetActionForward(v)
  29458. return nil
  29459. }
  29460. return fmt.Errorf("unknown SopNode field %s", name)
  29461. }
  29462. // AddedFields returns all numeric fields that were incremented/decremented during
  29463. // this mutation.
  29464. func (m *SopNodeMutation) AddedFields() []string {
  29465. var fields []string
  29466. if m.addstatus != nil {
  29467. fields = append(fields, sopnode.FieldStatus)
  29468. }
  29469. if m.addparent_id != nil {
  29470. fields = append(fields, sopnode.FieldParentID)
  29471. }
  29472. if m.addcondition_type != nil {
  29473. fields = append(fields, sopnode.FieldConditionType)
  29474. }
  29475. if m.addno_reply_condition != nil {
  29476. fields = append(fields, sopnode.FieldNoReplyCondition)
  29477. }
  29478. return fields
  29479. }
  29480. // AddedField returns the numeric value that was incremented/decremented on a field
  29481. // with the given name. The second boolean return value indicates that this field
  29482. // was not set, or was not defined in the schema.
  29483. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  29484. switch name {
  29485. case sopnode.FieldStatus:
  29486. return m.AddedStatus()
  29487. case sopnode.FieldParentID:
  29488. return m.AddedParentID()
  29489. case sopnode.FieldConditionType:
  29490. return m.AddedConditionType()
  29491. case sopnode.FieldNoReplyCondition:
  29492. return m.AddedNoReplyCondition()
  29493. }
  29494. return nil, false
  29495. }
  29496. // AddField adds the value to the field with the given name. It returns an error if
  29497. // the field is not defined in the schema, or if the type mismatched the field
  29498. // type.
  29499. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  29500. switch name {
  29501. case sopnode.FieldStatus:
  29502. v, ok := value.(int8)
  29503. if !ok {
  29504. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29505. }
  29506. m.AddStatus(v)
  29507. return nil
  29508. case sopnode.FieldParentID:
  29509. v, ok := value.(int64)
  29510. if !ok {
  29511. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29512. }
  29513. m.AddParentID(v)
  29514. return nil
  29515. case sopnode.FieldConditionType:
  29516. v, ok := value.(int)
  29517. if !ok {
  29518. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29519. }
  29520. m.AddConditionType(v)
  29521. return nil
  29522. case sopnode.FieldNoReplyCondition:
  29523. v, ok := value.(int64)
  29524. if !ok {
  29525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29526. }
  29527. m.AddNoReplyCondition(v)
  29528. return nil
  29529. }
  29530. return fmt.Errorf("unknown SopNode numeric field %s", name)
  29531. }
  29532. // ClearedFields returns all nullable fields that were cleared during this
  29533. // mutation.
  29534. func (m *SopNodeMutation) ClearedFields() []string {
  29535. var fields []string
  29536. if m.FieldCleared(sopnode.FieldStatus) {
  29537. fields = append(fields, sopnode.FieldStatus)
  29538. }
  29539. if m.FieldCleared(sopnode.FieldDeletedAt) {
  29540. fields = append(fields, sopnode.FieldDeletedAt)
  29541. }
  29542. if m.FieldCleared(sopnode.FieldConditionList) {
  29543. fields = append(fields, sopnode.FieldConditionList)
  29544. }
  29545. if m.FieldCleared(sopnode.FieldActionMessage) {
  29546. fields = append(fields, sopnode.FieldActionMessage)
  29547. }
  29548. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  29549. fields = append(fields, sopnode.FieldActionLabelAdd)
  29550. }
  29551. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  29552. fields = append(fields, sopnode.FieldActionLabelDel)
  29553. }
  29554. if m.FieldCleared(sopnode.FieldActionForward) {
  29555. fields = append(fields, sopnode.FieldActionForward)
  29556. }
  29557. return fields
  29558. }
  29559. // FieldCleared returns a boolean indicating if a field with the given name was
  29560. // cleared in this mutation.
  29561. func (m *SopNodeMutation) FieldCleared(name string) bool {
  29562. _, ok := m.clearedFields[name]
  29563. return ok
  29564. }
  29565. // ClearField clears the value of the field with the given name. It returns an
  29566. // error if the field is not defined in the schema.
  29567. func (m *SopNodeMutation) ClearField(name string) error {
  29568. switch name {
  29569. case sopnode.FieldStatus:
  29570. m.ClearStatus()
  29571. return nil
  29572. case sopnode.FieldDeletedAt:
  29573. m.ClearDeletedAt()
  29574. return nil
  29575. case sopnode.FieldConditionList:
  29576. m.ClearConditionList()
  29577. return nil
  29578. case sopnode.FieldActionMessage:
  29579. m.ClearActionMessage()
  29580. return nil
  29581. case sopnode.FieldActionLabelAdd:
  29582. m.ClearActionLabelAdd()
  29583. return nil
  29584. case sopnode.FieldActionLabelDel:
  29585. m.ClearActionLabelDel()
  29586. return nil
  29587. case sopnode.FieldActionForward:
  29588. m.ClearActionForward()
  29589. return nil
  29590. }
  29591. return fmt.Errorf("unknown SopNode nullable field %s", name)
  29592. }
  29593. // ResetField resets all changes in the mutation for the field with the given name.
  29594. // It returns an error if the field is not defined in the schema.
  29595. func (m *SopNodeMutation) ResetField(name string) error {
  29596. switch name {
  29597. case sopnode.FieldCreatedAt:
  29598. m.ResetCreatedAt()
  29599. return nil
  29600. case sopnode.FieldUpdatedAt:
  29601. m.ResetUpdatedAt()
  29602. return nil
  29603. case sopnode.FieldStatus:
  29604. m.ResetStatus()
  29605. return nil
  29606. case sopnode.FieldDeletedAt:
  29607. m.ResetDeletedAt()
  29608. return nil
  29609. case sopnode.FieldStageID:
  29610. m.ResetStageID()
  29611. return nil
  29612. case sopnode.FieldParentID:
  29613. m.ResetParentID()
  29614. return nil
  29615. case sopnode.FieldName:
  29616. m.ResetName()
  29617. return nil
  29618. case sopnode.FieldConditionType:
  29619. m.ResetConditionType()
  29620. return nil
  29621. case sopnode.FieldConditionList:
  29622. m.ResetConditionList()
  29623. return nil
  29624. case sopnode.FieldNoReplyCondition:
  29625. m.ResetNoReplyCondition()
  29626. return nil
  29627. case sopnode.FieldNoReplyUnit:
  29628. m.ResetNoReplyUnit()
  29629. return nil
  29630. case sopnode.FieldActionMessage:
  29631. m.ResetActionMessage()
  29632. return nil
  29633. case sopnode.FieldActionLabelAdd:
  29634. m.ResetActionLabelAdd()
  29635. return nil
  29636. case sopnode.FieldActionLabelDel:
  29637. m.ResetActionLabelDel()
  29638. return nil
  29639. case sopnode.FieldActionForward:
  29640. m.ResetActionForward()
  29641. return nil
  29642. }
  29643. return fmt.Errorf("unknown SopNode field %s", name)
  29644. }
  29645. // AddedEdges returns all edge names that were set/added in this mutation.
  29646. func (m *SopNodeMutation) AddedEdges() []string {
  29647. edges := make([]string, 0, 2)
  29648. if m.sop_stage != nil {
  29649. edges = append(edges, sopnode.EdgeSopStage)
  29650. }
  29651. if m.node_messages != nil {
  29652. edges = append(edges, sopnode.EdgeNodeMessages)
  29653. }
  29654. return edges
  29655. }
  29656. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29657. // name in this mutation.
  29658. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  29659. switch name {
  29660. case sopnode.EdgeSopStage:
  29661. if id := m.sop_stage; id != nil {
  29662. return []ent.Value{*id}
  29663. }
  29664. case sopnode.EdgeNodeMessages:
  29665. ids := make([]ent.Value, 0, len(m.node_messages))
  29666. for id := range m.node_messages {
  29667. ids = append(ids, id)
  29668. }
  29669. return ids
  29670. }
  29671. return nil
  29672. }
  29673. // RemovedEdges returns all edge names that were removed in this mutation.
  29674. func (m *SopNodeMutation) RemovedEdges() []string {
  29675. edges := make([]string, 0, 2)
  29676. if m.removednode_messages != nil {
  29677. edges = append(edges, sopnode.EdgeNodeMessages)
  29678. }
  29679. return edges
  29680. }
  29681. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29682. // the given name in this mutation.
  29683. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  29684. switch name {
  29685. case sopnode.EdgeNodeMessages:
  29686. ids := make([]ent.Value, 0, len(m.removednode_messages))
  29687. for id := range m.removednode_messages {
  29688. ids = append(ids, id)
  29689. }
  29690. return ids
  29691. }
  29692. return nil
  29693. }
  29694. // ClearedEdges returns all edge names that were cleared in this mutation.
  29695. func (m *SopNodeMutation) ClearedEdges() []string {
  29696. edges := make([]string, 0, 2)
  29697. if m.clearedsop_stage {
  29698. edges = append(edges, sopnode.EdgeSopStage)
  29699. }
  29700. if m.clearednode_messages {
  29701. edges = append(edges, sopnode.EdgeNodeMessages)
  29702. }
  29703. return edges
  29704. }
  29705. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29706. // was cleared in this mutation.
  29707. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  29708. switch name {
  29709. case sopnode.EdgeSopStage:
  29710. return m.clearedsop_stage
  29711. case sopnode.EdgeNodeMessages:
  29712. return m.clearednode_messages
  29713. }
  29714. return false
  29715. }
  29716. // ClearEdge clears the value of the edge with the given name. It returns an error
  29717. // if that edge is not defined in the schema.
  29718. func (m *SopNodeMutation) ClearEdge(name string) error {
  29719. switch name {
  29720. case sopnode.EdgeSopStage:
  29721. m.ClearSopStage()
  29722. return nil
  29723. }
  29724. return fmt.Errorf("unknown SopNode unique edge %s", name)
  29725. }
  29726. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29727. // It returns an error if the edge is not defined in the schema.
  29728. func (m *SopNodeMutation) ResetEdge(name string) error {
  29729. switch name {
  29730. case sopnode.EdgeSopStage:
  29731. m.ResetSopStage()
  29732. return nil
  29733. case sopnode.EdgeNodeMessages:
  29734. m.ResetNodeMessages()
  29735. return nil
  29736. }
  29737. return fmt.Errorf("unknown SopNode edge %s", name)
  29738. }
  29739. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  29740. type SopStageMutation struct {
  29741. config
  29742. op Op
  29743. typ string
  29744. id *uint64
  29745. created_at *time.Time
  29746. updated_at *time.Time
  29747. status *uint8
  29748. addstatus *int8
  29749. deleted_at *time.Time
  29750. name *string
  29751. condition_type *int
  29752. addcondition_type *int
  29753. condition_operator *int
  29754. addcondition_operator *int
  29755. condition_list *[]custom_types.Condition
  29756. appendcondition_list []custom_types.Condition
  29757. action_message *[]custom_types.Action
  29758. appendaction_message []custom_types.Action
  29759. action_label_add *[]uint64
  29760. appendaction_label_add []uint64
  29761. action_label_del *[]uint64
  29762. appendaction_label_del []uint64
  29763. action_forward **custom_types.ActionForward
  29764. index_sort *int
  29765. addindex_sort *int
  29766. clearedFields map[string]struct{}
  29767. sop_task *uint64
  29768. clearedsop_task bool
  29769. stage_nodes map[uint64]struct{}
  29770. removedstage_nodes map[uint64]struct{}
  29771. clearedstage_nodes bool
  29772. stage_messages map[uint64]struct{}
  29773. removedstage_messages map[uint64]struct{}
  29774. clearedstage_messages bool
  29775. done bool
  29776. oldValue func(context.Context) (*SopStage, error)
  29777. predicates []predicate.SopStage
  29778. }
  29779. var _ ent.Mutation = (*SopStageMutation)(nil)
  29780. // sopstageOption allows management of the mutation configuration using functional options.
  29781. type sopstageOption func(*SopStageMutation)
  29782. // newSopStageMutation creates new mutation for the SopStage entity.
  29783. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  29784. m := &SopStageMutation{
  29785. config: c,
  29786. op: op,
  29787. typ: TypeSopStage,
  29788. clearedFields: make(map[string]struct{}),
  29789. }
  29790. for _, opt := range opts {
  29791. opt(m)
  29792. }
  29793. return m
  29794. }
  29795. // withSopStageID sets the ID field of the mutation.
  29796. func withSopStageID(id uint64) sopstageOption {
  29797. return func(m *SopStageMutation) {
  29798. var (
  29799. err error
  29800. once sync.Once
  29801. value *SopStage
  29802. )
  29803. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  29804. once.Do(func() {
  29805. if m.done {
  29806. err = errors.New("querying old values post mutation is not allowed")
  29807. } else {
  29808. value, err = m.Client().SopStage.Get(ctx, id)
  29809. }
  29810. })
  29811. return value, err
  29812. }
  29813. m.id = &id
  29814. }
  29815. }
  29816. // withSopStage sets the old SopStage of the mutation.
  29817. func withSopStage(node *SopStage) sopstageOption {
  29818. return func(m *SopStageMutation) {
  29819. m.oldValue = func(context.Context) (*SopStage, error) {
  29820. return node, nil
  29821. }
  29822. m.id = &node.ID
  29823. }
  29824. }
  29825. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29826. // executed in a transaction (ent.Tx), a transactional client is returned.
  29827. func (m SopStageMutation) Client() *Client {
  29828. client := &Client{config: m.config}
  29829. client.init()
  29830. return client
  29831. }
  29832. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29833. // it returns an error otherwise.
  29834. func (m SopStageMutation) Tx() (*Tx, error) {
  29835. if _, ok := m.driver.(*txDriver); !ok {
  29836. return nil, errors.New("ent: mutation is not running in a transaction")
  29837. }
  29838. tx := &Tx{config: m.config}
  29839. tx.init()
  29840. return tx, nil
  29841. }
  29842. // SetID sets the value of the id field. Note that this
  29843. // operation is only accepted on creation of SopStage entities.
  29844. func (m *SopStageMutation) SetID(id uint64) {
  29845. m.id = &id
  29846. }
  29847. // ID returns the ID value in the mutation. Note that the ID is only available
  29848. // if it was provided to the builder or after it was returned from the database.
  29849. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  29850. if m.id == nil {
  29851. return
  29852. }
  29853. return *m.id, true
  29854. }
  29855. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29856. // That means, if the mutation is applied within a transaction with an isolation level such
  29857. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29858. // or updated by the mutation.
  29859. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  29860. switch {
  29861. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29862. id, exists := m.ID()
  29863. if exists {
  29864. return []uint64{id}, nil
  29865. }
  29866. fallthrough
  29867. case m.op.Is(OpUpdate | OpDelete):
  29868. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  29869. default:
  29870. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29871. }
  29872. }
  29873. // SetCreatedAt sets the "created_at" field.
  29874. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  29875. m.created_at = &t
  29876. }
  29877. // CreatedAt returns the value of the "created_at" field in the mutation.
  29878. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  29879. v := m.created_at
  29880. if v == nil {
  29881. return
  29882. }
  29883. return *v, true
  29884. }
  29885. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  29886. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29888. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29889. if !m.op.Is(OpUpdateOne) {
  29890. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29891. }
  29892. if m.id == nil || m.oldValue == nil {
  29893. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29894. }
  29895. oldValue, err := m.oldValue(ctx)
  29896. if err != nil {
  29897. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29898. }
  29899. return oldValue.CreatedAt, nil
  29900. }
  29901. // ResetCreatedAt resets all changes to the "created_at" field.
  29902. func (m *SopStageMutation) ResetCreatedAt() {
  29903. m.created_at = nil
  29904. }
  29905. // SetUpdatedAt sets the "updated_at" field.
  29906. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  29907. m.updated_at = &t
  29908. }
  29909. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29910. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  29911. v := m.updated_at
  29912. if v == nil {
  29913. return
  29914. }
  29915. return *v, true
  29916. }
  29917. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  29918. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29920. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29921. if !m.op.Is(OpUpdateOne) {
  29922. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29923. }
  29924. if m.id == nil || m.oldValue == nil {
  29925. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29926. }
  29927. oldValue, err := m.oldValue(ctx)
  29928. if err != nil {
  29929. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29930. }
  29931. return oldValue.UpdatedAt, nil
  29932. }
  29933. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29934. func (m *SopStageMutation) ResetUpdatedAt() {
  29935. m.updated_at = nil
  29936. }
  29937. // SetStatus sets the "status" field.
  29938. func (m *SopStageMutation) SetStatus(u uint8) {
  29939. m.status = &u
  29940. m.addstatus = nil
  29941. }
  29942. // Status returns the value of the "status" field in the mutation.
  29943. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  29944. v := m.status
  29945. if v == nil {
  29946. return
  29947. }
  29948. return *v, true
  29949. }
  29950. // OldStatus returns the old "status" field's value of the SopStage entity.
  29951. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  29952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29953. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29954. if !m.op.Is(OpUpdateOne) {
  29955. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29956. }
  29957. if m.id == nil || m.oldValue == nil {
  29958. return v, errors.New("OldStatus requires an ID field in the mutation")
  29959. }
  29960. oldValue, err := m.oldValue(ctx)
  29961. if err != nil {
  29962. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29963. }
  29964. return oldValue.Status, nil
  29965. }
  29966. // AddStatus adds u to the "status" field.
  29967. func (m *SopStageMutation) AddStatus(u int8) {
  29968. if m.addstatus != nil {
  29969. *m.addstatus += u
  29970. } else {
  29971. m.addstatus = &u
  29972. }
  29973. }
  29974. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29975. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  29976. v := m.addstatus
  29977. if v == nil {
  29978. return
  29979. }
  29980. return *v, true
  29981. }
  29982. // ClearStatus clears the value of the "status" field.
  29983. func (m *SopStageMutation) ClearStatus() {
  29984. m.status = nil
  29985. m.addstatus = nil
  29986. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  29987. }
  29988. // StatusCleared returns if the "status" field was cleared in this mutation.
  29989. func (m *SopStageMutation) StatusCleared() bool {
  29990. _, ok := m.clearedFields[sopstage.FieldStatus]
  29991. return ok
  29992. }
  29993. // ResetStatus resets all changes to the "status" field.
  29994. func (m *SopStageMutation) ResetStatus() {
  29995. m.status = nil
  29996. m.addstatus = nil
  29997. delete(m.clearedFields, sopstage.FieldStatus)
  29998. }
  29999. // SetDeletedAt sets the "deleted_at" field.
  30000. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  30001. m.deleted_at = &t
  30002. }
  30003. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30004. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  30005. v := m.deleted_at
  30006. if v == nil {
  30007. return
  30008. }
  30009. return *v, true
  30010. }
  30011. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  30012. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30014. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30015. if !m.op.Is(OpUpdateOne) {
  30016. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30017. }
  30018. if m.id == nil || m.oldValue == nil {
  30019. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30020. }
  30021. oldValue, err := m.oldValue(ctx)
  30022. if err != nil {
  30023. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30024. }
  30025. return oldValue.DeletedAt, nil
  30026. }
  30027. // ClearDeletedAt clears the value of the "deleted_at" field.
  30028. func (m *SopStageMutation) ClearDeletedAt() {
  30029. m.deleted_at = nil
  30030. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  30031. }
  30032. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30033. func (m *SopStageMutation) DeletedAtCleared() bool {
  30034. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  30035. return ok
  30036. }
  30037. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30038. func (m *SopStageMutation) ResetDeletedAt() {
  30039. m.deleted_at = nil
  30040. delete(m.clearedFields, sopstage.FieldDeletedAt)
  30041. }
  30042. // SetTaskID sets the "task_id" field.
  30043. func (m *SopStageMutation) SetTaskID(u uint64) {
  30044. m.sop_task = &u
  30045. }
  30046. // TaskID returns the value of the "task_id" field in the mutation.
  30047. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  30048. v := m.sop_task
  30049. if v == nil {
  30050. return
  30051. }
  30052. return *v, true
  30053. }
  30054. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  30055. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30057. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  30058. if !m.op.Is(OpUpdateOne) {
  30059. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  30060. }
  30061. if m.id == nil || m.oldValue == nil {
  30062. return v, errors.New("OldTaskID requires an ID field in the mutation")
  30063. }
  30064. oldValue, err := m.oldValue(ctx)
  30065. if err != nil {
  30066. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  30067. }
  30068. return oldValue.TaskID, nil
  30069. }
  30070. // ResetTaskID resets all changes to the "task_id" field.
  30071. func (m *SopStageMutation) ResetTaskID() {
  30072. m.sop_task = nil
  30073. }
  30074. // SetName sets the "name" field.
  30075. func (m *SopStageMutation) SetName(s string) {
  30076. m.name = &s
  30077. }
  30078. // Name returns the value of the "name" field in the mutation.
  30079. func (m *SopStageMutation) Name() (r string, exists bool) {
  30080. v := m.name
  30081. if v == nil {
  30082. return
  30083. }
  30084. return *v, true
  30085. }
  30086. // OldName returns the old "name" field's value of the SopStage entity.
  30087. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30089. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  30090. if !m.op.Is(OpUpdateOne) {
  30091. return v, errors.New("OldName is only allowed on UpdateOne operations")
  30092. }
  30093. if m.id == nil || m.oldValue == nil {
  30094. return v, errors.New("OldName requires an ID field in the mutation")
  30095. }
  30096. oldValue, err := m.oldValue(ctx)
  30097. if err != nil {
  30098. return v, fmt.Errorf("querying old value for OldName: %w", err)
  30099. }
  30100. return oldValue.Name, nil
  30101. }
  30102. // ResetName resets all changes to the "name" field.
  30103. func (m *SopStageMutation) ResetName() {
  30104. m.name = nil
  30105. }
  30106. // SetConditionType sets the "condition_type" field.
  30107. func (m *SopStageMutation) SetConditionType(i int) {
  30108. m.condition_type = &i
  30109. m.addcondition_type = nil
  30110. }
  30111. // ConditionType returns the value of the "condition_type" field in the mutation.
  30112. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  30113. v := m.condition_type
  30114. if v == nil {
  30115. return
  30116. }
  30117. return *v, true
  30118. }
  30119. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  30120. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30122. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  30123. if !m.op.Is(OpUpdateOne) {
  30124. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  30125. }
  30126. if m.id == nil || m.oldValue == nil {
  30127. return v, errors.New("OldConditionType requires an ID field in the mutation")
  30128. }
  30129. oldValue, err := m.oldValue(ctx)
  30130. if err != nil {
  30131. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  30132. }
  30133. return oldValue.ConditionType, nil
  30134. }
  30135. // AddConditionType adds i to the "condition_type" field.
  30136. func (m *SopStageMutation) AddConditionType(i int) {
  30137. if m.addcondition_type != nil {
  30138. *m.addcondition_type += i
  30139. } else {
  30140. m.addcondition_type = &i
  30141. }
  30142. }
  30143. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  30144. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  30145. v := m.addcondition_type
  30146. if v == nil {
  30147. return
  30148. }
  30149. return *v, true
  30150. }
  30151. // ResetConditionType resets all changes to the "condition_type" field.
  30152. func (m *SopStageMutation) ResetConditionType() {
  30153. m.condition_type = nil
  30154. m.addcondition_type = nil
  30155. }
  30156. // SetConditionOperator sets the "condition_operator" field.
  30157. func (m *SopStageMutation) SetConditionOperator(i int) {
  30158. m.condition_operator = &i
  30159. m.addcondition_operator = nil
  30160. }
  30161. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  30162. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  30163. v := m.condition_operator
  30164. if v == nil {
  30165. return
  30166. }
  30167. return *v, true
  30168. }
  30169. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  30170. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30172. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  30173. if !m.op.Is(OpUpdateOne) {
  30174. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  30175. }
  30176. if m.id == nil || m.oldValue == nil {
  30177. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  30178. }
  30179. oldValue, err := m.oldValue(ctx)
  30180. if err != nil {
  30181. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  30182. }
  30183. return oldValue.ConditionOperator, nil
  30184. }
  30185. // AddConditionOperator adds i to the "condition_operator" field.
  30186. func (m *SopStageMutation) AddConditionOperator(i int) {
  30187. if m.addcondition_operator != nil {
  30188. *m.addcondition_operator += i
  30189. } else {
  30190. m.addcondition_operator = &i
  30191. }
  30192. }
  30193. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  30194. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  30195. v := m.addcondition_operator
  30196. if v == nil {
  30197. return
  30198. }
  30199. return *v, true
  30200. }
  30201. // ResetConditionOperator resets all changes to the "condition_operator" field.
  30202. func (m *SopStageMutation) ResetConditionOperator() {
  30203. m.condition_operator = nil
  30204. m.addcondition_operator = nil
  30205. }
  30206. // SetConditionList sets the "condition_list" field.
  30207. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  30208. m.condition_list = &ct
  30209. m.appendcondition_list = nil
  30210. }
  30211. // ConditionList returns the value of the "condition_list" field in the mutation.
  30212. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  30213. v := m.condition_list
  30214. if v == nil {
  30215. return
  30216. }
  30217. return *v, true
  30218. }
  30219. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  30220. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30222. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  30223. if !m.op.Is(OpUpdateOne) {
  30224. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  30225. }
  30226. if m.id == nil || m.oldValue == nil {
  30227. return v, errors.New("OldConditionList requires an ID field in the mutation")
  30228. }
  30229. oldValue, err := m.oldValue(ctx)
  30230. if err != nil {
  30231. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  30232. }
  30233. return oldValue.ConditionList, nil
  30234. }
  30235. // AppendConditionList adds ct to the "condition_list" field.
  30236. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  30237. m.appendcondition_list = append(m.appendcondition_list, ct...)
  30238. }
  30239. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  30240. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  30241. if len(m.appendcondition_list) == 0 {
  30242. return nil, false
  30243. }
  30244. return m.appendcondition_list, true
  30245. }
  30246. // ResetConditionList resets all changes to the "condition_list" field.
  30247. func (m *SopStageMutation) ResetConditionList() {
  30248. m.condition_list = nil
  30249. m.appendcondition_list = nil
  30250. }
  30251. // SetActionMessage sets the "action_message" field.
  30252. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  30253. m.action_message = &ct
  30254. m.appendaction_message = nil
  30255. }
  30256. // ActionMessage returns the value of the "action_message" field in the mutation.
  30257. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  30258. v := m.action_message
  30259. if v == nil {
  30260. return
  30261. }
  30262. return *v, true
  30263. }
  30264. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  30265. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30267. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  30268. if !m.op.Is(OpUpdateOne) {
  30269. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  30270. }
  30271. if m.id == nil || m.oldValue == nil {
  30272. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  30273. }
  30274. oldValue, err := m.oldValue(ctx)
  30275. if err != nil {
  30276. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  30277. }
  30278. return oldValue.ActionMessage, nil
  30279. }
  30280. // AppendActionMessage adds ct to the "action_message" field.
  30281. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  30282. m.appendaction_message = append(m.appendaction_message, ct...)
  30283. }
  30284. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  30285. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  30286. if len(m.appendaction_message) == 0 {
  30287. return nil, false
  30288. }
  30289. return m.appendaction_message, true
  30290. }
  30291. // ClearActionMessage clears the value of the "action_message" field.
  30292. func (m *SopStageMutation) ClearActionMessage() {
  30293. m.action_message = nil
  30294. m.appendaction_message = nil
  30295. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  30296. }
  30297. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  30298. func (m *SopStageMutation) ActionMessageCleared() bool {
  30299. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  30300. return ok
  30301. }
  30302. // ResetActionMessage resets all changes to the "action_message" field.
  30303. func (m *SopStageMutation) ResetActionMessage() {
  30304. m.action_message = nil
  30305. m.appendaction_message = nil
  30306. delete(m.clearedFields, sopstage.FieldActionMessage)
  30307. }
  30308. // SetActionLabelAdd sets the "action_label_add" field.
  30309. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  30310. m.action_label_add = &u
  30311. m.appendaction_label_add = nil
  30312. }
  30313. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  30314. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  30315. v := m.action_label_add
  30316. if v == nil {
  30317. return
  30318. }
  30319. return *v, true
  30320. }
  30321. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  30322. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30324. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  30325. if !m.op.Is(OpUpdateOne) {
  30326. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  30327. }
  30328. if m.id == nil || m.oldValue == nil {
  30329. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  30330. }
  30331. oldValue, err := m.oldValue(ctx)
  30332. if err != nil {
  30333. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  30334. }
  30335. return oldValue.ActionLabelAdd, nil
  30336. }
  30337. // AppendActionLabelAdd adds u to the "action_label_add" field.
  30338. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  30339. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  30340. }
  30341. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  30342. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  30343. if len(m.appendaction_label_add) == 0 {
  30344. return nil, false
  30345. }
  30346. return m.appendaction_label_add, true
  30347. }
  30348. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  30349. func (m *SopStageMutation) ClearActionLabelAdd() {
  30350. m.action_label_add = nil
  30351. m.appendaction_label_add = nil
  30352. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  30353. }
  30354. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  30355. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  30356. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  30357. return ok
  30358. }
  30359. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  30360. func (m *SopStageMutation) ResetActionLabelAdd() {
  30361. m.action_label_add = nil
  30362. m.appendaction_label_add = nil
  30363. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  30364. }
  30365. // SetActionLabelDel sets the "action_label_del" field.
  30366. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  30367. m.action_label_del = &u
  30368. m.appendaction_label_del = nil
  30369. }
  30370. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  30371. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  30372. v := m.action_label_del
  30373. if v == nil {
  30374. return
  30375. }
  30376. return *v, true
  30377. }
  30378. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  30379. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30381. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  30382. if !m.op.Is(OpUpdateOne) {
  30383. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  30384. }
  30385. if m.id == nil || m.oldValue == nil {
  30386. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  30387. }
  30388. oldValue, err := m.oldValue(ctx)
  30389. if err != nil {
  30390. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  30391. }
  30392. return oldValue.ActionLabelDel, nil
  30393. }
  30394. // AppendActionLabelDel adds u to the "action_label_del" field.
  30395. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  30396. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  30397. }
  30398. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  30399. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  30400. if len(m.appendaction_label_del) == 0 {
  30401. return nil, false
  30402. }
  30403. return m.appendaction_label_del, true
  30404. }
  30405. // ClearActionLabelDel clears the value of the "action_label_del" field.
  30406. func (m *SopStageMutation) ClearActionLabelDel() {
  30407. m.action_label_del = nil
  30408. m.appendaction_label_del = nil
  30409. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  30410. }
  30411. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  30412. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  30413. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  30414. return ok
  30415. }
  30416. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  30417. func (m *SopStageMutation) ResetActionLabelDel() {
  30418. m.action_label_del = nil
  30419. m.appendaction_label_del = nil
  30420. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  30421. }
  30422. // SetActionForward sets the "action_forward" field.
  30423. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  30424. m.action_forward = &ctf
  30425. }
  30426. // ActionForward returns the value of the "action_forward" field in the mutation.
  30427. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  30428. v := m.action_forward
  30429. if v == nil {
  30430. return
  30431. }
  30432. return *v, true
  30433. }
  30434. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  30435. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30436. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30437. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  30438. if !m.op.Is(OpUpdateOne) {
  30439. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  30440. }
  30441. if m.id == nil || m.oldValue == nil {
  30442. return v, errors.New("OldActionForward requires an ID field in the mutation")
  30443. }
  30444. oldValue, err := m.oldValue(ctx)
  30445. if err != nil {
  30446. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  30447. }
  30448. return oldValue.ActionForward, nil
  30449. }
  30450. // ClearActionForward clears the value of the "action_forward" field.
  30451. func (m *SopStageMutation) ClearActionForward() {
  30452. m.action_forward = nil
  30453. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  30454. }
  30455. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  30456. func (m *SopStageMutation) ActionForwardCleared() bool {
  30457. _, ok := m.clearedFields[sopstage.FieldActionForward]
  30458. return ok
  30459. }
  30460. // ResetActionForward resets all changes to the "action_forward" field.
  30461. func (m *SopStageMutation) ResetActionForward() {
  30462. m.action_forward = nil
  30463. delete(m.clearedFields, sopstage.FieldActionForward)
  30464. }
  30465. // SetIndexSort sets the "index_sort" field.
  30466. func (m *SopStageMutation) SetIndexSort(i int) {
  30467. m.index_sort = &i
  30468. m.addindex_sort = nil
  30469. }
  30470. // IndexSort returns the value of the "index_sort" field in the mutation.
  30471. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  30472. v := m.index_sort
  30473. if v == nil {
  30474. return
  30475. }
  30476. return *v, true
  30477. }
  30478. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  30479. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  30480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30481. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  30482. if !m.op.Is(OpUpdateOne) {
  30483. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  30484. }
  30485. if m.id == nil || m.oldValue == nil {
  30486. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  30487. }
  30488. oldValue, err := m.oldValue(ctx)
  30489. if err != nil {
  30490. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  30491. }
  30492. return oldValue.IndexSort, nil
  30493. }
  30494. // AddIndexSort adds i to the "index_sort" field.
  30495. func (m *SopStageMutation) AddIndexSort(i int) {
  30496. if m.addindex_sort != nil {
  30497. *m.addindex_sort += i
  30498. } else {
  30499. m.addindex_sort = &i
  30500. }
  30501. }
  30502. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  30503. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  30504. v := m.addindex_sort
  30505. if v == nil {
  30506. return
  30507. }
  30508. return *v, true
  30509. }
  30510. // ClearIndexSort clears the value of the "index_sort" field.
  30511. func (m *SopStageMutation) ClearIndexSort() {
  30512. m.index_sort = nil
  30513. m.addindex_sort = nil
  30514. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  30515. }
  30516. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  30517. func (m *SopStageMutation) IndexSortCleared() bool {
  30518. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  30519. return ok
  30520. }
  30521. // ResetIndexSort resets all changes to the "index_sort" field.
  30522. func (m *SopStageMutation) ResetIndexSort() {
  30523. m.index_sort = nil
  30524. m.addindex_sort = nil
  30525. delete(m.clearedFields, sopstage.FieldIndexSort)
  30526. }
  30527. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  30528. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  30529. m.sop_task = &id
  30530. }
  30531. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  30532. func (m *SopStageMutation) ClearSopTask() {
  30533. m.clearedsop_task = true
  30534. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  30535. }
  30536. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  30537. func (m *SopStageMutation) SopTaskCleared() bool {
  30538. return m.clearedsop_task
  30539. }
  30540. // SopTaskID returns the "sop_task" edge ID in the mutation.
  30541. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  30542. if m.sop_task != nil {
  30543. return *m.sop_task, true
  30544. }
  30545. return
  30546. }
  30547. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  30548. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30549. // SopTaskID instead. It exists only for internal usage by the builders.
  30550. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  30551. if id := m.sop_task; id != nil {
  30552. ids = append(ids, *id)
  30553. }
  30554. return
  30555. }
  30556. // ResetSopTask resets all changes to the "sop_task" edge.
  30557. func (m *SopStageMutation) ResetSopTask() {
  30558. m.sop_task = nil
  30559. m.clearedsop_task = false
  30560. }
  30561. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  30562. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  30563. if m.stage_nodes == nil {
  30564. m.stage_nodes = make(map[uint64]struct{})
  30565. }
  30566. for i := range ids {
  30567. m.stage_nodes[ids[i]] = struct{}{}
  30568. }
  30569. }
  30570. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  30571. func (m *SopStageMutation) ClearStageNodes() {
  30572. m.clearedstage_nodes = true
  30573. }
  30574. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  30575. func (m *SopStageMutation) StageNodesCleared() bool {
  30576. return m.clearedstage_nodes
  30577. }
  30578. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  30579. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  30580. if m.removedstage_nodes == nil {
  30581. m.removedstage_nodes = make(map[uint64]struct{})
  30582. }
  30583. for i := range ids {
  30584. delete(m.stage_nodes, ids[i])
  30585. m.removedstage_nodes[ids[i]] = struct{}{}
  30586. }
  30587. }
  30588. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  30589. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  30590. for id := range m.removedstage_nodes {
  30591. ids = append(ids, id)
  30592. }
  30593. return
  30594. }
  30595. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  30596. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  30597. for id := range m.stage_nodes {
  30598. ids = append(ids, id)
  30599. }
  30600. return
  30601. }
  30602. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  30603. func (m *SopStageMutation) ResetStageNodes() {
  30604. m.stage_nodes = nil
  30605. m.clearedstage_nodes = false
  30606. m.removedstage_nodes = nil
  30607. }
  30608. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  30609. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  30610. if m.stage_messages == nil {
  30611. m.stage_messages = make(map[uint64]struct{})
  30612. }
  30613. for i := range ids {
  30614. m.stage_messages[ids[i]] = struct{}{}
  30615. }
  30616. }
  30617. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  30618. func (m *SopStageMutation) ClearStageMessages() {
  30619. m.clearedstage_messages = true
  30620. }
  30621. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  30622. func (m *SopStageMutation) StageMessagesCleared() bool {
  30623. return m.clearedstage_messages
  30624. }
  30625. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  30626. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  30627. if m.removedstage_messages == nil {
  30628. m.removedstage_messages = make(map[uint64]struct{})
  30629. }
  30630. for i := range ids {
  30631. delete(m.stage_messages, ids[i])
  30632. m.removedstage_messages[ids[i]] = struct{}{}
  30633. }
  30634. }
  30635. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  30636. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  30637. for id := range m.removedstage_messages {
  30638. ids = append(ids, id)
  30639. }
  30640. return
  30641. }
  30642. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  30643. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  30644. for id := range m.stage_messages {
  30645. ids = append(ids, id)
  30646. }
  30647. return
  30648. }
  30649. // ResetStageMessages resets all changes to the "stage_messages" edge.
  30650. func (m *SopStageMutation) ResetStageMessages() {
  30651. m.stage_messages = nil
  30652. m.clearedstage_messages = false
  30653. m.removedstage_messages = nil
  30654. }
  30655. // Where appends a list predicates to the SopStageMutation builder.
  30656. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  30657. m.predicates = append(m.predicates, ps...)
  30658. }
  30659. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  30660. // users can use type-assertion to append predicates that do not depend on any generated package.
  30661. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  30662. p := make([]predicate.SopStage, len(ps))
  30663. for i := range ps {
  30664. p[i] = ps[i]
  30665. }
  30666. m.Where(p...)
  30667. }
  30668. // Op returns the operation name.
  30669. func (m *SopStageMutation) Op() Op {
  30670. return m.op
  30671. }
  30672. // SetOp allows setting the mutation operation.
  30673. func (m *SopStageMutation) SetOp(op Op) {
  30674. m.op = op
  30675. }
  30676. // Type returns the node type of this mutation (SopStage).
  30677. func (m *SopStageMutation) Type() string {
  30678. return m.typ
  30679. }
  30680. // Fields returns all fields that were changed during this mutation. Note that in
  30681. // order to get all numeric fields that were incremented/decremented, call
  30682. // AddedFields().
  30683. func (m *SopStageMutation) Fields() []string {
  30684. fields := make([]string, 0, 14)
  30685. if m.created_at != nil {
  30686. fields = append(fields, sopstage.FieldCreatedAt)
  30687. }
  30688. if m.updated_at != nil {
  30689. fields = append(fields, sopstage.FieldUpdatedAt)
  30690. }
  30691. if m.status != nil {
  30692. fields = append(fields, sopstage.FieldStatus)
  30693. }
  30694. if m.deleted_at != nil {
  30695. fields = append(fields, sopstage.FieldDeletedAt)
  30696. }
  30697. if m.sop_task != nil {
  30698. fields = append(fields, sopstage.FieldTaskID)
  30699. }
  30700. if m.name != nil {
  30701. fields = append(fields, sopstage.FieldName)
  30702. }
  30703. if m.condition_type != nil {
  30704. fields = append(fields, sopstage.FieldConditionType)
  30705. }
  30706. if m.condition_operator != nil {
  30707. fields = append(fields, sopstage.FieldConditionOperator)
  30708. }
  30709. if m.condition_list != nil {
  30710. fields = append(fields, sopstage.FieldConditionList)
  30711. }
  30712. if m.action_message != nil {
  30713. fields = append(fields, sopstage.FieldActionMessage)
  30714. }
  30715. if m.action_label_add != nil {
  30716. fields = append(fields, sopstage.FieldActionLabelAdd)
  30717. }
  30718. if m.action_label_del != nil {
  30719. fields = append(fields, sopstage.FieldActionLabelDel)
  30720. }
  30721. if m.action_forward != nil {
  30722. fields = append(fields, sopstage.FieldActionForward)
  30723. }
  30724. if m.index_sort != nil {
  30725. fields = append(fields, sopstage.FieldIndexSort)
  30726. }
  30727. return fields
  30728. }
  30729. // Field returns the value of a field with the given name. The second boolean
  30730. // return value indicates that this field was not set, or was not defined in the
  30731. // schema.
  30732. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  30733. switch name {
  30734. case sopstage.FieldCreatedAt:
  30735. return m.CreatedAt()
  30736. case sopstage.FieldUpdatedAt:
  30737. return m.UpdatedAt()
  30738. case sopstage.FieldStatus:
  30739. return m.Status()
  30740. case sopstage.FieldDeletedAt:
  30741. return m.DeletedAt()
  30742. case sopstage.FieldTaskID:
  30743. return m.TaskID()
  30744. case sopstage.FieldName:
  30745. return m.Name()
  30746. case sopstage.FieldConditionType:
  30747. return m.ConditionType()
  30748. case sopstage.FieldConditionOperator:
  30749. return m.ConditionOperator()
  30750. case sopstage.FieldConditionList:
  30751. return m.ConditionList()
  30752. case sopstage.FieldActionMessage:
  30753. return m.ActionMessage()
  30754. case sopstage.FieldActionLabelAdd:
  30755. return m.ActionLabelAdd()
  30756. case sopstage.FieldActionLabelDel:
  30757. return m.ActionLabelDel()
  30758. case sopstage.FieldActionForward:
  30759. return m.ActionForward()
  30760. case sopstage.FieldIndexSort:
  30761. return m.IndexSort()
  30762. }
  30763. return nil, false
  30764. }
  30765. // OldField returns the old value of the field from the database. An error is
  30766. // returned if the mutation operation is not UpdateOne, or the query to the
  30767. // database failed.
  30768. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30769. switch name {
  30770. case sopstage.FieldCreatedAt:
  30771. return m.OldCreatedAt(ctx)
  30772. case sopstage.FieldUpdatedAt:
  30773. return m.OldUpdatedAt(ctx)
  30774. case sopstage.FieldStatus:
  30775. return m.OldStatus(ctx)
  30776. case sopstage.FieldDeletedAt:
  30777. return m.OldDeletedAt(ctx)
  30778. case sopstage.FieldTaskID:
  30779. return m.OldTaskID(ctx)
  30780. case sopstage.FieldName:
  30781. return m.OldName(ctx)
  30782. case sopstage.FieldConditionType:
  30783. return m.OldConditionType(ctx)
  30784. case sopstage.FieldConditionOperator:
  30785. return m.OldConditionOperator(ctx)
  30786. case sopstage.FieldConditionList:
  30787. return m.OldConditionList(ctx)
  30788. case sopstage.FieldActionMessage:
  30789. return m.OldActionMessage(ctx)
  30790. case sopstage.FieldActionLabelAdd:
  30791. return m.OldActionLabelAdd(ctx)
  30792. case sopstage.FieldActionLabelDel:
  30793. return m.OldActionLabelDel(ctx)
  30794. case sopstage.FieldActionForward:
  30795. return m.OldActionForward(ctx)
  30796. case sopstage.FieldIndexSort:
  30797. return m.OldIndexSort(ctx)
  30798. }
  30799. return nil, fmt.Errorf("unknown SopStage field %s", name)
  30800. }
  30801. // SetField sets the value of a field with the given name. It returns an error if
  30802. // the field is not defined in the schema, or if the type mismatched the field
  30803. // type.
  30804. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  30805. switch name {
  30806. case sopstage.FieldCreatedAt:
  30807. v, ok := value.(time.Time)
  30808. if !ok {
  30809. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30810. }
  30811. m.SetCreatedAt(v)
  30812. return nil
  30813. case sopstage.FieldUpdatedAt:
  30814. v, ok := value.(time.Time)
  30815. if !ok {
  30816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30817. }
  30818. m.SetUpdatedAt(v)
  30819. return nil
  30820. case sopstage.FieldStatus:
  30821. v, ok := value.(uint8)
  30822. if !ok {
  30823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30824. }
  30825. m.SetStatus(v)
  30826. return nil
  30827. case sopstage.FieldDeletedAt:
  30828. v, ok := value.(time.Time)
  30829. if !ok {
  30830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30831. }
  30832. m.SetDeletedAt(v)
  30833. return nil
  30834. case sopstage.FieldTaskID:
  30835. v, ok := value.(uint64)
  30836. if !ok {
  30837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30838. }
  30839. m.SetTaskID(v)
  30840. return nil
  30841. case sopstage.FieldName:
  30842. v, ok := value.(string)
  30843. if !ok {
  30844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30845. }
  30846. m.SetName(v)
  30847. return nil
  30848. case sopstage.FieldConditionType:
  30849. v, ok := value.(int)
  30850. if !ok {
  30851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30852. }
  30853. m.SetConditionType(v)
  30854. return nil
  30855. case sopstage.FieldConditionOperator:
  30856. v, ok := value.(int)
  30857. if !ok {
  30858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30859. }
  30860. m.SetConditionOperator(v)
  30861. return nil
  30862. case sopstage.FieldConditionList:
  30863. v, ok := value.([]custom_types.Condition)
  30864. if !ok {
  30865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30866. }
  30867. m.SetConditionList(v)
  30868. return nil
  30869. case sopstage.FieldActionMessage:
  30870. v, ok := value.([]custom_types.Action)
  30871. if !ok {
  30872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30873. }
  30874. m.SetActionMessage(v)
  30875. return nil
  30876. case sopstage.FieldActionLabelAdd:
  30877. v, ok := value.([]uint64)
  30878. if !ok {
  30879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30880. }
  30881. m.SetActionLabelAdd(v)
  30882. return nil
  30883. case sopstage.FieldActionLabelDel:
  30884. v, ok := value.([]uint64)
  30885. if !ok {
  30886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30887. }
  30888. m.SetActionLabelDel(v)
  30889. return nil
  30890. case sopstage.FieldActionForward:
  30891. v, ok := value.(*custom_types.ActionForward)
  30892. if !ok {
  30893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30894. }
  30895. m.SetActionForward(v)
  30896. return nil
  30897. case sopstage.FieldIndexSort:
  30898. v, ok := value.(int)
  30899. if !ok {
  30900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30901. }
  30902. m.SetIndexSort(v)
  30903. return nil
  30904. }
  30905. return fmt.Errorf("unknown SopStage field %s", name)
  30906. }
  30907. // AddedFields returns all numeric fields that were incremented/decremented during
  30908. // this mutation.
  30909. func (m *SopStageMutation) AddedFields() []string {
  30910. var fields []string
  30911. if m.addstatus != nil {
  30912. fields = append(fields, sopstage.FieldStatus)
  30913. }
  30914. if m.addcondition_type != nil {
  30915. fields = append(fields, sopstage.FieldConditionType)
  30916. }
  30917. if m.addcondition_operator != nil {
  30918. fields = append(fields, sopstage.FieldConditionOperator)
  30919. }
  30920. if m.addindex_sort != nil {
  30921. fields = append(fields, sopstage.FieldIndexSort)
  30922. }
  30923. return fields
  30924. }
  30925. // AddedField returns the numeric value that was incremented/decremented on a field
  30926. // with the given name. The second boolean return value indicates that this field
  30927. // was not set, or was not defined in the schema.
  30928. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  30929. switch name {
  30930. case sopstage.FieldStatus:
  30931. return m.AddedStatus()
  30932. case sopstage.FieldConditionType:
  30933. return m.AddedConditionType()
  30934. case sopstage.FieldConditionOperator:
  30935. return m.AddedConditionOperator()
  30936. case sopstage.FieldIndexSort:
  30937. return m.AddedIndexSort()
  30938. }
  30939. return nil, false
  30940. }
  30941. // AddField adds the value to the field with the given name. It returns an error if
  30942. // the field is not defined in the schema, or if the type mismatched the field
  30943. // type.
  30944. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  30945. switch name {
  30946. case sopstage.FieldStatus:
  30947. v, ok := value.(int8)
  30948. if !ok {
  30949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30950. }
  30951. m.AddStatus(v)
  30952. return nil
  30953. case sopstage.FieldConditionType:
  30954. v, ok := value.(int)
  30955. if !ok {
  30956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30957. }
  30958. m.AddConditionType(v)
  30959. return nil
  30960. case sopstage.FieldConditionOperator:
  30961. v, ok := value.(int)
  30962. if !ok {
  30963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30964. }
  30965. m.AddConditionOperator(v)
  30966. return nil
  30967. case sopstage.FieldIndexSort:
  30968. v, ok := value.(int)
  30969. if !ok {
  30970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30971. }
  30972. m.AddIndexSort(v)
  30973. return nil
  30974. }
  30975. return fmt.Errorf("unknown SopStage numeric field %s", name)
  30976. }
  30977. // ClearedFields returns all nullable fields that were cleared during this
  30978. // mutation.
  30979. func (m *SopStageMutation) ClearedFields() []string {
  30980. var fields []string
  30981. if m.FieldCleared(sopstage.FieldStatus) {
  30982. fields = append(fields, sopstage.FieldStatus)
  30983. }
  30984. if m.FieldCleared(sopstage.FieldDeletedAt) {
  30985. fields = append(fields, sopstage.FieldDeletedAt)
  30986. }
  30987. if m.FieldCleared(sopstage.FieldActionMessage) {
  30988. fields = append(fields, sopstage.FieldActionMessage)
  30989. }
  30990. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  30991. fields = append(fields, sopstage.FieldActionLabelAdd)
  30992. }
  30993. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  30994. fields = append(fields, sopstage.FieldActionLabelDel)
  30995. }
  30996. if m.FieldCleared(sopstage.FieldActionForward) {
  30997. fields = append(fields, sopstage.FieldActionForward)
  30998. }
  30999. if m.FieldCleared(sopstage.FieldIndexSort) {
  31000. fields = append(fields, sopstage.FieldIndexSort)
  31001. }
  31002. return fields
  31003. }
  31004. // FieldCleared returns a boolean indicating if a field with the given name was
  31005. // cleared in this mutation.
  31006. func (m *SopStageMutation) FieldCleared(name string) bool {
  31007. _, ok := m.clearedFields[name]
  31008. return ok
  31009. }
  31010. // ClearField clears the value of the field with the given name. It returns an
  31011. // error if the field is not defined in the schema.
  31012. func (m *SopStageMutation) ClearField(name string) error {
  31013. switch name {
  31014. case sopstage.FieldStatus:
  31015. m.ClearStatus()
  31016. return nil
  31017. case sopstage.FieldDeletedAt:
  31018. m.ClearDeletedAt()
  31019. return nil
  31020. case sopstage.FieldActionMessage:
  31021. m.ClearActionMessage()
  31022. return nil
  31023. case sopstage.FieldActionLabelAdd:
  31024. m.ClearActionLabelAdd()
  31025. return nil
  31026. case sopstage.FieldActionLabelDel:
  31027. m.ClearActionLabelDel()
  31028. return nil
  31029. case sopstage.FieldActionForward:
  31030. m.ClearActionForward()
  31031. return nil
  31032. case sopstage.FieldIndexSort:
  31033. m.ClearIndexSort()
  31034. return nil
  31035. }
  31036. return fmt.Errorf("unknown SopStage nullable field %s", name)
  31037. }
  31038. // ResetField resets all changes in the mutation for the field with the given name.
  31039. // It returns an error if the field is not defined in the schema.
  31040. func (m *SopStageMutation) ResetField(name string) error {
  31041. switch name {
  31042. case sopstage.FieldCreatedAt:
  31043. m.ResetCreatedAt()
  31044. return nil
  31045. case sopstage.FieldUpdatedAt:
  31046. m.ResetUpdatedAt()
  31047. return nil
  31048. case sopstage.FieldStatus:
  31049. m.ResetStatus()
  31050. return nil
  31051. case sopstage.FieldDeletedAt:
  31052. m.ResetDeletedAt()
  31053. return nil
  31054. case sopstage.FieldTaskID:
  31055. m.ResetTaskID()
  31056. return nil
  31057. case sopstage.FieldName:
  31058. m.ResetName()
  31059. return nil
  31060. case sopstage.FieldConditionType:
  31061. m.ResetConditionType()
  31062. return nil
  31063. case sopstage.FieldConditionOperator:
  31064. m.ResetConditionOperator()
  31065. return nil
  31066. case sopstage.FieldConditionList:
  31067. m.ResetConditionList()
  31068. return nil
  31069. case sopstage.FieldActionMessage:
  31070. m.ResetActionMessage()
  31071. return nil
  31072. case sopstage.FieldActionLabelAdd:
  31073. m.ResetActionLabelAdd()
  31074. return nil
  31075. case sopstage.FieldActionLabelDel:
  31076. m.ResetActionLabelDel()
  31077. return nil
  31078. case sopstage.FieldActionForward:
  31079. m.ResetActionForward()
  31080. return nil
  31081. case sopstage.FieldIndexSort:
  31082. m.ResetIndexSort()
  31083. return nil
  31084. }
  31085. return fmt.Errorf("unknown SopStage field %s", name)
  31086. }
  31087. // AddedEdges returns all edge names that were set/added in this mutation.
  31088. func (m *SopStageMutation) AddedEdges() []string {
  31089. edges := make([]string, 0, 3)
  31090. if m.sop_task != nil {
  31091. edges = append(edges, sopstage.EdgeSopTask)
  31092. }
  31093. if m.stage_nodes != nil {
  31094. edges = append(edges, sopstage.EdgeStageNodes)
  31095. }
  31096. if m.stage_messages != nil {
  31097. edges = append(edges, sopstage.EdgeStageMessages)
  31098. }
  31099. return edges
  31100. }
  31101. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31102. // name in this mutation.
  31103. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  31104. switch name {
  31105. case sopstage.EdgeSopTask:
  31106. if id := m.sop_task; id != nil {
  31107. return []ent.Value{*id}
  31108. }
  31109. case sopstage.EdgeStageNodes:
  31110. ids := make([]ent.Value, 0, len(m.stage_nodes))
  31111. for id := range m.stage_nodes {
  31112. ids = append(ids, id)
  31113. }
  31114. return ids
  31115. case sopstage.EdgeStageMessages:
  31116. ids := make([]ent.Value, 0, len(m.stage_messages))
  31117. for id := range m.stage_messages {
  31118. ids = append(ids, id)
  31119. }
  31120. return ids
  31121. }
  31122. return nil
  31123. }
  31124. // RemovedEdges returns all edge names that were removed in this mutation.
  31125. func (m *SopStageMutation) RemovedEdges() []string {
  31126. edges := make([]string, 0, 3)
  31127. if m.removedstage_nodes != nil {
  31128. edges = append(edges, sopstage.EdgeStageNodes)
  31129. }
  31130. if m.removedstage_messages != nil {
  31131. edges = append(edges, sopstage.EdgeStageMessages)
  31132. }
  31133. return edges
  31134. }
  31135. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31136. // the given name in this mutation.
  31137. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  31138. switch name {
  31139. case sopstage.EdgeStageNodes:
  31140. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  31141. for id := range m.removedstage_nodes {
  31142. ids = append(ids, id)
  31143. }
  31144. return ids
  31145. case sopstage.EdgeStageMessages:
  31146. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  31147. for id := range m.removedstage_messages {
  31148. ids = append(ids, id)
  31149. }
  31150. return ids
  31151. }
  31152. return nil
  31153. }
  31154. // ClearedEdges returns all edge names that were cleared in this mutation.
  31155. func (m *SopStageMutation) ClearedEdges() []string {
  31156. edges := make([]string, 0, 3)
  31157. if m.clearedsop_task {
  31158. edges = append(edges, sopstage.EdgeSopTask)
  31159. }
  31160. if m.clearedstage_nodes {
  31161. edges = append(edges, sopstage.EdgeStageNodes)
  31162. }
  31163. if m.clearedstage_messages {
  31164. edges = append(edges, sopstage.EdgeStageMessages)
  31165. }
  31166. return edges
  31167. }
  31168. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31169. // was cleared in this mutation.
  31170. func (m *SopStageMutation) EdgeCleared(name string) bool {
  31171. switch name {
  31172. case sopstage.EdgeSopTask:
  31173. return m.clearedsop_task
  31174. case sopstage.EdgeStageNodes:
  31175. return m.clearedstage_nodes
  31176. case sopstage.EdgeStageMessages:
  31177. return m.clearedstage_messages
  31178. }
  31179. return false
  31180. }
  31181. // ClearEdge clears the value of the edge with the given name. It returns an error
  31182. // if that edge is not defined in the schema.
  31183. func (m *SopStageMutation) ClearEdge(name string) error {
  31184. switch name {
  31185. case sopstage.EdgeSopTask:
  31186. m.ClearSopTask()
  31187. return nil
  31188. }
  31189. return fmt.Errorf("unknown SopStage unique edge %s", name)
  31190. }
  31191. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31192. // It returns an error if the edge is not defined in the schema.
  31193. func (m *SopStageMutation) ResetEdge(name string) error {
  31194. switch name {
  31195. case sopstage.EdgeSopTask:
  31196. m.ResetSopTask()
  31197. return nil
  31198. case sopstage.EdgeStageNodes:
  31199. m.ResetStageNodes()
  31200. return nil
  31201. case sopstage.EdgeStageMessages:
  31202. m.ResetStageMessages()
  31203. return nil
  31204. }
  31205. return fmt.Errorf("unknown SopStage edge %s", name)
  31206. }
  31207. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  31208. type SopTaskMutation struct {
  31209. config
  31210. op Op
  31211. typ string
  31212. id *uint64
  31213. created_at *time.Time
  31214. updated_at *time.Time
  31215. status *uint8
  31216. addstatus *int8
  31217. deleted_at *time.Time
  31218. name *string
  31219. bot_wxid_list *[]string
  31220. appendbot_wxid_list []string
  31221. _type *int
  31222. add_type *int
  31223. plan_start_time *time.Time
  31224. plan_end_time *time.Time
  31225. creator_id *string
  31226. organization_id *uint64
  31227. addorganization_id *int64
  31228. token *[]string
  31229. appendtoken []string
  31230. clearedFields map[string]struct{}
  31231. task_stages map[uint64]struct{}
  31232. removedtask_stages map[uint64]struct{}
  31233. clearedtask_stages bool
  31234. done bool
  31235. oldValue func(context.Context) (*SopTask, error)
  31236. predicates []predicate.SopTask
  31237. }
  31238. var _ ent.Mutation = (*SopTaskMutation)(nil)
  31239. // soptaskOption allows management of the mutation configuration using functional options.
  31240. type soptaskOption func(*SopTaskMutation)
  31241. // newSopTaskMutation creates new mutation for the SopTask entity.
  31242. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  31243. m := &SopTaskMutation{
  31244. config: c,
  31245. op: op,
  31246. typ: TypeSopTask,
  31247. clearedFields: make(map[string]struct{}),
  31248. }
  31249. for _, opt := range opts {
  31250. opt(m)
  31251. }
  31252. return m
  31253. }
  31254. // withSopTaskID sets the ID field of the mutation.
  31255. func withSopTaskID(id uint64) soptaskOption {
  31256. return func(m *SopTaskMutation) {
  31257. var (
  31258. err error
  31259. once sync.Once
  31260. value *SopTask
  31261. )
  31262. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  31263. once.Do(func() {
  31264. if m.done {
  31265. err = errors.New("querying old values post mutation is not allowed")
  31266. } else {
  31267. value, err = m.Client().SopTask.Get(ctx, id)
  31268. }
  31269. })
  31270. return value, err
  31271. }
  31272. m.id = &id
  31273. }
  31274. }
  31275. // withSopTask sets the old SopTask of the mutation.
  31276. func withSopTask(node *SopTask) soptaskOption {
  31277. return func(m *SopTaskMutation) {
  31278. m.oldValue = func(context.Context) (*SopTask, error) {
  31279. return node, nil
  31280. }
  31281. m.id = &node.ID
  31282. }
  31283. }
  31284. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31285. // executed in a transaction (ent.Tx), a transactional client is returned.
  31286. func (m SopTaskMutation) Client() *Client {
  31287. client := &Client{config: m.config}
  31288. client.init()
  31289. return client
  31290. }
  31291. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31292. // it returns an error otherwise.
  31293. func (m SopTaskMutation) Tx() (*Tx, error) {
  31294. if _, ok := m.driver.(*txDriver); !ok {
  31295. return nil, errors.New("ent: mutation is not running in a transaction")
  31296. }
  31297. tx := &Tx{config: m.config}
  31298. tx.init()
  31299. return tx, nil
  31300. }
  31301. // SetID sets the value of the id field. Note that this
  31302. // operation is only accepted on creation of SopTask entities.
  31303. func (m *SopTaskMutation) SetID(id uint64) {
  31304. m.id = &id
  31305. }
  31306. // ID returns the ID value in the mutation. Note that the ID is only available
  31307. // if it was provided to the builder or after it was returned from the database.
  31308. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  31309. if m.id == nil {
  31310. return
  31311. }
  31312. return *m.id, true
  31313. }
  31314. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31315. // That means, if the mutation is applied within a transaction with an isolation level such
  31316. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31317. // or updated by the mutation.
  31318. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  31319. switch {
  31320. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31321. id, exists := m.ID()
  31322. if exists {
  31323. return []uint64{id}, nil
  31324. }
  31325. fallthrough
  31326. case m.op.Is(OpUpdate | OpDelete):
  31327. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  31328. default:
  31329. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31330. }
  31331. }
  31332. // SetCreatedAt sets the "created_at" field.
  31333. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  31334. m.created_at = &t
  31335. }
  31336. // CreatedAt returns the value of the "created_at" field in the mutation.
  31337. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  31338. v := m.created_at
  31339. if v == nil {
  31340. return
  31341. }
  31342. return *v, true
  31343. }
  31344. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  31345. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31347. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31348. if !m.op.Is(OpUpdateOne) {
  31349. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31350. }
  31351. if m.id == nil || m.oldValue == nil {
  31352. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31353. }
  31354. oldValue, err := m.oldValue(ctx)
  31355. if err != nil {
  31356. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31357. }
  31358. return oldValue.CreatedAt, nil
  31359. }
  31360. // ResetCreatedAt resets all changes to the "created_at" field.
  31361. func (m *SopTaskMutation) ResetCreatedAt() {
  31362. m.created_at = nil
  31363. }
  31364. // SetUpdatedAt sets the "updated_at" field.
  31365. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  31366. m.updated_at = &t
  31367. }
  31368. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31369. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  31370. v := m.updated_at
  31371. if v == nil {
  31372. return
  31373. }
  31374. return *v, true
  31375. }
  31376. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  31377. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31379. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31380. if !m.op.Is(OpUpdateOne) {
  31381. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31382. }
  31383. if m.id == nil || m.oldValue == nil {
  31384. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31385. }
  31386. oldValue, err := m.oldValue(ctx)
  31387. if err != nil {
  31388. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31389. }
  31390. return oldValue.UpdatedAt, nil
  31391. }
  31392. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31393. func (m *SopTaskMutation) ResetUpdatedAt() {
  31394. m.updated_at = nil
  31395. }
  31396. // SetStatus sets the "status" field.
  31397. func (m *SopTaskMutation) SetStatus(u uint8) {
  31398. m.status = &u
  31399. m.addstatus = nil
  31400. }
  31401. // Status returns the value of the "status" field in the mutation.
  31402. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  31403. v := m.status
  31404. if v == nil {
  31405. return
  31406. }
  31407. return *v, true
  31408. }
  31409. // OldStatus returns the old "status" field's value of the SopTask entity.
  31410. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31412. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31413. if !m.op.Is(OpUpdateOne) {
  31414. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31415. }
  31416. if m.id == nil || m.oldValue == nil {
  31417. return v, errors.New("OldStatus requires an ID field in the mutation")
  31418. }
  31419. oldValue, err := m.oldValue(ctx)
  31420. if err != nil {
  31421. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31422. }
  31423. return oldValue.Status, nil
  31424. }
  31425. // AddStatus adds u to the "status" field.
  31426. func (m *SopTaskMutation) AddStatus(u int8) {
  31427. if m.addstatus != nil {
  31428. *m.addstatus += u
  31429. } else {
  31430. m.addstatus = &u
  31431. }
  31432. }
  31433. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31434. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  31435. v := m.addstatus
  31436. if v == nil {
  31437. return
  31438. }
  31439. return *v, true
  31440. }
  31441. // ClearStatus clears the value of the "status" field.
  31442. func (m *SopTaskMutation) ClearStatus() {
  31443. m.status = nil
  31444. m.addstatus = nil
  31445. m.clearedFields[soptask.FieldStatus] = struct{}{}
  31446. }
  31447. // StatusCleared returns if the "status" field was cleared in this mutation.
  31448. func (m *SopTaskMutation) StatusCleared() bool {
  31449. _, ok := m.clearedFields[soptask.FieldStatus]
  31450. return ok
  31451. }
  31452. // ResetStatus resets all changes to the "status" field.
  31453. func (m *SopTaskMutation) ResetStatus() {
  31454. m.status = nil
  31455. m.addstatus = nil
  31456. delete(m.clearedFields, soptask.FieldStatus)
  31457. }
  31458. // SetDeletedAt sets the "deleted_at" field.
  31459. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  31460. m.deleted_at = &t
  31461. }
  31462. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31463. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  31464. v := m.deleted_at
  31465. if v == nil {
  31466. return
  31467. }
  31468. return *v, true
  31469. }
  31470. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  31471. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31473. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31474. if !m.op.Is(OpUpdateOne) {
  31475. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31476. }
  31477. if m.id == nil || m.oldValue == nil {
  31478. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31479. }
  31480. oldValue, err := m.oldValue(ctx)
  31481. if err != nil {
  31482. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31483. }
  31484. return oldValue.DeletedAt, nil
  31485. }
  31486. // ClearDeletedAt clears the value of the "deleted_at" field.
  31487. func (m *SopTaskMutation) ClearDeletedAt() {
  31488. m.deleted_at = nil
  31489. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  31490. }
  31491. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31492. func (m *SopTaskMutation) DeletedAtCleared() bool {
  31493. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  31494. return ok
  31495. }
  31496. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31497. func (m *SopTaskMutation) ResetDeletedAt() {
  31498. m.deleted_at = nil
  31499. delete(m.clearedFields, soptask.FieldDeletedAt)
  31500. }
  31501. // SetName sets the "name" field.
  31502. func (m *SopTaskMutation) SetName(s string) {
  31503. m.name = &s
  31504. }
  31505. // Name returns the value of the "name" field in the mutation.
  31506. func (m *SopTaskMutation) Name() (r string, exists bool) {
  31507. v := m.name
  31508. if v == nil {
  31509. return
  31510. }
  31511. return *v, true
  31512. }
  31513. // OldName returns the old "name" field's value of the SopTask entity.
  31514. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31516. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  31517. if !m.op.Is(OpUpdateOne) {
  31518. return v, errors.New("OldName is only allowed on UpdateOne operations")
  31519. }
  31520. if m.id == nil || m.oldValue == nil {
  31521. return v, errors.New("OldName requires an ID field in the mutation")
  31522. }
  31523. oldValue, err := m.oldValue(ctx)
  31524. if err != nil {
  31525. return v, fmt.Errorf("querying old value for OldName: %w", err)
  31526. }
  31527. return oldValue.Name, nil
  31528. }
  31529. // ResetName resets all changes to the "name" field.
  31530. func (m *SopTaskMutation) ResetName() {
  31531. m.name = nil
  31532. }
  31533. // SetBotWxidList sets the "bot_wxid_list" field.
  31534. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  31535. m.bot_wxid_list = &s
  31536. m.appendbot_wxid_list = nil
  31537. }
  31538. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  31539. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  31540. v := m.bot_wxid_list
  31541. if v == nil {
  31542. return
  31543. }
  31544. return *v, true
  31545. }
  31546. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  31547. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31548. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31549. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  31550. if !m.op.Is(OpUpdateOne) {
  31551. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  31552. }
  31553. if m.id == nil || m.oldValue == nil {
  31554. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  31555. }
  31556. oldValue, err := m.oldValue(ctx)
  31557. if err != nil {
  31558. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  31559. }
  31560. return oldValue.BotWxidList, nil
  31561. }
  31562. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  31563. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  31564. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  31565. }
  31566. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  31567. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  31568. if len(m.appendbot_wxid_list) == 0 {
  31569. return nil, false
  31570. }
  31571. return m.appendbot_wxid_list, true
  31572. }
  31573. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  31574. func (m *SopTaskMutation) ClearBotWxidList() {
  31575. m.bot_wxid_list = nil
  31576. m.appendbot_wxid_list = nil
  31577. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  31578. }
  31579. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  31580. func (m *SopTaskMutation) BotWxidListCleared() bool {
  31581. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  31582. return ok
  31583. }
  31584. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  31585. func (m *SopTaskMutation) ResetBotWxidList() {
  31586. m.bot_wxid_list = nil
  31587. m.appendbot_wxid_list = nil
  31588. delete(m.clearedFields, soptask.FieldBotWxidList)
  31589. }
  31590. // SetType sets the "type" field.
  31591. func (m *SopTaskMutation) SetType(i int) {
  31592. m._type = &i
  31593. m.add_type = nil
  31594. }
  31595. // GetType returns the value of the "type" field in the mutation.
  31596. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  31597. v := m._type
  31598. if v == nil {
  31599. return
  31600. }
  31601. return *v, true
  31602. }
  31603. // OldType returns the old "type" field's value of the SopTask entity.
  31604. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31606. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  31607. if !m.op.Is(OpUpdateOne) {
  31608. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31609. }
  31610. if m.id == nil || m.oldValue == nil {
  31611. return v, errors.New("OldType requires an ID field in the mutation")
  31612. }
  31613. oldValue, err := m.oldValue(ctx)
  31614. if err != nil {
  31615. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31616. }
  31617. return oldValue.Type, nil
  31618. }
  31619. // AddType adds i to the "type" field.
  31620. func (m *SopTaskMutation) AddType(i int) {
  31621. if m.add_type != nil {
  31622. *m.add_type += i
  31623. } else {
  31624. m.add_type = &i
  31625. }
  31626. }
  31627. // AddedType returns the value that was added to the "type" field in this mutation.
  31628. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  31629. v := m.add_type
  31630. if v == nil {
  31631. return
  31632. }
  31633. return *v, true
  31634. }
  31635. // ResetType resets all changes to the "type" field.
  31636. func (m *SopTaskMutation) ResetType() {
  31637. m._type = nil
  31638. m.add_type = nil
  31639. }
  31640. // SetPlanStartTime sets the "plan_start_time" field.
  31641. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  31642. m.plan_start_time = &t
  31643. }
  31644. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  31645. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  31646. v := m.plan_start_time
  31647. if v == nil {
  31648. return
  31649. }
  31650. return *v, true
  31651. }
  31652. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  31653. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31655. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  31656. if !m.op.Is(OpUpdateOne) {
  31657. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  31658. }
  31659. if m.id == nil || m.oldValue == nil {
  31660. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  31661. }
  31662. oldValue, err := m.oldValue(ctx)
  31663. if err != nil {
  31664. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  31665. }
  31666. return oldValue.PlanStartTime, nil
  31667. }
  31668. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  31669. func (m *SopTaskMutation) ClearPlanStartTime() {
  31670. m.plan_start_time = nil
  31671. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  31672. }
  31673. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  31674. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  31675. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  31676. return ok
  31677. }
  31678. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  31679. func (m *SopTaskMutation) ResetPlanStartTime() {
  31680. m.plan_start_time = nil
  31681. delete(m.clearedFields, soptask.FieldPlanStartTime)
  31682. }
  31683. // SetPlanEndTime sets the "plan_end_time" field.
  31684. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  31685. m.plan_end_time = &t
  31686. }
  31687. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  31688. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  31689. v := m.plan_end_time
  31690. if v == nil {
  31691. return
  31692. }
  31693. return *v, true
  31694. }
  31695. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  31696. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31698. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  31699. if !m.op.Is(OpUpdateOne) {
  31700. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  31701. }
  31702. if m.id == nil || m.oldValue == nil {
  31703. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  31704. }
  31705. oldValue, err := m.oldValue(ctx)
  31706. if err != nil {
  31707. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  31708. }
  31709. return oldValue.PlanEndTime, nil
  31710. }
  31711. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  31712. func (m *SopTaskMutation) ClearPlanEndTime() {
  31713. m.plan_end_time = nil
  31714. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  31715. }
  31716. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  31717. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  31718. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  31719. return ok
  31720. }
  31721. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  31722. func (m *SopTaskMutation) ResetPlanEndTime() {
  31723. m.plan_end_time = nil
  31724. delete(m.clearedFields, soptask.FieldPlanEndTime)
  31725. }
  31726. // SetCreatorID sets the "creator_id" field.
  31727. func (m *SopTaskMutation) SetCreatorID(s string) {
  31728. m.creator_id = &s
  31729. }
  31730. // CreatorID returns the value of the "creator_id" field in the mutation.
  31731. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  31732. v := m.creator_id
  31733. if v == nil {
  31734. return
  31735. }
  31736. return *v, true
  31737. }
  31738. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  31739. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31741. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  31742. if !m.op.Is(OpUpdateOne) {
  31743. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  31744. }
  31745. if m.id == nil || m.oldValue == nil {
  31746. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  31747. }
  31748. oldValue, err := m.oldValue(ctx)
  31749. if err != nil {
  31750. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  31751. }
  31752. return oldValue.CreatorID, nil
  31753. }
  31754. // ClearCreatorID clears the value of the "creator_id" field.
  31755. func (m *SopTaskMutation) ClearCreatorID() {
  31756. m.creator_id = nil
  31757. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  31758. }
  31759. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  31760. func (m *SopTaskMutation) CreatorIDCleared() bool {
  31761. _, ok := m.clearedFields[soptask.FieldCreatorID]
  31762. return ok
  31763. }
  31764. // ResetCreatorID resets all changes to the "creator_id" field.
  31765. func (m *SopTaskMutation) ResetCreatorID() {
  31766. m.creator_id = nil
  31767. delete(m.clearedFields, soptask.FieldCreatorID)
  31768. }
  31769. // SetOrganizationID sets the "organization_id" field.
  31770. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  31771. m.organization_id = &u
  31772. m.addorganization_id = nil
  31773. }
  31774. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31775. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  31776. v := m.organization_id
  31777. if v == nil {
  31778. return
  31779. }
  31780. return *v, true
  31781. }
  31782. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  31783. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31785. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31786. if !m.op.Is(OpUpdateOne) {
  31787. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31788. }
  31789. if m.id == nil || m.oldValue == nil {
  31790. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31791. }
  31792. oldValue, err := m.oldValue(ctx)
  31793. if err != nil {
  31794. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31795. }
  31796. return oldValue.OrganizationID, nil
  31797. }
  31798. // AddOrganizationID adds u to the "organization_id" field.
  31799. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  31800. if m.addorganization_id != nil {
  31801. *m.addorganization_id += u
  31802. } else {
  31803. m.addorganization_id = &u
  31804. }
  31805. }
  31806. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31807. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  31808. v := m.addorganization_id
  31809. if v == nil {
  31810. return
  31811. }
  31812. return *v, true
  31813. }
  31814. // ClearOrganizationID clears the value of the "organization_id" field.
  31815. func (m *SopTaskMutation) ClearOrganizationID() {
  31816. m.organization_id = nil
  31817. m.addorganization_id = nil
  31818. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  31819. }
  31820. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31821. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  31822. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  31823. return ok
  31824. }
  31825. // ResetOrganizationID resets all changes to the "organization_id" field.
  31826. func (m *SopTaskMutation) ResetOrganizationID() {
  31827. m.organization_id = nil
  31828. m.addorganization_id = nil
  31829. delete(m.clearedFields, soptask.FieldOrganizationID)
  31830. }
  31831. // SetToken sets the "token" field.
  31832. func (m *SopTaskMutation) SetToken(s []string) {
  31833. m.token = &s
  31834. m.appendtoken = nil
  31835. }
  31836. // Token returns the value of the "token" field in the mutation.
  31837. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  31838. v := m.token
  31839. if v == nil {
  31840. return
  31841. }
  31842. return *v, true
  31843. }
  31844. // OldToken returns the old "token" field's value of the SopTask entity.
  31845. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  31846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31847. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  31848. if !m.op.Is(OpUpdateOne) {
  31849. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  31850. }
  31851. if m.id == nil || m.oldValue == nil {
  31852. return v, errors.New("OldToken requires an ID field in the mutation")
  31853. }
  31854. oldValue, err := m.oldValue(ctx)
  31855. if err != nil {
  31856. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  31857. }
  31858. return oldValue.Token, nil
  31859. }
  31860. // AppendToken adds s to the "token" field.
  31861. func (m *SopTaskMutation) AppendToken(s []string) {
  31862. m.appendtoken = append(m.appendtoken, s...)
  31863. }
  31864. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  31865. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  31866. if len(m.appendtoken) == 0 {
  31867. return nil, false
  31868. }
  31869. return m.appendtoken, true
  31870. }
  31871. // ClearToken clears the value of the "token" field.
  31872. func (m *SopTaskMutation) ClearToken() {
  31873. m.token = nil
  31874. m.appendtoken = nil
  31875. m.clearedFields[soptask.FieldToken] = struct{}{}
  31876. }
  31877. // TokenCleared returns if the "token" field was cleared in this mutation.
  31878. func (m *SopTaskMutation) TokenCleared() bool {
  31879. _, ok := m.clearedFields[soptask.FieldToken]
  31880. return ok
  31881. }
  31882. // ResetToken resets all changes to the "token" field.
  31883. func (m *SopTaskMutation) ResetToken() {
  31884. m.token = nil
  31885. m.appendtoken = nil
  31886. delete(m.clearedFields, soptask.FieldToken)
  31887. }
  31888. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  31889. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  31890. if m.task_stages == nil {
  31891. m.task_stages = make(map[uint64]struct{})
  31892. }
  31893. for i := range ids {
  31894. m.task_stages[ids[i]] = struct{}{}
  31895. }
  31896. }
  31897. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  31898. func (m *SopTaskMutation) ClearTaskStages() {
  31899. m.clearedtask_stages = true
  31900. }
  31901. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  31902. func (m *SopTaskMutation) TaskStagesCleared() bool {
  31903. return m.clearedtask_stages
  31904. }
  31905. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  31906. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  31907. if m.removedtask_stages == nil {
  31908. m.removedtask_stages = make(map[uint64]struct{})
  31909. }
  31910. for i := range ids {
  31911. delete(m.task_stages, ids[i])
  31912. m.removedtask_stages[ids[i]] = struct{}{}
  31913. }
  31914. }
  31915. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  31916. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  31917. for id := range m.removedtask_stages {
  31918. ids = append(ids, id)
  31919. }
  31920. return
  31921. }
  31922. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  31923. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  31924. for id := range m.task_stages {
  31925. ids = append(ids, id)
  31926. }
  31927. return
  31928. }
  31929. // ResetTaskStages resets all changes to the "task_stages" edge.
  31930. func (m *SopTaskMutation) ResetTaskStages() {
  31931. m.task_stages = nil
  31932. m.clearedtask_stages = false
  31933. m.removedtask_stages = nil
  31934. }
  31935. // Where appends a list predicates to the SopTaskMutation builder.
  31936. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  31937. m.predicates = append(m.predicates, ps...)
  31938. }
  31939. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  31940. // users can use type-assertion to append predicates that do not depend on any generated package.
  31941. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  31942. p := make([]predicate.SopTask, len(ps))
  31943. for i := range ps {
  31944. p[i] = ps[i]
  31945. }
  31946. m.Where(p...)
  31947. }
  31948. // Op returns the operation name.
  31949. func (m *SopTaskMutation) Op() Op {
  31950. return m.op
  31951. }
  31952. // SetOp allows setting the mutation operation.
  31953. func (m *SopTaskMutation) SetOp(op Op) {
  31954. m.op = op
  31955. }
  31956. // Type returns the node type of this mutation (SopTask).
  31957. func (m *SopTaskMutation) Type() string {
  31958. return m.typ
  31959. }
  31960. // Fields returns all fields that were changed during this mutation. Note that in
  31961. // order to get all numeric fields that were incremented/decremented, call
  31962. // AddedFields().
  31963. func (m *SopTaskMutation) Fields() []string {
  31964. fields := make([]string, 0, 12)
  31965. if m.created_at != nil {
  31966. fields = append(fields, soptask.FieldCreatedAt)
  31967. }
  31968. if m.updated_at != nil {
  31969. fields = append(fields, soptask.FieldUpdatedAt)
  31970. }
  31971. if m.status != nil {
  31972. fields = append(fields, soptask.FieldStatus)
  31973. }
  31974. if m.deleted_at != nil {
  31975. fields = append(fields, soptask.FieldDeletedAt)
  31976. }
  31977. if m.name != nil {
  31978. fields = append(fields, soptask.FieldName)
  31979. }
  31980. if m.bot_wxid_list != nil {
  31981. fields = append(fields, soptask.FieldBotWxidList)
  31982. }
  31983. if m._type != nil {
  31984. fields = append(fields, soptask.FieldType)
  31985. }
  31986. if m.plan_start_time != nil {
  31987. fields = append(fields, soptask.FieldPlanStartTime)
  31988. }
  31989. if m.plan_end_time != nil {
  31990. fields = append(fields, soptask.FieldPlanEndTime)
  31991. }
  31992. if m.creator_id != nil {
  31993. fields = append(fields, soptask.FieldCreatorID)
  31994. }
  31995. if m.organization_id != nil {
  31996. fields = append(fields, soptask.FieldOrganizationID)
  31997. }
  31998. if m.token != nil {
  31999. fields = append(fields, soptask.FieldToken)
  32000. }
  32001. return fields
  32002. }
  32003. // Field returns the value of a field with the given name. The second boolean
  32004. // return value indicates that this field was not set, or was not defined in the
  32005. // schema.
  32006. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  32007. switch name {
  32008. case soptask.FieldCreatedAt:
  32009. return m.CreatedAt()
  32010. case soptask.FieldUpdatedAt:
  32011. return m.UpdatedAt()
  32012. case soptask.FieldStatus:
  32013. return m.Status()
  32014. case soptask.FieldDeletedAt:
  32015. return m.DeletedAt()
  32016. case soptask.FieldName:
  32017. return m.Name()
  32018. case soptask.FieldBotWxidList:
  32019. return m.BotWxidList()
  32020. case soptask.FieldType:
  32021. return m.GetType()
  32022. case soptask.FieldPlanStartTime:
  32023. return m.PlanStartTime()
  32024. case soptask.FieldPlanEndTime:
  32025. return m.PlanEndTime()
  32026. case soptask.FieldCreatorID:
  32027. return m.CreatorID()
  32028. case soptask.FieldOrganizationID:
  32029. return m.OrganizationID()
  32030. case soptask.FieldToken:
  32031. return m.Token()
  32032. }
  32033. return nil, false
  32034. }
  32035. // OldField returns the old value of the field from the database. An error is
  32036. // returned if the mutation operation is not UpdateOne, or the query to the
  32037. // database failed.
  32038. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32039. switch name {
  32040. case soptask.FieldCreatedAt:
  32041. return m.OldCreatedAt(ctx)
  32042. case soptask.FieldUpdatedAt:
  32043. return m.OldUpdatedAt(ctx)
  32044. case soptask.FieldStatus:
  32045. return m.OldStatus(ctx)
  32046. case soptask.FieldDeletedAt:
  32047. return m.OldDeletedAt(ctx)
  32048. case soptask.FieldName:
  32049. return m.OldName(ctx)
  32050. case soptask.FieldBotWxidList:
  32051. return m.OldBotWxidList(ctx)
  32052. case soptask.FieldType:
  32053. return m.OldType(ctx)
  32054. case soptask.FieldPlanStartTime:
  32055. return m.OldPlanStartTime(ctx)
  32056. case soptask.FieldPlanEndTime:
  32057. return m.OldPlanEndTime(ctx)
  32058. case soptask.FieldCreatorID:
  32059. return m.OldCreatorID(ctx)
  32060. case soptask.FieldOrganizationID:
  32061. return m.OldOrganizationID(ctx)
  32062. case soptask.FieldToken:
  32063. return m.OldToken(ctx)
  32064. }
  32065. return nil, fmt.Errorf("unknown SopTask field %s", name)
  32066. }
  32067. // SetField sets the value of a field with the given name. It returns an error if
  32068. // the field is not defined in the schema, or if the type mismatched the field
  32069. // type.
  32070. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  32071. switch name {
  32072. case soptask.FieldCreatedAt:
  32073. v, ok := value.(time.Time)
  32074. if !ok {
  32075. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32076. }
  32077. m.SetCreatedAt(v)
  32078. return nil
  32079. case soptask.FieldUpdatedAt:
  32080. v, ok := value.(time.Time)
  32081. if !ok {
  32082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32083. }
  32084. m.SetUpdatedAt(v)
  32085. return nil
  32086. case soptask.FieldStatus:
  32087. v, ok := value.(uint8)
  32088. if !ok {
  32089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32090. }
  32091. m.SetStatus(v)
  32092. return nil
  32093. case soptask.FieldDeletedAt:
  32094. v, ok := value.(time.Time)
  32095. if !ok {
  32096. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32097. }
  32098. m.SetDeletedAt(v)
  32099. return nil
  32100. case soptask.FieldName:
  32101. v, ok := value.(string)
  32102. if !ok {
  32103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32104. }
  32105. m.SetName(v)
  32106. return nil
  32107. case soptask.FieldBotWxidList:
  32108. v, ok := value.([]string)
  32109. if !ok {
  32110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32111. }
  32112. m.SetBotWxidList(v)
  32113. return nil
  32114. case soptask.FieldType:
  32115. v, ok := value.(int)
  32116. if !ok {
  32117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32118. }
  32119. m.SetType(v)
  32120. return nil
  32121. case soptask.FieldPlanStartTime:
  32122. v, ok := value.(time.Time)
  32123. if !ok {
  32124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32125. }
  32126. m.SetPlanStartTime(v)
  32127. return nil
  32128. case soptask.FieldPlanEndTime:
  32129. v, ok := value.(time.Time)
  32130. if !ok {
  32131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32132. }
  32133. m.SetPlanEndTime(v)
  32134. return nil
  32135. case soptask.FieldCreatorID:
  32136. v, ok := value.(string)
  32137. if !ok {
  32138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32139. }
  32140. m.SetCreatorID(v)
  32141. return nil
  32142. case soptask.FieldOrganizationID:
  32143. v, ok := value.(uint64)
  32144. if !ok {
  32145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32146. }
  32147. m.SetOrganizationID(v)
  32148. return nil
  32149. case soptask.FieldToken:
  32150. v, ok := value.([]string)
  32151. if !ok {
  32152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32153. }
  32154. m.SetToken(v)
  32155. return nil
  32156. }
  32157. return fmt.Errorf("unknown SopTask field %s", name)
  32158. }
  32159. // AddedFields returns all numeric fields that were incremented/decremented during
  32160. // this mutation.
  32161. func (m *SopTaskMutation) AddedFields() []string {
  32162. var fields []string
  32163. if m.addstatus != nil {
  32164. fields = append(fields, soptask.FieldStatus)
  32165. }
  32166. if m.add_type != nil {
  32167. fields = append(fields, soptask.FieldType)
  32168. }
  32169. if m.addorganization_id != nil {
  32170. fields = append(fields, soptask.FieldOrganizationID)
  32171. }
  32172. return fields
  32173. }
  32174. // AddedField returns the numeric value that was incremented/decremented on a field
  32175. // with the given name. The second boolean return value indicates that this field
  32176. // was not set, or was not defined in the schema.
  32177. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  32178. switch name {
  32179. case soptask.FieldStatus:
  32180. return m.AddedStatus()
  32181. case soptask.FieldType:
  32182. return m.AddedType()
  32183. case soptask.FieldOrganizationID:
  32184. return m.AddedOrganizationID()
  32185. }
  32186. return nil, false
  32187. }
  32188. // AddField adds the value to the field with the given name. It returns an error if
  32189. // the field is not defined in the schema, or if the type mismatched the field
  32190. // type.
  32191. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  32192. switch name {
  32193. case soptask.FieldStatus:
  32194. v, ok := value.(int8)
  32195. if !ok {
  32196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32197. }
  32198. m.AddStatus(v)
  32199. return nil
  32200. case soptask.FieldType:
  32201. v, ok := value.(int)
  32202. if !ok {
  32203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32204. }
  32205. m.AddType(v)
  32206. return nil
  32207. case soptask.FieldOrganizationID:
  32208. v, ok := value.(int64)
  32209. if !ok {
  32210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32211. }
  32212. m.AddOrganizationID(v)
  32213. return nil
  32214. }
  32215. return fmt.Errorf("unknown SopTask numeric field %s", name)
  32216. }
  32217. // ClearedFields returns all nullable fields that were cleared during this
  32218. // mutation.
  32219. func (m *SopTaskMutation) ClearedFields() []string {
  32220. var fields []string
  32221. if m.FieldCleared(soptask.FieldStatus) {
  32222. fields = append(fields, soptask.FieldStatus)
  32223. }
  32224. if m.FieldCleared(soptask.FieldDeletedAt) {
  32225. fields = append(fields, soptask.FieldDeletedAt)
  32226. }
  32227. if m.FieldCleared(soptask.FieldBotWxidList) {
  32228. fields = append(fields, soptask.FieldBotWxidList)
  32229. }
  32230. if m.FieldCleared(soptask.FieldPlanStartTime) {
  32231. fields = append(fields, soptask.FieldPlanStartTime)
  32232. }
  32233. if m.FieldCleared(soptask.FieldPlanEndTime) {
  32234. fields = append(fields, soptask.FieldPlanEndTime)
  32235. }
  32236. if m.FieldCleared(soptask.FieldCreatorID) {
  32237. fields = append(fields, soptask.FieldCreatorID)
  32238. }
  32239. if m.FieldCleared(soptask.FieldOrganizationID) {
  32240. fields = append(fields, soptask.FieldOrganizationID)
  32241. }
  32242. if m.FieldCleared(soptask.FieldToken) {
  32243. fields = append(fields, soptask.FieldToken)
  32244. }
  32245. return fields
  32246. }
  32247. // FieldCleared returns a boolean indicating if a field with the given name was
  32248. // cleared in this mutation.
  32249. func (m *SopTaskMutation) FieldCleared(name string) bool {
  32250. _, ok := m.clearedFields[name]
  32251. return ok
  32252. }
  32253. // ClearField clears the value of the field with the given name. It returns an
  32254. // error if the field is not defined in the schema.
  32255. func (m *SopTaskMutation) ClearField(name string) error {
  32256. switch name {
  32257. case soptask.FieldStatus:
  32258. m.ClearStatus()
  32259. return nil
  32260. case soptask.FieldDeletedAt:
  32261. m.ClearDeletedAt()
  32262. return nil
  32263. case soptask.FieldBotWxidList:
  32264. m.ClearBotWxidList()
  32265. return nil
  32266. case soptask.FieldPlanStartTime:
  32267. m.ClearPlanStartTime()
  32268. return nil
  32269. case soptask.FieldPlanEndTime:
  32270. m.ClearPlanEndTime()
  32271. return nil
  32272. case soptask.FieldCreatorID:
  32273. m.ClearCreatorID()
  32274. return nil
  32275. case soptask.FieldOrganizationID:
  32276. m.ClearOrganizationID()
  32277. return nil
  32278. case soptask.FieldToken:
  32279. m.ClearToken()
  32280. return nil
  32281. }
  32282. return fmt.Errorf("unknown SopTask nullable field %s", name)
  32283. }
  32284. // ResetField resets all changes in the mutation for the field with the given name.
  32285. // It returns an error if the field is not defined in the schema.
  32286. func (m *SopTaskMutation) ResetField(name string) error {
  32287. switch name {
  32288. case soptask.FieldCreatedAt:
  32289. m.ResetCreatedAt()
  32290. return nil
  32291. case soptask.FieldUpdatedAt:
  32292. m.ResetUpdatedAt()
  32293. return nil
  32294. case soptask.FieldStatus:
  32295. m.ResetStatus()
  32296. return nil
  32297. case soptask.FieldDeletedAt:
  32298. m.ResetDeletedAt()
  32299. return nil
  32300. case soptask.FieldName:
  32301. m.ResetName()
  32302. return nil
  32303. case soptask.FieldBotWxidList:
  32304. m.ResetBotWxidList()
  32305. return nil
  32306. case soptask.FieldType:
  32307. m.ResetType()
  32308. return nil
  32309. case soptask.FieldPlanStartTime:
  32310. m.ResetPlanStartTime()
  32311. return nil
  32312. case soptask.FieldPlanEndTime:
  32313. m.ResetPlanEndTime()
  32314. return nil
  32315. case soptask.FieldCreatorID:
  32316. m.ResetCreatorID()
  32317. return nil
  32318. case soptask.FieldOrganizationID:
  32319. m.ResetOrganizationID()
  32320. return nil
  32321. case soptask.FieldToken:
  32322. m.ResetToken()
  32323. return nil
  32324. }
  32325. return fmt.Errorf("unknown SopTask field %s", name)
  32326. }
  32327. // AddedEdges returns all edge names that were set/added in this mutation.
  32328. func (m *SopTaskMutation) AddedEdges() []string {
  32329. edges := make([]string, 0, 1)
  32330. if m.task_stages != nil {
  32331. edges = append(edges, soptask.EdgeTaskStages)
  32332. }
  32333. return edges
  32334. }
  32335. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32336. // name in this mutation.
  32337. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  32338. switch name {
  32339. case soptask.EdgeTaskStages:
  32340. ids := make([]ent.Value, 0, len(m.task_stages))
  32341. for id := range m.task_stages {
  32342. ids = append(ids, id)
  32343. }
  32344. return ids
  32345. }
  32346. return nil
  32347. }
  32348. // RemovedEdges returns all edge names that were removed in this mutation.
  32349. func (m *SopTaskMutation) RemovedEdges() []string {
  32350. edges := make([]string, 0, 1)
  32351. if m.removedtask_stages != nil {
  32352. edges = append(edges, soptask.EdgeTaskStages)
  32353. }
  32354. return edges
  32355. }
  32356. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32357. // the given name in this mutation.
  32358. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  32359. switch name {
  32360. case soptask.EdgeTaskStages:
  32361. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  32362. for id := range m.removedtask_stages {
  32363. ids = append(ids, id)
  32364. }
  32365. return ids
  32366. }
  32367. return nil
  32368. }
  32369. // ClearedEdges returns all edge names that were cleared in this mutation.
  32370. func (m *SopTaskMutation) ClearedEdges() []string {
  32371. edges := make([]string, 0, 1)
  32372. if m.clearedtask_stages {
  32373. edges = append(edges, soptask.EdgeTaskStages)
  32374. }
  32375. return edges
  32376. }
  32377. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32378. // was cleared in this mutation.
  32379. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  32380. switch name {
  32381. case soptask.EdgeTaskStages:
  32382. return m.clearedtask_stages
  32383. }
  32384. return false
  32385. }
  32386. // ClearEdge clears the value of the edge with the given name. It returns an error
  32387. // if that edge is not defined in the schema.
  32388. func (m *SopTaskMutation) ClearEdge(name string) error {
  32389. switch name {
  32390. }
  32391. return fmt.Errorf("unknown SopTask unique edge %s", name)
  32392. }
  32393. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32394. // It returns an error if the edge is not defined in the schema.
  32395. func (m *SopTaskMutation) ResetEdge(name string) error {
  32396. switch name {
  32397. case soptask.EdgeTaskStages:
  32398. m.ResetTaskStages()
  32399. return nil
  32400. }
  32401. return fmt.Errorf("unknown SopTask edge %s", name)
  32402. }
  32403. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  32404. type TokenMutation struct {
  32405. config
  32406. op Op
  32407. typ string
  32408. id *uint64
  32409. created_at *time.Time
  32410. updated_at *time.Time
  32411. deleted_at *time.Time
  32412. expire_at *time.Time
  32413. token *string
  32414. mac *string
  32415. organization_id *uint64
  32416. addorganization_id *int64
  32417. custom_agent_base *string
  32418. custom_agent_key *string
  32419. openai_base *string
  32420. openai_key *string
  32421. clearedFields map[string]struct{}
  32422. agent *uint64
  32423. clearedagent bool
  32424. done bool
  32425. oldValue func(context.Context) (*Token, error)
  32426. predicates []predicate.Token
  32427. }
  32428. var _ ent.Mutation = (*TokenMutation)(nil)
  32429. // tokenOption allows management of the mutation configuration using functional options.
  32430. type tokenOption func(*TokenMutation)
  32431. // newTokenMutation creates new mutation for the Token entity.
  32432. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  32433. m := &TokenMutation{
  32434. config: c,
  32435. op: op,
  32436. typ: TypeToken,
  32437. clearedFields: make(map[string]struct{}),
  32438. }
  32439. for _, opt := range opts {
  32440. opt(m)
  32441. }
  32442. return m
  32443. }
  32444. // withTokenID sets the ID field of the mutation.
  32445. func withTokenID(id uint64) tokenOption {
  32446. return func(m *TokenMutation) {
  32447. var (
  32448. err error
  32449. once sync.Once
  32450. value *Token
  32451. )
  32452. m.oldValue = func(ctx context.Context) (*Token, error) {
  32453. once.Do(func() {
  32454. if m.done {
  32455. err = errors.New("querying old values post mutation is not allowed")
  32456. } else {
  32457. value, err = m.Client().Token.Get(ctx, id)
  32458. }
  32459. })
  32460. return value, err
  32461. }
  32462. m.id = &id
  32463. }
  32464. }
  32465. // withToken sets the old Token of the mutation.
  32466. func withToken(node *Token) tokenOption {
  32467. return func(m *TokenMutation) {
  32468. m.oldValue = func(context.Context) (*Token, error) {
  32469. return node, nil
  32470. }
  32471. m.id = &node.ID
  32472. }
  32473. }
  32474. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32475. // executed in a transaction (ent.Tx), a transactional client is returned.
  32476. func (m TokenMutation) Client() *Client {
  32477. client := &Client{config: m.config}
  32478. client.init()
  32479. return client
  32480. }
  32481. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32482. // it returns an error otherwise.
  32483. func (m TokenMutation) Tx() (*Tx, error) {
  32484. if _, ok := m.driver.(*txDriver); !ok {
  32485. return nil, errors.New("ent: mutation is not running in a transaction")
  32486. }
  32487. tx := &Tx{config: m.config}
  32488. tx.init()
  32489. return tx, nil
  32490. }
  32491. // SetID sets the value of the id field. Note that this
  32492. // operation is only accepted on creation of Token entities.
  32493. func (m *TokenMutation) SetID(id uint64) {
  32494. m.id = &id
  32495. }
  32496. // ID returns the ID value in the mutation. Note that the ID is only available
  32497. // if it was provided to the builder or after it was returned from the database.
  32498. func (m *TokenMutation) ID() (id uint64, exists bool) {
  32499. if m.id == nil {
  32500. return
  32501. }
  32502. return *m.id, true
  32503. }
  32504. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32505. // That means, if the mutation is applied within a transaction with an isolation level such
  32506. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32507. // or updated by the mutation.
  32508. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  32509. switch {
  32510. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32511. id, exists := m.ID()
  32512. if exists {
  32513. return []uint64{id}, nil
  32514. }
  32515. fallthrough
  32516. case m.op.Is(OpUpdate | OpDelete):
  32517. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  32518. default:
  32519. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32520. }
  32521. }
  32522. // SetCreatedAt sets the "created_at" field.
  32523. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  32524. m.created_at = &t
  32525. }
  32526. // CreatedAt returns the value of the "created_at" field in the mutation.
  32527. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  32528. v := m.created_at
  32529. if v == nil {
  32530. return
  32531. }
  32532. return *v, true
  32533. }
  32534. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  32535. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32537. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32538. if !m.op.Is(OpUpdateOne) {
  32539. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32540. }
  32541. if m.id == nil || m.oldValue == nil {
  32542. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32543. }
  32544. oldValue, err := m.oldValue(ctx)
  32545. if err != nil {
  32546. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32547. }
  32548. return oldValue.CreatedAt, nil
  32549. }
  32550. // ResetCreatedAt resets all changes to the "created_at" field.
  32551. func (m *TokenMutation) ResetCreatedAt() {
  32552. m.created_at = nil
  32553. }
  32554. // SetUpdatedAt sets the "updated_at" field.
  32555. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  32556. m.updated_at = &t
  32557. }
  32558. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32559. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  32560. v := m.updated_at
  32561. if v == nil {
  32562. return
  32563. }
  32564. return *v, true
  32565. }
  32566. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  32567. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32569. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32570. if !m.op.Is(OpUpdateOne) {
  32571. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32572. }
  32573. if m.id == nil || m.oldValue == nil {
  32574. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32575. }
  32576. oldValue, err := m.oldValue(ctx)
  32577. if err != nil {
  32578. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32579. }
  32580. return oldValue.UpdatedAt, nil
  32581. }
  32582. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32583. func (m *TokenMutation) ResetUpdatedAt() {
  32584. m.updated_at = nil
  32585. }
  32586. // SetDeletedAt sets the "deleted_at" field.
  32587. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  32588. m.deleted_at = &t
  32589. }
  32590. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32591. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  32592. v := m.deleted_at
  32593. if v == nil {
  32594. return
  32595. }
  32596. return *v, true
  32597. }
  32598. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  32599. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32601. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32602. if !m.op.Is(OpUpdateOne) {
  32603. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32604. }
  32605. if m.id == nil || m.oldValue == nil {
  32606. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32607. }
  32608. oldValue, err := m.oldValue(ctx)
  32609. if err != nil {
  32610. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32611. }
  32612. return oldValue.DeletedAt, nil
  32613. }
  32614. // ClearDeletedAt clears the value of the "deleted_at" field.
  32615. func (m *TokenMutation) ClearDeletedAt() {
  32616. m.deleted_at = nil
  32617. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  32618. }
  32619. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32620. func (m *TokenMutation) DeletedAtCleared() bool {
  32621. _, ok := m.clearedFields[token.FieldDeletedAt]
  32622. return ok
  32623. }
  32624. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32625. func (m *TokenMutation) ResetDeletedAt() {
  32626. m.deleted_at = nil
  32627. delete(m.clearedFields, token.FieldDeletedAt)
  32628. }
  32629. // SetExpireAt sets the "expire_at" field.
  32630. func (m *TokenMutation) SetExpireAt(t time.Time) {
  32631. m.expire_at = &t
  32632. }
  32633. // ExpireAt returns the value of the "expire_at" field in the mutation.
  32634. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  32635. v := m.expire_at
  32636. if v == nil {
  32637. return
  32638. }
  32639. return *v, true
  32640. }
  32641. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  32642. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32644. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  32645. if !m.op.Is(OpUpdateOne) {
  32646. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  32647. }
  32648. if m.id == nil || m.oldValue == nil {
  32649. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  32650. }
  32651. oldValue, err := m.oldValue(ctx)
  32652. if err != nil {
  32653. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  32654. }
  32655. return oldValue.ExpireAt, nil
  32656. }
  32657. // ClearExpireAt clears the value of the "expire_at" field.
  32658. func (m *TokenMutation) ClearExpireAt() {
  32659. m.expire_at = nil
  32660. m.clearedFields[token.FieldExpireAt] = struct{}{}
  32661. }
  32662. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  32663. func (m *TokenMutation) ExpireAtCleared() bool {
  32664. _, ok := m.clearedFields[token.FieldExpireAt]
  32665. return ok
  32666. }
  32667. // ResetExpireAt resets all changes to the "expire_at" field.
  32668. func (m *TokenMutation) ResetExpireAt() {
  32669. m.expire_at = nil
  32670. delete(m.clearedFields, token.FieldExpireAt)
  32671. }
  32672. // SetToken sets the "token" field.
  32673. func (m *TokenMutation) SetToken(s string) {
  32674. m.token = &s
  32675. }
  32676. // Token returns the value of the "token" field in the mutation.
  32677. func (m *TokenMutation) Token() (r string, exists bool) {
  32678. v := m.token
  32679. if v == nil {
  32680. return
  32681. }
  32682. return *v, true
  32683. }
  32684. // OldToken returns the old "token" field's value of the Token entity.
  32685. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32687. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  32688. if !m.op.Is(OpUpdateOne) {
  32689. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  32690. }
  32691. if m.id == nil || m.oldValue == nil {
  32692. return v, errors.New("OldToken requires an ID field in the mutation")
  32693. }
  32694. oldValue, err := m.oldValue(ctx)
  32695. if err != nil {
  32696. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  32697. }
  32698. return oldValue.Token, nil
  32699. }
  32700. // ClearToken clears the value of the "token" field.
  32701. func (m *TokenMutation) ClearToken() {
  32702. m.token = nil
  32703. m.clearedFields[token.FieldToken] = struct{}{}
  32704. }
  32705. // TokenCleared returns if the "token" field was cleared in this mutation.
  32706. func (m *TokenMutation) TokenCleared() bool {
  32707. _, ok := m.clearedFields[token.FieldToken]
  32708. return ok
  32709. }
  32710. // ResetToken resets all changes to the "token" field.
  32711. func (m *TokenMutation) ResetToken() {
  32712. m.token = nil
  32713. delete(m.clearedFields, token.FieldToken)
  32714. }
  32715. // SetMAC sets the "mac" field.
  32716. func (m *TokenMutation) SetMAC(s string) {
  32717. m.mac = &s
  32718. }
  32719. // MAC returns the value of the "mac" field in the mutation.
  32720. func (m *TokenMutation) MAC() (r string, exists bool) {
  32721. v := m.mac
  32722. if v == nil {
  32723. return
  32724. }
  32725. return *v, true
  32726. }
  32727. // OldMAC returns the old "mac" field's value of the Token entity.
  32728. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32730. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  32731. if !m.op.Is(OpUpdateOne) {
  32732. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  32733. }
  32734. if m.id == nil || m.oldValue == nil {
  32735. return v, errors.New("OldMAC requires an ID field in the mutation")
  32736. }
  32737. oldValue, err := m.oldValue(ctx)
  32738. if err != nil {
  32739. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  32740. }
  32741. return oldValue.MAC, nil
  32742. }
  32743. // ClearMAC clears the value of the "mac" field.
  32744. func (m *TokenMutation) ClearMAC() {
  32745. m.mac = nil
  32746. m.clearedFields[token.FieldMAC] = struct{}{}
  32747. }
  32748. // MACCleared returns if the "mac" field was cleared in this mutation.
  32749. func (m *TokenMutation) MACCleared() bool {
  32750. _, ok := m.clearedFields[token.FieldMAC]
  32751. return ok
  32752. }
  32753. // ResetMAC resets all changes to the "mac" field.
  32754. func (m *TokenMutation) ResetMAC() {
  32755. m.mac = nil
  32756. delete(m.clearedFields, token.FieldMAC)
  32757. }
  32758. // SetOrganizationID sets the "organization_id" field.
  32759. func (m *TokenMutation) SetOrganizationID(u uint64) {
  32760. m.organization_id = &u
  32761. m.addorganization_id = nil
  32762. }
  32763. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32764. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  32765. v := m.organization_id
  32766. if v == nil {
  32767. return
  32768. }
  32769. return *v, true
  32770. }
  32771. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  32772. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32774. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32775. if !m.op.Is(OpUpdateOne) {
  32776. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32777. }
  32778. if m.id == nil || m.oldValue == nil {
  32779. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32780. }
  32781. oldValue, err := m.oldValue(ctx)
  32782. if err != nil {
  32783. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32784. }
  32785. return oldValue.OrganizationID, nil
  32786. }
  32787. // AddOrganizationID adds u to the "organization_id" field.
  32788. func (m *TokenMutation) AddOrganizationID(u int64) {
  32789. if m.addorganization_id != nil {
  32790. *m.addorganization_id += u
  32791. } else {
  32792. m.addorganization_id = &u
  32793. }
  32794. }
  32795. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32796. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  32797. v := m.addorganization_id
  32798. if v == nil {
  32799. return
  32800. }
  32801. return *v, true
  32802. }
  32803. // ResetOrganizationID resets all changes to the "organization_id" field.
  32804. func (m *TokenMutation) ResetOrganizationID() {
  32805. m.organization_id = nil
  32806. m.addorganization_id = nil
  32807. }
  32808. // SetAgentID sets the "agent_id" field.
  32809. func (m *TokenMutation) SetAgentID(u uint64) {
  32810. m.agent = &u
  32811. }
  32812. // AgentID returns the value of the "agent_id" field in the mutation.
  32813. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  32814. v := m.agent
  32815. if v == nil {
  32816. return
  32817. }
  32818. return *v, true
  32819. }
  32820. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  32821. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32823. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  32824. if !m.op.Is(OpUpdateOne) {
  32825. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  32826. }
  32827. if m.id == nil || m.oldValue == nil {
  32828. return v, errors.New("OldAgentID requires an ID field in the mutation")
  32829. }
  32830. oldValue, err := m.oldValue(ctx)
  32831. if err != nil {
  32832. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  32833. }
  32834. return oldValue.AgentID, nil
  32835. }
  32836. // ResetAgentID resets all changes to the "agent_id" field.
  32837. func (m *TokenMutation) ResetAgentID() {
  32838. m.agent = nil
  32839. }
  32840. // SetCustomAgentBase sets the "custom_agent_base" field.
  32841. func (m *TokenMutation) SetCustomAgentBase(s string) {
  32842. m.custom_agent_base = &s
  32843. }
  32844. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  32845. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  32846. v := m.custom_agent_base
  32847. if v == nil {
  32848. return
  32849. }
  32850. return *v, true
  32851. }
  32852. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  32853. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32855. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  32856. if !m.op.Is(OpUpdateOne) {
  32857. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  32858. }
  32859. if m.id == nil || m.oldValue == nil {
  32860. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  32861. }
  32862. oldValue, err := m.oldValue(ctx)
  32863. if err != nil {
  32864. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  32865. }
  32866. return oldValue.CustomAgentBase, nil
  32867. }
  32868. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  32869. func (m *TokenMutation) ClearCustomAgentBase() {
  32870. m.custom_agent_base = nil
  32871. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  32872. }
  32873. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  32874. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  32875. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  32876. return ok
  32877. }
  32878. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  32879. func (m *TokenMutation) ResetCustomAgentBase() {
  32880. m.custom_agent_base = nil
  32881. delete(m.clearedFields, token.FieldCustomAgentBase)
  32882. }
  32883. // SetCustomAgentKey sets the "custom_agent_key" field.
  32884. func (m *TokenMutation) SetCustomAgentKey(s string) {
  32885. m.custom_agent_key = &s
  32886. }
  32887. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  32888. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  32889. v := m.custom_agent_key
  32890. if v == nil {
  32891. return
  32892. }
  32893. return *v, true
  32894. }
  32895. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  32896. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32898. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  32899. if !m.op.Is(OpUpdateOne) {
  32900. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  32901. }
  32902. if m.id == nil || m.oldValue == nil {
  32903. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  32904. }
  32905. oldValue, err := m.oldValue(ctx)
  32906. if err != nil {
  32907. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  32908. }
  32909. return oldValue.CustomAgentKey, nil
  32910. }
  32911. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  32912. func (m *TokenMutation) ClearCustomAgentKey() {
  32913. m.custom_agent_key = nil
  32914. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  32915. }
  32916. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  32917. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  32918. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  32919. return ok
  32920. }
  32921. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  32922. func (m *TokenMutation) ResetCustomAgentKey() {
  32923. m.custom_agent_key = nil
  32924. delete(m.clearedFields, token.FieldCustomAgentKey)
  32925. }
  32926. // SetOpenaiBase sets the "openai_base" field.
  32927. func (m *TokenMutation) SetOpenaiBase(s string) {
  32928. m.openai_base = &s
  32929. }
  32930. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  32931. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  32932. v := m.openai_base
  32933. if v == nil {
  32934. return
  32935. }
  32936. return *v, true
  32937. }
  32938. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  32939. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32941. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  32942. if !m.op.Is(OpUpdateOne) {
  32943. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  32944. }
  32945. if m.id == nil || m.oldValue == nil {
  32946. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  32947. }
  32948. oldValue, err := m.oldValue(ctx)
  32949. if err != nil {
  32950. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  32951. }
  32952. return oldValue.OpenaiBase, nil
  32953. }
  32954. // ClearOpenaiBase clears the value of the "openai_base" field.
  32955. func (m *TokenMutation) ClearOpenaiBase() {
  32956. m.openai_base = nil
  32957. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  32958. }
  32959. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  32960. func (m *TokenMutation) OpenaiBaseCleared() bool {
  32961. _, ok := m.clearedFields[token.FieldOpenaiBase]
  32962. return ok
  32963. }
  32964. // ResetOpenaiBase resets all changes to the "openai_base" field.
  32965. func (m *TokenMutation) ResetOpenaiBase() {
  32966. m.openai_base = nil
  32967. delete(m.clearedFields, token.FieldOpenaiBase)
  32968. }
  32969. // SetOpenaiKey sets the "openai_key" field.
  32970. func (m *TokenMutation) SetOpenaiKey(s string) {
  32971. m.openai_key = &s
  32972. }
  32973. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  32974. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  32975. v := m.openai_key
  32976. if v == nil {
  32977. return
  32978. }
  32979. return *v, true
  32980. }
  32981. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  32982. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  32983. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32984. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  32985. if !m.op.Is(OpUpdateOne) {
  32986. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  32987. }
  32988. if m.id == nil || m.oldValue == nil {
  32989. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  32990. }
  32991. oldValue, err := m.oldValue(ctx)
  32992. if err != nil {
  32993. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  32994. }
  32995. return oldValue.OpenaiKey, nil
  32996. }
  32997. // ClearOpenaiKey clears the value of the "openai_key" field.
  32998. func (m *TokenMutation) ClearOpenaiKey() {
  32999. m.openai_key = nil
  33000. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  33001. }
  33002. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  33003. func (m *TokenMutation) OpenaiKeyCleared() bool {
  33004. _, ok := m.clearedFields[token.FieldOpenaiKey]
  33005. return ok
  33006. }
  33007. // ResetOpenaiKey resets all changes to the "openai_key" field.
  33008. func (m *TokenMutation) ResetOpenaiKey() {
  33009. m.openai_key = nil
  33010. delete(m.clearedFields, token.FieldOpenaiKey)
  33011. }
  33012. // ClearAgent clears the "agent" edge to the Agent entity.
  33013. func (m *TokenMutation) ClearAgent() {
  33014. m.clearedagent = true
  33015. m.clearedFields[token.FieldAgentID] = struct{}{}
  33016. }
  33017. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  33018. func (m *TokenMutation) AgentCleared() bool {
  33019. return m.clearedagent
  33020. }
  33021. // AgentIDs returns the "agent" edge IDs in the mutation.
  33022. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33023. // AgentID instead. It exists only for internal usage by the builders.
  33024. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  33025. if id := m.agent; id != nil {
  33026. ids = append(ids, *id)
  33027. }
  33028. return
  33029. }
  33030. // ResetAgent resets all changes to the "agent" edge.
  33031. func (m *TokenMutation) ResetAgent() {
  33032. m.agent = nil
  33033. m.clearedagent = false
  33034. }
  33035. // Where appends a list predicates to the TokenMutation builder.
  33036. func (m *TokenMutation) Where(ps ...predicate.Token) {
  33037. m.predicates = append(m.predicates, ps...)
  33038. }
  33039. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  33040. // users can use type-assertion to append predicates that do not depend on any generated package.
  33041. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  33042. p := make([]predicate.Token, len(ps))
  33043. for i := range ps {
  33044. p[i] = ps[i]
  33045. }
  33046. m.Where(p...)
  33047. }
  33048. // Op returns the operation name.
  33049. func (m *TokenMutation) Op() Op {
  33050. return m.op
  33051. }
  33052. // SetOp allows setting the mutation operation.
  33053. func (m *TokenMutation) SetOp(op Op) {
  33054. m.op = op
  33055. }
  33056. // Type returns the node type of this mutation (Token).
  33057. func (m *TokenMutation) Type() string {
  33058. return m.typ
  33059. }
  33060. // Fields returns all fields that were changed during this mutation. Note that in
  33061. // order to get all numeric fields that were incremented/decremented, call
  33062. // AddedFields().
  33063. func (m *TokenMutation) Fields() []string {
  33064. fields := make([]string, 0, 12)
  33065. if m.created_at != nil {
  33066. fields = append(fields, token.FieldCreatedAt)
  33067. }
  33068. if m.updated_at != nil {
  33069. fields = append(fields, token.FieldUpdatedAt)
  33070. }
  33071. if m.deleted_at != nil {
  33072. fields = append(fields, token.FieldDeletedAt)
  33073. }
  33074. if m.expire_at != nil {
  33075. fields = append(fields, token.FieldExpireAt)
  33076. }
  33077. if m.token != nil {
  33078. fields = append(fields, token.FieldToken)
  33079. }
  33080. if m.mac != nil {
  33081. fields = append(fields, token.FieldMAC)
  33082. }
  33083. if m.organization_id != nil {
  33084. fields = append(fields, token.FieldOrganizationID)
  33085. }
  33086. if m.agent != nil {
  33087. fields = append(fields, token.FieldAgentID)
  33088. }
  33089. if m.custom_agent_base != nil {
  33090. fields = append(fields, token.FieldCustomAgentBase)
  33091. }
  33092. if m.custom_agent_key != nil {
  33093. fields = append(fields, token.FieldCustomAgentKey)
  33094. }
  33095. if m.openai_base != nil {
  33096. fields = append(fields, token.FieldOpenaiBase)
  33097. }
  33098. if m.openai_key != nil {
  33099. fields = append(fields, token.FieldOpenaiKey)
  33100. }
  33101. return fields
  33102. }
  33103. // Field returns the value of a field with the given name. The second boolean
  33104. // return value indicates that this field was not set, or was not defined in the
  33105. // schema.
  33106. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  33107. switch name {
  33108. case token.FieldCreatedAt:
  33109. return m.CreatedAt()
  33110. case token.FieldUpdatedAt:
  33111. return m.UpdatedAt()
  33112. case token.FieldDeletedAt:
  33113. return m.DeletedAt()
  33114. case token.FieldExpireAt:
  33115. return m.ExpireAt()
  33116. case token.FieldToken:
  33117. return m.Token()
  33118. case token.FieldMAC:
  33119. return m.MAC()
  33120. case token.FieldOrganizationID:
  33121. return m.OrganizationID()
  33122. case token.FieldAgentID:
  33123. return m.AgentID()
  33124. case token.FieldCustomAgentBase:
  33125. return m.CustomAgentBase()
  33126. case token.FieldCustomAgentKey:
  33127. return m.CustomAgentKey()
  33128. case token.FieldOpenaiBase:
  33129. return m.OpenaiBase()
  33130. case token.FieldOpenaiKey:
  33131. return m.OpenaiKey()
  33132. }
  33133. return nil, false
  33134. }
  33135. // OldField returns the old value of the field from the database. An error is
  33136. // returned if the mutation operation is not UpdateOne, or the query to the
  33137. // database failed.
  33138. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33139. switch name {
  33140. case token.FieldCreatedAt:
  33141. return m.OldCreatedAt(ctx)
  33142. case token.FieldUpdatedAt:
  33143. return m.OldUpdatedAt(ctx)
  33144. case token.FieldDeletedAt:
  33145. return m.OldDeletedAt(ctx)
  33146. case token.FieldExpireAt:
  33147. return m.OldExpireAt(ctx)
  33148. case token.FieldToken:
  33149. return m.OldToken(ctx)
  33150. case token.FieldMAC:
  33151. return m.OldMAC(ctx)
  33152. case token.FieldOrganizationID:
  33153. return m.OldOrganizationID(ctx)
  33154. case token.FieldAgentID:
  33155. return m.OldAgentID(ctx)
  33156. case token.FieldCustomAgentBase:
  33157. return m.OldCustomAgentBase(ctx)
  33158. case token.FieldCustomAgentKey:
  33159. return m.OldCustomAgentKey(ctx)
  33160. case token.FieldOpenaiBase:
  33161. return m.OldOpenaiBase(ctx)
  33162. case token.FieldOpenaiKey:
  33163. return m.OldOpenaiKey(ctx)
  33164. }
  33165. return nil, fmt.Errorf("unknown Token field %s", name)
  33166. }
  33167. // SetField sets the value of a field with the given name. It returns an error if
  33168. // the field is not defined in the schema, or if the type mismatched the field
  33169. // type.
  33170. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  33171. switch name {
  33172. case token.FieldCreatedAt:
  33173. v, ok := value.(time.Time)
  33174. if !ok {
  33175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33176. }
  33177. m.SetCreatedAt(v)
  33178. return nil
  33179. case token.FieldUpdatedAt:
  33180. v, ok := value.(time.Time)
  33181. if !ok {
  33182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33183. }
  33184. m.SetUpdatedAt(v)
  33185. return nil
  33186. case token.FieldDeletedAt:
  33187. v, ok := value.(time.Time)
  33188. if !ok {
  33189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33190. }
  33191. m.SetDeletedAt(v)
  33192. return nil
  33193. case token.FieldExpireAt:
  33194. v, ok := value.(time.Time)
  33195. if !ok {
  33196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33197. }
  33198. m.SetExpireAt(v)
  33199. return nil
  33200. case token.FieldToken:
  33201. v, ok := value.(string)
  33202. if !ok {
  33203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33204. }
  33205. m.SetToken(v)
  33206. return nil
  33207. case token.FieldMAC:
  33208. v, ok := value.(string)
  33209. if !ok {
  33210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33211. }
  33212. m.SetMAC(v)
  33213. return nil
  33214. case token.FieldOrganizationID:
  33215. v, ok := value.(uint64)
  33216. if !ok {
  33217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33218. }
  33219. m.SetOrganizationID(v)
  33220. return nil
  33221. case token.FieldAgentID:
  33222. v, ok := value.(uint64)
  33223. if !ok {
  33224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33225. }
  33226. m.SetAgentID(v)
  33227. return nil
  33228. case token.FieldCustomAgentBase:
  33229. v, ok := value.(string)
  33230. if !ok {
  33231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33232. }
  33233. m.SetCustomAgentBase(v)
  33234. return nil
  33235. case token.FieldCustomAgentKey:
  33236. v, ok := value.(string)
  33237. if !ok {
  33238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33239. }
  33240. m.SetCustomAgentKey(v)
  33241. return nil
  33242. case token.FieldOpenaiBase:
  33243. v, ok := value.(string)
  33244. if !ok {
  33245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33246. }
  33247. m.SetOpenaiBase(v)
  33248. return nil
  33249. case token.FieldOpenaiKey:
  33250. v, ok := value.(string)
  33251. if !ok {
  33252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33253. }
  33254. m.SetOpenaiKey(v)
  33255. return nil
  33256. }
  33257. return fmt.Errorf("unknown Token field %s", name)
  33258. }
  33259. // AddedFields returns all numeric fields that were incremented/decremented during
  33260. // this mutation.
  33261. func (m *TokenMutation) AddedFields() []string {
  33262. var fields []string
  33263. if m.addorganization_id != nil {
  33264. fields = append(fields, token.FieldOrganizationID)
  33265. }
  33266. return fields
  33267. }
  33268. // AddedField returns the numeric value that was incremented/decremented on a field
  33269. // with the given name. The second boolean return value indicates that this field
  33270. // was not set, or was not defined in the schema.
  33271. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  33272. switch name {
  33273. case token.FieldOrganizationID:
  33274. return m.AddedOrganizationID()
  33275. }
  33276. return nil, false
  33277. }
  33278. // AddField adds the value to the field with the given name. It returns an error if
  33279. // the field is not defined in the schema, or if the type mismatched the field
  33280. // type.
  33281. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  33282. switch name {
  33283. case token.FieldOrganizationID:
  33284. v, ok := value.(int64)
  33285. if !ok {
  33286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33287. }
  33288. m.AddOrganizationID(v)
  33289. return nil
  33290. }
  33291. return fmt.Errorf("unknown Token numeric field %s", name)
  33292. }
  33293. // ClearedFields returns all nullable fields that were cleared during this
  33294. // mutation.
  33295. func (m *TokenMutation) ClearedFields() []string {
  33296. var fields []string
  33297. if m.FieldCleared(token.FieldDeletedAt) {
  33298. fields = append(fields, token.FieldDeletedAt)
  33299. }
  33300. if m.FieldCleared(token.FieldExpireAt) {
  33301. fields = append(fields, token.FieldExpireAt)
  33302. }
  33303. if m.FieldCleared(token.FieldToken) {
  33304. fields = append(fields, token.FieldToken)
  33305. }
  33306. if m.FieldCleared(token.FieldMAC) {
  33307. fields = append(fields, token.FieldMAC)
  33308. }
  33309. if m.FieldCleared(token.FieldCustomAgentBase) {
  33310. fields = append(fields, token.FieldCustomAgentBase)
  33311. }
  33312. if m.FieldCleared(token.FieldCustomAgentKey) {
  33313. fields = append(fields, token.FieldCustomAgentKey)
  33314. }
  33315. if m.FieldCleared(token.FieldOpenaiBase) {
  33316. fields = append(fields, token.FieldOpenaiBase)
  33317. }
  33318. if m.FieldCleared(token.FieldOpenaiKey) {
  33319. fields = append(fields, token.FieldOpenaiKey)
  33320. }
  33321. return fields
  33322. }
  33323. // FieldCleared returns a boolean indicating if a field with the given name was
  33324. // cleared in this mutation.
  33325. func (m *TokenMutation) FieldCleared(name string) bool {
  33326. _, ok := m.clearedFields[name]
  33327. return ok
  33328. }
  33329. // ClearField clears the value of the field with the given name. It returns an
  33330. // error if the field is not defined in the schema.
  33331. func (m *TokenMutation) ClearField(name string) error {
  33332. switch name {
  33333. case token.FieldDeletedAt:
  33334. m.ClearDeletedAt()
  33335. return nil
  33336. case token.FieldExpireAt:
  33337. m.ClearExpireAt()
  33338. return nil
  33339. case token.FieldToken:
  33340. m.ClearToken()
  33341. return nil
  33342. case token.FieldMAC:
  33343. m.ClearMAC()
  33344. return nil
  33345. case token.FieldCustomAgentBase:
  33346. m.ClearCustomAgentBase()
  33347. return nil
  33348. case token.FieldCustomAgentKey:
  33349. m.ClearCustomAgentKey()
  33350. return nil
  33351. case token.FieldOpenaiBase:
  33352. m.ClearOpenaiBase()
  33353. return nil
  33354. case token.FieldOpenaiKey:
  33355. m.ClearOpenaiKey()
  33356. return nil
  33357. }
  33358. return fmt.Errorf("unknown Token nullable field %s", name)
  33359. }
  33360. // ResetField resets all changes in the mutation for the field with the given name.
  33361. // It returns an error if the field is not defined in the schema.
  33362. func (m *TokenMutation) ResetField(name string) error {
  33363. switch name {
  33364. case token.FieldCreatedAt:
  33365. m.ResetCreatedAt()
  33366. return nil
  33367. case token.FieldUpdatedAt:
  33368. m.ResetUpdatedAt()
  33369. return nil
  33370. case token.FieldDeletedAt:
  33371. m.ResetDeletedAt()
  33372. return nil
  33373. case token.FieldExpireAt:
  33374. m.ResetExpireAt()
  33375. return nil
  33376. case token.FieldToken:
  33377. m.ResetToken()
  33378. return nil
  33379. case token.FieldMAC:
  33380. m.ResetMAC()
  33381. return nil
  33382. case token.FieldOrganizationID:
  33383. m.ResetOrganizationID()
  33384. return nil
  33385. case token.FieldAgentID:
  33386. m.ResetAgentID()
  33387. return nil
  33388. case token.FieldCustomAgentBase:
  33389. m.ResetCustomAgentBase()
  33390. return nil
  33391. case token.FieldCustomAgentKey:
  33392. m.ResetCustomAgentKey()
  33393. return nil
  33394. case token.FieldOpenaiBase:
  33395. m.ResetOpenaiBase()
  33396. return nil
  33397. case token.FieldOpenaiKey:
  33398. m.ResetOpenaiKey()
  33399. return nil
  33400. }
  33401. return fmt.Errorf("unknown Token field %s", name)
  33402. }
  33403. // AddedEdges returns all edge names that were set/added in this mutation.
  33404. func (m *TokenMutation) AddedEdges() []string {
  33405. edges := make([]string, 0, 1)
  33406. if m.agent != nil {
  33407. edges = append(edges, token.EdgeAgent)
  33408. }
  33409. return edges
  33410. }
  33411. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33412. // name in this mutation.
  33413. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  33414. switch name {
  33415. case token.EdgeAgent:
  33416. if id := m.agent; id != nil {
  33417. return []ent.Value{*id}
  33418. }
  33419. }
  33420. return nil
  33421. }
  33422. // RemovedEdges returns all edge names that were removed in this mutation.
  33423. func (m *TokenMutation) RemovedEdges() []string {
  33424. edges := make([]string, 0, 1)
  33425. return edges
  33426. }
  33427. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33428. // the given name in this mutation.
  33429. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  33430. return nil
  33431. }
  33432. // ClearedEdges returns all edge names that were cleared in this mutation.
  33433. func (m *TokenMutation) ClearedEdges() []string {
  33434. edges := make([]string, 0, 1)
  33435. if m.clearedagent {
  33436. edges = append(edges, token.EdgeAgent)
  33437. }
  33438. return edges
  33439. }
  33440. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33441. // was cleared in this mutation.
  33442. func (m *TokenMutation) EdgeCleared(name string) bool {
  33443. switch name {
  33444. case token.EdgeAgent:
  33445. return m.clearedagent
  33446. }
  33447. return false
  33448. }
  33449. // ClearEdge clears the value of the edge with the given name. It returns an error
  33450. // if that edge is not defined in the schema.
  33451. func (m *TokenMutation) ClearEdge(name string) error {
  33452. switch name {
  33453. case token.EdgeAgent:
  33454. m.ClearAgent()
  33455. return nil
  33456. }
  33457. return fmt.Errorf("unknown Token unique edge %s", name)
  33458. }
  33459. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33460. // It returns an error if the edge is not defined in the schema.
  33461. func (m *TokenMutation) ResetEdge(name string) error {
  33462. switch name {
  33463. case token.EdgeAgent:
  33464. m.ResetAgent()
  33465. return nil
  33466. }
  33467. return fmt.Errorf("unknown Token edge %s", name)
  33468. }
  33469. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  33470. type TutorialMutation struct {
  33471. config
  33472. op Op
  33473. typ string
  33474. id *uint64
  33475. created_at *time.Time
  33476. updated_at *time.Time
  33477. deleted_at *time.Time
  33478. index *int
  33479. addindex *int
  33480. title *string
  33481. content *string
  33482. organization_id *uint64
  33483. addorganization_id *int64
  33484. clearedFields map[string]struct{}
  33485. employee *uint64
  33486. clearedemployee bool
  33487. done bool
  33488. oldValue func(context.Context) (*Tutorial, error)
  33489. predicates []predicate.Tutorial
  33490. }
  33491. var _ ent.Mutation = (*TutorialMutation)(nil)
  33492. // tutorialOption allows management of the mutation configuration using functional options.
  33493. type tutorialOption func(*TutorialMutation)
  33494. // newTutorialMutation creates new mutation for the Tutorial entity.
  33495. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  33496. m := &TutorialMutation{
  33497. config: c,
  33498. op: op,
  33499. typ: TypeTutorial,
  33500. clearedFields: make(map[string]struct{}),
  33501. }
  33502. for _, opt := range opts {
  33503. opt(m)
  33504. }
  33505. return m
  33506. }
  33507. // withTutorialID sets the ID field of the mutation.
  33508. func withTutorialID(id uint64) tutorialOption {
  33509. return func(m *TutorialMutation) {
  33510. var (
  33511. err error
  33512. once sync.Once
  33513. value *Tutorial
  33514. )
  33515. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  33516. once.Do(func() {
  33517. if m.done {
  33518. err = errors.New("querying old values post mutation is not allowed")
  33519. } else {
  33520. value, err = m.Client().Tutorial.Get(ctx, id)
  33521. }
  33522. })
  33523. return value, err
  33524. }
  33525. m.id = &id
  33526. }
  33527. }
  33528. // withTutorial sets the old Tutorial of the mutation.
  33529. func withTutorial(node *Tutorial) tutorialOption {
  33530. return func(m *TutorialMutation) {
  33531. m.oldValue = func(context.Context) (*Tutorial, error) {
  33532. return node, nil
  33533. }
  33534. m.id = &node.ID
  33535. }
  33536. }
  33537. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33538. // executed in a transaction (ent.Tx), a transactional client is returned.
  33539. func (m TutorialMutation) Client() *Client {
  33540. client := &Client{config: m.config}
  33541. client.init()
  33542. return client
  33543. }
  33544. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33545. // it returns an error otherwise.
  33546. func (m TutorialMutation) Tx() (*Tx, error) {
  33547. if _, ok := m.driver.(*txDriver); !ok {
  33548. return nil, errors.New("ent: mutation is not running in a transaction")
  33549. }
  33550. tx := &Tx{config: m.config}
  33551. tx.init()
  33552. return tx, nil
  33553. }
  33554. // SetID sets the value of the id field. Note that this
  33555. // operation is only accepted on creation of Tutorial entities.
  33556. func (m *TutorialMutation) SetID(id uint64) {
  33557. m.id = &id
  33558. }
  33559. // ID returns the ID value in the mutation. Note that the ID is only available
  33560. // if it was provided to the builder or after it was returned from the database.
  33561. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  33562. if m.id == nil {
  33563. return
  33564. }
  33565. return *m.id, true
  33566. }
  33567. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33568. // That means, if the mutation is applied within a transaction with an isolation level such
  33569. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33570. // or updated by the mutation.
  33571. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  33572. switch {
  33573. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33574. id, exists := m.ID()
  33575. if exists {
  33576. return []uint64{id}, nil
  33577. }
  33578. fallthrough
  33579. case m.op.Is(OpUpdate | OpDelete):
  33580. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  33581. default:
  33582. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33583. }
  33584. }
  33585. // SetCreatedAt sets the "created_at" field.
  33586. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  33587. m.created_at = &t
  33588. }
  33589. // CreatedAt returns the value of the "created_at" field in the mutation.
  33590. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  33591. v := m.created_at
  33592. if v == nil {
  33593. return
  33594. }
  33595. return *v, true
  33596. }
  33597. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  33598. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33600. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33601. if !m.op.Is(OpUpdateOne) {
  33602. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33603. }
  33604. if m.id == nil || m.oldValue == nil {
  33605. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33606. }
  33607. oldValue, err := m.oldValue(ctx)
  33608. if err != nil {
  33609. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33610. }
  33611. return oldValue.CreatedAt, nil
  33612. }
  33613. // ResetCreatedAt resets all changes to the "created_at" field.
  33614. func (m *TutorialMutation) ResetCreatedAt() {
  33615. m.created_at = nil
  33616. }
  33617. // SetUpdatedAt sets the "updated_at" field.
  33618. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  33619. m.updated_at = &t
  33620. }
  33621. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33622. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  33623. v := m.updated_at
  33624. if v == nil {
  33625. return
  33626. }
  33627. return *v, true
  33628. }
  33629. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  33630. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33632. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33633. if !m.op.Is(OpUpdateOne) {
  33634. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33635. }
  33636. if m.id == nil || m.oldValue == nil {
  33637. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33638. }
  33639. oldValue, err := m.oldValue(ctx)
  33640. if err != nil {
  33641. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33642. }
  33643. return oldValue.UpdatedAt, nil
  33644. }
  33645. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33646. func (m *TutorialMutation) ResetUpdatedAt() {
  33647. m.updated_at = nil
  33648. }
  33649. // SetDeletedAt sets the "deleted_at" field.
  33650. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  33651. m.deleted_at = &t
  33652. }
  33653. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33654. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  33655. v := m.deleted_at
  33656. if v == nil {
  33657. return
  33658. }
  33659. return *v, true
  33660. }
  33661. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  33662. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33663. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33664. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33665. if !m.op.Is(OpUpdateOne) {
  33666. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33667. }
  33668. if m.id == nil || m.oldValue == nil {
  33669. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33670. }
  33671. oldValue, err := m.oldValue(ctx)
  33672. if err != nil {
  33673. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33674. }
  33675. return oldValue.DeletedAt, nil
  33676. }
  33677. // ClearDeletedAt clears the value of the "deleted_at" field.
  33678. func (m *TutorialMutation) ClearDeletedAt() {
  33679. m.deleted_at = nil
  33680. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  33681. }
  33682. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33683. func (m *TutorialMutation) DeletedAtCleared() bool {
  33684. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  33685. return ok
  33686. }
  33687. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33688. func (m *TutorialMutation) ResetDeletedAt() {
  33689. m.deleted_at = nil
  33690. delete(m.clearedFields, tutorial.FieldDeletedAt)
  33691. }
  33692. // SetEmployeeID sets the "employee_id" field.
  33693. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  33694. m.employee = &u
  33695. }
  33696. // EmployeeID returns the value of the "employee_id" field in the mutation.
  33697. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  33698. v := m.employee
  33699. if v == nil {
  33700. return
  33701. }
  33702. return *v, true
  33703. }
  33704. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  33705. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33707. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  33708. if !m.op.Is(OpUpdateOne) {
  33709. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  33710. }
  33711. if m.id == nil || m.oldValue == nil {
  33712. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  33713. }
  33714. oldValue, err := m.oldValue(ctx)
  33715. if err != nil {
  33716. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  33717. }
  33718. return oldValue.EmployeeID, nil
  33719. }
  33720. // ResetEmployeeID resets all changes to the "employee_id" field.
  33721. func (m *TutorialMutation) ResetEmployeeID() {
  33722. m.employee = nil
  33723. }
  33724. // SetIndex sets the "index" field.
  33725. func (m *TutorialMutation) SetIndex(i int) {
  33726. m.index = &i
  33727. m.addindex = nil
  33728. }
  33729. // Index returns the value of the "index" field in the mutation.
  33730. func (m *TutorialMutation) Index() (r int, exists bool) {
  33731. v := m.index
  33732. if v == nil {
  33733. return
  33734. }
  33735. return *v, true
  33736. }
  33737. // OldIndex returns the old "index" field's value of the Tutorial entity.
  33738. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33740. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  33741. if !m.op.Is(OpUpdateOne) {
  33742. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  33743. }
  33744. if m.id == nil || m.oldValue == nil {
  33745. return v, errors.New("OldIndex requires an ID field in the mutation")
  33746. }
  33747. oldValue, err := m.oldValue(ctx)
  33748. if err != nil {
  33749. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  33750. }
  33751. return oldValue.Index, nil
  33752. }
  33753. // AddIndex adds i to the "index" field.
  33754. func (m *TutorialMutation) AddIndex(i int) {
  33755. if m.addindex != nil {
  33756. *m.addindex += i
  33757. } else {
  33758. m.addindex = &i
  33759. }
  33760. }
  33761. // AddedIndex returns the value that was added to the "index" field in this mutation.
  33762. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  33763. v := m.addindex
  33764. if v == nil {
  33765. return
  33766. }
  33767. return *v, true
  33768. }
  33769. // ResetIndex resets all changes to the "index" field.
  33770. func (m *TutorialMutation) ResetIndex() {
  33771. m.index = nil
  33772. m.addindex = nil
  33773. }
  33774. // SetTitle sets the "title" field.
  33775. func (m *TutorialMutation) SetTitle(s string) {
  33776. m.title = &s
  33777. }
  33778. // Title returns the value of the "title" field in the mutation.
  33779. func (m *TutorialMutation) Title() (r string, exists bool) {
  33780. v := m.title
  33781. if v == nil {
  33782. return
  33783. }
  33784. return *v, true
  33785. }
  33786. // OldTitle returns the old "title" field's value of the Tutorial entity.
  33787. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33789. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  33790. if !m.op.Is(OpUpdateOne) {
  33791. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  33792. }
  33793. if m.id == nil || m.oldValue == nil {
  33794. return v, errors.New("OldTitle requires an ID field in the mutation")
  33795. }
  33796. oldValue, err := m.oldValue(ctx)
  33797. if err != nil {
  33798. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  33799. }
  33800. return oldValue.Title, nil
  33801. }
  33802. // ResetTitle resets all changes to the "title" field.
  33803. func (m *TutorialMutation) ResetTitle() {
  33804. m.title = nil
  33805. }
  33806. // SetContent sets the "content" field.
  33807. func (m *TutorialMutation) SetContent(s string) {
  33808. m.content = &s
  33809. }
  33810. // Content returns the value of the "content" field in the mutation.
  33811. func (m *TutorialMutation) Content() (r string, exists bool) {
  33812. v := m.content
  33813. if v == nil {
  33814. return
  33815. }
  33816. return *v, true
  33817. }
  33818. // OldContent returns the old "content" field's value of the Tutorial entity.
  33819. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33821. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  33822. if !m.op.Is(OpUpdateOne) {
  33823. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  33824. }
  33825. if m.id == nil || m.oldValue == nil {
  33826. return v, errors.New("OldContent requires an ID field in the mutation")
  33827. }
  33828. oldValue, err := m.oldValue(ctx)
  33829. if err != nil {
  33830. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  33831. }
  33832. return oldValue.Content, nil
  33833. }
  33834. // ResetContent resets all changes to the "content" field.
  33835. func (m *TutorialMutation) ResetContent() {
  33836. m.content = nil
  33837. }
  33838. // SetOrganizationID sets the "organization_id" field.
  33839. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  33840. m.organization_id = &u
  33841. m.addorganization_id = nil
  33842. }
  33843. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33844. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  33845. v := m.organization_id
  33846. if v == nil {
  33847. return
  33848. }
  33849. return *v, true
  33850. }
  33851. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  33852. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  33853. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33854. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33855. if !m.op.Is(OpUpdateOne) {
  33856. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33857. }
  33858. if m.id == nil || m.oldValue == nil {
  33859. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33860. }
  33861. oldValue, err := m.oldValue(ctx)
  33862. if err != nil {
  33863. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33864. }
  33865. return oldValue.OrganizationID, nil
  33866. }
  33867. // AddOrganizationID adds u to the "organization_id" field.
  33868. func (m *TutorialMutation) AddOrganizationID(u int64) {
  33869. if m.addorganization_id != nil {
  33870. *m.addorganization_id += u
  33871. } else {
  33872. m.addorganization_id = &u
  33873. }
  33874. }
  33875. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33876. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  33877. v := m.addorganization_id
  33878. if v == nil {
  33879. return
  33880. }
  33881. return *v, true
  33882. }
  33883. // ResetOrganizationID resets all changes to the "organization_id" field.
  33884. func (m *TutorialMutation) ResetOrganizationID() {
  33885. m.organization_id = nil
  33886. m.addorganization_id = nil
  33887. }
  33888. // ClearEmployee clears the "employee" edge to the Employee entity.
  33889. func (m *TutorialMutation) ClearEmployee() {
  33890. m.clearedemployee = true
  33891. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  33892. }
  33893. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  33894. func (m *TutorialMutation) EmployeeCleared() bool {
  33895. return m.clearedemployee
  33896. }
  33897. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  33898. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33899. // EmployeeID instead. It exists only for internal usage by the builders.
  33900. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  33901. if id := m.employee; id != nil {
  33902. ids = append(ids, *id)
  33903. }
  33904. return
  33905. }
  33906. // ResetEmployee resets all changes to the "employee" edge.
  33907. func (m *TutorialMutation) ResetEmployee() {
  33908. m.employee = nil
  33909. m.clearedemployee = false
  33910. }
  33911. // Where appends a list predicates to the TutorialMutation builder.
  33912. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  33913. m.predicates = append(m.predicates, ps...)
  33914. }
  33915. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  33916. // users can use type-assertion to append predicates that do not depend on any generated package.
  33917. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  33918. p := make([]predicate.Tutorial, len(ps))
  33919. for i := range ps {
  33920. p[i] = ps[i]
  33921. }
  33922. m.Where(p...)
  33923. }
  33924. // Op returns the operation name.
  33925. func (m *TutorialMutation) Op() Op {
  33926. return m.op
  33927. }
  33928. // SetOp allows setting the mutation operation.
  33929. func (m *TutorialMutation) SetOp(op Op) {
  33930. m.op = op
  33931. }
  33932. // Type returns the node type of this mutation (Tutorial).
  33933. func (m *TutorialMutation) Type() string {
  33934. return m.typ
  33935. }
  33936. // Fields returns all fields that were changed during this mutation. Note that in
  33937. // order to get all numeric fields that were incremented/decremented, call
  33938. // AddedFields().
  33939. func (m *TutorialMutation) Fields() []string {
  33940. fields := make([]string, 0, 8)
  33941. if m.created_at != nil {
  33942. fields = append(fields, tutorial.FieldCreatedAt)
  33943. }
  33944. if m.updated_at != nil {
  33945. fields = append(fields, tutorial.FieldUpdatedAt)
  33946. }
  33947. if m.deleted_at != nil {
  33948. fields = append(fields, tutorial.FieldDeletedAt)
  33949. }
  33950. if m.employee != nil {
  33951. fields = append(fields, tutorial.FieldEmployeeID)
  33952. }
  33953. if m.index != nil {
  33954. fields = append(fields, tutorial.FieldIndex)
  33955. }
  33956. if m.title != nil {
  33957. fields = append(fields, tutorial.FieldTitle)
  33958. }
  33959. if m.content != nil {
  33960. fields = append(fields, tutorial.FieldContent)
  33961. }
  33962. if m.organization_id != nil {
  33963. fields = append(fields, tutorial.FieldOrganizationID)
  33964. }
  33965. return fields
  33966. }
  33967. // Field returns the value of a field with the given name. The second boolean
  33968. // return value indicates that this field was not set, or was not defined in the
  33969. // schema.
  33970. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  33971. switch name {
  33972. case tutorial.FieldCreatedAt:
  33973. return m.CreatedAt()
  33974. case tutorial.FieldUpdatedAt:
  33975. return m.UpdatedAt()
  33976. case tutorial.FieldDeletedAt:
  33977. return m.DeletedAt()
  33978. case tutorial.FieldEmployeeID:
  33979. return m.EmployeeID()
  33980. case tutorial.FieldIndex:
  33981. return m.Index()
  33982. case tutorial.FieldTitle:
  33983. return m.Title()
  33984. case tutorial.FieldContent:
  33985. return m.Content()
  33986. case tutorial.FieldOrganizationID:
  33987. return m.OrganizationID()
  33988. }
  33989. return nil, false
  33990. }
  33991. // OldField returns the old value of the field from the database. An error is
  33992. // returned if the mutation operation is not UpdateOne, or the query to the
  33993. // database failed.
  33994. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33995. switch name {
  33996. case tutorial.FieldCreatedAt:
  33997. return m.OldCreatedAt(ctx)
  33998. case tutorial.FieldUpdatedAt:
  33999. return m.OldUpdatedAt(ctx)
  34000. case tutorial.FieldDeletedAt:
  34001. return m.OldDeletedAt(ctx)
  34002. case tutorial.FieldEmployeeID:
  34003. return m.OldEmployeeID(ctx)
  34004. case tutorial.FieldIndex:
  34005. return m.OldIndex(ctx)
  34006. case tutorial.FieldTitle:
  34007. return m.OldTitle(ctx)
  34008. case tutorial.FieldContent:
  34009. return m.OldContent(ctx)
  34010. case tutorial.FieldOrganizationID:
  34011. return m.OldOrganizationID(ctx)
  34012. }
  34013. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  34014. }
  34015. // SetField sets the value of a field with the given name. It returns an error if
  34016. // the field is not defined in the schema, or if the type mismatched the field
  34017. // type.
  34018. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  34019. switch name {
  34020. case tutorial.FieldCreatedAt:
  34021. v, ok := value.(time.Time)
  34022. if !ok {
  34023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34024. }
  34025. m.SetCreatedAt(v)
  34026. return nil
  34027. case tutorial.FieldUpdatedAt:
  34028. v, ok := value.(time.Time)
  34029. if !ok {
  34030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34031. }
  34032. m.SetUpdatedAt(v)
  34033. return nil
  34034. case tutorial.FieldDeletedAt:
  34035. v, ok := value.(time.Time)
  34036. if !ok {
  34037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34038. }
  34039. m.SetDeletedAt(v)
  34040. return nil
  34041. case tutorial.FieldEmployeeID:
  34042. v, ok := value.(uint64)
  34043. if !ok {
  34044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34045. }
  34046. m.SetEmployeeID(v)
  34047. return nil
  34048. case tutorial.FieldIndex:
  34049. v, ok := value.(int)
  34050. if !ok {
  34051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34052. }
  34053. m.SetIndex(v)
  34054. return nil
  34055. case tutorial.FieldTitle:
  34056. v, ok := value.(string)
  34057. if !ok {
  34058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34059. }
  34060. m.SetTitle(v)
  34061. return nil
  34062. case tutorial.FieldContent:
  34063. v, ok := value.(string)
  34064. if !ok {
  34065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34066. }
  34067. m.SetContent(v)
  34068. return nil
  34069. case tutorial.FieldOrganizationID:
  34070. v, ok := value.(uint64)
  34071. if !ok {
  34072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34073. }
  34074. m.SetOrganizationID(v)
  34075. return nil
  34076. }
  34077. return fmt.Errorf("unknown Tutorial field %s", name)
  34078. }
  34079. // AddedFields returns all numeric fields that were incremented/decremented during
  34080. // this mutation.
  34081. func (m *TutorialMutation) AddedFields() []string {
  34082. var fields []string
  34083. if m.addindex != nil {
  34084. fields = append(fields, tutorial.FieldIndex)
  34085. }
  34086. if m.addorganization_id != nil {
  34087. fields = append(fields, tutorial.FieldOrganizationID)
  34088. }
  34089. return fields
  34090. }
  34091. // AddedField returns the numeric value that was incremented/decremented on a field
  34092. // with the given name. The second boolean return value indicates that this field
  34093. // was not set, or was not defined in the schema.
  34094. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  34095. switch name {
  34096. case tutorial.FieldIndex:
  34097. return m.AddedIndex()
  34098. case tutorial.FieldOrganizationID:
  34099. return m.AddedOrganizationID()
  34100. }
  34101. return nil, false
  34102. }
  34103. // AddField adds the value to the field with the given name. It returns an error if
  34104. // the field is not defined in the schema, or if the type mismatched the field
  34105. // type.
  34106. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  34107. switch name {
  34108. case tutorial.FieldIndex:
  34109. v, ok := value.(int)
  34110. if !ok {
  34111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34112. }
  34113. m.AddIndex(v)
  34114. return nil
  34115. case tutorial.FieldOrganizationID:
  34116. v, ok := value.(int64)
  34117. if !ok {
  34118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34119. }
  34120. m.AddOrganizationID(v)
  34121. return nil
  34122. }
  34123. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  34124. }
  34125. // ClearedFields returns all nullable fields that were cleared during this
  34126. // mutation.
  34127. func (m *TutorialMutation) ClearedFields() []string {
  34128. var fields []string
  34129. if m.FieldCleared(tutorial.FieldDeletedAt) {
  34130. fields = append(fields, tutorial.FieldDeletedAt)
  34131. }
  34132. return fields
  34133. }
  34134. // FieldCleared returns a boolean indicating if a field with the given name was
  34135. // cleared in this mutation.
  34136. func (m *TutorialMutation) FieldCleared(name string) bool {
  34137. _, ok := m.clearedFields[name]
  34138. return ok
  34139. }
  34140. // ClearField clears the value of the field with the given name. It returns an
  34141. // error if the field is not defined in the schema.
  34142. func (m *TutorialMutation) ClearField(name string) error {
  34143. switch name {
  34144. case tutorial.FieldDeletedAt:
  34145. m.ClearDeletedAt()
  34146. return nil
  34147. }
  34148. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  34149. }
  34150. // ResetField resets all changes in the mutation for the field with the given name.
  34151. // It returns an error if the field is not defined in the schema.
  34152. func (m *TutorialMutation) ResetField(name string) error {
  34153. switch name {
  34154. case tutorial.FieldCreatedAt:
  34155. m.ResetCreatedAt()
  34156. return nil
  34157. case tutorial.FieldUpdatedAt:
  34158. m.ResetUpdatedAt()
  34159. return nil
  34160. case tutorial.FieldDeletedAt:
  34161. m.ResetDeletedAt()
  34162. return nil
  34163. case tutorial.FieldEmployeeID:
  34164. m.ResetEmployeeID()
  34165. return nil
  34166. case tutorial.FieldIndex:
  34167. m.ResetIndex()
  34168. return nil
  34169. case tutorial.FieldTitle:
  34170. m.ResetTitle()
  34171. return nil
  34172. case tutorial.FieldContent:
  34173. m.ResetContent()
  34174. return nil
  34175. case tutorial.FieldOrganizationID:
  34176. m.ResetOrganizationID()
  34177. return nil
  34178. }
  34179. return fmt.Errorf("unknown Tutorial field %s", name)
  34180. }
  34181. // AddedEdges returns all edge names that were set/added in this mutation.
  34182. func (m *TutorialMutation) AddedEdges() []string {
  34183. edges := make([]string, 0, 1)
  34184. if m.employee != nil {
  34185. edges = append(edges, tutorial.EdgeEmployee)
  34186. }
  34187. return edges
  34188. }
  34189. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34190. // name in this mutation.
  34191. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  34192. switch name {
  34193. case tutorial.EdgeEmployee:
  34194. if id := m.employee; id != nil {
  34195. return []ent.Value{*id}
  34196. }
  34197. }
  34198. return nil
  34199. }
  34200. // RemovedEdges returns all edge names that were removed in this mutation.
  34201. func (m *TutorialMutation) RemovedEdges() []string {
  34202. edges := make([]string, 0, 1)
  34203. return edges
  34204. }
  34205. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34206. // the given name in this mutation.
  34207. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  34208. return nil
  34209. }
  34210. // ClearedEdges returns all edge names that were cleared in this mutation.
  34211. func (m *TutorialMutation) ClearedEdges() []string {
  34212. edges := make([]string, 0, 1)
  34213. if m.clearedemployee {
  34214. edges = append(edges, tutorial.EdgeEmployee)
  34215. }
  34216. return edges
  34217. }
  34218. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34219. // was cleared in this mutation.
  34220. func (m *TutorialMutation) EdgeCleared(name string) bool {
  34221. switch name {
  34222. case tutorial.EdgeEmployee:
  34223. return m.clearedemployee
  34224. }
  34225. return false
  34226. }
  34227. // ClearEdge clears the value of the edge with the given name. It returns an error
  34228. // if that edge is not defined in the schema.
  34229. func (m *TutorialMutation) ClearEdge(name string) error {
  34230. switch name {
  34231. case tutorial.EdgeEmployee:
  34232. m.ClearEmployee()
  34233. return nil
  34234. }
  34235. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  34236. }
  34237. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34238. // It returns an error if the edge is not defined in the schema.
  34239. func (m *TutorialMutation) ResetEdge(name string) error {
  34240. switch name {
  34241. case tutorial.EdgeEmployee:
  34242. m.ResetEmployee()
  34243. return nil
  34244. }
  34245. return fmt.Errorf("unknown Tutorial edge %s", name)
  34246. }
  34247. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  34248. type UsageDetailMutation struct {
  34249. config
  34250. op Op
  34251. typ string
  34252. id *uint64
  34253. created_at *time.Time
  34254. updated_at *time.Time
  34255. status *uint8
  34256. addstatus *int8
  34257. _type *int
  34258. add_type *int
  34259. bot_id *string
  34260. receiver_id *string
  34261. app *int
  34262. addapp *int
  34263. session_id *uint64
  34264. addsession_id *int64
  34265. request *string
  34266. response *string
  34267. original_data *custom_types.OriginalData
  34268. total_tokens *uint64
  34269. addtotal_tokens *int64
  34270. prompt_tokens *uint64
  34271. addprompt_tokens *int64
  34272. completion_tokens *uint64
  34273. addcompletion_tokens *int64
  34274. organization_id *uint64
  34275. addorganization_id *int64
  34276. model *string
  34277. credits *float64
  34278. addcredits *float64
  34279. clearedFields map[string]struct{}
  34280. done bool
  34281. oldValue func(context.Context) (*UsageDetail, error)
  34282. predicates []predicate.UsageDetail
  34283. }
  34284. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  34285. // usagedetailOption allows management of the mutation configuration using functional options.
  34286. type usagedetailOption func(*UsageDetailMutation)
  34287. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  34288. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  34289. m := &UsageDetailMutation{
  34290. config: c,
  34291. op: op,
  34292. typ: TypeUsageDetail,
  34293. clearedFields: make(map[string]struct{}),
  34294. }
  34295. for _, opt := range opts {
  34296. opt(m)
  34297. }
  34298. return m
  34299. }
  34300. // withUsageDetailID sets the ID field of the mutation.
  34301. func withUsageDetailID(id uint64) usagedetailOption {
  34302. return func(m *UsageDetailMutation) {
  34303. var (
  34304. err error
  34305. once sync.Once
  34306. value *UsageDetail
  34307. )
  34308. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  34309. once.Do(func() {
  34310. if m.done {
  34311. err = errors.New("querying old values post mutation is not allowed")
  34312. } else {
  34313. value, err = m.Client().UsageDetail.Get(ctx, id)
  34314. }
  34315. })
  34316. return value, err
  34317. }
  34318. m.id = &id
  34319. }
  34320. }
  34321. // withUsageDetail sets the old UsageDetail of the mutation.
  34322. func withUsageDetail(node *UsageDetail) usagedetailOption {
  34323. return func(m *UsageDetailMutation) {
  34324. m.oldValue = func(context.Context) (*UsageDetail, error) {
  34325. return node, nil
  34326. }
  34327. m.id = &node.ID
  34328. }
  34329. }
  34330. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34331. // executed in a transaction (ent.Tx), a transactional client is returned.
  34332. func (m UsageDetailMutation) Client() *Client {
  34333. client := &Client{config: m.config}
  34334. client.init()
  34335. return client
  34336. }
  34337. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34338. // it returns an error otherwise.
  34339. func (m UsageDetailMutation) Tx() (*Tx, error) {
  34340. if _, ok := m.driver.(*txDriver); !ok {
  34341. return nil, errors.New("ent: mutation is not running in a transaction")
  34342. }
  34343. tx := &Tx{config: m.config}
  34344. tx.init()
  34345. return tx, nil
  34346. }
  34347. // SetID sets the value of the id field. Note that this
  34348. // operation is only accepted on creation of UsageDetail entities.
  34349. func (m *UsageDetailMutation) SetID(id uint64) {
  34350. m.id = &id
  34351. }
  34352. // ID returns the ID value in the mutation. Note that the ID is only available
  34353. // if it was provided to the builder or after it was returned from the database.
  34354. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  34355. if m.id == nil {
  34356. return
  34357. }
  34358. return *m.id, true
  34359. }
  34360. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34361. // That means, if the mutation is applied within a transaction with an isolation level such
  34362. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34363. // or updated by the mutation.
  34364. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  34365. switch {
  34366. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34367. id, exists := m.ID()
  34368. if exists {
  34369. return []uint64{id}, nil
  34370. }
  34371. fallthrough
  34372. case m.op.Is(OpUpdate | OpDelete):
  34373. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  34374. default:
  34375. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34376. }
  34377. }
  34378. // SetCreatedAt sets the "created_at" field.
  34379. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  34380. m.created_at = &t
  34381. }
  34382. // CreatedAt returns the value of the "created_at" field in the mutation.
  34383. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  34384. v := m.created_at
  34385. if v == nil {
  34386. return
  34387. }
  34388. return *v, true
  34389. }
  34390. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  34391. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34393. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34394. if !m.op.Is(OpUpdateOne) {
  34395. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34396. }
  34397. if m.id == nil || m.oldValue == nil {
  34398. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34399. }
  34400. oldValue, err := m.oldValue(ctx)
  34401. if err != nil {
  34402. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34403. }
  34404. return oldValue.CreatedAt, nil
  34405. }
  34406. // ResetCreatedAt resets all changes to the "created_at" field.
  34407. func (m *UsageDetailMutation) ResetCreatedAt() {
  34408. m.created_at = nil
  34409. }
  34410. // SetUpdatedAt sets the "updated_at" field.
  34411. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  34412. m.updated_at = &t
  34413. }
  34414. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34415. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  34416. v := m.updated_at
  34417. if v == nil {
  34418. return
  34419. }
  34420. return *v, true
  34421. }
  34422. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  34423. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34425. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34426. if !m.op.Is(OpUpdateOne) {
  34427. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34428. }
  34429. if m.id == nil || m.oldValue == nil {
  34430. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34431. }
  34432. oldValue, err := m.oldValue(ctx)
  34433. if err != nil {
  34434. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34435. }
  34436. return oldValue.UpdatedAt, nil
  34437. }
  34438. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34439. func (m *UsageDetailMutation) ResetUpdatedAt() {
  34440. m.updated_at = nil
  34441. }
  34442. // SetStatus sets the "status" field.
  34443. func (m *UsageDetailMutation) SetStatus(u uint8) {
  34444. m.status = &u
  34445. m.addstatus = nil
  34446. }
  34447. // Status returns the value of the "status" field in the mutation.
  34448. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  34449. v := m.status
  34450. if v == nil {
  34451. return
  34452. }
  34453. return *v, true
  34454. }
  34455. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  34456. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34458. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34459. if !m.op.Is(OpUpdateOne) {
  34460. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34461. }
  34462. if m.id == nil || m.oldValue == nil {
  34463. return v, errors.New("OldStatus requires an ID field in the mutation")
  34464. }
  34465. oldValue, err := m.oldValue(ctx)
  34466. if err != nil {
  34467. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34468. }
  34469. return oldValue.Status, nil
  34470. }
  34471. // AddStatus adds u to the "status" field.
  34472. func (m *UsageDetailMutation) AddStatus(u int8) {
  34473. if m.addstatus != nil {
  34474. *m.addstatus += u
  34475. } else {
  34476. m.addstatus = &u
  34477. }
  34478. }
  34479. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34480. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  34481. v := m.addstatus
  34482. if v == nil {
  34483. return
  34484. }
  34485. return *v, true
  34486. }
  34487. // ClearStatus clears the value of the "status" field.
  34488. func (m *UsageDetailMutation) ClearStatus() {
  34489. m.status = nil
  34490. m.addstatus = nil
  34491. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  34492. }
  34493. // StatusCleared returns if the "status" field was cleared in this mutation.
  34494. func (m *UsageDetailMutation) StatusCleared() bool {
  34495. _, ok := m.clearedFields[usagedetail.FieldStatus]
  34496. return ok
  34497. }
  34498. // ResetStatus resets all changes to the "status" field.
  34499. func (m *UsageDetailMutation) ResetStatus() {
  34500. m.status = nil
  34501. m.addstatus = nil
  34502. delete(m.clearedFields, usagedetail.FieldStatus)
  34503. }
  34504. // SetType sets the "type" field.
  34505. func (m *UsageDetailMutation) SetType(i int) {
  34506. m._type = &i
  34507. m.add_type = nil
  34508. }
  34509. // GetType returns the value of the "type" field in the mutation.
  34510. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  34511. v := m._type
  34512. if v == nil {
  34513. return
  34514. }
  34515. return *v, true
  34516. }
  34517. // OldType returns the old "type" field's value of the UsageDetail entity.
  34518. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34520. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  34521. if !m.op.Is(OpUpdateOne) {
  34522. return v, errors.New("OldType is only allowed on UpdateOne operations")
  34523. }
  34524. if m.id == nil || m.oldValue == nil {
  34525. return v, errors.New("OldType requires an ID field in the mutation")
  34526. }
  34527. oldValue, err := m.oldValue(ctx)
  34528. if err != nil {
  34529. return v, fmt.Errorf("querying old value for OldType: %w", err)
  34530. }
  34531. return oldValue.Type, nil
  34532. }
  34533. // AddType adds i to the "type" field.
  34534. func (m *UsageDetailMutation) AddType(i int) {
  34535. if m.add_type != nil {
  34536. *m.add_type += i
  34537. } else {
  34538. m.add_type = &i
  34539. }
  34540. }
  34541. // AddedType returns the value that was added to the "type" field in this mutation.
  34542. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  34543. v := m.add_type
  34544. if v == nil {
  34545. return
  34546. }
  34547. return *v, true
  34548. }
  34549. // ClearType clears the value of the "type" field.
  34550. func (m *UsageDetailMutation) ClearType() {
  34551. m._type = nil
  34552. m.add_type = nil
  34553. m.clearedFields[usagedetail.FieldType] = struct{}{}
  34554. }
  34555. // TypeCleared returns if the "type" field was cleared in this mutation.
  34556. func (m *UsageDetailMutation) TypeCleared() bool {
  34557. _, ok := m.clearedFields[usagedetail.FieldType]
  34558. return ok
  34559. }
  34560. // ResetType resets all changes to the "type" field.
  34561. func (m *UsageDetailMutation) ResetType() {
  34562. m._type = nil
  34563. m.add_type = nil
  34564. delete(m.clearedFields, usagedetail.FieldType)
  34565. }
  34566. // SetBotID sets the "bot_id" field.
  34567. func (m *UsageDetailMutation) SetBotID(s string) {
  34568. m.bot_id = &s
  34569. }
  34570. // BotID returns the value of the "bot_id" field in the mutation.
  34571. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  34572. v := m.bot_id
  34573. if v == nil {
  34574. return
  34575. }
  34576. return *v, true
  34577. }
  34578. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  34579. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34581. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  34582. if !m.op.Is(OpUpdateOne) {
  34583. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  34584. }
  34585. if m.id == nil || m.oldValue == nil {
  34586. return v, errors.New("OldBotID requires an ID field in the mutation")
  34587. }
  34588. oldValue, err := m.oldValue(ctx)
  34589. if err != nil {
  34590. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  34591. }
  34592. return oldValue.BotID, nil
  34593. }
  34594. // ResetBotID resets all changes to the "bot_id" field.
  34595. func (m *UsageDetailMutation) ResetBotID() {
  34596. m.bot_id = nil
  34597. }
  34598. // SetReceiverID sets the "receiver_id" field.
  34599. func (m *UsageDetailMutation) SetReceiverID(s string) {
  34600. m.receiver_id = &s
  34601. }
  34602. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  34603. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  34604. v := m.receiver_id
  34605. if v == nil {
  34606. return
  34607. }
  34608. return *v, true
  34609. }
  34610. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  34611. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34612. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34613. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  34614. if !m.op.Is(OpUpdateOne) {
  34615. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  34616. }
  34617. if m.id == nil || m.oldValue == nil {
  34618. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  34619. }
  34620. oldValue, err := m.oldValue(ctx)
  34621. if err != nil {
  34622. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  34623. }
  34624. return oldValue.ReceiverID, nil
  34625. }
  34626. // ResetReceiverID resets all changes to the "receiver_id" field.
  34627. func (m *UsageDetailMutation) ResetReceiverID() {
  34628. m.receiver_id = nil
  34629. }
  34630. // SetApp sets the "app" field.
  34631. func (m *UsageDetailMutation) SetApp(i int) {
  34632. m.app = &i
  34633. m.addapp = nil
  34634. }
  34635. // App returns the value of the "app" field in the mutation.
  34636. func (m *UsageDetailMutation) App() (r int, exists bool) {
  34637. v := m.app
  34638. if v == nil {
  34639. return
  34640. }
  34641. return *v, true
  34642. }
  34643. // OldApp returns the old "app" field's value of the UsageDetail entity.
  34644. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34646. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  34647. if !m.op.Is(OpUpdateOne) {
  34648. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  34649. }
  34650. if m.id == nil || m.oldValue == nil {
  34651. return v, errors.New("OldApp requires an ID field in the mutation")
  34652. }
  34653. oldValue, err := m.oldValue(ctx)
  34654. if err != nil {
  34655. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  34656. }
  34657. return oldValue.App, nil
  34658. }
  34659. // AddApp adds i to the "app" field.
  34660. func (m *UsageDetailMutation) AddApp(i int) {
  34661. if m.addapp != nil {
  34662. *m.addapp += i
  34663. } else {
  34664. m.addapp = &i
  34665. }
  34666. }
  34667. // AddedApp returns the value that was added to the "app" field in this mutation.
  34668. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  34669. v := m.addapp
  34670. if v == nil {
  34671. return
  34672. }
  34673. return *v, true
  34674. }
  34675. // ClearApp clears the value of the "app" field.
  34676. func (m *UsageDetailMutation) ClearApp() {
  34677. m.app = nil
  34678. m.addapp = nil
  34679. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  34680. }
  34681. // AppCleared returns if the "app" field was cleared in this mutation.
  34682. func (m *UsageDetailMutation) AppCleared() bool {
  34683. _, ok := m.clearedFields[usagedetail.FieldApp]
  34684. return ok
  34685. }
  34686. // ResetApp resets all changes to the "app" field.
  34687. func (m *UsageDetailMutation) ResetApp() {
  34688. m.app = nil
  34689. m.addapp = nil
  34690. delete(m.clearedFields, usagedetail.FieldApp)
  34691. }
  34692. // SetSessionID sets the "session_id" field.
  34693. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  34694. m.session_id = &u
  34695. m.addsession_id = nil
  34696. }
  34697. // SessionID returns the value of the "session_id" field in the mutation.
  34698. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  34699. v := m.session_id
  34700. if v == nil {
  34701. return
  34702. }
  34703. return *v, true
  34704. }
  34705. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  34706. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34708. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  34709. if !m.op.Is(OpUpdateOne) {
  34710. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  34711. }
  34712. if m.id == nil || m.oldValue == nil {
  34713. return v, errors.New("OldSessionID requires an ID field in the mutation")
  34714. }
  34715. oldValue, err := m.oldValue(ctx)
  34716. if err != nil {
  34717. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  34718. }
  34719. return oldValue.SessionID, nil
  34720. }
  34721. // AddSessionID adds u to the "session_id" field.
  34722. func (m *UsageDetailMutation) AddSessionID(u int64) {
  34723. if m.addsession_id != nil {
  34724. *m.addsession_id += u
  34725. } else {
  34726. m.addsession_id = &u
  34727. }
  34728. }
  34729. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  34730. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  34731. v := m.addsession_id
  34732. if v == nil {
  34733. return
  34734. }
  34735. return *v, true
  34736. }
  34737. // ClearSessionID clears the value of the "session_id" field.
  34738. func (m *UsageDetailMutation) ClearSessionID() {
  34739. m.session_id = nil
  34740. m.addsession_id = nil
  34741. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  34742. }
  34743. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  34744. func (m *UsageDetailMutation) SessionIDCleared() bool {
  34745. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  34746. return ok
  34747. }
  34748. // ResetSessionID resets all changes to the "session_id" field.
  34749. func (m *UsageDetailMutation) ResetSessionID() {
  34750. m.session_id = nil
  34751. m.addsession_id = nil
  34752. delete(m.clearedFields, usagedetail.FieldSessionID)
  34753. }
  34754. // SetRequest sets the "request" field.
  34755. func (m *UsageDetailMutation) SetRequest(s string) {
  34756. m.request = &s
  34757. }
  34758. // Request returns the value of the "request" field in the mutation.
  34759. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  34760. v := m.request
  34761. if v == nil {
  34762. return
  34763. }
  34764. return *v, true
  34765. }
  34766. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  34767. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34769. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  34770. if !m.op.Is(OpUpdateOne) {
  34771. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  34772. }
  34773. if m.id == nil || m.oldValue == nil {
  34774. return v, errors.New("OldRequest requires an ID field in the mutation")
  34775. }
  34776. oldValue, err := m.oldValue(ctx)
  34777. if err != nil {
  34778. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  34779. }
  34780. return oldValue.Request, nil
  34781. }
  34782. // ResetRequest resets all changes to the "request" field.
  34783. func (m *UsageDetailMutation) ResetRequest() {
  34784. m.request = nil
  34785. }
  34786. // SetResponse sets the "response" field.
  34787. func (m *UsageDetailMutation) SetResponse(s string) {
  34788. m.response = &s
  34789. }
  34790. // Response returns the value of the "response" field in the mutation.
  34791. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  34792. v := m.response
  34793. if v == nil {
  34794. return
  34795. }
  34796. return *v, true
  34797. }
  34798. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  34799. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34801. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  34802. if !m.op.Is(OpUpdateOne) {
  34803. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  34804. }
  34805. if m.id == nil || m.oldValue == nil {
  34806. return v, errors.New("OldResponse requires an ID field in the mutation")
  34807. }
  34808. oldValue, err := m.oldValue(ctx)
  34809. if err != nil {
  34810. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  34811. }
  34812. return oldValue.Response, nil
  34813. }
  34814. // ResetResponse resets all changes to the "response" field.
  34815. func (m *UsageDetailMutation) ResetResponse() {
  34816. m.response = nil
  34817. }
  34818. // SetOriginalData sets the "original_data" field.
  34819. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  34820. m.original_data = &ctd
  34821. }
  34822. // OriginalData returns the value of the "original_data" field in the mutation.
  34823. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  34824. v := m.original_data
  34825. if v == nil {
  34826. return
  34827. }
  34828. return *v, true
  34829. }
  34830. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  34831. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34833. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  34834. if !m.op.Is(OpUpdateOne) {
  34835. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  34836. }
  34837. if m.id == nil || m.oldValue == nil {
  34838. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  34839. }
  34840. oldValue, err := m.oldValue(ctx)
  34841. if err != nil {
  34842. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  34843. }
  34844. return oldValue.OriginalData, nil
  34845. }
  34846. // ResetOriginalData resets all changes to the "original_data" field.
  34847. func (m *UsageDetailMutation) ResetOriginalData() {
  34848. m.original_data = nil
  34849. }
  34850. // SetTotalTokens sets the "total_tokens" field.
  34851. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  34852. m.total_tokens = &u
  34853. m.addtotal_tokens = nil
  34854. }
  34855. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  34856. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  34857. v := m.total_tokens
  34858. if v == nil {
  34859. return
  34860. }
  34861. return *v, true
  34862. }
  34863. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  34864. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34866. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  34867. if !m.op.Is(OpUpdateOne) {
  34868. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  34869. }
  34870. if m.id == nil || m.oldValue == nil {
  34871. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  34872. }
  34873. oldValue, err := m.oldValue(ctx)
  34874. if err != nil {
  34875. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  34876. }
  34877. return oldValue.TotalTokens, nil
  34878. }
  34879. // AddTotalTokens adds u to the "total_tokens" field.
  34880. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  34881. if m.addtotal_tokens != nil {
  34882. *m.addtotal_tokens += u
  34883. } else {
  34884. m.addtotal_tokens = &u
  34885. }
  34886. }
  34887. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  34888. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  34889. v := m.addtotal_tokens
  34890. if v == nil {
  34891. return
  34892. }
  34893. return *v, true
  34894. }
  34895. // ClearTotalTokens clears the value of the "total_tokens" field.
  34896. func (m *UsageDetailMutation) ClearTotalTokens() {
  34897. m.total_tokens = nil
  34898. m.addtotal_tokens = nil
  34899. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  34900. }
  34901. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  34902. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  34903. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  34904. return ok
  34905. }
  34906. // ResetTotalTokens resets all changes to the "total_tokens" field.
  34907. func (m *UsageDetailMutation) ResetTotalTokens() {
  34908. m.total_tokens = nil
  34909. m.addtotal_tokens = nil
  34910. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  34911. }
  34912. // SetPromptTokens sets the "prompt_tokens" field.
  34913. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  34914. m.prompt_tokens = &u
  34915. m.addprompt_tokens = nil
  34916. }
  34917. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  34918. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  34919. v := m.prompt_tokens
  34920. if v == nil {
  34921. return
  34922. }
  34923. return *v, true
  34924. }
  34925. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  34926. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34928. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  34929. if !m.op.Is(OpUpdateOne) {
  34930. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  34931. }
  34932. if m.id == nil || m.oldValue == nil {
  34933. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  34934. }
  34935. oldValue, err := m.oldValue(ctx)
  34936. if err != nil {
  34937. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  34938. }
  34939. return oldValue.PromptTokens, nil
  34940. }
  34941. // AddPromptTokens adds u to the "prompt_tokens" field.
  34942. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  34943. if m.addprompt_tokens != nil {
  34944. *m.addprompt_tokens += u
  34945. } else {
  34946. m.addprompt_tokens = &u
  34947. }
  34948. }
  34949. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  34950. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  34951. v := m.addprompt_tokens
  34952. if v == nil {
  34953. return
  34954. }
  34955. return *v, true
  34956. }
  34957. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  34958. func (m *UsageDetailMutation) ClearPromptTokens() {
  34959. m.prompt_tokens = nil
  34960. m.addprompt_tokens = nil
  34961. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  34962. }
  34963. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  34964. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  34965. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  34966. return ok
  34967. }
  34968. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  34969. func (m *UsageDetailMutation) ResetPromptTokens() {
  34970. m.prompt_tokens = nil
  34971. m.addprompt_tokens = nil
  34972. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  34973. }
  34974. // SetCompletionTokens sets the "completion_tokens" field.
  34975. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  34976. m.completion_tokens = &u
  34977. m.addcompletion_tokens = nil
  34978. }
  34979. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  34980. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  34981. v := m.completion_tokens
  34982. if v == nil {
  34983. return
  34984. }
  34985. return *v, true
  34986. }
  34987. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  34988. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  34989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34990. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  34991. if !m.op.Is(OpUpdateOne) {
  34992. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  34993. }
  34994. if m.id == nil || m.oldValue == nil {
  34995. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  34996. }
  34997. oldValue, err := m.oldValue(ctx)
  34998. if err != nil {
  34999. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  35000. }
  35001. return oldValue.CompletionTokens, nil
  35002. }
  35003. // AddCompletionTokens adds u to the "completion_tokens" field.
  35004. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  35005. if m.addcompletion_tokens != nil {
  35006. *m.addcompletion_tokens += u
  35007. } else {
  35008. m.addcompletion_tokens = &u
  35009. }
  35010. }
  35011. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  35012. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  35013. v := m.addcompletion_tokens
  35014. if v == nil {
  35015. return
  35016. }
  35017. return *v, true
  35018. }
  35019. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  35020. func (m *UsageDetailMutation) ClearCompletionTokens() {
  35021. m.completion_tokens = nil
  35022. m.addcompletion_tokens = nil
  35023. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  35024. }
  35025. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  35026. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  35027. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  35028. return ok
  35029. }
  35030. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  35031. func (m *UsageDetailMutation) ResetCompletionTokens() {
  35032. m.completion_tokens = nil
  35033. m.addcompletion_tokens = nil
  35034. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  35035. }
  35036. // SetOrganizationID sets the "organization_id" field.
  35037. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  35038. m.organization_id = &u
  35039. m.addorganization_id = nil
  35040. }
  35041. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35042. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  35043. v := m.organization_id
  35044. if v == nil {
  35045. return
  35046. }
  35047. return *v, true
  35048. }
  35049. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  35050. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35052. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35053. if !m.op.Is(OpUpdateOne) {
  35054. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35055. }
  35056. if m.id == nil || m.oldValue == nil {
  35057. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35058. }
  35059. oldValue, err := m.oldValue(ctx)
  35060. if err != nil {
  35061. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35062. }
  35063. return oldValue.OrganizationID, nil
  35064. }
  35065. // AddOrganizationID adds u to the "organization_id" field.
  35066. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  35067. if m.addorganization_id != nil {
  35068. *m.addorganization_id += u
  35069. } else {
  35070. m.addorganization_id = &u
  35071. }
  35072. }
  35073. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35074. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  35075. v := m.addorganization_id
  35076. if v == nil {
  35077. return
  35078. }
  35079. return *v, true
  35080. }
  35081. // ClearOrganizationID clears the value of the "organization_id" field.
  35082. func (m *UsageDetailMutation) ClearOrganizationID() {
  35083. m.organization_id = nil
  35084. m.addorganization_id = nil
  35085. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  35086. }
  35087. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35088. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  35089. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  35090. return ok
  35091. }
  35092. // ResetOrganizationID resets all changes to the "organization_id" field.
  35093. func (m *UsageDetailMutation) ResetOrganizationID() {
  35094. m.organization_id = nil
  35095. m.addorganization_id = nil
  35096. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  35097. }
  35098. // SetModel sets the "model" field.
  35099. func (m *UsageDetailMutation) SetModel(s string) {
  35100. m.model = &s
  35101. }
  35102. // Model returns the value of the "model" field in the mutation.
  35103. func (m *UsageDetailMutation) Model() (r string, exists bool) {
  35104. v := m.model
  35105. if v == nil {
  35106. return
  35107. }
  35108. return *v, true
  35109. }
  35110. // OldModel returns the old "model" field's value of the UsageDetail entity.
  35111. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35113. func (m *UsageDetailMutation) OldModel(ctx context.Context) (v string, err error) {
  35114. if !m.op.Is(OpUpdateOne) {
  35115. return v, errors.New("OldModel is only allowed on UpdateOne operations")
  35116. }
  35117. if m.id == nil || m.oldValue == nil {
  35118. return v, errors.New("OldModel requires an ID field in the mutation")
  35119. }
  35120. oldValue, err := m.oldValue(ctx)
  35121. if err != nil {
  35122. return v, fmt.Errorf("querying old value for OldModel: %w", err)
  35123. }
  35124. return oldValue.Model, nil
  35125. }
  35126. // ClearModel clears the value of the "model" field.
  35127. func (m *UsageDetailMutation) ClearModel() {
  35128. m.model = nil
  35129. m.clearedFields[usagedetail.FieldModel] = struct{}{}
  35130. }
  35131. // ModelCleared returns if the "model" field was cleared in this mutation.
  35132. func (m *UsageDetailMutation) ModelCleared() bool {
  35133. _, ok := m.clearedFields[usagedetail.FieldModel]
  35134. return ok
  35135. }
  35136. // ResetModel resets all changes to the "model" field.
  35137. func (m *UsageDetailMutation) ResetModel() {
  35138. m.model = nil
  35139. delete(m.clearedFields, usagedetail.FieldModel)
  35140. }
  35141. // SetCredits sets the "credits" field.
  35142. func (m *UsageDetailMutation) SetCredits(f float64) {
  35143. m.credits = &f
  35144. m.addcredits = nil
  35145. }
  35146. // Credits returns the value of the "credits" field in the mutation.
  35147. func (m *UsageDetailMutation) Credits() (r float64, exists bool) {
  35148. v := m.credits
  35149. if v == nil {
  35150. return
  35151. }
  35152. return *v, true
  35153. }
  35154. // OldCredits returns the old "credits" field's value of the UsageDetail entity.
  35155. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  35156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35157. func (m *UsageDetailMutation) OldCredits(ctx context.Context) (v float64, err error) {
  35158. if !m.op.Is(OpUpdateOne) {
  35159. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  35160. }
  35161. if m.id == nil || m.oldValue == nil {
  35162. return v, errors.New("OldCredits requires an ID field in the mutation")
  35163. }
  35164. oldValue, err := m.oldValue(ctx)
  35165. if err != nil {
  35166. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  35167. }
  35168. return oldValue.Credits, nil
  35169. }
  35170. // AddCredits adds f to the "credits" field.
  35171. func (m *UsageDetailMutation) AddCredits(f float64) {
  35172. if m.addcredits != nil {
  35173. *m.addcredits += f
  35174. } else {
  35175. m.addcredits = &f
  35176. }
  35177. }
  35178. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  35179. func (m *UsageDetailMutation) AddedCredits() (r float64, exists bool) {
  35180. v := m.addcredits
  35181. if v == nil {
  35182. return
  35183. }
  35184. return *v, true
  35185. }
  35186. // ClearCredits clears the value of the "credits" field.
  35187. func (m *UsageDetailMutation) ClearCredits() {
  35188. m.credits = nil
  35189. m.addcredits = nil
  35190. m.clearedFields[usagedetail.FieldCredits] = struct{}{}
  35191. }
  35192. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  35193. func (m *UsageDetailMutation) CreditsCleared() bool {
  35194. _, ok := m.clearedFields[usagedetail.FieldCredits]
  35195. return ok
  35196. }
  35197. // ResetCredits resets all changes to the "credits" field.
  35198. func (m *UsageDetailMutation) ResetCredits() {
  35199. m.credits = nil
  35200. m.addcredits = nil
  35201. delete(m.clearedFields, usagedetail.FieldCredits)
  35202. }
  35203. // Where appends a list predicates to the UsageDetailMutation builder.
  35204. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  35205. m.predicates = append(m.predicates, ps...)
  35206. }
  35207. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  35208. // users can use type-assertion to append predicates that do not depend on any generated package.
  35209. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  35210. p := make([]predicate.UsageDetail, len(ps))
  35211. for i := range ps {
  35212. p[i] = ps[i]
  35213. }
  35214. m.Where(p...)
  35215. }
  35216. // Op returns the operation name.
  35217. func (m *UsageDetailMutation) Op() Op {
  35218. return m.op
  35219. }
  35220. // SetOp allows setting the mutation operation.
  35221. func (m *UsageDetailMutation) SetOp(op Op) {
  35222. m.op = op
  35223. }
  35224. // Type returns the node type of this mutation (UsageDetail).
  35225. func (m *UsageDetailMutation) Type() string {
  35226. return m.typ
  35227. }
  35228. // Fields returns all fields that were changed during this mutation. Note that in
  35229. // order to get all numeric fields that were incremented/decremented, call
  35230. // AddedFields().
  35231. func (m *UsageDetailMutation) Fields() []string {
  35232. fields := make([]string, 0, 17)
  35233. if m.created_at != nil {
  35234. fields = append(fields, usagedetail.FieldCreatedAt)
  35235. }
  35236. if m.updated_at != nil {
  35237. fields = append(fields, usagedetail.FieldUpdatedAt)
  35238. }
  35239. if m.status != nil {
  35240. fields = append(fields, usagedetail.FieldStatus)
  35241. }
  35242. if m._type != nil {
  35243. fields = append(fields, usagedetail.FieldType)
  35244. }
  35245. if m.bot_id != nil {
  35246. fields = append(fields, usagedetail.FieldBotID)
  35247. }
  35248. if m.receiver_id != nil {
  35249. fields = append(fields, usagedetail.FieldReceiverID)
  35250. }
  35251. if m.app != nil {
  35252. fields = append(fields, usagedetail.FieldApp)
  35253. }
  35254. if m.session_id != nil {
  35255. fields = append(fields, usagedetail.FieldSessionID)
  35256. }
  35257. if m.request != nil {
  35258. fields = append(fields, usagedetail.FieldRequest)
  35259. }
  35260. if m.response != nil {
  35261. fields = append(fields, usagedetail.FieldResponse)
  35262. }
  35263. if m.original_data != nil {
  35264. fields = append(fields, usagedetail.FieldOriginalData)
  35265. }
  35266. if m.total_tokens != nil {
  35267. fields = append(fields, usagedetail.FieldTotalTokens)
  35268. }
  35269. if m.prompt_tokens != nil {
  35270. fields = append(fields, usagedetail.FieldPromptTokens)
  35271. }
  35272. if m.completion_tokens != nil {
  35273. fields = append(fields, usagedetail.FieldCompletionTokens)
  35274. }
  35275. if m.organization_id != nil {
  35276. fields = append(fields, usagedetail.FieldOrganizationID)
  35277. }
  35278. if m.model != nil {
  35279. fields = append(fields, usagedetail.FieldModel)
  35280. }
  35281. if m.credits != nil {
  35282. fields = append(fields, usagedetail.FieldCredits)
  35283. }
  35284. return fields
  35285. }
  35286. // Field returns the value of a field with the given name. The second boolean
  35287. // return value indicates that this field was not set, or was not defined in the
  35288. // schema.
  35289. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  35290. switch name {
  35291. case usagedetail.FieldCreatedAt:
  35292. return m.CreatedAt()
  35293. case usagedetail.FieldUpdatedAt:
  35294. return m.UpdatedAt()
  35295. case usagedetail.FieldStatus:
  35296. return m.Status()
  35297. case usagedetail.FieldType:
  35298. return m.GetType()
  35299. case usagedetail.FieldBotID:
  35300. return m.BotID()
  35301. case usagedetail.FieldReceiverID:
  35302. return m.ReceiverID()
  35303. case usagedetail.FieldApp:
  35304. return m.App()
  35305. case usagedetail.FieldSessionID:
  35306. return m.SessionID()
  35307. case usagedetail.FieldRequest:
  35308. return m.Request()
  35309. case usagedetail.FieldResponse:
  35310. return m.Response()
  35311. case usagedetail.FieldOriginalData:
  35312. return m.OriginalData()
  35313. case usagedetail.FieldTotalTokens:
  35314. return m.TotalTokens()
  35315. case usagedetail.FieldPromptTokens:
  35316. return m.PromptTokens()
  35317. case usagedetail.FieldCompletionTokens:
  35318. return m.CompletionTokens()
  35319. case usagedetail.FieldOrganizationID:
  35320. return m.OrganizationID()
  35321. case usagedetail.FieldModel:
  35322. return m.Model()
  35323. case usagedetail.FieldCredits:
  35324. return m.Credits()
  35325. }
  35326. return nil, false
  35327. }
  35328. // OldField returns the old value of the field from the database. An error is
  35329. // returned if the mutation operation is not UpdateOne, or the query to the
  35330. // database failed.
  35331. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35332. switch name {
  35333. case usagedetail.FieldCreatedAt:
  35334. return m.OldCreatedAt(ctx)
  35335. case usagedetail.FieldUpdatedAt:
  35336. return m.OldUpdatedAt(ctx)
  35337. case usagedetail.FieldStatus:
  35338. return m.OldStatus(ctx)
  35339. case usagedetail.FieldType:
  35340. return m.OldType(ctx)
  35341. case usagedetail.FieldBotID:
  35342. return m.OldBotID(ctx)
  35343. case usagedetail.FieldReceiverID:
  35344. return m.OldReceiverID(ctx)
  35345. case usagedetail.FieldApp:
  35346. return m.OldApp(ctx)
  35347. case usagedetail.FieldSessionID:
  35348. return m.OldSessionID(ctx)
  35349. case usagedetail.FieldRequest:
  35350. return m.OldRequest(ctx)
  35351. case usagedetail.FieldResponse:
  35352. return m.OldResponse(ctx)
  35353. case usagedetail.FieldOriginalData:
  35354. return m.OldOriginalData(ctx)
  35355. case usagedetail.FieldTotalTokens:
  35356. return m.OldTotalTokens(ctx)
  35357. case usagedetail.FieldPromptTokens:
  35358. return m.OldPromptTokens(ctx)
  35359. case usagedetail.FieldCompletionTokens:
  35360. return m.OldCompletionTokens(ctx)
  35361. case usagedetail.FieldOrganizationID:
  35362. return m.OldOrganizationID(ctx)
  35363. case usagedetail.FieldModel:
  35364. return m.OldModel(ctx)
  35365. case usagedetail.FieldCredits:
  35366. return m.OldCredits(ctx)
  35367. }
  35368. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  35369. }
  35370. // SetField sets the value of a field with the given name. It returns an error if
  35371. // the field is not defined in the schema, or if the type mismatched the field
  35372. // type.
  35373. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  35374. switch name {
  35375. case usagedetail.FieldCreatedAt:
  35376. v, ok := value.(time.Time)
  35377. if !ok {
  35378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35379. }
  35380. m.SetCreatedAt(v)
  35381. return nil
  35382. case usagedetail.FieldUpdatedAt:
  35383. v, ok := value.(time.Time)
  35384. if !ok {
  35385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35386. }
  35387. m.SetUpdatedAt(v)
  35388. return nil
  35389. case usagedetail.FieldStatus:
  35390. v, ok := value.(uint8)
  35391. if !ok {
  35392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35393. }
  35394. m.SetStatus(v)
  35395. return nil
  35396. case usagedetail.FieldType:
  35397. v, ok := value.(int)
  35398. if !ok {
  35399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35400. }
  35401. m.SetType(v)
  35402. return nil
  35403. case usagedetail.FieldBotID:
  35404. v, ok := value.(string)
  35405. if !ok {
  35406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35407. }
  35408. m.SetBotID(v)
  35409. return nil
  35410. case usagedetail.FieldReceiverID:
  35411. v, ok := value.(string)
  35412. if !ok {
  35413. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35414. }
  35415. m.SetReceiverID(v)
  35416. return nil
  35417. case usagedetail.FieldApp:
  35418. v, ok := value.(int)
  35419. if !ok {
  35420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35421. }
  35422. m.SetApp(v)
  35423. return nil
  35424. case usagedetail.FieldSessionID:
  35425. v, ok := value.(uint64)
  35426. if !ok {
  35427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35428. }
  35429. m.SetSessionID(v)
  35430. return nil
  35431. case usagedetail.FieldRequest:
  35432. v, ok := value.(string)
  35433. if !ok {
  35434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35435. }
  35436. m.SetRequest(v)
  35437. return nil
  35438. case usagedetail.FieldResponse:
  35439. v, ok := value.(string)
  35440. if !ok {
  35441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35442. }
  35443. m.SetResponse(v)
  35444. return nil
  35445. case usagedetail.FieldOriginalData:
  35446. v, ok := value.(custom_types.OriginalData)
  35447. if !ok {
  35448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35449. }
  35450. m.SetOriginalData(v)
  35451. return nil
  35452. case usagedetail.FieldTotalTokens:
  35453. v, ok := value.(uint64)
  35454. if !ok {
  35455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35456. }
  35457. m.SetTotalTokens(v)
  35458. return nil
  35459. case usagedetail.FieldPromptTokens:
  35460. v, ok := value.(uint64)
  35461. if !ok {
  35462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35463. }
  35464. m.SetPromptTokens(v)
  35465. return nil
  35466. case usagedetail.FieldCompletionTokens:
  35467. v, ok := value.(uint64)
  35468. if !ok {
  35469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35470. }
  35471. m.SetCompletionTokens(v)
  35472. return nil
  35473. case usagedetail.FieldOrganizationID:
  35474. v, ok := value.(uint64)
  35475. if !ok {
  35476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35477. }
  35478. m.SetOrganizationID(v)
  35479. return nil
  35480. case usagedetail.FieldModel:
  35481. v, ok := value.(string)
  35482. if !ok {
  35483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35484. }
  35485. m.SetModel(v)
  35486. return nil
  35487. case usagedetail.FieldCredits:
  35488. v, ok := value.(float64)
  35489. if !ok {
  35490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35491. }
  35492. m.SetCredits(v)
  35493. return nil
  35494. }
  35495. return fmt.Errorf("unknown UsageDetail field %s", name)
  35496. }
  35497. // AddedFields returns all numeric fields that were incremented/decremented during
  35498. // this mutation.
  35499. func (m *UsageDetailMutation) AddedFields() []string {
  35500. var fields []string
  35501. if m.addstatus != nil {
  35502. fields = append(fields, usagedetail.FieldStatus)
  35503. }
  35504. if m.add_type != nil {
  35505. fields = append(fields, usagedetail.FieldType)
  35506. }
  35507. if m.addapp != nil {
  35508. fields = append(fields, usagedetail.FieldApp)
  35509. }
  35510. if m.addsession_id != nil {
  35511. fields = append(fields, usagedetail.FieldSessionID)
  35512. }
  35513. if m.addtotal_tokens != nil {
  35514. fields = append(fields, usagedetail.FieldTotalTokens)
  35515. }
  35516. if m.addprompt_tokens != nil {
  35517. fields = append(fields, usagedetail.FieldPromptTokens)
  35518. }
  35519. if m.addcompletion_tokens != nil {
  35520. fields = append(fields, usagedetail.FieldCompletionTokens)
  35521. }
  35522. if m.addorganization_id != nil {
  35523. fields = append(fields, usagedetail.FieldOrganizationID)
  35524. }
  35525. if m.addcredits != nil {
  35526. fields = append(fields, usagedetail.FieldCredits)
  35527. }
  35528. return fields
  35529. }
  35530. // AddedField returns the numeric value that was incremented/decremented on a field
  35531. // with the given name. The second boolean return value indicates that this field
  35532. // was not set, or was not defined in the schema.
  35533. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  35534. switch name {
  35535. case usagedetail.FieldStatus:
  35536. return m.AddedStatus()
  35537. case usagedetail.FieldType:
  35538. return m.AddedType()
  35539. case usagedetail.FieldApp:
  35540. return m.AddedApp()
  35541. case usagedetail.FieldSessionID:
  35542. return m.AddedSessionID()
  35543. case usagedetail.FieldTotalTokens:
  35544. return m.AddedTotalTokens()
  35545. case usagedetail.FieldPromptTokens:
  35546. return m.AddedPromptTokens()
  35547. case usagedetail.FieldCompletionTokens:
  35548. return m.AddedCompletionTokens()
  35549. case usagedetail.FieldOrganizationID:
  35550. return m.AddedOrganizationID()
  35551. case usagedetail.FieldCredits:
  35552. return m.AddedCredits()
  35553. }
  35554. return nil, false
  35555. }
  35556. // AddField adds the value to the field with the given name. It returns an error if
  35557. // the field is not defined in the schema, or if the type mismatched the field
  35558. // type.
  35559. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  35560. switch name {
  35561. case usagedetail.FieldStatus:
  35562. v, ok := value.(int8)
  35563. if !ok {
  35564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35565. }
  35566. m.AddStatus(v)
  35567. return nil
  35568. case usagedetail.FieldType:
  35569. v, ok := value.(int)
  35570. if !ok {
  35571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35572. }
  35573. m.AddType(v)
  35574. return nil
  35575. case usagedetail.FieldApp:
  35576. v, ok := value.(int)
  35577. if !ok {
  35578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35579. }
  35580. m.AddApp(v)
  35581. return nil
  35582. case usagedetail.FieldSessionID:
  35583. v, ok := value.(int64)
  35584. if !ok {
  35585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35586. }
  35587. m.AddSessionID(v)
  35588. return nil
  35589. case usagedetail.FieldTotalTokens:
  35590. v, ok := value.(int64)
  35591. if !ok {
  35592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35593. }
  35594. m.AddTotalTokens(v)
  35595. return nil
  35596. case usagedetail.FieldPromptTokens:
  35597. v, ok := value.(int64)
  35598. if !ok {
  35599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35600. }
  35601. m.AddPromptTokens(v)
  35602. return nil
  35603. case usagedetail.FieldCompletionTokens:
  35604. v, ok := value.(int64)
  35605. if !ok {
  35606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35607. }
  35608. m.AddCompletionTokens(v)
  35609. return nil
  35610. case usagedetail.FieldOrganizationID:
  35611. v, ok := value.(int64)
  35612. if !ok {
  35613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35614. }
  35615. m.AddOrganizationID(v)
  35616. return nil
  35617. case usagedetail.FieldCredits:
  35618. v, ok := value.(float64)
  35619. if !ok {
  35620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35621. }
  35622. m.AddCredits(v)
  35623. return nil
  35624. }
  35625. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  35626. }
  35627. // ClearedFields returns all nullable fields that were cleared during this
  35628. // mutation.
  35629. func (m *UsageDetailMutation) ClearedFields() []string {
  35630. var fields []string
  35631. if m.FieldCleared(usagedetail.FieldStatus) {
  35632. fields = append(fields, usagedetail.FieldStatus)
  35633. }
  35634. if m.FieldCleared(usagedetail.FieldType) {
  35635. fields = append(fields, usagedetail.FieldType)
  35636. }
  35637. if m.FieldCleared(usagedetail.FieldApp) {
  35638. fields = append(fields, usagedetail.FieldApp)
  35639. }
  35640. if m.FieldCleared(usagedetail.FieldSessionID) {
  35641. fields = append(fields, usagedetail.FieldSessionID)
  35642. }
  35643. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  35644. fields = append(fields, usagedetail.FieldTotalTokens)
  35645. }
  35646. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  35647. fields = append(fields, usagedetail.FieldPromptTokens)
  35648. }
  35649. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  35650. fields = append(fields, usagedetail.FieldCompletionTokens)
  35651. }
  35652. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  35653. fields = append(fields, usagedetail.FieldOrganizationID)
  35654. }
  35655. if m.FieldCleared(usagedetail.FieldModel) {
  35656. fields = append(fields, usagedetail.FieldModel)
  35657. }
  35658. if m.FieldCleared(usagedetail.FieldCredits) {
  35659. fields = append(fields, usagedetail.FieldCredits)
  35660. }
  35661. return fields
  35662. }
  35663. // FieldCleared returns a boolean indicating if a field with the given name was
  35664. // cleared in this mutation.
  35665. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  35666. _, ok := m.clearedFields[name]
  35667. return ok
  35668. }
  35669. // ClearField clears the value of the field with the given name. It returns an
  35670. // error if the field is not defined in the schema.
  35671. func (m *UsageDetailMutation) ClearField(name string) error {
  35672. switch name {
  35673. case usagedetail.FieldStatus:
  35674. m.ClearStatus()
  35675. return nil
  35676. case usagedetail.FieldType:
  35677. m.ClearType()
  35678. return nil
  35679. case usagedetail.FieldApp:
  35680. m.ClearApp()
  35681. return nil
  35682. case usagedetail.FieldSessionID:
  35683. m.ClearSessionID()
  35684. return nil
  35685. case usagedetail.FieldTotalTokens:
  35686. m.ClearTotalTokens()
  35687. return nil
  35688. case usagedetail.FieldPromptTokens:
  35689. m.ClearPromptTokens()
  35690. return nil
  35691. case usagedetail.FieldCompletionTokens:
  35692. m.ClearCompletionTokens()
  35693. return nil
  35694. case usagedetail.FieldOrganizationID:
  35695. m.ClearOrganizationID()
  35696. return nil
  35697. case usagedetail.FieldModel:
  35698. m.ClearModel()
  35699. return nil
  35700. case usagedetail.FieldCredits:
  35701. m.ClearCredits()
  35702. return nil
  35703. }
  35704. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  35705. }
  35706. // ResetField resets all changes in the mutation for the field with the given name.
  35707. // It returns an error if the field is not defined in the schema.
  35708. func (m *UsageDetailMutation) ResetField(name string) error {
  35709. switch name {
  35710. case usagedetail.FieldCreatedAt:
  35711. m.ResetCreatedAt()
  35712. return nil
  35713. case usagedetail.FieldUpdatedAt:
  35714. m.ResetUpdatedAt()
  35715. return nil
  35716. case usagedetail.FieldStatus:
  35717. m.ResetStatus()
  35718. return nil
  35719. case usagedetail.FieldType:
  35720. m.ResetType()
  35721. return nil
  35722. case usagedetail.FieldBotID:
  35723. m.ResetBotID()
  35724. return nil
  35725. case usagedetail.FieldReceiverID:
  35726. m.ResetReceiverID()
  35727. return nil
  35728. case usagedetail.FieldApp:
  35729. m.ResetApp()
  35730. return nil
  35731. case usagedetail.FieldSessionID:
  35732. m.ResetSessionID()
  35733. return nil
  35734. case usagedetail.FieldRequest:
  35735. m.ResetRequest()
  35736. return nil
  35737. case usagedetail.FieldResponse:
  35738. m.ResetResponse()
  35739. return nil
  35740. case usagedetail.FieldOriginalData:
  35741. m.ResetOriginalData()
  35742. return nil
  35743. case usagedetail.FieldTotalTokens:
  35744. m.ResetTotalTokens()
  35745. return nil
  35746. case usagedetail.FieldPromptTokens:
  35747. m.ResetPromptTokens()
  35748. return nil
  35749. case usagedetail.FieldCompletionTokens:
  35750. m.ResetCompletionTokens()
  35751. return nil
  35752. case usagedetail.FieldOrganizationID:
  35753. m.ResetOrganizationID()
  35754. return nil
  35755. case usagedetail.FieldModel:
  35756. m.ResetModel()
  35757. return nil
  35758. case usagedetail.FieldCredits:
  35759. m.ResetCredits()
  35760. return nil
  35761. }
  35762. return fmt.Errorf("unknown UsageDetail field %s", name)
  35763. }
  35764. // AddedEdges returns all edge names that were set/added in this mutation.
  35765. func (m *UsageDetailMutation) AddedEdges() []string {
  35766. edges := make([]string, 0, 0)
  35767. return edges
  35768. }
  35769. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35770. // name in this mutation.
  35771. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  35772. return nil
  35773. }
  35774. // RemovedEdges returns all edge names that were removed in this mutation.
  35775. func (m *UsageDetailMutation) RemovedEdges() []string {
  35776. edges := make([]string, 0, 0)
  35777. return edges
  35778. }
  35779. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35780. // the given name in this mutation.
  35781. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  35782. return nil
  35783. }
  35784. // ClearedEdges returns all edge names that were cleared in this mutation.
  35785. func (m *UsageDetailMutation) ClearedEdges() []string {
  35786. edges := make([]string, 0, 0)
  35787. return edges
  35788. }
  35789. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35790. // was cleared in this mutation.
  35791. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  35792. return false
  35793. }
  35794. // ClearEdge clears the value of the edge with the given name. It returns an error
  35795. // if that edge is not defined in the schema.
  35796. func (m *UsageDetailMutation) ClearEdge(name string) error {
  35797. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  35798. }
  35799. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35800. // It returns an error if the edge is not defined in the schema.
  35801. func (m *UsageDetailMutation) ResetEdge(name string) error {
  35802. return fmt.Errorf("unknown UsageDetail edge %s", name)
  35803. }
  35804. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  35805. type UsageStatisticDayMutation struct {
  35806. config
  35807. op Op
  35808. typ string
  35809. id *uint64
  35810. created_at *time.Time
  35811. updated_at *time.Time
  35812. status *uint8
  35813. addstatus *int8
  35814. deleted_at *time.Time
  35815. addtime *uint64
  35816. addaddtime *int64
  35817. _type *int
  35818. add_type *int
  35819. bot_id *string
  35820. organization_id *uint64
  35821. addorganization_id *int64
  35822. ai_response *uint64
  35823. addai_response *int64
  35824. sop_run *uint64
  35825. addsop_run *int64
  35826. total_friend *uint64
  35827. addtotal_friend *int64
  35828. total_group *uint64
  35829. addtotal_group *int64
  35830. account_balance *uint64
  35831. addaccount_balance *int64
  35832. consume_token *uint64
  35833. addconsume_token *int64
  35834. active_user *uint64
  35835. addactive_user *int64
  35836. new_user *int64
  35837. addnew_user *int64
  35838. label_dist *[]custom_types.LabelDist
  35839. appendlabel_dist []custom_types.LabelDist
  35840. consume_coin *float64
  35841. addconsume_coin *float64
  35842. clearedFields map[string]struct{}
  35843. done bool
  35844. oldValue func(context.Context) (*UsageStatisticDay, error)
  35845. predicates []predicate.UsageStatisticDay
  35846. }
  35847. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  35848. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  35849. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  35850. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  35851. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  35852. m := &UsageStatisticDayMutation{
  35853. config: c,
  35854. op: op,
  35855. typ: TypeUsageStatisticDay,
  35856. clearedFields: make(map[string]struct{}),
  35857. }
  35858. for _, opt := range opts {
  35859. opt(m)
  35860. }
  35861. return m
  35862. }
  35863. // withUsageStatisticDayID sets the ID field of the mutation.
  35864. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  35865. return func(m *UsageStatisticDayMutation) {
  35866. var (
  35867. err error
  35868. once sync.Once
  35869. value *UsageStatisticDay
  35870. )
  35871. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  35872. once.Do(func() {
  35873. if m.done {
  35874. err = errors.New("querying old values post mutation is not allowed")
  35875. } else {
  35876. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  35877. }
  35878. })
  35879. return value, err
  35880. }
  35881. m.id = &id
  35882. }
  35883. }
  35884. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  35885. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  35886. return func(m *UsageStatisticDayMutation) {
  35887. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  35888. return node, nil
  35889. }
  35890. m.id = &node.ID
  35891. }
  35892. }
  35893. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35894. // executed in a transaction (ent.Tx), a transactional client is returned.
  35895. func (m UsageStatisticDayMutation) Client() *Client {
  35896. client := &Client{config: m.config}
  35897. client.init()
  35898. return client
  35899. }
  35900. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35901. // it returns an error otherwise.
  35902. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  35903. if _, ok := m.driver.(*txDriver); !ok {
  35904. return nil, errors.New("ent: mutation is not running in a transaction")
  35905. }
  35906. tx := &Tx{config: m.config}
  35907. tx.init()
  35908. return tx, nil
  35909. }
  35910. // SetID sets the value of the id field. Note that this
  35911. // operation is only accepted on creation of UsageStatisticDay entities.
  35912. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  35913. m.id = &id
  35914. }
  35915. // ID returns the ID value in the mutation. Note that the ID is only available
  35916. // if it was provided to the builder or after it was returned from the database.
  35917. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  35918. if m.id == nil {
  35919. return
  35920. }
  35921. return *m.id, true
  35922. }
  35923. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35924. // That means, if the mutation is applied within a transaction with an isolation level such
  35925. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35926. // or updated by the mutation.
  35927. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  35928. switch {
  35929. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35930. id, exists := m.ID()
  35931. if exists {
  35932. return []uint64{id}, nil
  35933. }
  35934. fallthrough
  35935. case m.op.Is(OpUpdate | OpDelete):
  35936. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  35937. default:
  35938. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35939. }
  35940. }
  35941. // SetCreatedAt sets the "created_at" field.
  35942. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  35943. m.created_at = &t
  35944. }
  35945. // CreatedAt returns the value of the "created_at" field in the mutation.
  35946. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  35947. v := m.created_at
  35948. if v == nil {
  35949. return
  35950. }
  35951. return *v, true
  35952. }
  35953. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  35954. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35956. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35957. if !m.op.Is(OpUpdateOne) {
  35958. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35959. }
  35960. if m.id == nil || m.oldValue == nil {
  35961. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35962. }
  35963. oldValue, err := m.oldValue(ctx)
  35964. if err != nil {
  35965. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35966. }
  35967. return oldValue.CreatedAt, nil
  35968. }
  35969. // ResetCreatedAt resets all changes to the "created_at" field.
  35970. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  35971. m.created_at = nil
  35972. }
  35973. // SetUpdatedAt sets the "updated_at" field.
  35974. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  35975. m.updated_at = &t
  35976. }
  35977. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35978. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  35979. v := m.updated_at
  35980. if v == nil {
  35981. return
  35982. }
  35983. return *v, true
  35984. }
  35985. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  35986. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  35987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35988. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35989. if !m.op.Is(OpUpdateOne) {
  35990. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35991. }
  35992. if m.id == nil || m.oldValue == nil {
  35993. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35994. }
  35995. oldValue, err := m.oldValue(ctx)
  35996. if err != nil {
  35997. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35998. }
  35999. return oldValue.UpdatedAt, nil
  36000. }
  36001. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36002. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  36003. m.updated_at = nil
  36004. }
  36005. // SetStatus sets the "status" field.
  36006. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  36007. m.status = &u
  36008. m.addstatus = nil
  36009. }
  36010. // Status returns the value of the "status" field in the mutation.
  36011. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  36012. v := m.status
  36013. if v == nil {
  36014. return
  36015. }
  36016. return *v, true
  36017. }
  36018. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  36019. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36021. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36022. if !m.op.Is(OpUpdateOne) {
  36023. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36024. }
  36025. if m.id == nil || m.oldValue == nil {
  36026. return v, errors.New("OldStatus requires an ID field in the mutation")
  36027. }
  36028. oldValue, err := m.oldValue(ctx)
  36029. if err != nil {
  36030. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36031. }
  36032. return oldValue.Status, nil
  36033. }
  36034. // AddStatus adds u to the "status" field.
  36035. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  36036. if m.addstatus != nil {
  36037. *m.addstatus += u
  36038. } else {
  36039. m.addstatus = &u
  36040. }
  36041. }
  36042. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36043. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  36044. v := m.addstatus
  36045. if v == nil {
  36046. return
  36047. }
  36048. return *v, true
  36049. }
  36050. // ClearStatus clears the value of the "status" field.
  36051. func (m *UsageStatisticDayMutation) ClearStatus() {
  36052. m.status = nil
  36053. m.addstatus = nil
  36054. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  36055. }
  36056. // StatusCleared returns if the "status" field was cleared in this mutation.
  36057. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  36058. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  36059. return ok
  36060. }
  36061. // ResetStatus resets all changes to the "status" field.
  36062. func (m *UsageStatisticDayMutation) ResetStatus() {
  36063. m.status = nil
  36064. m.addstatus = nil
  36065. delete(m.clearedFields, usagestatisticday.FieldStatus)
  36066. }
  36067. // SetDeletedAt sets the "deleted_at" field.
  36068. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  36069. m.deleted_at = &t
  36070. }
  36071. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36072. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  36073. v := m.deleted_at
  36074. if v == nil {
  36075. return
  36076. }
  36077. return *v, true
  36078. }
  36079. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  36080. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36082. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36083. if !m.op.Is(OpUpdateOne) {
  36084. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36085. }
  36086. if m.id == nil || m.oldValue == nil {
  36087. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36088. }
  36089. oldValue, err := m.oldValue(ctx)
  36090. if err != nil {
  36091. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36092. }
  36093. return oldValue.DeletedAt, nil
  36094. }
  36095. // ClearDeletedAt clears the value of the "deleted_at" field.
  36096. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  36097. m.deleted_at = nil
  36098. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  36099. }
  36100. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36101. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  36102. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  36103. return ok
  36104. }
  36105. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36106. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  36107. m.deleted_at = nil
  36108. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  36109. }
  36110. // SetAddtime sets the "addtime" field.
  36111. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  36112. m.addtime = &u
  36113. m.addaddtime = nil
  36114. }
  36115. // Addtime returns the value of the "addtime" field in the mutation.
  36116. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  36117. v := m.addtime
  36118. if v == nil {
  36119. return
  36120. }
  36121. return *v, true
  36122. }
  36123. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  36124. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36126. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  36127. if !m.op.Is(OpUpdateOne) {
  36128. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  36129. }
  36130. if m.id == nil || m.oldValue == nil {
  36131. return v, errors.New("OldAddtime requires an ID field in the mutation")
  36132. }
  36133. oldValue, err := m.oldValue(ctx)
  36134. if err != nil {
  36135. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  36136. }
  36137. return oldValue.Addtime, nil
  36138. }
  36139. // AddAddtime adds u to the "addtime" field.
  36140. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  36141. if m.addaddtime != nil {
  36142. *m.addaddtime += u
  36143. } else {
  36144. m.addaddtime = &u
  36145. }
  36146. }
  36147. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  36148. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  36149. v := m.addaddtime
  36150. if v == nil {
  36151. return
  36152. }
  36153. return *v, true
  36154. }
  36155. // ResetAddtime resets all changes to the "addtime" field.
  36156. func (m *UsageStatisticDayMutation) ResetAddtime() {
  36157. m.addtime = nil
  36158. m.addaddtime = nil
  36159. }
  36160. // SetType sets the "type" field.
  36161. func (m *UsageStatisticDayMutation) SetType(i int) {
  36162. m._type = &i
  36163. m.add_type = nil
  36164. }
  36165. // GetType returns the value of the "type" field in the mutation.
  36166. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  36167. v := m._type
  36168. if v == nil {
  36169. return
  36170. }
  36171. return *v, true
  36172. }
  36173. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  36174. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36176. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  36177. if !m.op.Is(OpUpdateOne) {
  36178. return v, errors.New("OldType is only allowed on UpdateOne operations")
  36179. }
  36180. if m.id == nil || m.oldValue == nil {
  36181. return v, errors.New("OldType requires an ID field in the mutation")
  36182. }
  36183. oldValue, err := m.oldValue(ctx)
  36184. if err != nil {
  36185. return v, fmt.Errorf("querying old value for OldType: %w", err)
  36186. }
  36187. return oldValue.Type, nil
  36188. }
  36189. // AddType adds i to the "type" field.
  36190. func (m *UsageStatisticDayMutation) AddType(i int) {
  36191. if m.add_type != nil {
  36192. *m.add_type += i
  36193. } else {
  36194. m.add_type = &i
  36195. }
  36196. }
  36197. // AddedType returns the value that was added to the "type" field in this mutation.
  36198. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  36199. v := m.add_type
  36200. if v == nil {
  36201. return
  36202. }
  36203. return *v, true
  36204. }
  36205. // ResetType resets all changes to the "type" field.
  36206. func (m *UsageStatisticDayMutation) ResetType() {
  36207. m._type = nil
  36208. m.add_type = nil
  36209. }
  36210. // SetBotID sets the "bot_id" field.
  36211. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  36212. m.bot_id = &s
  36213. }
  36214. // BotID returns the value of the "bot_id" field in the mutation.
  36215. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  36216. v := m.bot_id
  36217. if v == nil {
  36218. return
  36219. }
  36220. return *v, true
  36221. }
  36222. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  36223. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36225. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  36226. if !m.op.Is(OpUpdateOne) {
  36227. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36228. }
  36229. if m.id == nil || m.oldValue == nil {
  36230. return v, errors.New("OldBotID requires an ID field in the mutation")
  36231. }
  36232. oldValue, err := m.oldValue(ctx)
  36233. if err != nil {
  36234. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36235. }
  36236. return oldValue.BotID, nil
  36237. }
  36238. // ClearBotID clears the value of the "bot_id" field.
  36239. func (m *UsageStatisticDayMutation) ClearBotID() {
  36240. m.bot_id = nil
  36241. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  36242. }
  36243. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  36244. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  36245. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  36246. return ok
  36247. }
  36248. // ResetBotID resets all changes to the "bot_id" field.
  36249. func (m *UsageStatisticDayMutation) ResetBotID() {
  36250. m.bot_id = nil
  36251. delete(m.clearedFields, usagestatisticday.FieldBotID)
  36252. }
  36253. // SetOrganizationID sets the "organization_id" field.
  36254. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  36255. m.organization_id = &u
  36256. m.addorganization_id = nil
  36257. }
  36258. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36259. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  36260. v := m.organization_id
  36261. if v == nil {
  36262. return
  36263. }
  36264. return *v, true
  36265. }
  36266. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  36267. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36269. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36270. if !m.op.Is(OpUpdateOne) {
  36271. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36272. }
  36273. if m.id == nil || m.oldValue == nil {
  36274. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36275. }
  36276. oldValue, err := m.oldValue(ctx)
  36277. if err != nil {
  36278. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36279. }
  36280. return oldValue.OrganizationID, nil
  36281. }
  36282. // AddOrganizationID adds u to the "organization_id" field.
  36283. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  36284. if m.addorganization_id != nil {
  36285. *m.addorganization_id += u
  36286. } else {
  36287. m.addorganization_id = &u
  36288. }
  36289. }
  36290. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36291. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  36292. v := m.addorganization_id
  36293. if v == nil {
  36294. return
  36295. }
  36296. return *v, true
  36297. }
  36298. // ClearOrganizationID clears the value of the "organization_id" field.
  36299. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  36300. m.organization_id = nil
  36301. m.addorganization_id = nil
  36302. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  36303. }
  36304. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36305. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  36306. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  36307. return ok
  36308. }
  36309. // ResetOrganizationID resets all changes to the "organization_id" field.
  36310. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  36311. m.organization_id = nil
  36312. m.addorganization_id = nil
  36313. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  36314. }
  36315. // SetAiResponse sets the "ai_response" field.
  36316. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  36317. m.ai_response = &u
  36318. m.addai_response = nil
  36319. }
  36320. // AiResponse returns the value of the "ai_response" field in the mutation.
  36321. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  36322. v := m.ai_response
  36323. if v == nil {
  36324. return
  36325. }
  36326. return *v, true
  36327. }
  36328. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  36329. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36331. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  36332. if !m.op.Is(OpUpdateOne) {
  36333. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  36334. }
  36335. if m.id == nil || m.oldValue == nil {
  36336. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  36337. }
  36338. oldValue, err := m.oldValue(ctx)
  36339. if err != nil {
  36340. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  36341. }
  36342. return oldValue.AiResponse, nil
  36343. }
  36344. // AddAiResponse adds u to the "ai_response" field.
  36345. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  36346. if m.addai_response != nil {
  36347. *m.addai_response += u
  36348. } else {
  36349. m.addai_response = &u
  36350. }
  36351. }
  36352. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  36353. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  36354. v := m.addai_response
  36355. if v == nil {
  36356. return
  36357. }
  36358. return *v, true
  36359. }
  36360. // ResetAiResponse resets all changes to the "ai_response" field.
  36361. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  36362. m.ai_response = nil
  36363. m.addai_response = nil
  36364. }
  36365. // SetSopRun sets the "sop_run" field.
  36366. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  36367. m.sop_run = &u
  36368. m.addsop_run = nil
  36369. }
  36370. // SopRun returns the value of the "sop_run" field in the mutation.
  36371. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  36372. v := m.sop_run
  36373. if v == nil {
  36374. return
  36375. }
  36376. return *v, true
  36377. }
  36378. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  36379. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36381. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  36382. if !m.op.Is(OpUpdateOne) {
  36383. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  36384. }
  36385. if m.id == nil || m.oldValue == nil {
  36386. return v, errors.New("OldSopRun requires an ID field in the mutation")
  36387. }
  36388. oldValue, err := m.oldValue(ctx)
  36389. if err != nil {
  36390. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  36391. }
  36392. return oldValue.SopRun, nil
  36393. }
  36394. // AddSopRun adds u to the "sop_run" field.
  36395. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  36396. if m.addsop_run != nil {
  36397. *m.addsop_run += u
  36398. } else {
  36399. m.addsop_run = &u
  36400. }
  36401. }
  36402. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  36403. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  36404. v := m.addsop_run
  36405. if v == nil {
  36406. return
  36407. }
  36408. return *v, true
  36409. }
  36410. // ResetSopRun resets all changes to the "sop_run" field.
  36411. func (m *UsageStatisticDayMutation) ResetSopRun() {
  36412. m.sop_run = nil
  36413. m.addsop_run = nil
  36414. }
  36415. // SetTotalFriend sets the "total_friend" field.
  36416. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  36417. m.total_friend = &u
  36418. m.addtotal_friend = nil
  36419. }
  36420. // TotalFriend returns the value of the "total_friend" field in the mutation.
  36421. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  36422. v := m.total_friend
  36423. if v == nil {
  36424. return
  36425. }
  36426. return *v, true
  36427. }
  36428. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  36429. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36431. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  36432. if !m.op.Is(OpUpdateOne) {
  36433. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  36434. }
  36435. if m.id == nil || m.oldValue == nil {
  36436. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  36437. }
  36438. oldValue, err := m.oldValue(ctx)
  36439. if err != nil {
  36440. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  36441. }
  36442. return oldValue.TotalFriend, nil
  36443. }
  36444. // AddTotalFriend adds u to the "total_friend" field.
  36445. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  36446. if m.addtotal_friend != nil {
  36447. *m.addtotal_friend += u
  36448. } else {
  36449. m.addtotal_friend = &u
  36450. }
  36451. }
  36452. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  36453. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  36454. v := m.addtotal_friend
  36455. if v == nil {
  36456. return
  36457. }
  36458. return *v, true
  36459. }
  36460. // ResetTotalFriend resets all changes to the "total_friend" field.
  36461. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  36462. m.total_friend = nil
  36463. m.addtotal_friend = nil
  36464. }
  36465. // SetTotalGroup sets the "total_group" field.
  36466. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  36467. m.total_group = &u
  36468. m.addtotal_group = nil
  36469. }
  36470. // TotalGroup returns the value of the "total_group" field in the mutation.
  36471. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  36472. v := m.total_group
  36473. if v == nil {
  36474. return
  36475. }
  36476. return *v, true
  36477. }
  36478. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  36479. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36481. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  36482. if !m.op.Is(OpUpdateOne) {
  36483. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  36484. }
  36485. if m.id == nil || m.oldValue == nil {
  36486. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  36487. }
  36488. oldValue, err := m.oldValue(ctx)
  36489. if err != nil {
  36490. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  36491. }
  36492. return oldValue.TotalGroup, nil
  36493. }
  36494. // AddTotalGroup adds u to the "total_group" field.
  36495. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  36496. if m.addtotal_group != nil {
  36497. *m.addtotal_group += u
  36498. } else {
  36499. m.addtotal_group = &u
  36500. }
  36501. }
  36502. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  36503. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  36504. v := m.addtotal_group
  36505. if v == nil {
  36506. return
  36507. }
  36508. return *v, true
  36509. }
  36510. // ResetTotalGroup resets all changes to the "total_group" field.
  36511. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  36512. m.total_group = nil
  36513. m.addtotal_group = nil
  36514. }
  36515. // SetAccountBalance sets the "account_balance" field.
  36516. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  36517. m.account_balance = &u
  36518. m.addaccount_balance = nil
  36519. }
  36520. // AccountBalance returns the value of the "account_balance" field in the mutation.
  36521. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  36522. v := m.account_balance
  36523. if v == nil {
  36524. return
  36525. }
  36526. return *v, true
  36527. }
  36528. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  36529. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36531. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  36532. if !m.op.Is(OpUpdateOne) {
  36533. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  36534. }
  36535. if m.id == nil || m.oldValue == nil {
  36536. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  36537. }
  36538. oldValue, err := m.oldValue(ctx)
  36539. if err != nil {
  36540. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  36541. }
  36542. return oldValue.AccountBalance, nil
  36543. }
  36544. // AddAccountBalance adds u to the "account_balance" field.
  36545. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  36546. if m.addaccount_balance != nil {
  36547. *m.addaccount_balance += u
  36548. } else {
  36549. m.addaccount_balance = &u
  36550. }
  36551. }
  36552. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  36553. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  36554. v := m.addaccount_balance
  36555. if v == nil {
  36556. return
  36557. }
  36558. return *v, true
  36559. }
  36560. // ResetAccountBalance resets all changes to the "account_balance" field.
  36561. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  36562. m.account_balance = nil
  36563. m.addaccount_balance = nil
  36564. }
  36565. // SetConsumeToken sets the "consume_token" field.
  36566. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  36567. m.consume_token = &u
  36568. m.addconsume_token = nil
  36569. }
  36570. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  36571. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  36572. v := m.consume_token
  36573. if v == nil {
  36574. return
  36575. }
  36576. return *v, true
  36577. }
  36578. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  36579. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36581. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  36582. if !m.op.Is(OpUpdateOne) {
  36583. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  36584. }
  36585. if m.id == nil || m.oldValue == nil {
  36586. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  36587. }
  36588. oldValue, err := m.oldValue(ctx)
  36589. if err != nil {
  36590. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  36591. }
  36592. return oldValue.ConsumeToken, nil
  36593. }
  36594. // AddConsumeToken adds u to the "consume_token" field.
  36595. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  36596. if m.addconsume_token != nil {
  36597. *m.addconsume_token += u
  36598. } else {
  36599. m.addconsume_token = &u
  36600. }
  36601. }
  36602. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  36603. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  36604. v := m.addconsume_token
  36605. if v == nil {
  36606. return
  36607. }
  36608. return *v, true
  36609. }
  36610. // ResetConsumeToken resets all changes to the "consume_token" field.
  36611. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  36612. m.consume_token = nil
  36613. m.addconsume_token = nil
  36614. }
  36615. // SetActiveUser sets the "active_user" field.
  36616. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  36617. m.active_user = &u
  36618. m.addactive_user = nil
  36619. }
  36620. // ActiveUser returns the value of the "active_user" field in the mutation.
  36621. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  36622. v := m.active_user
  36623. if v == nil {
  36624. return
  36625. }
  36626. return *v, true
  36627. }
  36628. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  36629. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36631. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  36632. if !m.op.Is(OpUpdateOne) {
  36633. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  36634. }
  36635. if m.id == nil || m.oldValue == nil {
  36636. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  36637. }
  36638. oldValue, err := m.oldValue(ctx)
  36639. if err != nil {
  36640. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  36641. }
  36642. return oldValue.ActiveUser, nil
  36643. }
  36644. // AddActiveUser adds u to the "active_user" field.
  36645. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  36646. if m.addactive_user != nil {
  36647. *m.addactive_user += u
  36648. } else {
  36649. m.addactive_user = &u
  36650. }
  36651. }
  36652. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  36653. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  36654. v := m.addactive_user
  36655. if v == nil {
  36656. return
  36657. }
  36658. return *v, true
  36659. }
  36660. // ResetActiveUser resets all changes to the "active_user" field.
  36661. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  36662. m.active_user = nil
  36663. m.addactive_user = nil
  36664. }
  36665. // SetNewUser sets the "new_user" field.
  36666. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  36667. m.new_user = &i
  36668. m.addnew_user = nil
  36669. }
  36670. // NewUser returns the value of the "new_user" field in the mutation.
  36671. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  36672. v := m.new_user
  36673. if v == nil {
  36674. return
  36675. }
  36676. return *v, true
  36677. }
  36678. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  36679. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36681. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  36682. if !m.op.Is(OpUpdateOne) {
  36683. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  36684. }
  36685. if m.id == nil || m.oldValue == nil {
  36686. return v, errors.New("OldNewUser requires an ID field in the mutation")
  36687. }
  36688. oldValue, err := m.oldValue(ctx)
  36689. if err != nil {
  36690. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  36691. }
  36692. return oldValue.NewUser, nil
  36693. }
  36694. // AddNewUser adds i to the "new_user" field.
  36695. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  36696. if m.addnew_user != nil {
  36697. *m.addnew_user += i
  36698. } else {
  36699. m.addnew_user = &i
  36700. }
  36701. }
  36702. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  36703. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  36704. v := m.addnew_user
  36705. if v == nil {
  36706. return
  36707. }
  36708. return *v, true
  36709. }
  36710. // ResetNewUser resets all changes to the "new_user" field.
  36711. func (m *UsageStatisticDayMutation) ResetNewUser() {
  36712. m.new_user = nil
  36713. m.addnew_user = nil
  36714. }
  36715. // SetLabelDist sets the "label_dist" field.
  36716. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  36717. m.label_dist = &ctd
  36718. m.appendlabel_dist = nil
  36719. }
  36720. // LabelDist returns the value of the "label_dist" field in the mutation.
  36721. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  36722. v := m.label_dist
  36723. if v == nil {
  36724. return
  36725. }
  36726. return *v, true
  36727. }
  36728. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  36729. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36731. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  36732. if !m.op.Is(OpUpdateOne) {
  36733. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  36734. }
  36735. if m.id == nil || m.oldValue == nil {
  36736. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  36737. }
  36738. oldValue, err := m.oldValue(ctx)
  36739. if err != nil {
  36740. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  36741. }
  36742. return oldValue.LabelDist, nil
  36743. }
  36744. // AppendLabelDist adds ctd to the "label_dist" field.
  36745. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  36746. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  36747. }
  36748. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  36749. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  36750. if len(m.appendlabel_dist) == 0 {
  36751. return nil, false
  36752. }
  36753. return m.appendlabel_dist, true
  36754. }
  36755. // ResetLabelDist resets all changes to the "label_dist" field.
  36756. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  36757. m.label_dist = nil
  36758. m.appendlabel_dist = nil
  36759. }
  36760. // SetConsumeCoin sets the "consume_coin" field.
  36761. func (m *UsageStatisticDayMutation) SetConsumeCoin(f float64) {
  36762. m.consume_coin = &f
  36763. m.addconsume_coin = nil
  36764. }
  36765. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  36766. func (m *UsageStatisticDayMutation) ConsumeCoin() (r float64, exists bool) {
  36767. v := m.consume_coin
  36768. if v == nil {
  36769. return
  36770. }
  36771. return *v, true
  36772. }
  36773. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticDay entity.
  36774. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  36775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36776. func (m *UsageStatisticDayMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  36777. if !m.op.Is(OpUpdateOne) {
  36778. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  36779. }
  36780. if m.id == nil || m.oldValue == nil {
  36781. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  36782. }
  36783. oldValue, err := m.oldValue(ctx)
  36784. if err != nil {
  36785. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  36786. }
  36787. return oldValue.ConsumeCoin, nil
  36788. }
  36789. // AddConsumeCoin adds f to the "consume_coin" field.
  36790. func (m *UsageStatisticDayMutation) AddConsumeCoin(f float64) {
  36791. if m.addconsume_coin != nil {
  36792. *m.addconsume_coin += f
  36793. } else {
  36794. m.addconsume_coin = &f
  36795. }
  36796. }
  36797. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  36798. func (m *UsageStatisticDayMutation) AddedConsumeCoin() (r float64, exists bool) {
  36799. v := m.addconsume_coin
  36800. if v == nil {
  36801. return
  36802. }
  36803. return *v, true
  36804. }
  36805. // ClearConsumeCoin clears the value of the "consume_coin" field.
  36806. func (m *UsageStatisticDayMutation) ClearConsumeCoin() {
  36807. m.consume_coin = nil
  36808. m.addconsume_coin = nil
  36809. m.clearedFields[usagestatisticday.FieldConsumeCoin] = struct{}{}
  36810. }
  36811. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  36812. func (m *UsageStatisticDayMutation) ConsumeCoinCleared() bool {
  36813. _, ok := m.clearedFields[usagestatisticday.FieldConsumeCoin]
  36814. return ok
  36815. }
  36816. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  36817. func (m *UsageStatisticDayMutation) ResetConsumeCoin() {
  36818. m.consume_coin = nil
  36819. m.addconsume_coin = nil
  36820. delete(m.clearedFields, usagestatisticday.FieldConsumeCoin)
  36821. }
  36822. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  36823. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  36824. m.predicates = append(m.predicates, ps...)
  36825. }
  36826. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  36827. // users can use type-assertion to append predicates that do not depend on any generated package.
  36828. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  36829. p := make([]predicate.UsageStatisticDay, len(ps))
  36830. for i := range ps {
  36831. p[i] = ps[i]
  36832. }
  36833. m.Where(p...)
  36834. }
  36835. // Op returns the operation name.
  36836. func (m *UsageStatisticDayMutation) Op() Op {
  36837. return m.op
  36838. }
  36839. // SetOp allows setting the mutation operation.
  36840. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  36841. m.op = op
  36842. }
  36843. // Type returns the node type of this mutation (UsageStatisticDay).
  36844. func (m *UsageStatisticDayMutation) Type() string {
  36845. return m.typ
  36846. }
  36847. // Fields returns all fields that were changed during this mutation. Note that in
  36848. // order to get all numeric fields that were incremented/decremented, call
  36849. // AddedFields().
  36850. func (m *UsageStatisticDayMutation) Fields() []string {
  36851. fields := make([]string, 0, 18)
  36852. if m.created_at != nil {
  36853. fields = append(fields, usagestatisticday.FieldCreatedAt)
  36854. }
  36855. if m.updated_at != nil {
  36856. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  36857. }
  36858. if m.status != nil {
  36859. fields = append(fields, usagestatisticday.FieldStatus)
  36860. }
  36861. if m.deleted_at != nil {
  36862. fields = append(fields, usagestatisticday.FieldDeletedAt)
  36863. }
  36864. if m.addtime != nil {
  36865. fields = append(fields, usagestatisticday.FieldAddtime)
  36866. }
  36867. if m._type != nil {
  36868. fields = append(fields, usagestatisticday.FieldType)
  36869. }
  36870. if m.bot_id != nil {
  36871. fields = append(fields, usagestatisticday.FieldBotID)
  36872. }
  36873. if m.organization_id != nil {
  36874. fields = append(fields, usagestatisticday.FieldOrganizationID)
  36875. }
  36876. if m.ai_response != nil {
  36877. fields = append(fields, usagestatisticday.FieldAiResponse)
  36878. }
  36879. if m.sop_run != nil {
  36880. fields = append(fields, usagestatisticday.FieldSopRun)
  36881. }
  36882. if m.total_friend != nil {
  36883. fields = append(fields, usagestatisticday.FieldTotalFriend)
  36884. }
  36885. if m.total_group != nil {
  36886. fields = append(fields, usagestatisticday.FieldTotalGroup)
  36887. }
  36888. if m.account_balance != nil {
  36889. fields = append(fields, usagestatisticday.FieldAccountBalance)
  36890. }
  36891. if m.consume_token != nil {
  36892. fields = append(fields, usagestatisticday.FieldConsumeToken)
  36893. }
  36894. if m.active_user != nil {
  36895. fields = append(fields, usagestatisticday.FieldActiveUser)
  36896. }
  36897. if m.new_user != nil {
  36898. fields = append(fields, usagestatisticday.FieldNewUser)
  36899. }
  36900. if m.label_dist != nil {
  36901. fields = append(fields, usagestatisticday.FieldLabelDist)
  36902. }
  36903. if m.consume_coin != nil {
  36904. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  36905. }
  36906. return fields
  36907. }
  36908. // Field returns the value of a field with the given name. The second boolean
  36909. // return value indicates that this field was not set, or was not defined in the
  36910. // schema.
  36911. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  36912. switch name {
  36913. case usagestatisticday.FieldCreatedAt:
  36914. return m.CreatedAt()
  36915. case usagestatisticday.FieldUpdatedAt:
  36916. return m.UpdatedAt()
  36917. case usagestatisticday.FieldStatus:
  36918. return m.Status()
  36919. case usagestatisticday.FieldDeletedAt:
  36920. return m.DeletedAt()
  36921. case usagestatisticday.FieldAddtime:
  36922. return m.Addtime()
  36923. case usagestatisticday.FieldType:
  36924. return m.GetType()
  36925. case usagestatisticday.FieldBotID:
  36926. return m.BotID()
  36927. case usagestatisticday.FieldOrganizationID:
  36928. return m.OrganizationID()
  36929. case usagestatisticday.FieldAiResponse:
  36930. return m.AiResponse()
  36931. case usagestatisticday.FieldSopRun:
  36932. return m.SopRun()
  36933. case usagestatisticday.FieldTotalFriend:
  36934. return m.TotalFriend()
  36935. case usagestatisticday.FieldTotalGroup:
  36936. return m.TotalGroup()
  36937. case usagestatisticday.FieldAccountBalance:
  36938. return m.AccountBalance()
  36939. case usagestatisticday.FieldConsumeToken:
  36940. return m.ConsumeToken()
  36941. case usagestatisticday.FieldActiveUser:
  36942. return m.ActiveUser()
  36943. case usagestatisticday.FieldNewUser:
  36944. return m.NewUser()
  36945. case usagestatisticday.FieldLabelDist:
  36946. return m.LabelDist()
  36947. case usagestatisticday.FieldConsumeCoin:
  36948. return m.ConsumeCoin()
  36949. }
  36950. return nil, false
  36951. }
  36952. // OldField returns the old value of the field from the database. An error is
  36953. // returned if the mutation operation is not UpdateOne, or the query to the
  36954. // database failed.
  36955. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36956. switch name {
  36957. case usagestatisticday.FieldCreatedAt:
  36958. return m.OldCreatedAt(ctx)
  36959. case usagestatisticday.FieldUpdatedAt:
  36960. return m.OldUpdatedAt(ctx)
  36961. case usagestatisticday.FieldStatus:
  36962. return m.OldStatus(ctx)
  36963. case usagestatisticday.FieldDeletedAt:
  36964. return m.OldDeletedAt(ctx)
  36965. case usagestatisticday.FieldAddtime:
  36966. return m.OldAddtime(ctx)
  36967. case usagestatisticday.FieldType:
  36968. return m.OldType(ctx)
  36969. case usagestatisticday.FieldBotID:
  36970. return m.OldBotID(ctx)
  36971. case usagestatisticday.FieldOrganizationID:
  36972. return m.OldOrganizationID(ctx)
  36973. case usagestatisticday.FieldAiResponse:
  36974. return m.OldAiResponse(ctx)
  36975. case usagestatisticday.FieldSopRun:
  36976. return m.OldSopRun(ctx)
  36977. case usagestatisticday.FieldTotalFriend:
  36978. return m.OldTotalFriend(ctx)
  36979. case usagestatisticday.FieldTotalGroup:
  36980. return m.OldTotalGroup(ctx)
  36981. case usagestatisticday.FieldAccountBalance:
  36982. return m.OldAccountBalance(ctx)
  36983. case usagestatisticday.FieldConsumeToken:
  36984. return m.OldConsumeToken(ctx)
  36985. case usagestatisticday.FieldActiveUser:
  36986. return m.OldActiveUser(ctx)
  36987. case usagestatisticday.FieldNewUser:
  36988. return m.OldNewUser(ctx)
  36989. case usagestatisticday.FieldLabelDist:
  36990. return m.OldLabelDist(ctx)
  36991. case usagestatisticday.FieldConsumeCoin:
  36992. return m.OldConsumeCoin(ctx)
  36993. }
  36994. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  36995. }
  36996. // SetField sets the value of a field with the given name. It returns an error if
  36997. // the field is not defined in the schema, or if the type mismatched the field
  36998. // type.
  36999. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  37000. switch name {
  37001. case usagestatisticday.FieldCreatedAt:
  37002. v, ok := value.(time.Time)
  37003. if !ok {
  37004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37005. }
  37006. m.SetCreatedAt(v)
  37007. return nil
  37008. case usagestatisticday.FieldUpdatedAt:
  37009. v, ok := value.(time.Time)
  37010. if !ok {
  37011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37012. }
  37013. m.SetUpdatedAt(v)
  37014. return nil
  37015. case usagestatisticday.FieldStatus:
  37016. v, ok := value.(uint8)
  37017. if !ok {
  37018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37019. }
  37020. m.SetStatus(v)
  37021. return nil
  37022. case usagestatisticday.FieldDeletedAt:
  37023. v, ok := value.(time.Time)
  37024. if !ok {
  37025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37026. }
  37027. m.SetDeletedAt(v)
  37028. return nil
  37029. case usagestatisticday.FieldAddtime:
  37030. v, ok := value.(uint64)
  37031. if !ok {
  37032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37033. }
  37034. m.SetAddtime(v)
  37035. return nil
  37036. case usagestatisticday.FieldType:
  37037. v, ok := value.(int)
  37038. if !ok {
  37039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37040. }
  37041. m.SetType(v)
  37042. return nil
  37043. case usagestatisticday.FieldBotID:
  37044. v, ok := value.(string)
  37045. if !ok {
  37046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37047. }
  37048. m.SetBotID(v)
  37049. return nil
  37050. case usagestatisticday.FieldOrganizationID:
  37051. v, ok := value.(uint64)
  37052. if !ok {
  37053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37054. }
  37055. m.SetOrganizationID(v)
  37056. return nil
  37057. case usagestatisticday.FieldAiResponse:
  37058. v, ok := value.(uint64)
  37059. if !ok {
  37060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37061. }
  37062. m.SetAiResponse(v)
  37063. return nil
  37064. case usagestatisticday.FieldSopRun:
  37065. v, ok := value.(uint64)
  37066. if !ok {
  37067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37068. }
  37069. m.SetSopRun(v)
  37070. return nil
  37071. case usagestatisticday.FieldTotalFriend:
  37072. v, ok := value.(uint64)
  37073. if !ok {
  37074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37075. }
  37076. m.SetTotalFriend(v)
  37077. return nil
  37078. case usagestatisticday.FieldTotalGroup:
  37079. v, ok := value.(uint64)
  37080. if !ok {
  37081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37082. }
  37083. m.SetTotalGroup(v)
  37084. return nil
  37085. case usagestatisticday.FieldAccountBalance:
  37086. v, ok := value.(uint64)
  37087. if !ok {
  37088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37089. }
  37090. m.SetAccountBalance(v)
  37091. return nil
  37092. case usagestatisticday.FieldConsumeToken:
  37093. v, ok := value.(uint64)
  37094. if !ok {
  37095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37096. }
  37097. m.SetConsumeToken(v)
  37098. return nil
  37099. case usagestatisticday.FieldActiveUser:
  37100. v, ok := value.(uint64)
  37101. if !ok {
  37102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37103. }
  37104. m.SetActiveUser(v)
  37105. return nil
  37106. case usagestatisticday.FieldNewUser:
  37107. v, ok := value.(int64)
  37108. if !ok {
  37109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37110. }
  37111. m.SetNewUser(v)
  37112. return nil
  37113. case usagestatisticday.FieldLabelDist:
  37114. v, ok := value.([]custom_types.LabelDist)
  37115. if !ok {
  37116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37117. }
  37118. m.SetLabelDist(v)
  37119. return nil
  37120. case usagestatisticday.FieldConsumeCoin:
  37121. v, ok := value.(float64)
  37122. if !ok {
  37123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37124. }
  37125. m.SetConsumeCoin(v)
  37126. return nil
  37127. }
  37128. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37129. }
  37130. // AddedFields returns all numeric fields that were incremented/decremented during
  37131. // this mutation.
  37132. func (m *UsageStatisticDayMutation) AddedFields() []string {
  37133. var fields []string
  37134. if m.addstatus != nil {
  37135. fields = append(fields, usagestatisticday.FieldStatus)
  37136. }
  37137. if m.addaddtime != nil {
  37138. fields = append(fields, usagestatisticday.FieldAddtime)
  37139. }
  37140. if m.add_type != nil {
  37141. fields = append(fields, usagestatisticday.FieldType)
  37142. }
  37143. if m.addorganization_id != nil {
  37144. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37145. }
  37146. if m.addai_response != nil {
  37147. fields = append(fields, usagestatisticday.FieldAiResponse)
  37148. }
  37149. if m.addsop_run != nil {
  37150. fields = append(fields, usagestatisticday.FieldSopRun)
  37151. }
  37152. if m.addtotal_friend != nil {
  37153. fields = append(fields, usagestatisticday.FieldTotalFriend)
  37154. }
  37155. if m.addtotal_group != nil {
  37156. fields = append(fields, usagestatisticday.FieldTotalGroup)
  37157. }
  37158. if m.addaccount_balance != nil {
  37159. fields = append(fields, usagestatisticday.FieldAccountBalance)
  37160. }
  37161. if m.addconsume_token != nil {
  37162. fields = append(fields, usagestatisticday.FieldConsumeToken)
  37163. }
  37164. if m.addactive_user != nil {
  37165. fields = append(fields, usagestatisticday.FieldActiveUser)
  37166. }
  37167. if m.addnew_user != nil {
  37168. fields = append(fields, usagestatisticday.FieldNewUser)
  37169. }
  37170. if m.addconsume_coin != nil {
  37171. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37172. }
  37173. return fields
  37174. }
  37175. // AddedField returns the numeric value that was incremented/decremented on a field
  37176. // with the given name. The second boolean return value indicates that this field
  37177. // was not set, or was not defined in the schema.
  37178. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  37179. switch name {
  37180. case usagestatisticday.FieldStatus:
  37181. return m.AddedStatus()
  37182. case usagestatisticday.FieldAddtime:
  37183. return m.AddedAddtime()
  37184. case usagestatisticday.FieldType:
  37185. return m.AddedType()
  37186. case usagestatisticday.FieldOrganizationID:
  37187. return m.AddedOrganizationID()
  37188. case usagestatisticday.FieldAiResponse:
  37189. return m.AddedAiResponse()
  37190. case usagestatisticday.FieldSopRun:
  37191. return m.AddedSopRun()
  37192. case usagestatisticday.FieldTotalFriend:
  37193. return m.AddedTotalFriend()
  37194. case usagestatisticday.FieldTotalGroup:
  37195. return m.AddedTotalGroup()
  37196. case usagestatisticday.FieldAccountBalance:
  37197. return m.AddedAccountBalance()
  37198. case usagestatisticday.FieldConsumeToken:
  37199. return m.AddedConsumeToken()
  37200. case usagestatisticday.FieldActiveUser:
  37201. return m.AddedActiveUser()
  37202. case usagestatisticday.FieldNewUser:
  37203. return m.AddedNewUser()
  37204. case usagestatisticday.FieldConsumeCoin:
  37205. return m.AddedConsumeCoin()
  37206. }
  37207. return nil, false
  37208. }
  37209. // AddField adds the value to the field with the given name. It returns an error if
  37210. // the field is not defined in the schema, or if the type mismatched the field
  37211. // type.
  37212. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  37213. switch name {
  37214. case usagestatisticday.FieldStatus:
  37215. v, ok := value.(int8)
  37216. if !ok {
  37217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37218. }
  37219. m.AddStatus(v)
  37220. return nil
  37221. case usagestatisticday.FieldAddtime:
  37222. v, ok := value.(int64)
  37223. if !ok {
  37224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37225. }
  37226. m.AddAddtime(v)
  37227. return nil
  37228. case usagestatisticday.FieldType:
  37229. v, ok := value.(int)
  37230. if !ok {
  37231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37232. }
  37233. m.AddType(v)
  37234. return nil
  37235. case usagestatisticday.FieldOrganizationID:
  37236. v, ok := value.(int64)
  37237. if !ok {
  37238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37239. }
  37240. m.AddOrganizationID(v)
  37241. return nil
  37242. case usagestatisticday.FieldAiResponse:
  37243. v, ok := value.(int64)
  37244. if !ok {
  37245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37246. }
  37247. m.AddAiResponse(v)
  37248. return nil
  37249. case usagestatisticday.FieldSopRun:
  37250. v, ok := value.(int64)
  37251. if !ok {
  37252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37253. }
  37254. m.AddSopRun(v)
  37255. return nil
  37256. case usagestatisticday.FieldTotalFriend:
  37257. v, ok := value.(int64)
  37258. if !ok {
  37259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37260. }
  37261. m.AddTotalFriend(v)
  37262. return nil
  37263. case usagestatisticday.FieldTotalGroup:
  37264. v, ok := value.(int64)
  37265. if !ok {
  37266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37267. }
  37268. m.AddTotalGroup(v)
  37269. return nil
  37270. case usagestatisticday.FieldAccountBalance:
  37271. v, ok := value.(int64)
  37272. if !ok {
  37273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37274. }
  37275. m.AddAccountBalance(v)
  37276. return nil
  37277. case usagestatisticday.FieldConsumeToken:
  37278. v, ok := value.(int64)
  37279. if !ok {
  37280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37281. }
  37282. m.AddConsumeToken(v)
  37283. return nil
  37284. case usagestatisticday.FieldActiveUser:
  37285. v, ok := value.(int64)
  37286. if !ok {
  37287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37288. }
  37289. m.AddActiveUser(v)
  37290. return nil
  37291. case usagestatisticday.FieldNewUser:
  37292. v, ok := value.(int64)
  37293. if !ok {
  37294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37295. }
  37296. m.AddNewUser(v)
  37297. return nil
  37298. case usagestatisticday.FieldConsumeCoin:
  37299. v, ok := value.(float64)
  37300. if !ok {
  37301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37302. }
  37303. m.AddConsumeCoin(v)
  37304. return nil
  37305. }
  37306. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  37307. }
  37308. // ClearedFields returns all nullable fields that were cleared during this
  37309. // mutation.
  37310. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  37311. var fields []string
  37312. if m.FieldCleared(usagestatisticday.FieldStatus) {
  37313. fields = append(fields, usagestatisticday.FieldStatus)
  37314. }
  37315. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  37316. fields = append(fields, usagestatisticday.FieldDeletedAt)
  37317. }
  37318. if m.FieldCleared(usagestatisticday.FieldBotID) {
  37319. fields = append(fields, usagestatisticday.FieldBotID)
  37320. }
  37321. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  37322. fields = append(fields, usagestatisticday.FieldOrganizationID)
  37323. }
  37324. if m.FieldCleared(usagestatisticday.FieldConsumeCoin) {
  37325. fields = append(fields, usagestatisticday.FieldConsumeCoin)
  37326. }
  37327. return fields
  37328. }
  37329. // FieldCleared returns a boolean indicating if a field with the given name was
  37330. // cleared in this mutation.
  37331. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  37332. _, ok := m.clearedFields[name]
  37333. return ok
  37334. }
  37335. // ClearField clears the value of the field with the given name. It returns an
  37336. // error if the field is not defined in the schema.
  37337. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  37338. switch name {
  37339. case usagestatisticday.FieldStatus:
  37340. m.ClearStatus()
  37341. return nil
  37342. case usagestatisticday.FieldDeletedAt:
  37343. m.ClearDeletedAt()
  37344. return nil
  37345. case usagestatisticday.FieldBotID:
  37346. m.ClearBotID()
  37347. return nil
  37348. case usagestatisticday.FieldOrganizationID:
  37349. m.ClearOrganizationID()
  37350. return nil
  37351. case usagestatisticday.FieldConsumeCoin:
  37352. m.ClearConsumeCoin()
  37353. return nil
  37354. }
  37355. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  37356. }
  37357. // ResetField resets all changes in the mutation for the field with the given name.
  37358. // It returns an error if the field is not defined in the schema.
  37359. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  37360. switch name {
  37361. case usagestatisticday.FieldCreatedAt:
  37362. m.ResetCreatedAt()
  37363. return nil
  37364. case usagestatisticday.FieldUpdatedAt:
  37365. m.ResetUpdatedAt()
  37366. return nil
  37367. case usagestatisticday.FieldStatus:
  37368. m.ResetStatus()
  37369. return nil
  37370. case usagestatisticday.FieldDeletedAt:
  37371. m.ResetDeletedAt()
  37372. return nil
  37373. case usagestatisticday.FieldAddtime:
  37374. m.ResetAddtime()
  37375. return nil
  37376. case usagestatisticday.FieldType:
  37377. m.ResetType()
  37378. return nil
  37379. case usagestatisticday.FieldBotID:
  37380. m.ResetBotID()
  37381. return nil
  37382. case usagestatisticday.FieldOrganizationID:
  37383. m.ResetOrganizationID()
  37384. return nil
  37385. case usagestatisticday.FieldAiResponse:
  37386. m.ResetAiResponse()
  37387. return nil
  37388. case usagestatisticday.FieldSopRun:
  37389. m.ResetSopRun()
  37390. return nil
  37391. case usagestatisticday.FieldTotalFriend:
  37392. m.ResetTotalFriend()
  37393. return nil
  37394. case usagestatisticday.FieldTotalGroup:
  37395. m.ResetTotalGroup()
  37396. return nil
  37397. case usagestatisticday.FieldAccountBalance:
  37398. m.ResetAccountBalance()
  37399. return nil
  37400. case usagestatisticday.FieldConsumeToken:
  37401. m.ResetConsumeToken()
  37402. return nil
  37403. case usagestatisticday.FieldActiveUser:
  37404. m.ResetActiveUser()
  37405. return nil
  37406. case usagestatisticday.FieldNewUser:
  37407. m.ResetNewUser()
  37408. return nil
  37409. case usagestatisticday.FieldLabelDist:
  37410. m.ResetLabelDist()
  37411. return nil
  37412. case usagestatisticday.FieldConsumeCoin:
  37413. m.ResetConsumeCoin()
  37414. return nil
  37415. }
  37416. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  37417. }
  37418. // AddedEdges returns all edge names that were set/added in this mutation.
  37419. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  37420. edges := make([]string, 0, 0)
  37421. return edges
  37422. }
  37423. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37424. // name in this mutation.
  37425. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  37426. return nil
  37427. }
  37428. // RemovedEdges returns all edge names that were removed in this mutation.
  37429. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  37430. edges := make([]string, 0, 0)
  37431. return edges
  37432. }
  37433. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37434. // the given name in this mutation.
  37435. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  37436. return nil
  37437. }
  37438. // ClearedEdges returns all edge names that were cleared in this mutation.
  37439. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  37440. edges := make([]string, 0, 0)
  37441. return edges
  37442. }
  37443. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37444. // was cleared in this mutation.
  37445. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  37446. return false
  37447. }
  37448. // ClearEdge clears the value of the edge with the given name. It returns an error
  37449. // if that edge is not defined in the schema.
  37450. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  37451. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  37452. }
  37453. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37454. // It returns an error if the edge is not defined in the schema.
  37455. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  37456. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  37457. }
  37458. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  37459. type UsageStatisticHourMutation struct {
  37460. config
  37461. op Op
  37462. typ string
  37463. id *uint64
  37464. created_at *time.Time
  37465. updated_at *time.Time
  37466. status *uint8
  37467. addstatus *int8
  37468. deleted_at *time.Time
  37469. addtime *uint64
  37470. addaddtime *int64
  37471. _type *int
  37472. add_type *int
  37473. bot_id *string
  37474. organization_id *uint64
  37475. addorganization_id *int64
  37476. ai_response *uint64
  37477. addai_response *int64
  37478. sop_run *uint64
  37479. addsop_run *int64
  37480. total_friend *uint64
  37481. addtotal_friend *int64
  37482. total_group *uint64
  37483. addtotal_group *int64
  37484. account_balance *uint64
  37485. addaccount_balance *int64
  37486. consume_token *uint64
  37487. addconsume_token *int64
  37488. active_user *uint64
  37489. addactive_user *int64
  37490. new_user *int64
  37491. addnew_user *int64
  37492. label_dist *[]custom_types.LabelDist
  37493. appendlabel_dist []custom_types.LabelDist
  37494. consume_coin *float64
  37495. addconsume_coin *float64
  37496. clearedFields map[string]struct{}
  37497. done bool
  37498. oldValue func(context.Context) (*UsageStatisticHour, error)
  37499. predicates []predicate.UsageStatisticHour
  37500. }
  37501. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  37502. // usagestatistichourOption allows management of the mutation configuration using functional options.
  37503. type usagestatistichourOption func(*UsageStatisticHourMutation)
  37504. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  37505. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  37506. m := &UsageStatisticHourMutation{
  37507. config: c,
  37508. op: op,
  37509. typ: TypeUsageStatisticHour,
  37510. clearedFields: make(map[string]struct{}),
  37511. }
  37512. for _, opt := range opts {
  37513. opt(m)
  37514. }
  37515. return m
  37516. }
  37517. // withUsageStatisticHourID sets the ID field of the mutation.
  37518. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  37519. return func(m *UsageStatisticHourMutation) {
  37520. var (
  37521. err error
  37522. once sync.Once
  37523. value *UsageStatisticHour
  37524. )
  37525. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  37526. once.Do(func() {
  37527. if m.done {
  37528. err = errors.New("querying old values post mutation is not allowed")
  37529. } else {
  37530. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  37531. }
  37532. })
  37533. return value, err
  37534. }
  37535. m.id = &id
  37536. }
  37537. }
  37538. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  37539. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  37540. return func(m *UsageStatisticHourMutation) {
  37541. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  37542. return node, nil
  37543. }
  37544. m.id = &node.ID
  37545. }
  37546. }
  37547. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37548. // executed in a transaction (ent.Tx), a transactional client is returned.
  37549. func (m UsageStatisticHourMutation) Client() *Client {
  37550. client := &Client{config: m.config}
  37551. client.init()
  37552. return client
  37553. }
  37554. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37555. // it returns an error otherwise.
  37556. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  37557. if _, ok := m.driver.(*txDriver); !ok {
  37558. return nil, errors.New("ent: mutation is not running in a transaction")
  37559. }
  37560. tx := &Tx{config: m.config}
  37561. tx.init()
  37562. return tx, nil
  37563. }
  37564. // SetID sets the value of the id field. Note that this
  37565. // operation is only accepted on creation of UsageStatisticHour entities.
  37566. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  37567. m.id = &id
  37568. }
  37569. // ID returns the ID value in the mutation. Note that the ID is only available
  37570. // if it was provided to the builder or after it was returned from the database.
  37571. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  37572. if m.id == nil {
  37573. return
  37574. }
  37575. return *m.id, true
  37576. }
  37577. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37578. // That means, if the mutation is applied within a transaction with an isolation level such
  37579. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37580. // or updated by the mutation.
  37581. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  37582. switch {
  37583. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37584. id, exists := m.ID()
  37585. if exists {
  37586. return []uint64{id}, nil
  37587. }
  37588. fallthrough
  37589. case m.op.Is(OpUpdate | OpDelete):
  37590. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  37591. default:
  37592. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37593. }
  37594. }
  37595. // SetCreatedAt sets the "created_at" field.
  37596. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  37597. m.created_at = &t
  37598. }
  37599. // CreatedAt returns the value of the "created_at" field in the mutation.
  37600. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  37601. v := m.created_at
  37602. if v == nil {
  37603. return
  37604. }
  37605. return *v, true
  37606. }
  37607. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  37608. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37610. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37611. if !m.op.Is(OpUpdateOne) {
  37612. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37613. }
  37614. if m.id == nil || m.oldValue == nil {
  37615. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37616. }
  37617. oldValue, err := m.oldValue(ctx)
  37618. if err != nil {
  37619. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37620. }
  37621. return oldValue.CreatedAt, nil
  37622. }
  37623. // ResetCreatedAt resets all changes to the "created_at" field.
  37624. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  37625. m.created_at = nil
  37626. }
  37627. // SetUpdatedAt sets the "updated_at" field.
  37628. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  37629. m.updated_at = &t
  37630. }
  37631. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37632. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  37633. v := m.updated_at
  37634. if v == nil {
  37635. return
  37636. }
  37637. return *v, true
  37638. }
  37639. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  37640. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37642. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37643. if !m.op.Is(OpUpdateOne) {
  37644. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37645. }
  37646. if m.id == nil || m.oldValue == nil {
  37647. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37648. }
  37649. oldValue, err := m.oldValue(ctx)
  37650. if err != nil {
  37651. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37652. }
  37653. return oldValue.UpdatedAt, nil
  37654. }
  37655. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37656. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  37657. m.updated_at = nil
  37658. }
  37659. // SetStatus sets the "status" field.
  37660. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  37661. m.status = &u
  37662. m.addstatus = nil
  37663. }
  37664. // Status returns the value of the "status" field in the mutation.
  37665. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  37666. v := m.status
  37667. if v == nil {
  37668. return
  37669. }
  37670. return *v, true
  37671. }
  37672. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  37673. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37675. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37676. if !m.op.Is(OpUpdateOne) {
  37677. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37678. }
  37679. if m.id == nil || m.oldValue == nil {
  37680. return v, errors.New("OldStatus requires an ID field in the mutation")
  37681. }
  37682. oldValue, err := m.oldValue(ctx)
  37683. if err != nil {
  37684. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37685. }
  37686. return oldValue.Status, nil
  37687. }
  37688. // AddStatus adds u to the "status" field.
  37689. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  37690. if m.addstatus != nil {
  37691. *m.addstatus += u
  37692. } else {
  37693. m.addstatus = &u
  37694. }
  37695. }
  37696. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37697. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  37698. v := m.addstatus
  37699. if v == nil {
  37700. return
  37701. }
  37702. return *v, true
  37703. }
  37704. // ClearStatus clears the value of the "status" field.
  37705. func (m *UsageStatisticHourMutation) ClearStatus() {
  37706. m.status = nil
  37707. m.addstatus = nil
  37708. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  37709. }
  37710. // StatusCleared returns if the "status" field was cleared in this mutation.
  37711. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  37712. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  37713. return ok
  37714. }
  37715. // ResetStatus resets all changes to the "status" field.
  37716. func (m *UsageStatisticHourMutation) ResetStatus() {
  37717. m.status = nil
  37718. m.addstatus = nil
  37719. delete(m.clearedFields, usagestatistichour.FieldStatus)
  37720. }
  37721. // SetDeletedAt sets the "deleted_at" field.
  37722. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  37723. m.deleted_at = &t
  37724. }
  37725. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37726. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  37727. v := m.deleted_at
  37728. if v == nil {
  37729. return
  37730. }
  37731. return *v, true
  37732. }
  37733. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  37734. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37736. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37737. if !m.op.Is(OpUpdateOne) {
  37738. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37739. }
  37740. if m.id == nil || m.oldValue == nil {
  37741. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37742. }
  37743. oldValue, err := m.oldValue(ctx)
  37744. if err != nil {
  37745. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37746. }
  37747. return oldValue.DeletedAt, nil
  37748. }
  37749. // ClearDeletedAt clears the value of the "deleted_at" field.
  37750. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  37751. m.deleted_at = nil
  37752. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  37753. }
  37754. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37755. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  37756. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  37757. return ok
  37758. }
  37759. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37760. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  37761. m.deleted_at = nil
  37762. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  37763. }
  37764. // SetAddtime sets the "addtime" field.
  37765. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  37766. m.addtime = &u
  37767. m.addaddtime = nil
  37768. }
  37769. // Addtime returns the value of the "addtime" field in the mutation.
  37770. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  37771. v := m.addtime
  37772. if v == nil {
  37773. return
  37774. }
  37775. return *v, true
  37776. }
  37777. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  37778. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37780. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  37781. if !m.op.Is(OpUpdateOne) {
  37782. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  37783. }
  37784. if m.id == nil || m.oldValue == nil {
  37785. return v, errors.New("OldAddtime requires an ID field in the mutation")
  37786. }
  37787. oldValue, err := m.oldValue(ctx)
  37788. if err != nil {
  37789. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  37790. }
  37791. return oldValue.Addtime, nil
  37792. }
  37793. // AddAddtime adds u to the "addtime" field.
  37794. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  37795. if m.addaddtime != nil {
  37796. *m.addaddtime += u
  37797. } else {
  37798. m.addaddtime = &u
  37799. }
  37800. }
  37801. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  37802. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  37803. v := m.addaddtime
  37804. if v == nil {
  37805. return
  37806. }
  37807. return *v, true
  37808. }
  37809. // ResetAddtime resets all changes to the "addtime" field.
  37810. func (m *UsageStatisticHourMutation) ResetAddtime() {
  37811. m.addtime = nil
  37812. m.addaddtime = nil
  37813. }
  37814. // SetType sets the "type" field.
  37815. func (m *UsageStatisticHourMutation) SetType(i int) {
  37816. m._type = &i
  37817. m.add_type = nil
  37818. }
  37819. // GetType returns the value of the "type" field in the mutation.
  37820. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  37821. v := m._type
  37822. if v == nil {
  37823. return
  37824. }
  37825. return *v, true
  37826. }
  37827. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  37828. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37830. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  37831. if !m.op.Is(OpUpdateOne) {
  37832. return v, errors.New("OldType is only allowed on UpdateOne operations")
  37833. }
  37834. if m.id == nil || m.oldValue == nil {
  37835. return v, errors.New("OldType requires an ID field in the mutation")
  37836. }
  37837. oldValue, err := m.oldValue(ctx)
  37838. if err != nil {
  37839. return v, fmt.Errorf("querying old value for OldType: %w", err)
  37840. }
  37841. return oldValue.Type, nil
  37842. }
  37843. // AddType adds i to the "type" field.
  37844. func (m *UsageStatisticHourMutation) AddType(i int) {
  37845. if m.add_type != nil {
  37846. *m.add_type += i
  37847. } else {
  37848. m.add_type = &i
  37849. }
  37850. }
  37851. // AddedType returns the value that was added to the "type" field in this mutation.
  37852. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  37853. v := m.add_type
  37854. if v == nil {
  37855. return
  37856. }
  37857. return *v, true
  37858. }
  37859. // ResetType resets all changes to the "type" field.
  37860. func (m *UsageStatisticHourMutation) ResetType() {
  37861. m._type = nil
  37862. m.add_type = nil
  37863. }
  37864. // SetBotID sets the "bot_id" field.
  37865. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  37866. m.bot_id = &s
  37867. }
  37868. // BotID returns the value of the "bot_id" field in the mutation.
  37869. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  37870. v := m.bot_id
  37871. if v == nil {
  37872. return
  37873. }
  37874. return *v, true
  37875. }
  37876. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  37877. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37879. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  37880. if !m.op.Is(OpUpdateOne) {
  37881. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  37882. }
  37883. if m.id == nil || m.oldValue == nil {
  37884. return v, errors.New("OldBotID requires an ID field in the mutation")
  37885. }
  37886. oldValue, err := m.oldValue(ctx)
  37887. if err != nil {
  37888. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  37889. }
  37890. return oldValue.BotID, nil
  37891. }
  37892. // ClearBotID clears the value of the "bot_id" field.
  37893. func (m *UsageStatisticHourMutation) ClearBotID() {
  37894. m.bot_id = nil
  37895. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  37896. }
  37897. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  37898. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  37899. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  37900. return ok
  37901. }
  37902. // ResetBotID resets all changes to the "bot_id" field.
  37903. func (m *UsageStatisticHourMutation) ResetBotID() {
  37904. m.bot_id = nil
  37905. delete(m.clearedFields, usagestatistichour.FieldBotID)
  37906. }
  37907. // SetOrganizationID sets the "organization_id" field.
  37908. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  37909. m.organization_id = &u
  37910. m.addorganization_id = nil
  37911. }
  37912. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37913. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  37914. v := m.organization_id
  37915. if v == nil {
  37916. return
  37917. }
  37918. return *v, true
  37919. }
  37920. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  37921. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37923. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37924. if !m.op.Is(OpUpdateOne) {
  37925. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37926. }
  37927. if m.id == nil || m.oldValue == nil {
  37928. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37929. }
  37930. oldValue, err := m.oldValue(ctx)
  37931. if err != nil {
  37932. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37933. }
  37934. return oldValue.OrganizationID, nil
  37935. }
  37936. // AddOrganizationID adds u to the "organization_id" field.
  37937. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  37938. if m.addorganization_id != nil {
  37939. *m.addorganization_id += u
  37940. } else {
  37941. m.addorganization_id = &u
  37942. }
  37943. }
  37944. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37945. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  37946. v := m.addorganization_id
  37947. if v == nil {
  37948. return
  37949. }
  37950. return *v, true
  37951. }
  37952. // ClearOrganizationID clears the value of the "organization_id" field.
  37953. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  37954. m.organization_id = nil
  37955. m.addorganization_id = nil
  37956. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  37957. }
  37958. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37959. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  37960. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  37961. return ok
  37962. }
  37963. // ResetOrganizationID resets all changes to the "organization_id" field.
  37964. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  37965. m.organization_id = nil
  37966. m.addorganization_id = nil
  37967. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  37968. }
  37969. // SetAiResponse sets the "ai_response" field.
  37970. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  37971. m.ai_response = &u
  37972. m.addai_response = nil
  37973. }
  37974. // AiResponse returns the value of the "ai_response" field in the mutation.
  37975. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  37976. v := m.ai_response
  37977. if v == nil {
  37978. return
  37979. }
  37980. return *v, true
  37981. }
  37982. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  37983. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  37984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37985. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  37986. if !m.op.Is(OpUpdateOne) {
  37987. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  37988. }
  37989. if m.id == nil || m.oldValue == nil {
  37990. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  37991. }
  37992. oldValue, err := m.oldValue(ctx)
  37993. if err != nil {
  37994. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  37995. }
  37996. return oldValue.AiResponse, nil
  37997. }
  37998. // AddAiResponse adds u to the "ai_response" field.
  37999. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  38000. if m.addai_response != nil {
  38001. *m.addai_response += u
  38002. } else {
  38003. m.addai_response = &u
  38004. }
  38005. }
  38006. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  38007. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  38008. v := m.addai_response
  38009. if v == nil {
  38010. return
  38011. }
  38012. return *v, true
  38013. }
  38014. // ResetAiResponse resets all changes to the "ai_response" field.
  38015. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  38016. m.ai_response = nil
  38017. m.addai_response = nil
  38018. }
  38019. // SetSopRun sets the "sop_run" field.
  38020. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  38021. m.sop_run = &u
  38022. m.addsop_run = nil
  38023. }
  38024. // SopRun returns the value of the "sop_run" field in the mutation.
  38025. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  38026. v := m.sop_run
  38027. if v == nil {
  38028. return
  38029. }
  38030. return *v, true
  38031. }
  38032. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  38033. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38035. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  38036. if !m.op.Is(OpUpdateOne) {
  38037. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  38038. }
  38039. if m.id == nil || m.oldValue == nil {
  38040. return v, errors.New("OldSopRun requires an ID field in the mutation")
  38041. }
  38042. oldValue, err := m.oldValue(ctx)
  38043. if err != nil {
  38044. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  38045. }
  38046. return oldValue.SopRun, nil
  38047. }
  38048. // AddSopRun adds u to the "sop_run" field.
  38049. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  38050. if m.addsop_run != nil {
  38051. *m.addsop_run += u
  38052. } else {
  38053. m.addsop_run = &u
  38054. }
  38055. }
  38056. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  38057. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  38058. v := m.addsop_run
  38059. if v == nil {
  38060. return
  38061. }
  38062. return *v, true
  38063. }
  38064. // ResetSopRun resets all changes to the "sop_run" field.
  38065. func (m *UsageStatisticHourMutation) ResetSopRun() {
  38066. m.sop_run = nil
  38067. m.addsop_run = nil
  38068. }
  38069. // SetTotalFriend sets the "total_friend" field.
  38070. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  38071. m.total_friend = &u
  38072. m.addtotal_friend = nil
  38073. }
  38074. // TotalFriend returns the value of the "total_friend" field in the mutation.
  38075. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  38076. v := m.total_friend
  38077. if v == nil {
  38078. return
  38079. }
  38080. return *v, true
  38081. }
  38082. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  38083. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38085. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  38086. if !m.op.Is(OpUpdateOne) {
  38087. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  38088. }
  38089. if m.id == nil || m.oldValue == nil {
  38090. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  38091. }
  38092. oldValue, err := m.oldValue(ctx)
  38093. if err != nil {
  38094. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  38095. }
  38096. return oldValue.TotalFriend, nil
  38097. }
  38098. // AddTotalFriend adds u to the "total_friend" field.
  38099. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  38100. if m.addtotal_friend != nil {
  38101. *m.addtotal_friend += u
  38102. } else {
  38103. m.addtotal_friend = &u
  38104. }
  38105. }
  38106. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  38107. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  38108. v := m.addtotal_friend
  38109. if v == nil {
  38110. return
  38111. }
  38112. return *v, true
  38113. }
  38114. // ResetTotalFriend resets all changes to the "total_friend" field.
  38115. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  38116. m.total_friend = nil
  38117. m.addtotal_friend = nil
  38118. }
  38119. // SetTotalGroup sets the "total_group" field.
  38120. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  38121. m.total_group = &u
  38122. m.addtotal_group = nil
  38123. }
  38124. // TotalGroup returns the value of the "total_group" field in the mutation.
  38125. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  38126. v := m.total_group
  38127. if v == nil {
  38128. return
  38129. }
  38130. return *v, true
  38131. }
  38132. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  38133. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38135. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  38136. if !m.op.Is(OpUpdateOne) {
  38137. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  38138. }
  38139. if m.id == nil || m.oldValue == nil {
  38140. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  38141. }
  38142. oldValue, err := m.oldValue(ctx)
  38143. if err != nil {
  38144. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  38145. }
  38146. return oldValue.TotalGroup, nil
  38147. }
  38148. // AddTotalGroup adds u to the "total_group" field.
  38149. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  38150. if m.addtotal_group != nil {
  38151. *m.addtotal_group += u
  38152. } else {
  38153. m.addtotal_group = &u
  38154. }
  38155. }
  38156. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  38157. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  38158. v := m.addtotal_group
  38159. if v == nil {
  38160. return
  38161. }
  38162. return *v, true
  38163. }
  38164. // ResetTotalGroup resets all changes to the "total_group" field.
  38165. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  38166. m.total_group = nil
  38167. m.addtotal_group = nil
  38168. }
  38169. // SetAccountBalance sets the "account_balance" field.
  38170. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  38171. m.account_balance = &u
  38172. m.addaccount_balance = nil
  38173. }
  38174. // AccountBalance returns the value of the "account_balance" field in the mutation.
  38175. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  38176. v := m.account_balance
  38177. if v == nil {
  38178. return
  38179. }
  38180. return *v, true
  38181. }
  38182. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  38183. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38185. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  38186. if !m.op.Is(OpUpdateOne) {
  38187. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  38188. }
  38189. if m.id == nil || m.oldValue == nil {
  38190. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  38191. }
  38192. oldValue, err := m.oldValue(ctx)
  38193. if err != nil {
  38194. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  38195. }
  38196. return oldValue.AccountBalance, nil
  38197. }
  38198. // AddAccountBalance adds u to the "account_balance" field.
  38199. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  38200. if m.addaccount_balance != nil {
  38201. *m.addaccount_balance += u
  38202. } else {
  38203. m.addaccount_balance = &u
  38204. }
  38205. }
  38206. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  38207. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  38208. v := m.addaccount_balance
  38209. if v == nil {
  38210. return
  38211. }
  38212. return *v, true
  38213. }
  38214. // ResetAccountBalance resets all changes to the "account_balance" field.
  38215. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  38216. m.account_balance = nil
  38217. m.addaccount_balance = nil
  38218. }
  38219. // SetConsumeToken sets the "consume_token" field.
  38220. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  38221. m.consume_token = &u
  38222. m.addconsume_token = nil
  38223. }
  38224. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  38225. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  38226. v := m.consume_token
  38227. if v == nil {
  38228. return
  38229. }
  38230. return *v, true
  38231. }
  38232. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  38233. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38235. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  38236. if !m.op.Is(OpUpdateOne) {
  38237. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  38238. }
  38239. if m.id == nil || m.oldValue == nil {
  38240. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  38241. }
  38242. oldValue, err := m.oldValue(ctx)
  38243. if err != nil {
  38244. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  38245. }
  38246. return oldValue.ConsumeToken, nil
  38247. }
  38248. // AddConsumeToken adds u to the "consume_token" field.
  38249. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  38250. if m.addconsume_token != nil {
  38251. *m.addconsume_token += u
  38252. } else {
  38253. m.addconsume_token = &u
  38254. }
  38255. }
  38256. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  38257. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  38258. v := m.addconsume_token
  38259. if v == nil {
  38260. return
  38261. }
  38262. return *v, true
  38263. }
  38264. // ResetConsumeToken resets all changes to the "consume_token" field.
  38265. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  38266. m.consume_token = nil
  38267. m.addconsume_token = nil
  38268. }
  38269. // SetActiveUser sets the "active_user" field.
  38270. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  38271. m.active_user = &u
  38272. m.addactive_user = nil
  38273. }
  38274. // ActiveUser returns the value of the "active_user" field in the mutation.
  38275. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  38276. v := m.active_user
  38277. if v == nil {
  38278. return
  38279. }
  38280. return *v, true
  38281. }
  38282. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  38283. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38284. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38285. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  38286. if !m.op.Is(OpUpdateOne) {
  38287. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  38288. }
  38289. if m.id == nil || m.oldValue == nil {
  38290. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  38291. }
  38292. oldValue, err := m.oldValue(ctx)
  38293. if err != nil {
  38294. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  38295. }
  38296. return oldValue.ActiveUser, nil
  38297. }
  38298. // AddActiveUser adds u to the "active_user" field.
  38299. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  38300. if m.addactive_user != nil {
  38301. *m.addactive_user += u
  38302. } else {
  38303. m.addactive_user = &u
  38304. }
  38305. }
  38306. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  38307. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  38308. v := m.addactive_user
  38309. if v == nil {
  38310. return
  38311. }
  38312. return *v, true
  38313. }
  38314. // ResetActiveUser resets all changes to the "active_user" field.
  38315. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  38316. m.active_user = nil
  38317. m.addactive_user = nil
  38318. }
  38319. // SetNewUser sets the "new_user" field.
  38320. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  38321. m.new_user = &i
  38322. m.addnew_user = nil
  38323. }
  38324. // NewUser returns the value of the "new_user" field in the mutation.
  38325. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  38326. v := m.new_user
  38327. if v == nil {
  38328. return
  38329. }
  38330. return *v, true
  38331. }
  38332. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  38333. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38335. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  38336. if !m.op.Is(OpUpdateOne) {
  38337. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  38338. }
  38339. if m.id == nil || m.oldValue == nil {
  38340. return v, errors.New("OldNewUser requires an ID field in the mutation")
  38341. }
  38342. oldValue, err := m.oldValue(ctx)
  38343. if err != nil {
  38344. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  38345. }
  38346. return oldValue.NewUser, nil
  38347. }
  38348. // AddNewUser adds i to the "new_user" field.
  38349. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  38350. if m.addnew_user != nil {
  38351. *m.addnew_user += i
  38352. } else {
  38353. m.addnew_user = &i
  38354. }
  38355. }
  38356. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  38357. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  38358. v := m.addnew_user
  38359. if v == nil {
  38360. return
  38361. }
  38362. return *v, true
  38363. }
  38364. // ResetNewUser resets all changes to the "new_user" field.
  38365. func (m *UsageStatisticHourMutation) ResetNewUser() {
  38366. m.new_user = nil
  38367. m.addnew_user = nil
  38368. }
  38369. // SetLabelDist sets the "label_dist" field.
  38370. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  38371. m.label_dist = &ctd
  38372. m.appendlabel_dist = nil
  38373. }
  38374. // LabelDist returns the value of the "label_dist" field in the mutation.
  38375. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  38376. v := m.label_dist
  38377. if v == nil {
  38378. return
  38379. }
  38380. return *v, true
  38381. }
  38382. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  38383. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38385. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  38386. if !m.op.Is(OpUpdateOne) {
  38387. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  38388. }
  38389. if m.id == nil || m.oldValue == nil {
  38390. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  38391. }
  38392. oldValue, err := m.oldValue(ctx)
  38393. if err != nil {
  38394. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  38395. }
  38396. return oldValue.LabelDist, nil
  38397. }
  38398. // AppendLabelDist adds ctd to the "label_dist" field.
  38399. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  38400. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  38401. }
  38402. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  38403. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  38404. if len(m.appendlabel_dist) == 0 {
  38405. return nil, false
  38406. }
  38407. return m.appendlabel_dist, true
  38408. }
  38409. // ResetLabelDist resets all changes to the "label_dist" field.
  38410. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  38411. m.label_dist = nil
  38412. m.appendlabel_dist = nil
  38413. }
  38414. // SetConsumeCoin sets the "consume_coin" field.
  38415. func (m *UsageStatisticHourMutation) SetConsumeCoin(f float64) {
  38416. m.consume_coin = &f
  38417. m.addconsume_coin = nil
  38418. }
  38419. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  38420. func (m *UsageStatisticHourMutation) ConsumeCoin() (r float64, exists bool) {
  38421. v := m.consume_coin
  38422. if v == nil {
  38423. return
  38424. }
  38425. return *v, true
  38426. }
  38427. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticHour entity.
  38428. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  38429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38430. func (m *UsageStatisticHourMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  38431. if !m.op.Is(OpUpdateOne) {
  38432. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  38433. }
  38434. if m.id == nil || m.oldValue == nil {
  38435. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  38436. }
  38437. oldValue, err := m.oldValue(ctx)
  38438. if err != nil {
  38439. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  38440. }
  38441. return oldValue.ConsumeCoin, nil
  38442. }
  38443. // AddConsumeCoin adds f to the "consume_coin" field.
  38444. func (m *UsageStatisticHourMutation) AddConsumeCoin(f float64) {
  38445. if m.addconsume_coin != nil {
  38446. *m.addconsume_coin += f
  38447. } else {
  38448. m.addconsume_coin = &f
  38449. }
  38450. }
  38451. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  38452. func (m *UsageStatisticHourMutation) AddedConsumeCoin() (r float64, exists bool) {
  38453. v := m.addconsume_coin
  38454. if v == nil {
  38455. return
  38456. }
  38457. return *v, true
  38458. }
  38459. // ClearConsumeCoin clears the value of the "consume_coin" field.
  38460. func (m *UsageStatisticHourMutation) ClearConsumeCoin() {
  38461. m.consume_coin = nil
  38462. m.addconsume_coin = nil
  38463. m.clearedFields[usagestatistichour.FieldConsumeCoin] = struct{}{}
  38464. }
  38465. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  38466. func (m *UsageStatisticHourMutation) ConsumeCoinCleared() bool {
  38467. _, ok := m.clearedFields[usagestatistichour.FieldConsumeCoin]
  38468. return ok
  38469. }
  38470. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  38471. func (m *UsageStatisticHourMutation) ResetConsumeCoin() {
  38472. m.consume_coin = nil
  38473. m.addconsume_coin = nil
  38474. delete(m.clearedFields, usagestatistichour.FieldConsumeCoin)
  38475. }
  38476. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  38477. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  38478. m.predicates = append(m.predicates, ps...)
  38479. }
  38480. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  38481. // users can use type-assertion to append predicates that do not depend on any generated package.
  38482. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  38483. p := make([]predicate.UsageStatisticHour, len(ps))
  38484. for i := range ps {
  38485. p[i] = ps[i]
  38486. }
  38487. m.Where(p...)
  38488. }
  38489. // Op returns the operation name.
  38490. func (m *UsageStatisticHourMutation) Op() Op {
  38491. return m.op
  38492. }
  38493. // SetOp allows setting the mutation operation.
  38494. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  38495. m.op = op
  38496. }
  38497. // Type returns the node type of this mutation (UsageStatisticHour).
  38498. func (m *UsageStatisticHourMutation) Type() string {
  38499. return m.typ
  38500. }
  38501. // Fields returns all fields that were changed during this mutation. Note that in
  38502. // order to get all numeric fields that were incremented/decremented, call
  38503. // AddedFields().
  38504. func (m *UsageStatisticHourMutation) Fields() []string {
  38505. fields := make([]string, 0, 18)
  38506. if m.created_at != nil {
  38507. fields = append(fields, usagestatistichour.FieldCreatedAt)
  38508. }
  38509. if m.updated_at != nil {
  38510. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  38511. }
  38512. if m.status != nil {
  38513. fields = append(fields, usagestatistichour.FieldStatus)
  38514. }
  38515. if m.deleted_at != nil {
  38516. fields = append(fields, usagestatistichour.FieldDeletedAt)
  38517. }
  38518. if m.addtime != nil {
  38519. fields = append(fields, usagestatistichour.FieldAddtime)
  38520. }
  38521. if m._type != nil {
  38522. fields = append(fields, usagestatistichour.FieldType)
  38523. }
  38524. if m.bot_id != nil {
  38525. fields = append(fields, usagestatistichour.FieldBotID)
  38526. }
  38527. if m.organization_id != nil {
  38528. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38529. }
  38530. if m.ai_response != nil {
  38531. fields = append(fields, usagestatistichour.FieldAiResponse)
  38532. }
  38533. if m.sop_run != nil {
  38534. fields = append(fields, usagestatistichour.FieldSopRun)
  38535. }
  38536. if m.total_friend != nil {
  38537. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38538. }
  38539. if m.total_group != nil {
  38540. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38541. }
  38542. if m.account_balance != nil {
  38543. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38544. }
  38545. if m.consume_token != nil {
  38546. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38547. }
  38548. if m.active_user != nil {
  38549. fields = append(fields, usagestatistichour.FieldActiveUser)
  38550. }
  38551. if m.new_user != nil {
  38552. fields = append(fields, usagestatistichour.FieldNewUser)
  38553. }
  38554. if m.label_dist != nil {
  38555. fields = append(fields, usagestatistichour.FieldLabelDist)
  38556. }
  38557. if m.consume_coin != nil {
  38558. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38559. }
  38560. return fields
  38561. }
  38562. // Field returns the value of a field with the given name. The second boolean
  38563. // return value indicates that this field was not set, or was not defined in the
  38564. // schema.
  38565. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  38566. switch name {
  38567. case usagestatistichour.FieldCreatedAt:
  38568. return m.CreatedAt()
  38569. case usagestatistichour.FieldUpdatedAt:
  38570. return m.UpdatedAt()
  38571. case usagestatistichour.FieldStatus:
  38572. return m.Status()
  38573. case usagestatistichour.FieldDeletedAt:
  38574. return m.DeletedAt()
  38575. case usagestatistichour.FieldAddtime:
  38576. return m.Addtime()
  38577. case usagestatistichour.FieldType:
  38578. return m.GetType()
  38579. case usagestatistichour.FieldBotID:
  38580. return m.BotID()
  38581. case usagestatistichour.FieldOrganizationID:
  38582. return m.OrganizationID()
  38583. case usagestatistichour.FieldAiResponse:
  38584. return m.AiResponse()
  38585. case usagestatistichour.FieldSopRun:
  38586. return m.SopRun()
  38587. case usagestatistichour.FieldTotalFriend:
  38588. return m.TotalFriend()
  38589. case usagestatistichour.FieldTotalGroup:
  38590. return m.TotalGroup()
  38591. case usagestatistichour.FieldAccountBalance:
  38592. return m.AccountBalance()
  38593. case usagestatistichour.FieldConsumeToken:
  38594. return m.ConsumeToken()
  38595. case usagestatistichour.FieldActiveUser:
  38596. return m.ActiveUser()
  38597. case usagestatistichour.FieldNewUser:
  38598. return m.NewUser()
  38599. case usagestatistichour.FieldLabelDist:
  38600. return m.LabelDist()
  38601. case usagestatistichour.FieldConsumeCoin:
  38602. return m.ConsumeCoin()
  38603. }
  38604. return nil, false
  38605. }
  38606. // OldField returns the old value of the field from the database. An error is
  38607. // returned if the mutation operation is not UpdateOne, or the query to the
  38608. // database failed.
  38609. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38610. switch name {
  38611. case usagestatistichour.FieldCreatedAt:
  38612. return m.OldCreatedAt(ctx)
  38613. case usagestatistichour.FieldUpdatedAt:
  38614. return m.OldUpdatedAt(ctx)
  38615. case usagestatistichour.FieldStatus:
  38616. return m.OldStatus(ctx)
  38617. case usagestatistichour.FieldDeletedAt:
  38618. return m.OldDeletedAt(ctx)
  38619. case usagestatistichour.FieldAddtime:
  38620. return m.OldAddtime(ctx)
  38621. case usagestatistichour.FieldType:
  38622. return m.OldType(ctx)
  38623. case usagestatistichour.FieldBotID:
  38624. return m.OldBotID(ctx)
  38625. case usagestatistichour.FieldOrganizationID:
  38626. return m.OldOrganizationID(ctx)
  38627. case usagestatistichour.FieldAiResponse:
  38628. return m.OldAiResponse(ctx)
  38629. case usagestatistichour.FieldSopRun:
  38630. return m.OldSopRun(ctx)
  38631. case usagestatistichour.FieldTotalFriend:
  38632. return m.OldTotalFriend(ctx)
  38633. case usagestatistichour.FieldTotalGroup:
  38634. return m.OldTotalGroup(ctx)
  38635. case usagestatistichour.FieldAccountBalance:
  38636. return m.OldAccountBalance(ctx)
  38637. case usagestatistichour.FieldConsumeToken:
  38638. return m.OldConsumeToken(ctx)
  38639. case usagestatistichour.FieldActiveUser:
  38640. return m.OldActiveUser(ctx)
  38641. case usagestatistichour.FieldNewUser:
  38642. return m.OldNewUser(ctx)
  38643. case usagestatistichour.FieldLabelDist:
  38644. return m.OldLabelDist(ctx)
  38645. case usagestatistichour.FieldConsumeCoin:
  38646. return m.OldConsumeCoin(ctx)
  38647. }
  38648. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38649. }
  38650. // SetField sets the value of a field with the given name. It returns an error if
  38651. // the field is not defined in the schema, or if the type mismatched the field
  38652. // type.
  38653. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  38654. switch name {
  38655. case usagestatistichour.FieldCreatedAt:
  38656. v, ok := value.(time.Time)
  38657. if !ok {
  38658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38659. }
  38660. m.SetCreatedAt(v)
  38661. return nil
  38662. case usagestatistichour.FieldUpdatedAt:
  38663. v, ok := value.(time.Time)
  38664. if !ok {
  38665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38666. }
  38667. m.SetUpdatedAt(v)
  38668. return nil
  38669. case usagestatistichour.FieldStatus:
  38670. v, ok := value.(uint8)
  38671. if !ok {
  38672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38673. }
  38674. m.SetStatus(v)
  38675. return nil
  38676. case usagestatistichour.FieldDeletedAt:
  38677. v, ok := value.(time.Time)
  38678. if !ok {
  38679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38680. }
  38681. m.SetDeletedAt(v)
  38682. return nil
  38683. case usagestatistichour.FieldAddtime:
  38684. v, ok := value.(uint64)
  38685. if !ok {
  38686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38687. }
  38688. m.SetAddtime(v)
  38689. return nil
  38690. case usagestatistichour.FieldType:
  38691. v, ok := value.(int)
  38692. if !ok {
  38693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38694. }
  38695. m.SetType(v)
  38696. return nil
  38697. case usagestatistichour.FieldBotID:
  38698. v, ok := value.(string)
  38699. if !ok {
  38700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38701. }
  38702. m.SetBotID(v)
  38703. return nil
  38704. case usagestatistichour.FieldOrganizationID:
  38705. v, ok := value.(uint64)
  38706. if !ok {
  38707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38708. }
  38709. m.SetOrganizationID(v)
  38710. return nil
  38711. case usagestatistichour.FieldAiResponse:
  38712. v, ok := value.(uint64)
  38713. if !ok {
  38714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38715. }
  38716. m.SetAiResponse(v)
  38717. return nil
  38718. case usagestatistichour.FieldSopRun:
  38719. v, ok := value.(uint64)
  38720. if !ok {
  38721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38722. }
  38723. m.SetSopRun(v)
  38724. return nil
  38725. case usagestatistichour.FieldTotalFriend:
  38726. v, ok := value.(uint64)
  38727. if !ok {
  38728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38729. }
  38730. m.SetTotalFriend(v)
  38731. return nil
  38732. case usagestatistichour.FieldTotalGroup:
  38733. v, ok := value.(uint64)
  38734. if !ok {
  38735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38736. }
  38737. m.SetTotalGroup(v)
  38738. return nil
  38739. case usagestatistichour.FieldAccountBalance:
  38740. v, ok := value.(uint64)
  38741. if !ok {
  38742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38743. }
  38744. m.SetAccountBalance(v)
  38745. return nil
  38746. case usagestatistichour.FieldConsumeToken:
  38747. v, ok := value.(uint64)
  38748. if !ok {
  38749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38750. }
  38751. m.SetConsumeToken(v)
  38752. return nil
  38753. case usagestatistichour.FieldActiveUser:
  38754. v, ok := value.(uint64)
  38755. if !ok {
  38756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38757. }
  38758. m.SetActiveUser(v)
  38759. return nil
  38760. case usagestatistichour.FieldNewUser:
  38761. v, ok := value.(int64)
  38762. if !ok {
  38763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38764. }
  38765. m.SetNewUser(v)
  38766. return nil
  38767. case usagestatistichour.FieldLabelDist:
  38768. v, ok := value.([]custom_types.LabelDist)
  38769. if !ok {
  38770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38771. }
  38772. m.SetLabelDist(v)
  38773. return nil
  38774. case usagestatistichour.FieldConsumeCoin:
  38775. v, ok := value.(float64)
  38776. if !ok {
  38777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38778. }
  38779. m.SetConsumeCoin(v)
  38780. return nil
  38781. }
  38782. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  38783. }
  38784. // AddedFields returns all numeric fields that were incremented/decremented during
  38785. // this mutation.
  38786. func (m *UsageStatisticHourMutation) AddedFields() []string {
  38787. var fields []string
  38788. if m.addstatus != nil {
  38789. fields = append(fields, usagestatistichour.FieldStatus)
  38790. }
  38791. if m.addaddtime != nil {
  38792. fields = append(fields, usagestatistichour.FieldAddtime)
  38793. }
  38794. if m.add_type != nil {
  38795. fields = append(fields, usagestatistichour.FieldType)
  38796. }
  38797. if m.addorganization_id != nil {
  38798. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38799. }
  38800. if m.addai_response != nil {
  38801. fields = append(fields, usagestatistichour.FieldAiResponse)
  38802. }
  38803. if m.addsop_run != nil {
  38804. fields = append(fields, usagestatistichour.FieldSopRun)
  38805. }
  38806. if m.addtotal_friend != nil {
  38807. fields = append(fields, usagestatistichour.FieldTotalFriend)
  38808. }
  38809. if m.addtotal_group != nil {
  38810. fields = append(fields, usagestatistichour.FieldTotalGroup)
  38811. }
  38812. if m.addaccount_balance != nil {
  38813. fields = append(fields, usagestatistichour.FieldAccountBalance)
  38814. }
  38815. if m.addconsume_token != nil {
  38816. fields = append(fields, usagestatistichour.FieldConsumeToken)
  38817. }
  38818. if m.addactive_user != nil {
  38819. fields = append(fields, usagestatistichour.FieldActiveUser)
  38820. }
  38821. if m.addnew_user != nil {
  38822. fields = append(fields, usagestatistichour.FieldNewUser)
  38823. }
  38824. if m.addconsume_coin != nil {
  38825. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38826. }
  38827. return fields
  38828. }
  38829. // AddedField returns the numeric value that was incremented/decremented on a field
  38830. // with the given name. The second boolean return value indicates that this field
  38831. // was not set, or was not defined in the schema.
  38832. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  38833. switch name {
  38834. case usagestatistichour.FieldStatus:
  38835. return m.AddedStatus()
  38836. case usagestatistichour.FieldAddtime:
  38837. return m.AddedAddtime()
  38838. case usagestatistichour.FieldType:
  38839. return m.AddedType()
  38840. case usagestatistichour.FieldOrganizationID:
  38841. return m.AddedOrganizationID()
  38842. case usagestatistichour.FieldAiResponse:
  38843. return m.AddedAiResponse()
  38844. case usagestatistichour.FieldSopRun:
  38845. return m.AddedSopRun()
  38846. case usagestatistichour.FieldTotalFriend:
  38847. return m.AddedTotalFriend()
  38848. case usagestatistichour.FieldTotalGroup:
  38849. return m.AddedTotalGroup()
  38850. case usagestatistichour.FieldAccountBalance:
  38851. return m.AddedAccountBalance()
  38852. case usagestatistichour.FieldConsumeToken:
  38853. return m.AddedConsumeToken()
  38854. case usagestatistichour.FieldActiveUser:
  38855. return m.AddedActiveUser()
  38856. case usagestatistichour.FieldNewUser:
  38857. return m.AddedNewUser()
  38858. case usagestatistichour.FieldConsumeCoin:
  38859. return m.AddedConsumeCoin()
  38860. }
  38861. return nil, false
  38862. }
  38863. // AddField adds the value to the field with the given name. It returns an error if
  38864. // the field is not defined in the schema, or if the type mismatched the field
  38865. // type.
  38866. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  38867. switch name {
  38868. case usagestatistichour.FieldStatus:
  38869. v, ok := value.(int8)
  38870. if !ok {
  38871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38872. }
  38873. m.AddStatus(v)
  38874. return nil
  38875. case usagestatistichour.FieldAddtime:
  38876. v, ok := value.(int64)
  38877. if !ok {
  38878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38879. }
  38880. m.AddAddtime(v)
  38881. return nil
  38882. case usagestatistichour.FieldType:
  38883. v, ok := value.(int)
  38884. if !ok {
  38885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38886. }
  38887. m.AddType(v)
  38888. return nil
  38889. case usagestatistichour.FieldOrganizationID:
  38890. v, ok := value.(int64)
  38891. if !ok {
  38892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38893. }
  38894. m.AddOrganizationID(v)
  38895. return nil
  38896. case usagestatistichour.FieldAiResponse:
  38897. v, ok := value.(int64)
  38898. if !ok {
  38899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38900. }
  38901. m.AddAiResponse(v)
  38902. return nil
  38903. case usagestatistichour.FieldSopRun:
  38904. v, ok := value.(int64)
  38905. if !ok {
  38906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38907. }
  38908. m.AddSopRun(v)
  38909. return nil
  38910. case usagestatistichour.FieldTotalFriend:
  38911. v, ok := value.(int64)
  38912. if !ok {
  38913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38914. }
  38915. m.AddTotalFriend(v)
  38916. return nil
  38917. case usagestatistichour.FieldTotalGroup:
  38918. v, ok := value.(int64)
  38919. if !ok {
  38920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38921. }
  38922. m.AddTotalGroup(v)
  38923. return nil
  38924. case usagestatistichour.FieldAccountBalance:
  38925. v, ok := value.(int64)
  38926. if !ok {
  38927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38928. }
  38929. m.AddAccountBalance(v)
  38930. return nil
  38931. case usagestatistichour.FieldConsumeToken:
  38932. v, ok := value.(int64)
  38933. if !ok {
  38934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38935. }
  38936. m.AddConsumeToken(v)
  38937. return nil
  38938. case usagestatistichour.FieldActiveUser:
  38939. v, ok := value.(int64)
  38940. if !ok {
  38941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38942. }
  38943. m.AddActiveUser(v)
  38944. return nil
  38945. case usagestatistichour.FieldNewUser:
  38946. v, ok := value.(int64)
  38947. if !ok {
  38948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38949. }
  38950. m.AddNewUser(v)
  38951. return nil
  38952. case usagestatistichour.FieldConsumeCoin:
  38953. v, ok := value.(float64)
  38954. if !ok {
  38955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38956. }
  38957. m.AddConsumeCoin(v)
  38958. return nil
  38959. }
  38960. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  38961. }
  38962. // ClearedFields returns all nullable fields that were cleared during this
  38963. // mutation.
  38964. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  38965. var fields []string
  38966. if m.FieldCleared(usagestatistichour.FieldStatus) {
  38967. fields = append(fields, usagestatistichour.FieldStatus)
  38968. }
  38969. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  38970. fields = append(fields, usagestatistichour.FieldDeletedAt)
  38971. }
  38972. if m.FieldCleared(usagestatistichour.FieldBotID) {
  38973. fields = append(fields, usagestatistichour.FieldBotID)
  38974. }
  38975. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  38976. fields = append(fields, usagestatistichour.FieldOrganizationID)
  38977. }
  38978. if m.FieldCleared(usagestatistichour.FieldConsumeCoin) {
  38979. fields = append(fields, usagestatistichour.FieldConsumeCoin)
  38980. }
  38981. return fields
  38982. }
  38983. // FieldCleared returns a boolean indicating if a field with the given name was
  38984. // cleared in this mutation.
  38985. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  38986. _, ok := m.clearedFields[name]
  38987. return ok
  38988. }
  38989. // ClearField clears the value of the field with the given name. It returns an
  38990. // error if the field is not defined in the schema.
  38991. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  38992. switch name {
  38993. case usagestatistichour.FieldStatus:
  38994. m.ClearStatus()
  38995. return nil
  38996. case usagestatistichour.FieldDeletedAt:
  38997. m.ClearDeletedAt()
  38998. return nil
  38999. case usagestatistichour.FieldBotID:
  39000. m.ClearBotID()
  39001. return nil
  39002. case usagestatistichour.FieldOrganizationID:
  39003. m.ClearOrganizationID()
  39004. return nil
  39005. case usagestatistichour.FieldConsumeCoin:
  39006. m.ClearConsumeCoin()
  39007. return nil
  39008. }
  39009. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  39010. }
  39011. // ResetField resets all changes in the mutation for the field with the given name.
  39012. // It returns an error if the field is not defined in the schema.
  39013. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  39014. switch name {
  39015. case usagestatistichour.FieldCreatedAt:
  39016. m.ResetCreatedAt()
  39017. return nil
  39018. case usagestatistichour.FieldUpdatedAt:
  39019. m.ResetUpdatedAt()
  39020. return nil
  39021. case usagestatistichour.FieldStatus:
  39022. m.ResetStatus()
  39023. return nil
  39024. case usagestatistichour.FieldDeletedAt:
  39025. m.ResetDeletedAt()
  39026. return nil
  39027. case usagestatistichour.FieldAddtime:
  39028. m.ResetAddtime()
  39029. return nil
  39030. case usagestatistichour.FieldType:
  39031. m.ResetType()
  39032. return nil
  39033. case usagestatistichour.FieldBotID:
  39034. m.ResetBotID()
  39035. return nil
  39036. case usagestatistichour.FieldOrganizationID:
  39037. m.ResetOrganizationID()
  39038. return nil
  39039. case usagestatistichour.FieldAiResponse:
  39040. m.ResetAiResponse()
  39041. return nil
  39042. case usagestatistichour.FieldSopRun:
  39043. m.ResetSopRun()
  39044. return nil
  39045. case usagestatistichour.FieldTotalFriend:
  39046. m.ResetTotalFriend()
  39047. return nil
  39048. case usagestatistichour.FieldTotalGroup:
  39049. m.ResetTotalGroup()
  39050. return nil
  39051. case usagestatistichour.FieldAccountBalance:
  39052. m.ResetAccountBalance()
  39053. return nil
  39054. case usagestatistichour.FieldConsumeToken:
  39055. m.ResetConsumeToken()
  39056. return nil
  39057. case usagestatistichour.FieldActiveUser:
  39058. m.ResetActiveUser()
  39059. return nil
  39060. case usagestatistichour.FieldNewUser:
  39061. m.ResetNewUser()
  39062. return nil
  39063. case usagestatistichour.FieldLabelDist:
  39064. m.ResetLabelDist()
  39065. return nil
  39066. case usagestatistichour.FieldConsumeCoin:
  39067. m.ResetConsumeCoin()
  39068. return nil
  39069. }
  39070. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  39071. }
  39072. // AddedEdges returns all edge names that were set/added in this mutation.
  39073. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  39074. edges := make([]string, 0, 0)
  39075. return edges
  39076. }
  39077. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39078. // name in this mutation.
  39079. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  39080. return nil
  39081. }
  39082. // RemovedEdges returns all edge names that were removed in this mutation.
  39083. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  39084. edges := make([]string, 0, 0)
  39085. return edges
  39086. }
  39087. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39088. // the given name in this mutation.
  39089. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  39090. return nil
  39091. }
  39092. // ClearedEdges returns all edge names that were cleared in this mutation.
  39093. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  39094. edges := make([]string, 0, 0)
  39095. return edges
  39096. }
  39097. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39098. // was cleared in this mutation.
  39099. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  39100. return false
  39101. }
  39102. // ClearEdge clears the value of the edge with the given name. It returns an error
  39103. // if that edge is not defined in the schema.
  39104. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  39105. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  39106. }
  39107. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39108. // It returns an error if the edge is not defined in the schema.
  39109. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  39110. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  39111. }
  39112. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  39113. type UsageStatisticMonthMutation struct {
  39114. config
  39115. op Op
  39116. typ string
  39117. id *uint64
  39118. created_at *time.Time
  39119. updated_at *time.Time
  39120. status *uint8
  39121. addstatus *int8
  39122. deleted_at *time.Time
  39123. addtime *uint64
  39124. addaddtime *int64
  39125. _type *int
  39126. add_type *int
  39127. bot_id *string
  39128. organization_id *uint64
  39129. addorganization_id *int64
  39130. ai_response *uint64
  39131. addai_response *int64
  39132. sop_run *uint64
  39133. addsop_run *int64
  39134. total_friend *uint64
  39135. addtotal_friend *int64
  39136. total_group *uint64
  39137. addtotal_group *int64
  39138. account_balance *uint64
  39139. addaccount_balance *int64
  39140. consume_token *uint64
  39141. addconsume_token *int64
  39142. active_user *uint64
  39143. addactive_user *int64
  39144. new_user *int64
  39145. addnew_user *int64
  39146. label_dist *[]custom_types.LabelDist
  39147. appendlabel_dist []custom_types.LabelDist
  39148. consume_coin *float64
  39149. addconsume_coin *float64
  39150. clearedFields map[string]struct{}
  39151. done bool
  39152. oldValue func(context.Context) (*UsageStatisticMonth, error)
  39153. predicates []predicate.UsageStatisticMonth
  39154. }
  39155. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  39156. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  39157. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  39158. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  39159. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  39160. m := &UsageStatisticMonthMutation{
  39161. config: c,
  39162. op: op,
  39163. typ: TypeUsageStatisticMonth,
  39164. clearedFields: make(map[string]struct{}),
  39165. }
  39166. for _, opt := range opts {
  39167. opt(m)
  39168. }
  39169. return m
  39170. }
  39171. // withUsageStatisticMonthID sets the ID field of the mutation.
  39172. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  39173. return func(m *UsageStatisticMonthMutation) {
  39174. var (
  39175. err error
  39176. once sync.Once
  39177. value *UsageStatisticMonth
  39178. )
  39179. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  39180. once.Do(func() {
  39181. if m.done {
  39182. err = errors.New("querying old values post mutation is not allowed")
  39183. } else {
  39184. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  39185. }
  39186. })
  39187. return value, err
  39188. }
  39189. m.id = &id
  39190. }
  39191. }
  39192. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  39193. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  39194. return func(m *UsageStatisticMonthMutation) {
  39195. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  39196. return node, nil
  39197. }
  39198. m.id = &node.ID
  39199. }
  39200. }
  39201. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39202. // executed in a transaction (ent.Tx), a transactional client is returned.
  39203. func (m UsageStatisticMonthMutation) Client() *Client {
  39204. client := &Client{config: m.config}
  39205. client.init()
  39206. return client
  39207. }
  39208. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39209. // it returns an error otherwise.
  39210. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  39211. if _, ok := m.driver.(*txDriver); !ok {
  39212. return nil, errors.New("ent: mutation is not running in a transaction")
  39213. }
  39214. tx := &Tx{config: m.config}
  39215. tx.init()
  39216. return tx, nil
  39217. }
  39218. // SetID sets the value of the id field. Note that this
  39219. // operation is only accepted on creation of UsageStatisticMonth entities.
  39220. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  39221. m.id = &id
  39222. }
  39223. // ID returns the ID value in the mutation. Note that the ID is only available
  39224. // if it was provided to the builder or after it was returned from the database.
  39225. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  39226. if m.id == nil {
  39227. return
  39228. }
  39229. return *m.id, true
  39230. }
  39231. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39232. // That means, if the mutation is applied within a transaction with an isolation level such
  39233. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39234. // or updated by the mutation.
  39235. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  39236. switch {
  39237. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39238. id, exists := m.ID()
  39239. if exists {
  39240. return []uint64{id}, nil
  39241. }
  39242. fallthrough
  39243. case m.op.Is(OpUpdate | OpDelete):
  39244. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  39245. default:
  39246. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39247. }
  39248. }
  39249. // SetCreatedAt sets the "created_at" field.
  39250. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  39251. m.created_at = &t
  39252. }
  39253. // CreatedAt returns the value of the "created_at" field in the mutation.
  39254. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  39255. v := m.created_at
  39256. if v == nil {
  39257. return
  39258. }
  39259. return *v, true
  39260. }
  39261. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  39262. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39264. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39265. if !m.op.Is(OpUpdateOne) {
  39266. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39267. }
  39268. if m.id == nil || m.oldValue == nil {
  39269. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39270. }
  39271. oldValue, err := m.oldValue(ctx)
  39272. if err != nil {
  39273. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39274. }
  39275. return oldValue.CreatedAt, nil
  39276. }
  39277. // ResetCreatedAt resets all changes to the "created_at" field.
  39278. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  39279. m.created_at = nil
  39280. }
  39281. // SetUpdatedAt sets the "updated_at" field.
  39282. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  39283. m.updated_at = &t
  39284. }
  39285. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39286. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  39287. v := m.updated_at
  39288. if v == nil {
  39289. return
  39290. }
  39291. return *v, true
  39292. }
  39293. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  39294. // If the UsageStatisticMonth 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 *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39297. if !m.op.Is(OpUpdateOne) {
  39298. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39299. }
  39300. if m.id == nil || m.oldValue == nil {
  39301. return v, errors.New("OldUpdatedAt 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 OldUpdatedAt: %w", err)
  39306. }
  39307. return oldValue.UpdatedAt, nil
  39308. }
  39309. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39310. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  39311. m.updated_at = nil
  39312. }
  39313. // SetStatus sets the "status" field.
  39314. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  39315. m.status = &u
  39316. m.addstatus = nil
  39317. }
  39318. // Status returns the value of the "status" field in the mutation.
  39319. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  39320. v := m.status
  39321. if v == nil {
  39322. return
  39323. }
  39324. return *v, true
  39325. }
  39326. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  39327. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39329. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  39330. if !m.op.Is(OpUpdateOne) {
  39331. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  39332. }
  39333. if m.id == nil || m.oldValue == nil {
  39334. return v, errors.New("OldStatus requires an ID field in the mutation")
  39335. }
  39336. oldValue, err := m.oldValue(ctx)
  39337. if err != nil {
  39338. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  39339. }
  39340. return oldValue.Status, nil
  39341. }
  39342. // AddStatus adds u to the "status" field.
  39343. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  39344. if m.addstatus != nil {
  39345. *m.addstatus += u
  39346. } else {
  39347. m.addstatus = &u
  39348. }
  39349. }
  39350. // AddedStatus returns the value that was added to the "status" field in this mutation.
  39351. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  39352. v := m.addstatus
  39353. if v == nil {
  39354. return
  39355. }
  39356. return *v, true
  39357. }
  39358. // ClearStatus clears the value of the "status" field.
  39359. func (m *UsageStatisticMonthMutation) ClearStatus() {
  39360. m.status = nil
  39361. m.addstatus = nil
  39362. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  39363. }
  39364. // StatusCleared returns if the "status" field was cleared in this mutation.
  39365. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  39366. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  39367. return ok
  39368. }
  39369. // ResetStatus resets all changes to the "status" field.
  39370. func (m *UsageStatisticMonthMutation) ResetStatus() {
  39371. m.status = nil
  39372. m.addstatus = nil
  39373. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  39374. }
  39375. // SetDeletedAt sets the "deleted_at" field.
  39376. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  39377. m.deleted_at = &t
  39378. }
  39379. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39380. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  39381. v := m.deleted_at
  39382. if v == nil {
  39383. return
  39384. }
  39385. return *v, true
  39386. }
  39387. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  39388. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39390. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39391. if !m.op.Is(OpUpdateOne) {
  39392. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39393. }
  39394. if m.id == nil || m.oldValue == nil {
  39395. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39396. }
  39397. oldValue, err := m.oldValue(ctx)
  39398. if err != nil {
  39399. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39400. }
  39401. return oldValue.DeletedAt, nil
  39402. }
  39403. // ClearDeletedAt clears the value of the "deleted_at" field.
  39404. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  39405. m.deleted_at = nil
  39406. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  39407. }
  39408. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39409. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  39410. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  39411. return ok
  39412. }
  39413. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39414. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  39415. m.deleted_at = nil
  39416. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  39417. }
  39418. // SetAddtime sets the "addtime" field.
  39419. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  39420. m.addtime = &u
  39421. m.addaddtime = nil
  39422. }
  39423. // Addtime returns the value of the "addtime" field in the mutation.
  39424. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  39425. v := m.addtime
  39426. if v == nil {
  39427. return
  39428. }
  39429. return *v, true
  39430. }
  39431. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  39432. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39434. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  39435. if !m.op.Is(OpUpdateOne) {
  39436. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  39437. }
  39438. if m.id == nil || m.oldValue == nil {
  39439. return v, errors.New("OldAddtime requires an ID field in the mutation")
  39440. }
  39441. oldValue, err := m.oldValue(ctx)
  39442. if err != nil {
  39443. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  39444. }
  39445. return oldValue.Addtime, nil
  39446. }
  39447. // AddAddtime adds u to the "addtime" field.
  39448. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  39449. if m.addaddtime != nil {
  39450. *m.addaddtime += u
  39451. } else {
  39452. m.addaddtime = &u
  39453. }
  39454. }
  39455. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  39456. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  39457. v := m.addaddtime
  39458. if v == nil {
  39459. return
  39460. }
  39461. return *v, true
  39462. }
  39463. // ResetAddtime resets all changes to the "addtime" field.
  39464. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  39465. m.addtime = nil
  39466. m.addaddtime = nil
  39467. }
  39468. // SetType sets the "type" field.
  39469. func (m *UsageStatisticMonthMutation) SetType(i int) {
  39470. m._type = &i
  39471. m.add_type = nil
  39472. }
  39473. // GetType returns the value of the "type" field in the mutation.
  39474. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  39475. v := m._type
  39476. if v == nil {
  39477. return
  39478. }
  39479. return *v, true
  39480. }
  39481. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  39482. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39484. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  39485. if !m.op.Is(OpUpdateOne) {
  39486. return v, errors.New("OldType is only allowed on UpdateOne operations")
  39487. }
  39488. if m.id == nil || m.oldValue == nil {
  39489. return v, errors.New("OldType requires an ID field in the mutation")
  39490. }
  39491. oldValue, err := m.oldValue(ctx)
  39492. if err != nil {
  39493. return v, fmt.Errorf("querying old value for OldType: %w", err)
  39494. }
  39495. return oldValue.Type, nil
  39496. }
  39497. // AddType adds i to the "type" field.
  39498. func (m *UsageStatisticMonthMutation) AddType(i int) {
  39499. if m.add_type != nil {
  39500. *m.add_type += i
  39501. } else {
  39502. m.add_type = &i
  39503. }
  39504. }
  39505. // AddedType returns the value that was added to the "type" field in this mutation.
  39506. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  39507. v := m.add_type
  39508. if v == nil {
  39509. return
  39510. }
  39511. return *v, true
  39512. }
  39513. // ResetType resets all changes to the "type" field.
  39514. func (m *UsageStatisticMonthMutation) ResetType() {
  39515. m._type = nil
  39516. m.add_type = nil
  39517. }
  39518. // SetBotID sets the "bot_id" field.
  39519. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  39520. m.bot_id = &s
  39521. }
  39522. // BotID returns the value of the "bot_id" field in the mutation.
  39523. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  39524. v := m.bot_id
  39525. if v == nil {
  39526. return
  39527. }
  39528. return *v, true
  39529. }
  39530. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  39531. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39533. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  39534. if !m.op.Is(OpUpdateOne) {
  39535. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39536. }
  39537. if m.id == nil || m.oldValue == nil {
  39538. return v, errors.New("OldBotID requires an ID field in the mutation")
  39539. }
  39540. oldValue, err := m.oldValue(ctx)
  39541. if err != nil {
  39542. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39543. }
  39544. return oldValue.BotID, nil
  39545. }
  39546. // ClearBotID clears the value of the "bot_id" field.
  39547. func (m *UsageStatisticMonthMutation) ClearBotID() {
  39548. m.bot_id = nil
  39549. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  39550. }
  39551. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  39552. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  39553. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  39554. return ok
  39555. }
  39556. // ResetBotID resets all changes to the "bot_id" field.
  39557. func (m *UsageStatisticMonthMutation) ResetBotID() {
  39558. m.bot_id = nil
  39559. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  39560. }
  39561. // SetOrganizationID sets the "organization_id" field.
  39562. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  39563. m.organization_id = &u
  39564. m.addorganization_id = nil
  39565. }
  39566. // OrganizationID returns the value of the "organization_id" field in the mutation.
  39567. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  39568. v := m.organization_id
  39569. if v == nil {
  39570. return
  39571. }
  39572. return *v, true
  39573. }
  39574. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  39575. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39577. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  39578. if !m.op.Is(OpUpdateOne) {
  39579. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  39580. }
  39581. if m.id == nil || m.oldValue == nil {
  39582. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  39583. }
  39584. oldValue, err := m.oldValue(ctx)
  39585. if err != nil {
  39586. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  39587. }
  39588. return oldValue.OrganizationID, nil
  39589. }
  39590. // AddOrganizationID adds u to the "organization_id" field.
  39591. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  39592. if m.addorganization_id != nil {
  39593. *m.addorganization_id += u
  39594. } else {
  39595. m.addorganization_id = &u
  39596. }
  39597. }
  39598. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  39599. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  39600. v := m.addorganization_id
  39601. if v == nil {
  39602. return
  39603. }
  39604. return *v, true
  39605. }
  39606. // ClearOrganizationID clears the value of the "organization_id" field.
  39607. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  39608. m.organization_id = nil
  39609. m.addorganization_id = nil
  39610. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  39611. }
  39612. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  39613. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  39614. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  39615. return ok
  39616. }
  39617. // ResetOrganizationID resets all changes to the "organization_id" field.
  39618. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  39619. m.organization_id = nil
  39620. m.addorganization_id = nil
  39621. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  39622. }
  39623. // SetAiResponse sets the "ai_response" field.
  39624. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  39625. m.ai_response = &u
  39626. m.addai_response = nil
  39627. }
  39628. // AiResponse returns the value of the "ai_response" field in the mutation.
  39629. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  39630. v := m.ai_response
  39631. if v == nil {
  39632. return
  39633. }
  39634. return *v, true
  39635. }
  39636. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  39637. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39639. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  39640. if !m.op.Is(OpUpdateOne) {
  39641. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  39642. }
  39643. if m.id == nil || m.oldValue == nil {
  39644. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  39645. }
  39646. oldValue, err := m.oldValue(ctx)
  39647. if err != nil {
  39648. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  39649. }
  39650. return oldValue.AiResponse, nil
  39651. }
  39652. // AddAiResponse adds u to the "ai_response" field.
  39653. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  39654. if m.addai_response != nil {
  39655. *m.addai_response += u
  39656. } else {
  39657. m.addai_response = &u
  39658. }
  39659. }
  39660. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  39661. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  39662. v := m.addai_response
  39663. if v == nil {
  39664. return
  39665. }
  39666. return *v, true
  39667. }
  39668. // ResetAiResponse resets all changes to the "ai_response" field.
  39669. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  39670. m.ai_response = nil
  39671. m.addai_response = nil
  39672. }
  39673. // SetSopRun sets the "sop_run" field.
  39674. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  39675. m.sop_run = &u
  39676. m.addsop_run = nil
  39677. }
  39678. // SopRun returns the value of the "sop_run" field in the mutation.
  39679. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  39680. v := m.sop_run
  39681. if v == nil {
  39682. return
  39683. }
  39684. return *v, true
  39685. }
  39686. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  39687. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39689. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  39690. if !m.op.Is(OpUpdateOne) {
  39691. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  39692. }
  39693. if m.id == nil || m.oldValue == nil {
  39694. return v, errors.New("OldSopRun requires an ID field in the mutation")
  39695. }
  39696. oldValue, err := m.oldValue(ctx)
  39697. if err != nil {
  39698. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  39699. }
  39700. return oldValue.SopRun, nil
  39701. }
  39702. // AddSopRun adds u to the "sop_run" field.
  39703. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  39704. if m.addsop_run != nil {
  39705. *m.addsop_run += u
  39706. } else {
  39707. m.addsop_run = &u
  39708. }
  39709. }
  39710. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  39711. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  39712. v := m.addsop_run
  39713. if v == nil {
  39714. return
  39715. }
  39716. return *v, true
  39717. }
  39718. // ResetSopRun resets all changes to the "sop_run" field.
  39719. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  39720. m.sop_run = nil
  39721. m.addsop_run = nil
  39722. }
  39723. // SetTotalFriend sets the "total_friend" field.
  39724. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  39725. m.total_friend = &u
  39726. m.addtotal_friend = nil
  39727. }
  39728. // TotalFriend returns the value of the "total_friend" field in the mutation.
  39729. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  39730. v := m.total_friend
  39731. if v == nil {
  39732. return
  39733. }
  39734. return *v, true
  39735. }
  39736. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  39737. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39739. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  39740. if !m.op.Is(OpUpdateOne) {
  39741. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  39742. }
  39743. if m.id == nil || m.oldValue == nil {
  39744. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  39745. }
  39746. oldValue, err := m.oldValue(ctx)
  39747. if err != nil {
  39748. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  39749. }
  39750. return oldValue.TotalFriend, nil
  39751. }
  39752. // AddTotalFriend adds u to the "total_friend" field.
  39753. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  39754. if m.addtotal_friend != nil {
  39755. *m.addtotal_friend += u
  39756. } else {
  39757. m.addtotal_friend = &u
  39758. }
  39759. }
  39760. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  39761. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  39762. v := m.addtotal_friend
  39763. if v == nil {
  39764. return
  39765. }
  39766. return *v, true
  39767. }
  39768. // ResetTotalFriend resets all changes to the "total_friend" field.
  39769. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  39770. m.total_friend = nil
  39771. m.addtotal_friend = nil
  39772. }
  39773. // SetTotalGroup sets the "total_group" field.
  39774. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  39775. m.total_group = &u
  39776. m.addtotal_group = nil
  39777. }
  39778. // TotalGroup returns the value of the "total_group" field in the mutation.
  39779. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  39780. v := m.total_group
  39781. if v == nil {
  39782. return
  39783. }
  39784. return *v, true
  39785. }
  39786. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  39787. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39788. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39789. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  39790. if !m.op.Is(OpUpdateOne) {
  39791. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  39792. }
  39793. if m.id == nil || m.oldValue == nil {
  39794. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  39795. }
  39796. oldValue, err := m.oldValue(ctx)
  39797. if err != nil {
  39798. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  39799. }
  39800. return oldValue.TotalGroup, nil
  39801. }
  39802. // AddTotalGroup adds u to the "total_group" field.
  39803. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  39804. if m.addtotal_group != nil {
  39805. *m.addtotal_group += u
  39806. } else {
  39807. m.addtotal_group = &u
  39808. }
  39809. }
  39810. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  39811. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  39812. v := m.addtotal_group
  39813. if v == nil {
  39814. return
  39815. }
  39816. return *v, true
  39817. }
  39818. // ResetTotalGroup resets all changes to the "total_group" field.
  39819. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  39820. m.total_group = nil
  39821. m.addtotal_group = nil
  39822. }
  39823. // SetAccountBalance sets the "account_balance" field.
  39824. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  39825. m.account_balance = &u
  39826. m.addaccount_balance = nil
  39827. }
  39828. // AccountBalance returns the value of the "account_balance" field in the mutation.
  39829. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  39830. v := m.account_balance
  39831. if v == nil {
  39832. return
  39833. }
  39834. return *v, true
  39835. }
  39836. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  39837. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39839. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  39840. if !m.op.Is(OpUpdateOne) {
  39841. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  39842. }
  39843. if m.id == nil || m.oldValue == nil {
  39844. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  39845. }
  39846. oldValue, err := m.oldValue(ctx)
  39847. if err != nil {
  39848. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  39849. }
  39850. return oldValue.AccountBalance, nil
  39851. }
  39852. // AddAccountBalance adds u to the "account_balance" field.
  39853. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  39854. if m.addaccount_balance != nil {
  39855. *m.addaccount_balance += u
  39856. } else {
  39857. m.addaccount_balance = &u
  39858. }
  39859. }
  39860. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  39861. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  39862. v := m.addaccount_balance
  39863. if v == nil {
  39864. return
  39865. }
  39866. return *v, true
  39867. }
  39868. // ResetAccountBalance resets all changes to the "account_balance" field.
  39869. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  39870. m.account_balance = nil
  39871. m.addaccount_balance = nil
  39872. }
  39873. // SetConsumeToken sets the "consume_token" field.
  39874. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  39875. m.consume_token = &u
  39876. m.addconsume_token = nil
  39877. }
  39878. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  39879. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  39880. v := m.consume_token
  39881. if v == nil {
  39882. return
  39883. }
  39884. return *v, true
  39885. }
  39886. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  39887. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39889. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  39890. if !m.op.Is(OpUpdateOne) {
  39891. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  39892. }
  39893. if m.id == nil || m.oldValue == nil {
  39894. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  39895. }
  39896. oldValue, err := m.oldValue(ctx)
  39897. if err != nil {
  39898. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  39899. }
  39900. return oldValue.ConsumeToken, nil
  39901. }
  39902. // AddConsumeToken adds u to the "consume_token" field.
  39903. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  39904. if m.addconsume_token != nil {
  39905. *m.addconsume_token += u
  39906. } else {
  39907. m.addconsume_token = &u
  39908. }
  39909. }
  39910. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  39911. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  39912. v := m.addconsume_token
  39913. if v == nil {
  39914. return
  39915. }
  39916. return *v, true
  39917. }
  39918. // ResetConsumeToken resets all changes to the "consume_token" field.
  39919. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  39920. m.consume_token = nil
  39921. m.addconsume_token = nil
  39922. }
  39923. // SetActiveUser sets the "active_user" field.
  39924. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  39925. m.active_user = &u
  39926. m.addactive_user = nil
  39927. }
  39928. // ActiveUser returns the value of the "active_user" field in the mutation.
  39929. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  39930. v := m.active_user
  39931. if v == nil {
  39932. return
  39933. }
  39934. return *v, true
  39935. }
  39936. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  39937. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39938. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39939. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  39940. if !m.op.Is(OpUpdateOne) {
  39941. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  39942. }
  39943. if m.id == nil || m.oldValue == nil {
  39944. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  39945. }
  39946. oldValue, err := m.oldValue(ctx)
  39947. if err != nil {
  39948. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  39949. }
  39950. return oldValue.ActiveUser, nil
  39951. }
  39952. // AddActiveUser adds u to the "active_user" field.
  39953. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  39954. if m.addactive_user != nil {
  39955. *m.addactive_user += u
  39956. } else {
  39957. m.addactive_user = &u
  39958. }
  39959. }
  39960. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  39961. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  39962. v := m.addactive_user
  39963. if v == nil {
  39964. return
  39965. }
  39966. return *v, true
  39967. }
  39968. // ResetActiveUser resets all changes to the "active_user" field.
  39969. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  39970. m.active_user = nil
  39971. m.addactive_user = nil
  39972. }
  39973. // SetNewUser sets the "new_user" field.
  39974. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  39975. m.new_user = &i
  39976. m.addnew_user = nil
  39977. }
  39978. // NewUser returns the value of the "new_user" field in the mutation.
  39979. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  39980. v := m.new_user
  39981. if v == nil {
  39982. return
  39983. }
  39984. return *v, true
  39985. }
  39986. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  39987. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  39988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39989. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  39990. if !m.op.Is(OpUpdateOne) {
  39991. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  39992. }
  39993. if m.id == nil || m.oldValue == nil {
  39994. return v, errors.New("OldNewUser requires an ID field in the mutation")
  39995. }
  39996. oldValue, err := m.oldValue(ctx)
  39997. if err != nil {
  39998. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  39999. }
  40000. return oldValue.NewUser, nil
  40001. }
  40002. // AddNewUser adds i to the "new_user" field.
  40003. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  40004. if m.addnew_user != nil {
  40005. *m.addnew_user += i
  40006. } else {
  40007. m.addnew_user = &i
  40008. }
  40009. }
  40010. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  40011. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  40012. v := m.addnew_user
  40013. if v == nil {
  40014. return
  40015. }
  40016. return *v, true
  40017. }
  40018. // ResetNewUser resets all changes to the "new_user" field.
  40019. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  40020. m.new_user = nil
  40021. m.addnew_user = nil
  40022. }
  40023. // SetLabelDist sets the "label_dist" field.
  40024. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  40025. m.label_dist = &ctd
  40026. m.appendlabel_dist = nil
  40027. }
  40028. // LabelDist returns the value of the "label_dist" field in the mutation.
  40029. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  40030. v := m.label_dist
  40031. if v == nil {
  40032. return
  40033. }
  40034. return *v, true
  40035. }
  40036. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  40037. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40039. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  40040. if !m.op.Is(OpUpdateOne) {
  40041. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  40042. }
  40043. if m.id == nil || m.oldValue == nil {
  40044. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  40045. }
  40046. oldValue, err := m.oldValue(ctx)
  40047. if err != nil {
  40048. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  40049. }
  40050. return oldValue.LabelDist, nil
  40051. }
  40052. // AppendLabelDist adds ctd to the "label_dist" field.
  40053. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  40054. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  40055. }
  40056. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  40057. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  40058. if len(m.appendlabel_dist) == 0 {
  40059. return nil, false
  40060. }
  40061. return m.appendlabel_dist, true
  40062. }
  40063. // ResetLabelDist resets all changes to the "label_dist" field.
  40064. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  40065. m.label_dist = nil
  40066. m.appendlabel_dist = nil
  40067. }
  40068. // SetConsumeCoin sets the "consume_coin" field.
  40069. func (m *UsageStatisticMonthMutation) SetConsumeCoin(f float64) {
  40070. m.consume_coin = &f
  40071. m.addconsume_coin = nil
  40072. }
  40073. // ConsumeCoin returns the value of the "consume_coin" field in the mutation.
  40074. func (m *UsageStatisticMonthMutation) ConsumeCoin() (r float64, exists bool) {
  40075. v := m.consume_coin
  40076. if v == nil {
  40077. return
  40078. }
  40079. return *v, true
  40080. }
  40081. // OldConsumeCoin returns the old "consume_coin" field's value of the UsageStatisticMonth entity.
  40082. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  40083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40084. func (m *UsageStatisticMonthMutation) OldConsumeCoin(ctx context.Context) (v float64, err error) {
  40085. if !m.op.Is(OpUpdateOne) {
  40086. return v, errors.New("OldConsumeCoin is only allowed on UpdateOne operations")
  40087. }
  40088. if m.id == nil || m.oldValue == nil {
  40089. return v, errors.New("OldConsumeCoin requires an ID field in the mutation")
  40090. }
  40091. oldValue, err := m.oldValue(ctx)
  40092. if err != nil {
  40093. return v, fmt.Errorf("querying old value for OldConsumeCoin: %w", err)
  40094. }
  40095. return oldValue.ConsumeCoin, nil
  40096. }
  40097. // AddConsumeCoin adds f to the "consume_coin" field.
  40098. func (m *UsageStatisticMonthMutation) AddConsumeCoin(f float64) {
  40099. if m.addconsume_coin != nil {
  40100. *m.addconsume_coin += f
  40101. } else {
  40102. m.addconsume_coin = &f
  40103. }
  40104. }
  40105. // AddedConsumeCoin returns the value that was added to the "consume_coin" field in this mutation.
  40106. func (m *UsageStatisticMonthMutation) AddedConsumeCoin() (r float64, exists bool) {
  40107. v := m.addconsume_coin
  40108. if v == nil {
  40109. return
  40110. }
  40111. return *v, true
  40112. }
  40113. // ClearConsumeCoin clears the value of the "consume_coin" field.
  40114. func (m *UsageStatisticMonthMutation) ClearConsumeCoin() {
  40115. m.consume_coin = nil
  40116. m.addconsume_coin = nil
  40117. m.clearedFields[usagestatisticmonth.FieldConsumeCoin] = struct{}{}
  40118. }
  40119. // ConsumeCoinCleared returns if the "consume_coin" field was cleared in this mutation.
  40120. func (m *UsageStatisticMonthMutation) ConsumeCoinCleared() bool {
  40121. _, ok := m.clearedFields[usagestatisticmonth.FieldConsumeCoin]
  40122. return ok
  40123. }
  40124. // ResetConsumeCoin resets all changes to the "consume_coin" field.
  40125. func (m *UsageStatisticMonthMutation) ResetConsumeCoin() {
  40126. m.consume_coin = nil
  40127. m.addconsume_coin = nil
  40128. delete(m.clearedFields, usagestatisticmonth.FieldConsumeCoin)
  40129. }
  40130. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  40131. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  40132. m.predicates = append(m.predicates, ps...)
  40133. }
  40134. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  40135. // users can use type-assertion to append predicates that do not depend on any generated package.
  40136. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  40137. p := make([]predicate.UsageStatisticMonth, len(ps))
  40138. for i := range ps {
  40139. p[i] = ps[i]
  40140. }
  40141. m.Where(p...)
  40142. }
  40143. // Op returns the operation name.
  40144. func (m *UsageStatisticMonthMutation) Op() Op {
  40145. return m.op
  40146. }
  40147. // SetOp allows setting the mutation operation.
  40148. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  40149. m.op = op
  40150. }
  40151. // Type returns the node type of this mutation (UsageStatisticMonth).
  40152. func (m *UsageStatisticMonthMutation) Type() string {
  40153. return m.typ
  40154. }
  40155. // Fields returns all fields that were changed during this mutation. Note that in
  40156. // order to get all numeric fields that were incremented/decremented, call
  40157. // AddedFields().
  40158. func (m *UsageStatisticMonthMutation) Fields() []string {
  40159. fields := make([]string, 0, 18)
  40160. if m.created_at != nil {
  40161. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  40162. }
  40163. if m.updated_at != nil {
  40164. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  40165. }
  40166. if m.status != nil {
  40167. fields = append(fields, usagestatisticmonth.FieldStatus)
  40168. }
  40169. if m.deleted_at != nil {
  40170. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40171. }
  40172. if m.addtime != nil {
  40173. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40174. }
  40175. if m._type != nil {
  40176. fields = append(fields, usagestatisticmonth.FieldType)
  40177. }
  40178. if m.bot_id != nil {
  40179. fields = append(fields, usagestatisticmonth.FieldBotID)
  40180. }
  40181. if m.organization_id != nil {
  40182. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40183. }
  40184. if m.ai_response != nil {
  40185. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40186. }
  40187. if m.sop_run != nil {
  40188. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40189. }
  40190. if m.total_friend != nil {
  40191. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40192. }
  40193. if m.total_group != nil {
  40194. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40195. }
  40196. if m.account_balance != nil {
  40197. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40198. }
  40199. if m.consume_token != nil {
  40200. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40201. }
  40202. if m.active_user != nil {
  40203. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40204. }
  40205. if m.new_user != nil {
  40206. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40207. }
  40208. if m.label_dist != nil {
  40209. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  40210. }
  40211. if m.consume_coin != nil {
  40212. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40213. }
  40214. return fields
  40215. }
  40216. // Field returns the value of a field with the given name. The second boolean
  40217. // return value indicates that this field was not set, or was not defined in the
  40218. // schema.
  40219. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  40220. switch name {
  40221. case usagestatisticmonth.FieldCreatedAt:
  40222. return m.CreatedAt()
  40223. case usagestatisticmonth.FieldUpdatedAt:
  40224. return m.UpdatedAt()
  40225. case usagestatisticmonth.FieldStatus:
  40226. return m.Status()
  40227. case usagestatisticmonth.FieldDeletedAt:
  40228. return m.DeletedAt()
  40229. case usagestatisticmonth.FieldAddtime:
  40230. return m.Addtime()
  40231. case usagestatisticmonth.FieldType:
  40232. return m.GetType()
  40233. case usagestatisticmonth.FieldBotID:
  40234. return m.BotID()
  40235. case usagestatisticmonth.FieldOrganizationID:
  40236. return m.OrganizationID()
  40237. case usagestatisticmonth.FieldAiResponse:
  40238. return m.AiResponse()
  40239. case usagestatisticmonth.FieldSopRun:
  40240. return m.SopRun()
  40241. case usagestatisticmonth.FieldTotalFriend:
  40242. return m.TotalFriend()
  40243. case usagestatisticmonth.FieldTotalGroup:
  40244. return m.TotalGroup()
  40245. case usagestatisticmonth.FieldAccountBalance:
  40246. return m.AccountBalance()
  40247. case usagestatisticmonth.FieldConsumeToken:
  40248. return m.ConsumeToken()
  40249. case usagestatisticmonth.FieldActiveUser:
  40250. return m.ActiveUser()
  40251. case usagestatisticmonth.FieldNewUser:
  40252. return m.NewUser()
  40253. case usagestatisticmonth.FieldLabelDist:
  40254. return m.LabelDist()
  40255. case usagestatisticmonth.FieldConsumeCoin:
  40256. return m.ConsumeCoin()
  40257. }
  40258. return nil, false
  40259. }
  40260. // OldField returns the old value of the field from the database. An error is
  40261. // returned if the mutation operation is not UpdateOne, or the query to the
  40262. // database failed.
  40263. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40264. switch name {
  40265. case usagestatisticmonth.FieldCreatedAt:
  40266. return m.OldCreatedAt(ctx)
  40267. case usagestatisticmonth.FieldUpdatedAt:
  40268. return m.OldUpdatedAt(ctx)
  40269. case usagestatisticmonth.FieldStatus:
  40270. return m.OldStatus(ctx)
  40271. case usagestatisticmonth.FieldDeletedAt:
  40272. return m.OldDeletedAt(ctx)
  40273. case usagestatisticmonth.FieldAddtime:
  40274. return m.OldAddtime(ctx)
  40275. case usagestatisticmonth.FieldType:
  40276. return m.OldType(ctx)
  40277. case usagestatisticmonth.FieldBotID:
  40278. return m.OldBotID(ctx)
  40279. case usagestatisticmonth.FieldOrganizationID:
  40280. return m.OldOrganizationID(ctx)
  40281. case usagestatisticmonth.FieldAiResponse:
  40282. return m.OldAiResponse(ctx)
  40283. case usagestatisticmonth.FieldSopRun:
  40284. return m.OldSopRun(ctx)
  40285. case usagestatisticmonth.FieldTotalFriend:
  40286. return m.OldTotalFriend(ctx)
  40287. case usagestatisticmonth.FieldTotalGroup:
  40288. return m.OldTotalGroup(ctx)
  40289. case usagestatisticmonth.FieldAccountBalance:
  40290. return m.OldAccountBalance(ctx)
  40291. case usagestatisticmonth.FieldConsumeToken:
  40292. return m.OldConsumeToken(ctx)
  40293. case usagestatisticmonth.FieldActiveUser:
  40294. return m.OldActiveUser(ctx)
  40295. case usagestatisticmonth.FieldNewUser:
  40296. return m.OldNewUser(ctx)
  40297. case usagestatisticmonth.FieldLabelDist:
  40298. return m.OldLabelDist(ctx)
  40299. case usagestatisticmonth.FieldConsumeCoin:
  40300. return m.OldConsumeCoin(ctx)
  40301. }
  40302. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40303. }
  40304. // SetField sets the value of a field with the given name. It returns an error if
  40305. // the field is not defined in the schema, or if the type mismatched the field
  40306. // type.
  40307. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  40308. switch name {
  40309. case usagestatisticmonth.FieldCreatedAt:
  40310. v, ok := value.(time.Time)
  40311. if !ok {
  40312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40313. }
  40314. m.SetCreatedAt(v)
  40315. return nil
  40316. case usagestatisticmonth.FieldUpdatedAt:
  40317. v, ok := value.(time.Time)
  40318. if !ok {
  40319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40320. }
  40321. m.SetUpdatedAt(v)
  40322. return nil
  40323. case usagestatisticmonth.FieldStatus:
  40324. v, ok := value.(uint8)
  40325. if !ok {
  40326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40327. }
  40328. m.SetStatus(v)
  40329. return nil
  40330. case usagestatisticmonth.FieldDeletedAt:
  40331. v, ok := value.(time.Time)
  40332. if !ok {
  40333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40334. }
  40335. m.SetDeletedAt(v)
  40336. return nil
  40337. case usagestatisticmonth.FieldAddtime:
  40338. v, ok := value.(uint64)
  40339. if !ok {
  40340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40341. }
  40342. m.SetAddtime(v)
  40343. return nil
  40344. case usagestatisticmonth.FieldType:
  40345. v, ok := value.(int)
  40346. if !ok {
  40347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40348. }
  40349. m.SetType(v)
  40350. return nil
  40351. case usagestatisticmonth.FieldBotID:
  40352. v, ok := value.(string)
  40353. if !ok {
  40354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40355. }
  40356. m.SetBotID(v)
  40357. return nil
  40358. case usagestatisticmonth.FieldOrganizationID:
  40359. v, ok := value.(uint64)
  40360. if !ok {
  40361. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40362. }
  40363. m.SetOrganizationID(v)
  40364. return nil
  40365. case usagestatisticmonth.FieldAiResponse:
  40366. v, ok := value.(uint64)
  40367. if !ok {
  40368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40369. }
  40370. m.SetAiResponse(v)
  40371. return nil
  40372. case usagestatisticmonth.FieldSopRun:
  40373. v, ok := value.(uint64)
  40374. if !ok {
  40375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40376. }
  40377. m.SetSopRun(v)
  40378. return nil
  40379. case usagestatisticmonth.FieldTotalFriend:
  40380. v, ok := value.(uint64)
  40381. if !ok {
  40382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40383. }
  40384. m.SetTotalFriend(v)
  40385. return nil
  40386. case usagestatisticmonth.FieldTotalGroup:
  40387. v, ok := value.(uint64)
  40388. if !ok {
  40389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40390. }
  40391. m.SetTotalGroup(v)
  40392. return nil
  40393. case usagestatisticmonth.FieldAccountBalance:
  40394. v, ok := value.(uint64)
  40395. if !ok {
  40396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40397. }
  40398. m.SetAccountBalance(v)
  40399. return nil
  40400. case usagestatisticmonth.FieldConsumeToken:
  40401. v, ok := value.(uint64)
  40402. if !ok {
  40403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40404. }
  40405. m.SetConsumeToken(v)
  40406. return nil
  40407. case usagestatisticmonth.FieldActiveUser:
  40408. v, ok := value.(uint64)
  40409. if !ok {
  40410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40411. }
  40412. m.SetActiveUser(v)
  40413. return nil
  40414. case usagestatisticmonth.FieldNewUser:
  40415. v, ok := value.(int64)
  40416. if !ok {
  40417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40418. }
  40419. m.SetNewUser(v)
  40420. return nil
  40421. case usagestatisticmonth.FieldLabelDist:
  40422. v, ok := value.([]custom_types.LabelDist)
  40423. if !ok {
  40424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40425. }
  40426. m.SetLabelDist(v)
  40427. return nil
  40428. case usagestatisticmonth.FieldConsumeCoin:
  40429. v, ok := value.(float64)
  40430. if !ok {
  40431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40432. }
  40433. m.SetConsumeCoin(v)
  40434. return nil
  40435. }
  40436. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40437. }
  40438. // AddedFields returns all numeric fields that were incremented/decremented during
  40439. // this mutation.
  40440. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  40441. var fields []string
  40442. if m.addstatus != nil {
  40443. fields = append(fields, usagestatisticmonth.FieldStatus)
  40444. }
  40445. if m.addaddtime != nil {
  40446. fields = append(fields, usagestatisticmonth.FieldAddtime)
  40447. }
  40448. if m.add_type != nil {
  40449. fields = append(fields, usagestatisticmonth.FieldType)
  40450. }
  40451. if m.addorganization_id != nil {
  40452. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40453. }
  40454. if m.addai_response != nil {
  40455. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  40456. }
  40457. if m.addsop_run != nil {
  40458. fields = append(fields, usagestatisticmonth.FieldSopRun)
  40459. }
  40460. if m.addtotal_friend != nil {
  40461. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  40462. }
  40463. if m.addtotal_group != nil {
  40464. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  40465. }
  40466. if m.addaccount_balance != nil {
  40467. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  40468. }
  40469. if m.addconsume_token != nil {
  40470. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  40471. }
  40472. if m.addactive_user != nil {
  40473. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  40474. }
  40475. if m.addnew_user != nil {
  40476. fields = append(fields, usagestatisticmonth.FieldNewUser)
  40477. }
  40478. if m.addconsume_coin != nil {
  40479. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40480. }
  40481. return fields
  40482. }
  40483. // AddedField returns the numeric value that was incremented/decremented on a field
  40484. // with the given name. The second boolean return value indicates that this field
  40485. // was not set, or was not defined in the schema.
  40486. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  40487. switch name {
  40488. case usagestatisticmonth.FieldStatus:
  40489. return m.AddedStatus()
  40490. case usagestatisticmonth.FieldAddtime:
  40491. return m.AddedAddtime()
  40492. case usagestatisticmonth.FieldType:
  40493. return m.AddedType()
  40494. case usagestatisticmonth.FieldOrganizationID:
  40495. return m.AddedOrganizationID()
  40496. case usagestatisticmonth.FieldAiResponse:
  40497. return m.AddedAiResponse()
  40498. case usagestatisticmonth.FieldSopRun:
  40499. return m.AddedSopRun()
  40500. case usagestatisticmonth.FieldTotalFriend:
  40501. return m.AddedTotalFriend()
  40502. case usagestatisticmonth.FieldTotalGroup:
  40503. return m.AddedTotalGroup()
  40504. case usagestatisticmonth.FieldAccountBalance:
  40505. return m.AddedAccountBalance()
  40506. case usagestatisticmonth.FieldConsumeToken:
  40507. return m.AddedConsumeToken()
  40508. case usagestatisticmonth.FieldActiveUser:
  40509. return m.AddedActiveUser()
  40510. case usagestatisticmonth.FieldNewUser:
  40511. return m.AddedNewUser()
  40512. case usagestatisticmonth.FieldConsumeCoin:
  40513. return m.AddedConsumeCoin()
  40514. }
  40515. return nil, false
  40516. }
  40517. // AddField adds the value to the field with the given name. It returns an error if
  40518. // the field is not defined in the schema, or if the type mismatched the field
  40519. // type.
  40520. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  40521. switch name {
  40522. case usagestatisticmonth.FieldStatus:
  40523. v, ok := value.(int8)
  40524. if !ok {
  40525. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40526. }
  40527. m.AddStatus(v)
  40528. return nil
  40529. case usagestatisticmonth.FieldAddtime:
  40530. v, ok := value.(int64)
  40531. if !ok {
  40532. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40533. }
  40534. m.AddAddtime(v)
  40535. return nil
  40536. case usagestatisticmonth.FieldType:
  40537. v, ok := value.(int)
  40538. if !ok {
  40539. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40540. }
  40541. m.AddType(v)
  40542. return nil
  40543. case usagestatisticmonth.FieldOrganizationID:
  40544. v, ok := value.(int64)
  40545. if !ok {
  40546. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40547. }
  40548. m.AddOrganizationID(v)
  40549. return nil
  40550. case usagestatisticmonth.FieldAiResponse:
  40551. v, ok := value.(int64)
  40552. if !ok {
  40553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40554. }
  40555. m.AddAiResponse(v)
  40556. return nil
  40557. case usagestatisticmonth.FieldSopRun:
  40558. v, ok := value.(int64)
  40559. if !ok {
  40560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40561. }
  40562. m.AddSopRun(v)
  40563. return nil
  40564. case usagestatisticmonth.FieldTotalFriend:
  40565. v, ok := value.(int64)
  40566. if !ok {
  40567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40568. }
  40569. m.AddTotalFriend(v)
  40570. return nil
  40571. case usagestatisticmonth.FieldTotalGroup:
  40572. v, ok := value.(int64)
  40573. if !ok {
  40574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40575. }
  40576. m.AddTotalGroup(v)
  40577. return nil
  40578. case usagestatisticmonth.FieldAccountBalance:
  40579. v, ok := value.(int64)
  40580. if !ok {
  40581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40582. }
  40583. m.AddAccountBalance(v)
  40584. return nil
  40585. case usagestatisticmonth.FieldConsumeToken:
  40586. v, ok := value.(int64)
  40587. if !ok {
  40588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40589. }
  40590. m.AddConsumeToken(v)
  40591. return nil
  40592. case usagestatisticmonth.FieldActiveUser:
  40593. v, ok := value.(int64)
  40594. if !ok {
  40595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40596. }
  40597. m.AddActiveUser(v)
  40598. return nil
  40599. case usagestatisticmonth.FieldNewUser:
  40600. v, ok := value.(int64)
  40601. if !ok {
  40602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40603. }
  40604. m.AddNewUser(v)
  40605. return nil
  40606. case usagestatisticmonth.FieldConsumeCoin:
  40607. v, ok := value.(float64)
  40608. if !ok {
  40609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40610. }
  40611. m.AddConsumeCoin(v)
  40612. return nil
  40613. }
  40614. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  40615. }
  40616. // ClearedFields returns all nullable fields that were cleared during this
  40617. // mutation.
  40618. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  40619. var fields []string
  40620. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  40621. fields = append(fields, usagestatisticmonth.FieldStatus)
  40622. }
  40623. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  40624. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  40625. }
  40626. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  40627. fields = append(fields, usagestatisticmonth.FieldBotID)
  40628. }
  40629. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  40630. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  40631. }
  40632. if m.FieldCleared(usagestatisticmonth.FieldConsumeCoin) {
  40633. fields = append(fields, usagestatisticmonth.FieldConsumeCoin)
  40634. }
  40635. return fields
  40636. }
  40637. // FieldCleared returns a boolean indicating if a field with the given name was
  40638. // cleared in this mutation.
  40639. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  40640. _, ok := m.clearedFields[name]
  40641. return ok
  40642. }
  40643. // ClearField clears the value of the field with the given name. It returns an
  40644. // error if the field is not defined in the schema.
  40645. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  40646. switch name {
  40647. case usagestatisticmonth.FieldStatus:
  40648. m.ClearStatus()
  40649. return nil
  40650. case usagestatisticmonth.FieldDeletedAt:
  40651. m.ClearDeletedAt()
  40652. return nil
  40653. case usagestatisticmonth.FieldBotID:
  40654. m.ClearBotID()
  40655. return nil
  40656. case usagestatisticmonth.FieldOrganizationID:
  40657. m.ClearOrganizationID()
  40658. return nil
  40659. case usagestatisticmonth.FieldConsumeCoin:
  40660. m.ClearConsumeCoin()
  40661. return nil
  40662. }
  40663. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  40664. }
  40665. // ResetField resets all changes in the mutation for the field with the given name.
  40666. // It returns an error if the field is not defined in the schema.
  40667. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  40668. switch name {
  40669. case usagestatisticmonth.FieldCreatedAt:
  40670. m.ResetCreatedAt()
  40671. return nil
  40672. case usagestatisticmonth.FieldUpdatedAt:
  40673. m.ResetUpdatedAt()
  40674. return nil
  40675. case usagestatisticmonth.FieldStatus:
  40676. m.ResetStatus()
  40677. return nil
  40678. case usagestatisticmonth.FieldDeletedAt:
  40679. m.ResetDeletedAt()
  40680. return nil
  40681. case usagestatisticmonth.FieldAddtime:
  40682. m.ResetAddtime()
  40683. return nil
  40684. case usagestatisticmonth.FieldType:
  40685. m.ResetType()
  40686. return nil
  40687. case usagestatisticmonth.FieldBotID:
  40688. m.ResetBotID()
  40689. return nil
  40690. case usagestatisticmonth.FieldOrganizationID:
  40691. m.ResetOrganizationID()
  40692. return nil
  40693. case usagestatisticmonth.FieldAiResponse:
  40694. m.ResetAiResponse()
  40695. return nil
  40696. case usagestatisticmonth.FieldSopRun:
  40697. m.ResetSopRun()
  40698. return nil
  40699. case usagestatisticmonth.FieldTotalFriend:
  40700. m.ResetTotalFriend()
  40701. return nil
  40702. case usagestatisticmonth.FieldTotalGroup:
  40703. m.ResetTotalGroup()
  40704. return nil
  40705. case usagestatisticmonth.FieldAccountBalance:
  40706. m.ResetAccountBalance()
  40707. return nil
  40708. case usagestatisticmonth.FieldConsumeToken:
  40709. m.ResetConsumeToken()
  40710. return nil
  40711. case usagestatisticmonth.FieldActiveUser:
  40712. m.ResetActiveUser()
  40713. return nil
  40714. case usagestatisticmonth.FieldNewUser:
  40715. m.ResetNewUser()
  40716. return nil
  40717. case usagestatisticmonth.FieldLabelDist:
  40718. m.ResetLabelDist()
  40719. return nil
  40720. case usagestatisticmonth.FieldConsumeCoin:
  40721. m.ResetConsumeCoin()
  40722. return nil
  40723. }
  40724. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  40725. }
  40726. // AddedEdges returns all edge names that were set/added in this mutation.
  40727. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  40728. edges := make([]string, 0, 0)
  40729. return edges
  40730. }
  40731. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40732. // name in this mutation.
  40733. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  40734. return nil
  40735. }
  40736. // RemovedEdges returns all edge names that were removed in this mutation.
  40737. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  40738. edges := make([]string, 0, 0)
  40739. return edges
  40740. }
  40741. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40742. // the given name in this mutation.
  40743. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  40744. return nil
  40745. }
  40746. // ClearedEdges returns all edge names that were cleared in this mutation.
  40747. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  40748. edges := make([]string, 0, 0)
  40749. return edges
  40750. }
  40751. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40752. // was cleared in this mutation.
  40753. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  40754. return false
  40755. }
  40756. // ClearEdge clears the value of the edge with the given name. It returns an error
  40757. // if that edge is not defined in the schema.
  40758. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  40759. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  40760. }
  40761. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40762. // It returns an error if the edge is not defined in the schema.
  40763. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  40764. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  40765. }
  40766. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  40767. type UsageTotalMutation struct {
  40768. config
  40769. op Op
  40770. typ string
  40771. id *uint64
  40772. created_at *time.Time
  40773. updated_at *time.Time
  40774. status *uint8
  40775. addstatus *int8
  40776. _type *int
  40777. add_type *int
  40778. bot_id *string
  40779. total_tokens *uint64
  40780. addtotal_tokens *int64
  40781. credits *float64
  40782. addcredits *float64
  40783. start_index *uint64
  40784. addstart_index *int64
  40785. end_index *uint64
  40786. addend_index *int64
  40787. organization_id *uint64
  40788. addorganization_id *int64
  40789. clearedFields map[string]struct{}
  40790. done bool
  40791. oldValue func(context.Context) (*UsageTotal, error)
  40792. predicates []predicate.UsageTotal
  40793. }
  40794. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  40795. // usagetotalOption allows management of the mutation configuration using functional options.
  40796. type usagetotalOption func(*UsageTotalMutation)
  40797. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  40798. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  40799. m := &UsageTotalMutation{
  40800. config: c,
  40801. op: op,
  40802. typ: TypeUsageTotal,
  40803. clearedFields: make(map[string]struct{}),
  40804. }
  40805. for _, opt := range opts {
  40806. opt(m)
  40807. }
  40808. return m
  40809. }
  40810. // withUsageTotalID sets the ID field of the mutation.
  40811. func withUsageTotalID(id uint64) usagetotalOption {
  40812. return func(m *UsageTotalMutation) {
  40813. var (
  40814. err error
  40815. once sync.Once
  40816. value *UsageTotal
  40817. )
  40818. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  40819. once.Do(func() {
  40820. if m.done {
  40821. err = errors.New("querying old values post mutation is not allowed")
  40822. } else {
  40823. value, err = m.Client().UsageTotal.Get(ctx, id)
  40824. }
  40825. })
  40826. return value, err
  40827. }
  40828. m.id = &id
  40829. }
  40830. }
  40831. // withUsageTotal sets the old UsageTotal of the mutation.
  40832. func withUsageTotal(node *UsageTotal) usagetotalOption {
  40833. return func(m *UsageTotalMutation) {
  40834. m.oldValue = func(context.Context) (*UsageTotal, error) {
  40835. return node, nil
  40836. }
  40837. m.id = &node.ID
  40838. }
  40839. }
  40840. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40841. // executed in a transaction (ent.Tx), a transactional client is returned.
  40842. func (m UsageTotalMutation) Client() *Client {
  40843. client := &Client{config: m.config}
  40844. client.init()
  40845. return client
  40846. }
  40847. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40848. // it returns an error otherwise.
  40849. func (m UsageTotalMutation) Tx() (*Tx, error) {
  40850. if _, ok := m.driver.(*txDriver); !ok {
  40851. return nil, errors.New("ent: mutation is not running in a transaction")
  40852. }
  40853. tx := &Tx{config: m.config}
  40854. tx.init()
  40855. return tx, nil
  40856. }
  40857. // SetID sets the value of the id field. Note that this
  40858. // operation is only accepted on creation of UsageTotal entities.
  40859. func (m *UsageTotalMutation) SetID(id uint64) {
  40860. m.id = &id
  40861. }
  40862. // ID returns the ID value in the mutation. Note that the ID is only available
  40863. // if it was provided to the builder or after it was returned from the database.
  40864. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  40865. if m.id == nil {
  40866. return
  40867. }
  40868. return *m.id, true
  40869. }
  40870. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40871. // That means, if the mutation is applied within a transaction with an isolation level such
  40872. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40873. // or updated by the mutation.
  40874. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  40875. switch {
  40876. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40877. id, exists := m.ID()
  40878. if exists {
  40879. return []uint64{id}, nil
  40880. }
  40881. fallthrough
  40882. case m.op.Is(OpUpdate | OpDelete):
  40883. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  40884. default:
  40885. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40886. }
  40887. }
  40888. // SetCreatedAt sets the "created_at" field.
  40889. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  40890. m.created_at = &t
  40891. }
  40892. // CreatedAt returns the value of the "created_at" field in the mutation.
  40893. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  40894. v := m.created_at
  40895. if v == nil {
  40896. return
  40897. }
  40898. return *v, true
  40899. }
  40900. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  40901. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40903. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40904. if !m.op.Is(OpUpdateOne) {
  40905. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40906. }
  40907. if m.id == nil || m.oldValue == nil {
  40908. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40909. }
  40910. oldValue, err := m.oldValue(ctx)
  40911. if err != nil {
  40912. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40913. }
  40914. return oldValue.CreatedAt, nil
  40915. }
  40916. // ResetCreatedAt resets all changes to the "created_at" field.
  40917. func (m *UsageTotalMutation) ResetCreatedAt() {
  40918. m.created_at = nil
  40919. }
  40920. // SetUpdatedAt sets the "updated_at" field.
  40921. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  40922. m.updated_at = &t
  40923. }
  40924. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40925. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  40926. v := m.updated_at
  40927. if v == nil {
  40928. return
  40929. }
  40930. return *v, true
  40931. }
  40932. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  40933. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40935. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40936. if !m.op.Is(OpUpdateOne) {
  40937. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40938. }
  40939. if m.id == nil || m.oldValue == nil {
  40940. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40941. }
  40942. oldValue, err := m.oldValue(ctx)
  40943. if err != nil {
  40944. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40945. }
  40946. return oldValue.UpdatedAt, nil
  40947. }
  40948. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40949. func (m *UsageTotalMutation) ResetUpdatedAt() {
  40950. m.updated_at = nil
  40951. }
  40952. // SetStatus sets the "status" field.
  40953. func (m *UsageTotalMutation) SetStatus(u uint8) {
  40954. m.status = &u
  40955. m.addstatus = nil
  40956. }
  40957. // Status returns the value of the "status" field in the mutation.
  40958. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  40959. v := m.status
  40960. if v == nil {
  40961. return
  40962. }
  40963. return *v, true
  40964. }
  40965. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  40966. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  40967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40968. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  40969. if !m.op.Is(OpUpdateOne) {
  40970. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  40971. }
  40972. if m.id == nil || m.oldValue == nil {
  40973. return v, errors.New("OldStatus requires an ID field in the mutation")
  40974. }
  40975. oldValue, err := m.oldValue(ctx)
  40976. if err != nil {
  40977. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  40978. }
  40979. return oldValue.Status, nil
  40980. }
  40981. // AddStatus adds u to the "status" field.
  40982. func (m *UsageTotalMutation) AddStatus(u int8) {
  40983. if m.addstatus != nil {
  40984. *m.addstatus += u
  40985. } else {
  40986. m.addstatus = &u
  40987. }
  40988. }
  40989. // AddedStatus returns the value that was added to the "status" field in this mutation.
  40990. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  40991. v := m.addstatus
  40992. if v == nil {
  40993. return
  40994. }
  40995. return *v, true
  40996. }
  40997. // ClearStatus clears the value of the "status" field.
  40998. func (m *UsageTotalMutation) ClearStatus() {
  40999. m.status = nil
  41000. m.addstatus = nil
  41001. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  41002. }
  41003. // StatusCleared returns if the "status" field was cleared in this mutation.
  41004. func (m *UsageTotalMutation) StatusCleared() bool {
  41005. _, ok := m.clearedFields[usagetotal.FieldStatus]
  41006. return ok
  41007. }
  41008. // ResetStatus resets all changes to the "status" field.
  41009. func (m *UsageTotalMutation) ResetStatus() {
  41010. m.status = nil
  41011. m.addstatus = nil
  41012. delete(m.clearedFields, usagetotal.FieldStatus)
  41013. }
  41014. // SetType sets the "type" field.
  41015. func (m *UsageTotalMutation) SetType(i int) {
  41016. m._type = &i
  41017. m.add_type = nil
  41018. }
  41019. // GetType returns the value of the "type" field in the mutation.
  41020. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  41021. v := m._type
  41022. if v == nil {
  41023. return
  41024. }
  41025. return *v, true
  41026. }
  41027. // OldType returns the old "type" field's value of the UsageTotal entity.
  41028. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41030. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  41031. if !m.op.Is(OpUpdateOne) {
  41032. return v, errors.New("OldType is only allowed on UpdateOne operations")
  41033. }
  41034. if m.id == nil || m.oldValue == nil {
  41035. return v, errors.New("OldType requires an ID field in the mutation")
  41036. }
  41037. oldValue, err := m.oldValue(ctx)
  41038. if err != nil {
  41039. return v, fmt.Errorf("querying old value for OldType: %w", err)
  41040. }
  41041. return oldValue.Type, nil
  41042. }
  41043. // AddType adds i to the "type" field.
  41044. func (m *UsageTotalMutation) AddType(i int) {
  41045. if m.add_type != nil {
  41046. *m.add_type += i
  41047. } else {
  41048. m.add_type = &i
  41049. }
  41050. }
  41051. // AddedType returns the value that was added to the "type" field in this mutation.
  41052. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  41053. v := m.add_type
  41054. if v == nil {
  41055. return
  41056. }
  41057. return *v, true
  41058. }
  41059. // ClearType clears the value of the "type" field.
  41060. func (m *UsageTotalMutation) ClearType() {
  41061. m._type = nil
  41062. m.add_type = nil
  41063. m.clearedFields[usagetotal.FieldType] = struct{}{}
  41064. }
  41065. // TypeCleared returns if the "type" field was cleared in this mutation.
  41066. func (m *UsageTotalMutation) TypeCleared() bool {
  41067. _, ok := m.clearedFields[usagetotal.FieldType]
  41068. return ok
  41069. }
  41070. // ResetType resets all changes to the "type" field.
  41071. func (m *UsageTotalMutation) ResetType() {
  41072. m._type = nil
  41073. m.add_type = nil
  41074. delete(m.clearedFields, usagetotal.FieldType)
  41075. }
  41076. // SetBotID sets the "bot_id" field.
  41077. func (m *UsageTotalMutation) SetBotID(s string) {
  41078. m.bot_id = &s
  41079. }
  41080. // BotID returns the value of the "bot_id" field in the mutation.
  41081. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  41082. v := m.bot_id
  41083. if v == nil {
  41084. return
  41085. }
  41086. return *v, true
  41087. }
  41088. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  41089. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41091. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  41092. if !m.op.Is(OpUpdateOne) {
  41093. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41094. }
  41095. if m.id == nil || m.oldValue == nil {
  41096. return v, errors.New("OldBotID requires an ID field in the mutation")
  41097. }
  41098. oldValue, err := m.oldValue(ctx)
  41099. if err != nil {
  41100. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41101. }
  41102. return oldValue.BotID, nil
  41103. }
  41104. // ResetBotID resets all changes to the "bot_id" field.
  41105. func (m *UsageTotalMutation) ResetBotID() {
  41106. m.bot_id = nil
  41107. }
  41108. // SetTotalTokens sets the "total_tokens" field.
  41109. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  41110. m.total_tokens = &u
  41111. m.addtotal_tokens = nil
  41112. }
  41113. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  41114. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  41115. v := m.total_tokens
  41116. if v == nil {
  41117. return
  41118. }
  41119. return *v, true
  41120. }
  41121. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  41122. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41124. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  41125. if !m.op.Is(OpUpdateOne) {
  41126. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  41127. }
  41128. if m.id == nil || m.oldValue == nil {
  41129. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  41130. }
  41131. oldValue, err := m.oldValue(ctx)
  41132. if err != nil {
  41133. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  41134. }
  41135. return oldValue.TotalTokens, nil
  41136. }
  41137. // AddTotalTokens adds u to the "total_tokens" field.
  41138. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  41139. if m.addtotal_tokens != nil {
  41140. *m.addtotal_tokens += u
  41141. } else {
  41142. m.addtotal_tokens = &u
  41143. }
  41144. }
  41145. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  41146. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  41147. v := m.addtotal_tokens
  41148. if v == nil {
  41149. return
  41150. }
  41151. return *v, true
  41152. }
  41153. // ClearTotalTokens clears the value of the "total_tokens" field.
  41154. func (m *UsageTotalMutation) ClearTotalTokens() {
  41155. m.total_tokens = nil
  41156. m.addtotal_tokens = nil
  41157. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  41158. }
  41159. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  41160. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  41161. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  41162. return ok
  41163. }
  41164. // ResetTotalTokens resets all changes to the "total_tokens" field.
  41165. func (m *UsageTotalMutation) ResetTotalTokens() {
  41166. m.total_tokens = nil
  41167. m.addtotal_tokens = nil
  41168. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  41169. }
  41170. // SetCredits sets the "credits" field.
  41171. func (m *UsageTotalMutation) SetCredits(f float64) {
  41172. m.credits = &f
  41173. m.addcredits = nil
  41174. }
  41175. // Credits returns the value of the "credits" field in the mutation.
  41176. func (m *UsageTotalMutation) Credits() (r float64, exists bool) {
  41177. v := m.credits
  41178. if v == nil {
  41179. return
  41180. }
  41181. return *v, true
  41182. }
  41183. // OldCredits returns the old "credits" field's value of the UsageTotal entity.
  41184. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41186. func (m *UsageTotalMutation) OldCredits(ctx context.Context) (v float64, err error) {
  41187. if !m.op.Is(OpUpdateOne) {
  41188. return v, errors.New("OldCredits is only allowed on UpdateOne operations")
  41189. }
  41190. if m.id == nil || m.oldValue == nil {
  41191. return v, errors.New("OldCredits requires an ID field in the mutation")
  41192. }
  41193. oldValue, err := m.oldValue(ctx)
  41194. if err != nil {
  41195. return v, fmt.Errorf("querying old value for OldCredits: %w", err)
  41196. }
  41197. return oldValue.Credits, nil
  41198. }
  41199. // AddCredits adds f to the "credits" field.
  41200. func (m *UsageTotalMutation) AddCredits(f float64) {
  41201. if m.addcredits != nil {
  41202. *m.addcredits += f
  41203. } else {
  41204. m.addcredits = &f
  41205. }
  41206. }
  41207. // AddedCredits returns the value that was added to the "credits" field in this mutation.
  41208. func (m *UsageTotalMutation) AddedCredits() (r float64, exists bool) {
  41209. v := m.addcredits
  41210. if v == nil {
  41211. return
  41212. }
  41213. return *v, true
  41214. }
  41215. // ClearCredits clears the value of the "credits" field.
  41216. func (m *UsageTotalMutation) ClearCredits() {
  41217. m.credits = nil
  41218. m.addcredits = nil
  41219. m.clearedFields[usagetotal.FieldCredits] = struct{}{}
  41220. }
  41221. // CreditsCleared returns if the "credits" field was cleared in this mutation.
  41222. func (m *UsageTotalMutation) CreditsCleared() bool {
  41223. _, ok := m.clearedFields[usagetotal.FieldCredits]
  41224. return ok
  41225. }
  41226. // ResetCredits resets all changes to the "credits" field.
  41227. func (m *UsageTotalMutation) ResetCredits() {
  41228. m.credits = nil
  41229. m.addcredits = nil
  41230. delete(m.clearedFields, usagetotal.FieldCredits)
  41231. }
  41232. // SetStartIndex sets the "start_index" field.
  41233. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  41234. m.start_index = &u
  41235. m.addstart_index = nil
  41236. }
  41237. // StartIndex returns the value of the "start_index" field in the mutation.
  41238. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  41239. v := m.start_index
  41240. if v == nil {
  41241. return
  41242. }
  41243. return *v, true
  41244. }
  41245. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  41246. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41248. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  41249. if !m.op.Is(OpUpdateOne) {
  41250. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  41251. }
  41252. if m.id == nil || m.oldValue == nil {
  41253. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  41254. }
  41255. oldValue, err := m.oldValue(ctx)
  41256. if err != nil {
  41257. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  41258. }
  41259. return oldValue.StartIndex, nil
  41260. }
  41261. // AddStartIndex adds u to the "start_index" field.
  41262. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  41263. if m.addstart_index != nil {
  41264. *m.addstart_index += u
  41265. } else {
  41266. m.addstart_index = &u
  41267. }
  41268. }
  41269. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  41270. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  41271. v := m.addstart_index
  41272. if v == nil {
  41273. return
  41274. }
  41275. return *v, true
  41276. }
  41277. // ClearStartIndex clears the value of the "start_index" field.
  41278. func (m *UsageTotalMutation) ClearStartIndex() {
  41279. m.start_index = nil
  41280. m.addstart_index = nil
  41281. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  41282. }
  41283. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  41284. func (m *UsageTotalMutation) StartIndexCleared() bool {
  41285. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  41286. return ok
  41287. }
  41288. // ResetStartIndex resets all changes to the "start_index" field.
  41289. func (m *UsageTotalMutation) ResetStartIndex() {
  41290. m.start_index = nil
  41291. m.addstart_index = nil
  41292. delete(m.clearedFields, usagetotal.FieldStartIndex)
  41293. }
  41294. // SetEndIndex sets the "end_index" field.
  41295. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  41296. m.end_index = &u
  41297. m.addend_index = nil
  41298. }
  41299. // EndIndex returns the value of the "end_index" field in the mutation.
  41300. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  41301. v := m.end_index
  41302. if v == nil {
  41303. return
  41304. }
  41305. return *v, true
  41306. }
  41307. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  41308. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41310. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  41311. if !m.op.Is(OpUpdateOne) {
  41312. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  41313. }
  41314. if m.id == nil || m.oldValue == nil {
  41315. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  41316. }
  41317. oldValue, err := m.oldValue(ctx)
  41318. if err != nil {
  41319. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  41320. }
  41321. return oldValue.EndIndex, nil
  41322. }
  41323. // AddEndIndex adds u to the "end_index" field.
  41324. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  41325. if m.addend_index != nil {
  41326. *m.addend_index += u
  41327. } else {
  41328. m.addend_index = &u
  41329. }
  41330. }
  41331. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  41332. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  41333. v := m.addend_index
  41334. if v == nil {
  41335. return
  41336. }
  41337. return *v, true
  41338. }
  41339. // ClearEndIndex clears the value of the "end_index" field.
  41340. func (m *UsageTotalMutation) ClearEndIndex() {
  41341. m.end_index = nil
  41342. m.addend_index = nil
  41343. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  41344. }
  41345. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  41346. func (m *UsageTotalMutation) EndIndexCleared() bool {
  41347. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  41348. return ok
  41349. }
  41350. // ResetEndIndex resets all changes to the "end_index" field.
  41351. func (m *UsageTotalMutation) ResetEndIndex() {
  41352. m.end_index = nil
  41353. m.addend_index = nil
  41354. delete(m.clearedFields, usagetotal.FieldEndIndex)
  41355. }
  41356. // SetOrganizationID sets the "organization_id" field.
  41357. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  41358. m.organization_id = &u
  41359. m.addorganization_id = nil
  41360. }
  41361. // OrganizationID returns the value of the "organization_id" field in the mutation.
  41362. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  41363. v := m.organization_id
  41364. if v == nil {
  41365. return
  41366. }
  41367. return *v, true
  41368. }
  41369. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  41370. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  41371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41372. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  41373. if !m.op.Is(OpUpdateOne) {
  41374. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  41375. }
  41376. if m.id == nil || m.oldValue == nil {
  41377. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  41378. }
  41379. oldValue, err := m.oldValue(ctx)
  41380. if err != nil {
  41381. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  41382. }
  41383. return oldValue.OrganizationID, nil
  41384. }
  41385. // AddOrganizationID adds u to the "organization_id" field.
  41386. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  41387. if m.addorganization_id != nil {
  41388. *m.addorganization_id += u
  41389. } else {
  41390. m.addorganization_id = &u
  41391. }
  41392. }
  41393. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  41394. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  41395. v := m.addorganization_id
  41396. if v == nil {
  41397. return
  41398. }
  41399. return *v, true
  41400. }
  41401. // ClearOrganizationID clears the value of the "organization_id" field.
  41402. func (m *UsageTotalMutation) ClearOrganizationID() {
  41403. m.organization_id = nil
  41404. m.addorganization_id = nil
  41405. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  41406. }
  41407. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  41408. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  41409. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  41410. return ok
  41411. }
  41412. // ResetOrganizationID resets all changes to the "organization_id" field.
  41413. func (m *UsageTotalMutation) ResetOrganizationID() {
  41414. m.organization_id = nil
  41415. m.addorganization_id = nil
  41416. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  41417. }
  41418. // Where appends a list predicates to the UsageTotalMutation builder.
  41419. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  41420. m.predicates = append(m.predicates, ps...)
  41421. }
  41422. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  41423. // users can use type-assertion to append predicates that do not depend on any generated package.
  41424. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  41425. p := make([]predicate.UsageTotal, len(ps))
  41426. for i := range ps {
  41427. p[i] = ps[i]
  41428. }
  41429. m.Where(p...)
  41430. }
  41431. // Op returns the operation name.
  41432. func (m *UsageTotalMutation) Op() Op {
  41433. return m.op
  41434. }
  41435. // SetOp allows setting the mutation operation.
  41436. func (m *UsageTotalMutation) SetOp(op Op) {
  41437. m.op = op
  41438. }
  41439. // Type returns the node type of this mutation (UsageTotal).
  41440. func (m *UsageTotalMutation) Type() string {
  41441. return m.typ
  41442. }
  41443. // Fields returns all fields that were changed during this mutation. Note that in
  41444. // order to get all numeric fields that were incremented/decremented, call
  41445. // AddedFields().
  41446. func (m *UsageTotalMutation) Fields() []string {
  41447. fields := make([]string, 0, 10)
  41448. if m.created_at != nil {
  41449. fields = append(fields, usagetotal.FieldCreatedAt)
  41450. }
  41451. if m.updated_at != nil {
  41452. fields = append(fields, usagetotal.FieldUpdatedAt)
  41453. }
  41454. if m.status != nil {
  41455. fields = append(fields, usagetotal.FieldStatus)
  41456. }
  41457. if m._type != nil {
  41458. fields = append(fields, usagetotal.FieldType)
  41459. }
  41460. if m.bot_id != nil {
  41461. fields = append(fields, usagetotal.FieldBotID)
  41462. }
  41463. if m.total_tokens != nil {
  41464. fields = append(fields, usagetotal.FieldTotalTokens)
  41465. }
  41466. if m.credits != nil {
  41467. fields = append(fields, usagetotal.FieldCredits)
  41468. }
  41469. if m.start_index != nil {
  41470. fields = append(fields, usagetotal.FieldStartIndex)
  41471. }
  41472. if m.end_index != nil {
  41473. fields = append(fields, usagetotal.FieldEndIndex)
  41474. }
  41475. if m.organization_id != nil {
  41476. fields = append(fields, usagetotal.FieldOrganizationID)
  41477. }
  41478. return fields
  41479. }
  41480. // Field returns the value of a field with the given name. The second boolean
  41481. // return value indicates that this field was not set, or was not defined in the
  41482. // schema.
  41483. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  41484. switch name {
  41485. case usagetotal.FieldCreatedAt:
  41486. return m.CreatedAt()
  41487. case usagetotal.FieldUpdatedAt:
  41488. return m.UpdatedAt()
  41489. case usagetotal.FieldStatus:
  41490. return m.Status()
  41491. case usagetotal.FieldType:
  41492. return m.GetType()
  41493. case usagetotal.FieldBotID:
  41494. return m.BotID()
  41495. case usagetotal.FieldTotalTokens:
  41496. return m.TotalTokens()
  41497. case usagetotal.FieldCredits:
  41498. return m.Credits()
  41499. case usagetotal.FieldStartIndex:
  41500. return m.StartIndex()
  41501. case usagetotal.FieldEndIndex:
  41502. return m.EndIndex()
  41503. case usagetotal.FieldOrganizationID:
  41504. return m.OrganizationID()
  41505. }
  41506. return nil, false
  41507. }
  41508. // OldField returns the old value of the field from the database. An error is
  41509. // returned if the mutation operation is not UpdateOne, or the query to the
  41510. // database failed.
  41511. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41512. switch name {
  41513. case usagetotal.FieldCreatedAt:
  41514. return m.OldCreatedAt(ctx)
  41515. case usagetotal.FieldUpdatedAt:
  41516. return m.OldUpdatedAt(ctx)
  41517. case usagetotal.FieldStatus:
  41518. return m.OldStatus(ctx)
  41519. case usagetotal.FieldType:
  41520. return m.OldType(ctx)
  41521. case usagetotal.FieldBotID:
  41522. return m.OldBotID(ctx)
  41523. case usagetotal.FieldTotalTokens:
  41524. return m.OldTotalTokens(ctx)
  41525. case usagetotal.FieldCredits:
  41526. return m.OldCredits(ctx)
  41527. case usagetotal.FieldStartIndex:
  41528. return m.OldStartIndex(ctx)
  41529. case usagetotal.FieldEndIndex:
  41530. return m.OldEndIndex(ctx)
  41531. case usagetotal.FieldOrganizationID:
  41532. return m.OldOrganizationID(ctx)
  41533. }
  41534. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  41535. }
  41536. // SetField sets the value of a field with the given name. It returns an error if
  41537. // the field is not defined in the schema, or if the type mismatched the field
  41538. // type.
  41539. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  41540. switch name {
  41541. case usagetotal.FieldCreatedAt:
  41542. v, ok := value.(time.Time)
  41543. if !ok {
  41544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41545. }
  41546. m.SetCreatedAt(v)
  41547. return nil
  41548. case usagetotal.FieldUpdatedAt:
  41549. v, ok := value.(time.Time)
  41550. if !ok {
  41551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41552. }
  41553. m.SetUpdatedAt(v)
  41554. return nil
  41555. case usagetotal.FieldStatus:
  41556. v, ok := value.(uint8)
  41557. if !ok {
  41558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41559. }
  41560. m.SetStatus(v)
  41561. return nil
  41562. case usagetotal.FieldType:
  41563. v, ok := value.(int)
  41564. if !ok {
  41565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41566. }
  41567. m.SetType(v)
  41568. return nil
  41569. case usagetotal.FieldBotID:
  41570. v, ok := value.(string)
  41571. if !ok {
  41572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41573. }
  41574. m.SetBotID(v)
  41575. return nil
  41576. case usagetotal.FieldTotalTokens:
  41577. v, ok := value.(uint64)
  41578. if !ok {
  41579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41580. }
  41581. m.SetTotalTokens(v)
  41582. return nil
  41583. case usagetotal.FieldCredits:
  41584. v, ok := value.(float64)
  41585. if !ok {
  41586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41587. }
  41588. m.SetCredits(v)
  41589. return nil
  41590. case usagetotal.FieldStartIndex:
  41591. v, ok := value.(uint64)
  41592. if !ok {
  41593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41594. }
  41595. m.SetStartIndex(v)
  41596. return nil
  41597. case usagetotal.FieldEndIndex:
  41598. v, ok := value.(uint64)
  41599. if !ok {
  41600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41601. }
  41602. m.SetEndIndex(v)
  41603. return nil
  41604. case usagetotal.FieldOrganizationID:
  41605. v, ok := value.(uint64)
  41606. if !ok {
  41607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41608. }
  41609. m.SetOrganizationID(v)
  41610. return nil
  41611. }
  41612. return fmt.Errorf("unknown UsageTotal field %s", name)
  41613. }
  41614. // AddedFields returns all numeric fields that were incremented/decremented during
  41615. // this mutation.
  41616. func (m *UsageTotalMutation) AddedFields() []string {
  41617. var fields []string
  41618. if m.addstatus != nil {
  41619. fields = append(fields, usagetotal.FieldStatus)
  41620. }
  41621. if m.add_type != nil {
  41622. fields = append(fields, usagetotal.FieldType)
  41623. }
  41624. if m.addtotal_tokens != nil {
  41625. fields = append(fields, usagetotal.FieldTotalTokens)
  41626. }
  41627. if m.addcredits != nil {
  41628. fields = append(fields, usagetotal.FieldCredits)
  41629. }
  41630. if m.addstart_index != nil {
  41631. fields = append(fields, usagetotal.FieldStartIndex)
  41632. }
  41633. if m.addend_index != nil {
  41634. fields = append(fields, usagetotal.FieldEndIndex)
  41635. }
  41636. if m.addorganization_id != nil {
  41637. fields = append(fields, usagetotal.FieldOrganizationID)
  41638. }
  41639. return fields
  41640. }
  41641. // AddedField returns the numeric value that was incremented/decremented on a field
  41642. // with the given name. The second boolean return value indicates that this field
  41643. // was not set, or was not defined in the schema.
  41644. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  41645. switch name {
  41646. case usagetotal.FieldStatus:
  41647. return m.AddedStatus()
  41648. case usagetotal.FieldType:
  41649. return m.AddedType()
  41650. case usagetotal.FieldTotalTokens:
  41651. return m.AddedTotalTokens()
  41652. case usagetotal.FieldCredits:
  41653. return m.AddedCredits()
  41654. case usagetotal.FieldStartIndex:
  41655. return m.AddedStartIndex()
  41656. case usagetotal.FieldEndIndex:
  41657. return m.AddedEndIndex()
  41658. case usagetotal.FieldOrganizationID:
  41659. return m.AddedOrganizationID()
  41660. }
  41661. return nil, false
  41662. }
  41663. // AddField adds the value to the field with the given name. It returns an error if
  41664. // the field is not defined in the schema, or if the type mismatched the field
  41665. // type.
  41666. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  41667. switch name {
  41668. case usagetotal.FieldStatus:
  41669. v, ok := value.(int8)
  41670. if !ok {
  41671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41672. }
  41673. m.AddStatus(v)
  41674. return nil
  41675. case usagetotal.FieldType:
  41676. v, ok := value.(int)
  41677. if !ok {
  41678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41679. }
  41680. m.AddType(v)
  41681. return nil
  41682. case usagetotal.FieldTotalTokens:
  41683. v, ok := value.(int64)
  41684. if !ok {
  41685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41686. }
  41687. m.AddTotalTokens(v)
  41688. return nil
  41689. case usagetotal.FieldCredits:
  41690. v, ok := value.(float64)
  41691. if !ok {
  41692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41693. }
  41694. m.AddCredits(v)
  41695. return nil
  41696. case usagetotal.FieldStartIndex:
  41697. v, ok := value.(int64)
  41698. if !ok {
  41699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41700. }
  41701. m.AddStartIndex(v)
  41702. return nil
  41703. case usagetotal.FieldEndIndex:
  41704. v, ok := value.(int64)
  41705. if !ok {
  41706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41707. }
  41708. m.AddEndIndex(v)
  41709. return nil
  41710. case usagetotal.FieldOrganizationID:
  41711. v, ok := value.(int64)
  41712. if !ok {
  41713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41714. }
  41715. m.AddOrganizationID(v)
  41716. return nil
  41717. }
  41718. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  41719. }
  41720. // ClearedFields returns all nullable fields that were cleared during this
  41721. // mutation.
  41722. func (m *UsageTotalMutation) ClearedFields() []string {
  41723. var fields []string
  41724. if m.FieldCleared(usagetotal.FieldStatus) {
  41725. fields = append(fields, usagetotal.FieldStatus)
  41726. }
  41727. if m.FieldCleared(usagetotal.FieldType) {
  41728. fields = append(fields, usagetotal.FieldType)
  41729. }
  41730. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  41731. fields = append(fields, usagetotal.FieldTotalTokens)
  41732. }
  41733. if m.FieldCleared(usagetotal.FieldCredits) {
  41734. fields = append(fields, usagetotal.FieldCredits)
  41735. }
  41736. if m.FieldCleared(usagetotal.FieldStartIndex) {
  41737. fields = append(fields, usagetotal.FieldStartIndex)
  41738. }
  41739. if m.FieldCleared(usagetotal.FieldEndIndex) {
  41740. fields = append(fields, usagetotal.FieldEndIndex)
  41741. }
  41742. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  41743. fields = append(fields, usagetotal.FieldOrganizationID)
  41744. }
  41745. return fields
  41746. }
  41747. // FieldCleared returns a boolean indicating if a field with the given name was
  41748. // cleared in this mutation.
  41749. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  41750. _, ok := m.clearedFields[name]
  41751. return ok
  41752. }
  41753. // ClearField clears the value of the field with the given name. It returns an
  41754. // error if the field is not defined in the schema.
  41755. func (m *UsageTotalMutation) ClearField(name string) error {
  41756. switch name {
  41757. case usagetotal.FieldStatus:
  41758. m.ClearStatus()
  41759. return nil
  41760. case usagetotal.FieldType:
  41761. m.ClearType()
  41762. return nil
  41763. case usagetotal.FieldTotalTokens:
  41764. m.ClearTotalTokens()
  41765. return nil
  41766. case usagetotal.FieldCredits:
  41767. m.ClearCredits()
  41768. return nil
  41769. case usagetotal.FieldStartIndex:
  41770. m.ClearStartIndex()
  41771. return nil
  41772. case usagetotal.FieldEndIndex:
  41773. m.ClearEndIndex()
  41774. return nil
  41775. case usagetotal.FieldOrganizationID:
  41776. m.ClearOrganizationID()
  41777. return nil
  41778. }
  41779. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  41780. }
  41781. // ResetField resets all changes in the mutation for the field with the given name.
  41782. // It returns an error if the field is not defined in the schema.
  41783. func (m *UsageTotalMutation) ResetField(name string) error {
  41784. switch name {
  41785. case usagetotal.FieldCreatedAt:
  41786. m.ResetCreatedAt()
  41787. return nil
  41788. case usagetotal.FieldUpdatedAt:
  41789. m.ResetUpdatedAt()
  41790. return nil
  41791. case usagetotal.FieldStatus:
  41792. m.ResetStatus()
  41793. return nil
  41794. case usagetotal.FieldType:
  41795. m.ResetType()
  41796. return nil
  41797. case usagetotal.FieldBotID:
  41798. m.ResetBotID()
  41799. return nil
  41800. case usagetotal.FieldTotalTokens:
  41801. m.ResetTotalTokens()
  41802. return nil
  41803. case usagetotal.FieldCredits:
  41804. m.ResetCredits()
  41805. return nil
  41806. case usagetotal.FieldStartIndex:
  41807. m.ResetStartIndex()
  41808. return nil
  41809. case usagetotal.FieldEndIndex:
  41810. m.ResetEndIndex()
  41811. return nil
  41812. case usagetotal.FieldOrganizationID:
  41813. m.ResetOrganizationID()
  41814. return nil
  41815. }
  41816. return fmt.Errorf("unknown UsageTotal field %s", name)
  41817. }
  41818. // AddedEdges returns all edge names that were set/added in this mutation.
  41819. func (m *UsageTotalMutation) AddedEdges() []string {
  41820. edges := make([]string, 0, 0)
  41821. return edges
  41822. }
  41823. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41824. // name in this mutation.
  41825. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  41826. return nil
  41827. }
  41828. // RemovedEdges returns all edge names that were removed in this mutation.
  41829. func (m *UsageTotalMutation) RemovedEdges() []string {
  41830. edges := make([]string, 0, 0)
  41831. return edges
  41832. }
  41833. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41834. // the given name in this mutation.
  41835. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  41836. return nil
  41837. }
  41838. // ClearedEdges returns all edge names that were cleared in this mutation.
  41839. func (m *UsageTotalMutation) ClearedEdges() []string {
  41840. edges := make([]string, 0, 0)
  41841. return edges
  41842. }
  41843. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41844. // was cleared in this mutation.
  41845. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  41846. return false
  41847. }
  41848. // ClearEdge clears the value of the edge with the given name. It returns an error
  41849. // if that edge is not defined in the schema.
  41850. func (m *UsageTotalMutation) ClearEdge(name string) error {
  41851. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  41852. }
  41853. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41854. // It returns an error if the edge is not defined in the schema.
  41855. func (m *UsageTotalMutation) ResetEdge(name string) error {
  41856. return fmt.Errorf("unknown UsageTotal edge %s", name)
  41857. }
  41858. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  41859. type WhatsappMutation struct {
  41860. config
  41861. op Op
  41862. typ string
  41863. id *uint64
  41864. created_at *time.Time
  41865. updated_at *time.Time
  41866. status *uint8
  41867. addstatus *int8
  41868. deleted_at *time.Time
  41869. wa_id *string
  41870. wa_name *string
  41871. callback *string
  41872. account *string
  41873. cc *string
  41874. phone *string
  41875. cc_phone *string
  41876. phone_name *string
  41877. phone_status *int8
  41878. addphone_status *int8
  41879. organization_id *uint64
  41880. addorganization_id *int64
  41881. api_base *string
  41882. api_key *string
  41883. allow_list *[]string
  41884. appendallow_list []string
  41885. group_allow_list *[]string
  41886. appendgroup_allow_list []string
  41887. block_list *[]string
  41888. appendblock_list []string
  41889. group_block_list *[]string
  41890. appendgroup_block_list []string
  41891. clearedFields map[string]struct{}
  41892. agent *uint64
  41893. clearedagent bool
  41894. done bool
  41895. oldValue func(context.Context) (*Whatsapp, error)
  41896. predicates []predicate.Whatsapp
  41897. }
  41898. var _ ent.Mutation = (*WhatsappMutation)(nil)
  41899. // whatsappOption allows management of the mutation configuration using functional options.
  41900. type whatsappOption func(*WhatsappMutation)
  41901. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  41902. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  41903. m := &WhatsappMutation{
  41904. config: c,
  41905. op: op,
  41906. typ: TypeWhatsapp,
  41907. clearedFields: make(map[string]struct{}),
  41908. }
  41909. for _, opt := range opts {
  41910. opt(m)
  41911. }
  41912. return m
  41913. }
  41914. // withWhatsappID sets the ID field of the mutation.
  41915. func withWhatsappID(id uint64) whatsappOption {
  41916. return func(m *WhatsappMutation) {
  41917. var (
  41918. err error
  41919. once sync.Once
  41920. value *Whatsapp
  41921. )
  41922. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  41923. once.Do(func() {
  41924. if m.done {
  41925. err = errors.New("querying old values post mutation is not allowed")
  41926. } else {
  41927. value, err = m.Client().Whatsapp.Get(ctx, id)
  41928. }
  41929. })
  41930. return value, err
  41931. }
  41932. m.id = &id
  41933. }
  41934. }
  41935. // withWhatsapp sets the old Whatsapp of the mutation.
  41936. func withWhatsapp(node *Whatsapp) whatsappOption {
  41937. return func(m *WhatsappMutation) {
  41938. m.oldValue = func(context.Context) (*Whatsapp, error) {
  41939. return node, nil
  41940. }
  41941. m.id = &node.ID
  41942. }
  41943. }
  41944. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41945. // executed in a transaction (ent.Tx), a transactional client is returned.
  41946. func (m WhatsappMutation) Client() *Client {
  41947. client := &Client{config: m.config}
  41948. client.init()
  41949. return client
  41950. }
  41951. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41952. // it returns an error otherwise.
  41953. func (m WhatsappMutation) Tx() (*Tx, error) {
  41954. if _, ok := m.driver.(*txDriver); !ok {
  41955. return nil, errors.New("ent: mutation is not running in a transaction")
  41956. }
  41957. tx := &Tx{config: m.config}
  41958. tx.init()
  41959. return tx, nil
  41960. }
  41961. // SetID sets the value of the id field. Note that this
  41962. // operation is only accepted on creation of Whatsapp entities.
  41963. func (m *WhatsappMutation) SetID(id uint64) {
  41964. m.id = &id
  41965. }
  41966. // ID returns the ID value in the mutation. Note that the ID is only available
  41967. // if it was provided to the builder or after it was returned from the database.
  41968. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  41969. if m.id == nil {
  41970. return
  41971. }
  41972. return *m.id, true
  41973. }
  41974. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41975. // That means, if the mutation is applied within a transaction with an isolation level such
  41976. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41977. // or updated by the mutation.
  41978. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  41979. switch {
  41980. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41981. id, exists := m.ID()
  41982. if exists {
  41983. return []uint64{id}, nil
  41984. }
  41985. fallthrough
  41986. case m.op.Is(OpUpdate | OpDelete):
  41987. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  41988. default:
  41989. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41990. }
  41991. }
  41992. // SetCreatedAt sets the "created_at" field.
  41993. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  41994. m.created_at = &t
  41995. }
  41996. // CreatedAt returns the value of the "created_at" field in the mutation.
  41997. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  41998. v := m.created_at
  41999. if v == nil {
  42000. return
  42001. }
  42002. return *v, true
  42003. }
  42004. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  42005. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42007. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  42008. if !m.op.Is(OpUpdateOne) {
  42009. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  42010. }
  42011. if m.id == nil || m.oldValue == nil {
  42012. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  42013. }
  42014. oldValue, err := m.oldValue(ctx)
  42015. if err != nil {
  42016. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  42017. }
  42018. return oldValue.CreatedAt, nil
  42019. }
  42020. // ResetCreatedAt resets all changes to the "created_at" field.
  42021. func (m *WhatsappMutation) ResetCreatedAt() {
  42022. m.created_at = nil
  42023. }
  42024. // SetUpdatedAt sets the "updated_at" field.
  42025. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  42026. m.updated_at = &t
  42027. }
  42028. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  42029. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  42030. v := m.updated_at
  42031. if v == nil {
  42032. return
  42033. }
  42034. return *v, true
  42035. }
  42036. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  42037. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42039. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  42040. if !m.op.Is(OpUpdateOne) {
  42041. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  42042. }
  42043. if m.id == nil || m.oldValue == nil {
  42044. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  42045. }
  42046. oldValue, err := m.oldValue(ctx)
  42047. if err != nil {
  42048. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  42049. }
  42050. return oldValue.UpdatedAt, nil
  42051. }
  42052. // ResetUpdatedAt resets all changes to the "updated_at" field.
  42053. func (m *WhatsappMutation) ResetUpdatedAt() {
  42054. m.updated_at = nil
  42055. }
  42056. // SetStatus sets the "status" field.
  42057. func (m *WhatsappMutation) SetStatus(u uint8) {
  42058. m.status = &u
  42059. m.addstatus = nil
  42060. }
  42061. // Status returns the value of the "status" field in the mutation.
  42062. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  42063. v := m.status
  42064. if v == nil {
  42065. return
  42066. }
  42067. return *v, true
  42068. }
  42069. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  42070. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42072. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  42073. if !m.op.Is(OpUpdateOne) {
  42074. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  42075. }
  42076. if m.id == nil || m.oldValue == nil {
  42077. return v, errors.New("OldStatus requires an ID field in the mutation")
  42078. }
  42079. oldValue, err := m.oldValue(ctx)
  42080. if err != nil {
  42081. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  42082. }
  42083. return oldValue.Status, nil
  42084. }
  42085. // AddStatus adds u to the "status" field.
  42086. func (m *WhatsappMutation) AddStatus(u int8) {
  42087. if m.addstatus != nil {
  42088. *m.addstatus += u
  42089. } else {
  42090. m.addstatus = &u
  42091. }
  42092. }
  42093. // AddedStatus returns the value that was added to the "status" field in this mutation.
  42094. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  42095. v := m.addstatus
  42096. if v == nil {
  42097. return
  42098. }
  42099. return *v, true
  42100. }
  42101. // ClearStatus clears the value of the "status" field.
  42102. func (m *WhatsappMutation) ClearStatus() {
  42103. m.status = nil
  42104. m.addstatus = nil
  42105. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  42106. }
  42107. // StatusCleared returns if the "status" field was cleared in this mutation.
  42108. func (m *WhatsappMutation) StatusCleared() bool {
  42109. _, ok := m.clearedFields[whatsapp.FieldStatus]
  42110. return ok
  42111. }
  42112. // ResetStatus resets all changes to the "status" field.
  42113. func (m *WhatsappMutation) ResetStatus() {
  42114. m.status = nil
  42115. m.addstatus = nil
  42116. delete(m.clearedFields, whatsapp.FieldStatus)
  42117. }
  42118. // SetDeletedAt sets the "deleted_at" field.
  42119. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  42120. m.deleted_at = &t
  42121. }
  42122. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  42123. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  42124. v := m.deleted_at
  42125. if v == nil {
  42126. return
  42127. }
  42128. return *v, true
  42129. }
  42130. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  42131. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42133. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  42134. if !m.op.Is(OpUpdateOne) {
  42135. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  42136. }
  42137. if m.id == nil || m.oldValue == nil {
  42138. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  42139. }
  42140. oldValue, err := m.oldValue(ctx)
  42141. if err != nil {
  42142. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  42143. }
  42144. return oldValue.DeletedAt, nil
  42145. }
  42146. // ClearDeletedAt clears the value of the "deleted_at" field.
  42147. func (m *WhatsappMutation) ClearDeletedAt() {
  42148. m.deleted_at = nil
  42149. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  42150. }
  42151. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  42152. func (m *WhatsappMutation) DeletedAtCleared() bool {
  42153. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  42154. return ok
  42155. }
  42156. // ResetDeletedAt resets all changes to the "deleted_at" field.
  42157. func (m *WhatsappMutation) ResetDeletedAt() {
  42158. m.deleted_at = nil
  42159. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  42160. }
  42161. // SetWaID sets the "wa_id" field.
  42162. func (m *WhatsappMutation) SetWaID(s string) {
  42163. m.wa_id = &s
  42164. }
  42165. // WaID returns the value of the "wa_id" field in the mutation.
  42166. func (m *WhatsappMutation) WaID() (r string, exists bool) {
  42167. v := m.wa_id
  42168. if v == nil {
  42169. return
  42170. }
  42171. return *v, true
  42172. }
  42173. // OldWaID returns the old "wa_id" field's value of the Whatsapp entity.
  42174. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42176. func (m *WhatsappMutation) OldWaID(ctx context.Context) (v string, err error) {
  42177. if !m.op.Is(OpUpdateOne) {
  42178. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  42179. }
  42180. if m.id == nil || m.oldValue == nil {
  42181. return v, errors.New("OldWaID requires an ID field in the mutation")
  42182. }
  42183. oldValue, err := m.oldValue(ctx)
  42184. if err != nil {
  42185. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  42186. }
  42187. return oldValue.WaID, nil
  42188. }
  42189. // ClearWaID clears the value of the "wa_id" field.
  42190. func (m *WhatsappMutation) ClearWaID() {
  42191. m.wa_id = nil
  42192. m.clearedFields[whatsapp.FieldWaID] = struct{}{}
  42193. }
  42194. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  42195. func (m *WhatsappMutation) WaIDCleared() bool {
  42196. _, ok := m.clearedFields[whatsapp.FieldWaID]
  42197. return ok
  42198. }
  42199. // ResetWaID resets all changes to the "wa_id" field.
  42200. func (m *WhatsappMutation) ResetWaID() {
  42201. m.wa_id = nil
  42202. delete(m.clearedFields, whatsapp.FieldWaID)
  42203. }
  42204. // SetWaName sets the "wa_name" field.
  42205. func (m *WhatsappMutation) SetWaName(s string) {
  42206. m.wa_name = &s
  42207. }
  42208. // WaName returns the value of the "wa_name" field in the mutation.
  42209. func (m *WhatsappMutation) WaName() (r string, exists bool) {
  42210. v := m.wa_name
  42211. if v == nil {
  42212. return
  42213. }
  42214. return *v, true
  42215. }
  42216. // OldWaName returns the old "wa_name" field's value of the Whatsapp entity.
  42217. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42219. func (m *WhatsappMutation) OldWaName(ctx context.Context) (v string, err error) {
  42220. if !m.op.Is(OpUpdateOne) {
  42221. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  42222. }
  42223. if m.id == nil || m.oldValue == nil {
  42224. return v, errors.New("OldWaName requires an ID field in the mutation")
  42225. }
  42226. oldValue, err := m.oldValue(ctx)
  42227. if err != nil {
  42228. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  42229. }
  42230. return oldValue.WaName, nil
  42231. }
  42232. // ClearWaName clears the value of the "wa_name" field.
  42233. func (m *WhatsappMutation) ClearWaName() {
  42234. m.wa_name = nil
  42235. m.clearedFields[whatsapp.FieldWaName] = struct{}{}
  42236. }
  42237. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  42238. func (m *WhatsappMutation) WaNameCleared() bool {
  42239. _, ok := m.clearedFields[whatsapp.FieldWaName]
  42240. return ok
  42241. }
  42242. // ResetWaName resets all changes to the "wa_name" field.
  42243. func (m *WhatsappMutation) ResetWaName() {
  42244. m.wa_name = nil
  42245. delete(m.clearedFields, whatsapp.FieldWaName)
  42246. }
  42247. // SetCallback sets the "callback" field.
  42248. func (m *WhatsappMutation) SetCallback(s string) {
  42249. m.callback = &s
  42250. }
  42251. // Callback returns the value of the "callback" field in the mutation.
  42252. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  42253. v := m.callback
  42254. if v == nil {
  42255. return
  42256. }
  42257. return *v, true
  42258. }
  42259. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  42260. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42262. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  42263. if !m.op.Is(OpUpdateOne) {
  42264. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  42265. }
  42266. if m.id == nil || m.oldValue == nil {
  42267. return v, errors.New("OldCallback requires an ID field in the mutation")
  42268. }
  42269. oldValue, err := m.oldValue(ctx)
  42270. if err != nil {
  42271. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  42272. }
  42273. return oldValue.Callback, nil
  42274. }
  42275. // ClearCallback clears the value of the "callback" field.
  42276. func (m *WhatsappMutation) ClearCallback() {
  42277. m.callback = nil
  42278. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  42279. }
  42280. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  42281. func (m *WhatsappMutation) CallbackCleared() bool {
  42282. _, ok := m.clearedFields[whatsapp.FieldCallback]
  42283. return ok
  42284. }
  42285. // ResetCallback resets all changes to the "callback" field.
  42286. func (m *WhatsappMutation) ResetCallback() {
  42287. m.callback = nil
  42288. delete(m.clearedFields, whatsapp.FieldCallback)
  42289. }
  42290. // SetAgentID sets the "agent_id" field.
  42291. func (m *WhatsappMutation) SetAgentID(u uint64) {
  42292. m.agent = &u
  42293. }
  42294. // AgentID returns the value of the "agent_id" field in the mutation.
  42295. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  42296. v := m.agent
  42297. if v == nil {
  42298. return
  42299. }
  42300. return *v, true
  42301. }
  42302. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  42303. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42305. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  42306. if !m.op.Is(OpUpdateOne) {
  42307. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  42308. }
  42309. if m.id == nil || m.oldValue == nil {
  42310. return v, errors.New("OldAgentID requires an ID field in the mutation")
  42311. }
  42312. oldValue, err := m.oldValue(ctx)
  42313. if err != nil {
  42314. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  42315. }
  42316. return oldValue.AgentID, nil
  42317. }
  42318. // ResetAgentID resets all changes to the "agent_id" field.
  42319. func (m *WhatsappMutation) ResetAgentID() {
  42320. m.agent = nil
  42321. }
  42322. // SetAccount sets the "account" field.
  42323. func (m *WhatsappMutation) SetAccount(s string) {
  42324. m.account = &s
  42325. }
  42326. // Account returns the value of the "account" field in the mutation.
  42327. func (m *WhatsappMutation) Account() (r string, exists bool) {
  42328. v := m.account
  42329. if v == nil {
  42330. return
  42331. }
  42332. return *v, true
  42333. }
  42334. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  42335. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42337. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  42338. if !m.op.Is(OpUpdateOne) {
  42339. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  42340. }
  42341. if m.id == nil || m.oldValue == nil {
  42342. return v, errors.New("OldAccount requires an ID field in the mutation")
  42343. }
  42344. oldValue, err := m.oldValue(ctx)
  42345. if err != nil {
  42346. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  42347. }
  42348. return oldValue.Account, nil
  42349. }
  42350. // ClearAccount clears the value of the "account" field.
  42351. func (m *WhatsappMutation) ClearAccount() {
  42352. m.account = nil
  42353. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  42354. }
  42355. // AccountCleared returns if the "account" field was cleared in this mutation.
  42356. func (m *WhatsappMutation) AccountCleared() bool {
  42357. _, ok := m.clearedFields[whatsapp.FieldAccount]
  42358. return ok
  42359. }
  42360. // ResetAccount resets all changes to the "account" field.
  42361. func (m *WhatsappMutation) ResetAccount() {
  42362. m.account = nil
  42363. delete(m.clearedFields, whatsapp.FieldAccount)
  42364. }
  42365. // SetCc sets the "cc" field.
  42366. func (m *WhatsappMutation) SetCc(s string) {
  42367. m.cc = &s
  42368. }
  42369. // Cc returns the value of the "cc" field in the mutation.
  42370. func (m *WhatsappMutation) Cc() (r string, exists bool) {
  42371. v := m.cc
  42372. if v == nil {
  42373. return
  42374. }
  42375. return *v, true
  42376. }
  42377. // OldCc returns the old "cc" field's value of the Whatsapp entity.
  42378. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42379. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42380. func (m *WhatsappMutation) OldCc(ctx context.Context) (v string, err error) {
  42381. if !m.op.Is(OpUpdateOne) {
  42382. return v, errors.New("OldCc is only allowed on UpdateOne operations")
  42383. }
  42384. if m.id == nil || m.oldValue == nil {
  42385. return v, errors.New("OldCc requires an ID field in the mutation")
  42386. }
  42387. oldValue, err := m.oldValue(ctx)
  42388. if err != nil {
  42389. return v, fmt.Errorf("querying old value for OldCc: %w", err)
  42390. }
  42391. return oldValue.Cc, nil
  42392. }
  42393. // ResetCc resets all changes to the "cc" field.
  42394. func (m *WhatsappMutation) ResetCc() {
  42395. m.cc = nil
  42396. }
  42397. // SetPhone sets the "phone" field.
  42398. func (m *WhatsappMutation) SetPhone(s string) {
  42399. m.phone = &s
  42400. }
  42401. // Phone returns the value of the "phone" field in the mutation.
  42402. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  42403. v := m.phone
  42404. if v == nil {
  42405. return
  42406. }
  42407. return *v, true
  42408. }
  42409. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  42410. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42412. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  42413. if !m.op.Is(OpUpdateOne) {
  42414. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  42415. }
  42416. if m.id == nil || m.oldValue == nil {
  42417. return v, errors.New("OldPhone requires an ID field in the mutation")
  42418. }
  42419. oldValue, err := m.oldValue(ctx)
  42420. if err != nil {
  42421. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  42422. }
  42423. return oldValue.Phone, nil
  42424. }
  42425. // ResetPhone resets all changes to the "phone" field.
  42426. func (m *WhatsappMutation) ResetPhone() {
  42427. m.phone = nil
  42428. }
  42429. // SetCcPhone sets the "cc_phone" field.
  42430. func (m *WhatsappMutation) SetCcPhone(s string) {
  42431. m.cc_phone = &s
  42432. }
  42433. // CcPhone returns the value of the "cc_phone" field in the mutation.
  42434. func (m *WhatsappMutation) CcPhone() (r string, exists bool) {
  42435. v := m.cc_phone
  42436. if v == nil {
  42437. return
  42438. }
  42439. return *v, true
  42440. }
  42441. // OldCcPhone returns the old "cc_phone" field's value of the Whatsapp entity.
  42442. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42444. func (m *WhatsappMutation) OldCcPhone(ctx context.Context) (v string, err error) {
  42445. if !m.op.Is(OpUpdateOne) {
  42446. return v, errors.New("OldCcPhone is only allowed on UpdateOne operations")
  42447. }
  42448. if m.id == nil || m.oldValue == nil {
  42449. return v, errors.New("OldCcPhone requires an ID field in the mutation")
  42450. }
  42451. oldValue, err := m.oldValue(ctx)
  42452. if err != nil {
  42453. return v, fmt.Errorf("querying old value for OldCcPhone: %w", err)
  42454. }
  42455. return oldValue.CcPhone, nil
  42456. }
  42457. // ResetCcPhone resets all changes to the "cc_phone" field.
  42458. func (m *WhatsappMutation) ResetCcPhone() {
  42459. m.cc_phone = nil
  42460. }
  42461. // SetPhoneName sets the "phone_name" field.
  42462. func (m *WhatsappMutation) SetPhoneName(s string) {
  42463. m.phone_name = &s
  42464. }
  42465. // PhoneName returns the value of the "phone_name" field in the mutation.
  42466. func (m *WhatsappMutation) PhoneName() (r string, exists bool) {
  42467. v := m.phone_name
  42468. if v == nil {
  42469. return
  42470. }
  42471. return *v, true
  42472. }
  42473. // OldPhoneName returns the old "phone_name" field's value of the Whatsapp entity.
  42474. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42476. func (m *WhatsappMutation) OldPhoneName(ctx context.Context) (v string, err error) {
  42477. if !m.op.Is(OpUpdateOne) {
  42478. return v, errors.New("OldPhoneName is only allowed on UpdateOne operations")
  42479. }
  42480. if m.id == nil || m.oldValue == nil {
  42481. return v, errors.New("OldPhoneName requires an ID field in the mutation")
  42482. }
  42483. oldValue, err := m.oldValue(ctx)
  42484. if err != nil {
  42485. return v, fmt.Errorf("querying old value for OldPhoneName: %w", err)
  42486. }
  42487. return oldValue.PhoneName, nil
  42488. }
  42489. // ResetPhoneName resets all changes to the "phone_name" field.
  42490. func (m *WhatsappMutation) ResetPhoneName() {
  42491. m.phone_name = nil
  42492. }
  42493. // SetPhoneStatus sets the "phone_status" field.
  42494. func (m *WhatsappMutation) SetPhoneStatus(i int8) {
  42495. m.phone_status = &i
  42496. m.addphone_status = nil
  42497. }
  42498. // PhoneStatus returns the value of the "phone_status" field in the mutation.
  42499. func (m *WhatsappMutation) PhoneStatus() (r int8, exists bool) {
  42500. v := m.phone_status
  42501. if v == nil {
  42502. return
  42503. }
  42504. return *v, true
  42505. }
  42506. // OldPhoneStatus returns the old "phone_status" field's value of the Whatsapp entity.
  42507. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42509. func (m *WhatsappMutation) OldPhoneStatus(ctx context.Context) (v int8, err error) {
  42510. if !m.op.Is(OpUpdateOne) {
  42511. return v, errors.New("OldPhoneStatus is only allowed on UpdateOne operations")
  42512. }
  42513. if m.id == nil || m.oldValue == nil {
  42514. return v, errors.New("OldPhoneStatus requires an ID field in the mutation")
  42515. }
  42516. oldValue, err := m.oldValue(ctx)
  42517. if err != nil {
  42518. return v, fmt.Errorf("querying old value for OldPhoneStatus: %w", err)
  42519. }
  42520. return oldValue.PhoneStatus, nil
  42521. }
  42522. // AddPhoneStatus adds i to the "phone_status" field.
  42523. func (m *WhatsappMutation) AddPhoneStatus(i int8) {
  42524. if m.addphone_status != nil {
  42525. *m.addphone_status += i
  42526. } else {
  42527. m.addphone_status = &i
  42528. }
  42529. }
  42530. // AddedPhoneStatus returns the value that was added to the "phone_status" field in this mutation.
  42531. func (m *WhatsappMutation) AddedPhoneStatus() (r int8, exists bool) {
  42532. v := m.addphone_status
  42533. if v == nil {
  42534. return
  42535. }
  42536. return *v, true
  42537. }
  42538. // ResetPhoneStatus resets all changes to the "phone_status" field.
  42539. func (m *WhatsappMutation) ResetPhoneStatus() {
  42540. m.phone_status = nil
  42541. m.addphone_status = nil
  42542. }
  42543. // SetOrganizationID sets the "organization_id" field.
  42544. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  42545. m.organization_id = &u
  42546. m.addorganization_id = nil
  42547. }
  42548. // OrganizationID returns the value of the "organization_id" field in the mutation.
  42549. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  42550. v := m.organization_id
  42551. if v == nil {
  42552. return
  42553. }
  42554. return *v, true
  42555. }
  42556. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  42557. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42559. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  42560. if !m.op.Is(OpUpdateOne) {
  42561. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  42562. }
  42563. if m.id == nil || m.oldValue == nil {
  42564. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  42565. }
  42566. oldValue, err := m.oldValue(ctx)
  42567. if err != nil {
  42568. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  42569. }
  42570. return oldValue.OrganizationID, nil
  42571. }
  42572. // AddOrganizationID adds u to the "organization_id" field.
  42573. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  42574. if m.addorganization_id != nil {
  42575. *m.addorganization_id += u
  42576. } else {
  42577. m.addorganization_id = &u
  42578. }
  42579. }
  42580. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  42581. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  42582. v := m.addorganization_id
  42583. if v == nil {
  42584. return
  42585. }
  42586. return *v, true
  42587. }
  42588. // ClearOrganizationID clears the value of the "organization_id" field.
  42589. func (m *WhatsappMutation) ClearOrganizationID() {
  42590. m.organization_id = nil
  42591. m.addorganization_id = nil
  42592. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  42593. }
  42594. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  42595. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  42596. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  42597. return ok
  42598. }
  42599. // ResetOrganizationID resets all changes to the "organization_id" field.
  42600. func (m *WhatsappMutation) ResetOrganizationID() {
  42601. m.organization_id = nil
  42602. m.addorganization_id = nil
  42603. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  42604. }
  42605. // SetAPIBase sets the "api_base" field.
  42606. func (m *WhatsappMutation) SetAPIBase(s string) {
  42607. m.api_base = &s
  42608. }
  42609. // APIBase returns the value of the "api_base" field in the mutation.
  42610. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  42611. v := m.api_base
  42612. if v == nil {
  42613. return
  42614. }
  42615. return *v, true
  42616. }
  42617. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  42618. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42620. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  42621. if !m.op.Is(OpUpdateOne) {
  42622. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  42623. }
  42624. if m.id == nil || m.oldValue == nil {
  42625. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  42626. }
  42627. oldValue, err := m.oldValue(ctx)
  42628. if err != nil {
  42629. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  42630. }
  42631. return oldValue.APIBase, nil
  42632. }
  42633. // ClearAPIBase clears the value of the "api_base" field.
  42634. func (m *WhatsappMutation) ClearAPIBase() {
  42635. m.api_base = nil
  42636. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  42637. }
  42638. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  42639. func (m *WhatsappMutation) APIBaseCleared() bool {
  42640. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  42641. return ok
  42642. }
  42643. // ResetAPIBase resets all changes to the "api_base" field.
  42644. func (m *WhatsappMutation) ResetAPIBase() {
  42645. m.api_base = nil
  42646. delete(m.clearedFields, whatsapp.FieldAPIBase)
  42647. }
  42648. // SetAPIKey sets the "api_key" field.
  42649. func (m *WhatsappMutation) SetAPIKey(s string) {
  42650. m.api_key = &s
  42651. }
  42652. // APIKey returns the value of the "api_key" field in the mutation.
  42653. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  42654. v := m.api_key
  42655. if v == nil {
  42656. return
  42657. }
  42658. return *v, true
  42659. }
  42660. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  42661. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42663. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  42664. if !m.op.Is(OpUpdateOne) {
  42665. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  42666. }
  42667. if m.id == nil || m.oldValue == nil {
  42668. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  42669. }
  42670. oldValue, err := m.oldValue(ctx)
  42671. if err != nil {
  42672. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  42673. }
  42674. return oldValue.APIKey, nil
  42675. }
  42676. // ClearAPIKey clears the value of the "api_key" field.
  42677. func (m *WhatsappMutation) ClearAPIKey() {
  42678. m.api_key = nil
  42679. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  42680. }
  42681. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  42682. func (m *WhatsappMutation) APIKeyCleared() bool {
  42683. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  42684. return ok
  42685. }
  42686. // ResetAPIKey resets all changes to the "api_key" field.
  42687. func (m *WhatsappMutation) ResetAPIKey() {
  42688. m.api_key = nil
  42689. delete(m.clearedFields, whatsapp.FieldAPIKey)
  42690. }
  42691. // SetAllowList sets the "allow_list" field.
  42692. func (m *WhatsappMutation) SetAllowList(s []string) {
  42693. m.allow_list = &s
  42694. m.appendallow_list = nil
  42695. }
  42696. // AllowList returns the value of the "allow_list" field in the mutation.
  42697. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  42698. v := m.allow_list
  42699. if v == nil {
  42700. return
  42701. }
  42702. return *v, true
  42703. }
  42704. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  42705. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42707. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  42708. if !m.op.Is(OpUpdateOne) {
  42709. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  42710. }
  42711. if m.id == nil || m.oldValue == nil {
  42712. return v, errors.New("OldAllowList requires an ID field in the mutation")
  42713. }
  42714. oldValue, err := m.oldValue(ctx)
  42715. if err != nil {
  42716. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  42717. }
  42718. return oldValue.AllowList, nil
  42719. }
  42720. // AppendAllowList adds s to the "allow_list" field.
  42721. func (m *WhatsappMutation) AppendAllowList(s []string) {
  42722. m.appendallow_list = append(m.appendallow_list, s...)
  42723. }
  42724. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  42725. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  42726. if len(m.appendallow_list) == 0 {
  42727. return nil, false
  42728. }
  42729. return m.appendallow_list, true
  42730. }
  42731. // ClearAllowList clears the value of the "allow_list" field.
  42732. func (m *WhatsappMutation) ClearAllowList() {
  42733. m.allow_list = nil
  42734. m.appendallow_list = nil
  42735. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  42736. }
  42737. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  42738. func (m *WhatsappMutation) AllowListCleared() bool {
  42739. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  42740. return ok
  42741. }
  42742. // ResetAllowList resets all changes to the "allow_list" field.
  42743. func (m *WhatsappMutation) ResetAllowList() {
  42744. m.allow_list = nil
  42745. m.appendallow_list = nil
  42746. delete(m.clearedFields, whatsapp.FieldAllowList)
  42747. }
  42748. // SetGroupAllowList sets the "group_allow_list" field.
  42749. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  42750. m.group_allow_list = &s
  42751. m.appendgroup_allow_list = nil
  42752. }
  42753. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  42754. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  42755. v := m.group_allow_list
  42756. if v == nil {
  42757. return
  42758. }
  42759. return *v, true
  42760. }
  42761. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  42762. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42764. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  42765. if !m.op.Is(OpUpdateOne) {
  42766. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  42767. }
  42768. if m.id == nil || m.oldValue == nil {
  42769. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  42770. }
  42771. oldValue, err := m.oldValue(ctx)
  42772. if err != nil {
  42773. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  42774. }
  42775. return oldValue.GroupAllowList, nil
  42776. }
  42777. // AppendGroupAllowList adds s to the "group_allow_list" field.
  42778. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  42779. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  42780. }
  42781. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  42782. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  42783. if len(m.appendgroup_allow_list) == 0 {
  42784. return nil, false
  42785. }
  42786. return m.appendgroup_allow_list, true
  42787. }
  42788. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  42789. func (m *WhatsappMutation) ClearGroupAllowList() {
  42790. m.group_allow_list = nil
  42791. m.appendgroup_allow_list = nil
  42792. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  42793. }
  42794. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  42795. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  42796. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  42797. return ok
  42798. }
  42799. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  42800. func (m *WhatsappMutation) ResetGroupAllowList() {
  42801. m.group_allow_list = nil
  42802. m.appendgroup_allow_list = nil
  42803. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  42804. }
  42805. // SetBlockList sets the "block_list" field.
  42806. func (m *WhatsappMutation) SetBlockList(s []string) {
  42807. m.block_list = &s
  42808. m.appendblock_list = nil
  42809. }
  42810. // BlockList returns the value of the "block_list" field in the mutation.
  42811. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  42812. v := m.block_list
  42813. if v == nil {
  42814. return
  42815. }
  42816. return *v, true
  42817. }
  42818. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  42819. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42821. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  42822. if !m.op.Is(OpUpdateOne) {
  42823. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  42824. }
  42825. if m.id == nil || m.oldValue == nil {
  42826. return v, errors.New("OldBlockList requires an ID field in the mutation")
  42827. }
  42828. oldValue, err := m.oldValue(ctx)
  42829. if err != nil {
  42830. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  42831. }
  42832. return oldValue.BlockList, nil
  42833. }
  42834. // AppendBlockList adds s to the "block_list" field.
  42835. func (m *WhatsappMutation) AppendBlockList(s []string) {
  42836. m.appendblock_list = append(m.appendblock_list, s...)
  42837. }
  42838. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  42839. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  42840. if len(m.appendblock_list) == 0 {
  42841. return nil, false
  42842. }
  42843. return m.appendblock_list, true
  42844. }
  42845. // ClearBlockList clears the value of the "block_list" field.
  42846. func (m *WhatsappMutation) ClearBlockList() {
  42847. m.block_list = nil
  42848. m.appendblock_list = nil
  42849. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  42850. }
  42851. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  42852. func (m *WhatsappMutation) BlockListCleared() bool {
  42853. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  42854. return ok
  42855. }
  42856. // ResetBlockList resets all changes to the "block_list" field.
  42857. func (m *WhatsappMutation) ResetBlockList() {
  42858. m.block_list = nil
  42859. m.appendblock_list = nil
  42860. delete(m.clearedFields, whatsapp.FieldBlockList)
  42861. }
  42862. // SetGroupBlockList sets the "group_block_list" field.
  42863. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  42864. m.group_block_list = &s
  42865. m.appendgroup_block_list = nil
  42866. }
  42867. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  42868. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  42869. v := m.group_block_list
  42870. if v == nil {
  42871. return
  42872. }
  42873. return *v, true
  42874. }
  42875. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  42876. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  42877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  42878. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  42879. if !m.op.Is(OpUpdateOne) {
  42880. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  42881. }
  42882. if m.id == nil || m.oldValue == nil {
  42883. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  42884. }
  42885. oldValue, err := m.oldValue(ctx)
  42886. if err != nil {
  42887. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  42888. }
  42889. return oldValue.GroupBlockList, nil
  42890. }
  42891. // AppendGroupBlockList adds s to the "group_block_list" field.
  42892. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  42893. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  42894. }
  42895. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  42896. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  42897. if len(m.appendgroup_block_list) == 0 {
  42898. return nil, false
  42899. }
  42900. return m.appendgroup_block_list, true
  42901. }
  42902. // ClearGroupBlockList clears the value of the "group_block_list" field.
  42903. func (m *WhatsappMutation) ClearGroupBlockList() {
  42904. m.group_block_list = nil
  42905. m.appendgroup_block_list = nil
  42906. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  42907. }
  42908. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  42909. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  42910. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  42911. return ok
  42912. }
  42913. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  42914. func (m *WhatsappMutation) ResetGroupBlockList() {
  42915. m.group_block_list = nil
  42916. m.appendgroup_block_list = nil
  42917. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  42918. }
  42919. // ClearAgent clears the "agent" edge to the Agent entity.
  42920. func (m *WhatsappMutation) ClearAgent() {
  42921. m.clearedagent = true
  42922. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  42923. }
  42924. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  42925. func (m *WhatsappMutation) AgentCleared() bool {
  42926. return m.clearedagent
  42927. }
  42928. // AgentIDs returns the "agent" edge IDs in the mutation.
  42929. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  42930. // AgentID instead. It exists only for internal usage by the builders.
  42931. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  42932. if id := m.agent; id != nil {
  42933. ids = append(ids, *id)
  42934. }
  42935. return
  42936. }
  42937. // ResetAgent resets all changes to the "agent" edge.
  42938. func (m *WhatsappMutation) ResetAgent() {
  42939. m.agent = nil
  42940. m.clearedagent = false
  42941. }
  42942. // Where appends a list predicates to the WhatsappMutation builder.
  42943. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  42944. m.predicates = append(m.predicates, ps...)
  42945. }
  42946. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  42947. // users can use type-assertion to append predicates that do not depend on any generated package.
  42948. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  42949. p := make([]predicate.Whatsapp, len(ps))
  42950. for i := range ps {
  42951. p[i] = ps[i]
  42952. }
  42953. m.Where(p...)
  42954. }
  42955. // Op returns the operation name.
  42956. func (m *WhatsappMutation) Op() Op {
  42957. return m.op
  42958. }
  42959. // SetOp allows setting the mutation operation.
  42960. func (m *WhatsappMutation) SetOp(op Op) {
  42961. m.op = op
  42962. }
  42963. // Type returns the node type of this mutation (Whatsapp).
  42964. func (m *WhatsappMutation) Type() string {
  42965. return m.typ
  42966. }
  42967. // Fields returns all fields that were changed during this mutation. Note that in
  42968. // order to get all numeric fields that were incremented/decremented, call
  42969. // AddedFields().
  42970. func (m *WhatsappMutation) Fields() []string {
  42971. fields := make([]string, 0, 21)
  42972. if m.created_at != nil {
  42973. fields = append(fields, whatsapp.FieldCreatedAt)
  42974. }
  42975. if m.updated_at != nil {
  42976. fields = append(fields, whatsapp.FieldUpdatedAt)
  42977. }
  42978. if m.status != nil {
  42979. fields = append(fields, whatsapp.FieldStatus)
  42980. }
  42981. if m.deleted_at != nil {
  42982. fields = append(fields, whatsapp.FieldDeletedAt)
  42983. }
  42984. if m.wa_id != nil {
  42985. fields = append(fields, whatsapp.FieldWaID)
  42986. }
  42987. if m.wa_name != nil {
  42988. fields = append(fields, whatsapp.FieldWaName)
  42989. }
  42990. if m.callback != nil {
  42991. fields = append(fields, whatsapp.FieldCallback)
  42992. }
  42993. if m.agent != nil {
  42994. fields = append(fields, whatsapp.FieldAgentID)
  42995. }
  42996. if m.account != nil {
  42997. fields = append(fields, whatsapp.FieldAccount)
  42998. }
  42999. if m.cc != nil {
  43000. fields = append(fields, whatsapp.FieldCc)
  43001. }
  43002. if m.phone != nil {
  43003. fields = append(fields, whatsapp.FieldPhone)
  43004. }
  43005. if m.cc_phone != nil {
  43006. fields = append(fields, whatsapp.FieldCcPhone)
  43007. }
  43008. if m.phone_name != nil {
  43009. fields = append(fields, whatsapp.FieldPhoneName)
  43010. }
  43011. if m.phone_status != nil {
  43012. fields = append(fields, whatsapp.FieldPhoneStatus)
  43013. }
  43014. if m.organization_id != nil {
  43015. fields = append(fields, whatsapp.FieldOrganizationID)
  43016. }
  43017. if m.api_base != nil {
  43018. fields = append(fields, whatsapp.FieldAPIBase)
  43019. }
  43020. if m.api_key != nil {
  43021. fields = append(fields, whatsapp.FieldAPIKey)
  43022. }
  43023. if m.allow_list != nil {
  43024. fields = append(fields, whatsapp.FieldAllowList)
  43025. }
  43026. if m.group_allow_list != nil {
  43027. fields = append(fields, whatsapp.FieldGroupAllowList)
  43028. }
  43029. if m.block_list != nil {
  43030. fields = append(fields, whatsapp.FieldBlockList)
  43031. }
  43032. if m.group_block_list != nil {
  43033. fields = append(fields, whatsapp.FieldGroupBlockList)
  43034. }
  43035. return fields
  43036. }
  43037. // Field returns the value of a field with the given name. The second boolean
  43038. // return value indicates that this field was not set, or was not defined in the
  43039. // schema.
  43040. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  43041. switch name {
  43042. case whatsapp.FieldCreatedAt:
  43043. return m.CreatedAt()
  43044. case whatsapp.FieldUpdatedAt:
  43045. return m.UpdatedAt()
  43046. case whatsapp.FieldStatus:
  43047. return m.Status()
  43048. case whatsapp.FieldDeletedAt:
  43049. return m.DeletedAt()
  43050. case whatsapp.FieldWaID:
  43051. return m.WaID()
  43052. case whatsapp.FieldWaName:
  43053. return m.WaName()
  43054. case whatsapp.FieldCallback:
  43055. return m.Callback()
  43056. case whatsapp.FieldAgentID:
  43057. return m.AgentID()
  43058. case whatsapp.FieldAccount:
  43059. return m.Account()
  43060. case whatsapp.FieldCc:
  43061. return m.Cc()
  43062. case whatsapp.FieldPhone:
  43063. return m.Phone()
  43064. case whatsapp.FieldCcPhone:
  43065. return m.CcPhone()
  43066. case whatsapp.FieldPhoneName:
  43067. return m.PhoneName()
  43068. case whatsapp.FieldPhoneStatus:
  43069. return m.PhoneStatus()
  43070. case whatsapp.FieldOrganizationID:
  43071. return m.OrganizationID()
  43072. case whatsapp.FieldAPIBase:
  43073. return m.APIBase()
  43074. case whatsapp.FieldAPIKey:
  43075. return m.APIKey()
  43076. case whatsapp.FieldAllowList:
  43077. return m.AllowList()
  43078. case whatsapp.FieldGroupAllowList:
  43079. return m.GroupAllowList()
  43080. case whatsapp.FieldBlockList:
  43081. return m.BlockList()
  43082. case whatsapp.FieldGroupBlockList:
  43083. return m.GroupBlockList()
  43084. }
  43085. return nil, false
  43086. }
  43087. // OldField returns the old value of the field from the database. An error is
  43088. // returned if the mutation operation is not UpdateOne, or the query to the
  43089. // database failed.
  43090. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  43091. switch name {
  43092. case whatsapp.FieldCreatedAt:
  43093. return m.OldCreatedAt(ctx)
  43094. case whatsapp.FieldUpdatedAt:
  43095. return m.OldUpdatedAt(ctx)
  43096. case whatsapp.FieldStatus:
  43097. return m.OldStatus(ctx)
  43098. case whatsapp.FieldDeletedAt:
  43099. return m.OldDeletedAt(ctx)
  43100. case whatsapp.FieldWaID:
  43101. return m.OldWaID(ctx)
  43102. case whatsapp.FieldWaName:
  43103. return m.OldWaName(ctx)
  43104. case whatsapp.FieldCallback:
  43105. return m.OldCallback(ctx)
  43106. case whatsapp.FieldAgentID:
  43107. return m.OldAgentID(ctx)
  43108. case whatsapp.FieldAccount:
  43109. return m.OldAccount(ctx)
  43110. case whatsapp.FieldCc:
  43111. return m.OldCc(ctx)
  43112. case whatsapp.FieldPhone:
  43113. return m.OldPhone(ctx)
  43114. case whatsapp.FieldCcPhone:
  43115. return m.OldCcPhone(ctx)
  43116. case whatsapp.FieldPhoneName:
  43117. return m.OldPhoneName(ctx)
  43118. case whatsapp.FieldPhoneStatus:
  43119. return m.OldPhoneStatus(ctx)
  43120. case whatsapp.FieldOrganizationID:
  43121. return m.OldOrganizationID(ctx)
  43122. case whatsapp.FieldAPIBase:
  43123. return m.OldAPIBase(ctx)
  43124. case whatsapp.FieldAPIKey:
  43125. return m.OldAPIKey(ctx)
  43126. case whatsapp.FieldAllowList:
  43127. return m.OldAllowList(ctx)
  43128. case whatsapp.FieldGroupAllowList:
  43129. return m.OldGroupAllowList(ctx)
  43130. case whatsapp.FieldBlockList:
  43131. return m.OldBlockList(ctx)
  43132. case whatsapp.FieldGroupBlockList:
  43133. return m.OldGroupBlockList(ctx)
  43134. }
  43135. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  43136. }
  43137. // SetField sets the value of a field with the given name. It returns an error if
  43138. // the field is not defined in the schema, or if the type mismatched the field
  43139. // type.
  43140. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  43141. switch name {
  43142. case whatsapp.FieldCreatedAt:
  43143. v, ok := value.(time.Time)
  43144. if !ok {
  43145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43146. }
  43147. m.SetCreatedAt(v)
  43148. return nil
  43149. case whatsapp.FieldUpdatedAt:
  43150. v, ok := value.(time.Time)
  43151. if !ok {
  43152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43153. }
  43154. m.SetUpdatedAt(v)
  43155. return nil
  43156. case whatsapp.FieldStatus:
  43157. v, ok := value.(uint8)
  43158. if !ok {
  43159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43160. }
  43161. m.SetStatus(v)
  43162. return nil
  43163. case whatsapp.FieldDeletedAt:
  43164. v, ok := value.(time.Time)
  43165. if !ok {
  43166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43167. }
  43168. m.SetDeletedAt(v)
  43169. return nil
  43170. case whatsapp.FieldWaID:
  43171. v, ok := value.(string)
  43172. if !ok {
  43173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43174. }
  43175. m.SetWaID(v)
  43176. return nil
  43177. case whatsapp.FieldWaName:
  43178. v, ok := value.(string)
  43179. if !ok {
  43180. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43181. }
  43182. m.SetWaName(v)
  43183. return nil
  43184. case whatsapp.FieldCallback:
  43185. v, ok := value.(string)
  43186. if !ok {
  43187. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43188. }
  43189. m.SetCallback(v)
  43190. return nil
  43191. case whatsapp.FieldAgentID:
  43192. v, ok := value.(uint64)
  43193. if !ok {
  43194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43195. }
  43196. m.SetAgentID(v)
  43197. return nil
  43198. case whatsapp.FieldAccount:
  43199. v, ok := value.(string)
  43200. if !ok {
  43201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43202. }
  43203. m.SetAccount(v)
  43204. return nil
  43205. case whatsapp.FieldCc:
  43206. v, ok := value.(string)
  43207. if !ok {
  43208. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43209. }
  43210. m.SetCc(v)
  43211. return nil
  43212. case whatsapp.FieldPhone:
  43213. v, ok := value.(string)
  43214. if !ok {
  43215. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43216. }
  43217. m.SetPhone(v)
  43218. return nil
  43219. case whatsapp.FieldCcPhone:
  43220. v, ok := value.(string)
  43221. if !ok {
  43222. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43223. }
  43224. m.SetCcPhone(v)
  43225. return nil
  43226. case whatsapp.FieldPhoneName:
  43227. v, ok := value.(string)
  43228. if !ok {
  43229. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43230. }
  43231. m.SetPhoneName(v)
  43232. return nil
  43233. case whatsapp.FieldPhoneStatus:
  43234. v, ok := value.(int8)
  43235. if !ok {
  43236. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43237. }
  43238. m.SetPhoneStatus(v)
  43239. return nil
  43240. case whatsapp.FieldOrganizationID:
  43241. v, ok := value.(uint64)
  43242. if !ok {
  43243. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43244. }
  43245. m.SetOrganizationID(v)
  43246. return nil
  43247. case whatsapp.FieldAPIBase:
  43248. v, ok := value.(string)
  43249. if !ok {
  43250. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43251. }
  43252. m.SetAPIBase(v)
  43253. return nil
  43254. case whatsapp.FieldAPIKey:
  43255. v, ok := value.(string)
  43256. if !ok {
  43257. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43258. }
  43259. m.SetAPIKey(v)
  43260. return nil
  43261. case whatsapp.FieldAllowList:
  43262. v, ok := value.([]string)
  43263. if !ok {
  43264. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43265. }
  43266. m.SetAllowList(v)
  43267. return nil
  43268. case whatsapp.FieldGroupAllowList:
  43269. v, ok := value.([]string)
  43270. if !ok {
  43271. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43272. }
  43273. m.SetGroupAllowList(v)
  43274. return nil
  43275. case whatsapp.FieldBlockList:
  43276. v, ok := value.([]string)
  43277. if !ok {
  43278. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43279. }
  43280. m.SetBlockList(v)
  43281. return nil
  43282. case whatsapp.FieldGroupBlockList:
  43283. v, ok := value.([]string)
  43284. if !ok {
  43285. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43286. }
  43287. m.SetGroupBlockList(v)
  43288. return nil
  43289. }
  43290. return fmt.Errorf("unknown Whatsapp field %s", name)
  43291. }
  43292. // AddedFields returns all numeric fields that were incremented/decremented during
  43293. // this mutation.
  43294. func (m *WhatsappMutation) AddedFields() []string {
  43295. var fields []string
  43296. if m.addstatus != nil {
  43297. fields = append(fields, whatsapp.FieldStatus)
  43298. }
  43299. if m.addphone_status != nil {
  43300. fields = append(fields, whatsapp.FieldPhoneStatus)
  43301. }
  43302. if m.addorganization_id != nil {
  43303. fields = append(fields, whatsapp.FieldOrganizationID)
  43304. }
  43305. return fields
  43306. }
  43307. // AddedField returns the numeric value that was incremented/decremented on a field
  43308. // with the given name. The second boolean return value indicates that this field
  43309. // was not set, or was not defined in the schema.
  43310. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  43311. switch name {
  43312. case whatsapp.FieldStatus:
  43313. return m.AddedStatus()
  43314. case whatsapp.FieldPhoneStatus:
  43315. return m.AddedPhoneStatus()
  43316. case whatsapp.FieldOrganizationID:
  43317. return m.AddedOrganizationID()
  43318. }
  43319. return nil, false
  43320. }
  43321. // AddField adds the value to the field with the given name. It returns an error if
  43322. // the field is not defined in the schema, or if the type mismatched the field
  43323. // type.
  43324. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  43325. switch name {
  43326. case whatsapp.FieldStatus:
  43327. v, ok := value.(int8)
  43328. if !ok {
  43329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43330. }
  43331. m.AddStatus(v)
  43332. return nil
  43333. case whatsapp.FieldPhoneStatus:
  43334. v, ok := value.(int8)
  43335. if !ok {
  43336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43337. }
  43338. m.AddPhoneStatus(v)
  43339. return nil
  43340. case whatsapp.FieldOrganizationID:
  43341. v, ok := value.(int64)
  43342. if !ok {
  43343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  43344. }
  43345. m.AddOrganizationID(v)
  43346. return nil
  43347. }
  43348. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  43349. }
  43350. // ClearedFields returns all nullable fields that were cleared during this
  43351. // mutation.
  43352. func (m *WhatsappMutation) ClearedFields() []string {
  43353. var fields []string
  43354. if m.FieldCleared(whatsapp.FieldStatus) {
  43355. fields = append(fields, whatsapp.FieldStatus)
  43356. }
  43357. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  43358. fields = append(fields, whatsapp.FieldDeletedAt)
  43359. }
  43360. if m.FieldCleared(whatsapp.FieldWaID) {
  43361. fields = append(fields, whatsapp.FieldWaID)
  43362. }
  43363. if m.FieldCleared(whatsapp.FieldWaName) {
  43364. fields = append(fields, whatsapp.FieldWaName)
  43365. }
  43366. if m.FieldCleared(whatsapp.FieldCallback) {
  43367. fields = append(fields, whatsapp.FieldCallback)
  43368. }
  43369. if m.FieldCleared(whatsapp.FieldAccount) {
  43370. fields = append(fields, whatsapp.FieldAccount)
  43371. }
  43372. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  43373. fields = append(fields, whatsapp.FieldOrganizationID)
  43374. }
  43375. if m.FieldCleared(whatsapp.FieldAPIBase) {
  43376. fields = append(fields, whatsapp.FieldAPIBase)
  43377. }
  43378. if m.FieldCleared(whatsapp.FieldAPIKey) {
  43379. fields = append(fields, whatsapp.FieldAPIKey)
  43380. }
  43381. if m.FieldCleared(whatsapp.FieldAllowList) {
  43382. fields = append(fields, whatsapp.FieldAllowList)
  43383. }
  43384. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  43385. fields = append(fields, whatsapp.FieldGroupAllowList)
  43386. }
  43387. if m.FieldCleared(whatsapp.FieldBlockList) {
  43388. fields = append(fields, whatsapp.FieldBlockList)
  43389. }
  43390. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  43391. fields = append(fields, whatsapp.FieldGroupBlockList)
  43392. }
  43393. return fields
  43394. }
  43395. // FieldCleared returns a boolean indicating if a field with the given name was
  43396. // cleared in this mutation.
  43397. func (m *WhatsappMutation) FieldCleared(name string) bool {
  43398. _, ok := m.clearedFields[name]
  43399. return ok
  43400. }
  43401. // ClearField clears the value of the field with the given name. It returns an
  43402. // error if the field is not defined in the schema.
  43403. func (m *WhatsappMutation) ClearField(name string) error {
  43404. switch name {
  43405. case whatsapp.FieldStatus:
  43406. m.ClearStatus()
  43407. return nil
  43408. case whatsapp.FieldDeletedAt:
  43409. m.ClearDeletedAt()
  43410. return nil
  43411. case whatsapp.FieldWaID:
  43412. m.ClearWaID()
  43413. return nil
  43414. case whatsapp.FieldWaName:
  43415. m.ClearWaName()
  43416. return nil
  43417. case whatsapp.FieldCallback:
  43418. m.ClearCallback()
  43419. return nil
  43420. case whatsapp.FieldAccount:
  43421. m.ClearAccount()
  43422. return nil
  43423. case whatsapp.FieldOrganizationID:
  43424. m.ClearOrganizationID()
  43425. return nil
  43426. case whatsapp.FieldAPIBase:
  43427. m.ClearAPIBase()
  43428. return nil
  43429. case whatsapp.FieldAPIKey:
  43430. m.ClearAPIKey()
  43431. return nil
  43432. case whatsapp.FieldAllowList:
  43433. m.ClearAllowList()
  43434. return nil
  43435. case whatsapp.FieldGroupAllowList:
  43436. m.ClearGroupAllowList()
  43437. return nil
  43438. case whatsapp.FieldBlockList:
  43439. m.ClearBlockList()
  43440. return nil
  43441. case whatsapp.FieldGroupBlockList:
  43442. m.ClearGroupBlockList()
  43443. return nil
  43444. }
  43445. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  43446. }
  43447. // ResetField resets all changes in the mutation for the field with the given name.
  43448. // It returns an error if the field is not defined in the schema.
  43449. func (m *WhatsappMutation) ResetField(name string) error {
  43450. switch name {
  43451. case whatsapp.FieldCreatedAt:
  43452. m.ResetCreatedAt()
  43453. return nil
  43454. case whatsapp.FieldUpdatedAt:
  43455. m.ResetUpdatedAt()
  43456. return nil
  43457. case whatsapp.FieldStatus:
  43458. m.ResetStatus()
  43459. return nil
  43460. case whatsapp.FieldDeletedAt:
  43461. m.ResetDeletedAt()
  43462. return nil
  43463. case whatsapp.FieldWaID:
  43464. m.ResetWaID()
  43465. return nil
  43466. case whatsapp.FieldWaName:
  43467. m.ResetWaName()
  43468. return nil
  43469. case whatsapp.FieldCallback:
  43470. m.ResetCallback()
  43471. return nil
  43472. case whatsapp.FieldAgentID:
  43473. m.ResetAgentID()
  43474. return nil
  43475. case whatsapp.FieldAccount:
  43476. m.ResetAccount()
  43477. return nil
  43478. case whatsapp.FieldCc:
  43479. m.ResetCc()
  43480. return nil
  43481. case whatsapp.FieldPhone:
  43482. m.ResetPhone()
  43483. return nil
  43484. case whatsapp.FieldCcPhone:
  43485. m.ResetCcPhone()
  43486. return nil
  43487. case whatsapp.FieldPhoneName:
  43488. m.ResetPhoneName()
  43489. return nil
  43490. case whatsapp.FieldPhoneStatus:
  43491. m.ResetPhoneStatus()
  43492. return nil
  43493. case whatsapp.FieldOrganizationID:
  43494. m.ResetOrganizationID()
  43495. return nil
  43496. case whatsapp.FieldAPIBase:
  43497. m.ResetAPIBase()
  43498. return nil
  43499. case whatsapp.FieldAPIKey:
  43500. m.ResetAPIKey()
  43501. return nil
  43502. case whatsapp.FieldAllowList:
  43503. m.ResetAllowList()
  43504. return nil
  43505. case whatsapp.FieldGroupAllowList:
  43506. m.ResetGroupAllowList()
  43507. return nil
  43508. case whatsapp.FieldBlockList:
  43509. m.ResetBlockList()
  43510. return nil
  43511. case whatsapp.FieldGroupBlockList:
  43512. m.ResetGroupBlockList()
  43513. return nil
  43514. }
  43515. return fmt.Errorf("unknown Whatsapp field %s", name)
  43516. }
  43517. // AddedEdges returns all edge names that were set/added in this mutation.
  43518. func (m *WhatsappMutation) AddedEdges() []string {
  43519. edges := make([]string, 0, 1)
  43520. if m.agent != nil {
  43521. edges = append(edges, whatsapp.EdgeAgent)
  43522. }
  43523. return edges
  43524. }
  43525. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  43526. // name in this mutation.
  43527. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  43528. switch name {
  43529. case whatsapp.EdgeAgent:
  43530. if id := m.agent; id != nil {
  43531. return []ent.Value{*id}
  43532. }
  43533. }
  43534. return nil
  43535. }
  43536. // RemovedEdges returns all edge names that were removed in this mutation.
  43537. func (m *WhatsappMutation) RemovedEdges() []string {
  43538. edges := make([]string, 0, 1)
  43539. return edges
  43540. }
  43541. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  43542. // the given name in this mutation.
  43543. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  43544. return nil
  43545. }
  43546. // ClearedEdges returns all edge names that were cleared in this mutation.
  43547. func (m *WhatsappMutation) ClearedEdges() []string {
  43548. edges := make([]string, 0, 1)
  43549. if m.clearedagent {
  43550. edges = append(edges, whatsapp.EdgeAgent)
  43551. }
  43552. return edges
  43553. }
  43554. // EdgeCleared returns a boolean which indicates if the edge with the given name
  43555. // was cleared in this mutation.
  43556. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  43557. switch name {
  43558. case whatsapp.EdgeAgent:
  43559. return m.clearedagent
  43560. }
  43561. return false
  43562. }
  43563. // ClearEdge clears the value of the edge with the given name. It returns an error
  43564. // if that edge is not defined in the schema.
  43565. func (m *WhatsappMutation) ClearEdge(name string) error {
  43566. switch name {
  43567. case whatsapp.EdgeAgent:
  43568. m.ClearAgent()
  43569. return nil
  43570. }
  43571. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  43572. }
  43573. // ResetEdge resets all changes to the edge with the given name in this mutation.
  43574. // It returns an error if the edge is not defined in the schema.
  43575. func (m *WhatsappMutation) ResetEdge(name string) error {
  43576. switch name {
  43577. case whatsapp.EdgeAgent:
  43578. m.ResetAgent()
  43579. return nil
  43580. }
  43581. return fmt.Errorf("unknown Whatsapp edge %s", name)
  43582. }
  43583. // WhatsappChannelMutation represents an operation that mutates the WhatsappChannel nodes in the graph.
  43584. type WhatsappChannelMutation struct {
  43585. config
  43586. op Op
  43587. typ string
  43588. id *uint64
  43589. created_at *time.Time
  43590. updated_at *time.Time
  43591. status *uint8
  43592. addstatus *int8
  43593. deleted_at *time.Time
  43594. ak *string
  43595. sk *string
  43596. wa_id *string
  43597. wa_name *string
  43598. waba_id *uint64
  43599. addwaba_id *int64
  43600. business_id *uint64
  43601. addbusiness_id *int64
  43602. organization_id *uint64
  43603. addorganization_id *int64
  43604. verify_account *string
  43605. clearedFields map[string]struct{}
  43606. done bool
  43607. oldValue func(context.Context) (*WhatsappChannel, error)
  43608. predicates []predicate.WhatsappChannel
  43609. }
  43610. var _ ent.Mutation = (*WhatsappChannelMutation)(nil)
  43611. // whatsappchannelOption allows management of the mutation configuration using functional options.
  43612. type whatsappchannelOption func(*WhatsappChannelMutation)
  43613. // newWhatsappChannelMutation creates new mutation for the WhatsappChannel entity.
  43614. func newWhatsappChannelMutation(c config, op Op, opts ...whatsappchannelOption) *WhatsappChannelMutation {
  43615. m := &WhatsappChannelMutation{
  43616. config: c,
  43617. op: op,
  43618. typ: TypeWhatsappChannel,
  43619. clearedFields: make(map[string]struct{}),
  43620. }
  43621. for _, opt := range opts {
  43622. opt(m)
  43623. }
  43624. return m
  43625. }
  43626. // withWhatsappChannelID sets the ID field of the mutation.
  43627. func withWhatsappChannelID(id uint64) whatsappchannelOption {
  43628. return func(m *WhatsappChannelMutation) {
  43629. var (
  43630. err error
  43631. once sync.Once
  43632. value *WhatsappChannel
  43633. )
  43634. m.oldValue = func(ctx context.Context) (*WhatsappChannel, error) {
  43635. once.Do(func() {
  43636. if m.done {
  43637. err = errors.New("querying old values post mutation is not allowed")
  43638. } else {
  43639. value, err = m.Client().WhatsappChannel.Get(ctx, id)
  43640. }
  43641. })
  43642. return value, err
  43643. }
  43644. m.id = &id
  43645. }
  43646. }
  43647. // withWhatsappChannel sets the old WhatsappChannel of the mutation.
  43648. func withWhatsappChannel(node *WhatsappChannel) whatsappchannelOption {
  43649. return func(m *WhatsappChannelMutation) {
  43650. m.oldValue = func(context.Context) (*WhatsappChannel, error) {
  43651. return node, nil
  43652. }
  43653. m.id = &node.ID
  43654. }
  43655. }
  43656. // Client returns a new `ent.Client` from the mutation. If the mutation was
  43657. // executed in a transaction (ent.Tx), a transactional client is returned.
  43658. func (m WhatsappChannelMutation) Client() *Client {
  43659. client := &Client{config: m.config}
  43660. client.init()
  43661. return client
  43662. }
  43663. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  43664. // it returns an error otherwise.
  43665. func (m WhatsappChannelMutation) Tx() (*Tx, error) {
  43666. if _, ok := m.driver.(*txDriver); !ok {
  43667. return nil, errors.New("ent: mutation is not running in a transaction")
  43668. }
  43669. tx := &Tx{config: m.config}
  43670. tx.init()
  43671. return tx, nil
  43672. }
  43673. // SetID sets the value of the id field. Note that this
  43674. // operation is only accepted on creation of WhatsappChannel entities.
  43675. func (m *WhatsappChannelMutation) SetID(id uint64) {
  43676. m.id = &id
  43677. }
  43678. // ID returns the ID value in the mutation. Note that the ID is only available
  43679. // if it was provided to the builder or after it was returned from the database.
  43680. func (m *WhatsappChannelMutation) ID() (id uint64, exists bool) {
  43681. if m.id == nil {
  43682. return
  43683. }
  43684. return *m.id, true
  43685. }
  43686. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  43687. // That means, if the mutation is applied within a transaction with an isolation level such
  43688. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  43689. // or updated by the mutation.
  43690. func (m *WhatsappChannelMutation) IDs(ctx context.Context) ([]uint64, error) {
  43691. switch {
  43692. case m.op.Is(OpUpdateOne | OpDeleteOne):
  43693. id, exists := m.ID()
  43694. if exists {
  43695. return []uint64{id}, nil
  43696. }
  43697. fallthrough
  43698. case m.op.Is(OpUpdate | OpDelete):
  43699. return m.Client().WhatsappChannel.Query().Where(m.predicates...).IDs(ctx)
  43700. default:
  43701. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  43702. }
  43703. }
  43704. // SetCreatedAt sets the "created_at" field.
  43705. func (m *WhatsappChannelMutation) SetCreatedAt(t time.Time) {
  43706. m.created_at = &t
  43707. }
  43708. // CreatedAt returns the value of the "created_at" field in the mutation.
  43709. func (m *WhatsappChannelMutation) CreatedAt() (r time.Time, exists bool) {
  43710. v := m.created_at
  43711. if v == nil {
  43712. return
  43713. }
  43714. return *v, true
  43715. }
  43716. // OldCreatedAt returns the old "created_at" field's value of the WhatsappChannel entity.
  43717. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43719. func (m *WhatsappChannelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  43720. if !m.op.Is(OpUpdateOne) {
  43721. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  43722. }
  43723. if m.id == nil || m.oldValue == nil {
  43724. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  43725. }
  43726. oldValue, err := m.oldValue(ctx)
  43727. if err != nil {
  43728. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  43729. }
  43730. return oldValue.CreatedAt, nil
  43731. }
  43732. // ResetCreatedAt resets all changes to the "created_at" field.
  43733. func (m *WhatsappChannelMutation) ResetCreatedAt() {
  43734. m.created_at = nil
  43735. }
  43736. // SetUpdatedAt sets the "updated_at" field.
  43737. func (m *WhatsappChannelMutation) SetUpdatedAt(t time.Time) {
  43738. m.updated_at = &t
  43739. }
  43740. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  43741. func (m *WhatsappChannelMutation) UpdatedAt() (r time.Time, exists bool) {
  43742. v := m.updated_at
  43743. if v == nil {
  43744. return
  43745. }
  43746. return *v, true
  43747. }
  43748. // OldUpdatedAt returns the old "updated_at" field's value of the WhatsappChannel entity.
  43749. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43751. func (m *WhatsappChannelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  43752. if !m.op.Is(OpUpdateOne) {
  43753. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  43754. }
  43755. if m.id == nil || m.oldValue == nil {
  43756. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  43757. }
  43758. oldValue, err := m.oldValue(ctx)
  43759. if err != nil {
  43760. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  43761. }
  43762. return oldValue.UpdatedAt, nil
  43763. }
  43764. // ResetUpdatedAt resets all changes to the "updated_at" field.
  43765. func (m *WhatsappChannelMutation) ResetUpdatedAt() {
  43766. m.updated_at = nil
  43767. }
  43768. // SetStatus sets the "status" field.
  43769. func (m *WhatsappChannelMutation) SetStatus(u uint8) {
  43770. m.status = &u
  43771. m.addstatus = nil
  43772. }
  43773. // Status returns the value of the "status" field in the mutation.
  43774. func (m *WhatsappChannelMutation) Status() (r uint8, exists bool) {
  43775. v := m.status
  43776. if v == nil {
  43777. return
  43778. }
  43779. return *v, true
  43780. }
  43781. // OldStatus returns the old "status" field's value of the WhatsappChannel entity.
  43782. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43784. func (m *WhatsappChannelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  43785. if !m.op.Is(OpUpdateOne) {
  43786. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  43787. }
  43788. if m.id == nil || m.oldValue == nil {
  43789. return v, errors.New("OldStatus requires an ID field in the mutation")
  43790. }
  43791. oldValue, err := m.oldValue(ctx)
  43792. if err != nil {
  43793. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  43794. }
  43795. return oldValue.Status, nil
  43796. }
  43797. // AddStatus adds u to the "status" field.
  43798. func (m *WhatsappChannelMutation) AddStatus(u int8) {
  43799. if m.addstatus != nil {
  43800. *m.addstatus += u
  43801. } else {
  43802. m.addstatus = &u
  43803. }
  43804. }
  43805. // AddedStatus returns the value that was added to the "status" field in this mutation.
  43806. func (m *WhatsappChannelMutation) AddedStatus() (r int8, exists bool) {
  43807. v := m.addstatus
  43808. if v == nil {
  43809. return
  43810. }
  43811. return *v, true
  43812. }
  43813. // ClearStatus clears the value of the "status" field.
  43814. func (m *WhatsappChannelMutation) ClearStatus() {
  43815. m.status = nil
  43816. m.addstatus = nil
  43817. m.clearedFields[whatsappchannel.FieldStatus] = struct{}{}
  43818. }
  43819. // StatusCleared returns if the "status" field was cleared in this mutation.
  43820. func (m *WhatsappChannelMutation) StatusCleared() bool {
  43821. _, ok := m.clearedFields[whatsappchannel.FieldStatus]
  43822. return ok
  43823. }
  43824. // ResetStatus resets all changes to the "status" field.
  43825. func (m *WhatsappChannelMutation) ResetStatus() {
  43826. m.status = nil
  43827. m.addstatus = nil
  43828. delete(m.clearedFields, whatsappchannel.FieldStatus)
  43829. }
  43830. // SetDeletedAt sets the "deleted_at" field.
  43831. func (m *WhatsappChannelMutation) SetDeletedAt(t time.Time) {
  43832. m.deleted_at = &t
  43833. }
  43834. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  43835. func (m *WhatsappChannelMutation) DeletedAt() (r time.Time, exists bool) {
  43836. v := m.deleted_at
  43837. if v == nil {
  43838. return
  43839. }
  43840. return *v, true
  43841. }
  43842. // OldDeletedAt returns the old "deleted_at" field's value of the WhatsappChannel entity.
  43843. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43845. func (m *WhatsappChannelMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  43846. if !m.op.Is(OpUpdateOne) {
  43847. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  43848. }
  43849. if m.id == nil || m.oldValue == nil {
  43850. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  43851. }
  43852. oldValue, err := m.oldValue(ctx)
  43853. if err != nil {
  43854. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  43855. }
  43856. return oldValue.DeletedAt, nil
  43857. }
  43858. // ClearDeletedAt clears the value of the "deleted_at" field.
  43859. func (m *WhatsappChannelMutation) ClearDeletedAt() {
  43860. m.deleted_at = nil
  43861. m.clearedFields[whatsappchannel.FieldDeletedAt] = struct{}{}
  43862. }
  43863. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  43864. func (m *WhatsappChannelMutation) DeletedAtCleared() bool {
  43865. _, ok := m.clearedFields[whatsappchannel.FieldDeletedAt]
  43866. return ok
  43867. }
  43868. // ResetDeletedAt resets all changes to the "deleted_at" field.
  43869. func (m *WhatsappChannelMutation) ResetDeletedAt() {
  43870. m.deleted_at = nil
  43871. delete(m.clearedFields, whatsappchannel.FieldDeletedAt)
  43872. }
  43873. // SetAk sets the "ak" field.
  43874. func (m *WhatsappChannelMutation) SetAk(s string) {
  43875. m.ak = &s
  43876. }
  43877. // Ak returns the value of the "ak" field in the mutation.
  43878. func (m *WhatsappChannelMutation) Ak() (r string, exists bool) {
  43879. v := m.ak
  43880. if v == nil {
  43881. return
  43882. }
  43883. return *v, true
  43884. }
  43885. // OldAk returns the old "ak" field's value of the WhatsappChannel entity.
  43886. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43888. func (m *WhatsappChannelMutation) OldAk(ctx context.Context) (v string, err error) {
  43889. if !m.op.Is(OpUpdateOne) {
  43890. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  43891. }
  43892. if m.id == nil || m.oldValue == nil {
  43893. return v, errors.New("OldAk requires an ID field in the mutation")
  43894. }
  43895. oldValue, err := m.oldValue(ctx)
  43896. if err != nil {
  43897. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  43898. }
  43899. return oldValue.Ak, nil
  43900. }
  43901. // ClearAk clears the value of the "ak" field.
  43902. func (m *WhatsappChannelMutation) ClearAk() {
  43903. m.ak = nil
  43904. m.clearedFields[whatsappchannel.FieldAk] = struct{}{}
  43905. }
  43906. // AkCleared returns if the "ak" field was cleared in this mutation.
  43907. func (m *WhatsappChannelMutation) AkCleared() bool {
  43908. _, ok := m.clearedFields[whatsappchannel.FieldAk]
  43909. return ok
  43910. }
  43911. // ResetAk resets all changes to the "ak" field.
  43912. func (m *WhatsappChannelMutation) ResetAk() {
  43913. m.ak = nil
  43914. delete(m.clearedFields, whatsappchannel.FieldAk)
  43915. }
  43916. // SetSk sets the "sk" field.
  43917. func (m *WhatsappChannelMutation) SetSk(s string) {
  43918. m.sk = &s
  43919. }
  43920. // Sk returns the value of the "sk" field in the mutation.
  43921. func (m *WhatsappChannelMutation) Sk() (r string, exists bool) {
  43922. v := m.sk
  43923. if v == nil {
  43924. return
  43925. }
  43926. return *v, true
  43927. }
  43928. // OldSk returns the old "sk" field's value of the WhatsappChannel entity.
  43929. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43931. func (m *WhatsappChannelMutation) OldSk(ctx context.Context) (v string, err error) {
  43932. if !m.op.Is(OpUpdateOne) {
  43933. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  43934. }
  43935. if m.id == nil || m.oldValue == nil {
  43936. return v, errors.New("OldSk requires an ID field in the mutation")
  43937. }
  43938. oldValue, err := m.oldValue(ctx)
  43939. if err != nil {
  43940. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  43941. }
  43942. return oldValue.Sk, nil
  43943. }
  43944. // ResetSk resets all changes to the "sk" field.
  43945. func (m *WhatsappChannelMutation) ResetSk() {
  43946. m.sk = nil
  43947. }
  43948. // SetWaID sets the "wa_id" field.
  43949. func (m *WhatsappChannelMutation) SetWaID(s string) {
  43950. m.wa_id = &s
  43951. }
  43952. // WaID returns the value of the "wa_id" field in the mutation.
  43953. func (m *WhatsappChannelMutation) WaID() (r string, exists bool) {
  43954. v := m.wa_id
  43955. if v == nil {
  43956. return
  43957. }
  43958. return *v, true
  43959. }
  43960. // OldWaID returns the old "wa_id" field's value of the WhatsappChannel entity.
  43961. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  43962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  43963. func (m *WhatsappChannelMutation) OldWaID(ctx context.Context) (v string, err error) {
  43964. if !m.op.Is(OpUpdateOne) {
  43965. return v, errors.New("OldWaID is only allowed on UpdateOne operations")
  43966. }
  43967. if m.id == nil || m.oldValue == nil {
  43968. return v, errors.New("OldWaID requires an ID field in the mutation")
  43969. }
  43970. oldValue, err := m.oldValue(ctx)
  43971. if err != nil {
  43972. return v, fmt.Errorf("querying old value for OldWaID: %w", err)
  43973. }
  43974. return oldValue.WaID, nil
  43975. }
  43976. // ClearWaID clears the value of the "wa_id" field.
  43977. func (m *WhatsappChannelMutation) ClearWaID() {
  43978. m.wa_id = nil
  43979. m.clearedFields[whatsappchannel.FieldWaID] = struct{}{}
  43980. }
  43981. // WaIDCleared returns if the "wa_id" field was cleared in this mutation.
  43982. func (m *WhatsappChannelMutation) WaIDCleared() bool {
  43983. _, ok := m.clearedFields[whatsappchannel.FieldWaID]
  43984. return ok
  43985. }
  43986. // ResetWaID resets all changes to the "wa_id" field.
  43987. func (m *WhatsappChannelMutation) ResetWaID() {
  43988. m.wa_id = nil
  43989. delete(m.clearedFields, whatsappchannel.FieldWaID)
  43990. }
  43991. // SetWaName sets the "wa_name" field.
  43992. func (m *WhatsappChannelMutation) SetWaName(s string) {
  43993. m.wa_name = &s
  43994. }
  43995. // WaName returns the value of the "wa_name" field in the mutation.
  43996. func (m *WhatsappChannelMutation) WaName() (r string, exists bool) {
  43997. v := m.wa_name
  43998. if v == nil {
  43999. return
  44000. }
  44001. return *v, true
  44002. }
  44003. // OldWaName returns the old "wa_name" field's value of the WhatsappChannel entity.
  44004. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44006. func (m *WhatsappChannelMutation) OldWaName(ctx context.Context) (v string, err error) {
  44007. if !m.op.Is(OpUpdateOne) {
  44008. return v, errors.New("OldWaName is only allowed on UpdateOne operations")
  44009. }
  44010. if m.id == nil || m.oldValue == nil {
  44011. return v, errors.New("OldWaName requires an ID field in the mutation")
  44012. }
  44013. oldValue, err := m.oldValue(ctx)
  44014. if err != nil {
  44015. return v, fmt.Errorf("querying old value for OldWaName: %w", err)
  44016. }
  44017. return oldValue.WaName, nil
  44018. }
  44019. // ClearWaName clears the value of the "wa_name" field.
  44020. func (m *WhatsappChannelMutation) ClearWaName() {
  44021. m.wa_name = nil
  44022. m.clearedFields[whatsappchannel.FieldWaName] = struct{}{}
  44023. }
  44024. // WaNameCleared returns if the "wa_name" field was cleared in this mutation.
  44025. func (m *WhatsappChannelMutation) WaNameCleared() bool {
  44026. _, ok := m.clearedFields[whatsappchannel.FieldWaName]
  44027. return ok
  44028. }
  44029. // ResetWaName resets all changes to the "wa_name" field.
  44030. func (m *WhatsappChannelMutation) ResetWaName() {
  44031. m.wa_name = nil
  44032. delete(m.clearedFields, whatsappchannel.FieldWaName)
  44033. }
  44034. // SetWabaID sets the "waba_id" field.
  44035. func (m *WhatsappChannelMutation) SetWabaID(u uint64) {
  44036. m.waba_id = &u
  44037. m.addwaba_id = nil
  44038. }
  44039. // WabaID returns the value of the "waba_id" field in the mutation.
  44040. func (m *WhatsappChannelMutation) WabaID() (r uint64, exists bool) {
  44041. v := m.waba_id
  44042. if v == nil {
  44043. return
  44044. }
  44045. return *v, true
  44046. }
  44047. // OldWabaID returns the old "waba_id" field's value of the WhatsappChannel entity.
  44048. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44050. func (m *WhatsappChannelMutation) OldWabaID(ctx context.Context) (v uint64, err error) {
  44051. if !m.op.Is(OpUpdateOne) {
  44052. return v, errors.New("OldWabaID is only allowed on UpdateOne operations")
  44053. }
  44054. if m.id == nil || m.oldValue == nil {
  44055. return v, errors.New("OldWabaID requires an ID field in the mutation")
  44056. }
  44057. oldValue, err := m.oldValue(ctx)
  44058. if err != nil {
  44059. return v, fmt.Errorf("querying old value for OldWabaID: %w", err)
  44060. }
  44061. return oldValue.WabaID, nil
  44062. }
  44063. // AddWabaID adds u to the "waba_id" field.
  44064. func (m *WhatsappChannelMutation) AddWabaID(u int64) {
  44065. if m.addwaba_id != nil {
  44066. *m.addwaba_id += u
  44067. } else {
  44068. m.addwaba_id = &u
  44069. }
  44070. }
  44071. // AddedWabaID returns the value that was added to the "waba_id" field in this mutation.
  44072. func (m *WhatsappChannelMutation) AddedWabaID() (r int64, exists bool) {
  44073. v := m.addwaba_id
  44074. if v == nil {
  44075. return
  44076. }
  44077. return *v, true
  44078. }
  44079. // ResetWabaID resets all changes to the "waba_id" field.
  44080. func (m *WhatsappChannelMutation) ResetWabaID() {
  44081. m.waba_id = nil
  44082. m.addwaba_id = nil
  44083. }
  44084. // SetBusinessID sets the "business_id" field.
  44085. func (m *WhatsappChannelMutation) SetBusinessID(u uint64) {
  44086. m.business_id = &u
  44087. m.addbusiness_id = nil
  44088. }
  44089. // BusinessID returns the value of the "business_id" field in the mutation.
  44090. func (m *WhatsappChannelMutation) BusinessID() (r uint64, exists bool) {
  44091. v := m.business_id
  44092. if v == nil {
  44093. return
  44094. }
  44095. return *v, true
  44096. }
  44097. // OldBusinessID returns the old "business_id" field's value of the WhatsappChannel entity.
  44098. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44100. func (m *WhatsappChannelMutation) OldBusinessID(ctx context.Context) (v uint64, err error) {
  44101. if !m.op.Is(OpUpdateOne) {
  44102. return v, errors.New("OldBusinessID is only allowed on UpdateOne operations")
  44103. }
  44104. if m.id == nil || m.oldValue == nil {
  44105. return v, errors.New("OldBusinessID requires an ID field in the mutation")
  44106. }
  44107. oldValue, err := m.oldValue(ctx)
  44108. if err != nil {
  44109. return v, fmt.Errorf("querying old value for OldBusinessID: %w", err)
  44110. }
  44111. return oldValue.BusinessID, nil
  44112. }
  44113. // AddBusinessID adds u to the "business_id" field.
  44114. func (m *WhatsappChannelMutation) AddBusinessID(u int64) {
  44115. if m.addbusiness_id != nil {
  44116. *m.addbusiness_id += u
  44117. } else {
  44118. m.addbusiness_id = &u
  44119. }
  44120. }
  44121. // AddedBusinessID returns the value that was added to the "business_id" field in this mutation.
  44122. func (m *WhatsappChannelMutation) AddedBusinessID() (r int64, exists bool) {
  44123. v := m.addbusiness_id
  44124. if v == nil {
  44125. return
  44126. }
  44127. return *v, true
  44128. }
  44129. // ResetBusinessID resets all changes to the "business_id" field.
  44130. func (m *WhatsappChannelMutation) ResetBusinessID() {
  44131. m.business_id = nil
  44132. m.addbusiness_id = nil
  44133. }
  44134. // SetOrganizationID sets the "organization_id" field.
  44135. func (m *WhatsappChannelMutation) SetOrganizationID(u uint64) {
  44136. m.organization_id = &u
  44137. m.addorganization_id = nil
  44138. }
  44139. // OrganizationID returns the value of the "organization_id" field in the mutation.
  44140. func (m *WhatsappChannelMutation) OrganizationID() (r uint64, exists bool) {
  44141. v := m.organization_id
  44142. if v == nil {
  44143. return
  44144. }
  44145. return *v, true
  44146. }
  44147. // OldOrganizationID returns the old "organization_id" field's value of the WhatsappChannel entity.
  44148. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44150. func (m *WhatsappChannelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  44151. if !m.op.Is(OpUpdateOne) {
  44152. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  44153. }
  44154. if m.id == nil || m.oldValue == nil {
  44155. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  44156. }
  44157. oldValue, err := m.oldValue(ctx)
  44158. if err != nil {
  44159. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  44160. }
  44161. return oldValue.OrganizationID, nil
  44162. }
  44163. // AddOrganizationID adds u to the "organization_id" field.
  44164. func (m *WhatsappChannelMutation) AddOrganizationID(u int64) {
  44165. if m.addorganization_id != nil {
  44166. *m.addorganization_id += u
  44167. } else {
  44168. m.addorganization_id = &u
  44169. }
  44170. }
  44171. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  44172. func (m *WhatsappChannelMutation) AddedOrganizationID() (r int64, exists bool) {
  44173. v := m.addorganization_id
  44174. if v == nil {
  44175. return
  44176. }
  44177. return *v, true
  44178. }
  44179. // ClearOrganizationID clears the value of the "organization_id" field.
  44180. func (m *WhatsappChannelMutation) ClearOrganizationID() {
  44181. m.organization_id = nil
  44182. m.addorganization_id = nil
  44183. m.clearedFields[whatsappchannel.FieldOrganizationID] = struct{}{}
  44184. }
  44185. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  44186. func (m *WhatsappChannelMutation) OrganizationIDCleared() bool {
  44187. _, ok := m.clearedFields[whatsappchannel.FieldOrganizationID]
  44188. return ok
  44189. }
  44190. // ResetOrganizationID resets all changes to the "organization_id" field.
  44191. func (m *WhatsappChannelMutation) ResetOrganizationID() {
  44192. m.organization_id = nil
  44193. m.addorganization_id = nil
  44194. delete(m.clearedFields, whatsappchannel.FieldOrganizationID)
  44195. }
  44196. // SetVerifyAccount sets the "verify_account" field.
  44197. func (m *WhatsappChannelMutation) SetVerifyAccount(s string) {
  44198. m.verify_account = &s
  44199. }
  44200. // VerifyAccount returns the value of the "verify_account" field in the mutation.
  44201. func (m *WhatsappChannelMutation) VerifyAccount() (r string, exists bool) {
  44202. v := m.verify_account
  44203. if v == nil {
  44204. return
  44205. }
  44206. return *v, true
  44207. }
  44208. // OldVerifyAccount returns the old "verify_account" field's value of the WhatsappChannel entity.
  44209. // If the WhatsappChannel object wasn't provided to the builder, the object is fetched from the database.
  44210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44211. func (m *WhatsappChannelMutation) OldVerifyAccount(ctx context.Context) (v string, err error) {
  44212. if !m.op.Is(OpUpdateOne) {
  44213. return v, errors.New("OldVerifyAccount is only allowed on UpdateOne operations")
  44214. }
  44215. if m.id == nil || m.oldValue == nil {
  44216. return v, errors.New("OldVerifyAccount requires an ID field in the mutation")
  44217. }
  44218. oldValue, err := m.oldValue(ctx)
  44219. if err != nil {
  44220. return v, fmt.Errorf("querying old value for OldVerifyAccount: %w", err)
  44221. }
  44222. return oldValue.VerifyAccount, nil
  44223. }
  44224. // ResetVerifyAccount resets all changes to the "verify_account" field.
  44225. func (m *WhatsappChannelMutation) ResetVerifyAccount() {
  44226. m.verify_account = nil
  44227. }
  44228. // Where appends a list predicates to the WhatsappChannelMutation builder.
  44229. func (m *WhatsappChannelMutation) Where(ps ...predicate.WhatsappChannel) {
  44230. m.predicates = append(m.predicates, ps...)
  44231. }
  44232. // WhereP appends storage-level predicates to the WhatsappChannelMutation builder. Using this method,
  44233. // users can use type-assertion to append predicates that do not depend on any generated package.
  44234. func (m *WhatsappChannelMutation) WhereP(ps ...func(*sql.Selector)) {
  44235. p := make([]predicate.WhatsappChannel, len(ps))
  44236. for i := range ps {
  44237. p[i] = ps[i]
  44238. }
  44239. m.Where(p...)
  44240. }
  44241. // Op returns the operation name.
  44242. func (m *WhatsappChannelMutation) Op() Op {
  44243. return m.op
  44244. }
  44245. // SetOp allows setting the mutation operation.
  44246. func (m *WhatsappChannelMutation) SetOp(op Op) {
  44247. m.op = op
  44248. }
  44249. // Type returns the node type of this mutation (WhatsappChannel).
  44250. func (m *WhatsappChannelMutation) Type() string {
  44251. return m.typ
  44252. }
  44253. // Fields returns all fields that were changed during this mutation. Note that in
  44254. // order to get all numeric fields that were incremented/decremented, call
  44255. // AddedFields().
  44256. func (m *WhatsappChannelMutation) Fields() []string {
  44257. fields := make([]string, 0, 12)
  44258. if m.created_at != nil {
  44259. fields = append(fields, whatsappchannel.FieldCreatedAt)
  44260. }
  44261. if m.updated_at != nil {
  44262. fields = append(fields, whatsappchannel.FieldUpdatedAt)
  44263. }
  44264. if m.status != nil {
  44265. fields = append(fields, whatsappchannel.FieldStatus)
  44266. }
  44267. if m.deleted_at != nil {
  44268. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44269. }
  44270. if m.ak != nil {
  44271. fields = append(fields, whatsappchannel.FieldAk)
  44272. }
  44273. if m.sk != nil {
  44274. fields = append(fields, whatsappchannel.FieldSk)
  44275. }
  44276. if m.wa_id != nil {
  44277. fields = append(fields, whatsappchannel.FieldWaID)
  44278. }
  44279. if m.wa_name != nil {
  44280. fields = append(fields, whatsappchannel.FieldWaName)
  44281. }
  44282. if m.waba_id != nil {
  44283. fields = append(fields, whatsappchannel.FieldWabaID)
  44284. }
  44285. if m.business_id != nil {
  44286. fields = append(fields, whatsappchannel.FieldBusinessID)
  44287. }
  44288. if m.organization_id != nil {
  44289. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44290. }
  44291. if m.verify_account != nil {
  44292. fields = append(fields, whatsappchannel.FieldVerifyAccount)
  44293. }
  44294. return fields
  44295. }
  44296. // Field returns the value of a field with the given name. The second boolean
  44297. // return value indicates that this field was not set, or was not defined in the
  44298. // schema.
  44299. func (m *WhatsappChannelMutation) Field(name string) (ent.Value, bool) {
  44300. switch name {
  44301. case whatsappchannel.FieldCreatedAt:
  44302. return m.CreatedAt()
  44303. case whatsappchannel.FieldUpdatedAt:
  44304. return m.UpdatedAt()
  44305. case whatsappchannel.FieldStatus:
  44306. return m.Status()
  44307. case whatsappchannel.FieldDeletedAt:
  44308. return m.DeletedAt()
  44309. case whatsappchannel.FieldAk:
  44310. return m.Ak()
  44311. case whatsappchannel.FieldSk:
  44312. return m.Sk()
  44313. case whatsappchannel.FieldWaID:
  44314. return m.WaID()
  44315. case whatsappchannel.FieldWaName:
  44316. return m.WaName()
  44317. case whatsappchannel.FieldWabaID:
  44318. return m.WabaID()
  44319. case whatsappchannel.FieldBusinessID:
  44320. return m.BusinessID()
  44321. case whatsappchannel.FieldOrganizationID:
  44322. return m.OrganizationID()
  44323. case whatsappchannel.FieldVerifyAccount:
  44324. return m.VerifyAccount()
  44325. }
  44326. return nil, false
  44327. }
  44328. // OldField returns the old value of the field from the database. An error is
  44329. // returned if the mutation operation is not UpdateOne, or the query to the
  44330. // database failed.
  44331. func (m *WhatsappChannelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  44332. switch name {
  44333. case whatsappchannel.FieldCreatedAt:
  44334. return m.OldCreatedAt(ctx)
  44335. case whatsappchannel.FieldUpdatedAt:
  44336. return m.OldUpdatedAt(ctx)
  44337. case whatsappchannel.FieldStatus:
  44338. return m.OldStatus(ctx)
  44339. case whatsappchannel.FieldDeletedAt:
  44340. return m.OldDeletedAt(ctx)
  44341. case whatsappchannel.FieldAk:
  44342. return m.OldAk(ctx)
  44343. case whatsappchannel.FieldSk:
  44344. return m.OldSk(ctx)
  44345. case whatsappchannel.FieldWaID:
  44346. return m.OldWaID(ctx)
  44347. case whatsappchannel.FieldWaName:
  44348. return m.OldWaName(ctx)
  44349. case whatsappchannel.FieldWabaID:
  44350. return m.OldWabaID(ctx)
  44351. case whatsappchannel.FieldBusinessID:
  44352. return m.OldBusinessID(ctx)
  44353. case whatsappchannel.FieldOrganizationID:
  44354. return m.OldOrganizationID(ctx)
  44355. case whatsappchannel.FieldVerifyAccount:
  44356. return m.OldVerifyAccount(ctx)
  44357. }
  44358. return nil, fmt.Errorf("unknown WhatsappChannel field %s", name)
  44359. }
  44360. // SetField sets the value of a field with the given name. It returns an error if
  44361. // the field is not defined in the schema, or if the type mismatched the field
  44362. // type.
  44363. func (m *WhatsappChannelMutation) SetField(name string, value ent.Value) error {
  44364. switch name {
  44365. case whatsappchannel.FieldCreatedAt:
  44366. v, ok := value.(time.Time)
  44367. if !ok {
  44368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44369. }
  44370. m.SetCreatedAt(v)
  44371. return nil
  44372. case whatsappchannel.FieldUpdatedAt:
  44373. v, ok := value.(time.Time)
  44374. if !ok {
  44375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44376. }
  44377. m.SetUpdatedAt(v)
  44378. return nil
  44379. case whatsappchannel.FieldStatus:
  44380. v, ok := value.(uint8)
  44381. if !ok {
  44382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44383. }
  44384. m.SetStatus(v)
  44385. return nil
  44386. case whatsappchannel.FieldDeletedAt:
  44387. v, ok := value.(time.Time)
  44388. if !ok {
  44389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44390. }
  44391. m.SetDeletedAt(v)
  44392. return nil
  44393. case whatsappchannel.FieldAk:
  44394. v, ok := value.(string)
  44395. if !ok {
  44396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44397. }
  44398. m.SetAk(v)
  44399. return nil
  44400. case whatsappchannel.FieldSk:
  44401. v, ok := value.(string)
  44402. if !ok {
  44403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44404. }
  44405. m.SetSk(v)
  44406. return nil
  44407. case whatsappchannel.FieldWaID:
  44408. v, ok := value.(string)
  44409. if !ok {
  44410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44411. }
  44412. m.SetWaID(v)
  44413. return nil
  44414. case whatsappchannel.FieldWaName:
  44415. v, ok := value.(string)
  44416. if !ok {
  44417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44418. }
  44419. m.SetWaName(v)
  44420. return nil
  44421. case whatsappchannel.FieldWabaID:
  44422. v, ok := value.(uint64)
  44423. if !ok {
  44424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44425. }
  44426. m.SetWabaID(v)
  44427. return nil
  44428. case whatsappchannel.FieldBusinessID:
  44429. v, ok := value.(uint64)
  44430. if !ok {
  44431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44432. }
  44433. m.SetBusinessID(v)
  44434. return nil
  44435. case whatsappchannel.FieldOrganizationID:
  44436. v, ok := value.(uint64)
  44437. if !ok {
  44438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44439. }
  44440. m.SetOrganizationID(v)
  44441. return nil
  44442. case whatsappchannel.FieldVerifyAccount:
  44443. v, ok := value.(string)
  44444. if !ok {
  44445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44446. }
  44447. m.SetVerifyAccount(v)
  44448. return nil
  44449. }
  44450. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44451. }
  44452. // AddedFields returns all numeric fields that were incremented/decremented during
  44453. // this mutation.
  44454. func (m *WhatsappChannelMutation) AddedFields() []string {
  44455. var fields []string
  44456. if m.addstatus != nil {
  44457. fields = append(fields, whatsappchannel.FieldStatus)
  44458. }
  44459. if m.addwaba_id != nil {
  44460. fields = append(fields, whatsappchannel.FieldWabaID)
  44461. }
  44462. if m.addbusiness_id != nil {
  44463. fields = append(fields, whatsappchannel.FieldBusinessID)
  44464. }
  44465. if m.addorganization_id != nil {
  44466. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44467. }
  44468. return fields
  44469. }
  44470. // AddedField returns the numeric value that was incremented/decremented on a field
  44471. // with the given name. The second boolean return value indicates that this field
  44472. // was not set, or was not defined in the schema.
  44473. func (m *WhatsappChannelMutation) AddedField(name string) (ent.Value, bool) {
  44474. switch name {
  44475. case whatsappchannel.FieldStatus:
  44476. return m.AddedStatus()
  44477. case whatsappchannel.FieldWabaID:
  44478. return m.AddedWabaID()
  44479. case whatsappchannel.FieldBusinessID:
  44480. return m.AddedBusinessID()
  44481. case whatsappchannel.FieldOrganizationID:
  44482. return m.AddedOrganizationID()
  44483. }
  44484. return nil, false
  44485. }
  44486. // AddField adds the value to the field with the given name. It returns an error if
  44487. // the field is not defined in the schema, or if the type mismatched the field
  44488. // type.
  44489. func (m *WhatsappChannelMutation) AddField(name string, value ent.Value) error {
  44490. switch name {
  44491. case whatsappchannel.FieldStatus:
  44492. v, ok := value.(int8)
  44493. if !ok {
  44494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44495. }
  44496. m.AddStatus(v)
  44497. return nil
  44498. case whatsappchannel.FieldWabaID:
  44499. v, ok := value.(int64)
  44500. if !ok {
  44501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44502. }
  44503. m.AddWabaID(v)
  44504. return nil
  44505. case whatsappchannel.FieldBusinessID:
  44506. v, ok := value.(int64)
  44507. if !ok {
  44508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44509. }
  44510. m.AddBusinessID(v)
  44511. return nil
  44512. case whatsappchannel.FieldOrganizationID:
  44513. v, ok := value.(int64)
  44514. if !ok {
  44515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  44516. }
  44517. m.AddOrganizationID(v)
  44518. return nil
  44519. }
  44520. return fmt.Errorf("unknown WhatsappChannel numeric field %s", name)
  44521. }
  44522. // ClearedFields returns all nullable fields that were cleared during this
  44523. // mutation.
  44524. func (m *WhatsappChannelMutation) ClearedFields() []string {
  44525. var fields []string
  44526. if m.FieldCleared(whatsappchannel.FieldStatus) {
  44527. fields = append(fields, whatsappchannel.FieldStatus)
  44528. }
  44529. if m.FieldCleared(whatsappchannel.FieldDeletedAt) {
  44530. fields = append(fields, whatsappchannel.FieldDeletedAt)
  44531. }
  44532. if m.FieldCleared(whatsappchannel.FieldAk) {
  44533. fields = append(fields, whatsappchannel.FieldAk)
  44534. }
  44535. if m.FieldCleared(whatsappchannel.FieldWaID) {
  44536. fields = append(fields, whatsappchannel.FieldWaID)
  44537. }
  44538. if m.FieldCleared(whatsappchannel.FieldWaName) {
  44539. fields = append(fields, whatsappchannel.FieldWaName)
  44540. }
  44541. if m.FieldCleared(whatsappchannel.FieldOrganizationID) {
  44542. fields = append(fields, whatsappchannel.FieldOrganizationID)
  44543. }
  44544. return fields
  44545. }
  44546. // FieldCleared returns a boolean indicating if a field with the given name was
  44547. // cleared in this mutation.
  44548. func (m *WhatsappChannelMutation) FieldCleared(name string) bool {
  44549. _, ok := m.clearedFields[name]
  44550. return ok
  44551. }
  44552. // ClearField clears the value of the field with the given name. It returns an
  44553. // error if the field is not defined in the schema.
  44554. func (m *WhatsappChannelMutation) ClearField(name string) error {
  44555. switch name {
  44556. case whatsappchannel.FieldStatus:
  44557. m.ClearStatus()
  44558. return nil
  44559. case whatsappchannel.FieldDeletedAt:
  44560. m.ClearDeletedAt()
  44561. return nil
  44562. case whatsappchannel.FieldAk:
  44563. m.ClearAk()
  44564. return nil
  44565. case whatsappchannel.FieldWaID:
  44566. m.ClearWaID()
  44567. return nil
  44568. case whatsappchannel.FieldWaName:
  44569. m.ClearWaName()
  44570. return nil
  44571. case whatsappchannel.FieldOrganizationID:
  44572. m.ClearOrganizationID()
  44573. return nil
  44574. }
  44575. return fmt.Errorf("unknown WhatsappChannel nullable field %s", name)
  44576. }
  44577. // ResetField resets all changes in the mutation for the field with the given name.
  44578. // It returns an error if the field is not defined in the schema.
  44579. func (m *WhatsappChannelMutation) ResetField(name string) error {
  44580. switch name {
  44581. case whatsappchannel.FieldCreatedAt:
  44582. m.ResetCreatedAt()
  44583. return nil
  44584. case whatsappchannel.FieldUpdatedAt:
  44585. m.ResetUpdatedAt()
  44586. return nil
  44587. case whatsappchannel.FieldStatus:
  44588. m.ResetStatus()
  44589. return nil
  44590. case whatsappchannel.FieldDeletedAt:
  44591. m.ResetDeletedAt()
  44592. return nil
  44593. case whatsappchannel.FieldAk:
  44594. m.ResetAk()
  44595. return nil
  44596. case whatsappchannel.FieldSk:
  44597. m.ResetSk()
  44598. return nil
  44599. case whatsappchannel.FieldWaID:
  44600. m.ResetWaID()
  44601. return nil
  44602. case whatsappchannel.FieldWaName:
  44603. m.ResetWaName()
  44604. return nil
  44605. case whatsappchannel.FieldWabaID:
  44606. m.ResetWabaID()
  44607. return nil
  44608. case whatsappchannel.FieldBusinessID:
  44609. m.ResetBusinessID()
  44610. return nil
  44611. case whatsappchannel.FieldOrganizationID:
  44612. m.ResetOrganizationID()
  44613. return nil
  44614. case whatsappchannel.FieldVerifyAccount:
  44615. m.ResetVerifyAccount()
  44616. return nil
  44617. }
  44618. return fmt.Errorf("unknown WhatsappChannel field %s", name)
  44619. }
  44620. // AddedEdges returns all edge names that were set/added in this mutation.
  44621. func (m *WhatsappChannelMutation) AddedEdges() []string {
  44622. edges := make([]string, 0, 0)
  44623. return edges
  44624. }
  44625. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  44626. // name in this mutation.
  44627. func (m *WhatsappChannelMutation) AddedIDs(name string) []ent.Value {
  44628. return nil
  44629. }
  44630. // RemovedEdges returns all edge names that were removed in this mutation.
  44631. func (m *WhatsappChannelMutation) RemovedEdges() []string {
  44632. edges := make([]string, 0, 0)
  44633. return edges
  44634. }
  44635. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  44636. // the given name in this mutation.
  44637. func (m *WhatsappChannelMutation) RemovedIDs(name string) []ent.Value {
  44638. return nil
  44639. }
  44640. // ClearedEdges returns all edge names that were cleared in this mutation.
  44641. func (m *WhatsappChannelMutation) ClearedEdges() []string {
  44642. edges := make([]string, 0, 0)
  44643. return edges
  44644. }
  44645. // EdgeCleared returns a boolean which indicates if the edge with the given name
  44646. // was cleared in this mutation.
  44647. func (m *WhatsappChannelMutation) EdgeCleared(name string) bool {
  44648. return false
  44649. }
  44650. // ClearEdge clears the value of the edge with the given name. It returns an error
  44651. // if that edge is not defined in the schema.
  44652. func (m *WhatsappChannelMutation) ClearEdge(name string) error {
  44653. return fmt.Errorf("unknown WhatsappChannel unique edge %s", name)
  44654. }
  44655. // ResetEdge resets all changes to the edge with the given name in this mutation.
  44656. // It returns an error if the edge is not defined in the schema.
  44657. func (m *WhatsappChannelMutation) ResetEdge(name string) error {
  44658. return fmt.Errorf("unknown WhatsappChannel edge %s", name)
  44659. }
  44660. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  44661. type WorkExperienceMutation struct {
  44662. config
  44663. op Op
  44664. typ string
  44665. id *uint64
  44666. created_at *time.Time
  44667. updated_at *time.Time
  44668. deleted_at *time.Time
  44669. start_date *time.Time
  44670. end_date *time.Time
  44671. company *string
  44672. experience *string
  44673. organization_id *uint64
  44674. addorganization_id *int64
  44675. clearedFields map[string]struct{}
  44676. employee *uint64
  44677. clearedemployee bool
  44678. done bool
  44679. oldValue func(context.Context) (*WorkExperience, error)
  44680. predicates []predicate.WorkExperience
  44681. }
  44682. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  44683. // workexperienceOption allows management of the mutation configuration using functional options.
  44684. type workexperienceOption func(*WorkExperienceMutation)
  44685. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  44686. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  44687. m := &WorkExperienceMutation{
  44688. config: c,
  44689. op: op,
  44690. typ: TypeWorkExperience,
  44691. clearedFields: make(map[string]struct{}),
  44692. }
  44693. for _, opt := range opts {
  44694. opt(m)
  44695. }
  44696. return m
  44697. }
  44698. // withWorkExperienceID sets the ID field of the mutation.
  44699. func withWorkExperienceID(id uint64) workexperienceOption {
  44700. return func(m *WorkExperienceMutation) {
  44701. var (
  44702. err error
  44703. once sync.Once
  44704. value *WorkExperience
  44705. )
  44706. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  44707. once.Do(func() {
  44708. if m.done {
  44709. err = errors.New("querying old values post mutation is not allowed")
  44710. } else {
  44711. value, err = m.Client().WorkExperience.Get(ctx, id)
  44712. }
  44713. })
  44714. return value, err
  44715. }
  44716. m.id = &id
  44717. }
  44718. }
  44719. // withWorkExperience sets the old WorkExperience of the mutation.
  44720. func withWorkExperience(node *WorkExperience) workexperienceOption {
  44721. return func(m *WorkExperienceMutation) {
  44722. m.oldValue = func(context.Context) (*WorkExperience, error) {
  44723. return node, nil
  44724. }
  44725. m.id = &node.ID
  44726. }
  44727. }
  44728. // Client returns a new `ent.Client` from the mutation. If the mutation was
  44729. // executed in a transaction (ent.Tx), a transactional client is returned.
  44730. func (m WorkExperienceMutation) Client() *Client {
  44731. client := &Client{config: m.config}
  44732. client.init()
  44733. return client
  44734. }
  44735. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  44736. // it returns an error otherwise.
  44737. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  44738. if _, ok := m.driver.(*txDriver); !ok {
  44739. return nil, errors.New("ent: mutation is not running in a transaction")
  44740. }
  44741. tx := &Tx{config: m.config}
  44742. tx.init()
  44743. return tx, nil
  44744. }
  44745. // SetID sets the value of the id field. Note that this
  44746. // operation is only accepted on creation of WorkExperience entities.
  44747. func (m *WorkExperienceMutation) SetID(id uint64) {
  44748. m.id = &id
  44749. }
  44750. // ID returns the ID value in the mutation. Note that the ID is only available
  44751. // if it was provided to the builder or after it was returned from the database.
  44752. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  44753. if m.id == nil {
  44754. return
  44755. }
  44756. return *m.id, true
  44757. }
  44758. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  44759. // That means, if the mutation is applied within a transaction with an isolation level such
  44760. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  44761. // or updated by the mutation.
  44762. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  44763. switch {
  44764. case m.op.Is(OpUpdateOne | OpDeleteOne):
  44765. id, exists := m.ID()
  44766. if exists {
  44767. return []uint64{id}, nil
  44768. }
  44769. fallthrough
  44770. case m.op.Is(OpUpdate | OpDelete):
  44771. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  44772. default:
  44773. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  44774. }
  44775. }
  44776. // SetCreatedAt sets the "created_at" field.
  44777. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  44778. m.created_at = &t
  44779. }
  44780. // CreatedAt returns the value of the "created_at" field in the mutation.
  44781. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  44782. v := m.created_at
  44783. if v == nil {
  44784. return
  44785. }
  44786. return *v, true
  44787. }
  44788. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  44789. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44791. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  44792. if !m.op.Is(OpUpdateOne) {
  44793. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  44794. }
  44795. if m.id == nil || m.oldValue == nil {
  44796. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  44797. }
  44798. oldValue, err := m.oldValue(ctx)
  44799. if err != nil {
  44800. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  44801. }
  44802. return oldValue.CreatedAt, nil
  44803. }
  44804. // ResetCreatedAt resets all changes to the "created_at" field.
  44805. func (m *WorkExperienceMutation) ResetCreatedAt() {
  44806. m.created_at = nil
  44807. }
  44808. // SetUpdatedAt sets the "updated_at" field.
  44809. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  44810. m.updated_at = &t
  44811. }
  44812. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  44813. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  44814. v := m.updated_at
  44815. if v == nil {
  44816. return
  44817. }
  44818. return *v, true
  44819. }
  44820. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  44821. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44823. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  44824. if !m.op.Is(OpUpdateOne) {
  44825. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  44826. }
  44827. if m.id == nil || m.oldValue == nil {
  44828. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  44829. }
  44830. oldValue, err := m.oldValue(ctx)
  44831. if err != nil {
  44832. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  44833. }
  44834. return oldValue.UpdatedAt, nil
  44835. }
  44836. // ResetUpdatedAt resets all changes to the "updated_at" field.
  44837. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  44838. m.updated_at = nil
  44839. }
  44840. // SetDeletedAt sets the "deleted_at" field.
  44841. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  44842. m.deleted_at = &t
  44843. }
  44844. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  44845. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  44846. v := m.deleted_at
  44847. if v == nil {
  44848. return
  44849. }
  44850. return *v, true
  44851. }
  44852. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  44853. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44855. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  44856. if !m.op.Is(OpUpdateOne) {
  44857. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  44858. }
  44859. if m.id == nil || m.oldValue == nil {
  44860. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  44861. }
  44862. oldValue, err := m.oldValue(ctx)
  44863. if err != nil {
  44864. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  44865. }
  44866. return oldValue.DeletedAt, nil
  44867. }
  44868. // ClearDeletedAt clears the value of the "deleted_at" field.
  44869. func (m *WorkExperienceMutation) ClearDeletedAt() {
  44870. m.deleted_at = nil
  44871. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  44872. }
  44873. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  44874. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  44875. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  44876. return ok
  44877. }
  44878. // ResetDeletedAt resets all changes to the "deleted_at" field.
  44879. func (m *WorkExperienceMutation) ResetDeletedAt() {
  44880. m.deleted_at = nil
  44881. delete(m.clearedFields, workexperience.FieldDeletedAt)
  44882. }
  44883. // SetEmployeeID sets the "employee_id" field.
  44884. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  44885. m.employee = &u
  44886. }
  44887. // EmployeeID returns the value of the "employee_id" field in the mutation.
  44888. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  44889. v := m.employee
  44890. if v == nil {
  44891. return
  44892. }
  44893. return *v, true
  44894. }
  44895. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  44896. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44898. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  44899. if !m.op.Is(OpUpdateOne) {
  44900. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  44901. }
  44902. if m.id == nil || m.oldValue == nil {
  44903. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  44904. }
  44905. oldValue, err := m.oldValue(ctx)
  44906. if err != nil {
  44907. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  44908. }
  44909. return oldValue.EmployeeID, nil
  44910. }
  44911. // ResetEmployeeID resets all changes to the "employee_id" field.
  44912. func (m *WorkExperienceMutation) ResetEmployeeID() {
  44913. m.employee = nil
  44914. }
  44915. // SetStartDate sets the "start_date" field.
  44916. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  44917. m.start_date = &t
  44918. }
  44919. // StartDate returns the value of the "start_date" field in the mutation.
  44920. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  44921. v := m.start_date
  44922. if v == nil {
  44923. return
  44924. }
  44925. return *v, true
  44926. }
  44927. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  44928. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44930. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  44931. if !m.op.Is(OpUpdateOne) {
  44932. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  44933. }
  44934. if m.id == nil || m.oldValue == nil {
  44935. return v, errors.New("OldStartDate requires an ID field in the mutation")
  44936. }
  44937. oldValue, err := m.oldValue(ctx)
  44938. if err != nil {
  44939. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  44940. }
  44941. return oldValue.StartDate, nil
  44942. }
  44943. // ResetStartDate resets all changes to the "start_date" field.
  44944. func (m *WorkExperienceMutation) ResetStartDate() {
  44945. m.start_date = nil
  44946. }
  44947. // SetEndDate sets the "end_date" field.
  44948. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  44949. m.end_date = &t
  44950. }
  44951. // EndDate returns the value of the "end_date" field in the mutation.
  44952. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  44953. v := m.end_date
  44954. if v == nil {
  44955. return
  44956. }
  44957. return *v, true
  44958. }
  44959. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  44960. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44962. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  44963. if !m.op.Is(OpUpdateOne) {
  44964. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  44965. }
  44966. if m.id == nil || m.oldValue == nil {
  44967. return v, errors.New("OldEndDate requires an ID field in the mutation")
  44968. }
  44969. oldValue, err := m.oldValue(ctx)
  44970. if err != nil {
  44971. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  44972. }
  44973. return oldValue.EndDate, nil
  44974. }
  44975. // ResetEndDate resets all changes to the "end_date" field.
  44976. func (m *WorkExperienceMutation) ResetEndDate() {
  44977. m.end_date = nil
  44978. }
  44979. // SetCompany sets the "company" field.
  44980. func (m *WorkExperienceMutation) SetCompany(s string) {
  44981. m.company = &s
  44982. }
  44983. // Company returns the value of the "company" field in the mutation.
  44984. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  44985. v := m.company
  44986. if v == nil {
  44987. return
  44988. }
  44989. return *v, true
  44990. }
  44991. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  44992. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  44993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  44994. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  44995. if !m.op.Is(OpUpdateOne) {
  44996. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  44997. }
  44998. if m.id == nil || m.oldValue == nil {
  44999. return v, errors.New("OldCompany requires an ID field in the mutation")
  45000. }
  45001. oldValue, err := m.oldValue(ctx)
  45002. if err != nil {
  45003. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  45004. }
  45005. return oldValue.Company, nil
  45006. }
  45007. // ResetCompany resets all changes to the "company" field.
  45008. func (m *WorkExperienceMutation) ResetCompany() {
  45009. m.company = nil
  45010. }
  45011. // SetExperience sets the "experience" field.
  45012. func (m *WorkExperienceMutation) SetExperience(s string) {
  45013. m.experience = &s
  45014. }
  45015. // Experience returns the value of the "experience" field in the mutation.
  45016. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  45017. v := m.experience
  45018. if v == nil {
  45019. return
  45020. }
  45021. return *v, true
  45022. }
  45023. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  45024. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45025. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45026. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  45027. if !m.op.Is(OpUpdateOne) {
  45028. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  45029. }
  45030. if m.id == nil || m.oldValue == nil {
  45031. return v, errors.New("OldExperience requires an ID field in the mutation")
  45032. }
  45033. oldValue, err := m.oldValue(ctx)
  45034. if err != nil {
  45035. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  45036. }
  45037. return oldValue.Experience, nil
  45038. }
  45039. // ResetExperience resets all changes to the "experience" field.
  45040. func (m *WorkExperienceMutation) ResetExperience() {
  45041. m.experience = nil
  45042. }
  45043. // SetOrganizationID sets the "organization_id" field.
  45044. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  45045. m.organization_id = &u
  45046. m.addorganization_id = nil
  45047. }
  45048. // OrganizationID returns the value of the "organization_id" field in the mutation.
  45049. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  45050. v := m.organization_id
  45051. if v == nil {
  45052. return
  45053. }
  45054. return *v, true
  45055. }
  45056. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  45057. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  45058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45059. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  45060. if !m.op.Is(OpUpdateOne) {
  45061. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  45062. }
  45063. if m.id == nil || m.oldValue == nil {
  45064. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  45065. }
  45066. oldValue, err := m.oldValue(ctx)
  45067. if err != nil {
  45068. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  45069. }
  45070. return oldValue.OrganizationID, nil
  45071. }
  45072. // AddOrganizationID adds u to the "organization_id" field.
  45073. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  45074. if m.addorganization_id != nil {
  45075. *m.addorganization_id += u
  45076. } else {
  45077. m.addorganization_id = &u
  45078. }
  45079. }
  45080. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  45081. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  45082. v := m.addorganization_id
  45083. if v == nil {
  45084. return
  45085. }
  45086. return *v, true
  45087. }
  45088. // ResetOrganizationID resets all changes to the "organization_id" field.
  45089. func (m *WorkExperienceMutation) ResetOrganizationID() {
  45090. m.organization_id = nil
  45091. m.addorganization_id = nil
  45092. }
  45093. // ClearEmployee clears the "employee" edge to the Employee entity.
  45094. func (m *WorkExperienceMutation) ClearEmployee() {
  45095. m.clearedemployee = true
  45096. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  45097. }
  45098. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  45099. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  45100. return m.clearedemployee
  45101. }
  45102. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  45103. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  45104. // EmployeeID instead. It exists only for internal usage by the builders.
  45105. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  45106. if id := m.employee; id != nil {
  45107. ids = append(ids, *id)
  45108. }
  45109. return
  45110. }
  45111. // ResetEmployee resets all changes to the "employee" edge.
  45112. func (m *WorkExperienceMutation) ResetEmployee() {
  45113. m.employee = nil
  45114. m.clearedemployee = false
  45115. }
  45116. // Where appends a list predicates to the WorkExperienceMutation builder.
  45117. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  45118. m.predicates = append(m.predicates, ps...)
  45119. }
  45120. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  45121. // users can use type-assertion to append predicates that do not depend on any generated package.
  45122. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  45123. p := make([]predicate.WorkExperience, len(ps))
  45124. for i := range ps {
  45125. p[i] = ps[i]
  45126. }
  45127. m.Where(p...)
  45128. }
  45129. // Op returns the operation name.
  45130. func (m *WorkExperienceMutation) Op() Op {
  45131. return m.op
  45132. }
  45133. // SetOp allows setting the mutation operation.
  45134. func (m *WorkExperienceMutation) SetOp(op Op) {
  45135. m.op = op
  45136. }
  45137. // Type returns the node type of this mutation (WorkExperience).
  45138. func (m *WorkExperienceMutation) Type() string {
  45139. return m.typ
  45140. }
  45141. // Fields returns all fields that were changed during this mutation. Note that in
  45142. // order to get all numeric fields that were incremented/decremented, call
  45143. // AddedFields().
  45144. func (m *WorkExperienceMutation) Fields() []string {
  45145. fields := make([]string, 0, 9)
  45146. if m.created_at != nil {
  45147. fields = append(fields, workexperience.FieldCreatedAt)
  45148. }
  45149. if m.updated_at != nil {
  45150. fields = append(fields, workexperience.FieldUpdatedAt)
  45151. }
  45152. if m.deleted_at != nil {
  45153. fields = append(fields, workexperience.FieldDeletedAt)
  45154. }
  45155. if m.employee != nil {
  45156. fields = append(fields, workexperience.FieldEmployeeID)
  45157. }
  45158. if m.start_date != nil {
  45159. fields = append(fields, workexperience.FieldStartDate)
  45160. }
  45161. if m.end_date != nil {
  45162. fields = append(fields, workexperience.FieldEndDate)
  45163. }
  45164. if m.company != nil {
  45165. fields = append(fields, workexperience.FieldCompany)
  45166. }
  45167. if m.experience != nil {
  45168. fields = append(fields, workexperience.FieldExperience)
  45169. }
  45170. if m.organization_id != nil {
  45171. fields = append(fields, workexperience.FieldOrganizationID)
  45172. }
  45173. return fields
  45174. }
  45175. // Field returns the value of a field with the given name. The second boolean
  45176. // return value indicates that this field was not set, or was not defined in the
  45177. // schema.
  45178. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  45179. switch name {
  45180. case workexperience.FieldCreatedAt:
  45181. return m.CreatedAt()
  45182. case workexperience.FieldUpdatedAt:
  45183. return m.UpdatedAt()
  45184. case workexperience.FieldDeletedAt:
  45185. return m.DeletedAt()
  45186. case workexperience.FieldEmployeeID:
  45187. return m.EmployeeID()
  45188. case workexperience.FieldStartDate:
  45189. return m.StartDate()
  45190. case workexperience.FieldEndDate:
  45191. return m.EndDate()
  45192. case workexperience.FieldCompany:
  45193. return m.Company()
  45194. case workexperience.FieldExperience:
  45195. return m.Experience()
  45196. case workexperience.FieldOrganizationID:
  45197. return m.OrganizationID()
  45198. }
  45199. return nil, false
  45200. }
  45201. // OldField returns the old value of the field from the database. An error is
  45202. // returned if the mutation operation is not UpdateOne, or the query to the
  45203. // database failed.
  45204. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45205. switch name {
  45206. case workexperience.FieldCreatedAt:
  45207. return m.OldCreatedAt(ctx)
  45208. case workexperience.FieldUpdatedAt:
  45209. return m.OldUpdatedAt(ctx)
  45210. case workexperience.FieldDeletedAt:
  45211. return m.OldDeletedAt(ctx)
  45212. case workexperience.FieldEmployeeID:
  45213. return m.OldEmployeeID(ctx)
  45214. case workexperience.FieldStartDate:
  45215. return m.OldStartDate(ctx)
  45216. case workexperience.FieldEndDate:
  45217. return m.OldEndDate(ctx)
  45218. case workexperience.FieldCompany:
  45219. return m.OldCompany(ctx)
  45220. case workexperience.FieldExperience:
  45221. return m.OldExperience(ctx)
  45222. case workexperience.FieldOrganizationID:
  45223. return m.OldOrganizationID(ctx)
  45224. }
  45225. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  45226. }
  45227. // SetField sets the value of a field with the given name. It returns an error if
  45228. // the field is not defined in the schema, or if the type mismatched the field
  45229. // type.
  45230. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  45231. switch name {
  45232. case workexperience.FieldCreatedAt:
  45233. v, ok := value.(time.Time)
  45234. if !ok {
  45235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45236. }
  45237. m.SetCreatedAt(v)
  45238. return nil
  45239. case workexperience.FieldUpdatedAt:
  45240. v, ok := value.(time.Time)
  45241. if !ok {
  45242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45243. }
  45244. m.SetUpdatedAt(v)
  45245. return nil
  45246. case workexperience.FieldDeletedAt:
  45247. v, ok := value.(time.Time)
  45248. if !ok {
  45249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45250. }
  45251. m.SetDeletedAt(v)
  45252. return nil
  45253. case workexperience.FieldEmployeeID:
  45254. v, ok := value.(uint64)
  45255. if !ok {
  45256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45257. }
  45258. m.SetEmployeeID(v)
  45259. return nil
  45260. case workexperience.FieldStartDate:
  45261. v, ok := value.(time.Time)
  45262. if !ok {
  45263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45264. }
  45265. m.SetStartDate(v)
  45266. return nil
  45267. case workexperience.FieldEndDate:
  45268. v, ok := value.(time.Time)
  45269. if !ok {
  45270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45271. }
  45272. m.SetEndDate(v)
  45273. return nil
  45274. case workexperience.FieldCompany:
  45275. v, ok := value.(string)
  45276. if !ok {
  45277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45278. }
  45279. m.SetCompany(v)
  45280. return nil
  45281. case workexperience.FieldExperience:
  45282. v, ok := value.(string)
  45283. if !ok {
  45284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45285. }
  45286. m.SetExperience(v)
  45287. return nil
  45288. case workexperience.FieldOrganizationID:
  45289. v, ok := value.(uint64)
  45290. if !ok {
  45291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45292. }
  45293. m.SetOrganizationID(v)
  45294. return nil
  45295. }
  45296. return fmt.Errorf("unknown WorkExperience field %s", name)
  45297. }
  45298. // AddedFields returns all numeric fields that were incremented/decremented during
  45299. // this mutation.
  45300. func (m *WorkExperienceMutation) AddedFields() []string {
  45301. var fields []string
  45302. if m.addorganization_id != nil {
  45303. fields = append(fields, workexperience.FieldOrganizationID)
  45304. }
  45305. return fields
  45306. }
  45307. // AddedField returns the numeric value that was incremented/decremented on a field
  45308. // with the given name. The second boolean return value indicates that this field
  45309. // was not set, or was not defined in the schema.
  45310. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  45311. switch name {
  45312. case workexperience.FieldOrganizationID:
  45313. return m.AddedOrganizationID()
  45314. }
  45315. return nil, false
  45316. }
  45317. // AddField adds the value to the field with the given name. It returns an error if
  45318. // the field is not defined in the schema, or if the type mismatched the field
  45319. // type.
  45320. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  45321. switch name {
  45322. case workexperience.FieldOrganizationID:
  45323. v, ok := value.(int64)
  45324. if !ok {
  45325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  45326. }
  45327. m.AddOrganizationID(v)
  45328. return nil
  45329. }
  45330. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  45331. }
  45332. // ClearedFields returns all nullable fields that were cleared during this
  45333. // mutation.
  45334. func (m *WorkExperienceMutation) ClearedFields() []string {
  45335. var fields []string
  45336. if m.FieldCleared(workexperience.FieldDeletedAt) {
  45337. fields = append(fields, workexperience.FieldDeletedAt)
  45338. }
  45339. return fields
  45340. }
  45341. // FieldCleared returns a boolean indicating if a field with the given name was
  45342. // cleared in this mutation.
  45343. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  45344. _, ok := m.clearedFields[name]
  45345. return ok
  45346. }
  45347. // ClearField clears the value of the field with the given name. It returns an
  45348. // error if the field is not defined in the schema.
  45349. func (m *WorkExperienceMutation) ClearField(name string) error {
  45350. switch name {
  45351. case workexperience.FieldDeletedAt:
  45352. m.ClearDeletedAt()
  45353. return nil
  45354. }
  45355. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  45356. }
  45357. // ResetField resets all changes in the mutation for the field with the given name.
  45358. // It returns an error if the field is not defined in the schema.
  45359. func (m *WorkExperienceMutation) ResetField(name string) error {
  45360. switch name {
  45361. case workexperience.FieldCreatedAt:
  45362. m.ResetCreatedAt()
  45363. return nil
  45364. case workexperience.FieldUpdatedAt:
  45365. m.ResetUpdatedAt()
  45366. return nil
  45367. case workexperience.FieldDeletedAt:
  45368. m.ResetDeletedAt()
  45369. return nil
  45370. case workexperience.FieldEmployeeID:
  45371. m.ResetEmployeeID()
  45372. return nil
  45373. case workexperience.FieldStartDate:
  45374. m.ResetStartDate()
  45375. return nil
  45376. case workexperience.FieldEndDate:
  45377. m.ResetEndDate()
  45378. return nil
  45379. case workexperience.FieldCompany:
  45380. m.ResetCompany()
  45381. return nil
  45382. case workexperience.FieldExperience:
  45383. m.ResetExperience()
  45384. return nil
  45385. case workexperience.FieldOrganizationID:
  45386. m.ResetOrganizationID()
  45387. return nil
  45388. }
  45389. return fmt.Errorf("unknown WorkExperience field %s", name)
  45390. }
  45391. // AddedEdges returns all edge names that were set/added in this mutation.
  45392. func (m *WorkExperienceMutation) AddedEdges() []string {
  45393. edges := make([]string, 0, 1)
  45394. if m.employee != nil {
  45395. edges = append(edges, workexperience.EdgeEmployee)
  45396. }
  45397. return edges
  45398. }
  45399. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  45400. // name in this mutation.
  45401. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  45402. switch name {
  45403. case workexperience.EdgeEmployee:
  45404. if id := m.employee; id != nil {
  45405. return []ent.Value{*id}
  45406. }
  45407. }
  45408. return nil
  45409. }
  45410. // RemovedEdges returns all edge names that were removed in this mutation.
  45411. func (m *WorkExperienceMutation) RemovedEdges() []string {
  45412. edges := make([]string, 0, 1)
  45413. return edges
  45414. }
  45415. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  45416. // the given name in this mutation.
  45417. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  45418. return nil
  45419. }
  45420. // ClearedEdges returns all edge names that were cleared in this mutation.
  45421. func (m *WorkExperienceMutation) ClearedEdges() []string {
  45422. edges := make([]string, 0, 1)
  45423. if m.clearedemployee {
  45424. edges = append(edges, workexperience.EdgeEmployee)
  45425. }
  45426. return edges
  45427. }
  45428. // EdgeCleared returns a boolean which indicates if the edge with the given name
  45429. // was cleared in this mutation.
  45430. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  45431. switch name {
  45432. case workexperience.EdgeEmployee:
  45433. return m.clearedemployee
  45434. }
  45435. return false
  45436. }
  45437. // ClearEdge clears the value of the edge with the given name. It returns an error
  45438. // if that edge is not defined in the schema.
  45439. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  45440. switch name {
  45441. case workexperience.EdgeEmployee:
  45442. m.ClearEmployee()
  45443. return nil
  45444. }
  45445. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  45446. }
  45447. // ResetEdge resets all changes to the edge with the given name in this mutation.
  45448. // It returns an error if the edge is not defined in the schema.
  45449. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  45450. switch name {
  45451. case workexperience.EdgeEmployee:
  45452. m.ResetEmployee()
  45453. return nil
  45454. }
  45455. return fmt.Errorf("unknown WorkExperience edge %s", name)
  45456. }
  45457. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  45458. type WpChatroomMutation struct {
  45459. config
  45460. op Op
  45461. typ string
  45462. id *uint64
  45463. created_at *time.Time
  45464. updated_at *time.Time
  45465. status *uint8
  45466. addstatus *int8
  45467. wx_wxid *string
  45468. chatroom_id *string
  45469. nickname *string
  45470. owner *string
  45471. avatar *string
  45472. member_list *[]string
  45473. appendmember_list []string
  45474. clearedFields map[string]struct{}
  45475. done bool
  45476. oldValue func(context.Context) (*WpChatroom, error)
  45477. predicates []predicate.WpChatroom
  45478. }
  45479. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  45480. // wpchatroomOption allows management of the mutation configuration using functional options.
  45481. type wpchatroomOption func(*WpChatroomMutation)
  45482. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  45483. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  45484. m := &WpChatroomMutation{
  45485. config: c,
  45486. op: op,
  45487. typ: TypeWpChatroom,
  45488. clearedFields: make(map[string]struct{}),
  45489. }
  45490. for _, opt := range opts {
  45491. opt(m)
  45492. }
  45493. return m
  45494. }
  45495. // withWpChatroomID sets the ID field of the mutation.
  45496. func withWpChatroomID(id uint64) wpchatroomOption {
  45497. return func(m *WpChatroomMutation) {
  45498. var (
  45499. err error
  45500. once sync.Once
  45501. value *WpChatroom
  45502. )
  45503. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  45504. once.Do(func() {
  45505. if m.done {
  45506. err = errors.New("querying old values post mutation is not allowed")
  45507. } else {
  45508. value, err = m.Client().WpChatroom.Get(ctx, id)
  45509. }
  45510. })
  45511. return value, err
  45512. }
  45513. m.id = &id
  45514. }
  45515. }
  45516. // withWpChatroom sets the old WpChatroom of the mutation.
  45517. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  45518. return func(m *WpChatroomMutation) {
  45519. m.oldValue = func(context.Context) (*WpChatroom, error) {
  45520. return node, nil
  45521. }
  45522. m.id = &node.ID
  45523. }
  45524. }
  45525. // Client returns a new `ent.Client` from the mutation. If the mutation was
  45526. // executed in a transaction (ent.Tx), a transactional client is returned.
  45527. func (m WpChatroomMutation) Client() *Client {
  45528. client := &Client{config: m.config}
  45529. client.init()
  45530. return client
  45531. }
  45532. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  45533. // it returns an error otherwise.
  45534. func (m WpChatroomMutation) Tx() (*Tx, error) {
  45535. if _, ok := m.driver.(*txDriver); !ok {
  45536. return nil, errors.New("ent: mutation is not running in a transaction")
  45537. }
  45538. tx := &Tx{config: m.config}
  45539. tx.init()
  45540. return tx, nil
  45541. }
  45542. // SetID sets the value of the id field. Note that this
  45543. // operation is only accepted on creation of WpChatroom entities.
  45544. func (m *WpChatroomMutation) SetID(id uint64) {
  45545. m.id = &id
  45546. }
  45547. // ID returns the ID value in the mutation. Note that the ID is only available
  45548. // if it was provided to the builder or after it was returned from the database.
  45549. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  45550. if m.id == nil {
  45551. return
  45552. }
  45553. return *m.id, true
  45554. }
  45555. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  45556. // That means, if the mutation is applied within a transaction with an isolation level such
  45557. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  45558. // or updated by the mutation.
  45559. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  45560. switch {
  45561. case m.op.Is(OpUpdateOne | OpDeleteOne):
  45562. id, exists := m.ID()
  45563. if exists {
  45564. return []uint64{id}, nil
  45565. }
  45566. fallthrough
  45567. case m.op.Is(OpUpdate | OpDelete):
  45568. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  45569. default:
  45570. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  45571. }
  45572. }
  45573. // SetCreatedAt sets the "created_at" field.
  45574. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  45575. m.created_at = &t
  45576. }
  45577. // CreatedAt returns the value of the "created_at" field in the mutation.
  45578. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  45579. v := m.created_at
  45580. if v == nil {
  45581. return
  45582. }
  45583. return *v, true
  45584. }
  45585. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  45586. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45588. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  45589. if !m.op.Is(OpUpdateOne) {
  45590. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  45591. }
  45592. if m.id == nil || m.oldValue == nil {
  45593. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  45594. }
  45595. oldValue, err := m.oldValue(ctx)
  45596. if err != nil {
  45597. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  45598. }
  45599. return oldValue.CreatedAt, nil
  45600. }
  45601. // ResetCreatedAt resets all changes to the "created_at" field.
  45602. func (m *WpChatroomMutation) ResetCreatedAt() {
  45603. m.created_at = nil
  45604. }
  45605. // SetUpdatedAt sets the "updated_at" field.
  45606. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  45607. m.updated_at = &t
  45608. }
  45609. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  45610. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  45611. v := m.updated_at
  45612. if v == nil {
  45613. return
  45614. }
  45615. return *v, true
  45616. }
  45617. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  45618. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45620. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  45621. if !m.op.Is(OpUpdateOne) {
  45622. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  45623. }
  45624. if m.id == nil || m.oldValue == nil {
  45625. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  45626. }
  45627. oldValue, err := m.oldValue(ctx)
  45628. if err != nil {
  45629. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  45630. }
  45631. return oldValue.UpdatedAt, nil
  45632. }
  45633. // ResetUpdatedAt resets all changes to the "updated_at" field.
  45634. func (m *WpChatroomMutation) ResetUpdatedAt() {
  45635. m.updated_at = nil
  45636. }
  45637. // SetStatus sets the "status" field.
  45638. func (m *WpChatroomMutation) SetStatus(u uint8) {
  45639. m.status = &u
  45640. m.addstatus = nil
  45641. }
  45642. // Status returns the value of the "status" field in the mutation.
  45643. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  45644. v := m.status
  45645. if v == nil {
  45646. return
  45647. }
  45648. return *v, true
  45649. }
  45650. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  45651. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45653. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  45654. if !m.op.Is(OpUpdateOne) {
  45655. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  45656. }
  45657. if m.id == nil || m.oldValue == nil {
  45658. return v, errors.New("OldStatus requires an ID field in the mutation")
  45659. }
  45660. oldValue, err := m.oldValue(ctx)
  45661. if err != nil {
  45662. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  45663. }
  45664. return oldValue.Status, nil
  45665. }
  45666. // AddStatus adds u to the "status" field.
  45667. func (m *WpChatroomMutation) AddStatus(u int8) {
  45668. if m.addstatus != nil {
  45669. *m.addstatus += u
  45670. } else {
  45671. m.addstatus = &u
  45672. }
  45673. }
  45674. // AddedStatus returns the value that was added to the "status" field in this mutation.
  45675. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  45676. v := m.addstatus
  45677. if v == nil {
  45678. return
  45679. }
  45680. return *v, true
  45681. }
  45682. // ClearStatus clears the value of the "status" field.
  45683. func (m *WpChatroomMutation) ClearStatus() {
  45684. m.status = nil
  45685. m.addstatus = nil
  45686. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  45687. }
  45688. // StatusCleared returns if the "status" field was cleared in this mutation.
  45689. func (m *WpChatroomMutation) StatusCleared() bool {
  45690. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  45691. return ok
  45692. }
  45693. // ResetStatus resets all changes to the "status" field.
  45694. func (m *WpChatroomMutation) ResetStatus() {
  45695. m.status = nil
  45696. m.addstatus = nil
  45697. delete(m.clearedFields, wpchatroom.FieldStatus)
  45698. }
  45699. // SetWxWxid sets the "wx_wxid" field.
  45700. func (m *WpChatroomMutation) SetWxWxid(s string) {
  45701. m.wx_wxid = &s
  45702. }
  45703. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  45704. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  45705. v := m.wx_wxid
  45706. if v == nil {
  45707. return
  45708. }
  45709. return *v, true
  45710. }
  45711. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  45712. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45714. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  45715. if !m.op.Is(OpUpdateOne) {
  45716. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  45717. }
  45718. if m.id == nil || m.oldValue == nil {
  45719. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  45720. }
  45721. oldValue, err := m.oldValue(ctx)
  45722. if err != nil {
  45723. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  45724. }
  45725. return oldValue.WxWxid, nil
  45726. }
  45727. // ResetWxWxid resets all changes to the "wx_wxid" field.
  45728. func (m *WpChatroomMutation) ResetWxWxid() {
  45729. m.wx_wxid = nil
  45730. }
  45731. // SetChatroomID sets the "chatroom_id" field.
  45732. func (m *WpChatroomMutation) SetChatroomID(s string) {
  45733. m.chatroom_id = &s
  45734. }
  45735. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  45736. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  45737. v := m.chatroom_id
  45738. if v == nil {
  45739. return
  45740. }
  45741. return *v, true
  45742. }
  45743. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  45744. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45746. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  45747. if !m.op.Is(OpUpdateOne) {
  45748. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  45749. }
  45750. if m.id == nil || m.oldValue == nil {
  45751. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  45752. }
  45753. oldValue, err := m.oldValue(ctx)
  45754. if err != nil {
  45755. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  45756. }
  45757. return oldValue.ChatroomID, nil
  45758. }
  45759. // ResetChatroomID resets all changes to the "chatroom_id" field.
  45760. func (m *WpChatroomMutation) ResetChatroomID() {
  45761. m.chatroom_id = nil
  45762. }
  45763. // SetNickname sets the "nickname" field.
  45764. func (m *WpChatroomMutation) SetNickname(s string) {
  45765. m.nickname = &s
  45766. }
  45767. // Nickname returns the value of the "nickname" field in the mutation.
  45768. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  45769. v := m.nickname
  45770. if v == nil {
  45771. return
  45772. }
  45773. return *v, true
  45774. }
  45775. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  45776. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45778. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  45779. if !m.op.Is(OpUpdateOne) {
  45780. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  45781. }
  45782. if m.id == nil || m.oldValue == nil {
  45783. return v, errors.New("OldNickname requires an ID field in the mutation")
  45784. }
  45785. oldValue, err := m.oldValue(ctx)
  45786. if err != nil {
  45787. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  45788. }
  45789. return oldValue.Nickname, nil
  45790. }
  45791. // ResetNickname resets all changes to the "nickname" field.
  45792. func (m *WpChatroomMutation) ResetNickname() {
  45793. m.nickname = nil
  45794. }
  45795. // SetOwner sets the "owner" field.
  45796. func (m *WpChatroomMutation) SetOwner(s string) {
  45797. m.owner = &s
  45798. }
  45799. // Owner returns the value of the "owner" field in the mutation.
  45800. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  45801. v := m.owner
  45802. if v == nil {
  45803. return
  45804. }
  45805. return *v, true
  45806. }
  45807. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  45808. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45810. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  45811. if !m.op.Is(OpUpdateOne) {
  45812. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  45813. }
  45814. if m.id == nil || m.oldValue == nil {
  45815. return v, errors.New("OldOwner requires an ID field in the mutation")
  45816. }
  45817. oldValue, err := m.oldValue(ctx)
  45818. if err != nil {
  45819. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  45820. }
  45821. return oldValue.Owner, nil
  45822. }
  45823. // ResetOwner resets all changes to the "owner" field.
  45824. func (m *WpChatroomMutation) ResetOwner() {
  45825. m.owner = nil
  45826. }
  45827. // SetAvatar sets the "avatar" field.
  45828. func (m *WpChatroomMutation) SetAvatar(s string) {
  45829. m.avatar = &s
  45830. }
  45831. // Avatar returns the value of the "avatar" field in the mutation.
  45832. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  45833. v := m.avatar
  45834. if v == nil {
  45835. return
  45836. }
  45837. return *v, true
  45838. }
  45839. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  45840. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45842. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  45843. if !m.op.Is(OpUpdateOne) {
  45844. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  45845. }
  45846. if m.id == nil || m.oldValue == nil {
  45847. return v, errors.New("OldAvatar requires an ID field in the mutation")
  45848. }
  45849. oldValue, err := m.oldValue(ctx)
  45850. if err != nil {
  45851. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  45852. }
  45853. return oldValue.Avatar, nil
  45854. }
  45855. // ResetAvatar resets all changes to the "avatar" field.
  45856. func (m *WpChatroomMutation) ResetAvatar() {
  45857. m.avatar = nil
  45858. }
  45859. // SetMemberList sets the "member_list" field.
  45860. func (m *WpChatroomMutation) SetMemberList(s []string) {
  45861. m.member_list = &s
  45862. m.appendmember_list = nil
  45863. }
  45864. // MemberList returns the value of the "member_list" field in the mutation.
  45865. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  45866. v := m.member_list
  45867. if v == nil {
  45868. return
  45869. }
  45870. return *v, true
  45871. }
  45872. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  45873. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  45874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  45875. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  45876. if !m.op.Is(OpUpdateOne) {
  45877. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  45878. }
  45879. if m.id == nil || m.oldValue == nil {
  45880. return v, errors.New("OldMemberList requires an ID field in the mutation")
  45881. }
  45882. oldValue, err := m.oldValue(ctx)
  45883. if err != nil {
  45884. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  45885. }
  45886. return oldValue.MemberList, nil
  45887. }
  45888. // AppendMemberList adds s to the "member_list" field.
  45889. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  45890. m.appendmember_list = append(m.appendmember_list, s...)
  45891. }
  45892. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  45893. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  45894. if len(m.appendmember_list) == 0 {
  45895. return nil, false
  45896. }
  45897. return m.appendmember_list, true
  45898. }
  45899. // ResetMemberList resets all changes to the "member_list" field.
  45900. func (m *WpChatroomMutation) ResetMemberList() {
  45901. m.member_list = nil
  45902. m.appendmember_list = nil
  45903. }
  45904. // Where appends a list predicates to the WpChatroomMutation builder.
  45905. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  45906. m.predicates = append(m.predicates, ps...)
  45907. }
  45908. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  45909. // users can use type-assertion to append predicates that do not depend on any generated package.
  45910. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  45911. p := make([]predicate.WpChatroom, len(ps))
  45912. for i := range ps {
  45913. p[i] = ps[i]
  45914. }
  45915. m.Where(p...)
  45916. }
  45917. // Op returns the operation name.
  45918. func (m *WpChatroomMutation) Op() Op {
  45919. return m.op
  45920. }
  45921. // SetOp allows setting the mutation operation.
  45922. func (m *WpChatroomMutation) SetOp(op Op) {
  45923. m.op = op
  45924. }
  45925. // Type returns the node type of this mutation (WpChatroom).
  45926. func (m *WpChatroomMutation) Type() string {
  45927. return m.typ
  45928. }
  45929. // Fields returns all fields that were changed during this mutation. Note that in
  45930. // order to get all numeric fields that were incremented/decremented, call
  45931. // AddedFields().
  45932. func (m *WpChatroomMutation) Fields() []string {
  45933. fields := make([]string, 0, 9)
  45934. if m.created_at != nil {
  45935. fields = append(fields, wpchatroom.FieldCreatedAt)
  45936. }
  45937. if m.updated_at != nil {
  45938. fields = append(fields, wpchatroom.FieldUpdatedAt)
  45939. }
  45940. if m.status != nil {
  45941. fields = append(fields, wpchatroom.FieldStatus)
  45942. }
  45943. if m.wx_wxid != nil {
  45944. fields = append(fields, wpchatroom.FieldWxWxid)
  45945. }
  45946. if m.chatroom_id != nil {
  45947. fields = append(fields, wpchatroom.FieldChatroomID)
  45948. }
  45949. if m.nickname != nil {
  45950. fields = append(fields, wpchatroom.FieldNickname)
  45951. }
  45952. if m.owner != nil {
  45953. fields = append(fields, wpchatroom.FieldOwner)
  45954. }
  45955. if m.avatar != nil {
  45956. fields = append(fields, wpchatroom.FieldAvatar)
  45957. }
  45958. if m.member_list != nil {
  45959. fields = append(fields, wpchatroom.FieldMemberList)
  45960. }
  45961. return fields
  45962. }
  45963. // Field returns the value of a field with the given name. The second boolean
  45964. // return value indicates that this field was not set, or was not defined in the
  45965. // schema.
  45966. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  45967. switch name {
  45968. case wpchatroom.FieldCreatedAt:
  45969. return m.CreatedAt()
  45970. case wpchatroom.FieldUpdatedAt:
  45971. return m.UpdatedAt()
  45972. case wpchatroom.FieldStatus:
  45973. return m.Status()
  45974. case wpchatroom.FieldWxWxid:
  45975. return m.WxWxid()
  45976. case wpchatroom.FieldChatroomID:
  45977. return m.ChatroomID()
  45978. case wpchatroom.FieldNickname:
  45979. return m.Nickname()
  45980. case wpchatroom.FieldOwner:
  45981. return m.Owner()
  45982. case wpchatroom.FieldAvatar:
  45983. return m.Avatar()
  45984. case wpchatroom.FieldMemberList:
  45985. return m.MemberList()
  45986. }
  45987. return nil, false
  45988. }
  45989. // OldField returns the old value of the field from the database. An error is
  45990. // returned if the mutation operation is not UpdateOne, or the query to the
  45991. // database failed.
  45992. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  45993. switch name {
  45994. case wpchatroom.FieldCreatedAt:
  45995. return m.OldCreatedAt(ctx)
  45996. case wpchatroom.FieldUpdatedAt:
  45997. return m.OldUpdatedAt(ctx)
  45998. case wpchatroom.FieldStatus:
  45999. return m.OldStatus(ctx)
  46000. case wpchatroom.FieldWxWxid:
  46001. return m.OldWxWxid(ctx)
  46002. case wpchatroom.FieldChatroomID:
  46003. return m.OldChatroomID(ctx)
  46004. case wpchatroom.FieldNickname:
  46005. return m.OldNickname(ctx)
  46006. case wpchatroom.FieldOwner:
  46007. return m.OldOwner(ctx)
  46008. case wpchatroom.FieldAvatar:
  46009. return m.OldAvatar(ctx)
  46010. case wpchatroom.FieldMemberList:
  46011. return m.OldMemberList(ctx)
  46012. }
  46013. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  46014. }
  46015. // SetField sets the value of a field with the given name. It returns an error if
  46016. // the field is not defined in the schema, or if the type mismatched the field
  46017. // type.
  46018. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  46019. switch name {
  46020. case wpchatroom.FieldCreatedAt:
  46021. v, ok := value.(time.Time)
  46022. if !ok {
  46023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46024. }
  46025. m.SetCreatedAt(v)
  46026. return nil
  46027. case wpchatroom.FieldUpdatedAt:
  46028. v, ok := value.(time.Time)
  46029. if !ok {
  46030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46031. }
  46032. m.SetUpdatedAt(v)
  46033. return nil
  46034. case wpchatroom.FieldStatus:
  46035. v, ok := value.(uint8)
  46036. if !ok {
  46037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46038. }
  46039. m.SetStatus(v)
  46040. return nil
  46041. case wpchatroom.FieldWxWxid:
  46042. v, ok := value.(string)
  46043. if !ok {
  46044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46045. }
  46046. m.SetWxWxid(v)
  46047. return nil
  46048. case wpchatroom.FieldChatroomID:
  46049. v, ok := value.(string)
  46050. if !ok {
  46051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46052. }
  46053. m.SetChatroomID(v)
  46054. return nil
  46055. case wpchatroom.FieldNickname:
  46056. v, ok := value.(string)
  46057. if !ok {
  46058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46059. }
  46060. m.SetNickname(v)
  46061. return nil
  46062. case wpchatroom.FieldOwner:
  46063. v, ok := value.(string)
  46064. if !ok {
  46065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46066. }
  46067. m.SetOwner(v)
  46068. return nil
  46069. case wpchatroom.FieldAvatar:
  46070. v, ok := value.(string)
  46071. if !ok {
  46072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46073. }
  46074. m.SetAvatar(v)
  46075. return nil
  46076. case wpchatroom.FieldMemberList:
  46077. v, ok := value.([]string)
  46078. if !ok {
  46079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46080. }
  46081. m.SetMemberList(v)
  46082. return nil
  46083. }
  46084. return fmt.Errorf("unknown WpChatroom field %s", name)
  46085. }
  46086. // AddedFields returns all numeric fields that were incremented/decremented during
  46087. // this mutation.
  46088. func (m *WpChatroomMutation) AddedFields() []string {
  46089. var fields []string
  46090. if m.addstatus != nil {
  46091. fields = append(fields, wpchatroom.FieldStatus)
  46092. }
  46093. return fields
  46094. }
  46095. // AddedField returns the numeric value that was incremented/decremented on a field
  46096. // with the given name. The second boolean return value indicates that this field
  46097. // was not set, or was not defined in the schema.
  46098. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  46099. switch name {
  46100. case wpchatroom.FieldStatus:
  46101. return m.AddedStatus()
  46102. }
  46103. return nil, false
  46104. }
  46105. // AddField adds the value to the field with the given name. It returns an error if
  46106. // the field is not defined in the schema, or if the type mismatched the field
  46107. // type.
  46108. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  46109. switch name {
  46110. case wpchatroom.FieldStatus:
  46111. v, ok := value.(int8)
  46112. if !ok {
  46113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46114. }
  46115. m.AddStatus(v)
  46116. return nil
  46117. }
  46118. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  46119. }
  46120. // ClearedFields returns all nullable fields that were cleared during this
  46121. // mutation.
  46122. func (m *WpChatroomMutation) ClearedFields() []string {
  46123. var fields []string
  46124. if m.FieldCleared(wpchatroom.FieldStatus) {
  46125. fields = append(fields, wpchatroom.FieldStatus)
  46126. }
  46127. return fields
  46128. }
  46129. // FieldCleared returns a boolean indicating if a field with the given name was
  46130. // cleared in this mutation.
  46131. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  46132. _, ok := m.clearedFields[name]
  46133. return ok
  46134. }
  46135. // ClearField clears the value of the field with the given name. It returns an
  46136. // error if the field is not defined in the schema.
  46137. func (m *WpChatroomMutation) ClearField(name string) error {
  46138. switch name {
  46139. case wpchatroom.FieldStatus:
  46140. m.ClearStatus()
  46141. return nil
  46142. }
  46143. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  46144. }
  46145. // ResetField resets all changes in the mutation for the field with the given name.
  46146. // It returns an error if the field is not defined in the schema.
  46147. func (m *WpChatroomMutation) ResetField(name string) error {
  46148. switch name {
  46149. case wpchatroom.FieldCreatedAt:
  46150. m.ResetCreatedAt()
  46151. return nil
  46152. case wpchatroom.FieldUpdatedAt:
  46153. m.ResetUpdatedAt()
  46154. return nil
  46155. case wpchatroom.FieldStatus:
  46156. m.ResetStatus()
  46157. return nil
  46158. case wpchatroom.FieldWxWxid:
  46159. m.ResetWxWxid()
  46160. return nil
  46161. case wpchatroom.FieldChatroomID:
  46162. m.ResetChatroomID()
  46163. return nil
  46164. case wpchatroom.FieldNickname:
  46165. m.ResetNickname()
  46166. return nil
  46167. case wpchatroom.FieldOwner:
  46168. m.ResetOwner()
  46169. return nil
  46170. case wpchatroom.FieldAvatar:
  46171. m.ResetAvatar()
  46172. return nil
  46173. case wpchatroom.FieldMemberList:
  46174. m.ResetMemberList()
  46175. return nil
  46176. }
  46177. return fmt.Errorf("unknown WpChatroom field %s", name)
  46178. }
  46179. // AddedEdges returns all edge names that were set/added in this mutation.
  46180. func (m *WpChatroomMutation) AddedEdges() []string {
  46181. edges := make([]string, 0, 0)
  46182. return edges
  46183. }
  46184. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46185. // name in this mutation.
  46186. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  46187. return nil
  46188. }
  46189. // RemovedEdges returns all edge names that were removed in this mutation.
  46190. func (m *WpChatroomMutation) RemovedEdges() []string {
  46191. edges := make([]string, 0, 0)
  46192. return edges
  46193. }
  46194. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46195. // the given name in this mutation.
  46196. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  46197. return nil
  46198. }
  46199. // ClearedEdges returns all edge names that were cleared in this mutation.
  46200. func (m *WpChatroomMutation) ClearedEdges() []string {
  46201. edges := make([]string, 0, 0)
  46202. return edges
  46203. }
  46204. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46205. // was cleared in this mutation.
  46206. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  46207. return false
  46208. }
  46209. // ClearEdge clears the value of the edge with the given name. It returns an error
  46210. // if that edge is not defined in the schema.
  46211. func (m *WpChatroomMutation) ClearEdge(name string) error {
  46212. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  46213. }
  46214. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46215. // It returns an error if the edge is not defined in the schema.
  46216. func (m *WpChatroomMutation) ResetEdge(name string) error {
  46217. return fmt.Errorf("unknown WpChatroom edge %s", name)
  46218. }
  46219. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  46220. type WpChatroomMemberMutation struct {
  46221. config
  46222. op Op
  46223. typ string
  46224. id *uint64
  46225. created_at *time.Time
  46226. updated_at *time.Time
  46227. status *uint8
  46228. addstatus *int8
  46229. wx_wxid *string
  46230. wxid *string
  46231. nickname *string
  46232. avatar *string
  46233. clearedFields map[string]struct{}
  46234. done bool
  46235. oldValue func(context.Context) (*WpChatroomMember, error)
  46236. predicates []predicate.WpChatroomMember
  46237. }
  46238. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  46239. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  46240. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  46241. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  46242. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  46243. m := &WpChatroomMemberMutation{
  46244. config: c,
  46245. op: op,
  46246. typ: TypeWpChatroomMember,
  46247. clearedFields: make(map[string]struct{}),
  46248. }
  46249. for _, opt := range opts {
  46250. opt(m)
  46251. }
  46252. return m
  46253. }
  46254. // withWpChatroomMemberID sets the ID field of the mutation.
  46255. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  46256. return func(m *WpChatroomMemberMutation) {
  46257. var (
  46258. err error
  46259. once sync.Once
  46260. value *WpChatroomMember
  46261. )
  46262. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  46263. once.Do(func() {
  46264. if m.done {
  46265. err = errors.New("querying old values post mutation is not allowed")
  46266. } else {
  46267. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  46268. }
  46269. })
  46270. return value, err
  46271. }
  46272. m.id = &id
  46273. }
  46274. }
  46275. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  46276. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  46277. return func(m *WpChatroomMemberMutation) {
  46278. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  46279. return node, nil
  46280. }
  46281. m.id = &node.ID
  46282. }
  46283. }
  46284. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46285. // executed in a transaction (ent.Tx), a transactional client is returned.
  46286. func (m WpChatroomMemberMutation) Client() *Client {
  46287. client := &Client{config: m.config}
  46288. client.init()
  46289. return client
  46290. }
  46291. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46292. // it returns an error otherwise.
  46293. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  46294. if _, ok := m.driver.(*txDriver); !ok {
  46295. return nil, errors.New("ent: mutation is not running in a transaction")
  46296. }
  46297. tx := &Tx{config: m.config}
  46298. tx.init()
  46299. return tx, nil
  46300. }
  46301. // SetID sets the value of the id field. Note that this
  46302. // operation is only accepted on creation of WpChatroomMember entities.
  46303. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  46304. m.id = &id
  46305. }
  46306. // ID returns the ID value in the mutation. Note that the ID is only available
  46307. // if it was provided to the builder or after it was returned from the database.
  46308. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  46309. if m.id == nil {
  46310. return
  46311. }
  46312. return *m.id, true
  46313. }
  46314. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46315. // That means, if the mutation is applied within a transaction with an isolation level such
  46316. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46317. // or updated by the mutation.
  46318. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  46319. switch {
  46320. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46321. id, exists := m.ID()
  46322. if exists {
  46323. return []uint64{id}, nil
  46324. }
  46325. fallthrough
  46326. case m.op.Is(OpUpdate | OpDelete):
  46327. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  46328. default:
  46329. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  46330. }
  46331. }
  46332. // SetCreatedAt sets the "created_at" field.
  46333. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  46334. m.created_at = &t
  46335. }
  46336. // CreatedAt returns the value of the "created_at" field in the mutation.
  46337. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  46338. v := m.created_at
  46339. if v == nil {
  46340. return
  46341. }
  46342. return *v, true
  46343. }
  46344. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  46345. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46347. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  46348. if !m.op.Is(OpUpdateOne) {
  46349. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  46350. }
  46351. if m.id == nil || m.oldValue == nil {
  46352. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  46353. }
  46354. oldValue, err := m.oldValue(ctx)
  46355. if err != nil {
  46356. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  46357. }
  46358. return oldValue.CreatedAt, nil
  46359. }
  46360. // ResetCreatedAt resets all changes to the "created_at" field.
  46361. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  46362. m.created_at = nil
  46363. }
  46364. // SetUpdatedAt sets the "updated_at" field.
  46365. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  46366. m.updated_at = &t
  46367. }
  46368. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  46369. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  46370. v := m.updated_at
  46371. if v == nil {
  46372. return
  46373. }
  46374. return *v, true
  46375. }
  46376. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  46377. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46379. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  46380. if !m.op.Is(OpUpdateOne) {
  46381. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  46382. }
  46383. if m.id == nil || m.oldValue == nil {
  46384. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  46385. }
  46386. oldValue, err := m.oldValue(ctx)
  46387. if err != nil {
  46388. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  46389. }
  46390. return oldValue.UpdatedAt, nil
  46391. }
  46392. // ResetUpdatedAt resets all changes to the "updated_at" field.
  46393. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  46394. m.updated_at = nil
  46395. }
  46396. // SetStatus sets the "status" field.
  46397. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  46398. m.status = &u
  46399. m.addstatus = nil
  46400. }
  46401. // Status returns the value of the "status" field in the mutation.
  46402. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  46403. v := m.status
  46404. if v == nil {
  46405. return
  46406. }
  46407. return *v, true
  46408. }
  46409. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  46410. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46412. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  46413. if !m.op.Is(OpUpdateOne) {
  46414. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  46415. }
  46416. if m.id == nil || m.oldValue == nil {
  46417. return v, errors.New("OldStatus requires an ID field in the mutation")
  46418. }
  46419. oldValue, err := m.oldValue(ctx)
  46420. if err != nil {
  46421. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  46422. }
  46423. return oldValue.Status, nil
  46424. }
  46425. // AddStatus adds u to the "status" field.
  46426. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  46427. if m.addstatus != nil {
  46428. *m.addstatus += u
  46429. } else {
  46430. m.addstatus = &u
  46431. }
  46432. }
  46433. // AddedStatus returns the value that was added to the "status" field in this mutation.
  46434. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  46435. v := m.addstatus
  46436. if v == nil {
  46437. return
  46438. }
  46439. return *v, true
  46440. }
  46441. // ClearStatus clears the value of the "status" field.
  46442. func (m *WpChatroomMemberMutation) ClearStatus() {
  46443. m.status = nil
  46444. m.addstatus = nil
  46445. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  46446. }
  46447. // StatusCleared returns if the "status" field was cleared in this mutation.
  46448. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  46449. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  46450. return ok
  46451. }
  46452. // ResetStatus resets all changes to the "status" field.
  46453. func (m *WpChatroomMemberMutation) ResetStatus() {
  46454. m.status = nil
  46455. m.addstatus = nil
  46456. delete(m.clearedFields, wpchatroommember.FieldStatus)
  46457. }
  46458. // SetWxWxid sets the "wx_wxid" field.
  46459. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  46460. m.wx_wxid = &s
  46461. }
  46462. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  46463. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  46464. v := m.wx_wxid
  46465. if v == nil {
  46466. return
  46467. }
  46468. return *v, true
  46469. }
  46470. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  46471. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46473. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  46474. if !m.op.Is(OpUpdateOne) {
  46475. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  46476. }
  46477. if m.id == nil || m.oldValue == nil {
  46478. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  46479. }
  46480. oldValue, err := m.oldValue(ctx)
  46481. if err != nil {
  46482. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  46483. }
  46484. return oldValue.WxWxid, nil
  46485. }
  46486. // ResetWxWxid resets all changes to the "wx_wxid" field.
  46487. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  46488. m.wx_wxid = nil
  46489. }
  46490. // SetWxid sets the "wxid" field.
  46491. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  46492. m.wxid = &s
  46493. }
  46494. // Wxid returns the value of the "wxid" field in the mutation.
  46495. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  46496. v := m.wxid
  46497. if v == nil {
  46498. return
  46499. }
  46500. return *v, true
  46501. }
  46502. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  46503. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46505. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  46506. if !m.op.Is(OpUpdateOne) {
  46507. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  46508. }
  46509. if m.id == nil || m.oldValue == nil {
  46510. return v, errors.New("OldWxid requires an ID field in the mutation")
  46511. }
  46512. oldValue, err := m.oldValue(ctx)
  46513. if err != nil {
  46514. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  46515. }
  46516. return oldValue.Wxid, nil
  46517. }
  46518. // ResetWxid resets all changes to the "wxid" field.
  46519. func (m *WpChatroomMemberMutation) ResetWxid() {
  46520. m.wxid = nil
  46521. }
  46522. // SetNickname sets the "nickname" field.
  46523. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  46524. m.nickname = &s
  46525. }
  46526. // Nickname returns the value of the "nickname" field in the mutation.
  46527. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  46528. v := m.nickname
  46529. if v == nil {
  46530. return
  46531. }
  46532. return *v, true
  46533. }
  46534. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  46535. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46537. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  46538. if !m.op.Is(OpUpdateOne) {
  46539. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  46540. }
  46541. if m.id == nil || m.oldValue == nil {
  46542. return v, errors.New("OldNickname requires an ID field in the mutation")
  46543. }
  46544. oldValue, err := m.oldValue(ctx)
  46545. if err != nil {
  46546. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  46547. }
  46548. return oldValue.Nickname, nil
  46549. }
  46550. // ResetNickname resets all changes to the "nickname" field.
  46551. func (m *WpChatroomMemberMutation) ResetNickname() {
  46552. m.nickname = nil
  46553. }
  46554. // SetAvatar sets the "avatar" field.
  46555. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  46556. m.avatar = &s
  46557. }
  46558. // Avatar returns the value of the "avatar" field in the mutation.
  46559. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  46560. v := m.avatar
  46561. if v == nil {
  46562. return
  46563. }
  46564. return *v, true
  46565. }
  46566. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  46567. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  46568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  46569. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  46570. if !m.op.Is(OpUpdateOne) {
  46571. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  46572. }
  46573. if m.id == nil || m.oldValue == nil {
  46574. return v, errors.New("OldAvatar requires an ID field in the mutation")
  46575. }
  46576. oldValue, err := m.oldValue(ctx)
  46577. if err != nil {
  46578. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  46579. }
  46580. return oldValue.Avatar, nil
  46581. }
  46582. // ResetAvatar resets all changes to the "avatar" field.
  46583. func (m *WpChatroomMemberMutation) ResetAvatar() {
  46584. m.avatar = nil
  46585. }
  46586. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  46587. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  46588. m.predicates = append(m.predicates, ps...)
  46589. }
  46590. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  46591. // users can use type-assertion to append predicates that do not depend on any generated package.
  46592. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  46593. p := make([]predicate.WpChatroomMember, len(ps))
  46594. for i := range ps {
  46595. p[i] = ps[i]
  46596. }
  46597. m.Where(p...)
  46598. }
  46599. // Op returns the operation name.
  46600. func (m *WpChatroomMemberMutation) Op() Op {
  46601. return m.op
  46602. }
  46603. // SetOp allows setting the mutation operation.
  46604. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  46605. m.op = op
  46606. }
  46607. // Type returns the node type of this mutation (WpChatroomMember).
  46608. func (m *WpChatroomMemberMutation) Type() string {
  46609. return m.typ
  46610. }
  46611. // Fields returns all fields that were changed during this mutation. Note that in
  46612. // order to get all numeric fields that were incremented/decremented, call
  46613. // AddedFields().
  46614. func (m *WpChatroomMemberMutation) Fields() []string {
  46615. fields := make([]string, 0, 7)
  46616. if m.created_at != nil {
  46617. fields = append(fields, wpchatroommember.FieldCreatedAt)
  46618. }
  46619. if m.updated_at != nil {
  46620. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  46621. }
  46622. if m.status != nil {
  46623. fields = append(fields, wpchatroommember.FieldStatus)
  46624. }
  46625. if m.wx_wxid != nil {
  46626. fields = append(fields, wpchatroommember.FieldWxWxid)
  46627. }
  46628. if m.wxid != nil {
  46629. fields = append(fields, wpchatroommember.FieldWxid)
  46630. }
  46631. if m.nickname != nil {
  46632. fields = append(fields, wpchatroommember.FieldNickname)
  46633. }
  46634. if m.avatar != nil {
  46635. fields = append(fields, wpchatroommember.FieldAvatar)
  46636. }
  46637. return fields
  46638. }
  46639. // Field returns the value of a field with the given name. The second boolean
  46640. // return value indicates that this field was not set, or was not defined in the
  46641. // schema.
  46642. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  46643. switch name {
  46644. case wpchatroommember.FieldCreatedAt:
  46645. return m.CreatedAt()
  46646. case wpchatroommember.FieldUpdatedAt:
  46647. return m.UpdatedAt()
  46648. case wpchatroommember.FieldStatus:
  46649. return m.Status()
  46650. case wpchatroommember.FieldWxWxid:
  46651. return m.WxWxid()
  46652. case wpchatroommember.FieldWxid:
  46653. return m.Wxid()
  46654. case wpchatroommember.FieldNickname:
  46655. return m.Nickname()
  46656. case wpchatroommember.FieldAvatar:
  46657. return m.Avatar()
  46658. }
  46659. return nil, false
  46660. }
  46661. // OldField returns the old value of the field from the database. An error is
  46662. // returned if the mutation operation is not UpdateOne, or the query to the
  46663. // database failed.
  46664. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  46665. switch name {
  46666. case wpchatroommember.FieldCreatedAt:
  46667. return m.OldCreatedAt(ctx)
  46668. case wpchatroommember.FieldUpdatedAt:
  46669. return m.OldUpdatedAt(ctx)
  46670. case wpchatroommember.FieldStatus:
  46671. return m.OldStatus(ctx)
  46672. case wpchatroommember.FieldWxWxid:
  46673. return m.OldWxWxid(ctx)
  46674. case wpchatroommember.FieldWxid:
  46675. return m.OldWxid(ctx)
  46676. case wpchatroommember.FieldNickname:
  46677. return m.OldNickname(ctx)
  46678. case wpchatroommember.FieldAvatar:
  46679. return m.OldAvatar(ctx)
  46680. }
  46681. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  46682. }
  46683. // SetField sets the value of a field with the given name. It returns an error if
  46684. // the field is not defined in the schema, or if the type mismatched the field
  46685. // type.
  46686. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  46687. switch name {
  46688. case wpchatroommember.FieldCreatedAt:
  46689. v, ok := value.(time.Time)
  46690. if !ok {
  46691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46692. }
  46693. m.SetCreatedAt(v)
  46694. return nil
  46695. case wpchatroommember.FieldUpdatedAt:
  46696. v, ok := value.(time.Time)
  46697. if !ok {
  46698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46699. }
  46700. m.SetUpdatedAt(v)
  46701. return nil
  46702. case wpchatroommember.FieldStatus:
  46703. v, ok := value.(uint8)
  46704. if !ok {
  46705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46706. }
  46707. m.SetStatus(v)
  46708. return nil
  46709. case wpchatroommember.FieldWxWxid:
  46710. v, ok := value.(string)
  46711. if !ok {
  46712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46713. }
  46714. m.SetWxWxid(v)
  46715. return nil
  46716. case wpchatroommember.FieldWxid:
  46717. v, ok := value.(string)
  46718. if !ok {
  46719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46720. }
  46721. m.SetWxid(v)
  46722. return nil
  46723. case wpchatroommember.FieldNickname:
  46724. v, ok := value.(string)
  46725. if !ok {
  46726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46727. }
  46728. m.SetNickname(v)
  46729. return nil
  46730. case wpchatroommember.FieldAvatar:
  46731. v, ok := value.(string)
  46732. if !ok {
  46733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46734. }
  46735. m.SetAvatar(v)
  46736. return nil
  46737. }
  46738. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46739. }
  46740. // AddedFields returns all numeric fields that were incremented/decremented during
  46741. // this mutation.
  46742. func (m *WpChatroomMemberMutation) AddedFields() []string {
  46743. var fields []string
  46744. if m.addstatus != nil {
  46745. fields = append(fields, wpchatroommember.FieldStatus)
  46746. }
  46747. return fields
  46748. }
  46749. // AddedField returns the numeric value that was incremented/decremented on a field
  46750. // with the given name. The second boolean return value indicates that this field
  46751. // was not set, or was not defined in the schema.
  46752. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  46753. switch name {
  46754. case wpchatroommember.FieldStatus:
  46755. return m.AddedStatus()
  46756. }
  46757. return nil, false
  46758. }
  46759. // AddField adds the value to the field with the given name. It returns an error if
  46760. // the field is not defined in the schema, or if the type mismatched the field
  46761. // type.
  46762. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  46763. switch name {
  46764. case wpchatroommember.FieldStatus:
  46765. v, ok := value.(int8)
  46766. if !ok {
  46767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  46768. }
  46769. m.AddStatus(v)
  46770. return nil
  46771. }
  46772. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  46773. }
  46774. // ClearedFields returns all nullable fields that were cleared during this
  46775. // mutation.
  46776. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  46777. var fields []string
  46778. if m.FieldCleared(wpchatroommember.FieldStatus) {
  46779. fields = append(fields, wpchatroommember.FieldStatus)
  46780. }
  46781. return fields
  46782. }
  46783. // FieldCleared returns a boolean indicating if a field with the given name was
  46784. // cleared in this mutation.
  46785. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  46786. _, ok := m.clearedFields[name]
  46787. return ok
  46788. }
  46789. // ClearField clears the value of the field with the given name. It returns an
  46790. // error if the field is not defined in the schema.
  46791. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  46792. switch name {
  46793. case wpchatroommember.FieldStatus:
  46794. m.ClearStatus()
  46795. return nil
  46796. }
  46797. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  46798. }
  46799. // ResetField resets all changes in the mutation for the field with the given name.
  46800. // It returns an error if the field is not defined in the schema.
  46801. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  46802. switch name {
  46803. case wpchatroommember.FieldCreatedAt:
  46804. m.ResetCreatedAt()
  46805. return nil
  46806. case wpchatroommember.FieldUpdatedAt:
  46807. m.ResetUpdatedAt()
  46808. return nil
  46809. case wpchatroommember.FieldStatus:
  46810. m.ResetStatus()
  46811. return nil
  46812. case wpchatroommember.FieldWxWxid:
  46813. m.ResetWxWxid()
  46814. return nil
  46815. case wpchatroommember.FieldWxid:
  46816. m.ResetWxid()
  46817. return nil
  46818. case wpchatroommember.FieldNickname:
  46819. m.ResetNickname()
  46820. return nil
  46821. case wpchatroommember.FieldAvatar:
  46822. m.ResetAvatar()
  46823. return nil
  46824. }
  46825. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  46826. }
  46827. // AddedEdges returns all edge names that were set/added in this mutation.
  46828. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  46829. edges := make([]string, 0, 0)
  46830. return edges
  46831. }
  46832. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  46833. // name in this mutation.
  46834. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  46835. return nil
  46836. }
  46837. // RemovedEdges returns all edge names that were removed in this mutation.
  46838. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  46839. edges := make([]string, 0, 0)
  46840. return edges
  46841. }
  46842. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  46843. // the given name in this mutation.
  46844. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  46845. return nil
  46846. }
  46847. // ClearedEdges returns all edge names that were cleared in this mutation.
  46848. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  46849. edges := make([]string, 0, 0)
  46850. return edges
  46851. }
  46852. // EdgeCleared returns a boolean which indicates if the edge with the given name
  46853. // was cleared in this mutation.
  46854. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  46855. return false
  46856. }
  46857. // ClearEdge clears the value of the edge with the given name. It returns an error
  46858. // if that edge is not defined in the schema.
  46859. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  46860. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  46861. }
  46862. // ResetEdge resets all changes to the edge with the given name in this mutation.
  46863. // It returns an error if the edge is not defined in the schema.
  46864. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  46865. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  46866. }
  46867. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  46868. type WxMutation struct {
  46869. config
  46870. op Op
  46871. typ string
  46872. id *uint64
  46873. created_at *time.Time
  46874. updated_at *time.Time
  46875. status *uint8
  46876. addstatus *int8
  46877. deleted_at *time.Time
  46878. port *string
  46879. process_id *string
  46880. callback *string
  46881. wxid *string
  46882. account *string
  46883. nickname *string
  46884. tel *string
  46885. head_big *string
  46886. organization_id *uint64
  46887. addorganization_id *int64
  46888. api_base *string
  46889. api_key *string
  46890. allow_list *[]string
  46891. appendallow_list []string
  46892. group_allow_list *[]string
  46893. appendgroup_allow_list []string
  46894. block_list *[]string
  46895. appendblock_list []string
  46896. group_block_list *[]string
  46897. appendgroup_block_list []string
  46898. ctype *uint64
  46899. addctype *int64
  46900. clearedFields map[string]struct{}
  46901. server *uint64
  46902. clearedserver bool
  46903. agent *uint64
  46904. clearedagent bool
  46905. done bool
  46906. oldValue func(context.Context) (*Wx, error)
  46907. predicates []predicate.Wx
  46908. }
  46909. var _ ent.Mutation = (*WxMutation)(nil)
  46910. // wxOption allows management of the mutation configuration using functional options.
  46911. type wxOption func(*WxMutation)
  46912. // newWxMutation creates new mutation for the Wx entity.
  46913. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  46914. m := &WxMutation{
  46915. config: c,
  46916. op: op,
  46917. typ: TypeWx,
  46918. clearedFields: make(map[string]struct{}),
  46919. }
  46920. for _, opt := range opts {
  46921. opt(m)
  46922. }
  46923. return m
  46924. }
  46925. // withWxID sets the ID field of the mutation.
  46926. func withWxID(id uint64) wxOption {
  46927. return func(m *WxMutation) {
  46928. var (
  46929. err error
  46930. once sync.Once
  46931. value *Wx
  46932. )
  46933. m.oldValue = func(ctx context.Context) (*Wx, error) {
  46934. once.Do(func() {
  46935. if m.done {
  46936. err = errors.New("querying old values post mutation is not allowed")
  46937. } else {
  46938. value, err = m.Client().Wx.Get(ctx, id)
  46939. }
  46940. })
  46941. return value, err
  46942. }
  46943. m.id = &id
  46944. }
  46945. }
  46946. // withWx sets the old Wx of the mutation.
  46947. func withWx(node *Wx) wxOption {
  46948. return func(m *WxMutation) {
  46949. m.oldValue = func(context.Context) (*Wx, error) {
  46950. return node, nil
  46951. }
  46952. m.id = &node.ID
  46953. }
  46954. }
  46955. // Client returns a new `ent.Client` from the mutation. If the mutation was
  46956. // executed in a transaction (ent.Tx), a transactional client is returned.
  46957. func (m WxMutation) Client() *Client {
  46958. client := &Client{config: m.config}
  46959. client.init()
  46960. return client
  46961. }
  46962. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  46963. // it returns an error otherwise.
  46964. func (m WxMutation) Tx() (*Tx, error) {
  46965. if _, ok := m.driver.(*txDriver); !ok {
  46966. return nil, errors.New("ent: mutation is not running in a transaction")
  46967. }
  46968. tx := &Tx{config: m.config}
  46969. tx.init()
  46970. return tx, nil
  46971. }
  46972. // SetID sets the value of the id field. Note that this
  46973. // operation is only accepted on creation of Wx entities.
  46974. func (m *WxMutation) SetID(id uint64) {
  46975. m.id = &id
  46976. }
  46977. // ID returns the ID value in the mutation. Note that the ID is only available
  46978. // if it was provided to the builder or after it was returned from the database.
  46979. func (m *WxMutation) ID() (id uint64, exists bool) {
  46980. if m.id == nil {
  46981. return
  46982. }
  46983. return *m.id, true
  46984. }
  46985. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  46986. // That means, if the mutation is applied within a transaction with an isolation level such
  46987. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  46988. // or updated by the mutation.
  46989. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  46990. switch {
  46991. case m.op.Is(OpUpdateOne | OpDeleteOne):
  46992. id, exists := m.ID()
  46993. if exists {
  46994. return []uint64{id}, nil
  46995. }
  46996. fallthrough
  46997. case m.op.Is(OpUpdate | OpDelete):
  46998. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  46999. default:
  47000. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  47001. }
  47002. }
  47003. // SetCreatedAt sets the "created_at" field.
  47004. func (m *WxMutation) SetCreatedAt(t time.Time) {
  47005. m.created_at = &t
  47006. }
  47007. // CreatedAt returns the value of the "created_at" field in the mutation.
  47008. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  47009. v := m.created_at
  47010. if v == nil {
  47011. return
  47012. }
  47013. return *v, true
  47014. }
  47015. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  47016. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47018. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  47019. if !m.op.Is(OpUpdateOne) {
  47020. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  47021. }
  47022. if m.id == nil || m.oldValue == nil {
  47023. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  47024. }
  47025. oldValue, err := m.oldValue(ctx)
  47026. if err != nil {
  47027. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  47028. }
  47029. return oldValue.CreatedAt, nil
  47030. }
  47031. // ResetCreatedAt resets all changes to the "created_at" field.
  47032. func (m *WxMutation) ResetCreatedAt() {
  47033. m.created_at = nil
  47034. }
  47035. // SetUpdatedAt sets the "updated_at" field.
  47036. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  47037. m.updated_at = &t
  47038. }
  47039. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  47040. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  47041. v := m.updated_at
  47042. if v == nil {
  47043. return
  47044. }
  47045. return *v, true
  47046. }
  47047. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  47048. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47050. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  47051. if !m.op.Is(OpUpdateOne) {
  47052. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  47053. }
  47054. if m.id == nil || m.oldValue == nil {
  47055. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  47056. }
  47057. oldValue, err := m.oldValue(ctx)
  47058. if err != nil {
  47059. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  47060. }
  47061. return oldValue.UpdatedAt, nil
  47062. }
  47063. // ResetUpdatedAt resets all changes to the "updated_at" field.
  47064. func (m *WxMutation) ResetUpdatedAt() {
  47065. m.updated_at = nil
  47066. }
  47067. // SetStatus sets the "status" field.
  47068. func (m *WxMutation) SetStatus(u uint8) {
  47069. m.status = &u
  47070. m.addstatus = nil
  47071. }
  47072. // Status returns the value of the "status" field in the mutation.
  47073. func (m *WxMutation) Status() (r uint8, exists bool) {
  47074. v := m.status
  47075. if v == nil {
  47076. return
  47077. }
  47078. return *v, true
  47079. }
  47080. // OldStatus returns the old "status" field's value of the Wx entity.
  47081. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47083. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  47084. if !m.op.Is(OpUpdateOne) {
  47085. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  47086. }
  47087. if m.id == nil || m.oldValue == nil {
  47088. return v, errors.New("OldStatus requires an ID field in the mutation")
  47089. }
  47090. oldValue, err := m.oldValue(ctx)
  47091. if err != nil {
  47092. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  47093. }
  47094. return oldValue.Status, nil
  47095. }
  47096. // AddStatus adds u to the "status" field.
  47097. func (m *WxMutation) AddStatus(u int8) {
  47098. if m.addstatus != nil {
  47099. *m.addstatus += u
  47100. } else {
  47101. m.addstatus = &u
  47102. }
  47103. }
  47104. // AddedStatus returns the value that was added to the "status" field in this mutation.
  47105. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  47106. v := m.addstatus
  47107. if v == nil {
  47108. return
  47109. }
  47110. return *v, true
  47111. }
  47112. // ClearStatus clears the value of the "status" field.
  47113. func (m *WxMutation) ClearStatus() {
  47114. m.status = nil
  47115. m.addstatus = nil
  47116. m.clearedFields[wx.FieldStatus] = struct{}{}
  47117. }
  47118. // StatusCleared returns if the "status" field was cleared in this mutation.
  47119. func (m *WxMutation) StatusCleared() bool {
  47120. _, ok := m.clearedFields[wx.FieldStatus]
  47121. return ok
  47122. }
  47123. // ResetStatus resets all changes to the "status" field.
  47124. func (m *WxMutation) ResetStatus() {
  47125. m.status = nil
  47126. m.addstatus = nil
  47127. delete(m.clearedFields, wx.FieldStatus)
  47128. }
  47129. // SetDeletedAt sets the "deleted_at" field.
  47130. func (m *WxMutation) SetDeletedAt(t time.Time) {
  47131. m.deleted_at = &t
  47132. }
  47133. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  47134. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  47135. v := m.deleted_at
  47136. if v == nil {
  47137. return
  47138. }
  47139. return *v, true
  47140. }
  47141. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  47142. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47144. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  47145. if !m.op.Is(OpUpdateOne) {
  47146. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  47147. }
  47148. if m.id == nil || m.oldValue == nil {
  47149. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  47150. }
  47151. oldValue, err := m.oldValue(ctx)
  47152. if err != nil {
  47153. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  47154. }
  47155. return oldValue.DeletedAt, nil
  47156. }
  47157. // ClearDeletedAt clears the value of the "deleted_at" field.
  47158. func (m *WxMutation) ClearDeletedAt() {
  47159. m.deleted_at = nil
  47160. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  47161. }
  47162. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  47163. func (m *WxMutation) DeletedAtCleared() bool {
  47164. _, ok := m.clearedFields[wx.FieldDeletedAt]
  47165. return ok
  47166. }
  47167. // ResetDeletedAt resets all changes to the "deleted_at" field.
  47168. func (m *WxMutation) ResetDeletedAt() {
  47169. m.deleted_at = nil
  47170. delete(m.clearedFields, wx.FieldDeletedAt)
  47171. }
  47172. // SetServerID sets the "server_id" field.
  47173. func (m *WxMutation) SetServerID(u uint64) {
  47174. m.server = &u
  47175. }
  47176. // ServerID returns the value of the "server_id" field in the mutation.
  47177. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  47178. v := m.server
  47179. if v == nil {
  47180. return
  47181. }
  47182. return *v, true
  47183. }
  47184. // OldServerID returns the old "server_id" field's value of the Wx entity.
  47185. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47187. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  47188. if !m.op.Is(OpUpdateOne) {
  47189. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  47190. }
  47191. if m.id == nil || m.oldValue == nil {
  47192. return v, errors.New("OldServerID requires an ID field in the mutation")
  47193. }
  47194. oldValue, err := m.oldValue(ctx)
  47195. if err != nil {
  47196. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  47197. }
  47198. return oldValue.ServerID, nil
  47199. }
  47200. // ClearServerID clears the value of the "server_id" field.
  47201. func (m *WxMutation) ClearServerID() {
  47202. m.server = nil
  47203. m.clearedFields[wx.FieldServerID] = struct{}{}
  47204. }
  47205. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  47206. func (m *WxMutation) ServerIDCleared() bool {
  47207. _, ok := m.clearedFields[wx.FieldServerID]
  47208. return ok
  47209. }
  47210. // ResetServerID resets all changes to the "server_id" field.
  47211. func (m *WxMutation) ResetServerID() {
  47212. m.server = nil
  47213. delete(m.clearedFields, wx.FieldServerID)
  47214. }
  47215. // SetPort sets the "port" field.
  47216. func (m *WxMutation) SetPort(s string) {
  47217. m.port = &s
  47218. }
  47219. // Port returns the value of the "port" field in the mutation.
  47220. func (m *WxMutation) Port() (r string, exists bool) {
  47221. v := m.port
  47222. if v == nil {
  47223. return
  47224. }
  47225. return *v, true
  47226. }
  47227. // OldPort returns the old "port" field's value of the Wx entity.
  47228. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47230. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  47231. if !m.op.Is(OpUpdateOne) {
  47232. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  47233. }
  47234. if m.id == nil || m.oldValue == nil {
  47235. return v, errors.New("OldPort requires an ID field in the mutation")
  47236. }
  47237. oldValue, err := m.oldValue(ctx)
  47238. if err != nil {
  47239. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  47240. }
  47241. return oldValue.Port, nil
  47242. }
  47243. // ResetPort resets all changes to the "port" field.
  47244. func (m *WxMutation) ResetPort() {
  47245. m.port = nil
  47246. }
  47247. // SetProcessID sets the "process_id" field.
  47248. func (m *WxMutation) SetProcessID(s string) {
  47249. m.process_id = &s
  47250. }
  47251. // ProcessID returns the value of the "process_id" field in the mutation.
  47252. func (m *WxMutation) ProcessID() (r string, exists bool) {
  47253. v := m.process_id
  47254. if v == nil {
  47255. return
  47256. }
  47257. return *v, true
  47258. }
  47259. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  47260. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47262. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  47263. if !m.op.Is(OpUpdateOne) {
  47264. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  47265. }
  47266. if m.id == nil || m.oldValue == nil {
  47267. return v, errors.New("OldProcessID requires an ID field in the mutation")
  47268. }
  47269. oldValue, err := m.oldValue(ctx)
  47270. if err != nil {
  47271. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  47272. }
  47273. return oldValue.ProcessID, nil
  47274. }
  47275. // ResetProcessID resets all changes to the "process_id" field.
  47276. func (m *WxMutation) ResetProcessID() {
  47277. m.process_id = nil
  47278. }
  47279. // SetCallback sets the "callback" field.
  47280. func (m *WxMutation) SetCallback(s string) {
  47281. m.callback = &s
  47282. }
  47283. // Callback returns the value of the "callback" field in the mutation.
  47284. func (m *WxMutation) Callback() (r string, exists bool) {
  47285. v := m.callback
  47286. if v == nil {
  47287. return
  47288. }
  47289. return *v, true
  47290. }
  47291. // OldCallback returns the old "callback" field's value of the Wx entity.
  47292. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47294. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  47295. if !m.op.Is(OpUpdateOne) {
  47296. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  47297. }
  47298. if m.id == nil || m.oldValue == nil {
  47299. return v, errors.New("OldCallback requires an ID field in the mutation")
  47300. }
  47301. oldValue, err := m.oldValue(ctx)
  47302. if err != nil {
  47303. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  47304. }
  47305. return oldValue.Callback, nil
  47306. }
  47307. // ResetCallback resets all changes to the "callback" field.
  47308. func (m *WxMutation) ResetCallback() {
  47309. m.callback = nil
  47310. }
  47311. // SetWxid sets the "wxid" field.
  47312. func (m *WxMutation) SetWxid(s string) {
  47313. m.wxid = &s
  47314. }
  47315. // Wxid returns the value of the "wxid" field in the mutation.
  47316. func (m *WxMutation) Wxid() (r string, exists bool) {
  47317. v := m.wxid
  47318. if v == nil {
  47319. return
  47320. }
  47321. return *v, true
  47322. }
  47323. // OldWxid returns the old "wxid" field's value of the Wx entity.
  47324. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47326. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  47327. if !m.op.Is(OpUpdateOne) {
  47328. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  47329. }
  47330. if m.id == nil || m.oldValue == nil {
  47331. return v, errors.New("OldWxid requires an ID field in the mutation")
  47332. }
  47333. oldValue, err := m.oldValue(ctx)
  47334. if err != nil {
  47335. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  47336. }
  47337. return oldValue.Wxid, nil
  47338. }
  47339. // ResetWxid resets all changes to the "wxid" field.
  47340. func (m *WxMutation) ResetWxid() {
  47341. m.wxid = nil
  47342. }
  47343. // SetAccount sets the "account" field.
  47344. func (m *WxMutation) SetAccount(s string) {
  47345. m.account = &s
  47346. }
  47347. // Account returns the value of the "account" field in the mutation.
  47348. func (m *WxMutation) Account() (r string, exists bool) {
  47349. v := m.account
  47350. if v == nil {
  47351. return
  47352. }
  47353. return *v, true
  47354. }
  47355. // OldAccount returns the old "account" field's value of the Wx entity.
  47356. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47358. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  47359. if !m.op.Is(OpUpdateOne) {
  47360. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  47361. }
  47362. if m.id == nil || m.oldValue == nil {
  47363. return v, errors.New("OldAccount requires an ID field in the mutation")
  47364. }
  47365. oldValue, err := m.oldValue(ctx)
  47366. if err != nil {
  47367. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  47368. }
  47369. return oldValue.Account, nil
  47370. }
  47371. // ResetAccount resets all changes to the "account" field.
  47372. func (m *WxMutation) ResetAccount() {
  47373. m.account = nil
  47374. }
  47375. // SetNickname sets the "nickname" field.
  47376. func (m *WxMutation) SetNickname(s string) {
  47377. m.nickname = &s
  47378. }
  47379. // Nickname returns the value of the "nickname" field in the mutation.
  47380. func (m *WxMutation) Nickname() (r string, exists bool) {
  47381. v := m.nickname
  47382. if v == nil {
  47383. return
  47384. }
  47385. return *v, true
  47386. }
  47387. // OldNickname returns the old "nickname" field's value of the Wx entity.
  47388. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47390. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  47391. if !m.op.Is(OpUpdateOne) {
  47392. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  47393. }
  47394. if m.id == nil || m.oldValue == nil {
  47395. return v, errors.New("OldNickname requires an ID field in the mutation")
  47396. }
  47397. oldValue, err := m.oldValue(ctx)
  47398. if err != nil {
  47399. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  47400. }
  47401. return oldValue.Nickname, nil
  47402. }
  47403. // ResetNickname resets all changes to the "nickname" field.
  47404. func (m *WxMutation) ResetNickname() {
  47405. m.nickname = nil
  47406. }
  47407. // SetTel sets the "tel" field.
  47408. func (m *WxMutation) SetTel(s string) {
  47409. m.tel = &s
  47410. }
  47411. // Tel returns the value of the "tel" field in the mutation.
  47412. func (m *WxMutation) Tel() (r string, exists bool) {
  47413. v := m.tel
  47414. if v == nil {
  47415. return
  47416. }
  47417. return *v, true
  47418. }
  47419. // OldTel returns the old "tel" field's value of the Wx entity.
  47420. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47422. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  47423. if !m.op.Is(OpUpdateOne) {
  47424. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  47425. }
  47426. if m.id == nil || m.oldValue == nil {
  47427. return v, errors.New("OldTel requires an ID field in the mutation")
  47428. }
  47429. oldValue, err := m.oldValue(ctx)
  47430. if err != nil {
  47431. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  47432. }
  47433. return oldValue.Tel, nil
  47434. }
  47435. // ResetTel resets all changes to the "tel" field.
  47436. func (m *WxMutation) ResetTel() {
  47437. m.tel = nil
  47438. }
  47439. // SetHeadBig sets the "head_big" field.
  47440. func (m *WxMutation) SetHeadBig(s string) {
  47441. m.head_big = &s
  47442. }
  47443. // HeadBig returns the value of the "head_big" field in the mutation.
  47444. func (m *WxMutation) HeadBig() (r string, exists bool) {
  47445. v := m.head_big
  47446. if v == nil {
  47447. return
  47448. }
  47449. return *v, true
  47450. }
  47451. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  47452. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47454. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  47455. if !m.op.Is(OpUpdateOne) {
  47456. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  47457. }
  47458. if m.id == nil || m.oldValue == nil {
  47459. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  47460. }
  47461. oldValue, err := m.oldValue(ctx)
  47462. if err != nil {
  47463. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  47464. }
  47465. return oldValue.HeadBig, nil
  47466. }
  47467. // ResetHeadBig resets all changes to the "head_big" field.
  47468. func (m *WxMutation) ResetHeadBig() {
  47469. m.head_big = nil
  47470. }
  47471. // SetOrganizationID sets the "organization_id" field.
  47472. func (m *WxMutation) SetOrganizationID(u uint64) {
  47473. m.organization_id = &u
  47474. m.addorganization_id = nil
  47475. }
  47476. // OrganizationID returns the value of the "organization_id" field in the mutation.
  47477. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  47478. v := m.organization_id
  47479. if v == nil {
  47480. return
  47481. }
  47482. return *v, true
  47483. }
  47484. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  47485. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47486. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47487. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  47488. if !m.op.Is(OpUpdateOne) {
  47489. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  47490. }
  47491. if m.id == nil || m.oldValue == nil {
  47492. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  47493. }
  47494. oldValue, err := m.oldValue(ctx)
  47495. if err != nil {
  47496. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  47497. }
  47498. return oldValue.OrganizationID, nil
  47499. }
  47500. // AddOrganizationID adds u to the "organization_id" field.
  47501. func (m *WxMutation) AddOrganizationID(u int64) {
  47502. if m.addorganization_id != nil {
  47503. *m.addorganization_id += u
  47504. } else {
  47505. m.addorganization_id = &u
  47506. }
  47507. }
  47508. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  47509. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  47510. v := m.addorganization_id
  47511. if v == nil {
  47512. return
  47513. }
  47514. return *v, true
  47515. }
  47516. // ClearOrganizationID clears the value of the "organization_id" field.
  47517. func (m *WxMutation) ClearOrganizationID() {
  47518. m.organization_id = nil
  47519. m.addorganization_id = nil
  47520. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  47521. }
  47522. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  47523. func (m *WxMutation) OrganizationIDCleared() bool {
  47524. _, ok := m.clearedFields[wx.FieldOrganizationID]
  47525. return ok
  47526. }
  47527. // ResetOrganizationID resets all changes to the "organization_id" field.
  47528. func (m *WxMutation) ResetOrganizationID() {
  47529. m.organization_id = nil
  47530. m.addorganization_id = nil
  47531. delete(m.clearedFields, wx.FieldOrganizationID)
  47532. }
  47533. // SetAgentID sets the "agent_id" field.
  47534. func (m *WxMutation) SetAgentID(u uint64) {
  47535. m.agent = &u
  47536. }
  47537. // AgentID returns the value of the "agent_id" field in the mutation.
  47538. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  47539. v := m.agent
  47540. if v == nil {
  47541. return
  47542. }
  47543. return *v, true
  47544. }
  47545. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  47546. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47548. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  47549. if !m.op.Is(OpUpdateOne) {
  47550. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  47551. }
  47552. if m.id == nil || m.oldValue == nil {
  47553. return v, errors.New("OldAgentID requires an ID field in the mutation")
  47554. }
  47555. oldValue, err := m.oldValue(ctx)
  47556. if err != nil {
  47557. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  47558. }
  47559. return oldValue.AgentID, nil
  47560. }
  47561. // ResetAgentID resets all changes to the "agent_id" field.
  47562. func (m *WxMutation) ResetAgentID() {
  47563. m.agent = nil
  47564. }
  47565. // SetAPIBase sets the "api_base" field.
  47566. func (m *WxMutation) SetAPIBase(s string) {
  47567. m.api_base = &s
  47568. }
  47569. // APIBase returns the value of the "api_base" field in the mutation.
  47570. func (m *WxMutation) APIBase() (r string, exists bool) {
  47571. v := m.api_base
  47572. if v == nil {
  47573. return
  47574. }
  47575. return *v, true
  47576. }
  47577. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  47578. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47580. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  47581. if !m.op.Is(OpUpdateOne) {
  47582. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  47583. }
  47584. if m.id == nil || m.oldValue == nil {
  47585. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  47586. }
  47587. oldValue, err := m.oldValue(ctx)
  47588. if err != nil {
  47589. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  47590. }
  47591. return oldValue.APIBase, nil
  47592. }
  47593. // ClearAPIBase clears the value of the "api_base" field.
  47594. func (m *WxMutation) ClearAPIBase() {
  47595. m.api_base = nil
  47596. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  47597. }
  47598. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  47599. func (m *WxMutation) APIBaseCleared() bool {
  47600. _, ok := m.clearedFields[wx.FieldAPIBase]
  47601. return ok
  47602. }
  47603. // ResetAPIBase resets all changes to the "api_base" field.
  47604. func (m *WxMutation) ResetAPIBase() {
  47605. m.api_base = nil
  47606. delete(m.clearedFields, wx.FieldAPIBase)
  47607. }
  47608. // SetAPIKey sets the "api_key" field.
  47609. func (m *WxMutation) SetAPIKey(s string) {
  47610. m.api_key = &s
  47611. }
  47612. // APIKey returns the value of the "api_key" field in the mutation.
  47613. func (m *WxMutation) APIKey() (r string, exists bool) {
  47614. v := m.api_key
  47615. if v == nil {
  47616. return
  47617. }
  47618. return *v, true
  47619. }
  47620. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  47621. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47623. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  47624. if !m.op.Is(OpUpdateOne) {
  47625. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  47626. }
  47627. if m.id == nil || m.oldValue == nil {
  47628. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  47629. }
  47630. oldValue, err := m.oldValue(ctx)
  47631. if err != nil {
  47632. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  47633. }
  47634. return oldValue.APIKey, nil
  47635. }
  47636. // ClearAPIKey clears the value of the "api_key" field.
  47637. func (m *WxMutation) ClearAPIKey() {
  47638. m.api_key = nil
  47639. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  47640. }
  47641. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  47642. func (m *WxMutation) APIKeyCleared() bool {
  47643. _, ok := m.clearedFields[wx.FieldAPIKey]
  47644. return ok
  47645. }
  47646. // ResetAPIKey resets all changes to the "api_key" field.
  47647. func (m *WxMutation) ResetAPIKey() {
  47648. m.api_key = nil
  47649. delete(m.clearedFields, wx.FieldAPIKey)
  47650. }
  47651. // SetAllowList sets the "allow_list" field.
  47652. func (m *WxMutation) SetAllowList(s []string) {
  47653. m.allow_list = &s
  47654. m.appendallow_list = nil
  47655. }
  47656. // AllowList returns the value of the "allow_list" field in the mutation.
  47657. func (m *WxMutation) AllowList() (r []string, exists bool) {
  47658. v := m.allow_list
  47659. if v == nil {
  47660. return
  47661. }
  47662. return *v, true
  47663. }
  47664. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  47665. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47667. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  47668. if !m.op.Is(OpUpdateOne) {
  47669. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  47670. }
  47671. if m.id == nil || m.oldValue == nil {
  47672. return v, errors.New("OldAllowList requires an ID field in the mutation")
  47673. }
  47674. oldValue, err := m.oldValue(ctx)
  47675. if err != nil {
  47676. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  47677. }
  47678. return oldValue.AllowList, nil
  47679. }
  47680. // AppendAllowList adds s to the "allow_list" field.
  47681. func (m *WxMutation) AppendAllowList(s []string) {
  47682. m.appendallow_list = append(m.appendallow_list, s...)
  47683. }
  47684. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  47685. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  47686. if len(m.appendallow_list) == 0 {
  47687. return nil, false
  47688. }
  47689. return m.appendallow_list, true
  47690. }
  47691. // ResetAllowList resets all changes to the "allow_list" field.
  47692. func (m *WxMutation) ResetAllowList() {
  47693. m.allow_list = nil
  47694. m.appendallow_list = nil
  47695. }
  47696. // SetGroupAllowList sets the "group_allow_list" field.
  47697. func (m *WxMutation) SetGroupAllowList(s []string) {
  47698. m.group_allow_list = &s
  47699. m.appendgroup_allow_list = nil
  47700. }
  47701. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  47702. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  47703. v := m.group_allow_list
  47704. if v == nil {
  47705. return
  47706. }
  47707. return *v, true
  47708. }
  47709. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  47710. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47712. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  47713. if !m.op.Is(OpUpdateOne) {
  47714. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  47715. }
  47716. if m.id == nil || m.oldValue == nil {
  47717. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  47718. }
  47719. oldValue, err := m.oldValue(ctx)
  47720. if err != nil {
  47721. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  47722. }
  47723. return oldValue.GroupAllowList, nil
  47724. }
  47725. // AppendGroupAllowList adds s to the "group_allow_list" field.
  47726. func (m *WxMutation) AppendGroupAllowList(s []string) {
  47727. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  47728. }
  47729. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  47730. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  47731. if len(m.appendgroup_allow_list) == 0 {
  47732. return nil, false
  47733. }
  47734. return m.appendgroup_allow_list, true
  47735. }
  47736. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  47737. func (m *WxMutation) ResetGroupAllowList() {
  47738. m.group_allow_list = nil
  47739. m.appendgroup_allow_list = nil
  47740. }
  47741. // SetBlockList sets the "block_list" field.
  47742. func (m *WxMutation) SetBlockList(s []string) {
  47743. m.block_list = &s
  47744. m.appendblock_list = nil
  47745. }
  47746. // BlockList returns the value of the "block_list" field in the mutation.
  47747. func (m *WxMutation) BlockList() (r []string, exists bool) {
  47748. v := m.block_list
  47749. if v == nil {
  47750. return
  47751. }
  47752. return *v, true
  47753. }
  47754. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  47755. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47757. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  47758. if !m.op.Is(OpUpdateOne) {
  47759. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  47760. }
  47761. if m.id == nil || m.oldValue == nil {
  47762. return v, errors.New("OldBlockList requires an ID field in the mutation")
  47763. }
  47764. oldValue, err := m.oldValue(ctx)
  47765. if err != nil {
  47766. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  47767. }
  47768. return oldValue.BlockList, nil
  47769. }
  47770. // AppendBlockList adds s to the "block_list" field.
  47771. func (m *WxMutation) AppendBlockList(s []string) {
  47772. m.appendblock_list = append(m.appendblock_list, s...)
  47773. }
  47774. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  47775. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  47776. if len(m.appendblock_list) == 0 {
  47777. return nil, false
  47778. }
  47779. return m.appendblock_list, true
  47780. }
  47781. // ResetBlockList resets all changes to the "block_list" field.
  47782. func (m *WxMutation) ResetBlockList() {
  47783. m.block_list = nil
  47784. m.appendblock_list = nil
  47785. }
  47786. // SetGroupBlockList sets the "group_block_list" field.
  47787. func (m *WxMutation) SetGroupBlockList(s []string) {
  47788. m.group_block_list = &s
  47789. m.appendgroup_block_list = nil
  47790. }
  47791. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  47792. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  47793. v := m.group_block_list
  47794. if v == nil {
  47795. return
  47796. }
  47797. return *v, true
  47798. }
  47799. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  47800. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47802. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  47803. if !m.op.Is(OpUpdateOne) {
  47804. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  47805. }
  47806. if m.id == nil || m.oldValue == nil {
  47807. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  47808. }
  47809. oldValue, err := m.oldValue(ctx)
  47810. if err != nil {
  47811. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  47812. }
  47813. return oldValue.GroupBlockList, nil
  47814. }
  47815. // AppendGroupBlockList adds s to the "group_block_list" field.
  47816. func (m *WxMutation) AppendGroupBlockList(s []string) {
  47817. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  47818. }
  47819. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  47820. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  47821. if len(m.appendgroup_block_list) == 0 {
  47822. return nil, false
  47823. }
  47824. return m.appendgroup_block_list, true
  47825. }
  47826. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  47827. func (m *WxMutation) ResetGroupBlockList() {
  47828. m.group_block_list = nil
  47829. m.appendgroup_block_list = nil
  47830. }
  47831. // SetCtype sets the "ctype" field.
  47832. func (m *WxMutation) SetCtype(u uint64) {
  47833. m.ctype = &u
  47834. m.addctype = nil
  47835. }
  47836. // Ctype returns the value of the "ctype" field in the mutation.
  47837. func (m *WxMutation) Ctype() (r uint64, exists bool) {
  47838. v := m.ctype
  47839. if v == nil {
  47840. return
  47841. }
  47842. return *v, true
  47843. }
  47844. // OldCtype returns the old "ctype" field's value of the Wx entity.
  47845. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  47846. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  47847. func (m *WxMutation) OldCtype(ctx context.Context) (v uint64, err error) {
  47848. if !m.op.Is(OpUpdateOne) {
  47849. return v, errors.New("OldCtype is only allowed on UpdateOne operations")
  47850. }
  47851. if m.id == nil || m.oldValue == nil {
  47852. return v, errors.New("OldCtype requires an ID field in the mutation")
  47853. }
  47854. oldValue, err := m.oldValue(ctx)
  47855. if err != nil {
  47856. return v, fmt.Errorf("querying old value for OldCtype: %w", err)
  47857. }
  47858. return oldValue.Ctype, nil
  47859. }
  47860. // AddCtype adds u to the "ctype" field.
  47861. func (m *WxMutation) AddCtype(u int64) {
  47862. if m.addctype != nil {
  47863. *m.addctype += u
  47864. } else {
  47865. m.addctype = &u
  47866. }
  47867. }
  47868. // AddedCtype returns the value that was added to the "ctype" field in this mutation.
  47869. func (m *WxMutation) AddedCtype() (r int64, exists bool) {
  47870. v := m.addctype
  47871. if v == nil {
  47872. return
  47873. }
  47874. return *v, true
  47875. }
  47876. // ClearCtype clears the value of the "ctype" field.
  47877. func (m *WxMutation) ClearCtype() {
  47878. m.ctype = nil
  47879. m.addctype = nil
  47880. m.clearedFields[wx.FieldCtype] = struct{}{}
  47881. }
  47882. // CtypeCleared returns if the "ctype" field was cleared in this mutation.
  47883. func (m *WxMutation) CtypeCleared() bool {
  47884. _, ok := m.clearedFields[wx.FieldCtype]
  47885. return ok
  47886. }
  47887. // ResetCtype resets all changes to the "ctype" field.
  47888. func (m *WxMutation) ResetCtype() {
  47889. m.ctype = nil
  47890. m.addctype = nil
  47891. delete(m.clearedFields, wx.FieldCtype)
  47892. }
  47893. // ClearServer clears the "server" edge to the Server entity.
  47894. func (m *WxMutation) ClearServer() {
  47895. m.clearedserver = true
  47896. m.clearedFields[wx.FieldServerID] = struct{}{}
  47897. }
  47898. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  47899. func (m *WxMutation) ServerCleared() bool {
  47900. return m.ServerIDCleared() || m.clearedserver
  47901. }
  47902. // ServerIDs returns the "server" edge IDs in the mutation.
  47903. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47904. // ServerID instead. It exists only for internal usage by the builders.
  47905. func (m *WxMutation) ServerIDs() (ids []uint64) {
  47906. if id := m.server; id != nil {
  47907. ids = append(ids, *id)
  47908. }
  47909. return
  47910. }
  47911. // ResetServer resets all changes to the "server" edge.
  47912. func (m *WxMutation) ResetServer() {
  47913. m.server = nil
  47914. m.clearedserver = false
  47915. }
  47916. // ClearAgent clears the "agent" edge to the Agent entity.
  47917. func (m *WxMutation) ClearAgent() {
  47918. m.clearedagent = true
  47919. m.clearedFields[wx.FieldAgentID] = struct{}{}
  47920. }
  47921. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  47922. func (m *WxMutation) AgentCleared() bool {
  47923. return m.clearedagent
  47924. }
  47925. // AgentIDs returns the "agent" edge IDs in the mutation.
  47926. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  47927. // AgentID instead. It exists only for internal usage by the builders.
  47928. func (m *WxMutation) AgentIDs() (ids []uint64) {
  47929. if id := m.agent; id != nil {
  47930. ids = append(ids, *id)
  47931. }
  47932. return
  47933. }
  47934. // ResetAgent resets all changes to the "agent" edge.
  47935. func (m *WxMutation) ResetAgent() {
  47936. m.agent = nil
  47937. m.clearedagent = false
  47938. }
  47939. // Where appends a list predicates to the WxMutation builder.
  47940. func (m *WxMutation) Where(ps ...predicate.Wx) {
  47941. m.predicates = append(m.predicates, ps...)
  47942. }
  47943. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  47944. // users can use type-assertion to append predicates that do not depend on any generated package.
  47945. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  47946. p := make([]predicate.Wx, len(ps))
  47947. for i := range ps {
  47948. p[i] = ps[i]
  47949. }
  47950. m.Where(p...)
  47951. }
  47952. // Op returns the operation name.
  47953. func (m *WxMutation) Op() Op {
  47954. return m.op
  47955. }
  47956. // SetOp allows setting the mutation operation.
  47957. func (m *WxMutation) SetOp(op Op) {
  47958. m.op = op
  47959. }
  47960. // Type returns the node type of this mutation (Wx).
  47961. func (m *WxMutation) Type() string {
  47962. return m.typ
  47963. }
  47964. // Fields returns all fields that were changed during this mutation. Note that in
  47965. // order to get all numeric fields that were incremented/decremented, call
  47966. // AddedFields().
  47967. func (m *WxMutation) Fields() []string {
  47968. fields := make([]string, 0, 22)
  47969. if m.created_at != nil {
  47970. fields = append(fields, wx.FieldCreatedAt)
  47971. }
  47972. if m.updated_at != nil {
  47973. fields = append(fields, wx.FieldUpdatedAt)
  47974. }
  47975. if m.status != nil {
  47976. fields = append(fields, wx.FieldStatus)
  47977. }
  47978. if m.deleted_at != nil {
  47979. fields = append(fields, wx.FieldDeletedAt)
  47980. }
  47981. if m.server != nil {
  47982. fields = append(fields, wx.FieldServerID)
  47983. }
  47984. if m.port != nil {
  47985. fields = append(fields, wx.FieldPort)
  47986. }
  47987. if m.process_id != nil {
  47988. fields = append(fields, wx.FieldProcessID)
  47989. }
  47990. if m.callback != nil {
  47991. fields = append(fields, wx.FieldCallback)
  47992. }
  47993. if m.wxid != nil {
  47994. fields = append(fields, wx.FieldWxid)
  47995. }
  47996. if m.account != nil {
  47997. fields = append(fields, wx.FieldAccount)
  47998. }
  47999. if m.nickname != nil {
  48000. fields = append(fields, wx.FieldNickname)
  48001. }
  48002. if m.tel != nil {
  48003. fields = append(fields, wx.FieldTel)
  48004. }
  48005. if m.head_big != nil {
  48006. fields = append(fields, wx.FieldHeadBig)
  48007. }
  48008. if m.organization_id != nil {
  48009. fields = append(fields, wx.FieldOrganizationID)
  48010. }
  48011. if m.agent != nil {
  48012. fields = append(fields, wx.FieldAgentID)
  48013. }
  48014. if m.api_base != nil {
  48015. fields = append(fields, wx.FieldAPIBase)
  48016. }
  48017. if m.api_key != nil {
  48018. fields = append(fields, wx.FieldAPIKey)
  48019. }
  48020. if m.allow_list != nil {
  48021. fields = append(fields, wx.FieldAllowList)
  48022. }
  48023. if m.group_allow_list != nil {
  48024. fields = append(fields, wx.FieldGroupAllowList)
  48025. }
  48026. if m.block_list != nil {
  48027. fields = append(fields, wx.FieldBlockList)
  48028. }
  48029. if m.group_block_list != nil {
  48030. fields = append(fields, wx.FieldGroupBlockList)
  48031. }
  48032. if m.ctype != nil {
  48033. fields = append(fields, wx.FieldCtype)
  48034. }
  48035. return fields
  48036. }
  48037. // Field returns the value of a field with the given name. The second boolean
  48038. // return value indicates that this field was not set, or was not defined in the
  48039. // schema.
  48040. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  48041. switch name {
  48042. case wx.FieldCreatedAt:
  48043. return m.CreatedAt()
  48044. case wx.FieldUpdatedAt:
  48045. return m.UpdatedAt()
  48046. case wx.FieldStatus:
  48047. return m.Status()
  48048. case wx.FieldDeletedAt:
  48049. return m.DeletedAt()
  48050. case wx.FieldServerID:
  48051. return m.ServerID()
  48052. case wx.FieldPort:
  48053. return m.Port()
  48054. case wx.FieldProcessID:
  48055. return m.ProcessID()
  48056. case wx.FieldCallback:
  48057. return m.Callback()
  48058. case wx.FieldWxid:
  48059. return m.Wxid()
  48060. case wx.FieldAccount:
  48061. return m.Account()
  48062. case wx.FieldNickname:
  48063. return m.Nickname()
  48064. case wx.FieldTel:
  48065. return m.Tel()
  48066. case wx.FieldHeadBig:
  48067. return m.HeadBig()
  48068. case wx.FieldOrganizationID:
  48069. return m.OrganizationID()
  48070. case wx.FieldAgentID:
  48071. return m.AgentID()
  48072. case wx.FieldAPIBase:
  48073. return m.APIBase()
  48074. case wx.FieldAPIKey:
  48075. return m.APIKey()
  48076. case wx.FieldAllowList:
  48077. return m.AllowList()
  48078. case wx.FieldGroupAllowList:
  48079. return m.GroupAllowList()
  48080. case wx.FieldBlockList:
  48081. return m.BlockList()
  48082. case wx.FieldGroupBlockList:
  48083. return m.GroupBlockList()
  48084. case wx.FieldCtype:
  48085. return m.Ctype()
  48086. }
  48087. return nil, false
  48088. }
  48089. // OldField returns the old value of the field from the database. An error is
  48090. // returned if the mutation operation is not UpdateOne, or the query to the
  48091. // database failed.
  48092. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  48093. switch name {
  48094. case wx.FieldCreatedAt:
  48095. return m.OldCreatedAt(ctx)
  48096. case wx.FieldUpdatedAt:
  48097. return m.OldUpdatedAt(ctx)
  48098. case wx.FieldStatus:
  48099. return m.OldStatus(ctx)
  48100. case wx.FieldDeletedAt:
  48101. return m.OldDeletedAt(ctx)
  48102. case wx.FieldServerID:
  48103. return m.OldServerID(ctx)
  48104. case wx.FieldPort:
  48105. return m.OldPort(ctx)
  48106. case wx.FieldProcessID:
  48107. return m.OldProcessID(ctx)
  48108. case wx.FieldCallback:
  48109. return m.OldCallback(ctx)
  48110. case wx.FieldWxid:
  48111. return m.OldWxid(ctx)
  48112. case wx.FieldAccount:
  48113. return m.OldAccount(ctx)
  48114. case wx.FieldNickname:
  48115. return m.OldNickname(ctx)
  48116. case wx.FieldTel:
  48117. return m.OldTel(ctx)
  48118. case wx.FieldHeadBig:
  48119. return m.OldHeadBig(ctx)
  48120. case wx.FieldOrganizationID:
  48121. return m.OldOrganizationID(ctx)
  48122. case wx.FieldAgentID:
  48123. return m.OldAgentID(ctx)
  48124. case wx.FieldAPIBase:
  48125. return m.OldAPIBase(ctx)
  48126. case wx.FieldAPIKey:
  48127. return m.OldAPIKey(ctx)
  48128. case wx.FieldAllowList:
  48129. return m.OldAllowList(ctx)
  48130. case wx.FieldGroupAllowList:
  48131. return m.OldGroupAllowList(ctx)
  48132. case wx.FieldBlockList:
  48133. return m.OldBlockList(ctx)
  48134. case wx.FieldGroupBlockList:
  48135. return m.OldGroupBlockList(ctx)
  48136. case wx.FieldCtype:
  48137. return m.OldCtype(ctx)
  48138. }
  48139. return nil, fmt.Errorf("unknown Wx field %s", name)
  48140. }
  48141. // SetField sets the value of a field with the given name. It returns an error if
  48142. // the field is not defined in the schema, or if the type mismatched the field
  48143. // type.
  48144. func (m *WxMutation) SetField(name string, value ent.Value) error {
  48145. switch name {
  48146. case wx.FieldCreatedAt:
  48147. v, ok := value.(time.Time)
  48148. if !ok {
  48149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48150. }
  48151. m.SetCreatedAt(v)
  48152. return nil
  48153. case wx.FieldUpdatedAt:
  48154. v, ok := value.(time.Time)
  48155. if !ok {
  48156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48157. }
  48158. m.SetUpdatedAt(v)
  48159. return nil
  48160. case wx.FieldStatus:
  48161. v, ok := value.(uint8)
  48162. if !ok {
  48163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48164. }
  48165. m.SetStatus(v)
  48166. return nil
  48167. case wx.FieldDeletedAt:
  48168. v, ok := value.(time.Time)
  48169. if !ok {
  48170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48171. }
  48172. m.SetDeletedAt(v)
  48173. return nil
  48174. case wx.FieldServerID:
  48175. v, ok := value.(uint64)
  48176. if !ok {
  48177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48178. }
  48179. m.SetServerID(v)
  48180. return nil
  48181. case wx.FieldPort:
  48182. v, ok := value.(string)
  48183. if !ok {
  48184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48185. }
  48186. m.SetPort(v)
  48187. return nil
  48188. case wx.FieldProcessID:
  48189. v, ok := value.(string)
  48190. if !ok {
  48191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48192. }
  48193. m.SetProcessID(v)
  48194. return nil
  48195. case wx.FieldCallback:
  48196. v, ok := value.(string)
  48197. if !ok {
  48198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48199. }
  48200. m.SetCallback(v)
  48201. return nil
  48202. case wx.FieldWxid:
  48203. v, ok := value.(string)
  48204. if !ok {
  48205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48206. }
  48207. m.SetWxid(v)
  48208. return nil
  48209. case wx.FieldAccount:
  48210. v, ok := value.(string)
  48211. if !ok {
  48212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48213. }
  48214. m.SetAccount(v)
  48215. return nil
  48216. case wx.FieldNickname:
  48217. v, ok := value.(string)
  48218. if !ok {
  48219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48220. }
  48221. m.SetNickname(v)
  48222. return nil
  48223. case wx.FieldTel:
  48224. v, ok := value.(string)
  48225. if !ok {
  48226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48227. }
  48228. m.SetTel(v)
  48229. return nil
  48230. case wx.FieldHeadBig:
  48231. v, ok := value.(string)
  48232. if !ok {
  48233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48234. }
  48235. m.SetHeadBig(v)
  48236. return nil
  48237. case wx.FieldOrganizationID:
  48238. v, ok := value.(uint64)
  48239. if !ok {
  48240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48241. }
  48242. m.SetOrganizationID(v)
  48243. return nil
  48244. case wx.FieldAgentID:
  48245. v, ok := value.(uint64)
  48246. if !ok {
  48247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48248. }
  48249. m.SetAgentID(v)
  48250. return nil
  48251. case wx.FieldAPIBase:
  48252. v, ok := value.(string)
  48253. if !ok {
  48254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48255. }
  48256. m.SetAPIBase(v)
  48257. return nil
  48258. case wx.FieldAPIKey:
  48259. v, ok := value.(string)
  48260. if !ok {
  48261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48262. }
  48263. m.SetAPIKey(v)
  48264. return nil
  48265. case wx.FieldAllowList:
  48266. v, ok := value.([]string)
  48267. if !ok {
  48268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48269. }
  48270. m.SetAllowList(v)
  48271. return nil
  48272. case wx.FieldGroupAllowList:
  48273. v, ok := value.([]string)
  48274. if !ok {
  48275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48276. }
  48277. m.SetGroupAllowList(v)
  48278. return nil
  48279. case wx.FieldBlockList:
  48280. v, ok := value.([]string)
  48281. if !ok {
  48282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48283. }
  48284. m.SetBlockList(v)
  48285. return nil
  48286. case wx.FieldGroupBlockList:
  48287. v, ok := value.([]string)
  48288. if !ok {
  48289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48290. }
  48291. m.SetGroupBlockList(v)
  48292. return nil
  48293. case wx.FieldCtype:
  48294. v, ok := value.(uint64)
  48295. if !ok {
  48296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48297. }
  48298. m.SetCtype(v)
  48299. return nil
  48300. }
  48301. return fmt.Errorf("unknown Wx field %s", name)
  48302. }
  48303. // AddedFields returns all numeric fields that were incremented/decremented during
  48304. // this mutation.
  48305. func (m *WxMutation) AddedFields() []string {
  48306. var fields []string
  48307. if m.addstatus != nil {
  48308. fields = append(fields, wx.FieldStatus)
  48309. }
  48310. if m.addorganization_id != nil {
  48311. fields = append(fields, wx.FieldOrganizationID)
  48312. }
  48313. if m.addctype != nil {
  48314. fields = append(fields, wx.FieldCtype)
  48315. }
  48316. return fields
  48317. }
  48318. // AddedField returns the numeric value that was incremented/decremented on a field
  48319. // with the given name. The second boolean return value indicates that this field
  48320. // was not set, or was not defined in the schema.
  48321. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  48322. switch name {
  48323. case wx.FieldStatus:
  48324. return m.AddedStatus()
  48325. case wx.FieldOrganizationID:
  48326. return m.AddedOrganizationID()
  48327. case wx.FieldCtype:
  48328. return m.AddedCtype()
  48329. }
  48330. return nil, false
  48331. }
  48332. // AddField adds the value to the field with the given name. It returns an error if
  48333. // the field is not defined in the schema, or if the type mismatched the field
  48334. // type.
  48335. func (m *WxMutation) AddField(name string, value ent.Value) error {
  48336. switch name {
  48337. case wx.FieldStatus:
  48338. v, ok := value.(int8)
  48339. if !ok {
  48340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48341. }
  48342. m.AddStatus(v)
  48343. return nil
  48344. case wx.FieldOrganizationID:
  48345. v, ok := value.(int64)
  48346. if !ok {
  48347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48348. }
  48349. m.AddOrganizationID(v)
  48350. return nil
  48351. case wx.FieldCtype:
  48352. v, ok := value.(int64)
  48353. if !ok {
  48354. return fmt.Errorf("unexpected type %T for field %s", value, name)
  48355. }
  48356. m.AddCtype(v)
  48357. return nil
  48358. }
  48359. return fmt.Errorf("unknown Wx numeric field %s", name)
  48360. }
  48361. // ClearedFields returns all nullable fields that were cleared during this
  48362. // mutation.
  48363. func (m *WxMutation) ClearedFields() []string {
  48364. var fields []string
  48365. if m.FieldCleared(wx.FieldStatus) {
  48366. fields = append(fields, wx.FieldStatus)
  48367. }
  48368. if m.FieldCleared(wx.FieldDeletedAt) {
  48369. fields = append(fields, wx.FieldDeletedAt)
  48370. }
  48371. if m.FieldCleared(wx.FieldServerID) {
  48372. fields = append(fields, wx.FieldServerID)
  48373. }
  48374. if m.FieldCleared(wx.FieldOrganizationID) {
  48375. fields = append(fields, wx.FieldOrganizationID)
  48376. }
  48377. if m.FieldCleared(wx.FieldAPIBase) {
  48378. fields = append(fields, wx.FieldAPIBase)
  48379. }
  48380. if m.FieldCleared(wx.FieldAPIKey) {
  48381. fields = append(fields, wx.FieldAPIKey)
  48382. }
  48383. if m.FieldCleared(wx.FieldCtype) {
  48384. fields = append(fields, wx.FieldCtype)
  48385. }
  48386. return fields
  48387. }
  48388. // FieldCleared returns a boolean indicating if a field with the given name was
  48389. // cleared in this mutation.
  48390. func (m *WxMutation) FieldCleared(name string) bool {
  48391. _, ok := m.clearedFields[name]
  48392. return ok
  48393. }
  48394. // ClearField clears the value of the field with the given name. It returns an
  48395. // error if the field is not defined in the schema.
  48396. func (m *WxMutation) ClearField(name string) error {
  48397. switch name {
  48398. case wx.FieldStatus:
  48399. m.ClearStatus()
  48400. return nil
  48401. case wx.FieldDeletedAt:
  48402. m.ClearDeletedAt()
  48403. return nil
  48404. case wx.FieldServerID:
  48405. m.ClearServerID()
  48406. return nil
  48407. case wx.FieldOrganizationID:
  48408. m.ClearOrganizationID()
  48409. return nil
  48410. case wx.FieldAPIBase:
  48411. m.ClearAPIBase()
  48412. return nil
  48413. case wx.FieldAPIKey:
  48414. m.ClearAPIKey()
  48415. return nil
  48416. case wx.FieldCtype:
  48417. m.ClearCtype()
  48418. return nil
  48419. }
  48420. return fmt.Errorf("unknown Wx nullable field %s", name)
  48421. }
  48422. // ResetField resets all changes in the mutation for the field with the given name.
  48423. // It returns an error if the field is not defined in the schema.
  48424. func (m *WxMutation) ResetField(name string) error {
  48425. switch name {
  48426. case wx.FieldCreatedAt:
  48427. m.ResetCreatedAt()
  48428. return nil
  48429. case wx.FieldUpdatedAt:
  48430. m.ResetUpdatedAt()
  48431. return nil
  48432. case wx.FieldStatus:
  48433. m.ResetStatus()
  48434. return nil
  48435. case wx.FieldDeletedAt:
  48436. m.ResetDeletedAt()
  48437. return nil
  48438. case wx.FieldServerID:
  48439. m.ResetServerID()
  48440. return nil
  48441. case wx.FieldPort:
  48442. m.ResetPort()
  48443. return nil
  48444. case wx.FieldProcessID:
  48445. m.ResetProcessID()
  48446. return nil
  48447. case wx.FieldCallback:
  48448. m.ResetCallback()
  48449. return nil
  48450. case wx.FieldWxid:
  48451. m.ResetWxid()
  48452. return nil
  48453. case wx.FieldAccount:
  48454. m.ResetAccount()
  48455. return nil
  48456. case wx.FieldNickname:
  48457. m.ResetNickname()
  48458. return nil
  48459. case wx.FieldTel:
  48460. m.ResetTel()
  48461. return nil
  48462. case wx.FieldHeadBig:
  48463. m.ResetHeadBig()
  48464. return nil
  48465. case wx.FieldOrganizationID:
  48466. m.ResetOrganizationID()
  48467. return nil
  48468. case wx.FieldAgentID:
  48469. m.ResetAgentID()
  48470. return nil
  48471. case wx.FieldAPIBase:
  48472. m.ResetAPIBase()
  48473. return nil
  48474. case wx.FieldAPIKey:
  48475. m.ResetAPIKey()
  48476. return nil
  48477. case wx.FieldAllowList:
  48478. m.ResetAllowList()
  48479. return nil
  48480. case wx.FieldGroupAllowList:
  48481. m.ResetGroupAllowList()
  48482. return nil
  48483. case wx.FieldBlockList:
  48484. m.ResetBlockList()
  48485. return nil
  48486. case wx.FieldGroupBlockList:
  48487. m.ResetGroupBlockList()
  48488. return nil
  48489. case wx.FieldCtype:
  48490. m.ResetCtype()
  48491. return nil
  48492. }
  48493. return fmt.Errorf("unknown Wx field %s", name)
  48494. }
  48495. // AddedEdges returns all edge names that were set/added in this mutation.
  48496. func (m *WxMutation) AddedEdges() []string {
  48497. edges := make([]string, 0, 2)
  48498. if m.server != nil {
  48499. edges = append(edges, wx.EdgeServer)
  48500. }
  48501. if m.agent != nil {
  48502. edges = append(edges, wx.EdgeAgent)
  48503. }
  48504. return edges
  48505. }
  48506. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  48507. // name in this mutation.
  48508. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  48509. switch name {
  48510. case wx.EdgeServer:
  48511. if id := m.server; id != nil {
  48512. return []ent.Value{*id}
  48513. }
  48514. case wx.EdgeAgent:
  48515. if id := m.agent; id != nil {
  48516. return []ent.Value{*id}
  48517. }
  48518. }
  48519. return nil
  48520. }
  48521. // RemovedEdges returns all edge names that were removed in this mutation.
  48522. func (m *WxMutation) RemovedEdges() []string {
  48523. edges := make([]string, 0, 2)
  48524. return edges
  48525. }
  48526. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  48527. // the given name in this mutation.
  48528. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  48529. return nil
  48530. }
  48531. // ClearedEdges returns all edge names that were cleared in this mutation.
  48532. func (m *WxMutation) ClearedEdges() []string {
  48533. edges := make([]string, 0, 2)
  48534. if m.clearedserver {
  48535. edges = append(edges, wx.EdgeServer)
  48536. }
  48537. if m.clearedagent {
  48538. edges = append(edges, wx.EdgeAgent)
  48539. }
  48540. return edges
  48541. }
  48542. // EdgeCleared returns a boolean which indicates if the edge with the given name
  48543. // was cleared in this mutation.
  48544. func (m *WxMutation) EdgeCleared(name string) bool {
  48545. switch name {
  48546. case wx.EdgeServer:
  48547. return m.clearedserver
  48548. case wx.EdgeAgent:
  48549. return m.clearedagent
  48550. }
  48551. return false
  48552. }
  48553. // ClearEdge clears the value of the edge with the given name. It returns an error
  48554. // if that edge is not defined in the schema.
  48555. func (m *WxMutation) ClearEdge(name string) error {
  48556. switch name {
  48557. case wx.EdgeServer:
  48558. m.ClearServer()
  48559. return nil
  48560. case wx.EdgeAgent:
  48561. m.ClearAgent()
  48562. return nil
  48563. }
  48564. return fmt.Errorf("unknown Wx unique edge %s", name)
  48565. }
  48566. // ResetEdge resets all changes to the edge with the given name in this mutation.
  48567. // It returns an error if the edge is not defined in the schema.
  48568. func (m *WxMutation) ResetEdge(name string) error {
  48569. switch name {
  48570. case wx.EdgeServer:
  48571. m.ResetServer()
  48572. return nil
  48573. case wx.EdgeAgent:
  48574. m.ResetAgent()
  48575. return nil
  48576. }
  48577. return fmt.Errorf("unknown Wx edge %s", name)
  48578. }
  48579. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  48580. type WxCardMutation struct {
  48581. config
  48582. op Op
  48583. typ string
  48584. id *uint64
  48585. created_at *time.Time
  48586. updated_at *time.Time
  48587. deleted_at *time.Time
  48588. user_id *uint64
  48589. adduser_id *int64
  48590. wx_user_id *uint64
  48591. addwx_user_id *int64
  48592. avatar *string
  48593. logo *string
  48594. name *string
  48595. company *string
  48596. address *string
  48597. phone *string
  48598. official_account *string
  48599. wechat_account *string
  48600. email *string
  48601. api_base *string
  48602. api_key *string
  48603. ai_info *string
  48604. intro *string
  48605. clearedFields map[string]struct{}
  48606. done bool
  48607. oldValue func(context.Context) (*WxCard, error)
  48608. predicates []predicate.WxCard
  48609. }
  48610. var _ ent.Mutation = (*WxCardMutation)(nil)
  48611. // wxcardOption allows management of the mutation configuration using functional options.
  48612. type wxcardOption func(*WxCardMutation)
  48613. // newWxCardMutation creates new mutation for the WxCard entity.
  48614. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  48615. m := &WxCardMutation{
  48616. config: c,
  48617. op: op,
  48618. typ: TypeWxCard,
  48619. clearedFields: make(map[string]struct{}),
  48620. }
  48621. for _, opt := range opts {
  48622. opt(m)
  48623. }
  48624. return m
  48625. }
  48626. // withWxCardID sets the ID field of the mutation.
  48627. func withWxCardID(id uint64) wxcardOption {
  48628. return func(m *WxCardMutation) {
  48629. var (
  48630. err error
  48631. once sync.Once
  48632. value *WxCard
  48633. )
  48634. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  48635. once.Do(func() {
  48636. if m.done {
  48637. err = errors.New("querying old values post mutation is not allowed")
  48638. } else {
  48639. value, err = m.Client().WxCard.Get(ctx, id)
  48640. }
  48641. })
  48642. return value, err
  48643. }
  48644. m.id = &id
  48645. }
  48646. }
  48647. // withWxCard sets the old WxCard of the mutation.
  48648. func withWxCard(node *WxCard) wxcardOption {
  48649. return func(m *WxCardMutation) {
  48650. m.oldValue = func(context.Context) (*WxCard, error) {
  48651. return node, nil
  48652. }
  48653. m.id = &node.ID
  48654. }
  48655. }
  48656. // Client returns a new `ent.Client` from the mutation. If the mutation was
  48657. // executed in a transaction (ent.Tx), a transactional client is returned.
  48658. func (m WxCardMutation) Client() *Client {
  48659. client := &Client{config: m.config}
  48660. client.init()
  48661. return client
  48662. }
  48663. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  48664. // it returns an error otherwise.
  48665. func (m WxCardMutation) Tx() (*Tx, error) {
  48666. if _, ok := m.driver.(*txDriver); !ok {
  48667. return nil, errors.New("ent: mutation is not running in a transaction")
  48668. }
  48669. tx := &Tx{config: m.config}
  48670. tx.init()
  48671. return tx, nil
  48672. }
  48673. // SetID sets the value of the id field. Note that this
  48674. // operation is only accepted on creation of WxCard entities.
  48675. func (m *WxCardMutation) SetID(id uint64) {
  48676. m.id = &id
  48677. }
  48678. // ID returns the ID value in the mutation. Note that the ID is only available
  48679. // if it was provided to the builder or after it was returned from the database.
  48680. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  48681. if m.id == nil {
  48682. return
  48683. }
  48684. return *m.id, true
  48685. }
  48686. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  48687. // That means, if the mutation is applied within a transaction with an isolation level such
  48688. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  48689. // or updated by the mutation.
  48690. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  48691. switch {
  48692. case m.op.Is(OpUpdateOne | OpDeleteOne):
  48693. id, exists := m.ID()
  48694. if exists {
  48695. return []uint64{id}, nil
  48696. }
  48697. fallthrough
  48698. case m.op.Is(OpUpdate | OpDelete):
  48699. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  48700. default:
  48701. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  48702. }
  48703. }
  48704. // SetCreatedAt sets the "created_at" field.
  48705. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  48706. m.created_at = &t
  48707. }
  48708. // CreatedAt returns the value of the "created_at" field in the mutation.
  48709. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  48710. v := m.created_at
  48711. if v == nil {
  48712. return
  48713. }
  48714. return *v, true
  48715. }
  48716. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  48717. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48719. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  48720. if !m.op.Is(OpUpdateOne) {
  48721. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  48722. }
  48723. if m.id == nil || m.oldValue == nil {
  48724. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  48725. }
  48726. oldValue, err := m.oldValue(ctx)
  48727. if err != nil {
  48728. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  48729. }
  48730. return oldValue.CreatedAt, nil
  48731. }
  48732. // ResetCreatedAt resets all changes to the "created_at" field.
  48733. func (m *WxCardMutation) ResetCreatedAt() {
  48734. m.created_at = nil
  48735. }
  48736. // SetUpdatedAt sets the "updated_at" field.
  48737. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  48738. m.updated_at = &t
  48739. }
  48740. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  48741. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  48742. v := m.updated_at
  48743. if v == nil {
  48744. return
  48745. }
  48746. return *v, true
  48747. }
  48748. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  48749. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48751. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  48752. if !m.op.Is(OpUpdateOne) {
  48753. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  48754. }
  48755. if m.id == nil || m.oldValue == nil {
  48756. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  48757. }
  48758. oldValue, err := m.oldValue(ctx)
  48759. if err != nil {
  48760. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  48761. }
  48762. return oldValue.UpdatedAt, nil
  48763. }
  48764. // ResetUpdatedAt resets all changes to the "updated_at" field.
  48765. func (m *WxCardMutation) ResetUpdatedAt() {
  48766. m.updated_at = nil
  48767. }
  48768. // SetDeletedAt sets the "deleted_at" field.
  48769. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  48770. m.deleted_at = &t
  48771. }
  48772. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  48773. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  48774. v := m.deleted_at
  48775. if v == nil {
  48776. return
  48777. }
  48778. return *v, true
  48779. }
  48780. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  48781. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48783. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  48784. if !m.op.Is(OpUpdateOne) {
  48785. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  48786. }
  48787. if m.id == nil || m.oldValue == nil {
  48788. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  48789. }
  48790. oldValue, err := m.oldValue(ctx)
  48791. if err != nil {
  48792. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  48793. }
  48794. return oldValue.DeletedAt, nil
  48795. }
  48796. // ClearDeletedAt clears the value of the "deleted_at" field.
  48797. func (m *WxCardMutation) ClearDeletedAt() {
  48798. m.deleted_at = nil
  48799. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  48800. }
  48801. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  48802. func (m *WxCardMutation) DeletedAtCleared() bool {
  48803. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  48804. return ok
  48805. }
  48806. // ResetDeletedAt resets all changes to the "deleted_at" field.
  48807. func (m *WxCardMutation) ResetDeletedAt() {
  48808. m.deleted_at = nil
  48809. delete(m.clearedFields, wxcard.FieldDeletedAt)
  48810. }
  48811. // SetUserID sets the "user_id" field.
  48812. func (m *WxCardMutation) SetUserID(u uint64) {
  48813. m.user_id = &u
  48814. m.adduser_id = nil
  48815. }
  48816. // UserID returns the value of the "user_id" field in the mutation.
  48817. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  48818. v := m.user_id
  48819. if v == nil {
  48820. return
  48821. }
  48822. return *v, true
  48823. }
  48824. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  48825. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48827. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  48828. if !m.op.Is(OpUpdateOne) {
  48829. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  48830. }
  48831. if m.id == nil || m.oldValue == nil {
  48832. return v, errors.New("OldUserID requires an ID field in the mutation")
  48833. }
  48834. oldValue, err := m.oldValue(ctx)
  48835. if err != nil {
  48836. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  48837. }
  48838. return oldValue.UserID, nil
  48839. }
  48840. // AddUserID adds u to the "user_id" field.
  48841. func (m *WxCardMutation) AddUserID(u int64) {
  48842. if m.adduser_id != nil {
  48843. *m.adduser_id += u
  48844. } else {
  48845. m.adduser_id = &u
  48846. }
  48847. }
  48848. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  48849. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  48850. v := m.adduser_id
  48851. if v == nil {
  48852. return
  48853. }
  48854. return *v, true
  48855. }
  48856. // ClearUserID clears the value of the "user_id" field.
  48857. func (m *WxCardMutation) ClearUserID() {
  48858. m.user_id = nil
  48859. m.adduser_id = nil
  48860. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  48861. }
  48862. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  48863. func (m *WxCardMutation) UserIDCleared() bool {
  48864. _, ok := m.clearedFields[wxcard.FieldUserID]
  48865. return ok
  48866. }
  48867. // ResetUserID resets all changes to the "user_id" field.
  48868. func (m *WxCardMutation) ResetUserID() {
  48869. m.user_id = nil
  48870. m.adduser_id = nil
  48871. delete(m.clearedFields, wxcard.FieldUserID)
  48872. }
  48873. // SetWxUserID sets the "wx_user_id" field.
  48874. func (m *WxCardMutation) SetWxUserID(u uint64) {
  48875. m.wx_user_id = &u
  48876. m.addwx_user_id = nil
  48877. }
  48878. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  48879. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  48880. v := m.wx_user_id
  48881. if v == nil {
  48882. return
  48883. }
  48884. return *v, true
  48885. }
  48886. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  48887. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48889. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  48890. if !m.op.Is(OpUpdateOne) {
  48891. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  48892. }
  48893. if m.id == nil || m.oldValue == nil {
  48894. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  48895. }
  48896. oldValue, err := m.oldValue(ctx)
  48897. if err != nil {
  48898. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  48899. }
  48900. return oldValue.WxUserID, nil
  48901. }
  48902. // AddWxUserID adds u to the "wx_user_id" field.
  48903. func (m *WxCardMutation) AddWxUserID(u int64) {
  48904. if m.addwx_user_id != nil {
  48905. *m.addwx_user_id += u
  48906. } else {
  48907. m.addwx_user_id = &u
  48908. }
  48909. }
  48910. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  48911. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  48912. v := m.addwx_user_id
  48913. if v == nil {
  48914. return
  48915. }
  48916. return *v, true
  48917. }
  48918. // ClearWxUserID clears the value of the "wx_user_id" field.
  48919. func (m *WxCardMutation) ClearWxUserID() {
  48920. m.wx_user_id = nil
  48921. m.addwx_user_id = nil
  48922. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  48923. }
  48924. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  48925. func (m *WxCardMutation) WxUserIDCleared() bool {
  48926. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  48927. return ok
  48928. }
  48929. // ResetWxUserID resets all changes to the "wx_user_id" field.
  48930. func (m *WxCardMutation) ResetWxUserID() {
  48931. m.wx_user_id = nil
  48932. m.addwx_user_id = nil
  48933. delete(m.clearedFields, wxcard.FieldWxUserID)
  48934. }
  48935. // SetAvatar sets the "avatar" field.
  48936. func (m *WxCardMutation) SetAvatar(s string) {
  48937. m.avatar = &s
  48938. }
  48939. // Avatar returns the value of the "avatar" field in the mutation.
  48940. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  48941. v := m.avatar
  48942. if v == nil {
  48943. return
  48944. }
  48945. return *v, true
  48946. }
  48947. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  48948. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48950. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  48951. if !m.op.Is(OpUpdateOne) {
  48952. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  48953. }
  48954. if m.id == nil || m.oldValue == nil {
  48955. return v, errors.New("OldAvatar requires an ID field in the mutation")
  48956. }
  48957. oldValue, err := m.oldValue(ctx)
  48958. if err != nil {
  48959. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  48960. }
  48961. return oldValue.Avatar, nil
  48962. }
  48963. // ResetAvatar resets all changes to the "avatar" field.
  48964. func (m *WxCardMutation) ResetAvatar() {
  48965. m.avatar = nil
  48966. }
  48967. // SetLogo sets the "logo" field.
  48968. func (m *WxCardMutation) SetLogo(s string) {
  48969. m.logo = &s
  48970. }
  48971. // Logo returns the value of the "logo" field in the mutation.
  48972. func (m *WxCardMutation) Logo() (r string, exists bool) {
  48973. v := m.logo
  48974. if v == nil {
  48975. return
  48976. }
  48977. return *v, true
  48978. }
  48979. // OldLogo returns the old "logo" field's value of the WxCard entity.
  48980. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  48981. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  48982. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  48983. if !m.op.Is(OpUpdateOne) {
  48984. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  48985. }
  48986. if m.id == nil || m.oldValue == nil {
  48987. return v, errors.New("OldLogo requires an ID field in the mutation")
  48988. }
  48989. oldValue, err := m.oldValue(ctx)
  48990. if err != nil {
  48991. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  48992. }
  48993. return oldValue.Logo, nil
  48994. }
  48995. // ResetLogo resets all changes to the "logo" field.
  48996. func (m *WxCardMutation) ResetLogo() {
  48997. m.logo = nil
  48998. }
  48999. // SetName sets the "name" field.
  49000. func (m *WxCardMutation) SetName(s string) {
  49001. m.name = &s
  49002. }
  49003. // Name returns the value of the "name" field in the mutation.
  49004. func (m *WxCardMutation) Name() (r string, exists bool) {
  49005. v := m.name
  49006. if v == nil {
  49007. return
  49008. }
  49009. return *v, true
  49010. }
  49011. // OldName returns the old "name" field's value of the WxCard entity.
  49012. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49014. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  49015. if !m.op.Is(OpUpdateOne) {
  49016. return v, errors.New("OldName is only allowed on UpdateOne operations")
  49017. }
  49018. if m.id == nil || m.oldValue == nil {
  49019. return v, errors.New("OldName requires an ID field in the mutation")
  49020. }
  49021. oldValue, err := m.oldValue(ctx)
  49022. if err != nil {
  49023. return v, fmt.Errorf("querying old value for OldName: %w", err)
  49024. }
  49025. return oldValue.Name, nil
  49026. }
  49027. // ResetName resets all changes to the "name" field.
  49028. func (m *WxCardMutation) ResetName() {
  49029. m.name = nil
  49030. }
  49031. // SetCompany sets the "company" field.
  49032. func (m *WxCardMutation) SetCompany(s string) {
  49033. m.company = &s
  49034. }
  49035. // Company returns the value of the "company" field in the mutation.
  49036. func (m *WxCardMutation) Company() (r string, exists bool) {
  49037. v := m.company
  49038. if v == nil {
  49039. return
  49040. }
  49041. return *v, true
  49042. }
  49043. // OldCompany returns the old "company" field's value of the WxCard entity.
  49044. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49046. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  49047. if !m.op.Is(OpUpdateOne) {
  49048. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  49049. }
  49050. if m.id == nil || m.oldValue == nil {
  49051. return v, errors.New("OldCompany requires an ID field in the mutation")
  49052. }
  49053. oldValue, err := m.oldValue(ctx)
  49054. if err != nil {
  49055. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  49056. }
  49057. return oldValue.Company, nil
  49058. }
  49059. // ResetCompany resets all changes to the "company" field.
  49060. func (m *WxCardMutation) ResetCompany() {
  49061. m.company = nil
  49062. }
  49063. // SetAddress sets the "address" field.
  49064. func (m *WxCardMutation) SetAddress(s string) {
  49065. m.address = &s
  49066. }
  49067. // Address returns the value of the "address" field in the mutation.
  49068. func (m *WxCardMutation) Address() (r string, exists bool) {
  49069. v := m.address
  49070. if v == nil {
  49071. return
  49072. }
  49073. return *v, true
  49074. }
  49075. // OldAddress returns the old "address" field's value of the WxCard entity.
  49076. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49078. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  49079. if !m.op.Is(OpUpdateOne) {
  49080. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  49081. }
  49082. if m.id == nil || m.oldValue == nil {
  49083. return v, errors.New("OldAddress requires an ID field in the mutation")
  49084. }
  49085. oldValue, err := m.oldValue(ctx)
  49086. if err != nil {
  49087. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  49088. }
  49089. return oldValue.Address, nil
  49090. }
  49091. // ResetAddress resets all changes to the "address" field.
  49092. func (m *WxCardMutation) ResetAddress() {
  49093. m.address = nil
  49094. }
  49095. // SetPhone sets the "phone" field.
  49096. func (m *WxCardMutation) SetPhone(s string) {
  49097. m.phone = &s
  49098. }
  49099. // Phone returns the value of the "phone" field in the mutation.
  49100. func (m *WxCardMutation) Phone() (r string, exists bool) {
  49101. v := m.phone
  49102. if v == nil {
  49103. return
  49104. }
  49105. return *v, true
  49106. }
  49107. // OldPhone returns the old "phone" field's value of the WxCard entity.
  49108. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49110. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  49111. if !m.op.Is(OpUpdateOne) {
  49112. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  49113. }
  49114. if m.id == nil || m.oldValue == nil {
  49115. return v, errors.New("OldPhone requires an ID field in the mutation")
  49116. }
  49117. oldValue, err := m.oldValue(ctx)
  49118. if err != nil {
  49119. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  49120. }
  49121. return oldValue.Phone, nil
  49122. }
  49123. // ResetPhone resets all changes to the "phone" field.
  49124. func (m *WxCardMutation) ResetPhone() {
  49125. m.phone = nil
  49126. }
  49127. // SetOfficialAccount sets the "official_account" field.
  49128. func (m *WxCardMutation) SetOfficialAccount(s string) {
  49129. m.official_account = &s
  49130. }
  49131. // OfficialAccount returns the value of the "official_account" field in the mutation.
  49132. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  49133. v := m.official_account
  49134. if v == nil {
  49135. return
  49136. }
  49137. return *v, true
  49138. }
  49139. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  49140. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49142. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  49143. if !m.op.Is(OpUpdateOne) {
  49144. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  49145. }
  49146. if m.id == nil || m.oldValue == nil {
  49147. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  49148. }
  49149. oldValue, err := m.oldValue(ctx)
  49150. if err != nil {
  49151. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  49152. }
  49153. return oldValue.OfficialAccount, nil
  49154. }
  49155. // ResetOfficialAccount resets all changes to the "official_account" field.
  49156. func (m *WxCardMutation) ResetOfficialAccount() {
  49157. m.official_account = nil
  49158. }
  49159. // SetWechatAccount sets the "wechat_account" field.
  49160. func (m *WxCardMutation) SetWechatAccount(s string) {
  49161. m.wechat_account = &s
  49162. }
  49163. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  49164. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  49165. v := m.wechat_account
  49166. if v == nil {
  49167. return
  49168. }
  49169. return *v, true
  49170. }
  49171. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  49172. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49174. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  49175. if !m.op.Is(OpUpdateOne) {
  49176. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  49177. }
  49178. if m.id == nil || m.oldValue == nil {
  49179. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  49180. }
  49181. oldValue, err := m.oldValue(ctx)
  49182. if err != nil {
  49183. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  49184. }
  49185. return oldValue.WechatAccount, nil
  49186. }
  49187. // ResetWechatAccount resets all changes to the "wechat_account" field.
  49188. func (m *WxCardMutation) ResetWechatAccount() {
  49189. m.wechat_account = nil
  49190. }
  49191. // SetEmail sets the "email" field.
  49192. func (m *WxCardMutation) SetEmail(s string) {
  49193. m.email = &s
  49194. }
  49195. // Email returns the value of the "email" field in the mutation.
  49196. func (m *WxCardMutation) Email() (r string, exists bool) {
  49197. v := m.email
  49198. if v == nil {
  49199. return
  49200. }
  49201. return *v, true
  49202. }
  49203. // OldEmail returns the old "email" field's value of the WxCard entity.
  49204. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49206. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  49207. if !m.op.Is(OpUpdateOne) {
  49208. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  49209. }
  49210. if m.id == nil || m.oldValue == nil {
  49211. return v, errors.New("OldEmail requires an ID field in the mutation")
  49212. }
  49213. oldValue, err := m.oldValue(ctx)
  49214. if err != nil {
  49215. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  49216. }
  49217. return oldValue.Email, nil
  49218. }
  49219. // ClearEmail clears the value of the "email" field.
  49220. func (m *WxCardMutation) ClearEmail() {
  49221. m.email = nil
  49222. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  49223. }
  49224. // EmailCleared returns if the "email" field was cleared in this mutation.
  49225. func (m *WxCardMutation) EmailCleared() bool {
  49226. _, ok := m.clearedFields[wxcard.FieldEmail]
  49227. return ok
  49228. }
  49229. // ResetEmail resets all changes to the "email" field.
  49230. func (m *WxCardMutation) ResetEmail() {
  49231. m.email = nil
  49232. delete(m.clearedFields, wxcard.FieldEmail)
  49233. }
  49234. // SetAPIBase sets the "api_base" field.
  49235. func (m *WxCardMutation) SetAPIBase(s string) {
  49236. m.api_base = &s
  49237. }
  49238. // APIBase returns the value of the "api_base" field in the mutation.
  49239. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  49240. v := m.api_base
  49241. if v == nil {
  49242. return
  49243. }
  49244. return *v, true
  49245. }
  49246. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  49247. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49249. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  49250. if !m.op.Is(OpUpdateOne) {
  49251. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  49252. }
  49253. if m.id == nil || m.oldValue == nil {
  49254. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  49255. }
  49256. oldValue, err := m.oldValue(ctx)
  49257. if err != nil {
  49258. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  49259. }
  49260. return oldValue.APIBase, nil
  49261. }
  49262. // ClearAPIBase clears the value of the "api_base" field.
  49263. func (m *WxCardMutation) ClearAPIBase() {
  49264. m.api_base = nil
  49265. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  49266. }
  49267. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  49268. func (m *WxCardMutation) APIBaseCleared() bool {
  49269. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  49270. return ok
  49271. }
  49272. // ResetAPIBase resets all changes to the "api_base" field.
  49273. func (m *WxCardMutation) ResetAPIBase() {
  49274. m.api_base = nil
  49275. delete(m.clearedFields, wxcard.FieldAPIBase)
  49276. }
  49277. // SetAPIKey sets the "api_key" field.
  49278. func (m *WxCardMutation) SetAPIKey(s string) {
  49279. m.api_key = &s
  49280. }
  49281. // APIKey returns the value of the "api_key" field in the mutation.
  49282. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  49283. v := m.api_key
  49284. if v == nil {
  49285. return
  49286. }
  49287. return *v, true
  49288. }
  49289. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  49290. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49292. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  49293. if !m.op.Is(OpUpdateOne) {
  49294. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  49295. }
  49296. if m.id == nil || m.oldValue == nil {
  49297. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  49298. }
  49299. oldValue, err := m.oldValue(ctx)
  49300. if err != nil {
  49301. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  49302. }
  49303. return oldValue.APIKey, nil
  49304. }
  49305. // ClearAPIKey clears the value of the "api_key" field.
  49306. func (m *WxCardMutation) ClearAPIKey() {
  49307. m.api_key = nil
  49308. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  49309. }
  49310. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  49311. func (m *WxCardMutation) APIKeyCleared() bool {
  49312. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  49313. return ok
  49314. }
  49315. // ResetAPIKey resets all changes to the "api_key" field.
  49316. func (m *WxCardMutation) ResetAPIKey() {
  49317. m.api_key = nil
  49318. delete(m.clearedFields, wxcard.FieldAPIKey)
  49319. }
  49320. // SetAiInfo sets the "ai_info" field.
  49321. func (m *WxCardMutation) SetAiInfo(s string) {
  49322. m.ai_info = &s
  49323. }
  49324. // AiInfo returns the value of the "ai_info" field in the mutation.
  49325. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  49326. v := m.ai_info
  49327. if v == nil {
  49328. return
  49329. }
  49330. return *v, true
  49331. }
  49332. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  49333. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49335. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  49336. if !m.op.Is(OpUpdateOne) {
  49337. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  49338. }
  49339. if m.id == nil || m.oldValue == nil {
  49340. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  49341. }
  49342. oldValue, err := m.oldValue(ctx)
  49343. if err != nil {
  49344. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  49345. }
  49346. return oldValue.AiInfo, nil
  49347. }
  49348. // ClearAiInfo clears the value of the "ai_info" field.
  49349. func (m *WxCardMutation) ClearAiInfo() {
  49350. m.ai_info = nil
  49351. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  49352. }
  49353. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  49354. func (m *WxCardMutation) AiInfoCleared() bool {
  49355. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  49356. return ok
  49357. }
  49358. // ResetAiInfo resets all changes to the "ai_info" field.
  49359. func (m *WxCardMutation) ResetAiInfo() {
  49360. m.ai_info = nil
  49361. delete(m.clearedFields, wxcard.FieldAiInfo)
  49362. }
  49363. // SetIntro sets the "intro" field.
  49364. func (m *WxCardMutation) SetIntro(s string) {
  49365. m.intro = &s
  49366. }
  49367. // Intro returns the value of the "intro" field in the mutation.
  49368. func (m *WxCardMutation) Intro() (r string, exists bool) {
  49369. v := m.intro
  49370. if v == nil {
  49371. return
  49372. }
  49373. return *v, true
  49374. }
  49375. // OldIntro returns the old "intro" field's value of the WxCard entity.
  49376. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  49377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  49378. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  49379. if !m.op.Is(OpUpdateOne) {
  49380. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  49381. }
  49382. if m.id == nil || m.oldValue == nil {
  49383. return v, errors.New("OldIntro requires an ID field in the mutation")
  49384. }
  49385. oldValue, err := m.oldValue(ctx)
  49386. if err != nil {
  49387. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  49388. }
  49389. return oldValue.Intro, nil
  49390. }
  49391. // ClearIntro clears the value of the "intro" field.
  49392. func (m *WxCardMutation) ClearIntro() {
  49393. m.intro = nil
  49394. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  49395. }
  49396. // IntroCleared returns if the "intro" field was cleared in this mutation.
  49397. func (m *WxCardMutation) IntroCleared() bool {
  49398. _, ok := m.clearedFields[wxcard.FieldIntro]
  49399. return ok
  49400. }
  49401. // ResetIntro resets all changes to the "intro" field.
  49402. func (m *WxCardMutation) ResetIntro() {
  49403. m.intro = nil
  49404. delete(m.clearedFields, wxcard.FieldIntro)
  49405. }
  49406. // Where appends a list predicates to the WxCardMutation builder.
  49407. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  49408. m.predicates = append(m.predicates, ps...)
  49409. }
  49410. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  49411. // users can use type-assertion to append predicates that do not depend on any generated package.
  49412. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  49413. p := make([]predicate.WxCard, len(ps))
  49414. for i := range ps {
  49415. p[i] = ps[i]
  49416. }
  49417. m.Where(p...)
  49418. }
  49419. // Op returns the operation name.
  49420. func (m *WxCardMutation) Op() Op {
  49421. return m.op
  49422. }
  49423. // SetOp allows setting the mutation operation.
  49424. func (m *WxCardMutation) SetOp(op Op) {
  49425. m.op = op
  49426. }
  49427. // Type returns the node type of this mutation (WxCard).
  49428. func (m *WxCardMutation) Type() string {
  49429. return m.typ
  49430. }
  49431. // Fields returns all fields that were changed during this mutation. Note that in
  49432. // order to get all numeric fields that were incremented/decremented, call
  49433. // AddedFields().
  49434. func (m *WxCardMutation) Fields() []string {
  49435. fields := make([]string, 0, 18)
  49436. if m.created_at != nil {
  49437. fields = append(fields, wxcard.FieldCreatedAt)
  49438. }
  49439. if m.updated_at != nil {
  49440. fields = append(fields, wxcard.FieldUpdatedAt)
  49441. }
  49442. if m.deleted_at != nil {
  49443. fields = append(fields, wxcard.FieldDeletedAt)
  49444. }
  49445. if m.user_id != nil {
  49446. fields = append(fields, wxcard.FieldUserID)
  49447. }
  49448. if m.wx_user_id != nil {
  49449. fields = append(fields, wxcard.FieldWxUserID)
  49450. }
  49451. if m.avatar != nil {
  49452. fields = append(fields, wxcard.FieldAvatar)
  49453. }
  49454. if m.logo != nil {
  49455. fields = append(fields, wxcard.FieldLogo)
  49456. }
  49457. if m.name != nil {
  49458. fields = append(fields, wxcard.FieldName)
  49459. }
  49460. if m.company != nil {
  49461. fields = append(fields, wxcard.FieldCompany)
  49462. }
  49463. if m.address != nil {
  49464. fields = append(fields, wxcard.FieldAddress)
  49465. }
  49466. if m.phone != nil {
  49467. fields = append(fields, wxcard.FieldPhone)
  49468. }
  49469. if m.official_account != nil {
  49470. fields = append(fields, wxcard.FieldOfficialAccount)
  49471. }
  49472. if m.wechat_account != nil {
  49473. fields = append(fields, wxcard.FieldWechatAccount)
  49474. }
  49475. if m.email != nil {
  49476. fields = append(fields, wxcard.FieldEmail)
  49477. }
  49478. if m.api_base != nil {
  49479. fields = append(fields, wxcard.FieldAPIBase)
  49480. }
  49481. if m.api_key != nil {
  49482. fields = append(fields, wxcard.FieldAPIKey)
  49483. }
  49484. if m.ai_info != nil {
  49485. fields = append(fields, wxcard.FieldAiInfo)
  49486. }
  49487. if m.intro != nil {
  49488. fields = append(fields, wxcard.FieldIntro)
  49489. }
  49490. return fields
  49491. }
  49492. // Field returns the value of a field with the given name. The second boolean
  49493. // return value indicates that this field was not set, or was not defined in the
  49494. // schema.
  49495. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  49496. switch name {
  49497. case wxcard.FieldCreatedAt:
  49498. return m.CreatedAt()
  49499. case wxcard.FieldUpdatedAt:
  49500. return m.UpdatedAt()
  49501. case wxcard.FieldDeletedAt:
  49502. return m.DeletedAt()
  49503. case wxcard.FieldUserID:
  49504. return m.UserID()
  49505. case wxcard.FieldWxUserID:
  49506. return m.WxUserID()
  49507. case wxcard.FieldAvatar:
  49508. return m.Avatar()
  49509. case wxcard.FieldLogo:
  49510. return m.Logo()
  49511. case wxcard.FieldName:
  49512. return m.Name()
  49513. case wxcard.FieldCompany:
  49514. return m.Company()
  49515. case wxcard.FieldAddress:
  49516. return m.Address()
  49517. case wxcard.FieldPhone:
  49518. return m.Phone()
  49519. case wxcard.FieldOfficialAccount:
  49520. return m.OfficialAccount()
  49521. case wxcard.FieldWechatAccount:
  49522. return m.WechatAccount()
  49523. case wxcard.FieldEmail:
  49524. return m.Email()
  49525. case wxcard.FieldAPIBase:
  49526. return m.APIBase()
  49527. case wxcard.FieldAPIKey:
  49528. return m.APIKey()
  49529. case wxcard.FieldAiInfo:
  49530. return m.AiInfo()
  49531. case wxcard.FieldIntro:
  49532. return m.Intro()
  49533. }
  49534. return nil, false
  49535. }
  49536. // OldField returns the old value of the field from the database. An error is
  49537. // returned if the mutation operation is not UpdateOne, or the query to the
  49538. // database failed.
  49539. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  49540. switch name {
  49541. case wxcard.FieldCreatedAt:
  49542. return m.OldCreatedAt(ctx)
  49543. case wxcard.FieldUpdatedAt:
  49544. return m.OldUpdatedAt(ctx)
  49545. case wxcard.FieldDeletedAt:
  49546. return m.OldDeletedAt(ctx)
  49547. case wxcard.FieldUserID:
  49548. return m.OldUserID(ctx)
  49549. case wxcard.FieldWxUserID:
  49550. return m.OldWxUserID(ctx)
  49551. case wxcard.FieldAvatar:
  49552. return m.OldAvatar(ctx)
  49553. case wxcard.FieldLogo:
  49554. return m.OldLogo(ctx)
  49555. case wxcard.FieldName:
  49556. return m.OldName(ctx)
  49557. case wxcard.FieldCompany:
  49558. return m.OldCompany(ctx)
  49559. case wxcard.FieldAddress:
  49560. return m.OldAddress(ctx)
  49561. case wxcard.FieldPhone:
  49562. return m.OldPhone(ctx)
  49563. case wxcard.FieldOfficialAccount:
  49564. return m.OldOfficialAccount(ctx)
  49565. case wxcard.FieldWechatAccount:
  49566. return m.OldWechatAccount(ctx)
  49567. case wxcard.FieldEmail:
  49568. return m.OldEmail(ctx)
  49569. case wxcard.FieldAPIBase:
  49570. return m.OldAPIBase(ctx)
  49571. case wxcard.FieldAPIKey:
  49572. return m.OldAPIKey(ctx)
  49573. case wxcard.FieldAiInfo:
  49574. return m.OldAiInfo(ctx)
  49575. case wxcard.FieldIntro:
  49576. return m.OldIntro(ctx)
  49577. }
  49578. return nil, fmt.Errorf("unknown WxCard field %s", name)
  49579. }
  49580. // SetField sets the value of a field with the given name. It returns an error if
  49581. // the field is not defined in the schema, or if the type mismatched the field
  49582. // type.
  49583. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  49584. switch name {
  49585. case wxcard.FieldCreatedAt:
  49586. v, ok := value.(time.Time)
  49587. if !ok {
  49588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49589. }
  49590. m.SetCreatedAt(v)
  49591. return nil
  49592. case wxcard.FieldUpdatedAt:
  49593. v, ok := value.(time.Time)
  49594. if !ok {
  49595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49596. }
  49597. m.SetUpdatedAt(v)
  49598. return nil
  49599. case wxcard.FieldDeletedAt:
  49600. v, ok := value.(time.Time)
  49601. if !ok {
  49602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49603. }
  49604. m.SetDeletedAt(v)
  49605. return nil
  49606. case wxcard.FieldUserID:
  49607. v, ok := value.(uint64)
  49608. if !ok {
  49609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49610. }
  49611. m.SetUserID(v)
  49612. return nil
  49613. case wxcard.FieldWxUserID:
  49614. v, ok := value.(uint64)
  49615. if !ok {
  49616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49617. }
  49618. m.SetWxUserID(v)
  49619. return nil
  49620. case wxcard.FieldAvatar:
  49621. v, ok := value.(string)
  49622. if !ok {
  49623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49624. }
  49625. m.SetAvatar(v)
  49626. return nil
  49627. case wxcard.FieldLogo:
  49628. v, ok := value.(string)
  49629. if !ok {
  49630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49631. }
  49632. m.SetLogo(v)
  49633. return nil
  49634. case wxcard.FieldName:
  49635. v, ok := value.(string)
  49636. if !ok {
  49637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49638. }
  49639. m.SetName(v)
  49640. return nil
  49641. case wxcard.FieldCompany:
  49642. v, ok := value.(string)
  49643. if !ok {
  49644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49645. }
  49646. m.SetCompany(v)
  49647. return nil
  49648. case wxcard.FieldAddress:
  49649. v, ok := value.(string)
  49650. if !ok {
  49651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49652. }
  49653. m.SetAddress(v)
  49654. return nil
  49655. case wxcard.FieldPhone:
  49656. v, ok := value.(string)
  49657. if !ok {
  49658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49659. }
  49660. m.SetPhone(v)
  49661. return nil
  49662. case wxcard.FieldOfficialAccount:
  49663. v, ok := value.(string)
  49664. if !ok {
  49665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49666. }
  49667. m.SetOfficialAccount(v)
  49668. return nil
  49669. case wxcard.FieldWechatAccount:
  49670. v, ok := value.(string)
  49671. if !ok {
  49672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49673. }
  49674. m.SetWechatAccount(v)
  49675. return nil
  49676. case wxcard.FieldEmail:
  49677. v, ok := value.(string)
  49678. if !ok {
  49679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49680. }
  49681. m.SetEmail(v)
  49682. return nil
  49683. case wxcard.FieldAPIBase:
  49684. v, ok := value.(string)
  49685. if !ok {
  49686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49687. }
  49688. m.SetAPIBase(v)
  49689. return nil
  49690. case wxcard.FieldAPIKey:
  49691. v, ok := value.(string)
  49692. if !ok {
  49693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49694. }
  49695. m.SetAPIKey(v)
  49696. return nil
  49697. case wxcard.FieldAiInfo:
  49698. v, ok := value.(string)
  49699. if !ok {
  49700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49701. }
  49702. m.SetAiInfo(v)
  49703. return nil
  49704. case wxcard.FieldIntro:
  49705. v, ok := value.(string)
  49706. if !ok {
  49707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49708. }
  49709. m.SetIntro(v)
  49710. return nil
  49711. }
  49712. return fmt.Errorf("unknown WxCard field %s", name)
  49713. }
  49714. // AddedFields returns all numeric fields that were incremented/decremented during
  49715. // this mutation.
  49716. func (m *WxCardMutation) AddedFields() []string {
  49717. var fields []string
  49718. if m.adduser_id != nil {
  49719. fields = append(fields, wxcard.FieldUserID)
  49720. }
  49721. if m.addwx_user_id != nil {
  49722. fields = append(fields, wxcard.FieldWxUserID)
  49723. }
  49724. return fields
  49725. }
  49726. // AddedField returns the numeric value that was incremented/decremented on a field
  49727. // with the given name. The second boolean return value indicates that this field
  49728. // was not set, or was not defined in the schema.
  49729. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  49730. switch name {
  49731. case wxcard.FieldUserID:
  49732. return m.AddedUserID()
  49733. case wxcard.FieldWxUserID:
  49734. return m.AddedWxUserID()
  49735. }
  49736. return nil, false
  49737. }
  49738. // AddField adds the value to the field with the given name. It returns an error if
  49739. // the field is not defined in the schema, or if the type mismatched the field
  49740. // type.
  49741. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  49742. switch name {
  49743. case wxcard.FieldUserID:
  49744. v, ok := value.(int64)
  49745. if !ok {
  49746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49747. }
  49748. m.AddUserID(v)
  49749. return nil
  49750. case wxcard.FieldWxUserID:
  49751. v, ok := value.(int64)
  49752. if !ok {
  49753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  49754. }
  49755. m.AddWxUserID(v)
  49756. return nil
  49757. }
  49758. return fmt.Errorf("unknown WxCard numeric field %s", name)
  49759. }
  49760. // ClearedFields returns all nullable fields that were cleared during this
  49761. // mutation.
  49762. func (m *WxCardMutation) ClearedFields() []string {
  49763. var fields []string
  49764. if m.FieldCleared(wxcard.FieldDeletedAt) {
  49765. fields = append(fields, wxcard.FieldDeletedAt)
  49766. }
  49767. if m.FieldCleared(wxcard.FieldUserID) {
  49768. fields = append(fields, wxcard.FieldUserID)
  49769. }
  49770. if m.FieldCleared(wxcard.FieldWxUserID) {
  49771. fields = append(fields, wxcard.FieldWxUserID)
  49772. }
  49773. if m.FieldCleared(wxcard.FieldEmail) {
  49774. fields = append(fields, wxcard.FieldEmail)
  49775. }
  49776. if m.FieldCleared(wxcard.FieldAPIBase) {
  49777. fields = append(fields, wxcard.FieldAPIBase)
  49778. }
  49779. if m.FieldCleared(wxcard.FieldAPIKey) {
  49780. fields = append(fields, wxcard.FieldAPIKey)
  49781. }
  49782. if m.FieldCleared(wxcard.FieldAiInfo) {
  49783. fields = append(fields, wxcard.FieldAiInfo)
  49784. }
  49785. if m.FieldCleared(wxcard.FieldIntro) {
  49786. fields = append(fields, wxcard.FieldIntro)
  49787. }
  49788. return fields
  49789. }
  49790. // FieldCleared returns a boolean indicating if a field with the given name was
  49791. // cleared in this mutation.
  49792. func (m *WxCardMutation) FieldCleared(name string) bool {
  49793. _, ok := m.clearedFields[name]
  49794. return ok
  49795. }
  49796. // ClearField clears the value of the field with the given name. It returns an
  49797. // error if the field is not defined in the schema.
  49798. func (m *WxCardMutation) ClearField(name string) error {
  49799. switch name {
  49800. case wxcard.FieldDeletedAt:
  49801. m.ClearDeletedAt()
  49802. return nil
  49803. case wxcard.FieldUserID:
  49804. m.ClearUserID()
  49805. return nil
  49806. case wxcard.FieldWxUserID:
  49807. m.ClearWxUserID()
  49808. return nil
  49809. case wxcard.FieldEmail:
  49810. m.ClearEmail()
  49811. return nil
  49812. case wxcard.FieldAPIBase:
  49813. m.ClearAPIBase()
  49814. return nil
  49815. case wxcard.FieldAPIKey:
  49816. m.ClearAPIKey()
  49817. return nil
  49818. case wxcard.FieldAiInfo:
  49819. m.ClearAiInfo()
  49820. return nil
  49821. case wxcard.FieldIntro:
  49822. m.ClearIntro()
  49823. return nil
  49824. }
  49825. return fmt.Errorf("unknown WxCard nullable field %s", name)
  49826. }
  49827. // ResetField resets all changes in the mutation for the field with the given name.
  49828. // It returns an error if the field is not defined in the schema.
  49829. func (m *WxCardMutation) ResetField(name string) error {
  49830. switch name {
  49831. case wxcard.FieldCreatedAt:
  49832. m.ResetCreatedAt()
  49833. return nil
  49834. case wxcard.FieldUpdatedAt:
  49835. m.ResetUpdatedAt()
  49836. return nil
  49837. case wxcard.FieldDeletedAt:
  49838. m.ResetDeletedAt()
  49839. return nil
  49840. case wxcard.FieldUserID:
  49841. m.ResetUserID()
  49842. return nil
  49843. case wxcard.FieldWxUserID:
  49844. m.ResetWxUserID()
  49845. return nil
  49846. case wxcard.FieldAvatar:
  49847. m.ResetAvatar()
  49848. return nil
  49849. case wxcard.FieldLogo:
  49850. m.ResetLogo()
  49851. return nil
  49852. case wxcard.FieldName:
  49853. m.ResetName()
  49854. return nil
  49855. case wxcard.FieldCompany:
  49856. m.ResetCompany()
  49857. return nil
  49858. case wxcard.FieldAddress:
  49859. m.ResetAddress()
  49860. return nil
  49861. case wxcard.FieldPhone:
  49862. m.ResetPhone()
  49863. return nil
  49864. case wxcard.FieldOfficialAccount:
  49865. m.ResetOfficialAccount()
  49866. return nil
  49867. case wxcard.FieldWechatAccount:
  49868. m.ResetWechatAccount()
  49869. return nil
  49870. case wxcard.FieldEmail:
  49871. m.ResetEmail()
  49872. return nil
  49873. case wxcard.FieldAPIBase:
  49874. m.ResetAPIBase()
  49875. return nil
  49876. case wxcard.FieldAPIKey:
  49877. m.ResetAPIKey()
  49878. return nil
  49879. case wxcard.FieldAiInfo:
  49880. m.ResetAiInfo()
  49881. return nil
  49882. case wxcard.FieldIntro:
  49883. m.ResetIntro()
  49884. return nil
  49885. }
  49886. return fmt.Errorf("unknown WxCard field %s", name)
  49887. }
  49888. // AddedEdges returns all edge names that were set/added in this mutation.
  49889. func (m *WxCardMutation) AddedEdges() []string {
  49890. edges := make([]string, 0, 0)
  49891. return edges
  49892. }
  49893. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  49894. // name in this mutation.
  49895. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  49896. return nil
  49897. }
  49898. // RemovedEdges returns all edge names that were removed in this mutation.
  49899. func (m *WxCardMutation) RemovedEdges() []string {
  49900. edges := make([]string, 0, 0)
  49901. return edges
  49902. }
  49903. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  49904. // the given name in this mutation.
  49905. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  49906. return nil
  49907. }
  49908. // ClearedEdges returns all edge names that were cleared in this mutation.
  49909. func (m *WxCardMutation) ClearedEdges() []string {
  49910. edges := make([]string, 0, 0)
  49911. return edges
  49912. }
  49913. // EdgeCleared returns a boolean which indicates if the edge with the given name
  49914. // was cleared in this mutation.
  49915. func (m *WxCardMutation) EdgeCleared(name string) bool {
  49916. return false
  49917. }
  49918. // ClearEdge clears the value of the edge with the given name. It returns an error
  49919. // if that edge is not defined in the schema.
  49920. func (m *WxCardMutation) ClearEdge(name string) error {
  49921. return fmt.Errorf("unknown WxCard unique edge %s", name)
  49922. }
  49923. // ResetEdge resets all changes to the edge with the given name in this mutation.
  49924. // It returns an error if the edge is not defined in the schema.
  49925. func (m *WxCardMutation) ResetEdge(name string) error {
  49926. return fmt.Errorf("unknown WxCard edge %s", name)
  49927. }
  49928. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  49929. type WxCardUserMutation struct {
  49930. config
  49931. op Op
  49932. typ string
  49933. id *uint64
  49934. created_at *time.Time
  49935. updated_at *time.Time
  49936. deleted_at *time.Time
  49937. wxid *string
  49938. account *string
  49939. avatar *string
  49940. nickname *string
  49941. remark *string
  49942. phone *string
  49943. open_id *string
  49944. union_id *string
  49945. session_key *string
  49946. is_vip *int
  49947. addis_vip *int
  49948. clearedFields map[string]struct{}
  49949. done bool
  49950. oldValue func(context.Context) (*WxCardUser, error)
  49951. predicates []predicate.WxCardUser
  49952. }
  49953. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  49954. // wxcarduserOption allows management of the mutation configuration using functional options.
  49955. type wxcarduserOption func(*WxCardUserMutation)
  49956. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  49957. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  49958. m := &WxCardUserMutation{
  49959. config: c,
  49960. op: op,
  49961. typ: TypeWxCardUser,
  49962. clearedFields: make(map[string]struct{}),
  49963. }
  49964. for _, opt := range opts {
  49965. opt(m)
  49966. }
  49967. return m
  49968. }
  49969. // withWxCardUserID sets the ID field of the mutation.
  49970. func withWxCardUserID(id uint64) wxcarduserOption {
  49971. return func(m *WxCardUserMutation) {
  49972. var (
  49973. err error
  49974. once sync.Once
  49975. value *WxCardUser
  49976. )
  49977. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  49978. once.Do(func() {
  49979. if m.done {
  49980. err = errors.New("querying old values post mutation is not allowed")
  49981. } else {
  49982. value, err = m.Client().WxCardUser.Get(ctx, id)
  49983. }
  49984. })
  49985. return value, err
  49986. }
  49987. m.id = &id
  49988. }
  49989. }
  49990. // withWxCardUser sets the old WxCardUser of the mutation.
  49991. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  49992. return func(m *WxCardUserMutation) {
  49993. m.oldValue = func(context.Context) (*WxCardUser, error) {
  49994. return node, nil
  49995. }
  49996. m.id = &node.ID
  49997. }
  49998. }
  49999. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50000. // executed in a transaction (ent.Tx), a transactional client is returned.
  50001. func (m WxCardUserMutation) Client() *Client {
  50002. client := &Client{config: m.config}
  50003. client.init()
  50004. return client
  50005. }
  50006. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50007. // it returns an error otherwise.
  50008. func (m WxCardUserMutation) Tx() (*Tx, error) {
  50009. if _, ok := m.driver.(*txDriver); !ok {
  50010. return nil, errors.New("ent: mutation is not running in a transaction")
  50011. }
  50012. tx := &Tx{config: m.config}
  50013. tx.init()
  50014. return tx, nil
  50015. }
  50016. // SetID sets the value of the id field. Note that this
  50017. // operation is only accepted on creation of WxCardUser entities.
  50018. func (m *WxCardUserMutation) SetID(id uint64) {
  50019. m.id = &id
  50020. }
  50021. // ID returns the ID value in the mutation. Note that the ID is only available
  50022. // if it was provided to the builder or after it was returned from the database.
  50023. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  50024. if m.id == nil {
  50025. return
  50026. }
  50027. return *m.id, true
  50028. }
  50029. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50030. // That means, if the mutation is applied within a transaction with an isolation level such
  50031. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50032. // or updated by the mutation.
  50033. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  50034. switch {
  50035. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50036. id, exists := m.ID()
  50037. if exists {
  50038. return []uint64{id}, nil
  50039. }
  50040. fallthrough
  50041. case m.op.Is(OpUpdate | OpDelete):
  50042. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  50043. default:
  50044. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50045. }
  50046. }
  50047. // SetCreatedAt sets the "created_at" field.
  50048. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  50049. m.created_at = &t
  50050. }
  50051. // CreatedAt returns the value of the "created_at" field in the mutation.
  50052. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  50053. v := m.created_at
  50054. if v == nil {
  50055. return
  50056. }
  50057. return *v, true
  50058. }
  50059. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  50060. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50062. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  50063. if !m.op.Is(OpUpdateOne) {
  50064. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  50065. }
  50066. if m.id == nil || m.oldValue == nil {
  50067. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  50068. }
  50069. oldValue, err := m.oldValue(ctx)
  50070. if err != nil {
  50071. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  50072. }
  50073. return oldValue.CreatedAt, nil
  50074. }
  50075. // ResetCreatedAt resets all changes to the "created_at" field.
  50076. func (m *WxCardUserMutation) ResetCreatedAt() {
  50077. m.created_at = nil
  50078. }
  50079. // SetUpdatedAt sets the "updated_at" field.
  50080. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  50081. m.updated_at = &t
  50082. }
  50083. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  50084. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  50085. v := m.updated_at
  50086. if v == nil {
  50087. return
  50088. }
  50089. return *v, true
  50090. }
  50091. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  50092. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50094. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  50095. if !m.op.Is(OpUpdateOne) {
  50096. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  50097. }
  50098. if m.id == nil || m.oldValue == nil {
  50099. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  50100. }
  50101. oldValue, err := m.oldValue(ctx)
  50102. if err != nil {
  50103. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  50104. }
  50105. return oldValue.UpdatedAt, nil
  50106. }
  50107. // ResetUpdatedAt resets all changes to the "updated_at" field.
  50108. func (m *WxCardUserMutation) ResetUpdatedAt() {
  50109. m.updated_at = nil
  50110. }
  50111. // SetDeletedAt sets the "deleted_at" field.
  50112. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  50113. m.deleted_at = &t
  50114. }
  50115. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  50116. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  50117. v := m.deleted_at
  50118. if v == nil {
  50119. return
  50120. }
  50121. return *v, true
  50122. }
  50123. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  50124. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50126. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  50127. if !m.op.Is(OpUpdateOne) {
  50128. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  50129. }
  50130. if m.id == nil || m.oldValue == nil {
  50131. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  50132. }
  50133. oldValue, err := m.oldValue(ctx)
  50134. if err != nil {
  50135. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  50136. }
  50137. return oldValue.DeletedAt, nil
  50138. }
  50139. // ClearDeletedAt clears the value of the "deleted_at" field.
  50140. func (m *WxCardUserMutation) ClearDeletedAt() {
  50141. m.deleted_at = nil
  50142. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  50143. }
  50144. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  50145. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  50146. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  50147. return ok
  50148. }
  50149. // ResetDeletedAt resets all changes to the "deleted_at" field.
  50150. func (m *WxCardUserMutation) ResetDeletedAt() {
  50151. m.deleted_at = nil
  50152. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  50153. }
  50154. // SetWxid sets the "wxid" field.
  50155. func (m *WxCardUserMutation) SetWxid(s string) {
  50156. m.wxid = &s
  50157. }
  50158. // Wxid returns the value of the "wxid" field in the mutation.
  50159. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  50160. v := m.wxid
  50161. if v == nil {
  50162. return
  50163. }
  50164. return *v, true
  50165. }
  50166. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  50167. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50169. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  50170. if !m.op.Is(OpUpdateOne) {
  50171. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  50172. }
  50173. if m.id == nil || m.oldValue == nil {
  50174. return v, errors.New("OldWxid requires an ID field in the mutation")
  50175. }
  50176. oldValue, err := m.oldValue(ctx)
  50177. if err != nil {
  50178. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  50179. }
  50180. return oldValue.Wxid, nil
  50181. }
  50182. // ResetWxid resets all changes to the "wxid" field.
  50183. func (m *WxCardUserMutation) ResetWxid() {
  50184. m.wxid = nil
  50185. }
  50186. // SetAccount sets the "account" field.
  50187. func (m *WxCardUserMutation) SetAccount(s string) {
  50188. m.account = &s
  50189. }
  50190. // Account returns the value of the "account" field in the mutation.
  50191. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  50192. v := m.account
  50193. if v == nil {
  50194. return
  50195. }
  50196. return *v, true
  50197. }
  50198. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  50199. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50201. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  50202. if !m.op.Is(OpUpdateOne) {
  50203. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  50204. }
  50205. if m.id == nil || m.oldValue == nil {
  50206. return v, errors.New("OldAccount requires an ID field in the mutation")
  50207. }
  50208. oldValue, err := m.oldValue(ctx)
  50209. if err != nil {
  50210. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  50211. }
  50212. return oldValue.Account, nil
  50213. }
  50214. // ResetAccount resets all changes to the "account" field.
  50215. func (m *WxCardUserMutation) ResetAccount() {
  50216. m.account = nil
  50217. }
  50218. // SetAvatar sets the "avatar" field.
  50219. func (m *WxCardUserMutation) SetAvatar(s string) {
  50220. m.avatar = &s
  50221. }
  50222. // Avatar returns the value of the "avatar" field in the mutation.
  50223. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  50224. v := m.avatar
  50225. if v == nil {
  50226. return
  50227. }
  50228. return *v, true
  50229. }
  50230. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  50231. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50233. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  50234. if !m.op.Is(OpUpdateOne) {
  50235. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  50236. }
  50237. if m.id == nil || m.oldValue == nil {
  50238. return v, errors.New("OldAvatar requires an ID field in the mutation")
  50239. }
  50240. oldValue, err := m.oldValue(ctx)
  50241. if err != nil {
  50242. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  50243. }
  50244. return oldValue.Avatar, nil
  50245. }
  50246. // ResetAvatar resets all changes to the "avatar" field.
  50247. func (m *WxCardUserMutation) ResetAvatar() {
  50248. m.avatar = nil
  50249. }
  50250. // SetNickname sets the "nickname" field.
  50251. func (m *WxCardUserMutation) SetNickname(s string) {
  50252. m.nickname = &s
  50253. }
  50254. // Nickname returns the value of the "nickname" field in the mutation.
  50255. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  50256. v := m.nickname
  50257. if v == nil {
  50258. return
  50259. }
  50260. return *v, true
  50261. }
  50262. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  50263. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50265. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  50266. if !m.op.Is(OpUpdateOne) {
  50267. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  50268. }
  50269. if m.id == nil || m.oldValue == nil {
  50270. return v, errors.New("OldNickname requires an ID field in the mutation")
  50271. }
  50272. oldValue, err := m.oldValue(ctx)
  50273. if err != nil {
  50274. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  50275. }
  50276. return oldValue.Nickname, nil
  50277. }
  50278. // ResetNickname resets all changes to the "nickname" field.
  50279. func (m *WxCardUserMutation) ResetNickname() {
  50280. m.nickname = nil
  50281. }
  50282. // SetRemark sets the "remark" field.
  50283. func (m *WxCardUserMutation) SetRemark(s string) {
  50284. m.remark = &s
  50285. }
  50286. // Remark returns the value of the "remark" field in the mutation.
  50287. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  50288. v := m.remark
  50289. if v == nil {
  50290. return
  50291. }
  50292. return *v, true
  50293. }
  50294. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  50295. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50297. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  50298. if !m.op.Is(OpUpdateOne) {
  50299. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  50300. }
  50301. if m.id == nil || m.oldValue == nil {
  50302. return v, errors.New("OldRemark requires an ID field in the mutation")
  50303. }
  50304. oldValue, err := m.oldValue(ctx)
  50305. if err != nil {
  50306. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  50307. }
  50308. return oldValue.Remark, nil
  50309. }
  50310. // ResetRemark resets all changes to the "remark" field.
  50311. func (m *WxCardUserMutation) ResetRemark() {
  50312. m.remark = nil
  50313. }
  50314. // SetPhone sets the "phone" field.
  50315. func (m *WxCardUserMutation) SetPhone(s string) {
  50316. m.phone = &s
  50317. }
  50318. // Phone returns the value of the "phone" field in the mutation.
  50319. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  50320. v := m.phone
  50321. if v == nil {
  50322. return
  50323. }
  50324. return *v, true
  50325. }
  50326. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  50327. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50329. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  50330. if !m.op.Is(OpUpdateOne) {
  50331. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  50332. }
  50333. if m.id == nil || m.oldValue == nil {
  50334. return v, errors.New("OldPhone requires an ID field in the mutation")
  50335. }
  50336. oldValue, err := m.oldValue(ctx)
  50337. if err != nil {
  50338. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  50339. }
  50340. return oldValue.Phone, nil
  50341. }
  50342. // ResetPhone resets all changes to the "phone" field.
  50343. func (m *WxCardUserMutation) ResetPhone() {
  50344. m.phone = nil
  50345. }
  50346. // SetOpenID sets the "open_id" field.
  50347. func (m *WxCardUserMutation) SetOpenID(s string) {
  50348. m.open_id = &s
  50349. }
  50350. // OpenID returns the value of the "open_id" field in the mutation.
  50351. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  50352. v := m.open_id
  50353. if v == nil {
  50354. return
  50355. }
  50356. return *v, true
  50357. }
  50358. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  50359. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50361. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  50362. if !m.op.Is(OpUpdateOne) {
  50363. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  50364. }
  50365. if m.id == nil || m.oldValue == nil {
  50366. return v, errors.New("OldOpenID requires an ID field in the mutation")
  50367. }
  50368. oldValue, err := m.oldValue(ctx)
  50369. if err != nil {
  50370. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  50371. }
  50372. return oldValue.OpenID, nil
  50373. }
  50374. // ResetOpenID resets all changes to the "open_id" field.
  50375. func (m *WxCardUserMutation) ResetOpenID() {
  50376. m.open_id = nil
  50377. }
  50378. // SetUnionID sets the "union_id" field.
  50379. func (m *WxCardUserMutation) SetUnionID(s string) {
  50380. m.union_id = &s
  50381. }
  50382. // UnionID returns the value of the "union_id" field in the mutation.
  50383. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  50384. v := m.union_id
  50385. if v == nil {
  50386. return
  50387. }
  50388. return *v, true
  50389. }
  50390. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  50391. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50393. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  50394. if !m.op.Is(OpUpdateOne) {
  50395. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  50396. }
  50397. if m.id == nil || m.oldValue == nil {
  50398. return v, errors.New("OldUnionID requires an ID field in the mutation")
  50399. }
  50400. oldValue, err := m.oldValue(ctx)
  50401. if err != nil {
  50402. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  50403. }
  50404. return oldValue.UnionID, nil
  50405. }
  50406. // ResetUnionID resets all changes to the "union_id" field.
  50407. func (m *WxCardUserMutation) ResetUnionID() {
  50408. m.union_id = nil
  50409. }
  50410. // SetSessionKey sets the "session_key" field.
  50411. func (m *WxCardUserMutation) SetSessionKey(s string) {
  50412. m.session_key = &s
  50413. }
  50414. // SessionKey returns the value of the "session_key" field in the mutation.
  50415. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  50416. v := m.session_key
  50417. if v == nil {
  50418. return
  50419. }
  50420. return *v, true
  50421. }
  50422. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  50423. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50425. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  50426. if !m.op.Is(OpUpdateOne) {
  50427. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  50428. }
  50429. if m.id == nil || m.oldValue == nil {
  50430. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  50431. }
  50432. oldValue, err := m.oldValue(ctx)
  50433. if err != nil {
  50434. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  50435. }
  50436. return oldValue.SessionKey, nil
  50437. }
  50438. // ResetSessionKey resets all changes to the "session_key" field.
  50439. func (m *WxCardUserMutation) ResetSessionKey() {
  50440. m.session_key = nil
  50441. }
  50442. // SetIsVip sets the "is_vip" field.
  50443. func (m *WxCardUserMutation) SetIsVip(i int) {
  50444. m.is_vip = &i
  50445. m.addis_vip = nil
  50446. }
  50447. // IsVip returns the value of the "is_vip" field in the mutation.
  50448. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  50449. v := m.is_vip
  50450. if v == nil {
  50451. return
  50452. }
  50453. return *v, true
  50454. }
  50455. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  50456. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  50457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  50458. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  50459. if !m.op.Is(OpUpdateOne) {
  50460. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  50461. }
  50462. if m.id == nil || m.oldValue == nil {
  50463. return v, errors.New("OldIsVip requires an ID field in the mutation")
  50464. }
  50465. oldValue, err := m.oldValue(ctx)
  50466. if err != nil {
  50467. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  50468. }
  50469. return oldValue.IsVip, nil
  50470. }
  50471. // AddIsVip adds i to the "is_vip" field.
  50472. func (m *WxCardUserMutation) AddIsVip(i int) {
  50473. if m.addis_vip != nil {
  50474. *m.addis_vip += i
  50475. } else {
  50476. m.addis_vip = &i
  50477. }
  50478. }
  50479. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  50480. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  50481. v := m.addis_vip
  50482. if v == nil {
  50483. return
  50484. }
  50485. return *v, true
  50486. }
  50487. // ResetIsVip resets all changes to the "is_vip" field.
  50488. func (m *WxCardUserMutation) ResetIsVip() {
  50489. m.is_vip = nil
  50490. m.addis_vip = nil
  50491. }
  50492. // Where appends a list predicates to the WxCardUserMutation builder.
  50493. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  50494. m.predicates = append(m.predicates, ps...)
  50495. }
  50496. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  50497. // users can use type-assertion to append predicates that do not depend on any generated package.
  50498. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  50499. p := make([]predicate.WxCardUser, len(ps))
  50500. for i := range ps {
  50501. p[i] = ps[i]
  50502. }
  50503. m.Where(p...)
  50504. }
  50505. // Op returns the operation name.
  50506. func (m *WxCardUserMutation) Op() Op {
  50507. return m.op
  50508. }
  50509. // SetOp allows setting the mutation operation.
  50510. func (m *WxCardUserMutation) SetOp(op Op) {
  50511. m.op = op
  50512. }
  50513. // Type returns the node type of this mutation (WxCardUser).
  50514. func (m *WxCardUserMutation) Type() string {
  50515. return m.typ
  50516. }
  50517. // Fields returns all fields that were changed during this mutation. Note that in
  50518. // order to get all numeric fields that were incremented/decremented, call
  50519. // AddedFields().
  50520. func (m *WxCardUserMutation) Fields() []string {
  50521. fields := make([]string, 0, 13)
  50522. if m.created_at != nil {
  50523. fields = append(fields, wxcarduser.FieldCreatedAt)
  50524. }
  50525. if m.updated_at != nil {
  50526. fields = append(fields, wxcarduser.FieldUpdatedAt)
  50527. }
  50528. if m.deleted_at != nil {
  50529. fields = append(fields, wxcarduser.FieldDeletedAt)
  50530. }
  50531. if m.wxid != nil {
  50532. fields = append(fields, wxcarduser.FieldWxid)
  50533. }
  50534. if m.account != nil {
  50535. fields = append(fields, wxcarduser.FieldAccount)
  50536. }
  50537. if m.avatar != nil {
  50538. fields = append(fields, wxcarduser.FieldAvatar)
  50539. }
  50540. if m.nickname != nil {
  50541. fields = append(fields, wxcarduser.FieldNickname)
  50542. }
  50543. if m.remark != nil {
  50544. fields = append(fields, wxcarduser.FieldRemark)
  50545. }
  50546. if m.phone != nil {
  50547. fields = append(fields, wxcarduser.FieldPhone)
  50548. }
  50549. if m.open_id != nil {
  50550. fields = append(fields, wxcarduser.FieldOpenID)
  50551. }
  50552. if m.union_id != nil {
  50553. fields = append(fields, wxcarduser.FieldUnionID)
  50554. }
  50555. if m.session_key != nil {
  50556. fields = append(fields, wxcarduser.FieldSessionKey)
  50557. }
  50558. if m.is_vip != nil {
  50559. fields = append(fields, wxcarduser.FieldIsVip)
  50560. }
  50561. return fields
  50562. }
  50563. // Field returns the value of a field with the given name. The second boolean
  50564. // return value indicates that this field was not set, or was not defined in the
  50565. // schema.
  50566. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  50567. switch name {
  50568. case wxcarduser.FieldCreatedAt:
  50569. return m.CreatedAt()
  50570. case wxcarduser.FieldUpdatedAt:
  50571. return m.UpdatedAt()
  50572. case wxcarduser.FieldDeletedAt:
  50573. return m.DeletedAt()
  50574. case wxcarduser.FieldWxid:
  50575. return m.Wxid()
  50576. case wxcarduser.FieldAccount:
  50577. return m.Account()
  50578. case wxcarduser.FieldAvatar:
  50579. return m.Avatar()
  50580. case wxcarduser.FieldNickname:
  50581. return m.Nickname()
  50582. case wxcarduser.FieldRemark:
  50583. return m.Remark()
  50584. case wxcarduser.FieldPhone:
  50585. return m.Phone()
  50586. case wxcarduser.FieldOpenID:
  50587. return m.OpenID()
  50588. case wxcarduser.FieldUnionID:
  50589. return m.UnionID()
  50590. case wxcarduser.FieldSessionKey:
  50591. return m.SessionKey()
  50592. case wxcarduser.FieldIsVip:
  50593. return m.IsVip()
  50594. }
  50595. return nil, false
  50596. }
  50597. // OldField returns the old value of the field from the database. An error is
  50598. // returned if the mutation operation is not UpdateOne, or the query to the
  50599. // database failed.
  50600. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  50601. switch name {
  50602. case wxcarduser.FieldCreatedAt:
  50603. return m.OldCreatedAt(ctx)
  50604. case wxcarduser.FieldUpdatedAt:
  50605. return m.OldUpdatedAt(ctx)
  50606. case wxcarduser.FieldDeletedAt:
  50607. return m.OldDeletedAt(ctx)
  50608. case wxcarduser.FieldWxid:
  50609. return m.OldWxid(ctx)
  50610. case wxcarduser.FieldAccount:
  50611. return m.OldAccount(ctx)
  50612. case wxcarduser.FieldAvatar:
  50613. return m.OldAvatar(ctx)
  50614. case wxcarduser.FieldNickname:
  50615. return m.OldNickname(ctx)
  50616. case wxcarduser.FieldRemark:
  50617. return m.OldRemark(ctx)
  50618. case wxcarduser.FieldPhone:
  50619. return m.OldPhone(ctx)
  50620. case wxcarduser.FieldOpenID:
  50621. return m.OldOpenID(ctx)
  50622. case wxcarduser.FieldUnionID:
  50623. return m.OldUnionID(ctx)
  50624. case wxcarduser.FieldSessionKey:
  50625. return m.OldSessionKey(ctx)
  50626. case wxcarduser.FieldIsVip:
  50627. return m.OldIsVip(ctx)
  50628. }
  50629. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  50630. }
  50631. // SetField sets the value of a field with the given name. It returns an error if
  50632. // the field is not defined in the schema, or if the type mismatched the field
  50633. // type.
  50634. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  50635. switch name {
  50636. case wxcarduser.FieldCreatedAt:
  50637. v, ok := value.(time.Time)
  50638. if !ok {
  50639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50640. }
  50641. m.SetCreatedAt(v)
  50642. return nil
  50643. case wxcarduser.FieldUpdatedAt:
  50644. v, ok := value.(time.Time)
  50645. if !ok {
  50646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50647. }
  50648. m.SetUpdatedAt(v)
  50649. return nil
  50650. case wxcarduser.FieldDeletedAt:
  50651. v, ok := value.(time.Time)
  50652. if !ok {
  50653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50654. }
  50655. m.SetDeletedAt(v)
  50656. return nil
  50657. case wxcarduser.FieldWxid:
  50658. v, ok := value.(string)
  50659. if !ok {
  50660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50661. }
  50662. m.SetWxid(v)
  50663. return nil
  50664. case wxcarduser.FieldAccount:
  50665. v, ok := value.(string)
  50666. if !ok {
  50667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50668. }
  50669. m.SetAccount(v)
  50670. return nil
  50671. case wxcarduser.FieldAvatar:
  50672. v, ok := value.(string)
  50673. if !ok {
  50674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50675. }
  50676. m.SetAvatar(v)
  50677. return nil
  50678. case wxcarduser.FieldNickname:
  50679. v, ok := value.(string)
  50680. if !ok {
  50681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50682. }
  50683. m.SetNickname(v)
  50684. return nil
  50685. case wxcarduser.FieldRemark:
  50686. v, ok := value.(string)
  50687. if !ok {
  50688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50689. }
  50690. m.SetRemark(v)
  50691. return nil
  50692. case wxcarduser.FieldPhone:
  50693. v, ok := value.(string)
  50694. if !ok {
  50695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50696. }
  50697. m.SetPhone(v)
  50698. return nil
  50699. case wxcarduser.FieldOpenID:
  50700. v, ok := value.(string)
  50701. if !ok {
  50702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50703. }
  50704. m.SetOpenID(v)
  50705. return nil
  50706. case wxcarduser.FieldUnionID:
  50707. v, ok := value.(string)
  50708. if !ok {
  50709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50710. }
  50711. m.SetUnionID(v)
  50712. return nil
  50713. case wxcarduser.FieldSessionKey:
  50714. v, ok := value.(string)
  50715. if !ok {
  50716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50717. }
  50718. m.SetSessionKey(v)
  50719. return nil
  50720. case wxcarduser.FieldIsVip:
  50721. v, ok := value.(int)
  50722. if !ok {
  50723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50724. }
  50725. m.SetIsVip(v)
  50726. return nil
  50727. }
  50728. return fmt.Errorf("unknown WxCardUser field %s", name)
  50729. }
  50730. // AddedFields returns all numeric fields that were incremented/decremented during
  50731. // this mutation.
  50732. func (m *WxCardUserMutation) AddedFields() []string {
  50733. var fields []string
  50734. if m.addis_vip != nil {
  50735. fields = append(fields, wxcarduser.FieldIsVip)
  50736. }
  50737. return fields
  50738. }
  50739. // AddedField returns the numeric value that was incremented/decremented on a field
  50740. // with the given name. The second boolean return value indicates that this field
  50741. // was not set, or was not defined in the schema.
  50742. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  50743. switch name {
  50744. case wxcarduser.FieldIsVip:
  50745. return m.AddedIsVip()
  50746. }
  50747. return nil, false
  50748. }
  50749. // AddField adds the value to the field with the given name. It returns an error if
  50750. // the field is not defined in the schema, or if the type mismatched the field
  50751. // type.
  50752. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  50753. switch name {
  50754. case wxcarduser.FieldIsVip:
  50755. v, ok := value.(int)
  50756. if !ok {
  50757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  50758. }
  50759. m.AddIsVip(v)
  50760. return nil
  50761. }
  50762. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  50763. }
  50764. // ClearedFields returns all nullable fields that were cleared during this
  50765. // mutation.
  50766. func (m *WxCardUserMutation) ClearedFields() []string {
  50767. var fields []string
  50768. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  50769. fields = append(fields, wxcarduser.FieldDeletedAt)
  50770. }
  50771. return fields
  50772. }
  50773. // FieldCleared returns a boolean indicating if a field with the given name was
  50774. // cleared in this mutation.
  50775. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  50776. _, ok := m.clearedFields[name]
  50777. return ok
  50778. }
  50779. // ClearField clears the value of the field with the given name. It returns an
  50780. // error if the field is not defined in the schema.
  50781. func (m *WxCardUserMutation) ClearField(name string) error {
  50782. switch name {
  50783. case wxcarduser.FieldDeletedAt:
  50784. m.ClearDeletedAt()
  50785. return nil
  50786. }
  50787. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  50788. }
  50789. // ResetField resets all changes in the mutation for the field with the given name.
  50790. // It returns an error if the field is not defined in the schema.
  50791. func (m *WxCardUserMutation) ResetField(name string) error {
  50792. switch name {
  50793. case wxcarduser.FieldCreatedAt:
  50794. m.ResetCreatedAt()
  50795. return nil
  50796. case wxcarduser.FieldUpdatedAt:
  50797. m.ResetUpdatedAt()
  50798. return nil
  50799. case wxcarduser.FieldDeletedAt:
  50800. m.ResetDeletedAt()
  50801. return nil
  50802. case wxcarduser.FieldWxid:
  50803. m.ResetWxid()
  50804. return nil
  50805. case wxcarduser.FieldAccount:
  50806. m.ResetAccount()
  50807. return nil
  50808. case wxcarduser.FieldAvatar:
  50809. m.ResetAvatar()
  50810. return nil
  50811. case wxcarduser.FieldNickname:
  50812. m.ResetNickname()
  50813. return nil
  50814. case wxcarduser.FieldRemark:
  50815. m.ResetRemark()
  50816. return nil
  50817. case wxcarduser.FieldPhone:
  50818. m.ResetPhone()
  50819. return nil
  50820. case wxcarduser.FieldOpenID:
  50821. m.ResetOpenID()
  50822. return nil
  50823. case wxcarduser.FieldUnionID:
  50824. m.ResetUnionID()
  50825. return nil
  50826. case wxcarduser.FieldSessionKey:
  50827. m.ResetSessionKey()
  50828. return nil
  50829. case wxcarduser.FieldIsVip:
  50830. m.ResetIsVip()
  50831. return nil
  50832. }
  50833. return fmt.Errorf("unknown WxCardUser field %s", name)
  50834. }
  50835. // AddedEdges returns all edge names that were set/added in this mutation.
  50836. func (m *WxCardUserMutation) AddedEdges() []string {
  50837. edges := make([]string, 0, 0)
  50838. return edges
  50839. }
  50840. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  50841. // name in this mutation.
  50842. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  50843. return nil
  50844. }
  50845. // RemovedEdges returns all edge names that were removed in this mutation.
  50846. func (m *WxCardUserMutation) RemovedEdges() []string {
  50847. edges := make([]string, 0, 0)
  50848. return edges
  50849. }
  50850. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  50851. // the given name in this mutation.
  50852. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  50853. return nil
  50854. }
  50855. // ClearedEdges returns all edge names that were cleared in this mutation.
  50856. func (m *WxCardUserMutation) ClearedEdges() []string {
  50857. edges := make([]string, 0, 0)
  50858. return edges
  50859. }
  50860. // EdgeCleared returns a boolean which indicates if the edge with the given name
  50861. // was cleared in this mutation.
  50862. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  50863. return false
  50864. }
  50865. // ClearEdge clears the value of the edge with the given name. It returns an error
  50866. // if that edge is not defined in the schema.
  50867. func (m *WxCardUserMutation) ClearEdge(name string) error {
  50868. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  50869. }
  50870. // ResetEdge resets all changes to the edge with the given name in this mutation.
  50871. // It returns an error if the edge is not defined in the schema.
  50872. func (m *WxCardUserMutation) ResetEdge(name string) error {
  50873. return fmt.Errorf("unknown WxCardUser edge %s", name)
  50874. }
  50875. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  50876. type WxCardVisitMutation struct {
  50877. config
  50878. op Op
  50879. typ string
  50880. id *uint64
  50881. created_at *time.Time
  50882. updated_at *time.Time
  50883. deleted_at *time.Time
  50884. user_id *uint64
  50885. adduser_id *int64
  50886. bot_id *uint64
  50887. addbot_id *int64
  50888. bot_type *uint8
  50889. addbot_type *int8
  50890. clearedFields map[string]struct{}
  50891. done bool
  50892. oldValue func(context.Context) (*WxCardVisit, error)
  50893. predicates []predicate.WxCardVisit
  50894. }
  50895. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  50896. // wxcardvisitOption allows management of the mutation configuration using functional options.
  50897. type wxcardvisitOption func(*WxCardVisitMutation)
  50898. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  50899. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  50900. m := &WxCardVisitMutation{
  50901. config: c,
  50902. op: op,
  50903. typ: TypeWxCardVisit,
  50904. clearedFields: make(map[string]struct{}),
  50905. }
  50906. for _, opt := range opts {
  50907. opt(m)
  50908. }
  50909. return m
  50910. }
  50911. // withWxCardVisitID sets the ID field of the mutation.
  50912. func withWxCardVisitID(id uint64) wxcardvisitOption {
  50913. return func(m *WxCardVisitMutation) {
  50914. var (
  50915. err error
  50916. once sync.Once
  50917. value *WxCardVisit
  50918. )
  50919. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  50920. once.Do(func() {
  50921. if m.done {
  50922. err = errors.New("querying old values post mutation is not allowed")
  50923. } else {
  50924. value, err = m.Client().WxCardVisit.Get(ctx, id)
  50925. }
  50926. })
  50927. return value, err
  50928. }
  50929. m.id = &id
  50930. }
  50931. }
  50932. // withWxCardVisit sets the old WxCardVisit of the mutation.
  50933. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  50934. return func(m *WxCardVisitMutation) {
  50935. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  50936. return node, nil
  50937. }
  50938. m.id = &node.ID
  50939. }
  50940. }
  50941. // Client returns a new `ent.Client` from the mutation. If the mutation was
  50942. // executed in a transaction (ent.Tx), a transactional client is returned.
  50943. func (m WxCardVisitMutation) Client() *Client {
  50944. client := &Client{config: m.config}
  50945. client.init()
  50946. return client
  50947. }
  50948. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  50949. // it returns an error otherwise.
  50950. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  50951. if _, ok := m.driver.(*txDriver); !ok {
  50952. return nil, errors.New("ent: mutation is not running in a transaction")
  50953. }
  50954. tx := &Tx{config: m.config}
  50955. tx.init()
  50956. return tx, nil
  50957. }
  50958. // SetID sets the value of the id field. Note that this
  50959. // operation is only accepted on creation of WxCardVisit entities.
  50960. func (m *WxCardVisitMutation) SetID(id uint64) {
  50961. m.id = &id
  50962. }
  50963. // ID returns the ID value in the mutation. Note that the ID is only available
  50964. // if it was provided to the builder or after it was returned from the database.
  50965. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  50966. if m.id == nil {
  50967. return
  50968. }
  50969. return *m.id, true
  50970. }
  50971. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  50972. // That means, if the mutation is applied within a transaction with an isolation level such
  50973. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  50974. // or updated by the mutation.
  50975. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  50976. switch {
  50977. case m.op.Is(OpUpdateOne | OpDeleteOne):
  50978. id, exists := m.ID()
  50979. if exists {
  50980. return []uint64{id}, nil
  50981. }
  50982. fallthrough
  50983. case m.op.Is(OpUpdate | OpDelete):
  50984. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  50985. default:
  50986. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  50987. }
  50988. }
  50989. // SetCreatedAt sets the "created_at" field.
  50990. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  50991. m.created_at = &t
  50992. }
  50993. // CreatedAt returns the value of the "created_at" field in the mutation.
  50994. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  50995. v := m.created_at
  50996. if v == nil {
  50997. return
  50998. }
  50999. return *v, true
  51000. }
  51001. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  51002. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51004. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51005. if !m.op.Is(OpUpdateOne) {
  51006. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51007. }
  51008. if m.id == nil || m.oldValue == nil {
  51009. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51010. }
  51011. oldValue, err := m.oldValue(ctx)
  51012. if err != nil {
  51013. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51014. }
  51015. return oldValue.CreatedAt, nil
  51016. }
  51017. // ResetCreatedAt resets all changes to the "created_at" field.
  51018. func (m *WxCardVisitMutation) ResetCreatedAt() {
  51019. m.created_at = nil
  51020. }
  51021. // SetUpdatedAt sets the "updated_at" field.
  51022. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  51023. m.updated_at = &t
  51024. }
  51025. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51026. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  51027. v := m.updated_at
  51028. if v == nil {
  51029. return
  51030. }
  51031. return *v, true
  51032. }
  51033. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  51034. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51036. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51037. if !m.op.Is(OpUpdateOne) {
  51038. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51039. }
  51040. if m.id == nil || m.oldValue == nil {
  51041. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51042. }
  51043. oldValue, err := m.oldValue(ctx)
  51044. if err != nil {
  51045. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51046. }
  51047. return oldValue.UpdatedAt, nil
  51048. }
  51049. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51050. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  51051. m.updated_at = nil
  51052. }
  51053. // SetDeletedAt sets the "deleted_at" field.
  51054. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  51055. m.deleted_at = &t
  51056. }
  51057. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51058. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  51059. v := m.deleted_at
  51060. if v == nil {
  51061. return
  51062. }
  51063. return *v, true
  51064. }
  51065. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  51066. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51068. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51069. if !m.op.Is(OpUpdateOne) {
  51070. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51071. }
  51072. if m.id == nil || m.oldValue == nil {
  51073. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51074. }
  51075. oldValue, err := m.oldValue(ctx)
  51076. if err != nil {
  51077. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51078. }
  51079. return oldValue.DeletedAt, nil
  51080. }
  51081. // ClearDeletedAt clears the value of the "deleted_at" field.
  51082. func (m *WxCardVisitMutation) ClearDeletedAt() {
  51083. m.deleted_at = nil
  51084. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  51085. }
  51086. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51087. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  51088. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  51089. return ok
  51090. }
  51091. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51092. func (m *WxCardVisitMutation) ResetDeletedAt() {
  51093. m.deleted_at = nil
  51094. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  51095. }
  51096. // SetUserID sets the "user_id" field.
  51097. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  51098. m.user_id = &u
  51099. m.adduser_id = nil
  51100. }
  51101. // UserID returns the value of the "user_id" field in the mutation.
  51102. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  51103. v := m.user_id
  51104. if v == nil {
  51105. return
  51106. }
  51107. return *v, true
  51108. }
  51109. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  51110. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51112. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  51113. if !m.op.Is(OpUpdateOne) {
  51114. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  51115. }
  51116. if m.id == nil || m.oldValue == nil {
  51117. return v, errors.New("OldUserID requires an ID field in the mutation")
  51118. }
  51119. oldValue, err := m.oldValue(ctx)
  51120. if err != nil {
  51121. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  51122. }
  51123. return oldValue.UserID, nil
  51124. }
  51125. // AddUserID adds u to the "user_id" field.
  51126. func (m *WxCardVisitMutation) AddUserID(u int64) {
  51127. if m.adduser_id != nil {
  51128. *m.adduser_id += u
  51129. } else {
  51130. m.adduser_id = &u
  51131. }
  51132. }
  51133. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  51134. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  51135. v := m.adduser_id
  51136. if v == nil {
  51137. return
  51138. }
  51139. return *v, true
  51140. }
  51141. // ClearUserID clears the value of the "user_id" field.
  51142. func (m *WxCardVisitMutation) ClearUserID() {
  51143. m.user_id = nil
  51144. m.adduser_id = nil
  51145. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  51146. }
  51147. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  51148. func (m *WxCardVisitMutation) UserIDCleared() bool {
  51149. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  51150. return ok
  51151. }
  51152. // ResetUserID resets all changes to the "user_id" field.
  51153. func (m *WxCardVisitMutation) ResetUserID() {
  51154. m.user_id = nil
  51155. m.adduser_id = nil
  51156. delete(m.clearedFields, wxcardvisit.FieldUserID)
  51157. }
  51158. // SetBotID sets the "bot_id" field.
  51159. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  51160. m.bot_id = &u
  51161. m.addbot_id = nil
  51162. }
  51163. // BotID returns the value of the "bot_id" field in the mutation.
  51164. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  51165. v := m.bot_id
  51166. if v == nil {
  51167. return
  51168. }
  51169. return *v, true
  51170. }
  51171. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  51172. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51174. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  51175. if !m.op.Is(OpUpdateOne) {
  51176. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  51177. }
  51178. if m.id == nil || m.oldValue == nil {
  51179. return v, errors.New("OldBotID requires an ID field in the mutation")
  51180. }
  51181. oldValue, err := m.oldValue(ctx)
  51182. if err != nil {
  51183. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  51184. }
  51185. return oldValue.BotID, nil
  51186. }
  51187. // AddBotID adds u to the "bot_id" field.
  51188. func (m *WxCardVisitMutation) AddBotID(u int64) {
  51189. if m.addbot_id != nil {
  51190. *m.addbot_id += u
  51191. } else {
  51192. m.addbot_id = &u
  51193. }
  51194. }
  51195. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  51196. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  51197. v := m.addbot_id
  51198. if v == nil {
  51199. return
  51200. }
  51201. return *v, true
  51202. }
  51203. // ResetBotID resets all changes to the "bot_id" field.
  51204. func (m *WxCardVisitMutation) ResetBotID() {
  51205. m.bot_id = nil
  51206. m.addbot_id = nil
  51207. }
  51208. // SetBotType sets the "bot_type" field.
  51209. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  51210. m.bot_type = &u
  51211. m.addbot_type = nil
  51212. }
  51213. // BotType returns the value of the "bot_type" field in the mutation.
  51214. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  51215. v := m.bot_type
  51216. if v == nil {
  51217. return
  51218. }
  51219. return *v, true
  51220. }
  51221. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  51222. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  51223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51224. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  51225. if !m.op.Is(OpUpdateOne) {
  51226. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  51227. }
  51228. if m.id == nil || m.oldValue == nil {
  51229. return v, errors.New("OldBotType requires an ID field in the mutation")
  51230. }
  51231. oldValue, err := m.oldValue(ctx)
  51232. if err != nil {
  51233. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  51234. }
  51235. return oldValue.BotType, nil
  51236. }
  51237. // AddBotType adds u to the "bot_type" field.
  51238. func (m *WxCardVisitMutation) AddBotType(u int8) {
  51239. if m.addbot_type != nil {
  51240. *m.addbot_type += u
  51241. } else {
  51242. m.addbot_type = &u
  51243. }
  51244. }
  51245. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  51246. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  51247. v := m.addbot_type
  51248. if v == nil {
  51249. return
  51250. }
  51251. return *v, true
  51252. }
  51253. // ResetBotType resets all changes to the "bot_type" field.
  51254. func (m *WxCardVisitMutation) ResetBotType() {
  51255. m.bot_type = nil
  51256. m.addbot_type = nil
  51257. }
  51258. // Where appends a list predicates to the WxCardVisitMutation builder.
  51259. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  51260. m.predicates = append(m.predicates, ps...)
  51261. }
  51262. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  51263. // users can use type-assertion to append predicates that do not depend on any generated package.
  51264. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  51265. p := make([]predicate.WxCardVisit, len(ps))
  51266. for i := range ps {
  51267. p[i] = ps[i]
  51268. }
  51269. m.Where(p...)
  51270. }
  51271. // Op returns the operation name.
  51272. func (m *WxCardVisitMutation) Op() Op {
  51273. return m.op
  51274. }
  51275. // SetOp allows setting the mutation operation.
  51276. func (m *WxCardVisitMutation) SetOp(op Op) {
  51277. m.op = op
  51278. }
  51279. // Type returns the node type of this mutation (WxCardVisit).
  51280. func (m *WxCardVisitMutation) Type() string {
  51281. return m.typ
  51282. }
  51283. // Fields returns all fields that were changed during this mutation. Note that in
  51284. // order to get all numeric fields that were incremented/decremented, call
  51285. // AddedFields().
  51286. func (m *WxCardVisitMutation) Fields() []string {
  51287. fields := make([]string, 0, 6)
  51288. if m.created_at != nil {
  51289. fields = append(fields, wxcardvisit.FieldCreatedAt)
  51290. }
  51291. if m.updated_at != nil {
  51292. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  51293. }
  51294. if m.deleted_at != nil {
  51295. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51296. }
  51297. if m.user_id != nil {
  51298. fields = append(fields, wxcardvisit.FieldUserID)
  51299. }
  51300. if m.bot_id != nil {
  51301. fields = append(fields, wxcardvisit.FieldBotID)
  51302. }
  51303. if m.bot_type != nil {
  51304. fields = append(fields, wxcardvisit.FieldBotType)
  51305. }
  51306. return fields
  51307. }
  51308. // Field returns the value of a field with the given name. The second boolean
  51309. // return value indicates that this field was not set, or was not defined in the
  51310. // schema.
  51311. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  51312. switch name {
  51313. case wxcardvisit.FieldCreatedAt:
  51314. return m.CreatedAt()
  51315. case wxcardvisit.FieldUpdatedAt:
  51316. return m.UpdatedAt()
  51317. case wxcardvisit.FieldDeletedAt:
  51318. return m.DeletedAt()
  51319. case wxcardvisit.FieldUserID:
  51320. return m.UserID()
  51321. case wxcardvisit.FieldBotID:
  51322. return m.BotID()
  51323. case wxcardvisit.FieldBotType:
  51324. return m.BotType()
  51325. }
  51326. return nil, false
  51327. }
  51328. // OldField returns the old value of the field from the database. An error is
  51329. // returned if the mutation operation is not UpdateOne, or the query to the
  51330. // database failed.
  51331. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  51332. switch name {
  51333. case wxcardvisit.FieldCreatedAt:
  51334. return m.OldCreatedAt(ctx)
  51335. case wxcardvisit.FieldUpdatedAt:
  51336. return m.OldUpdatedAt(ctx)
  51337. case wxcardvisit.FieldDeletedAt:
  51338. return m.OldDeletedAt(ctx)
  51339. case wxcardvisit.FieldUserID:
  51340. return m.OldUserID(ctx)
  51341. case wxcardvisit.FieldBotID:
  51342. return m.OldBotID(ctx)
  51343. case wxcardvisit.FieldBotType:
  51344. return m.OldBotType(ctx)
  51345. }
  51346. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  51347. }
  51348. // SetField sets the value of a field with the given name. It returns an error if
  51349. // the field is not defined in the schema, or if the type mismatched the field
  51350. // type.
  51351. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  51352. switch name {
  51353. case wxcardvisit.FieldCreatedAt:
  51354. v, ok := value.(time.Time)
  51355. if !ok {
  51356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51357. }
  51358. m.SetCreatedAt(v)
  51359. return nil
  51360. case wxcardvisit.FieldUpdatedAt:
  51361. v, ok := value.(time.Time)
  51362. if !ok {
  51363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51364. }
  51365. m.SetUpdatedAt(v)
  51366. return nil
  51367. case wxcardvisit.FieldDeletedAt:
  51368. v, ok := value.(time.Time)
  51369. if !ok {
  51370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51371. }
  51372. m.SetDeletedAt(v)
  51373. return nil
  51374. case wxcardvisit.FieldUserID:
  51375. v, ok := value.(uint64)
  51376. if !ok {
  51377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51378. }
  51379. m.SetUserID(v)
  51380. return nil
  51381. case wxcardvisit.FieldBotID:
  51382. v, ok := value.(uint64)
  51383. if !ok {
  51384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51385. }
  51386. m.SetBotID(v)
  51387. return nil
  51388. case wxcardvisit.FieldBotType:
  51389. v, ok := value.(uint8)
  51390. if !ok {
  51391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51392. }
  51393. m.SetBotType(v)
  51394. return nil
  51395. }
  51396. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51397. }
  51398. // AddedFields returns all numeric fields that were incremented/decremented during
  51399. // this mutation.
  51400. func (m *WxCardVisitMutation) AddedFields() []string {
  51401. var fields []string
  51402. if m.adduser_id != nil {
  51403. fields = append(fields, wxcardvisit.FieldUserID)
  51404. }
  51405. if m.addbot_id != nil {
  51406. fields = append(fields, wxcardvisit.FieldBotID)
  51407. }
  51408. if m.addbot_type != nil {
  51409. fields = append(fields, wxcardvisit.FieldBotType)
  51410. }
  51411. return fields
  51412. }
  51413. // AddedField returns the numeric value that was incremented/decremented on a field
  51414. // with the given name. The second boolean return value indicates that this field
  51415. // was not set, or was not defined in the schema.
  51416. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  51417. switch name {
  51418. case wxcardvisit.FieldUserID:
  51419. return m.AddedUserID()
  51420. case wxcardvisit.FieldBotID:
  51421. return m.AddedBotID()
  51422. case wxcardvisit.FieldBotType:
  51423. return m.AddedBotType()
  51424. }
  51425. return nil, false
  51426. }
  51427. // AddField adds the value to the field with the given name. It returns an error if
  51428. // the field is not defined in the schema, or if the type mismatched the field
  51429. // type.
  51430. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  51431. switch name {
  51432. case wxcardvisit.FieldUserID:
  51433. v, ok := value.(int64)
  51434. if !ok {
  51435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51436. }
  51437. m.AddUserID(v)
  51438. return nil
  51439. case wxcardvisit.FieldBotID:
  51440. v, ok := value.(int64)
  51441. if !ok {
  51442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51443. }
  51444. m.AddBotID(v)
  51445. return nil
  51446. case wxcardvisit.FieldBotType:
  51447. v, ok := value.(int8)
  51448. if !ok {
  51449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  51450. }
  51451. m.AddBotType(v)
  51452. return nil
  51453. }
  51454. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  51455. }
  51456. // ClearedFields returns all nullable fields that were cleared during this
  51457. // mutation.
  51458. func (m *WxCardVisitMutation) ClearedFields() []string {
  51459. var fields []string
  51460. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  51461. fields = append(fields, wxcardvisit.FieldDeletedAt)
  51462. }
  51463. if m.FieldCleared(wxcardvisit.FieldUserID) {
  51464. fields = append(fields, wxcardvisit.FieldUserID)
  51465. }
  51466. return fields
  51467. }
  51468. // FieldCleared returns a boolean indicating if a field with the given name was
  51469. // cleared in this mutation.
  51470. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  51471. _, ok := m.clearedFields[name]
  51472. return ok
  51473. }
  51474. // ClearField clears the value of the field with the given name. It returns an
  51475. // error if the field is not defined in the schema.
  51476. func (m *WxCardVisitMutation) ClearField(name string) error {
  51477. switch name {
  51478. case wxcardvisit.FieldDeletedAt:
  51479. m.ClearDeletedAt()
  51480. return nil
  51481. case wxcardvisit.FieldUserID:
  51482. m.ClearUserID()
  51483. return nil
  51484. }
  51485. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  51486. }
  51487. // ResetField resets all changes in the mutation for the field with the given name.
  51488. // It returns an error if the field is not defined in the schema.
  51489. func (m *WxCardVisitMutation) ResetField(name string) error {
  51490. switch name {
  51491. case wxcardvisit.FieldCreatedAt:
  51492. m.ResetCreatedAt()
  51493. return nil
  51494. case wxcardvisit.FieldUpdatedAt:
  51495. m.ResetUpdatedAt()
  51496. return nil
  51497. case wxcardvisit.FieldDeletedAt:
  51498. m.ResetDeletedAt()
  51499. return nil
  51500. case wxcardvisit.FieldUserID:
  51501. m.ResetUserID()
  51502. return nil
  51503. case wxcardvisit.FieldBotID:
  51504. m.ResetBotID()
  51505. return nil
  51506. case wxcardvisit.FieldBotType:
  51507. m.ResetBotType()
  51508. return nil
  51509. }
  51510. return fmt.Errorf("unknown WxCardVisit field %s", name)
  51511. }
  51512. // AddedEdges returns all edge names that were set/added in this mutation.
  51513. func (m *WxCardVisitMutation) AddedEdges() []string {
  51514. edges := make([]string, 0, 0)
  51515. return edges
  51516. }
  51517. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  51518. // name in this mutation.
  51519. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  51520. return nil
  51521. }
  51522. // RemovedEdges returns all edge names that were removed in this mutation.
  51523. func (m *WxCardVisitMutation) RemovedEdges() []string {
  51524. edges := make([]string, 0, 0)
  51525. return edges
  51526. }
  51527. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  51528. // the given name in this mutation.
  51529. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  51530. return nil
  51531. }
  51532. // ClearedEdges returns all edge names that were cleared in this mutation.
  51533. func (m *WxCardVisitMutation) ClearedEdges() []string {
  51534. edges := make([]string, 0, 0)
  51535. return edges
  51536. }
  51537. // EdgeCleared returns a boolean which indicates if the edge with the given name
  51538. // was cleared in this mutation.
  51539. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  51540. return false
  51541. }
  51542. // ClearEdge clears the value of the edge with the given name. It returns an error
  51543. // if that edge is not defined in the schema.
  51544. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  51545. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  51546. }
  51547. // ResetEdge resets all changes to the edge with the given name in this mutation.
  51548. // It returns an error if the edge is not defined in the schema.
  51549. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  51550. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  51551. }
  51552. // XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
  51553. type XunjiMutation struct {
  51554. config
  51555. op Op
  51556. typ string
  51557. id *uint64
  51558. created_at *time.Time
  51559. updated_at *time.Time
  51560. status *uint8
  51561. addstatus *int8
  51562. deleted_at *time.Time
  51563. app_key *string
  51564. app_secret *string
  51565. token *string
  51566. encoding_key *string
  51567. organization_id *uint64
  51568. addorganization_id *int64
  51569. clearedFields map[string]struct{}
  51570. done bool
  51571. oldValue func(context.Context) (*Xunji, error)
  51572. predicates []predicate.Xunji
  51573. }
  51574. var _ ent.Mutation = (*XunjiMutation)(nil)
  51575. // xunjiOption allows management of the mutation configuration using functional options.
  51576. type xunjiOption func(*XunjiMutation)
  51577. // newXunjiMutation creates new mutation for the Xunji entity.
  51578. func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
  51579. m := &XunjiMutation{
  51580. config: c,
  51581. op: op,
  51582. typ: TypeXunji,
  51583. clearedFields: make(map[string]struct{}),
  51584. }
  51585. for _, opt := range opts {
  51586. opt(m)
  51587. }
  51588. return m
  51589. }
  51590. // withXunjiID sets the ID field of the mutation.
  51591. func withXunjiID(id uint64) xunjiOption {
  51592. return func(m *XunjiMutation) {
  51593. var (
  51594. err error
  51595. once sync.Once
  51596. value *Xunji
  51597. )
  51598. m.oldValue = func(ctx context.Context) (*Xunji, error) {
  51599. once.Do(func() {
  51600. if m.done {
  51601. err = errors.New("querying old values post mutation is not allowed")
  51602. } else {
  51603. value, err = m.Client().Xunji.Get(ctx, id)
  51604. }
  51605. })
  51606. return value, err
  51607. }
  51608. m.id = &id
  51609. }
  51610. }
  51611. // withXunji sets the old Xunji of the mutation.
  51612. func withXunji(node *Xunji) xunjiOption {
  51613. return func(m *XunjiMutation) {
  51614. m.oldValue = func(context.Context) (*Xunji, error) {
  51615. return node, nil
  51616. }
  51617. m.id = &node.ID
  51618. }
  51619. }
  51620. // Client returns a new `ent.Client` from the mutation. If the mutation was
  51621. // executed in a transaction (ent.Tx), a transactional client is returned.
  51622. func (m XunjiMutation) Client() *Client {
  51623. client := &Client{config: m.config}
  51624. client.init()
  51625. return client
  51626. }
  51627. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  51628. // it returns an error otherwise.
  51629. func (m XunjiMutation) Tx() (*Tx, error) {
  51630. if _, ok := m.driver.(*txDriver); !ok {
  51631. return nil, errors.New("ent: mutation is not running in a transaction")
  51632. }
  51633. tx := &Tx{config: m.config}
  51634. tx.init()
  51635. return tx, nil
  51636. }
  51637. // SetID sets the value of the id field. Note that this
  51638. // operation is only accepted on creation of Xunji entities.
  51639. func (m *XunjiMutation) SetID(id uint64) {
  51640. m.id = &id
  51641. }
  51642. // ID returns the ID value in the mutation. Note that the ID is only available
  51643. // if it was provided to the builder or after it was returned from the database.
  51644. func (m *XunjiMutation) ID() (id uint64, exists bool) {
  51645. if m.id == nil {
  51646. return
  51647. }
  51648. return *m.id, true
  51649. }
  51650. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  51651. // That means, if the mutation is applied within a transaction with an isolation level such
  51652. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  51653. // or updated by the mutation.
  51654. func (m *XunjiMutation) IDs(ctx context.Context) ([]uint64, error) {
  51655. switch {
  51656. case m.op.Is(OpUpdateOne | OpDeleteOne):
  51657. id, exists := m.ID()
  51658. if exists {
  51659. return []uint64{id}, nil
  51660. }
  51661. fallthrough
  51662. case m.op.Is(OpUpdate | OpDelete):
  51663. return m.Client().Xunji.Query().Where(m.predicates...).IDs(ctx)
  51664. default:
  51665. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  51666. }
  51667. }
  51668. // SetCreatedAt sets the "created_at" field.
  51669. func (m *XunjiMutation) SetCreatedAt(t time.Time) {
  51670. m.created_at = &t
  51671. }
  51672. // CreatedAt returns the value of the "created_at" field in the mutation.
  51673. func (m *XunjiMutation) CreatedAt() (r time.Time, exists bool) {
  51674. v := m.created_at
  51675. if v == nil {
  51676. return
  51677. }
  51678. return *v, true
  51679. }
  51680. // OldCreatedAt returns the old "created_at" field's value of the Xunji entity.
  51681. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51683. func (m *XunjiMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  51684. if !m.op.Is(OpUpdateOne) {
  51685. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  51686. }
  51687. if m.id == nil || m.oldValue == nil {
  51688. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  51689. }
  51690. oldValue, err := m.oldValue(ctx)
  51691. if err != nil {
  51692. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  51693. }
  51694. return oldValue.CreatedAt, nil
  51695. }
  51696. // ResetCreatedAt resets all changes to the "created_at" field.
  51697. func (m *XunjiMutation) ResetCreatedAt() {
  51698. m.created_at = nil
  51699. }
  51700. // SetUpdatedAt sets the "updated_at" field.
  51701. func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
  51702. m.updated_at = &t
  51703. }
  51704. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  51705. func (m *XunjiMutation) UpdatedAt() (r time.Time, exists bool) {
  51706. v := m.updated_at
  51707. if v == nil {
  51708. return
  51709. }
  51710. return *v, true
  51711. }
  51712. // OldUpdatedAt returns the old "updated_at" field's value of the Xunji entity.
  51713. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51715. func (m *XunjiMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  51716. if !m.op.Is(OpUpdateOne) {
  51717. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  51718. }
  51719. if m.id == nil || m.oldValue == nil {
  51720. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  51721. }
  51722. oldValue, err := m.oldValue(ctx)
  51723. if err != nil {
  51724. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  51725. }
  51726. return oldValue.UpdatedAt, nil
  51727. }
  51728. // ResetUpdatedAt resets all changes to the "updated_at" field.
  51729. func (m *XunjiMutation) ResetUpdatedAt() {
  51730. m.updated_at = nil
  51731. }
  51732. // SetStatus sets the "status" field.
  51733. func (m *XunjiMutation) SetStatus(u uint8) {
  51734. m.status = &u
  51735. m.addstatus = nil
  51736. }
  51737. // Status returns the value of the "status" field in the mutation.
  51738. func (m *XunjiMutation) Status() (r uint8, exists bool) {
  51739. v := m.status
  51740. if v == nil {
  51741. return
  51742. }
  51743. return *v, true
  51744. }
  51745. // OldStatus returns the old "status" field's value of the Xunji entity.
  51746. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51748. func (m *XunjiMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  51749. if !m.op.Is(OpUpdateOne) {
  51750. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  51751. }
  51752. if m.id == nil || m.oldValue == nil {
  51753. return v, errors.New("OldStatus requires an ID field in the mutation")
  51754. }
  51755. oldValue, err := m.oldValue(ctx)
  51756. if err != nil {
  51757. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  51758. }
  51759. return oldValue.Status, nil
  51760. }
  51761. // AddStatus adds u to the "status" field.
  51762. func (m *XunjiMutation) AddStatus(u int8) {
  51763. if m.addstatus != nil {
  51764. *m.addstatus += u
  51765. } else {
  51766. m.addstatus = &u
  51767. }
  51768. }
  51769. // AddedStatus returns the value that was added to the "status" field in this mutation.
  51770. func (m *XunjiMutation) AddedStatus() (r int8, exists bool) {
  51771. v := m.addstatus
  51772. if v == nil {
  51773. return
  51774. }
  51775. return *v, true
  51776. }
  51777. // ClearStatus clears the value of the "status" field.
  51778. func (m *XunjiMutation) ClearStatus() {
  51779. m.status = nil
  51780. m.addstatus = nil
  51781. m.clearedFields[xunji.FieldStatus] = struct{}{}
  51782. }
  51783. // StatusCleared returns if the "status" field was cleared in this mutation.
  51784. func (m *XunjiMutation) StatusCleared() bool {
  51785. _, ok := m.clearedFields[xunji.FieldStatus]
  51786. return ok
  51787. }
  51788. // ResetStatus resets all changes to the "status" field.
  51789. func (m *XunjiMutation) ResetStatus() {
  51790. m.status = nil
  51791. m.addstatus = nil
  51792. delete(m.clearedFields, xunji.FieldStatus)
  51793. }
  51794. // SetDeletedAt sets the "deleted_at" field.
  51795. func (m *XunjiMutation) SetDeletedAt(t time.Time) {
  51796. m.deleted_at = &t
  51797. }
  51798. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  51799. func (m *XunjiMutation) DeletedAt() (r time.Time, exists bool) {
  51800. v := m.deleted_at
  51801. if v == nil {
  51802. return
  51803. }
  51804. return *v, true
  51805. }
  51806. // OldDeletedAt returns the old "deleted_at" field's value of the Xunji entity.
  51807. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51809. func (m *XunjiMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  51810. if !m.op.Is(OpUpdateOne) {
  51811. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  51812. }
  51813. if m.id == nil || m.oldValue == nil {
  51814. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  51815. }
  51816. oldValue, err := m.oldValue(ctx)
  51817. if err != nil {
  51818. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  51819. }
  51820. return oldValue.DeletedAt, nil
  51821. }
  51822. // ClearDeletedAt clears the value of the "deleted_at" field.
  51823. func (m *XunjiMutation) ClearDeletedAt() {
  51824. m.deleted_at = nil
  51825. m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
  51826. }
  51827. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  51828. func (m *XunjiMutation) DeletedAtCleared() bool {
  51829. _, ok := m.clearedFields[xunji.FieldDeletedAt]
  51830. return ok
  51831. }
  51832. // ResetDeletedAt resets all changes to the "deleted_at" field.
  51833. func (m *XunjiMutation) ResetDeletedAt() {
  51834. m.deleted_at = nil
  51835. delete(m.clearedFields, xunji.FieldDeletedAt)
  51836. }
  51837. // SetAppKey sets the "app_key" field.
  51838. func (m *XunjiMutation) SetAppKey(s string) {
  51839. m.app_key = &s
  51840. }
  51841. // AppKey returns the value of the "app_key" field in the mutation.
  51842. func (m *XunjiMutation) AppKey() (r string, exists bool) {
  51843. v := m.app_key
  51844. if v == nil {
  51845. return
  51846. }
  51847. return *v, true
  51848. }
  51849. // OldAppKey returns the old "app_key" field's value of the Xunji entity.
  51850. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51851. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51852. func (m *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
  51853. if !m.op.Is(OpUpdateOne) {
  51854. return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
  51855. }
  51856. if m.id == nil || m.oldValue == nil {
  51857. return v, errors.New("OldAppKey requires an ID field in the mutation")
  51858. }
  51859. oldValue, err := m.oldValue(ctx)
  51860. if err != nil {
  51861. return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
  51862. }
  51863. return oldValue.AppKey, nil
  51864. }
  51865. // ClearAppKey clears the value of the "app_key" field.
  51866. func (m *XunjiMutation) ClearAppKey() {
  51867. m.app_key = nil
  51868. m.clearedFields[xunji.FieldAppKey] = struct{}{}
  51869. }
  51870. // AppKeyCleared returns if the "app_key" field was cleared in this mutation.
  51871. func (m *XunjiMutation) AppKeyCleared() bool {
  51872. _, ok := m.clearedFields[xunji.FieldAppKey]
  51873. return ok
  51874. }
  51875. // ResetAppKey resets all changes to the "app_key" field.
  51876. func (m *XunjiMutation) ResetAppKey() {
  51877. m.app_key = nil
  51878. delete(m.clearedFields, xunji.FieldAppKey)
  51879. }
  51880. // SetAppSecret sets the "app_secret" field.
  51881. func (m *XunjiMutation) SetAppSecret(s string) {
  51882. m.app_secret = &s
  51883. }
  51884. // AppSecret returns the value of the "app_secret" field in the mutation.
  51885. func (m *XunjiMutation) AppSecret() (r string, exists bool) {
  51886. v := m.app_secret
  51887. if v == nil {
  51888. return
  51889. }
  51890. return *v, true
  51891. }
  51892. // OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
  51893. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51895. func (m *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
  51896. if !m.op.Is(OpUpdateOne) {
  51897. return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
  51898. }
  51899. if m.id == nil || m.oldValue == nil {
  51900. return v, errors.New("OldAppSecret requires an ID field in the mutation")
  51901. }
  51902. oldValue, err := m.oldValue(ctx)
  51903. if err != nil {
  51904. return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
  51905. }
  51906. return oldValue.AppSecret, nil
  51907. }
  51908. // ClearAppSecret clears the value of the "app_secret" field.
  51909. func (m *XunjiMutation) ClearAppSecret() {
  51910. m.app_secret = nil
  51911. m.clearedFields[xunji.FieldAppSecret] = struct{}{}
  51912. }
  51913. // AppSecretCleared returns if the "app_secret" field was cleared in this mutation.
  51914. func (m *XunjiMutation) AppSecretCleared() bool {
  51915. _, ok := m.clearedFields[xunji.FieldAppSecret]
  51916. return ok
  51917. }
  51918. // ResetAppSecret resets all changes to the "app_secret" field.
  51919. func (m *XunjiMutation) ResetAppSecret() {
  51920. m.app_secret = nil
  51921. delete(m.clearedFields, xunji.FieldAppSecret)
  51922. }
  51923. // SetToken sets the "token" field.
  51924. func (m *XunjiMutation) SetToken(s string) {
  51925. m.token = &s
  51926. }
  51927. // Token returns the value of the "token" field in the mutation.
  51928. func (m *XunjiMutation) Token() (r string, exists bool) {
  51929. v := m.token
  51930. if v == nil {
  51931. return
  51932. }
  51933. return *v, true
  51934. }
  51935. // OldToken returns the old "token" field's value of the Xunji entity.
  51936. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51938. func (m *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
  51939. if !m.op.Is(OpUpdateOne) {
  51940. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  51941. }
  51942. if m.id == nil || m.oldValue == nil {
  51943. return v, errors.New("OldToken requires an ID field in the mutation")
  51944. }
  51945. oldValue, err := m.oldValue(ctx)
  51946. if err != nil {
  51947. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  51948. }
  51949. return oldValue.Token, nil
  51950. }
  51951. // ClearToken clears the value of the "token" field.
  51952. func (m *XunjiMutation) ClearToken() {
  51953. m.token = nil
  51954. m.clearedFields[xunji.FieldToken] = struct{}{}
  51955. }
  51956. // TokenCleared returns if the "token" field was cleared in this mutation.
  51957. func (m *XunjiMutation) TokenCleared() bool {
  51958. _, ok := m.clearedFields[xunji.FieldToken]
  51959. return ok
  51960. }
  51961. // ResetToken resets all changes to the "token" field.
  51962. func (m *XunjiMutation) ResetToken() {
  51963. m.token = nil
  51964. delete(m.clearedFields, xunji.FieldToken)
  51965. }
  51966. // SetEncodingKey sets the "encoding_key" field.
  51967. func (m *XunjiMutation) SetEncodingKey(s string) {
  51968. m.encoding_key = &s
  51969. }
  51970. // EncodingKey returns the value of the "encoding_key" field in the mutation.
  51971. func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
  51972. v := m.encoding_key
  51973. if v == nil {
  51974. return
  51975. }
  51976. return *v, true
  51977. }
  51978. // OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
  51979. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  51980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  51981. func (m *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
  51982. if !m.op.Is(OpUpdateOne) {
  51983. return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
  51984. }
  51985. if m.id == nil || m.oldValue == nil {
  51986. return v, errors.New("OldEncodingKey requires an ID field in the mutation")
  51987. }
  51988. oldValue, err := m.oldValue(ctx)
  51989. if err != nil {
  51990. return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
  51991. }
  51992. return oldValue.EncodingKey, nil
  51993. }
  51994. // ClearEncodingKey clears the value of the "encoding_key" field.
  51995. func (m *XunjiMutation) ClearEncodingKey() {
  51996. m.encoding_key = nil
  51997. m.clearedFields[xunji.FieldEncodingKey] = struct{}{}
  51998. }
  51999. // EncodingKeyCleared returns if the "encoding_key" field was cleared in this mutation.
  52000. func (m *XunjiMutation) EncodingKeyCleared() bool {
  52001. _, ok := m.clearedFields[xunji.FieldEncodingKey]
  52002. return ok
  52003. }
  52004. // ResetEncodingKey resets all changes to the "encoding_key" field.
  52005. func (m *XunjiMutation) ResetEncodingKey() {
  52006. m.encoding_key = nil
  52007. delete(m.clearedFields, xunji.FieldEncodingKey)
  52008. }
  52009. // SetOrganizationID sets the "organization_id" field.
  52010. func (m *XunjiMutation) SetOrganizationID(u uint64) {
  52011. m.organization_id = &u
  52012. m.addorganization_id = nil
  52013. }
  52014. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52015. func (m *XunjiMutation) OrganizationID() (r uint64, exists bool) {
  52016. v := m.organization_id
  52017. if v == nil {
  52018. return
  52019. }
  52020. return *v, true
  52021. }
  52022. // OldOrganizationID returns the old "organization_id" field's value of the Xunji entity.
  52023. // If the Xunji object wasn't provided to the builder, the object is fetched from the database.
  52024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52025. func (m *XunjiMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52026. if !m.op.Is(OpUpdateOne) {
  52027. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52028. }
  52029. if m.id == nil || m.oldValue == nil {
  52030. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52031. }
  52032. oldValue, err := m.oldValue(ctx)
  52033. if err != nil {
  52034. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52035. }
  52036. return oldValue.OrganizationID, nil
  52037. }
  52038. // AddOrganizationID adds u to the "organization_id" field.
  52039. func (m *XunjiMutation) AddOrganizationID(u int64) {
  52040. if m.addorganization_id != nil {
  52041. *m.addorganization_id += u
  52042. } else {
  52043. m.addorganization_id = &u
  52044. }
  52045. }
  52046. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52047. func (m *XunjiMutation) AddedOrganizationID() (r int64, exists bool) {
  52048. v := m.addorganization_id
  52049. if v == nil {
  52050. return
  52051. }
  52052. return *v, true
  52053. }
  52054. // ResetOrganizationID resets all changes to the "organization_id" field.
  52055. func (m *XunjiMutation) ResetOrganizationID() {
  52056. m.organization_id = nil
  52057. m.addorganization_id = nil
  52058. }
  52059. // Where appends a list predicates to the XunjiMutation builder.
  52060. func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
  52061. m.predicates = append(m.predicates, ps...)
  52062. }
  52063. // WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
  52064. // users can use type-assertion to append predicates that do not depend on any generated package.
  52065. func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
  52066. p := make([]predicate.Xunji, len(ps))
  52067. for i := range ps {
  52068. p[i] = ps[i]
  52069. }
  52070. m.Where(p...)
  52071. }
  52072. // Op returns the operation name.
  52073. func (m *XunjiMutation) Op() Op {
  52074. return m.op
  52075. }
  52076. // SetOp allows setting the mutation operation.
  52077. func (m *XunjiMutation) SetOp(op Op) {
  52078. m.op = op
  52079. }
  52080. // Type returns the node type of this mutation (Xunji).
  52081. func (m *XunjiMutation) Type() string {
  52082. return m.typ
  52083. }
  52084. // Fields returns all fields that were changed during this mutation. Note that in
  52085. // order to get all numeric fields that were incremented/decremented, call
  52086. // AddedFields().
  52087. func (m *XunjiMutation) Fields() []string {
  52088. fields := make([]string, 0, 9)
  52089. if m.created_at != nil {
  52090. fields = append(fields, xunji.FieldCreatedAt)
  52091. }
  52092. if m.updated_at != nil {
  52093. fields = append(fields, xunji.FieldUpdatedAt)
  52094. }
  52095. if m.status != nil {
  52096. fields = append(fields, xunji.FieldStatus)
  52097. }
  52098. if m.deleted_at != nil {
  52099. fields = append(fields, xunji.FieldDeletedAt)
  52100. }
  52101. if m.app_key != nil {
  52102. fields = append(fields, xunji.FieldAppKey)
  52103. }
  52104. if m.app_secret != nil {
  52105. fields = append(fields, xunji.FieldAppSecret)
  52106. }
  52107. if m.token != nil {
  52108. fields = append(fields, xunji.FieldToken)
  52109. }
  52110. if m.encoding_key != nil {
  52111. fields = append(fields, xunji.FieldEncodingKey)
  52112. }
  52113. if m.organization_id != nil {
  52114. fields = append(fields, xunji.FieldOrganizationID)
  52115. }
  52116. return fields
  52117. }
  52118. // Field returns the value of a field with the given name. The second boolean
  52119. // return value indicates that this field was not set, or was not defined in the
  52120. // schema.
  52121. func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
  52122. switch name {
  52123. case xunji.FieldCreatedAt:
  52124. return m.CreatedAt()
  52125. case xunji.FieldUpdatedAt:
  52126. return m.UpdatedAt()
  52127. case xunji.FieldStatus:
  52128. return m.Status()
  52129. case xunji.FieldDeletedAt:
  52130. return m.DeletedAt()
  52131. case xunji.FieldAppKey:
  52132. return m.AppKey()
  52133. case xunji.FieldAppSecret:
  52134. return m.AppSecret()
  52135. case xunji.FieldToken:
  52136. return m.Token()
  52137. case xunji.FieldEncodingKey:
  52138. return m.EncodingKey()
  52139. case xunji.FieldOrganizationID:
  52140. return m.OrganizationID()
  52141. }
  52142. return nil, false
  52143. }
  52144. // OldField returns the old value of the field from the database. An error is
  52145. // returned if the mutation operation is not UpdateOne, or the query to the
  52146. // database failed.
  52147. func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  52148. switch name {
  52149. case xunji.FieldCreatedAt:
  52150. return m.OldCreatedAt(ctx)
  52151. case xunji.FieldUpdatedAt:
  52152. return m.OldUpdatedAt(ctx)
  52153. case xunji.FieldStatus:
  52154. return m.OldStatus(ctx)
  52155. case xunji.FieldDeletedAt:
  52156. return m.OldDeletedAt(ctx)
  52157. case xunji.FieldAppKey:
  52158. return m.OldAppKey(ctx)
  52159. case xunji.FieldAppSecret:
  52160. return m.OldAppSecret(ctx)
  52161. case xunji.FieldToken:
  52162. return m.OldToken(ctx)
  52163. case xunji.FieldEncodingKey:
  52164. return m.OldEncodingKey(ctx)
  52165. case xunji.FieldOrganizationID:
  52166. return m.OldOrganizationID(ctx)
  52167. }
  52168. return nil, fmt.Errorf("unknown Xunji field %s", name)
  52169. }
  52170. // SetField sets the value of a field with the given name. It returns an error if
  52171. // the field is not defined in the schema, or if the type mismatched the field
  52172. // type.
  52173. func (m *XunjiMutation) SetField(name string, value ent.Value) error {
  52174. switch name {
  52175. case xunji.FieldCreatedAt:
  52176. v, ok := value.(time.Time)
  52177. if !ok {
  52178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52179. }
  52180. m.SetCreatedAt(v)
  52181. return nil
  52182. case xunji.FieldUpdatedAt:
  52183. v, ok := value.(time.Time)
  52184. if !ok {
  52185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52186. }
  52187. m.SetUpdatedAt(v)
  52188. return nil
  52189. case xunji.FieldStatus:
  52190. v, ok := value.(uint8)
  52191. if !ok {
  52192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52193. }
  52194. m.SetStatus(v)
  52195. return nil
  52196. case xunji.FieldDeletedAt:
  52197. v, ok := value.(time.Time)
  52198. if !ok {
  52199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52200. }
  52201. m.SetDeletedAt(v)
  52202. return nil
  52203. case xunji.FieldAppKey:
  52204. v, ok := value.(string)
  52205. if !ok {
  52206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52207. }
  52208. m.SetAppKey(v)
  52209. return nil
  52210. case xunji.FieldAppSecret:
  52211. v, ok := value.(string)
  52212. if !ok {
  52213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52214. }
  52215. m.SetAppSecret(v)
  52216. return nil
  52217. case xunji.FieldToken:
  52218. v, ok := value.(string)
  52219. if !ok {
  52220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52221. }
  52222. m.SetToken(v)
  52223. return nil
  52224. case xunji.FieldEncodingKey:
  52225. v, ok := value.(string)
  52226. if !ok {
  52227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52228. }
  52229. m.SetEncodingKey(v)
  52230. return nil
  52231. case xunji.FieldOrganizationID:
  52232. v, ok := value.(uint64)
  52233. if !ok {
  52234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52235. }
  52236. m.SetOrganizationID(v)
  52237. return nil
  52238. }
  52239. return fmt.Errorf("unknown Xunji field %s", name)
  52240. }
  52241. // AddedFields returns all numeric fields that were incremented/decremented during
  52242. // this mutation.
  52243. func (m *XunjiMutation) AddedFields() []string {
  52244. var fields []string
  52245. if m.addstatus != nil {
  52246. fields = append(fields, xunji.FieldStatus)
  52247. }
  52248. if m.addorganization_id != nil {
  52249. fields = append(fields, xunji.FieldOrganizationID)
  52250. }
  52251. return fields
  52252. }
  52253. // AddedField returns the numeric value that was incremented/decremented on a field
  52254. // with the given name. The second boolean return value indicates that this field
  52255. // was not set, or was not defined in the schema.
  52256. func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
  52257. switch name {
  52258. case xunji.FieldStatus:
  52259. return m.AddedStatus()
  52260. case xunji.FieldOrganizationID:
  52261. return m.AddedOrganizationID()
  52262. }
  52263. return nil, false
  52264. }
  52265. // AddField adds the value to the field with the given name. It returns an error if
  52266. // the field is not defined in the schema, or if the type mismatched the field
  52267. // type.
  52268. func (m *XunjiMutation) AddField(name string, value ent.Value) error {
  52269. switch name {
  52270. case xunji.FieldStatus:
  52271. v, ok := value.(int8)
  52272. if !ok {
  52273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52274. }
  52275. m.AddStatus(v)
  52276. return nil
  52277. case xunji.FieldOrganizationID:
  52278. v, ok := value.(int64)
  52279. if !ok {
  52280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  52281. }
  52282. m.AddOrganizationID(v)
  52283. return nil
  52284. }
  52285. return fmt.Errorf("unknown Xunji numeric field %s", name)
  52286. }
  52287. // ClearedFields returns all nullable fields that were cleared during this
  52288. // mutation.
  52289. func (m *XunjiMutation) ClearedFields() []string {
  52290. var fields []string
  52291. if m.FieldCleared(xunji.FieldStatus) {
  52292. fields = append(fields, xunji.FieldStatus)
  52293. }
  52294. if m.FieldCleared(xunji.FieldDeletedAt) {
  52295. fields = append(fields, xunji.FieldDeletedAt)
  52296. }
  52297. if m.FieldCleared(xunji.FieldAppKey) {
  52298. fields = append(fields, xunji.FieldAppKey)
  52299. }
  52300. if m.FieldCleared(xunji.FieldAppSecret) {
  52301. fields = append(fields, xunji.FieldAppSecret)
  52302. }
  52303. if m.FieldCleared(xunji.FieldToken) {
  52304. fields = append(fields, xunji.FieldToken)
  52305. }
  52306. if m.FieldCleared(xunji.FieldEncodingKey) {
  52307. fields = append(fields, xunji.FieldEncodingKey)
  52308. }
  52309. return fields
  52310. }
  52311. // FieldCleared returns a boolean indicating if a field with the given name was
  52312. // cleared in this mutation.
  52313. func (m *XunjiMutation) FieldCleared(name string) bool {
  52314. _, ok := m.clearedFields[name]
  52315. return ok
  52316. }
  52317. // ClearField clears the value of the field with the given name. It returns an
  52318. // error if the field is not defined in the schema.
  52319. func (m *XunjiMutation) ClearField(name string) error {
  52320. switch name {
  52321. case xunji.FieldStatus:
  52322. m.ClearStatus()
  52323. return nil
  52324. case xunji.FieldDeletedAt:
  52325. m.ClearDeletedAt()
  52326. return nil
  52327. case xunji.FieldAppKey:
  52328. m.ClearAppKey()
  52329. return nil
  52330. case xunji.FieldAppSecret:
  52331. m.ClearAppSecret()
  52332. return nil
  52333. case xunji.FieldToken:
  52334. m.ClearToken()
  52335. return nil
  52336. case xunji.FieldEncodingKey:
  52337. m.ClearEncodingKey()
  52338. return nil
  52339. }
  52340. return fmt.Errorf("unknown Xunji nullable field %s", name)
  52341. }
  52342. // ResetField resets all changes in the mutation for the field with the given name.
  52343. // It returns an error if the field is not defined in the schema.
  52344. func (m *XunjiMutation) ResetField(name string) error {
  52345. switch name {
  52346. case xunji.FieldCreatedAt:
  52347. m.ResetCreatedAt()
  52348. return nil
  52349. case xunji.FieldUpdatedAt:
  52350. m.ResetUpdatedAt()
  52351. return nil
  52352. case xunji.FieldStatus:
  52353. m.ResetStatus()
  52354. return nil
  52355. case xunji.FieldDeletedAt:
  52356. m.ResetDeletedAt()
  52357. return nil
  52358. case xunji.FieldAppKey:
  52359. m.ResetAppKey()
  52360. return nil
  52361. case xunji.FieldAppSecret:
  52362. m.ResetAppSecret()
  52363. return nil
  52364. case xunji.FieldToken:
  52365. m.ResetToken()
  52366. return nil
  52367. case xunji.FieldEncodingKey:
  52368. m.ResetEncodingKey()
  52369. return nil
  52370. case xunji.FieldOrganizationID:
  52371. m.ResetOrganizationID()
  52372. return nil
  52373. }
  52374. return fmt.Errorf("unknown Xunji field %s", name)
  52375. }
  52376. // AddedEdges returns all edge names that were set/added in this mutation.
  52377. func (m *XunjiMutation) AddedEdges() []string {
  52378. edges := make([]string, 0, 0)
  52379. return edges
  52380. }
  52381. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  52382. // name in this mutation.
  52383. func (m *XunjiMutation) AddedIDs(name string) []ent.Value {
  52384. return nil
  52385. }
  52386. // RemovedEdges returns all edge names that were removed in this mutation.
  52387. func (m *XunjiMutation) RemovedEdges() []string {
  52388. edges := make([]string, 0, 0)
  52389. return edges
  52390. }
  52391. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  52392. // the given name in this mutation.
  52393. func (m *XunjiMutation) RemovedIDs(name string) []ent.Value {
  52394. return nil
  52395. }
  52396. // ClearedEdges returns all edge names that were cleared in this mutation.
  52397. func (m *XunjiMutation) ClearedEdges() []string {
  52398. edges := make([]string, 0, 0)
  52399. return edges
  52400. }
  52401. // EdgeCleared returns a boolean which indicates if the edge with the given name
  52402. // was cleared in this mutation.
  52403. func (m *XunjiMutation) EdgeCleared(name string) bool {
  52404. return false
  52405. }
  52406. // ClearEdge clears the value of the edge with the given name. It returns an error
  52407. // if that edge is not defined in the schema.
  52408. func (m *XunjiMutation) ClearEdge(name string) error {
  52409. return fmt.Errorf("unknown Xunji unique edge %s", name)
  52410. }
  52411. // ResetEdge resets all changes to the edge with the given name in this mutation.
  52412. // It returns an error if the edge is not defined in the schema.
  52413. func (m *XunjiMutation) ResetEdge(name string) error {
  52414. return fmt.Errorf("unknown Xunji edge %s", name)
  52415. }
  52416. // XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
  52417. type XunjiServiceMutation struct {
  52418. config
  52419. op Op
  52420. typ string
  52421. id *uint64
  52422. created_at *time.Time
  52423. updated_at *time.Time
  52424. status *uint8
  52425. addstatus *int8
  52426. deleted_at *time.Time
  52427. xunji_id *uint64
  52428. addxunji_id *int64
  52429. organization_id *uint64
  52430. addorganization_id *int64
  52431. wxid *string
  52432. api_base *string
  52433. api_key *string
  52434. clearedFields map[string]struct{}
  52435. agent *uint64
  52436. clearedagent bool
  52437. done bool
  52438. oldValue func(context.Context) (*XunjiService, error)
  52439. predicates []predicate.XunjiService
  52440. }
  52441. var _ ent.Mutation = (*XunjiServiceMutation)(nil)
  52442. // xunjiserviceOption allows management of the mutation configuration using functional options.
  52443. type xunjiserviceOption func(*XunjiServiceMutation)
  52444. // newXunjiServiceMutation creates new mutation for the XunjiService entity.
  52445. func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
  52446. m := &XunjiServiceMutation{
  52447. config: c,
  52448. op: op,
  52449. typ: TypeXunjiService,
  52450. clearedFields: make(map[string]struct{}),
  52451. }
  52452. for _, opt := range opts {
  52453. opt(m)
  52454. }
  52455. return m
  52456. }
  52457. // withXunjiServiceID sets the ID field of the mutation.
  52458. func withXunjiServiceID(id uint64) xunjiserviceOption {
  52459. return func(m *XunjiServiceMutation) {
  52460. var (
  52461. err error
  52462. once sync.Once
  52463. value *XunjiService
  52464. )
  52465. m.oldValue = func(ctx context.Context) (*XunjiService, error) {
  52466. once.Do(func() {
  52467. if m.done {
  52468. err = errors.New("querying old values post mutation is not allowed")
  52469. } else {
  52470. value, err = m.Client().XunjiService.Get(ctx, id)
  52471. }
  52472. })
  52473. return value, err
  52474. }
  52475. m.id = &id
  52476. }
  52477. }
  52478. // withXunjiService sets the old XunjiService of the mutation.
  52479. func withXunjiService(node *XunjiService) xunjiserviceOption {
  52480. return func(m *XunjiServiceMutation) {
  52481. m.oldValue = func(context.Context) (*XunjiService, error) {
  52482. return node, nil
  52483. }
  52484. m.id = &node.ID
  52485. }
  52486. }
  52487. // Client returns a new `ent.Client` from the mutation. If the mutation was
  52488. // executed in a transaction (ent.Tx), a transactional client is returned.
  52489. func (m XunjiServiceMutation) Client() *Client {
  52490. client := &Client{config: m.config}
  52491. client.init()
  52492. return client
  52493. }
  52494. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  52495. // it returns an error otherwise.
  52496. func (m XunjiServiceMutation) Tx() (*Tx, error) {
  52497. if _, ok := m.driver.(*txDriver); !ok {
  52498. return nil, errors.New("ent: mutation is not running in a transaction")
  52499. }
  52500. tx := &Tx{config: m.config}
  52501. tx.init()
  52502. return tx, nil
  52503. }
  52504. // SetID sets the value of the id field. Note that this
  52505. // operation is only accepted on creation of XunjiService entities.
  52506. func (m *XunjiServiceMutation) SetID(id uint64) {
  52507. m.id = &id
  52508. }
  52509. // ID returns the ID value in the mutation. Note that the ID is only available
  52510. // if it was provided to the builder or after it was returned from the database.
  52511. func (m *XunjiServiceMutation) ID() (id uint64, exists bool) {
  52512. if m.id == nil {
  52513. return
  52514. }
  52515. return *m.id, true
  52516. }
  52517. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  52518. // That means, if the mutation is applied within a transaction with an isolation level such
  52519. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  52520. // or updated by the mutation.
  52521. func (m *XunjiServiceMutation) IDs(ctx context.Context) ([]uint64, error) {
  52522. switch {
  52523. case m.op.Is(OpUpdateOne | OpDeleteOne):
  52524. id, exists := m.ID()
  52525. if exists {
  52526. return []uint64{id}, nil
  52527. }
  52528. fallthrough
  52529. case m.op.Is(OpUpdate | OpDelete):
  52530. return m.Client().XunjiService.Query().Where(m.predicates...).IDs(ctx)
  52531. default:
  52532. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  52533. }
  52534. }
  52535. // SetCreatedAt sets the "created_at" field.
  52536. func (m *XunjiServiceMutation) SetCreatedAt(t time.Time) {
  52537. m.created_at = &t
  52538. }
  52539. // CreatedAt returns the value of the "created_at" field in the mutation.
  52540. func (m *XunjiServiceMutation) CreatedAt() (r time.Time, exists bool) {
  52541. v := m.created_at
  52542. if v == nil {
  52543. return
  52544. }
  52545. return *v, true
  52546. }
  52547. // OldCreatedAt returns the old "created_at" field's value of the XunjiService entity.
  52548. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52550. func (m *XunjiServiceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  52551. if !m.op.Is(OpUpdateOne) {
  52552. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  52553. }
  52554. if m.id == nil || m.oldValue == nil {
  52555. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  52556. }
  52557. oldValue, err := m.oldValue(ctx)
  52558. if err != nil {
  52559. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  52560. }
  52561. return oldValue.CreatedAt, nil
  52562. }
  52563. // ResetCreatedAt resets all changes to the "created_at" field.
  52564. func (m *XunjiServiceMutation) ResetCreatedAt() {
  52565. m.created_at = nil
  52566. }
  52567. // SetUpdatedAt sets the "updated_at" field.
  52568. func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
  52569. m.updated_at = &t
  52570. }
  52571. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  52572. func (m *XunjiServiceMutation) UpdatedAt() (r time.Time, exists bool) {
  52573. v := m.updated_at
  52574. if v == nil {
  52575. return
  52576. }
  52577. return *v, true
  52578. }
  52579. // OldUpdatedAt returns the old "updated_at" field's value of the XunjiService entity.
  52580. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52582. func (m *XunjiServiceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  52583. if !m.op.Is(OpUpdateOne) {
  52584. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  52585. }
  52586. if m.id == nil || m.oldValue == nil {
  52587. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  52588. }
  52589. oldValue, err := m.oldValue(ctx)
  52590. if err != nil {
  52591. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  52592. }
  52593. return oldValue.UpdatedAt, nil
  52594. }
  52595. // ResetUpdatedAt resets all changes to the "updated_at" field.
  52596. func (m *XunjiServiceMutation) ResetUpdatedAt() {
  52597. m.updated_at = nil
  52598. }
  52599. // SetStatus sets the "status" field.
  52600. func (m *XunjiServiceMutation) SetStatus(u uint8) {
  52601. m.status = &u
  52602. m.addstatus = nil
  52603. }
  52604. // Status returns the value of the "status" field in the mutation.
  52605. func (m *XunjiServiceMutation) Status() (r uint8, exists bool) {
  52606. v := m.status
  52607. if v == nil {
  52608. return
  52609. }
  52610. return *v, true
  52611. }
  52612. // OldStatus returns the old "status" field's value of the XunjiService entity.
  52613. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52615. func (m *XunjiServiceMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  52616. if !m.op.Is(OpUpdateOne) {
  52617. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  52618. }
  52619. if m.id == nil || m.oldValue == nil {
  52620. return v, errors.New("OldStatus requires an ID field in the mutation")
  52621. }
  52622. oldValue, err := m.oldValue(ctx)
  52623. if err != nil {
  52624. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  52625. }
  52626. return oldValue.Status, nil
  52627. }
  52628. // AddStatus adds u to the "status" field.
  52629. func (m *XunjiServiceMutation) AddStatus(u int8) {
  52630. if m.addstatus != nil {
  52631. *m.addstatus += u
  52632. } else {
  52633. m.addstatus = &u
  52634. }
  52635. }
  52636. // AddedStatus returns the value that was added to the "status" field in this mutation.
  52637. func (m *XunjiServiceMutation) AddedStatus() (r int8, exists bool) {
  52638. v := m.addstatus
  52639. if v == nil {
  52640. return
  52641. }
  52642. return *v, true
  52643. }
  52644. // ClearStatus clears the value of the "status" field.
  52645. func (m *XunjiServiceMutation) ClearStatus() {
  52646. m.status = nil
  52647. m.addstatus = nil
  52648. m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
  52649. }
  52650. // StatusCleared returns if the "status" field was cleared in this mutation.
  52651. func (m *XunjiServiceMutation) StatusCleared() bool {
  52652. _, ok := m.clearedFields[xunjiservice.FieldStatus]
  52653. return ok
  52654. }
  52655. // ResetStatus resets all changes to the "status" field.
  52656. func (m *XunjiServiceMutation) ResetStatus() {
  52657. m.status = nil
  52658. m.addstatus = nil
  52659. delete(m.clearedFields, xunjiservice.FieldStatus)
  52660. }
  52661. // SetDeletedAt sets the "deleted_at" field.
  52662. func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
  52663. m.deleted_at = &t
  52664. }
  52665. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  52666. func (m *XunjiServiceMutation) DeletedAt() (r time.Time, exists bool) {
  52667. v := m.deleted_at
  52668. if v == nil {
  52669. return
  52670. }
  52671. return *v, true
  52672. }
  52673. // OldDeletedAt returns the old "deleted_at" field's value of the XunjiService entity.
  52674. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52676. func (m *XunjiServiceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  52677. if !m.op.Is(OpUpdateOne) {
  52678. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  52679. }
  52680. if m.id == nil || m.oldValue == nil {
  52681. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  52682. }
  52683. oldValue, err := m.oldValue(ctx)
  52684. if err != nil {
  52685. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  52686. }
  52687. return oldValue.DeletedAt, nil
  52688. }
  52689. // ClearDeletedAt clears the value of the "deleted_at" field.
  52690. func (m *XunjiServiceMutation) ClearDeletedAt() {
  52691. m.deleted_at = nil
  52692. m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
  52693. }
  52694. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  52695. func (m *XunjiServiceMutation) DeletedAtCleared() bool {
  52696. _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
  52697. return ok
  52698. }
  52699. // ResetDeletedAt resets all changes to the "deleted_at" field.
  52700. func (m *XunjiServiceMutation) ResetDeletedAt() {
  52701. m.deleted_at = nil
  52702. delete(m.clearedFields, xunjiservice.FieldDeletedAt)
  52703. }
  52704. // SetXunjiID sets the "xunji_id" field.
  52705. func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
  52706. m.xunji_id = &u
  52707. m.addxunji_id = nil
  52708. }
  52709. // XunjiID returns the value of the "xunji_id" field in the mutation.
  52710. func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
  52711. v := m.xunji_id
  52712. if v == nil {
  52713. return
  52714. }
  52715. return *v, true
  52716. }
  52717. // OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
  52718. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52720. func (m *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
  52721. if !m.op.Is(OpUpdateOne) {
  52722. return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
  52723. }
  52724. if m.id == nil || m.oldValue == nil {
  52725. return v, errors.New("OldXunjiID requires an ID field in the mutation")
  52726. }
  52727. oldValue, err := m.oldValue(ctx)
  52728. if err != nil {
  52729. return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
  52730. }
  52731. return oldValue.XunjiID, nil
  52732. }
  52733. // AddXunjiID adds u to the "xunji_id" field.
  52734. func (m *XunjiServiceMutation) AddXunjiID(u int64) {
  52735. if m.addxunji_id != nil {
  52736. *m.addxunji_id += u
  52737. } else {
  52738. m.addxunji_id = &u
  52739. }
  52740. }
  52741. // AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
  52742. func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
  52743. v := m.addxunji_id
  52744. if v == nil {
  52745. return
  52746. }
  52747. return *v, true
  52748. }
  52749. // ResetXunjiID resets all changes to the "xunji_id" field.
  52750. func (m *XunjiServiceMutation) ResetXunjiID() {
  52751. m.xunji_id = nil
  52752. m.addxunji_id = nil
  52753. }
  52754. // SetAgentID sets the "agent_id" field.
  52755. func (m *XunjiServiceMutation) SetAgentID(u uint64) {
  52756. m.agent = &u
  52757. }
  52758. // AgentID returns the value of the "agent_id" field in the mutation.
  52759. func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
  52760. v := m.agent
  52761. if v == nil {
  52762. return
  52763. }
  52764. return *v, true
  52765. }
  52766. // OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
  52767. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52769. func (m *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  52770. if !m.op.Is(OpUpdateOne) {
  52771. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  52772. }
  52773. if m.id == nil || m.oldValue == nil {
  52774. return v, errors.New("OldAgentID requires an ID field in the mutation")
  52775. }
  52776. oldValue, err := m.oldValue(ctx)
  52777. if err != nil {
  52778. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  52779. }
  52780. return oldValue.AgentID, nil
  52781. }
  52782. // ResetAgentID resets all changes to the "agent_id" field.
  52783. func (m *XunjiServiceMutation) ResetAgentID() {
  52784. m.agent = nil
  52785. }
  52786. // SetOrganizationID sets the "organization_id" field.
  52787. func (m *XunjiServiceMutation) SetOrganizationID(u uint64) {
  52788. m.organization_id = &u
  52789. m.addorganization_id = nil
  52790. }
  52791. // OrganizationID returns the value of the "organization_id" field in the mutation.
  52792. func (m *XunjiServiceMutation) OrganizationID() (r uint64, exists bool) {
  52793. v := m.organization_id
  52794. if v == nil {
  52795. return
  52796. }
  52797. return *v, true
  52798. }
  52799. // OldOrganizationID returns the old "organization_id" field's value of the XunjiService entity.
  52800. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52802. func (m *XunjiServiceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  52803. if !m.op.Is(OpUpdateOne) {
  52804. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  52805. }
  52806. if m.id == nil || m.oldValue == nil {
  52807. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  52808. }
  52809. oldValue, err := m.oldValue(ctx)
  52810. if err != nil {
  52811. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  52812. }
  52813. return oldValue.OrganizationID, nil
  52814. }
  52815. // AddOrganizationID adds u to the "organization_id" field.
  52816. func (m *XunjiServiceMutation) AddOrganizationID(u int64) {
  52817. if m.addorganization_id != nil {
  52818. *m.addorganization_id += u
  52819. } else {
  52820. m.addorganization_id = &u
  52821. }
  52822. }
  52823. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  52824. func (m *XunjiServiceMutation) AddedOrganizationID() (r int64, exists bool) {
  52825. v := m.addorganization_id
  52826. if v == nil {
  52827. return
  52828. }
  52829. return *v, true
  52830. }
  52831. // ResetOrganizationID resets all changes to the "organization_id" field.
  52832. func (m *XunjiServiceMutation) ResetOrganizationID() {
  52833. m.organization_id = nil
  52834. m.addorganization_id = nil
  52835. }
  52836. // SetWxid sets the "wxid" field.
  52837. func (m *XunjiServiceMutation) SetWxid(s string) {
  52838. m.wxid = &s
  52839. }
  52840. // Wxid returns the value of the "wxid" field in the mutation.
  52841. func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
  52842. v := m.wxid
  52843. if v == nil {
  52844. return
  52845. }
  52846. return *v, true
  52847. }
  52848. // OldWxid returns the old "wxid" field's value of the XunjiService entity.
  52849. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52851. func (m *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
  52852. if !m.op.Is(OpUpdateOne) {
  52853. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  52854. }
  52855. if m.id == nil || m.oldValue == nil {
  52856. return v, errors.New("OldWxid requires an ID field in the mutation")
  52857. }
  52858. oldValue, err := m.oldValue(ctx)
  52859. if err != nil {
  52860. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  52861. }
  52862. return oldValue.Wxid, nil
  52863. }
  52864. // ResetWxid resets all changes to the "wxid" field.
  52865. func (m *XunjiServiceMutation) ResetWxid() {
  52866. m.wxid = nil
  52867. }
  52868. // SetAPIBase sets the "api_base" field.
  52869. func (m *XunjiServiceMutation) SetAPIBase(s string) {
  52870. m.api_base = &s
  52871. }
  52872. // APIBase returns the value of the "api_base" field in the mutation.
  52873. func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
  52874. v := m.api_base
  52875. if v == nil {
  52876. return
  52877. }
  52878. return *v, true
  52879. }
  52880. // OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
  52881. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52883. func (m *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  52884. if !m.op.Is(OpUpdateOne) {
  52885. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  52886. }
  52887. if m.id == nil || m.oldValue == nil {
  52888. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  52889. }
  52890. oldValue, err := m.oldValue(ctx)
  52891. if err != nil {
  52892. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  52893. }
  52894. return oldValue.APIBase, nil
  52895. }
  52896. // ClearAPIBase clears the value of the "api_base" field.
  52897. func (m *XunjiServiceMutation) ClearAPIBase() {
  52898. m.api_base = nil
  52899. m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
  52900. }
  52901. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  52902. func (m *XunjiServiceMutation) APIBaseCleared() bool {
  52903. _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
  52904. return ok
  52905. }
  52906. // ResetAPIBase resets all changes to the "api_base" field.
  52907. func (m *XunjiServiceMutation) ResetAPIBase() {
  52908. m.api_base = nil
  52909. delete(m.clearedFields, xunjiservice.FieldAPIBase)
  52910. }
  52911. // SetAPIKey sets the "api_key" field.
  52912. func (m *XunjiServiceMutation) SetAPIKey(s string) {
  52913. m.api_key = &s
  52914. }
  52915. // APIKey returns the value of the "api_key" field in the mutation.
  52916. func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
  52917. v := m.api_key
  52918. if v == nil {
  52919. return
  52920. }
  52921. return *v, true
  52922. }
  52923. // OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
  52924. // If the XunjiService object wasn't provided to the builder, the object is fetched from the database.
  52925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  52926. func (m *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  52927. if !m.op.Is(OpUpdateOne) {
  52928. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  52929. }
  52930. if m.id == nil || m.oldValue == nil {
  52931. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  52932. }
  52933. oldValue, err := m.oldValue(ctx)
  52934. if err != nil {
  52935. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  52936. }
  52937. return oldValue.APIKey, nil
  52938. }
  52939. // ClearAPIKey clears the value of the "api_key" field.
  52940. func (m *XunjiServiceMutation) ClearAPIKey() {
  52941. m.api_key = nil
  52942. m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
  52943. }
  52944. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  52945. func (m *XunjiServiceMutation) APIKeyCleared() bool {
  52946. _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
  52947. return ok
  52948. }
  52949. // ResetAPIKey resets all changes to the "api_key" field.
  52950. func (m *XunjiServiceMutation) ResetAPIKey() {
  52951. m.api_key = nil
  52952. delete(m.clearedFields, xunjiservice.FieldAPIKey)
  52953. }
  52954. // ClearAgent clears the "agent" edge to the Agent entity.
  52955. func (m *XunjiServiceMutation) ClearAgent() {
  52956. m.clearedagent = true
  52957. m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
  52958. }
  52959. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  52960. func (m *XunjiServiceMutation) AgentCleared() bool {
  52961. return m.clearedagent
  52962. }
  52963. // AgentIDs returns the "agent" edge IDs in the mutation.
  52964. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  52965. // AgentID instead. It exists only for internal usage by the builders.
  52966. func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
  52967. if id := m.agent; id != nil {
  52968. ids = append(ids, *id)
  52969. }
  52970. return
  52971. }
  52972. // ResetAgent resets all changes to the "agent" edge.
  52973. func (m *XunjiServiceMutation) ResetAgent() {
  52974. m.agent = nil
  52975. m.clearedagent = false
  52976. }
  52977. // Where appends a list predicates to the XunjiServiceMutation builder.
  52978. func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
  52979. m.predicates = append(m.predicates, ps...)
  52980. }
  52981. // WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
  52982. // users can use type-assertion to append predicates that do not depend on any generated package.
  52983. func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
  52984. p := make([]predicate.XunjiService, len(ps))
  52985. for i := range ps {
  52986. p[i] = ps[i]
  52987. }
  52988. m.Where(p...)
  52989. }
  52990. // Op returns the operation name.
  52991. func (m *XunjiServiceMutation) Op() Op {
  52992. return m.op
  52993. }
  52994. // SetOp allows setting the mutation operation.
  52995. func (m *XunjiServiceMutation) SetOp(op Op) {
  52996. m.op = op
  52997. }
  52998. // Type returns the node type of this mutation (XunjiService).
  52999. func (m *XunjiServiceMutation) Type() string {
  53000. return m.typ
  53001. }
  53002. // Fields returns all fields that were changed during this mutation. Note that in
  53003. // order to get all numeric fields that were incremented/decremented, call
  53004. // AddedFields().
  53005. func (m *XunjiServiceMutation) Fields() []string {
  53006. fields := make([]string, 0, 10)
  53007. if m.created_at != nil {
  53008. fields = append(fields, xunjiservice.FieldCreatedAt)
  53009. }
  53010. if m.updated_at != nil {
  53011. fields = append(fields, xunjiservice.FieldUpdatedAt)
  53012. }
  53013. if m.status != nil {
  53014. fields = append(fields, xunjiservice.FieldStatus)
  53015. }
  53016. if m.deleted_at != nil {
  53017. fields = append(fields, xunjiservice.FieldDeletedAt)
  53018. }
  53019. if m.xunji_id != nil {
  53020. fields = append(fields, xunjiservice.FieldXunjiID)
  53021. }
  53022. if m.agent != nil {
  53023. fields = append(fields, xunjiservice.FieldAgentID)
  53024. }
  53025. if m.organization_id != nil {
  53026. fields = append(fields, xunjiservice.FieldOrganizationID)
  53027. }
  53028. if m.wxid != nil {
  53029. fields = append(fields, xunjiservice.FieldWxid)
  53030. }
  53031. if m.api_base != nil {
  53032. fields = append(fields, xunjiservice.FieldAPIBase)
  53033. }
  53034. if m.api_key != nil {
  53035. fields = append(fields, xunjiservice.FieldAPIKey)
  53036. }
  53037. return fields
  53038. }
  53039. // Field returns the value of a field with the given name. The second boolean
  53040. // return value indicates that this field was not set, or was not defined in the
  53041. // schema.
  53042. func (m *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
  53043. switch name {
  53044. case xunjiservice.FieldCreatedAt:
  53045. return m.CreatedAt()
  53046. case xunjiservice.FieldUpdatedAt:
  53047. return m.UpdatedAt()
  53048. case xunjiservice.FieldStatus:
  53049. return m.Status()
  53050. case xunjiservice.FieldDeletedAt:
  53051. return m.DeletedAt()
  53052. case xunjiservice.FieldXunjiID:
  53053. return m.XunjiID()
  53054. case xunjiservice.FieldAgentID:
  53055. return m.AgentID()
  53056. case xunjiservice.FieldOrganizationID:
  53057. return m.OrganizationID()
  53058. case xunjiservice.FieldWxid:
  53059. return m.Wxid()
  53060. case xunjiservice.FieldAPIBase:
  53061. return m.APIBase()
  53062. case xunjiservice.FieldAPIKey:
  53063. return m.APIKey()
  53064. }
  53065. return nil, false
  53066. }
  53067. // OldField returns the old value of the field from the database. An error is
  53068. // returned if the mutation operation is not UpdateOne, or the query to the
  53069. // database failed.
  53070. func (m *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  53071. switch name {
  53072. case xunjiservice.FieldCreatedAt:
  53073. return m.OldCreatedAt(ctx)
  53074. case xunjiservice.FieldUpdatedAt:
  53075. return m.OldUpdatedAt(ctx)
  53076. case xunjiservice.FieldStatus:
  53077. return m.OldStatus(ctx)
  53078. case xunjiservice.FieldDeletedAt:
  53079. return m.OldDeletedAt(ctx)
  53080. case xunjiservice.FieldXunjiID:
  53081. return m.OldXunjiID(ctx)
  53082. case xunjiservice.FieldAgentID:
  53083. return m.OldAgentID(ctx)
  53084. case xunjiservice.FieldOrganizationID:
  53085. return m.OldOrganizationID(ctx)
  53086. case xunjiservice.FieldWxid:
  53087. return m.OldWxid(ctx)
  53088. case xunjiservice.FieldAPIBase:
  53089. return m.OldAPIBase(ctx)
  53090. case xunjiservice.FieldAPIKey:
  53091. return m.OldAPIKey(ctx)
  53092. }
  53093. return nil, fmt.Errorf("unknown XunjiService field %s", name)
  53094. }
  53095. // SetField sets the value of a field with the given name. It returns an error if
  53096. // the field is not defined in the schema, or if the type mismatched the field
  53097. // type.
  53098. func (m *XunjiServiceMutation) SetField(name string, value ent.Value) error {
  53099. switch name {
  53100. case xunjiservice.FieldCreatedAt:
  53101. v, ok := value.(time.Time)
  53102. if !ok {
  53103. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53104. }
  53105. m.SetCreatedAt(v)
  53106. return nil
  53107. case xunjiservice.FieldUpdatedAt:
  53108. v, ok := value.(time.Time)
  53109. if !ok {
  53110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53111. }
  53112. m.SetUpdatedAt(v)
  53113. return nil
  53114. case xunjiservice.FieldStatus:
  53115. v, ok := value.(uint8)
  53116. if !ok {
  53117. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53118. }
  53119. m.SetStatus(v)
  53120. return nil
  53121. case xunjiservice.FieldDeletedAt:
  53122. v, ok := value.(time.Time)
  53123. if !ok {
  53124. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53125. }
  53126. m.SetDeletedAt(v)
  53127. return nil
  53128. case xunjiservice.FieldXunjiID:
  53129. v, ok := value.(uint64)
  53130. if !ok {
  53131. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53132. }
  53133. m.SetXunjiID(v)
  53134. return nil
  53135. case xunjiservice.FieldAgentID:
  53136. v, ok := value.(uint64)
  53137. if !ok {
  53138. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53139. }
  53140. m.SetAgentID(v)
  53141. return nil
  53142. case xunjiservice.FieldOrganizationID:
  53143. v, ok := value.(uint64)
  53144. if !ok {
  53145. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53146. }
  53147. m.SetOrganizationID(v)
  53148. return nil
  53149. case xunjiservice.FieldWxid:
  53150. v, ok := value.(string)
  53151. if !ok {
  53152. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53153. }
  53154. m.SetWxid(v)
  53155. return nil
  53156. case xunjiservice.FieldAPIBase:
  53157. v, ok := value.(string)
  53158. if !ok {
  53159. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53160. }
  53161. m.SetAPIBase(v)
  53162. return nil
  53163. case xunjiservice.FieldAPIKey:
  53164. v, ok := value.(string)
  53165. if !ok {
  53166. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53167. }
  53168. m.SetAPIKey(v)
  53169. return nil
  53170. }
  53171. return fmt.Errorf("unknown XunjiService field %s", name)
  53172. }
  53173. // AddedFields returns all numeric fields that were incremented/decremented during
  53174. // this mutation.
  53175. func (m *XunjiServiceMutation) AddedFields() []string {
  53176. var fields []string
  53177. if m.addstatus != nil {
  53178. fields = append(fields, xunjiservice.FieldStatus)
  53179. }
  53180. if m.addxunji_id != nil {
  53181. fields = append(fields, xunjiservice.FieldXunjiID)
  53182. }
  53183. if m.addorganization_id != nil {
  53184. fields = append(fields, xunjiservice.FieldOrganizationID)
  53185. }
  53186. return fields
  53187. }
  53188. // AddedField returns the numeric value that was incremented/decremented on a field
  53189. // with the given name. The second boolean return value indicates that this field
  53190. // was not set, or was not defined in the schema.
  53191. func (m *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
  53192. switch name {
  53193. case xunjiservice.FieldStatus:
  53194. return m.AddedStatus()
  53195. case xunjiservice.FieldXunjiID:
  53196. return m.AddedXunjiID()
  53197. case xunjiservice.FieldOrganizationID:
  53198. return m.AddedOrganizationID()
  53199. }
  53200. return nil, false
  53201. }
  53202. // AddField adds the value to the field with the given name. It returns an error if
  53203. // the field is not defined in the schema, or if the type mismatched the field
  53204. // type.
  53205. func (m *XunjiServiceMutation) AddField(name string, value ent.Value) error {
  53206. switch name {
  53207. case xunjiservice.FieldStatus:
  53208. v, ok := value.(int8)
  53209. if !ok {
  53210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53211. }
  53212. m.AddStatus(v)
  53213. return nil
  53214. case xunjiservice.FieldXunjiID:
  53215. v, ok := value.(int64)
  53216. if !ok {
  53217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53218. }
  53219. m.AddXunjiID(v)
  53220. return nil
  53221. case xunjiservice.FieldOrganizationID:
  53222. v, ok := value.(int64)
  53223. if !ok {
  53224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  53225. }
  53226. m.AddOrganizationID(v)
  53227. return nil
  53228. }
  53229. return fmt.Errorf("unknown XunjiService numeric field %s", name)
  53230. }
  53231. // ClearedFields returns all nullable fields that were cleared during this
  53232. // mutation.
  53233. func (m *XunjiServiceMutation) ClearedFields() []string {
  53234. var fields []string
  53235. if m.FieldCleared(xunjiservice.FieldStatus) {
  53236. fields = append(fields, xunjiservice.FieldStatus)
  53237. }
  53238. if m.FieldCleared(xunjiservice.FieldDeletedAt) {
  53239. fields = append(fields, xunjiservice.FieldDeletedAt)
  53240. }
  53241. if m.FieldCleared(xunjiservice.FieldAPIBase) {
  53242. fields = append(fields, xunjiservice.FieldAPIBase)
  53243. }
  53244. if m.FieldCleared(xunjiservice.FieldAPIKey) {
  53245. fields = append(fields, xunjiservice.FieldAPIKey)
  53246. }
  53247. return fields
  53248. }
  53249. // FieldCleared returns a boolean indicating if a field with the given name was
  53250. // cleared in this mutation.
  53251. func (m *XunjiServiceMutation) FieldCleared(name string) bool {
  53252. _, ok := m.clearedFields[name]
  53253. return ok
  53254. }
  53255. // ClearField clears the value of the field with the given name. It returns an
  53256. // error if the field is not defined in the schema.
  53257. func (m *XunjiServiceMutation) ClearField(name string) error {
  53258. switch name {
  53259. case xunjiservice.FieldStatus:
  53260. m.ClearStatus()
  53261. return nil
  53262. case xunjiservice.FieldDeletedAt:
  53263. m.ClearDeletedAt()
  53264. return nil
  53265. case xunjiservice.FieldAPIBase:
  53266. m.ClearAPIBase()
  53267. return nil
  53268. case xunjiservice.FieldAPIKey:
  53269. m.ClearAPIKey()
  53270. return nil
  53271. }
  53272. return fmt.Errorf("unknown XunjiService nullable field %s", name)
  53273. }
  53274. // ResetField resets all changes in the mutation for the field with the given name.
  53275. // It returns an error if the field is not defined in the schema.
  53276. func (m *XunjiServiceMutation) ResetField(name string) error {
  53277. switch name {
  53278. case xunjiservice.FieldCreatedAt:
  53279. m.ResetCreatedAt()
  53280. return nil
  53281. case xunjiservice.FieldUpdatedAt:
  53282. m.ResetUpdatedAt()
  53283. return nil
  53284. case xunjiservice.FieldStatus:
  53285. m.ResetStatus()
  53286. return nil
  53287. case xunjiservice.FieldDeletedAt:
  53288. m.ResetDeletedAt()
  53289. return nil
  53290. case xunjiservice.FieldXunjiID:
  53291. m.ResetXunjiID()
  53292. return nil
  53293. case xunjiservice.FieldAgentID:
  53294. m.ResetAgentID()
  53295. return nil
  53296. case xunjiservice.FieldOrganizationID:
  53297. m.ResetOrganizationID()
  53298. return nil
  53299. case xunjiservice.FieldWxid:
  53300. m.ResetWxid()
  53301. return nil
  53302. case xunjiservice.FieldAPIBase:
  53303. m.ResetAPIBase()
  53304. return nil
  53305. case xunjiservice.FieldAPIKey:
  53306. m.ResetAPIKey()
  53307. return nil
  53308. }
  53309. return fmt.Errorf("unknown XunjiService field %s", name)
  53310. }
  53311. // AddedEdges returns all edge names that were set/added in this mutation.
  53312. func (m *XunjiServiceMutation) AddedEdges() []string {
  53313. edges := make([]string, 0, 1)
  53314. if m.agent != nil {
  53315. edges = append(edges, xunjiservice.EdgeAgent)
  53316. }
  53317. return edges
  53318. }
  53319. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  53320. // name in this mutation.
  53321. func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
  53322. switch name {
  53323. case xunjiservice.EdgeAgent:
  53324. if id := m.agent; id != nil {
  53325. return []ent.Value{*id}
  53326. }
  53327. }
  53328. return nil
  53329. }
  53330. // RemovedEdges returns all edge names that were removed in this mutation.
  53331. func (m *XunjiServiceMutation) RemovedEdges() []string {
  53332. edges := make([]string, 0, 1)
  53333. return edges
  53334. }
  53335. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  53336. // the given name in this mutation.
  53337. func (m *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
  53338. return nil
  53339. }
  53340. // ClearedEdges returns all edge names that were cleared in this mutation.
  53341. func (m *XunjiServiceMutation) ClearedEdges() []string {
  53342. edges := make([]string, 0, 1)
  53343. if m.clearedagent {
  53344. edges = append(edges, xunjiservice.EdgeAgent)
  53345. }
  53346. return edges
  53347. }
  53348. // EdgeCleared returns a boolean which indicates if the edge with the given name
  53349. // was cleared in this mutation.
  53350. func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
  53351. switch name {
  53352. case xunjiservice.EdgeAgent:
  53353. return m.clearedagent
  53354. }
  53355. return false
  53356. }
  53357. // ClearEdge clears the value of the edge with the given name. It returns an error
  53358. // if that edge is not defined in the schema.
  53359. func (m *XunjiServiceMutation) ClearEdge(name string) error {
  53360. switch name {
  53361. case xunjiservice.EdgeAgent:
  53362. m.ClearAgent()
  53363. return nil
  53364. }
  53365. return fmt.Errorf("unknown XunjiService unique edge %s", name)
  53366. }
  53367. // ResetEdge resets all changes to the edge with the given name in this mutation.
  53368. // It returns an error if the edge is not defined in the schema.
  53369. func (m *XunjiServiceMutation) ResetEdge(name string) error {
  53370. switch name {
  53371. case xunjiservice.EdgeAgent:
  53372. m.ResetAgent()
  53373. return nil
  53374. }
  53375. return fmt.Errorf("unknown XunjiService edge %s", name)
  53376. }